Skip to content

GPIB Primer

If you have never plugged in a GPIB cable, this page covers what you need to know. GPIB is a 50-year-old bus standard that remains the primary remote control interface for a vast installed base of precision test equipment. Understanding the basics helps when things do not work as expected.

GPIB stands for General Purpose Interface Bus. It was originally developed by Hewlett-Packard in the late 1960s as HP-IB (Hewlett-Packard Interface Bus) for connecting their instruments to computers. IEEE standardized it in 1975 as IEEE 488, and it was revised in 1987 as IEEE 488.2, which added the common command set (*IDN?, *RST, *CLS, etc.) and the status reporting model.

The physical connector is a 24-pin Centronics-style plug with a distinctive stackable design — you can plug multiple connectors onto the same instrument port, which makes daisy-chaining straightforward.

Key specifications:

PropertyValue
Data width8 bits parallel
Max devices15 (including the controller)
Max cable length20 meters total, 4 meters per segment
Max data rate~1 MB/s (theoretical), ~300 KB/s typical
Address range0—30 primary, 0—30 secondary
Signal levelsTTL (active low, open-collector)

GPIB uses a bus topology: all devices share the same set of 24 signal lines. Connections can be made in a daisy-chain (instrument A to instrument B to instrument C) or in a star pattern using a GPIB cable hub. Electrically, both are equivalent — every device sees every signal.

graph LR
    CTRL["Controller<br/>address 0"]
    IA["Instrument A<br/>address 1"]
    IB["Instrument B<br/>address 5"]
    IC["Instrument C<br/>address 22"]

    CTRL --- IA --- IB --- IC

    style CTRL fill:#78350f,stroke:#d97706,color:#fde68a
    style IA fill:#334155,stroke:#94a3b8,color:#e2e8f0
    style IB fill:#334155,stroke:#94a3b8,color:#e2e8f0
    style IC fill:#334155,stroke:#94a3b8,color:#e2e8f0

One device on the bus must be the Controller-In-Charge (CIC). The controller manages bus traffic: it decides which device talks, which devices listen, and when data transfers happen. In mcgpib, the AR488 bridge is always the controller.

Devices play three roles:

  • Controller — Manages bus state, addresses devices, sends interface commands
  • Talker — Sends data onto the bus (one at a time)
  • Listener — Receives data from the bus (multiple devices can listen simultaneously)

At any moment, there is at most one talker. The controller assigns the talker and listener roles by sending address commands while the ATN line is asserted.

stateDiagram-v2
    [*] --> Idle
    Idle --> Talker : Controller sends<br/>Talk Address (MTA)
    Idle --> Listener : Controller sends<br/>Listen Address (MLA)
    Talker --> Idle : Controller sends<br/>Untalk (UNT)
    Listener --> Idle : Controller sends<br/>Unlisten (UNL)
    Talker --> Idle : ATN asserted
    Listener --> Idle : ATN asserted

    note right of Talker : Only one talker<br/>at a time
    note right of Listener : Multiple listeners<br/>allowed

Every device on the GPIB bus has a primary address from 0 to 30. Address 0 is conventionally used by the controller. Instruments typically ship with a factory default address (often printed on the rear panel) and let you change it through the front panel menu or DIP switches.

Common factory defaults:

InstrumentTypical default address
HP/Agilent/Keysight multimeters22
Keithley multimeters16
HP/Agilent power supplies5
Tektronix oscilloscopes1
Stanford Research instrumentsVaries (often 2)

IEEE 488 also defines secondary addresses (0—30) for devices that need multiple logical channels on a single primary address. Most instruments do not use secondary addressing, and mcgpib’s bus_scan only operates on primary addresses.

The GPIB connector carries 24 lines: 8 data, 3 handshake, 5 bus management, and 8 ground.

Eight parallel data lines carry one byte at a time. All bus communication — commands and instrument data — travels over these same lines. The ATN signal distinguishes between command bytes (ATN asserted) and data bytes (ATN released).

These three lines implement a reliable asynchronous data transfer that works regardless of device speed. Every single byte on the bus goes through this handshake:

LineNameDriven byPurpose
DAVData ValidTalker”The data on DIO1-8 is valid, you can read it”
NRFDNot Ready For DataListener(s)“I am not ready to accept the next byte yet”
NDACNot Data AcceptedListener(s)“I have not finished reading the current byte”

The handshake sequence for one byte:

sequenceDiagram
    participant T as Talker
    participant BUS as Bus Lines<br/>(DAV / NRFD / NDAC)
    participant L as Listener(s)

    Note over L: NRFD=asserted, NDAC=asserted
    T->>BUS: Place data on DIO1–DIO8
    L-->>BUS: Release NRFD (ready)
    T->>BUS: Assert DAV (data valid)
    L->>BUS: Read byte from DIO1–DIO8
    L-->>BUS: Release NDAC (accepted)
    T-->>BUS: Release DAV
    L->>BUS: Assert NRFD + NDAC (ready for next)

Because NRFD and NDAC are open-collector (active-low, wired-AND), the bus automatically waits for the slowest device. A fast instrument cannot be overwhelmed — it simply holds NRFD or NDAC until it is ready.

LineNamePurpose
ATNAttentionWhen asserted: data lines carry bus commands. When released: data lines carry instrument data. Only the controller drives ATN.
IFCInterface ClearAsserted by the controller for at least 100 microseconds to reset all device interfaces. This is the “hard reset” for the bus (not instrument settings).
RENRemote EnableWhen asserted: instruments accept remote commands. When released: instruments operate from front panel only.
SRQService RequestAsserted by any device that needs attention. The controller must serial poll to find out who asserted it.
EOIEnd Or IdentifyAsserted by the talker on the last byte of a message, or by the controller during a parallel poll.

