LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Termination character for RS232 Instrument

I have an instrument that I am trying to communicate with via RS232.  I am having a difficult time figuring out how to write a command to the instrument using the VISA write VI.  I am able to successfully communicate with the instrument using a software program called Terminal (similar to hyperterminal).  A typical command starts and ends with ^m in Terminal.  For example, here is the command ^md01v00,00^m that returns the heat rate.  How do I write this command in the VISA write VI?  Is the ^m an unprintable character in LabVIEW that is represented in some other format?

 

   

Download All
0 Kudos
Message 1 of 8
(10,765 Views)
It's probable that the ^m is a CTRL-M which is the CR character. You can use the Carriage Return Constant that is on the string palette with a Concantanate String function or you can set your string control/constant to '\' Codes Display and use \r for a CR. Have you looked at the shipping example called Basic Serial Write and Read? That uses a \r\n (CR\LF) in it's default string to write. To set the display mode, just right click on the string control/constant.
0 Kudos
Message 2 of 8
(10,762 Views)
I have already tried that and it does not work.
0 Kudos
Message 3 of 8
(10,756 Views)
Your example does not show you doing any of that. Did you try it with the shipping example or something else? What does the manual for the instrument say you need to do? Is this 'terminal' program something you got from the instrument vendor?
0 Kudos
Message 4 of 8
(10,750 Views)
The problem is you are not using the right character in your string to write.  You are using a hex 02 (shows up as a box in normal mode and \02 in \codes).  That is equivalent to a control-B.  You need to either use the carriage return constant off the string palette, use a \r in \codes display like Dennis says, or use a hex 0D in hex codes display.
0 Kudos
Message 5 of 8
(10,740 Views)

I did try the <CR+LF> constant before starting to play with other characters (as shown in the VI I posted) but did not get the communication to work.  I just recently changed the terminating character back to <CR+LF> and added a 500 ms time delay between the VISA read and write VIs, which solved the communication problem.  Now I'm running into a new problem where I get the error message "A framing error occurred during transfer".  My communication port is set properly as the device settings.  I think that there is no noise in my cable (because the manufacturer's software reads fine at the same rate I'm reading).  What could possibly be wrong? 

0 Kudos
Message 6 of 8
(10,713 Views)

Hi SumTumWong,

 

I'm thrilled to hear that you resolved your serial communication issue.  As for your framing error that occurs, this is a common issue and we have a Knowledge Base article that explains what this error in full and how to resolve it.  The most common reason why this error occurs is that your serial port and device are configured to use a different settings.  The article shows how make sure that the settings of both your serial port and device are configured properly using Measurement & Automation Explorer (MAX).  Let us know if you have any more questions.  Have a great day!

 

Regards,

 

Todd Venable

 

National Instruments
Applications Engineer
NI Prototyping Community
0 Kudos
Message 7 of 8
(10,693 Views)
I solved my problem by using a serial com port sniffer (downloaded from www.hhdsoftware.com) to view the commands being sent to the instrument and monitoring commands recieved from the instrument.  Thanks all.
0 Kudos
Message 8 of 8
(10,656 Views)