Control a USB Device with NI-VISA on a Real-Time Controller

Updated Apr 18, 2024

Reported In


  • LabVIEW



Operating System

  • NI Linux Real-Time
  • PharLap
  • VxWorks

Issue Details

I have a Real-Time controller with a USB port and would like to use NI-VISA to control a USB device. Is this possible? Are there any examples I can reference? 


You can use the VISA API to communicate with the USB device. Any USB device that doesn't have an associated driver in the Operating System (OS) gets attached to VISA by default. This means that if you plug any USB device in your system, it should have a VISA resource that can be referenced with the VISA API. 

The type of VISA communication will depend on the type of USB instrument. The two types of USB instruments and resources to communicate with the instrument are listed below:
  1. USBTMC (USB Test & Measurement Class):
An instrument must have support for the USBTMC protocol in order to be considered part of the USB Test & Measurement Class, otherwise it is lumped into the USB RAW category.

If a device is USBTMC, it acts exactly like a GPIB instrument. For more information about communicating with USBTMC devices, please see the following: 
  1. USB RAW:
If an instrument is USB RAW, make sure the communication method is supported by NI-VISA. For any USB instrument, there are four different ways of communicating: Bulk, Control, Interrupt, and Isochronous. NI-VISA driver supports Bulk, Control, and Interrupt communication.

In the National Instruments Example Finder, there are three examples that demonstrate Bulk, Control, and Interrupt communication. To find them:
  1. Navigate to NI Example Finder by selecting the Help tab in LabVIEW >> Find Examples
  2. Navigate to Hardware Input and Output >> VISA. The examples are called: 
  • USB RAW -
  • USB RAW - 
  • USB RAW -

Additional Information

Not all types of RTOS support the functionality of accessing USB devices through the VISA API:
  • It is available in all controllers running the VxWorks RT OS.
  • It is unsupported for Phar Lap ETS targets with 2016 and previous versions of the LabVIEW Real-Time Module. Please see Real-Time Module on Phar Lap ETS Targets for more information.
  • If you are using a controller running NI Linux Real-Time, you must use a compatible version of the Real-Time module for your controller. Furthermore, USB devices connected to a cRIO-901x or cFP-2220 may not be automatically enumerated. If this is the case, connect the devices through a USB hub. If your USB device is not recognized in NI Linux Real-Time, please see USB Device Not Recognized by NI-VISA on NI Linux Real-Time Target
  • If you are using a controller running NI Linux Real-Time, and the USB resource is not shown. This might be because this instruments requires additional driver installations not available on this OS. Developing a Kernel module to allow compatibility is possible but not supported by NI.

Windows ships with a library of generic drivers that can identify USB devices in the appropriate way for VISA to then interact with them. If in Pharlap, or any other RTOS, the USB device shows up as a USB RAW device, and you don't expect it to, it's likely that a driver needs to be made for this device to work with VISA. Either contacting the device manager, or creating your own driver may be necessary for usage of this device with NI VISA.

Normally, instrument communication is not used on Real-Time systems because communicating over GPIB or Serial is inherently a non-deterministic process. However, the NI-VISA driver can be used in the cases where GPIB communication is needed.

If these steps have not proved useful then we suggest moving the Real-Time Controller to Linux RT OS. Please contact National Instruments Technical Support for information on how to do this.