Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to check data by VISA to see it's ready to be read?

I'd send a string command to pump air sample to the machine and wait a specific time to read the data. By VISA, is there a way to check if the data is ready to be read? An LED window on the machine shows the oxygen data after approximately 10 seconds after sampling. I don't want to use the timer to read the data because it changes over time. Thanks for your help. DN
0 Kudos
Message 1 of 2
(3,939 Views)
DN:

It's not so much VISA as it is the hardware interface and/or device that you are using.

For example, if you are using GPIB, you should configure the device to assert SRQ when it has data ready. If it is a serial device, you may be able to configure it to assert one of the hardware handshake lines, and then you would just need to configure the session to use hardware flow control. Alternately, you could just call viRead (VISA Read in LabVIEW) and let it wait until the data is ready. If you do the latter, make sure your timeout is sufficiently large. Newer versions of NI-VISA (>= 2.5) will not hog the CPU but you may want to put the read in a separate thread (LabVIEW execution system) so as to not affect your other calculations, etc. And you wou
ld not want to do this blocking read over GPIB because then you would not be able to communicate with your other instruments in the meantime. This is just the nature of GPIB.

As far as checking to see if the device has data ready, you could read the IEEE-488 status byte (viReadSTB) and see if the MAV bit is set. Just note that this is a polling technique.

Hope this helps,
Dan Mondrik
Senior Software Engineer, NI-VISA
National Instruments
0 Kudos
Message 2 of 2
(3,939 Views)