Communicating with LI-COR instruments using LabVIEW

Printable PDF: Communicating with LI-COR instruments using LabVIEW

(communicating-with-LabVIEW.pdf)

Download this content as a pdf that can be saved to your computer or printed.

LabVIEW™ is a graphical programming language from National Instruments, mainly used for data acquisition, instrument control and industrial automation. Since most LI-COR environmental instrument have some sort of digital interface such as serial or Ethernet, you can communicate, control, and collect data from these instruments using LabVIEW. The purpose of this application note is to provide a primer for developing LabVIEW scripts for interacting with some LI-COR gas analyzers. This note does not provide drivers or code to collect or process the data. The example scripts included are very basic scripts and don’t perform any particular function other than read in the data and display it. These scripts can be easily modified to suit any purpose. Several aspects of the instrument grammar is also used in the scripts and it is essential to refer back to the grammar section of the instrument user manual to fully understand or modify the implementation.

LI-820 and LI-840/A example script

(LI-840.vi)

Sample script to read data in LabVIEW

LI-6262 and LI-6251 example script

(LI-6262.vi)

Sample script to read data in LabVIEW

LI-7000 example script

(LI-7000.vi)

Sample script to read data in LabVIEW

LI-7500A/RS and LI-7200/RS example script

(LI-7200.vi)

Sample script to read data in LabVIEW

LI-7700 example script

(LI-7700.vi)

Sample script to read data in LabVIEW

LI-6262 and LI-6251

The LI-62XX series of analyzers has a serial port for digital communications and LabVIEW can be used to read the serial port. The serial port settings on the 62XX instrument should be set using keypad FCT17. The variables that have to be measured can be set by sending the *13x,x,x,x,x,x,x,x,x,x, where x is the channels you want to output. By writing *12 to the serial port along with a carriage return (serial write block), the data will be sent out and it can be read by using the serial read block. Writing and reading of the instrument data can be done in a simple while loop. The instrument is polled for data and it can be read continuously at a rate set by a LabVIEW timer. In the example below, channels 22, 23 29, 32, 33, 38, 39, 42 and 43 are configured to be sent out through the serial port. The serial setting property node is used to estimate the number of bytes at the port and then this information is fed to the serial read block to read in the data. To parse out and plot the data, search and replace vi and spread sheet string to array vi are used.

LI-7200/RS and LI-7500A/RS

The LI-7200 and LI-7500A gas analyzers have Ethernet and RS-232 connectivity. Ethernet connectivity is much more flexible and allows connectivity to a device on a home or remote network. The instrument transmits data at a fixed output rate, which is configured in the instrument settings. Since network data transmission is susceptible to latencies, the best practice is to use the time stamp from the instrument, rather than time stamping the data based on arrival to the computer.

A reliable way to get complete data packets from the instrument is to set its output rate to zero and then poll for data from the instrument. In this way you can expect predictable amount of data from the instrument and then read the expected number of bytes. The LI-7200 and LI-7500A/RS communicates through TCP port 7200. LabVIEW TCP write and read blocks can be used to interact with the instrument and read the data. The instrument grammar gives the option to add a carriage return and line feed to the end of a data stream. Enable this option in the instrument, then utilize the CRLF mode in the “TCP read” block. This configuration will wait for a carriage return followed by a line feed in the data stream to stop reading the data. Set the interactive mode in the instrument to false (IM FALSE) to suppress acknowledgments and other messages from the instrument. Configure the desired outputs through the outputs tab in the instrument software. Select the “bytes to read” parameter of the “TCP Read” block to match or exceed the size of the data message coming from the instrument. The best practice is to set “bytes to read” to a large value and “timeout ms” to a small value for the “TCP read” block so that the read operation is carried out efficiently.

In the above example, the data is read at 10 Hz, the number of bytes to read is set at 700 and the variable pressure is parsed out of the output string and converted into a number. Any variable measured by the analyzer can be parsed out easily using the labels present in the data stream and plotted.

LI-7700

The LI-7700 can be read in a similar way as the LI-7200/RS or LI-7500A/RS using TCP/IP blocks. The LI-7700 communicates over TCP port 7700 and the data stream does not come mixed with labels or terminated with any special character. In this case the strategy will be to set the output rate to zero and then poll for data from the instrument. As the data comes in, the “TCP read” block can be set to the immediate mode, so that whatever data appears at the port is immediately read, rather than waiting for a specific number of bytes or a particular termination character. As you open TCP/IP communications and write commands to the instrument to configure it, the instrument initially send out its current status, which includes information like the firmware version number, serial number instrument name and the data headers. Immediately after the configuration header, the LI-7700 will start sending out the data. An initial “TCP read” call will retrieve this header information. The headers are used to locate the position of the various variables with the data stream. The data output also includes diagnostic information and waveform information which should be turned off during the initial configuration.

In the example below, the output rate is initially set to zero and the status and waveform data is switched off. An initial read is done outside the main program loop to read in the headers and other information and data is polled inside the main program loop and read with a TCP/IP read block. The expected number of bytes at the port is set to about 500 and TCP read mode is set to immediate. The timeouts are kept short and the read text data can be easily parsed out and formatted. The data can be split out using spread sheet string to array vi and then indexed out and plotted.

LI-820, LI-840/A, LI-830, and LI-850

The LI-820, LI-840/A, LI-830 and LI-850 analyzers use a subset of the XML language to communicate with an external device. The same methodology adopted for other LI-COR devices can be adapted here, by setting the output rate to 0 and then polling for data. The data can be stripped off the tags and just read in as numbers or the tags can be left on the data stream to parse the numbers using the information in the tags. There is an <ECHO> command which echoes the commands sent to the LI-840(A) and this option should be set to FALSE to get a more consistent output from the instrument.

In the example below, the output rate is first set to 0 and the needed outputs are set to true. The XML tags are enabled by setting the STRIP option to TRUE and the ECHO is set to FALSE. The serial port is configured with a baud rate of 9600 and data is requested inside a while loop. The bytes at the port is determined and is sent to the “Visa Read” block to read the data coming out of the port.

The data can be parsed out using labels and variables can be plotted on a chart after converting the string to a number.