12-29-2013 01:51 PM
Hello All,
I am new to the forums here. I need help converting the following code for use in LabVIEW. The data is coming in using rs232 format in ASCII. The bits are manchester encoded. I have setup the normal vi for reading serial data but when indexing it in an array the data is all over the place and inconsistent. Your help would be greatly appreciated.
'SERIAL NUMBER
Cells(24, 3) = Chr(ReadValue(0)) & Chr(ReadValue(1)) & Format(Str((CVar(ReadValue(2)) * 65536) + (CVar (ReadValue(3)) * 256) + (CVar(ReadValue(4)))), "00000")
'PART NUMBER
PNRval = Format(Str(CVar(ReadValue(5)) * 65536) + (CVar(ReadValue(6)) * 256) + (CVar(ReadValue(7))), "00000")
Cells(25, 3) = "X" & Mid(PNRval, 1, 2) & "-" & Mid(PNRval, 3, 3)
'STATUS
Cells(26, 3) = CVar(ReadValue(8))
Cells(row, 24) = Cells(26, 3)
'Pressure
Cells(27, 3) = ((CVar(ReadValue(9)) * 256) + CVar(ReadValue(10))) / 100
Cells(row, 21) = Cells(27, 3)
'SensTmp
If (ReadValue(11) > 127) Then
Cells(28, 3) = (((CVar(ReadValue(11)) * 256) + CVar(ReadValue(12))) / 100) - 655.36
Else
Cells(28, 3) = ((CVar(ReadValue(11)) * 256) + CVar(ReadValue(12))) / 100
End If
Cells(row, 22) = Cells(28, 3)
'ElecTmp
If (ReadValue(13) > 127) Then
Cells(29, 3) = (((CVar(ReadValue(13)) * 256) + CVar(ReadValue(14))) / 100) - 655.36
Else
Cells(29, 3) = ((CVar(ReadValue(13)) * 256) + CVar(ReadValue(14))) / 100
End If
Cells(row, 23) = Cells(29, 3)
Cells(30, 3) = "PASS"
Cells(row, 25) = 1
'Cells(row, 26) = " "
12-29-2013 02:28 PM
Manchester encoding is typically used for synchronous communications and RS-232 is asynchrounous. ASCII has nothing to do with how the bits are encoded. So what are you really doing?
What is that "code" supposed to do? What language is it?
What do you actaully receive in your array when you read serial? The "normal" serial VI does not generate an array.
Exactly what do you mean by "...data is all over the place and inconsistent."? Is some of the data at one latitude and other parts at a different latitude?
Please run your VI until you have some data. Make the current value default and svve the VI. Then post that VI with the data. Tell us exactly what bytes were transmitted and exactly what you think the output should be.
Lynn
12-29-2013 02:38 PM
Thanks Lynn,
Let me clarify. I was stating that the data in the module uses manchester encoding. It outputs data on the serial port and I am reading that into the computer using a rs232 to usb adapter. I am converting the string to decimal using the unsigned byte array then indexing it from there. I will upload the data shortly.
12-31-2013 06:31 PM
The stream looks like this: ªªeZeiUUUUUYUUVši¦. ASCII characters, it takes 18 bytes to send a message.
12-31-2013 06:45 PM
What should the resulting data for that string look like?
Lynn
12-31-2013 07:07 PM
Preamble |
1 |
Byte to stablise the DC component signal |
serial number |
5 |
Serial number of the unit: - 2 Bytes for the 2 ASCII characters (AA to ZZ) |
part number |
3 |
Part Number of the unit( The last 5 numbers SSHHh):
|
Status |
1 |
Byte indicating the status |
Sensor pressure |
2 |
Value of the measured sensor pressure : 2 Bytes (unsigned integer) with 16 significant bits, decimal value x100 (0.00 to 655.35 psi) |
Sensor temp |
2 |
Value of the measured sensor temp : 2 Bytes (signed integer) with 1 sign bit and 15 significant bit, decimal value x100 (-327.68 à +327.67°C) |
E. temperature |
2 |
Value of the measured E. temperature : 2 Bytes (signed integer) with 1 sign bit and 15 significant bit, decimal value x100 (-327.68 à +327.67°C) |
Checksum |
2 |
Arithmetic sum of Bytes on the message frame (without preamble and checksum) |
12-31-2013 07:34 PM
12-31-2013 08:00 PM
The format you posted does not match the stream in your previous post.
The second and third bytes are not an upper case ASCII letters. How are the three-byte numbers (0 to 99999) encoded? Unsigned integer? which is the most significant bit? On the two-byte integers is the most significant byte first or second?
Again, what should the result be for the string you posted?
Lynn