GPIB Instrument Control Tutorial

Publish Date: May 04, 2020 | 34 Ratings | 2.59 out of 5 | Print | 1 Customer Review | Submit your review

Overview

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

Table of Contents

  1. Prerequisites
  2. Install NI Software and Drivers
  3. Install GPIB Controller
  4. Configure Hardware in MAX
  5. Test Communication
  6. Install Instrument Driver
  7. Run an Example
  8. Related Links

1. 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


Back to Top

2. 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.  


Back to Top

3. Install GPIB Controller

If you are using an NI GPIB controller, refer to the GPIB Hardware Installation Guide to install the hardware.

If you are using a NI GPIB-ENET device, refer to Setting Up the Ethernet Configuration for a GPIB-ENET Device for additional steps to add the interface to your system.


Back to Top

4. 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.

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.


Back to Top

5. 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. 


Back to Top

6. 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.


Back to Top

7. 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 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.


Back to Top

8. Related Links

More GPIB Resources

Other Instrument Control Tutorials

Back to Top

Customer Reviews
1 Review | Submit your review

Needs more substance  - Jan 18, 2016

After reading a tutorial, one should have a basic sense of how something works. This article doesn't have enough information to give that sense.

Bookmark & Share


Ratings

Rate this document

Answered Your Question?
Yes No

Submit