Instrument Control in Linux Tutorial

Publish Date: Aug 28, 2018 | 15 Ratings | 3.33 out of 5 | Print | Submit your review

Overview

Many pre-programmed instrument driver APIs are available for interfacing with common devices from NI LabVIEW applications, NI LabWindows/CVI applications, or other C applications running on Linux®. In addition, when a specific instrument driver is not available or custom functionality is needed, NI-VISA software can be used to develop your own drivers and simplify communication across instruments connected via Serial, Ethernet, GPIB, or USB as well as VXI controllers. This document explains how to install drivers for your National Instruments serial and GPIB interface hardware (if applicable), install NI-VISA 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.

Table of Contents

  1. Installing Linux Drivers for NI Serial and GPIB Interface Hardware
  2. Installing NI-VISA Software on Your Linux System
  3. Using the VISA Interactive Control (VISAIC) Utility on Linux
  4. Locating and Installing Existing Instrument Drivers
  5. Instrument Driver Development on Linux Using the NI-VISA API

1. Installing Linux Drivers for NI Serial and GPIB Interface Hardware

If you are using a National Instruments Serial or GPIB hardware interface, then your first step is to install the appropriate driver in order to access that interface from your applications on Linux. To do this, follow the instructions included in the document: National Instruments I/O Driver Support for Linux.

Back to Top

2. Installing NI-VISA Software on Your Linux System

To control your instrument on a Linux machine you need to install NI-VISA. Virtual Instrument Software Architecture (VISA) is a standard for configuring, programming, and troubleshooting instrumentation systems comprising GPIB, VXI, PXI, Serial, Ethernet, and/or USB interfaces. VISA provides the programming interface between the hardware and development environments such as LabVIEW. 

NI-VISA is the National Instruments implementation of the VISA I/O standard. In addition, NI-VISA includes software libraries, interactive utilities such as NI Spy and the VISA Interactive Control, and configuration programs through VISA Configuration for all your development needs. NI-VISA is standard across the National Instruments product line. With NI-VISA, you can feel confident that your software development will not become obsolete as your instrumentation interface hardware needs evolve into the future. 

National Instruments is actively maintaining the Linux edition of NI-VISA, and NI strives to maintain feature parity between the Windows and Linux versions (there are very few differences between NI-VISA on the two platforms). For every major release on Windows, there is a corresponding release for Linux.

You can get the latest version of NI-VISA from the Drivers and Updates webpage. Before you install NI-VISA on a Linux machine, make sure that your distribution of Linux is compatible by referring to National Instruments Driver and Software Support for Linux Distributions.

Note: Beginning in 2018, National Instruments offers a new catalog of Linux Desktop support for a variety of test and measurement hardware on the PXI Express platform. With this release, there has been a change to the way that National Instruments' driver software is acquired and installed onto a Linux Desktop system. Please see Downloading and Installing NI Driver Software on Linux Desktop for more information.

Back to Top

3. Using the VISA Interactive Control (VISAIC) Utility on Linux

NI-VISA comes with a utility called VISA Interactive Control (VISAIC) on Linux. This utility gives you access to all VISA functionality interactively, in an easy-to-use graphical environment. It is a convenient way to view available ports and get started developing instrument control applications. Note that this utility cannot be used to change settings on your instrument.

To launch VISAIC on Linux, use the NIvisaic command. When VISAIC runs, it automatically finds all of the available resources in the system and lists the instrument descriptors for each of these resources under the appropriate resource type. This information is displayed on the VISA I/O tab. The following figure shows the VISAIC opening window:

 


Figure 1. The VISA Interactive Control (VISAIC) Utility on Linux is a convenient way to view available ports and
get started developing instrument control applications.

 

Another utility, VISA Configuration, can be used to add and configure instrument interfaces in your system. To run this utility, use the visaconf command. The following figure shows the visaconf opening window:

 


Figure 2. The VISA Configuration utility can be used to add and configure instrument interfaces on your Linux system.

 

If your instrument is not initially displayed under the Resource Editor tab, you can use the Add Static button to manually add it to your system.

Back to Top

4. Locating and Installing Existing Instrument Drivers

While it is possible to use NI-VISA to communicate with an instrument directly, using instrument drivers can abstract the lower level details and accelerate software development. The NI Instrument Driver Network provides access to drivers for thousands of instruments many third-party vendors.

If you want to use an existing instrument driver in Linux, it must be a Plug and Play driver. Interchangeable Virtual Instrument (IVI) drivers run only on Windows operating systems. To download an instrument driver for use with LabVIEW on Linux, you must make sure it is packaged as a *.vi or *.llb file. You cannot open or install a *.exe instrument driver file on Linux.

To access the instrument driver VIs in LabVIEW, save the *.llb and menu files in the LabVIEW\instr.lib folder. You will now have access to the VIs from the Functions>>Instrument I/O>>Instrument Drivers palette. You can use these VIs to communicate with your instrument.

Back to Top

5. Instrument Driver Development on Linux Using the NI-VISA API

If an instrument driver does not exist for your instrument, you can use NI-VISA functions in LabVIEW or LabWindows/CVI to control your instrument. Make sure to have your instrument user manual available, because you will need to be familiar with the commands that your instrument responds to. Refer to the VISA API section in the following document: Instrument Control in LabVIEW Tutorial, for more help on using VISA in LabVIEW. You can access the VISA VIs from the Function»Instrument I/O»VISA palette in LabVIEW.

For information on accessing instruments from LabWindows/CVI applications using NI-VISA, see the Instrument Control in LabWindows/CVI Tutorial. Note that LabWindows/CVI applications require the LabWindows/CVI Run-Time Module for Linux to execute on a Linux OS.

>> Return to the Instrument Control Fundamentals Series

>> Return to the National Instrument Linux Portal

Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.

Back to Top

Bookmark & Share


Ratings

Rate this document

Answered Your Question?
Yes No

Submit