LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

termination character on/off

Hi,

I am using an USB to RS 485 converter. In the RS 485 line there are several instruments connected. Some use termination characters CR/LF (Hex  03 0D), one uses Hex  03 0D 0A FF. The communication goes through COM 1, calling each instrument by an individual hex address. I can access all instruments with a terminal program, but no response with Labview and Visa (error -1704001663). I make sure, that to address every individual instrument I open and close the port for this call. For calling the last instrument, I set use termination character to N in VISA configure serial port. I set that to Y when calling the other instruments.Is there another way I could try?

 

0 Kudos
Message 1 of 5
(2,829 Views)

Are you sure about that error number?  -1704001663 is undefined when I tried looking it up.

 

Are you sure you are sending the data in the same way out of LabVIEW as you are in the terminal program?  Do you need a termination character on the end of the command you send to the instrument such as carriage return or line feed?   If you are using a string control, make sure that if it has a \r at the end, you are actually in \codes display and not just normal display.  In \codes, \r is a carriage return.  In normal display, if you see \r, you are sending two distinct characters a "\" and an "r".

Message 2 of 5
(2,823 Views)

the problem is not with sending commands, it is reading. The instruments send their messages with different termination characters, I need to read these correctly.

 

0 Kudos
Message 3 of 5
(2,807 Views)
Hex 03 is not CR. CR is hex 0D (decimal 13). Opening/closing the serial port each time is very time-consuming and resource-intensive. You should not need to do this. If you set the termination character to "none" then you have to know when to stop reading. Presumably you are have a loop for your VISA Read and you are using the VISA Number of Bytes at Serial Port to read the characters until you see the termination characters. If not, then this is what you should be doing.
Message Edited by smercurio_fc on 03-26-2009 10:49 AM
Message 4 of 5
(2,799 Views)

sylvester wrote:

the problem is not with sending commands, it is reading. The instruments send their messages with different termination characters, I need to read these correctly.

 


 

Just trying to point out common issues when someone says "It works in Hyperterminal but not in LabVIEW".  A lot of times you will enter a bunch of characters in a terminal window and hit enter.  But when you programmatically put those characters in a string to send to a VISA write, you forget to put a CR or LF at the end which the equivalent of hitting enter in the terminal program.

 

For dealing with different terminal characters on the read from different instruments, I think your best bet is to read the bytes available at the port appending the data to a string and keep doing that in a while loop.  End the while loop whenever a search of the string shows that the termination characters are a part of the string.  That way you can programmatically change your stop condition (CR-LFin once case, 03 0D 0A FF in another) depending on which device you are talking to.

Message 5 of 5
(2,783 Views)