Examples of Interface Independence

NI-VISA

Examples of Interface Independence

Now that you are more familiar with the architecture of the VISA driver, we will cover two examples of how VISA provides interface independence.

First, many devices available today have both a Serial port and a GPIB port. If you do not use VISA, you must learn and use two APIs to communicate with this device, depending on how you have it connected. With VISA, however, you can use a single API to communicate with this device regardless of the connection. Only the initialization code differs—for example, the resource string is different, and you may have to set the serial communication port parameters if they are different from the specified defaults. But all communication after the initialization should be identical for either bus type. Many VISA-based instrument drivers exist for these types of devices.

The existence of multi-interface devices is a trend that will continue and likely increase with the proliferation of new computer buses. This trend is also true of non-GPIB devices. Several VXI device manufacturers, for example, have repackaged their boards as PXI devices, with a similarly minimal impact on their VISA-based instrument drivers.

A second example of interface independence is the GPIB-VXI controller. This lets you communicate with VXI devices, but through a GPIB cable. In other words, you use a GPIB interface with GPIB software to send messages to VXI devices, the same way you program stand-alone GPIB instruments. But how do you perform register accesses to the VXI devices? Prior to VISA, you were required to send messages to the GPIB-VXI itself and ask it to perform the register access. For example, when talking to the National Instruments GPIB-VXI/C with NI-488.2, the register access looks like the following when using NI-488.2 function calls:

dev = ibdev(boardID, PrimAddr, SecAddr, TMO, EOT, EOS);

status = ibwrt(dev, "A24 #h200000, #h1234", cnt);

If you had ever planned to move your code to a MXI or embedded VXI controller solution, you would spend a great deal of time changing your GPIB calls to VXI calls, especially when considering register accesses. VISA has been designed to eliminate problems such as this limitation. If you are talking to a VXI instrument, you can perform register I/O regardless of whether you are connected via GPIB, MXI, or an embedded VXI computer. In addition, the code is exactly the same for all three cases. Therefore, the code for writing to the A24 register through a GPIB-VXI is:

status = viOut16(instr, VI_A24_SPACE, 0x0, 0x1234);

These examples show how VISA removes the bus details from instrument communication. The VISA library takes care of those details and allows you to program your instrument based on its capabilities.