Make sure you have a USB A to USB B cable to connect your instrument to the computer.
This tutorial assumes familiarity with your instrument’s communication protocol and focuses on the set-up workflow in NI software. The set-up steps are different depending on the protocol used. Consult the documentation for your USB instrument or contact the instrument manufacturer for this information.
Install the latest compatible version of LabVIEW and the NI-VISA driver. Refer to the following for compatibility information.
After installing NI software, connect and configure your USB instrument.
NI-VISA will detect USBTMC instruments automatically, so no additional configuration is necessary after installing the NI-VISA driver. The instrument will be installed as a USB Test & Measurement Class Device.
For NI-VISA to recognize USB RAW instruments, you need to create a set-up information file (INF file) with the NI-VISA Driver Wizard and install it onto your computer.
Create INF File (USB driver)
Click the question mark on the upper right of the window. This enables the Context Help and provides descriptions for each field.
To get the USB Manufacturer ID (Vendor ID) and USB Model Code (Product ID), refer to External: USB Vendors. Search for the manufacturer of your instrument from the list and select Devices. The table will provide the Vendor ID and the Device ID. If you cannot find the Vendor or Device ID, contact your device manufacturer for this information.
Once you have the fields filled out, click Next. The image below shows an example for a National Instruments GPIB-USB-HS device.
Note: Choosing the Install the generated file(s) on this computer option requires administrator/root privilege.
Install INF File
If you are manually installing the INF file, navigate to the location the INF file was created and open the INF file in any text editor (e.g., Notepad). The installation instructions are included in the header at the top of INF file.
For more detailed instructions, follow the steps below:
Install USB Instrument
Some USB RAW instruments may not have serial numbers. If this is the case, NI-VISA automatically assigns a VISA specific serial number in the format NI-VISA-[number].
If the instrument only supports 1 interface, it will not be included in the VISA resource name.
In some cases, Windows may already have a default driver associated with your USB instrument and will install that driver first. To re-associate the driver to the INF file, follow the steps below:
After set-up and configuration, use VISA Test Panels to verify communication with the instrument and test different instrument commands.
After completing your configuration and verifying communication with the instrument, you need an easy way to transition from interactive mode to programming mode. The best way to achieve this is by using instrument drivers.
Refer to Choosing the Right Interface to Control Instruments in LabVIEW to determine which instrument driver type is best for your application. Follow the links in the document to install and use the instrument driver.
The instrument driver and NI-VISA driver will install examples and the API required to communicate with your instrument. Use these examples as programming references and an easy way to start using your instrument.
Note: Close MAX before you start running a LabVIEW example. Having MAX Test Panels open and running a LabVIEW example simultaneously will result in an access resource error.
If you installed an instrument driver, refer to the following examples:
If you are using NI-VISA, refer to the following examples based on the USB instrument type.
For USBTMC instruments, you can use the NI-VISA API to communicate with the instrument. An example snippet is provided below. This example opens a session to the USB instrument, performs a write of *IDN?\n, reads the specified number of bytes back from the instrument, closes the session, and handles any errors.
For more information on VISA functions, refer to LabVIEW Help: VISA VIs and Functions.
USB RAW Instruments
NI-VISA USB RAW mode supports Interrupt, Bulk and Control data transfers. Isochronous transfers are not supported. For more information about these communication types, refer to LabVIEW Help: Using NI-VISA to Communicate with Your USB Device.
Refer to the USB RAW shipping examples by navigating to the LabVIEW Help tab >> Find Examples…>>Hardware Input and Output >> VISA. You will find examples for bulk, control, and interrupt communication.
Note: Because NI-VISA USB RAW support is very device-specific, it requires detailed knowledge of how the device operates. Refer to manufacturer documentation for details on the communication protocol for your USB RAW instrument.
More USB Resources
Other Instrument Control Tutorials
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.