Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Frustrating bug, possibly in serial VISA

Hi all,

I have encountered a mysterious problem/bug while trying to interact with a serial device. It looks very much like a bug in LabView, but I am somewhat of a newbie, so I could be overlooking something simple.

Anyway, I have a hardware device that talks to the PC through the serial port. I can use the "Basic Serial Read and Write.vi" to write data to this serial device. The data I'm writing is of the form

LFFFF\r

where FFFF is a hexadecimal number (yes, the FFFF is supposed to be the string "FFFF" , not an integer value). This works fine when I use the input box ('string to write') in this VI. However, since I need to send a constant, very long consecutive string of data to the device (e.g. "LFFFF\rLFFFE\rLFFFD\r" ) , I'd like to use a string constant that will contain the string to be written ("LFFFF\r") instead of typing it into the box. So I create a string constant, and replace the input box with it. I put exactly the same string into the constant that I had in the box ("LFFFF\r") and try to run the program, but I get an error from the hardware device. Unfortunately, the hardware device doesn't have much in the way of debugging, so I can't see exactly what input it's getting from the PC, but it looks like it's getting two carriage return ("\r") characters at some point, instead of just one, since it spits back two messages that say, essentially "invalid input".

I have attached the two VIs so you can see I'm not bonkers. The first should have the string "LFFAB\r" in the text input box. The second should have the exact same value as a string constant. The first VI works fine, the second produces the two invalid input messages from the device.

I've played around for quite a bit, trying to figure this out, but I am very baffled. Thanks for any help or insight into this problem.
0 Kudos
Message 1 of 3
(3,166 Views)
It's not a bug in LabVIEW - it's a mistake in your program. The front panel string control is set for '\' Codes Display. The string constant is set for Normal Display. You select this by right clicking on the string control or constant. With normal display, what you are send is the characters '\' and 'r', not the control code for a carriage return.
Message 2 of 3
(3,160 Views)
Thank you so much! That was it! Program works as expected now. Many thanks.
0 Kudos
Message 3 of 3
(3,157 Views)