Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Troubleshooting GPIB Interface

GPIB is a standardized interface that allows you to connect and control multiple devices from various vendors. GPIB is also referred to by its original name HP-IB, or by its IEEE® designation IEEE-488.

Some of the GPIB functionality is required for all GPIB devices, while other GPIB functionality is optional. Refer to your device documentation for a complete list of its GPIB capabilities and its command set.

Supported Platforms

The GPIB interface support is dependent on support by third-party vendor driver for the hardware on the supported platforms.

The GPIB interface is supported on these platforms:

  • Linux® – The software works with Red Hat Enterprise Linux 4 and 5 with kernel 2.6. It may also be successful with SuSE and Ubuntu distributions.

  • Microsoft® Windows® 64-bit

Adaptor Requirements

Instrument hardware and driver

The GPIB interface support requires Keysight™ (formerly Agilent®), ICS Electronics™, Measurement Computing™ (MCC), ADLINK Technology, or National Instruments® adaptor board and driver.

Bus and connector

You need a bus and connector to communicate with GPIB instruments. The GPIB bus is a cable with two 24-pin connectors that allow you to connect multiple devices to each other. For more information, see Bus and Connector.

GPIB devices

Each GPIB device must be some combination of a Talker, a Listener, or a Controller. A Controller is typically a board that you install in your computer. Talkers and Listeners are typically instruments such as oscilloscopes, function generators, multimeters, and so on. Most modern instruments are both Talkers and Listeners. Each Controller is identified by a unique board index number. Each Talker/Listener is identified by a unique primary address ranging from 0 to 30, and by an optional secondary address, which can be 0 or can range from 96 to 126. for more information, see GPIB Devices.

GPIB data

There are two types of data that can be transferred over GPIB: instrument data and interface messages:

  • Instrument data — Instrument data consists of vendor-specific commands that configure your instrument, return measurement results, and so on. For a complete list of commands supported by your instrument, refer to its documentation.

  • Interface messages — Interface messages are defined by the GPIB standard and consist of commands that clear the GPIB bus, address devices, return self-test results, and so on.

    Data transfer consists of one byte (8 bits) sent in parallel. The data transfer rate across the interface is limited to 1 megabyte per second. However, this data rate is usually not achieved in practice, and is limited by the slowest device on the bus.

GPIB lines

GPIB consists of 24 lines, which are shared by all instruments connected to the bus. 16 lines are used for signals, while eight lines are for ground. The signal lines are divided into these groups:

  • Eight data lines

  • Five interface management lines

  • Three handshake lines

For information on the types of lines and GPIB pin and signal assignments, see GPIB Lines.

Configuration and Connection

  1. Make sure that you have the correct instrument driver installed for your device. Refer to your device’s documentation and the vendor’s web site.

  2. Make sure your device is supported in Instrument Control Toolbox™. See Is My Hardware Supported?.

  3. You must have a GPIB board and instrument installed to use the GPIB interface.

    Make sure that your GPIB adaptor board is plugged into the computer running MATLAB®. You can verify that you have an adaptor board installed by using the instrhwinfo function with the gpib interface name. Allowed adaptors include agilent, isc, mcc, adlink, and ni.

    instrhwinfo('gpib')
    
    ans = 
        InstalledAdaptors: {'mcc', 'agilent'}
           JarFileVersion: 'Version 14.3.0'

    This example shows two installed vendors. The vendor name is for the board manufacturer, not your instrument manufacturer. If you do not see any installed vendors, you must install a board and its driver.

  4. Make sure that Instrument Control Toolbox recognizes your device, by using the instrhwinfo function with the gpib interface name, and your adaptor name. For example:

    instrhwinfo('gpib', 'agilent')
    
    ans = 
                 AdaptorDllName: [1x91 char]
              AdaptorDllVersion: 'Version 14.3.0'
                    AdaptorName: 'agilent'
              InstalledBoardIds: [8 32]
          ObjectConstructorName: {'gpib('agilent', 8, 6);'}
                  VendorDllName: 'sicl32.dll'
        VendorDriverDescription: 'Agilent Technologies GPIB Driver'

    InstalledBoardIds should list all installed boards. This is not the GPIB address of the board. If your board is not listed, try to use the board manufacturer’s software to use the board.

    ObjectConstructorName should have one entry for every connected instrument. If your instrument is not listed, make sure the instrument is on and configured for GPIB communication.

  5. Make sure you can create the gpib object. Each GPIB object is associated with one controller and one instrument. You must provide three arguments to create the object. Vendor is the adaptor board vendor. BoardIndex and PrimaryAddress are the second and third arguments. For example, to create a GPIB object associated with a National Instruments controller with board index 0, and an instrument with primary address 1:

    % Vendor = ni
    % BoardIndex = 0
    % PrimaryAddress = 1
    
    g = gpib('ni',0,1);

    Note

    You do not use the GPIB board primary address in the GPIB object constructor syntax. You use the board index and the instrument address.

  6. If you do not get an error, the object was created successfully. To verify, you can look at the object properties, using the name you assigned to the object, g in this case.

    disp(g)
    
    GPIB Object Using NI Adaptor : GPIB0-1
    
    Communication Address 
       BoardIndex:         0
       PrimaryAddress:     1
       SecondaryAddress:   0
    
    Communication State 
       Status:             closed
       RecordStatus:       off
    
    Read/Write State  
       TransferStatus:     idle
       BytesAvailable:     0
       ValuesReceived:     0
       ValuesSent:         0
  7. Make sure you can connect to the device, using the fopen function with the object name.

    fopen(g);

    If you do not get an error, the connection was made successfully. If you do get an error, follow the steps in the error message and/or check the previous steps listed here.

  8. When you have connected, you can communicate with your device. See Writing and Reading Data for an example of reading and writing to a chip.

Other Troubleshooting Tips for GPIB

Verify in Vendor Utility

Verify correct operation in a vendor utility, such as Agilent Connection Expert or National Instruments Measurement and Automation Explorer (MAX).

Both Agilent and NI installed

If you have both Agilent and NI GPIB drivers installed, you may get conflicts. Try disabling the other vendor drivers and trying the vendor you want to use again.

EOIMode, EOSCharCode, and EOSMode

EOIMode is the default and should be left on most of the time. However, some instruments might require EOIMode to be turned off. Use the correct parameter, such as EOSCharCode or EOSMode when necessary.

VISA

You can almost always use the visa interface with a VISA GPIB resource name instead of the gpib interface if you run into an issue. The only limitation of using VISA is that you cannot use the spool function.

Incorrect command sent

A common problem in using the GPIB interface is that an incorrect command is sent to the instrument. Try:

query(g,'*IDN?')

to verify communication with the instrument.

Most newer instruments recognize this command, since it is part of the GPIB standard. You should also look at the instrument’s manual to see which commands it recognizes.

Byte Order

You can configure ByteOrder to be littleEndian or bigEndian. For GPIB, ByteOrder refers to the order in which the bytes in a multi-byte data type values are transmitted on the communication bus. You can use the swapbytes command to troubleshoot issues with ByteOrder. You should configure ByteOrder to the appropriate value for your instrument before performing a read or write operation. Refer to your instrument documentation for information about the order in which it stores bytes.

Incorrect Data

Make sure the correct data type – for example int16, uint16, double – is being used with fread and fwrite. You should use the same data type as the instrument uses.

If reading and writing data types other than uint8 or int8, make sure the ByteOrder is correct.

Was this topic helpful?