LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial port device works with HyperTerm and MAX, but only echos with LabView VISA interface

I have a serial device on COM4 with which I can communicate with HyperTerm and MAX, but when I send the same command string through a VISA session from LabView it just echos back what I sent but doesn't work.  The device wants a CR termination, and I've added it both directly in the command string (\r) and the VISA session (xD) to no avail.  Any suggestions on how to fix this would be most helpful.
0 Kudos
Message 1 of 6
(2,800 Views)
Do you have the string control correctly set to display \ codes and how did you set it with the 'VISA Session'? Right click on your string control/constant and select '\' Code Display. The regular VISA Configure Serial Port function does not have the option to set a termination character for transmit - only receive.
Message 2 of 6
(2,791 Views)
Dan, thanks for your prompt reply.  I'm setting the properties for the terminator on the VISA Configure Serial Port VI prior to writing the command string.  I didn't realize one could not set it in transmit, only receive.  I don't see the option you mention on the string control, maybe because I'm in LabView 7.  On the Format and Precision tab, it's set to Hexadecimal, and the value I'm using is D (for CR).  Can you be more specific?  How can I set its properties for transmit, or is my only option to include it in the command string?  Will the backslash cause problems in that case?  Thanks.
0 Kudos
Message 3 of 6
(2,784 Views)
You said you added a \r to the command string, right? That's the string control I'm talking about and the one you can set to '\' Code Display. Putting the terminator in the comand string will have no affect except that the command will be properly terminated. With \ Codes enabled, it will get interpreted as a CR. If you don't have \ Codes enabled, it will get interpreted as the separate characters '\' and 'r'.

You can use the concatanate strig function. If you have a front panel string control, wire it to the first input of the concatanate string and put the CR constant that is on the string palette to the second input. Wire the output to the VISA Write. This is proabably easier than trying to type it in every time on the front panel.

To set VISA to transmit it automatically, you can modify the VISA property node inside the VISA Configure Serial Port. Add the property 'Serial Settings:End Mode for Writes'. Wire the same enum 'TermChar' that is wired to the property 'Serial Settings:End Mode for Reads'. If you want an example, look at the HP34401 Initialize function that is on the Instrument I/O>Instr Drivers palette. I can't say for certain about the version that shipped with 7.0. I know it has it for 7.1 and higher.
Message 4 of 6
(2,777 Views)
Use portmon to watch the datastream with Hyperterm and labview. You can see the hex code going out the serial port.
 
Message 5 of 6
(2,768 Views)
Thanks for your suggestions - it worked!  The trick was using the string concatenation in combination with the slash code display.  I wasn't able to change the property node in the VISA Configure Serial Port VI, but it worked without it.  Maybe that wasn't available in 7.0, but it doesn't matter.  Thanks again!
0 Kudos
Message 6 of 6
(2,747 Views)