From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why use Visa Events?

In short, why would one want to use Visa Events?  I have been experimenting with them in order to try to find new ways to handle or avoid Visa Read timeouts and I am struggling to see how they are useful, because they throw timeout errors too.  To provide some background, I am hacking on a test application that reads and displays data from a serial port.  The data can be intermittent, because I often toggle my my serial devices on and off.  I don't want to be bothered with timeout errors stopping my application, so I have used varisous ways to handle them.  The current way I am experimenting with uses Visa Events, hence the reason for this question. 

 

If the Visa Read times out and the Visa Wait on Event  times out, then what is the advantage of the latter?  Is the Wait on Event less resource intensive than Visa Read?  By the last question, I mean does the Visa Read poll or block behind the scenes while the Wait on Event does not? 

 

Thanks in adavnce.

0 Kudos
Message 1 of 6
(3,158 Views)

Hi Tysoni,

 

There are many advantages to using VISA events, one of which being that they can prevent LabVIEW from continuously polling your serial ports.

 

The links below provide some additional information on VISA events and receiving time outs while using VISA events.

 

http://digital.ni.com/public.nsf/allkb/179E61F87CF8B340862571EA0037CFA3

 

http://digital.ni.com/public.nsf/allkb/E393205297CFF1B386256DFA00738F4A

 

Regards

Carli S.
Troubleshooting & Maintenance Digital Business Manager - NI
0 Kudos
Message 2 of 6
(3,088 Views)

So, when I use a VISA Read with count set to say 100, then LabVIEW will poll for those 100 bytes (or to termination character or timeout) behind the scenes until it returns?  Would a better (non-polling) approach be to enable a VISA Event for a termination character and then once the event triggers, read all the data available?  Conceptually, this seems like the cleaner, better approach.  The only problem is timeouts.   The Wait for Event will timeout just like the VISA Read will timeout, and because using events is more invovled, it begs the question of why to use events in this case.  The timeouts from the events seems like the polling on the read is replaced with a polling on the events.

0 Kudos
Message 3 of 6
(3,065 Views)
Why would you think a timeout is a bad thing? You would rather kill the program when an instrument goes off-line?
0 Kudos
Message 4 of 6
(3,057 Views)

I do not think timeouts are bad.  I am just wondering what the difference between using VISA Read and VISA Wait on Event is with respect to timeouts.  If one need to handle VISA Wait on Event timeouts when they occur, then why not just eliminate the event code and simply handle the VISA Read timeouts instead.  What's the advantage of VISA events?  The two errors/exceptions are the same, but using events requires more code. 

0 Kudos
Message 5 of 6
(3,034 Views)
You've already been told that in some cases, events can reduce the cpu load. I've seldom used them, to be honest. If I wrote an instrument driver, it needs to work with GPIB, Ethernet, USB, as well as serial so the events cannot be used.
0 Kudos
Message 6 of 6
(3,022 Views)