Introduction to Programming USB Devices in VISA

NI-VISA 15.0 Help

Edition Date: June 2015

Part Number: 370131S-01

»View Product Info

For users writing new code to communicate with a USB instrument, the most important consideration in choosing the right API is which protocol(s) the device supports. The USB Test & Measurement Class (USBTMC) protocol was designed to mimic the message-based IEEE 488 style of programming with which instrumentation users have become accustomed; VISA is the best API to program devices using this protocol. For other devices, if the vendor merely documents the proprietary data format for each endpoint present on the device, VISA may be the best solution. Finally, some devices use other common well-defined protocols over USB; in these cases, an existing standard implementation of that protocol may be more appropriate than VISA. For example, operating systems ship standard drivers for certain USB device classes such as Human Interface Device (HID).

For RAW USB devices, NI-VISA supports communication on the default control pipe (endpoint 0) on all platforms. On some platforms, NI-VISA also supports nonzero endpoints. (Nonzero endpoints are not currently supported on Windows 7/Vista/Server 2008 R2.) It also supports bulk-in, bulk-out, interrupt-in, and interrupt-out communication. NI-VISA does not support communication on isochronous endpoints.

The best way to determine the resource string is to query the system with viFindRsrc() and use or display the resource(s) returned from that operation. Each USB device has a vendor code and a model code; this is much the same as PXI does, although the vendor IDs are different. You can create a query to search for devices of a particular attribute value; in this case, you can search for a specific vendor ID and model code. For example, the USB vendor ID for National Instruments is 0x3923. If NI made a device with the model code 0xBEEF, you could call viFindRsrc() with the expression "USB?*{VI_ATTR_MANF_ID==0x3923 && VI_ATTR_MODEL_CODE==0xBEEF}". In many cases, the returned list has one or only a few devices.

WAS THIS ARTICLE HELPFUL?

Not Helpful