LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW 6i and RS232

Please how do I use LabVIEW 6i to acquire data from serial port? I'm using "Serial Communication.vi" as a model but I have not been successful, each time the program time out. I have used Windows Hyperterminal to confirm communication parameters (works well). However, I'm not sure if the parameters should be established using MAX, Windows Control Panel (Ports), or within the program itself. I'm also concerned about Write/Read sequence for continuous acquisition. Thanks.
0 Kudos
Message 1 of 7
(3,301 Views)
Personally, I don't think this VI is very good example. If you are going to use VISA for serial communication, you should add a VISA property node after the VISA Open and select Serial Settings to set the serial port baud rate, parity, etc. For continuous acquisition, do a VISA Open once and then just VISA Writes and Reads. The other thing that I usually do is use a Number of Bytes at Serial Port property before a read and then read until I see a termination character. Good luck.
Message 2 of 7
(3,301 Views)
Your suggestion works. The next challenge I have is about the termination character. Returned numbers are always followed by a single space. If multiple numbers are returned, they will also be separated by a space. The strategy I'm considering is to read all the bytes irrespective of the number, what are your thoughts?
0 Kudos
Message 3 of 7
(3,301 Views)
That should work. Since every serial instrument is a little different (sometimes a lot), you'll have to adapt a different strategy each time. All of the stuff I'm using now has a fairly predictable response and only transmits data when a request for data is sent. They all transmit a carriage return as the last character. It would be fairly simple to read all bytes. To avoid a read timeout, put the read inside of a case statement and only do the read when the number of available bytes is greater than zero.
0 Kudos
Message 4 of 7
(3,301 Views)
Please find attached what I have come up with. It runs properly with correct response when the "Highlight Execution" button is activated. Do you know why this happens? If I run it from the control panel, nothing happens.
0 Kudos
Message 5 of 7
(3,301 Views)
samsam,
in the diagram you try too soon to read the number of byte at serial port. It works in highlight mode because the program runs much slower and data has time to arrive. Try to put the 100ms delay in the write case rather that in the read case.

Jean-Pierre


LabVIEW, C'est LabVIEW

0 Kudos
Message 6 of 7
(3,301 Views)
Thanks guys; the program works satisfactorily now.
0 Kudos
Message 7 of 7
(3,301 Views)