SRQ is the interrupt mechanism of GPIB. When an instrument needs attention — a measurement completed, an error occurred, a trigger was received — it asserts the SRQ line. Because SRQ is a shared bus signal, the controller cannot tell from the line alone which device asserted it.

To identify the source, the controller performs a serial poll. This is a special bus operation where the controller asks each device for its status byte. The status byte contains:

  • Bit 6 (RQS) — Set if this device asserted SRQ
  • Bit 5 (ESB) — Event status bit (details in the Event Status Register)
  • Bit 4 (MAV) — Message available in the instrument’s output buffer
  • Bits 7, 3—0 — Instrument-specific

Reading the status byte clears the RQS bit and releases SRQ (if no other device is holding it).

In mcgpib, the check_srq tool reads the SRQ line state and automatically calls find_rqs to identify the requesting device. The serial_poll tool lets you read the status byte from specific instruments or all known listeners.

The Standard Commands for Programmable Instruments (SCPI) is a command language layered on top of IEEE 488.2. It defines a hierarchical command structure organized by measurement function:

MEAS:VOLT:DC? Measure DC voltage
CONF:CURR:AC 1,0.01 Configure for AC current, 1A range, 10mA resolution
TRIG:SOUR BUS Set trigger source to bus trigger
SYST:ERR? Read the error queue
graph TD
    ROOT["SCPI Root"]
    MEAS["MEASure"]
    CONF["CONFigure"]
    SENS["SENSe"]
    TRIG["TRIGger"]
    CALC["CALCulate"]
    SYST["SYSTem"]
    OUTP["OUTPut"]
    INST["INSTrument"]

    ROOT --> MEAS
    ROOT --> CONF
    ROOT --> SENS
    ROOT --> TRIG
    ROOT --> CALC
    ROOT --> SYST
    ROOT --> OUTP
    ROOT --> INST

    MEAS --> MV["VOLTage"]
    MEAS --> MC["CURRent"]
    MEAS --> MR["RESistance"]
    CONF --> CV["VOLTage"]
    CONF --> CC["CURRent"]
    SENS --> SV["VOLTage"]
    SENS --> SF["FREQuency"]
    SYST --> SE["ERRor?"]
    SYST --> SB["BEEPer"]

    style ROOT fill:#78350f,stroke:#d97706,color:#fde68a
    style MEAS fill:#334155,stroke:#94a3b8,color:#e2e8f0
    style CONF fill:#334155,stroke:#94a3b8,color:#e2e8f0
    style SENS fill:#334155,stroke:#94a3b8,color:#e2e8f0
    style TRIG fill:#334155,stroke:#94a3b8,color:#e2e8f0
    style CALC fill:#334155,stroke:#94a3b8,color:#e2e8f0
    style SYST fill:#334155,stroke:#94a3b8,color:#e2e8f0
    style OUTP fill:#334155,stroke:#94a3b8,color:#e2e8f0
    style INST fill:#334155,stroke:#94a3b8,color:#e2e8f0

SCPI commands ending with ? are queries — they ask the instrument for data and expect a response. Commands without ? configure the instrument and produce no response.

TypeExampleBehavior
QueryMEAS:VOLT:DC?Instrument measures and sends the result
CommandCONF:VOLT:DC 10Instrument configures itself, sends nothing
Common query*IDN?Returns identification string
Common command*RSTResets instrument to defaults

The IEEE 488.2 common commands (prefixed with *) work across all compliant instruments:

CommandPurpose
*IDN?Identification: manufacturer, model, serial, firmware
*RSTReset to power-on defaults
*CLSClear status registers and error queue
*ESE NSet event status enable register
*ESR?Read and clear event status register
*OPCSet OPC bit when all pending operations complete
*OPC?Return “1” when all pending operations complete
*SRE NSet service request enable register
*STB?Read status byte (same as serial poll, but as a query)
*TST?Run self-test, return result
*WAIWait until all pending operations complete

Most SCPI instruments organize commands into subsystems:

SubsystemPurposeExample
MEASOne-shot measurement (configure + trigger + read)MEAS:VOLT:DC?
CONFConfigure measurement functionCONF:RES 1E6
SENSDetailed sensor/function configurationSENS:VOLT:DC:RANG 10
TRIGTrigger configurationTRIG:SOUR IMM
CALCMath and data processingCALC:FUNC AVER
SYSTSystem settings and error handlingSYST:ERR?
OUTPOutput enable (power supplies, signal generators)OUTP ON
INSTChannel/instrument selection (multi-channel units)INST:SEL P6V

GPIB was designed in an era when instruments cost tens of thousands of dollars and were built to last decades. That installed base has not gone away:

  • Precision equipment — Many GPIB-only instruments (HP 3458A 8.5-digit multimeter, Keithley 6517B electrometer, HP 8566B spectrum analyzer) have no modern equivalent at the same performance and price point on the used market.
  • Calibration labs — Reference-grade equipment often uses GPIB exclusively. USB and LAN interfaces are common on newer models but do not cover the full range of available standards.
  • Test fixtures — Existing production test stations with GPIB wiring continue to operate because replacing them costs more than maintaining them.
  • Reliability — The three-wire handshake, open-collector bus, and robust connectors make GPIB extremely reliable for long cable runs in electrically noisy environments.

Modern alternatives (USB-TMC, LXI/Ethernet, VXI) exist for new instruments, but they do not address the massive installed base of GPIB equipment. Projects like AR488 and mcgpib make it possible to control this equipment with modern software without buying expensive proprietary GPIB controllers.