LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I read temperatures from a serial port using LabVIEW?

I have 28 thermocouples measuring the temperatures of various trays in a distillation column.  The thermocouples are connected to a few different CBCom 8 Channel Voltage and Thermocouple Input Modules (Model CB-7018), which are then connected to a CBCom Isolated RS-232 to RS-485 Converter (Model CB-7520) that connects to the computer via a serial cable (9 pins).
 
My goal is to have the 28 temperatures continuously displayed in LabVIEW (version 8.5).
 
However, this is my first time using LabVIEW with a serial port, so I am unsure when, and whether or not I need to, use the various Serial functions under the Instrument I/O.  I'm also confused on what all the inputs to the functions mean.
 
Any help/suggestions would be greatly appreciated.
 
Thanks!
0 Kudos
Message 1 of 21
(5,727 Views)
The first I would do if I were you is spend some time learning LabVIEW:

To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

Once you do that you can take a look at the examples that ship with LabVIEW that show you how to do serial I/O. Help -> Find Examples. Then change to the Search tab and enter "serial". There's a "Basic Serial Write and Read" VI.
0 Kudos
Message 2 of 21
(5,725 Views)

I am pretty familiar with LabVIEW already, just not with aquiring data using Serial Ports (I've written a process control program and a DAQ program using FieldPoint modules).  I already opened and looked at the basic serial read/write example and did various searches on NI on how to use the serial read/write functions, but I still don't quite understand how it all works together.

Any other help/suggestions from anyone would be great!

Thanks.

0 Kudos
Message 3 of 21
(5,715 Views)
Well, there's not much to it. The two main functions you're going to use is VISA Write and VISA Read. The VISA Write only has 2 inputs to use (aside from the error in)m and the VISA Read also only has 2 inputs. The VISA resource name input is how to refer to the serial port in VISA. This can be an alias, like "COM1" if an alias has been set in Measurement & Automation Explorer. Otherwise it would of the form ASLR[n]::INSTR, where n is the COM port number (e.g., ASRL1::INSTR).

What exactly is confusing you? Is it the inputs on the VISA Configure Serial Port? Those are just standard serial port communication settings, and dependent on the device you're talking to.
0 Kudos
Message 4 of 21
(5,708 Views)
I guess I'm not exactly sure what 'parity' and 'flow control' are or what their functions are.   Also, I am unsure of what I am supposed to write to the device in order for it to read and individually display all of the 28 different temperatures.
 
When running the Basic Serial Write and Read VI, my settings are the default values which match my port properties (baud rate=9600, data bits=8, parity=none, stop bits=1.0, flow control=none, delay before read=500) and the 'string to write' is *IDN?\r\n.  However, nothing is displayed in the 'read string' or 'bytes read' boxes during a run.  Is this because the 'string to write' is wrong?
 
Thanks for your help!
0 Kudos
Message 5 of 21
(5,700 Views)
If you right-click on the VISA Configure Serial Port VI and select "Help" from the popup menu you'll get the Help page describing those inputs. Those all define the communication protocol, and is device dependent. I'm not familiar with the CB-7018, but this thread mentions that the settings to use are 9600 Baud, 8 Bit, No parity, 1 stop, no flow control. To know more about the individual parameters you can find more information with this KB article: Serial Communication Overview.

According to the manual the *IDN? command is not recognized by the CB-7018. You need to check the documentation for a device to see what the commands are. Typically the thing you have to watch out for with serial is whether or not you have to append a carriage return and/or linefeed character(s) to the command string. Page 20 of the User Manual for the CB7018 shows you what the command syntax is as well as all the commands. This shows that the commands need to end with a checksum, followed by a carriage return character.
   
Second, you need to tell VISA whether or not it should automatically end a read when it sees a certain character. Typically the linefeed character is used to indicate the end of a message from an instrument. The default configuration for the VISA Configure Serial Port uses this setup. For the CB-7018 the User Manual indicates that the carriage return ends a message from the device. Thus, for the
VISA Configure Serial Port you have to set the termination char input to a value of 13, which is the ASCII value for a carriage return.
0 Kudos
Message 6 of 21
(5,691 Views)
Thank you for the link to the user manual.  It is a very helpful learning tool (considering there is no hard copy to be found in our lab).
 
Thanks for your suggestions as well... I changed the 'termination char' input to 13 to signify a carriage return.  However, no matter what code I enter into the 'string to write' box, I still don't get an output in the 'read string' box and the 'bytes read' is always 0.  I'm not sure if I'm entering the code incorrectly or if I have the wrong settings for the VISA Configure Serial Port.  The settings I'm using are the same as those mentioned in an earlier message (9600 Baud, 8 Bit, No parity, 1 stop, no flow) and an example of a code I used in the 'string to write' box (with Normal Display) is: $AAM(cr), with AA being 00, 01, 02, 03, etc..., when I try to read the module name.
 
On p.20 of the manual, it shows the Command Format as (Leading)(Address)(Command)[CHK](cr).  Is (Leading) the delimiter character and (Address)=AA, or are they something different and the delimiter character and AA are actually part of (Command)?
 
Thanks again for your help!  I appreciate it!
0 Kudos
Message 7 of 21
(5,645 Views)
"Leading" indicates the first character in the command string. There are different command sets, and each command set has its own leading character. "Address" is the 2-character address of your module: 01, 02, 03, etc.

In the string to write are you actually entering "$01M(cr)"? The (cr) is supposed to indicate that you need to append a carriage return to the command. This means that if you're using the Basic Serial Write and Read example, the string to write control should have this: $01M\r, where \r indicates a carriage return. This assumes you have checksum disabled. Do you have checksum enabled or disabled on the module? The default seems to be disabled.

If that doesn't work I would recommend opening up HyperTerminal and try to send a command that way to verify the communication link. In HyperTerminal to send the command you just need to enter $01M at the prompt and then press the "Enter" key on the keyboard to enter a carriage return. Make sure LabVIEW isn't running when you run HyperTerminal.
0 Kudos
Message 8 of 21
(5,640 Views)
I really have no idea how to even check to see if checksum is enabled or disabled on the modules.
 
Also, I ran HyperTerminal and did a serial port test, which resulted in me being able to see double characters.  But, when I plugged the cable back in and sent the command $01M, it didn't return anything (I also tried 00, 02, 03, etc...).  I know that there's communication with the modules, because there's another program on the computer that is able to acquire and display all of the various temperatures. 
 
I'm assuming that the problem is with the code I enter in 'string to write'?? .... At least that could be a simpler fix.  Any other suggestions?
 
Thanks again!
0 Kudos
Message 9 of 21
(5,630 Views)
You could try running NI-SPY while the other program is running to try to capture the commands it is sending.  Also run it with yours and do a comparison.
0 Kudos
Message 10 of 21
(5,610 Views)