This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

GPIB Instrument Control Tutorial

Updated Dec 19, 2023

Environment

Hardware

  • GPIB Instrument Control Device

This tutorial shows you how to set up National Instrument hardware and software to communicate with a GPIB instrument in LabVIEW.
 

Prerequisites

Consult the pinout or documentation for your GPIB instrument and make sure you have the correct cables and GPIB instrument control device to connect the instrument to the computer.

Cables

GPIB Instrument Control Device

 

Install NI Software and Drivers

Install the latest compatible version of LabVIEW, the NI-VISA driver, and the NI-488.2 driver. Refer to the following for compatibility information.  

 

Install GPIB Controller

If you are using an NI GPIB controller or a NI GPIB-ENET device, refer to the GPIB Hardware Installation Guide to install the hardware.
 

Configure Hardware in MAX

In Measurement and Automation Explorer (MAX), NI-VISA detects the instrument and creates the VISA resource that you use to communicate with the instrument.

  1. Open MAX from the Start menu.
  2. Expand Devices and Interfaces. You should see the VISA resource name of the NI GPIB controller listed as GPIB<controller>::INSTR where <controller> is the controller number. If not specified, the controller number defaults to 0.

If you are unable to see the controller, refer to Cannot Detect NI GPIB-USB HS Device in MAX.

  1. After the controller has been successfully recognized, securely connect the GPIB instrument to the controller via a GPIB cable and power it on.
  2. In MAX, select the GPIB controller and select Scan for Instruments. NI-VISA will attempt to identify the connected GPIB instrument by conducting a FindLstn() test and a *IDN? query. The instrument VISA resource name should appear under the GPIB controller resource as GPIB::<primary address>::INSTR.

Note: If your instrument is not SCPI compliant, it will not appear in MAX. Check the instrument’s user manual for supported commands and continue to the Test Communication section below.

If Scan for Instruments is missing, refer to NI MAX GPIB Scan for Instruments Missing.

If you experience issues with Scan for Instruments, refer to Can’t See GPIB Instrument Using Scan for Instruments in MAX.

Figure 1. Scanning for Instruments in MAX
 
  1. After your instrument has been successfully recognized, select the instrument in MAX and then the VISA Properties tab at the bottom of the window. You can configure the VISA Alias of the instrument for easier identification.
 

Test Communication

After set-up and configuration, use an interactive control to verify communication with the instrument and test different instrument commands.

If your device is SCPI compliant, select its VISA resource and select Communicate with Instrument.

  1. The NI-488.2 Communicator should launch.
  2. Type a supported command in the Send String field. Refer to manufacturer documentation for a list of valid commands.
  3. Select one of the following:

Query – writes the command to the instrument and reads the response back.

Write – writes the command to the instrument.

Read – reads the response from the instrument.

If your device is not SCPI compliant, use GPIB Interactive Control (IBIC) for more advanced communication.

  1. In MAX, navigate to the Tools tab >> NI-488.2 >> Interactive Control.
  2. Enter help to launch IBIC help documentation and refer to your instrument’s manual for supported commands.

If you are able to communicate with the instrument in IBIC, then you should also be able to communicate with the instrument from any other programming language, such as G code or C. 
 

Install Instrument Driver

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.

Run an Example

The instrument driver, NI-488.2, 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. For more information on whether to use the NI-488.2 or NI-VISA API, refer to NI-VISA Help: GPIB Summary.

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. 
 

Instrument Driver Examples

If you installed an instrument driver, refer to the following articles for instructions on running examples:

 

NI-488.2 or NI-VISA Driver Example

If you are using NI-488.2 or NI-VISA, refer to the shipping examples Simple GPIB.vi. or GPIB with VISA Functions.vi.

  1. To locate the examples, open LabVIEW and navigate to the Help tab >> Find Examples >> Hardware Input and Output >> GPIB.
  2. Ensure the proper VISA resource name is selected.
  3. Run the VI.

For more information on the NI-488.2 functions, refer to LabVIEW Help: GPIB Functions .

For more information on the NI-VISA functions, refer to LabVIEW Help: VISA Functions and VIs .

For a comparison on the NI-488.2 and NI-VISA functions, refer to NI-VISA Help: Comparison Between NI-VISA and NI-488.2 APIs.