LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Decoding serial data.

Solved!
Go to solution

I am working with an Li-800 gas analyzer and I am trying to extract a CO2 measurement from a serial feedback I get from the instrument.  Unfortunately the documentation for doing this is limited and I am stuck. 

 

I can successfully poll the instrument and get a package of information back from it.  In the “normal view” in my string indicator, the result is gibberish.  When I switch to hex view I get something like this:

 

062A 0028 9838 3895 9884 DA76 960F DB3C 92FA BC26 8F1F D31E 8A56 291D 8104 3000 0000 0000 0000 0000 8056 362E 0000 0000 8746 0000 8921 9333 337D 5DF0 2964 000A  

 

The documentation I have says the instrument should send a 89-byte configuration packet.  In looking at this package, I only see 64 bytes.  The CO2 information is supposed to be encoded in bytes 64 and 65.  The conversion for calculating the CO2 is:

 

CO2 = (256*config(64) + config(65))/scaling factor; (I think the scaling factor is 8.192)

 

I have some software that comes with the unit and it says the CO2 at the time I got this configuration package was 2264 ppm. 

 

When I successively poll the device, the bytes in the position occupied by bytes 5DF0 and 2964 change regularly.  The 337D byte changes slightly and the rest of the package doesn’t change. 

 

The package is also to supposed to encode the cell temperature (51.8), cell pressure (978) and supply voltage (16.7).  These are supposed to be in bytes 68-69, 72-73, and 77-78 respectively.  The general conversion formula for all of these is:

 

Parameter = o + (256*hb +lb)/s; where hb = high byte, lb = low byte, s = scaling, o = offset

 

I am pretty sure offset is 0 for all parameters except for temperature which is -20.  The scaling factor for temperature is 8.192, for pressure is 0.8192, and for voltage is 148.945. 

 

Any thoughts on this problem?

 

Thanks.

0 Kudos
Message 1 of 23
(6,381 Views)

Hi CoreyNE,

did you set the correct termination character? From your data i think you use the default "0xA" and that could be the reason for only 64 bytes instead of 89.

 

Mike

Message 2 of 23
(6,377 Views)
Do you have the termination character enabled on your VISA read?  I noticed that your last byte is 0A which is 10 decimal or the New Line character.  I'm thinking that you have the termination character enabled and your VISA read is being cut short from the 89 bytes you are expecting because of it.
Message 3 of 23
(6,378 Views)
Try to turn off the enable term char option in the "Visa Configure Serial port.vi" I saw the last byte was 0A and this is the termination char by default


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 4 of 23
(6,373 Views)
I am using the VISA Open vi and setting my COM properties through that (via a property node) every time I poll the device.  I checked the termination character enable setting through the property node and its default is false.  But tonight I will try hard wiring it to be 100% sure that it is not enabled.
0 Kudos
Message 5 of 23
(6,345 Views)
You do not have use VISA open every time you poll your com port. You use it before you enter your main program loop, and close it after you have left your main program loop. 


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 6 of 23
(6,338 Views)

Cory

 

You set the Termination properties with a Proerty node.

Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
0 Kudos
Message 7 of 23
(6,328 Views)

I made sure the termination character was disabled but I get the same result.  Maybe the documentation is incorrect in how many bytes are supposed to be returned.

0 Kudos
Message 8 of 23
(6,299 Views)
Solution
Accepted by topic author CoreyNE

There are two term char enables properties, one for transmit and one for recieve.

 

Try using a property node after your read to see if there are more bytes waitng to be read.

 

If you post your code we could help clear up some of the more subtle points.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 9 of 23
(6,293 Views)

Here's the code as it stands now.  There is not much to it.  Once I have it working it will serve as a sub-routine in a larger data acquisition program.

 

Corey

0 Kudos
Message 10 of 23
(6,279 Views)