Handle VXI Interrupts (signals, triggers, and so on) using NI-VISA or the NI-VXI API

NI-VISA Measurement & Automation

Handle VXI Interrupts (signals, triggers, and so on) using NI-VISA or the NI-VXI API

NI-VISA

NI-VISA provides two mechanisms to allow for flexible event handling: queuing and callbacks. The most common way to handle events is with the event queue. After opening a VISA session with viOpen(), you can enable the queue by calling viEnableEvent() and specifying VI_QUEUE as the mechanism. Later, you call viWaitOnEvent() to wait for and receive an event from the device associated with that session. If you prefer callbacks, first specify a callback handler with viInstallHandler() and then call viEnableEvent() with VI_HNDLR as the mechanism. The callback handler is invoked whenever the specified event type is received.

The available event types for the VXI interface include:

  • VI_EVENT_VXI_SIGP—for signals or 16-bit interrupts from VXI devices
  • VI_EVENT_VXI_VME_INTR—for 8-bit, 16-bit, or 32-bit interrupts from VXI or VME devices
  • VI_EVENT_TRIG—for sensing triggers from VXI devices

Most VXI devices generate 16-bit interrupts, so you can use either VI_EVENT_VXI_SIGP or VI_EVENT_VXI_VME_INTR—these are functionally equivalent. If a VXI device generates triggers, you must first specify in VI_ATTR_TRIG_ID the TTL or ECL trigger line to sense before calling viEnableEvent().

NI-VXI API

Note  National Instruments recommends using NI-VISA, rather than the NI-VXI API, to develop your applications.

The most common way to handle asynchronous signals in the NI-VXI API is to use callback functions. These functions are invoked whenever a specified asynchronous signal is received. After initializing the library with InitVXIlibrary(), you can set up a callback function using one of the following functions:

  • SetVXIintHandler()—to handle VXI interrupts
  • SetSignalHandler()—to handle VXI signals
  • SetTrigHandler()—to handle VXI triggers

Then you must also enable the specific signal you are trying to detect using the following functions:

  • EnableVXIint()—to enable VXI interrupt lines
  • EnableSignalInt()—to enable VXI signals
  • EnableTrigSense()—to enable triggers

VXI interrupts and signals also require that you perform some routing. See the functions RouteSignal() and RouteVXIint() for more information. You should also look at the interrupt example in the NIVXI directory.

To use VXI triggers, read National Instruments Technical Note 40, Triggering with NI-VXI. You can find this document on the National Instruments technical support resources Web pages.