Map the route to USB instruments
Program instruments through their USB ports with the same code you use to program IEEE 488, serial, VXI, or Ethernet instruments.
Martin Rowe, Senior Technical Editor -- Test & Measurement World, 5/1/2003
|
If you develop PC-based test applications, you may want to consider using the universal serial bus (USB) to connect your instruments. With two recently adopted specifications, you'll soon be able to program USB-based instruments with VISA—the Virtual Instrument Software Architecture that provides VXI, IEEE 488, Ethernet, and RS-232-based instruments with a common programming interface (Ref. 1). No longer will you need to use proprietary programming commands that have made it difficult to transfer USB code between instruments and test setups.
Traditional test-and-measurement instruments will increasingly contain USB ports. Courtesy of Agilent Technologies.

Figure 1
shows where VISA fits into the instrument-software hierarchy. VISA translates a common set of function calls into driver-specific commands. For example, an IEEE 488 interface card from National Instruments uses a different driver than a card from Agilent Technologies, but because both companies provide VISA, you can use the same higher-level programming calls with either card. (Both companies are developing new versions of VISA that add support for USB. See "VISA: It's almost where you want to be ," below, for more information.)
VISA and USB
![]() |
|
Figure 1. The VISA I/O layer provides a common programming interface from application programs and instrument drivers to test equipment over any of four I/O buses. |
In April 2001, several instrument manufacturers convened to address the two main drawbacks to using USB in test applications:
- USB is a serial bus, so it lacks dedicated hardware line interrupts, service requests, and triggers, which you get with IEEE 488 and VXI-based instruments. USB needs to provide these functions in software.
- Most instruments with USB ports use proprietary drivers, so code written for IEEE 488 and VXI instruments is unusable with USB instruments.
Because USB instruments are packed in boxes like IEEE 488 instruments, rather than as cards like VXI instruments, the instrument makers wanted engineers to be able to take code they'd written for the IEEE 488 bus and use it to communicate over the USB. Working within the USB Implementers Forum Device Working Group (USB-IF DWG), the instrument manufacturers adopted two specifications in December 2002—the USB Test and Measurement Class (USBTMC) base-class specification and the USBTMC-USB488 subclass specification (Ref. 2).
The USBTMC base-class specification describes a method that lets computers communicate with sensors and analog-to-digital converters. The USB488 specification provides communication with test equipment such as oscilloscopes, DMMs, function generators, and power supplies.
To make USB compatible with existing VISA-compatible applications code, VISA maps certain IEEE 488 functions into USB functions. "In, out, and trigger ," below, provides more detail on the command mapping.
Using VISAIf you know how to use VISA with other buses, then you already know how to write code for the USB488 version of VISA. With VISA, application code or instrument drivers make function calls with names such as viOpen(), viClear(), viWrite(), and viRead(). Because VISA hides the details of the lower-level USB drivers from you, you needn't concern yourself with USB endpoints, headers, buffer lengths, or other parameters.
![]() |
|
Figure 2. An alias editor lets you assign meaningful names to instruments on an I/O bus. Courtesy of National Instruments. |
USB[board]::manufacturer ID::model code::serial number[::USB interface number][::INSTR]
The USB descriptor that ends in "INSTR" tells VISA that it will talk to a USBTMC piece of equipment. The "[board]" descriptor, which lets you describe a USB device, is optional. The manufacturer ID, model code, and serial number are always required to uniquely identify an instrument. Fortunately, producers of VISA also provide software that lets you enter aliases for resource descriptors so you don't have to define them in your code.
After you assign an alias to an instrument, you're ready to make function calls to VISA. Listing 1 shows an example (written in C) of using the VISA functions viOpen, viClear, viWrite, and viRead.
The viOpen command returns a session identifier that enables communication between an application program and a particular instrument. Listing 1 shows an example use of an alias with viOpen(). The viOpen() function returns arbGenSession, which viClear(), viWrite(), and viRead() then use to communicate with an arbitrary waveform generator. For a more extensive code example, click here .
In Listing 1, the variable defaultRM represents the VISA default Resource Manager. idnQuery represents the IEEE 488 "*IDN?" command, and idnResponse holds the instrument's response to the query. If, for example, you use a DMM, then idnResponse might hold "Agilent Technologies,34401B,S000-0123-02,0".
Listing 1 demonstrates that programming an instrument through VISA maintains a common programming interface across I/O buses. With VISA, you can write applications programs or instrument drivers for IEEE 488, USB, VXI, and Ethernet I/O buses using identical commands. You need only designate the I/O bus for each instrument.
| Author Information |
| Martin Rowe has a BSEE from Worcester Polytechnic Institute and an MBA from Bentley College. Before joining T&MW in 1992, he worked for 12 years as a design engineer for manufacturers of semiconductor process equipment and as an applications engineer for manufacturers of measurement and control equipment. m.rowe@tmworld.com. |
| References |
|
|



















