LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronize read from RS232

Hi,
I'm using visa write and read to communicate with a sensor that is connected through RS232.
The sensor can be configured to send data packets at specific rates (50ms, 100ms, 200ms, etc.).
what is the best way to sysnchronize the read, so I read the data on time.

Thanks.
0 Kudos
Message 1 of 5
(3,331 Views)
Greetings:

CAn your sensor be configured to only send packets upon request? If you're using an internal clock on in your sensor, you're sort of at the mercy of the accuracy of that, and you will undoubtedly have some drift over time. A little more information on your sensor would be useful, but in any case, I think you'll be a lot happier if you can trigger the sensor via Labview, rather than the other way around.

Eric
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
0 Kudos
Message 2 of 5
(3,331 Views)
Hi chutla,
The sensor is an inertial sensor. It can be set to
send data at specific rate (like every 100ms, it
has an internal clock).
it also can be configured to send packets on
request, but the software has to support the
automatic transmition.
Thank you.
0 Kudos
Message 3 of 5
(3,331 Views)
The instrument driver for the Mettler Toledo AT/MTT balance has an example of retrieving data from an instrument that continuously sends data. Basically, you monitor the serial receive buffer for incoming data using the VISA property node: Number of Bytes at Serial Port.

You can download the Mettler driver from the following site
:Mettler AT Balance Instrument Driver
0 Kudos
Message 4 of 5
(3,331 Views)
If the message transmitted by your sensor is always terminated by a specific character, e.g. CR or LF, just enable that as the VISA termination character for serial reads and set a timeout that is a bit longer than the sensor interval, e.g. 2-3 times as long. Use a VISA Read function and wire a large value to 'bytes to read' (larger than the maximum expected message length). VISA Read will wait until a complete message is received and then return it.

If the message doesn't have a termination character, read one byte at a time in a while loop and assemble the bytes into a string or array using a shift register. Use appropriate code to detect when a complete message has been assembled.

Either of these methods will return the sensor response to your LV program as soo
n as possible after the sensor has sent it, which is what I assume you mean by 'on time'.

There are two possible problems to bear in mind when you have a device that sends data continuously, rather than in response to a request: first, that readings may build up in the serial buffer before your program starts reading them, and second, that the first response you read may have the beginning chopped off, if you opened the port while the device was half-way through sending something. Make sure you've considered both of these. (Using the 'flush' function can help, but remember you might flush the buffer while the device is half-way through sending!)
0 Kudos
Message 5 of 5
(3,331 Views)