Communicate with Third-Party Instrument in Linux

Updated Apr 19, 2024

Environment

Software

  • LabVIEW

Driver

  • NI-VISA

Operating System

  • Linux

Other

Third-party instrument

This tutorial shows you how to set up NI software to communicate with an Ethernet, GPIB, serial, or USB instrument in LabVIEW on Linux OS. After this tutorial, you should be able to install the software necessary for instrument communication, locate pre-programmed instrument drivers for use in Linux applications, and get started programming your own instrument driver using the NI-VISA API.

Install NI Software and Drivers

  1. Download the latest compatible version of LabVIEW and NI Linux Device Drivers. Refer to the Readmes for system requirements and compatibility information. The Linux Device Driver readme can be found on the download page.
  1. Follow the instructions in Installing NI Drivers and Software on Linux Desktop to install the driver software.

To control your instrument on a Linux machine, you will need to install the following driver repositories:

 

Install Instrument

Refer to the following links on how to install your instrument hardware based on instrument type: EthernetGPIBserial, or USB.

 

Configure Instrument With visaconf

NI-VISA installs with a configuration utility called visaconf for Linux and Mac OS X. Use this utility to add and configure instruments in your system.

  1. Launch the visaconf utility by entering visaconf command in the terminal window.
  2. If your instrument is not displayed under the Resource Editor tab, click the Add Static button to add it to your system.

  1. In the Add New Static Resource tab, select the instrument interface from the list. Configure the settings for the instrument and click OK. The instrument resource is now added to your system and will show up under the Resource Editor tab.
  1. Click File >> Save VISA Configuration.

 

Test Communication With VISA Interactive Control

After set up and configuration, use VISA Interactive Control (VISAIC) to verify communication with the instrument and test different instrument commands.

  1. Launch VISAIC by entering the NIvisaic command in the terminal window.
  2. In the VISAIC window, double-click on the VISA resource of your instrument created in the previous section.

  1. A VISA session window for the instrument VISA resource will open. In the viWrite tab, enter the *IDN?\n command into the Buffer field. Click Execute.
  2. In the viRead tab, click Execute. The Buffer field should read a response from the instrument.

 

Install Instrument Driver

After completing your configuration and verifying communication with the instrument, you can easily transition from interactive mode to programming mode by using an instrument driver. Only Plug and Play instrument drivers are supported on Linux.

  1. Refer to Using Plug and Play Instruments Drivers in LabVIEW  to find and download the instrument driver.
    Note: Before downloading the driver, make sure it is packaged as a *.vi or *.llb file. You cannot open or install the driver on Linux if it is an *.exe file.
  2. After downloading the instrument driver files, install the *.llb and menu files in the LabVIEW\instr.lib folder.


You now have access to the instrument driver VIs from the Functions >> Instrument I/O >> Instrument Drivers palette in LabVIEW. You can use these VIs to communicate with your instrument.


If an instrument driver does not exist for your instrument, you can use VISA functions in LabVIEW to control your instrument. You can access the VISA VIs from the Function >> Instrument I/O >> VISA palette.

 

Run an Example

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.


Refer to the following resources for LabVIEW examples. If you are using the NI-VISA driver, refer to the instrument-specific NI-VISA examples.