How Can I Communicate With a Device Using NI-VISA USB RAW Mode?

Updated Aug 28, 2018

Reported In

Driver

  • NI-VISA

Issue Details

I noticed that NI-VISA 3.0 introduced USB support. How can I get started communicating with a USB device using the RAW mode?
 

Solution

Follow these steps to communicate with a USB device:
  1. You need to get the device detected by Windows and make sure that NI-VISA is assigned as the device driver. In Windows this binding is done using .inf files. Each USB device has a unique vendor and model number. The .inf file contains the vendor and model number for the devices it supports and the driver that handles the devices. When a Plug and Play device is connected to the PC, Windows reads the device information and uses the vendor and model number to search through the .inf files. When a matching .inf file is located Windows binds the driver listed as the owner to the device. 
  2. To communicate to a device with NI-VISA you need to create the .inf file that will bind the NI-VISA driver to the device. Fortunately, the NI-VISA package has a utility called VISA Driver Development Wizard that automatically generates the .inf file, if you provide the appropriate vendor and model numbers. Refer to the links below for more information on the VISA Driver Development Wizard.
  3. Once the .inf file is in place (in the hidden SYSTEM_DIR\inf directory), plug in the USB device and Windows should go through the hardware detection wizard and show NI-VISA as the driver for device. After the installation, the device should show up in the Measurement & Automation Explorer (MAX) with the appropriate resource name. 
  4. You can now use the two additional VISA functions for USB, viUsbControlIn and viUsbControlOut. These functions give you access to the USB device's control pipe, which every USB device has by default. You can set up communication with the device using the VISA properties. Click here for more information on the USB specific attributes. 
NI-VISA will scan the device from any open endpoints. If there are any endpoints open for the Interrupt or Bulk pipes, the endpoint attribute for each pipe will show the lowest open endpoint. If the attribute contains -1 it means that there are no endpoints open for the pipe. From this point on any communication setup with the device is specific to that device.

Additional Information

USB RAW mode gives you access to the low level communication mechanisms of the USB specification. Since NI-VISA just exposes the mechanisms already defined in the specification, it is assumed that the user is familiar with the USB specification and programming USB devices. NI-VISA USB RAW mode supports Interrupt, Bulk and Control data transfers. Isochronous transfers are not supported. 

Additionally, communicating with a USB device using NI-VISA USB RAW support is very device specific, which requires from the user detailed knowledge of how the device operates. In this sense it is similar to register-level programming using the NI-VISA PXI support. NI-VISA provides the communication channel to the device, but the meaning of the data is device-specific. 

NI-VISA supports two modes for USB communication: USBTMC and RAW mode. This article gives some information on the VISA USB RAW mode. What is USBTMC and How Can I Communicate with My USB Instrument? 

WAS THIS ARTICLE HELPFUL?

Not Helpful