LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from CO2 sensor connected to the PC

Solved!
Go to solution

Hey everyone

 

I am facing a challenging problem. I have a CO2 sensor connected to the PC that I want to be able to read from and display it on a waveform graph. The main problem is to be able to read from the sensor in labview. I got a software program with the sensor but I want to be able to display it in labview together with the other sensor I have so that I wont need to have both labview and the software open at the same time. How do I accomplish that? I added a picture of the sensor aswell with some manuals. Thanks!

 

Greetings

DP

0 Kudos
Message 1 of 63
(5,595 Views)
Solution
Accepted by topic author DP123

The sensor has what looks like an FTDI USB to Serial cable attached to it - so you'll be using NI VISA to communicate with the sensor.

Page 4 of the manual defines the parameters you must use (e.g. baud rate etc.) and page 5 gives the format of the commands sent by the sensor (an ASCII string with a \r\n carriage return / line feed termination - "Z ##### z #####\r\n").

 

Look at the NI VISA examples to get started - you will want to use a termination character (\n) to help you separate the commands.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 63
(5,563 Views)

Hi Sam

 

Okey I have been playing around with the "Continuous serial read and write vi" and it seems to read similiar data as the software that came with the sensor. Is it correct of me to put an "A" as termination character? Second if I want to display the data on a waveform chart how do I do that?

Greetings

DP

0 Kudos
Message 3 of 63
(5,545 Views)

Hi Sam

 

Okey I have been playing around with the "Continuous serial read and write vi" and it seems to read similiar data as the software that came with the sensor. Is it correct of me to put an "A" as termination character? Second if I want to display the data on a waveform chart how do I do that?

 

Greetings

DP

0 Kudos
Message 4 of 63
(5,545 Views)
Yes - 0xA is the newline character (\n) so that is correct.

To display the data in a waveform chart, you will need to convert the string data to a numeric. The easiest way would probably be to use the 'scan from string' function. Use "Z %f z %f" as the format string and then wire the output(s) into a waveform chart (depending on whether you want the filtered/unfiltered data). You may also need to apply some scaling as per the manual.

LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 5 of 63
(5,542 Views)

This is what I did. I did not add any scaling yet but nothing is showing up on the chart. Whats wrong ?

Thanks alot for helping out.

 

Greetings

DP

0 Kudos
Message 6 of 63
(5,536 Views)

I can't open your VI as I only have LV2014. If you can save it for LV2014, I'll take a look.

Try using probes and check the error wires to see what is happening. If you are reading the string data correctly, it might be that the format string is slightly wrong (e.g. there's still a \r character in there - so you could add a trim whitespace to remove it).


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 7 of 63
(5,530 Views)
0 Kudos
Message 8 of 63
(5,526 Views)

Hi DP,

 

nothing is showing up on the chart. Whats wrong ?

Well, it's wrong to connect the VISA reference to a ScanFromString function and to expect to get some device readings by this!

You need to parse the response string you get from VISARead! And you should connect the chart with a data source: no wire, no data to display!

(And maybe it's a good idea NOT to collect all read data in this string…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 63
(5,505 Views)
Solution
Accepted by topic author DP123

I strongly suggest you take some of the LabVIEW tutorials as the error you have made is very basic and you would have easily found the problem if you had probed the input to your scan from string function.

 

You have the 'VISA Reference' (which contains the name of your serial port) wired to the input of the scan from string node. You need to wire the string data coming out of the 'VISA read' node (which contains the data being read from the device) into the scan from string.

 

Capture.PNG


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 10 of 63
(5,503 Views)