Measurement

GPIB over USB and Wi-Fi: my firmware for the AR488-ESP32

A small adapter controls the instruments on my bench. My fork of the firmware fixes bugs and adds Wi-Fi, firmware updates over the network, a radio off switch, unique USB names and a manual.

updated
Test bench with Rohde & Schwarz AMIQ, SMIQ, UPL, CMS54 and NRVD and a Schlumberger Stabilock, connected with grey GPIB cables

My bench holds instruments that can be remote-controlled – but only over GPIB (IEEE 488), the classic interface of lab instruments. SMIQ signal generator, UPL audio analyzer, CMS54 radio test set, NRVD power meter: all of them have the wide connector on the back. An original GPIB adapter for the PC easily costs several hundred euros. It can be done for less.

The adapter

AR488 is an open project that turns a microcontroller into a GPIB adapter. It understands the commands of the well-known Prologix adapters, so it works with existing software: a terminal program, Python with PyVISA or your own scripts. One variant runs on the ESP32 and therefore also does Wi-Fi.

My adapters are revision 5 boards with an ESP32-S2 and the SN75160/SN75161 driver chips, which drive the GPIB bus properly. They come from a group order in the Mikrocontroller.net forum.

Why my own fork

Using five adapters and a full bus every day, I ran into a number of bugs. Instead of working around them, I fixed them in the firmware, and a few features came along. The firmware now reports version 0.49.18 – before, it still said 0.49.14 from 2021, although a lot had changed.

Bugs fixed

  • Addresses from 10 up: The status query (++spoll) only accepted addresses 0 to 9. ++spoll 17 was rejected as an unknown command. Now all addresses from 0 to 30 work, and all polls the whole bus, as the documentation had always promised.
  • Line endings: Terminals that send only LF could not submit commands. Now CR, LF and both combinations are accepted. Backspace also works in terminals that send DEL for it.
  • Wi-Fi connection: A second client that connected by accident froze a running measurement. Now it is turned away at once and the running session is left alone. A client that closes cleanly is detected, and control returns to USB.
  • Saving settings: ++savecfg reported success and failure the same way – not at all. Now there is always an answer.
  • Wi-Fi password: ++wifi pass without an argument showed the stored password to anyone connected to the adapter. Now the adapter only answers “set” or “not set”.
  • Long answers: The adapter passed on every byte read from the bus one by one. For a trace of a few thousand characters this took noticeably long. Now it collects up to 256 bytes and sends them as a block.
  • Help texts: ++help described ++mode the wrong way round (0 and 1 swapped). This is fixed.

New features

  • Wi-Fi at startup: The adapter connects to the stored network at power-on without blocking the start, and reconnects on its own when needed. ++wifi status shows network, IP address, signal strength and the reason for the last failure.
  • Name on the network: Each adapter registers as ar488-xxxxxx (from the end of its MAC address) and can be found via mDNS as ar488-xxxxxx.local – no router entry needed.
  • Unique USB names: Until now, all adapters reported the serial number “0”. On Linux there was then only one fixed device name, and the numbers ttyACM0, ttyACM1 … changed every time one was plugged in. Now every adapter has its own fixed name under /dev/serial/by-id/.
  • Firmware update over the network: New firmware can be uploaded in the browser on the adapter’s update page, or fetched from a web server with ++ota <url>. The adapters no longer need to go on USB for this. Five adapters are brought to the same version in a few minutes.
  • Help on the ESP32: ++help shows all commands with a short description, ++help eor only one. The ESP32 boards have enough memory for it. Help is now left out only on the small Arduino boards.
  • Radio off: The adapter’s Wi-Fi transmits in the 2.4 GHz band and shows up on the spectrum analyzer in measurements between 2.4 and 2.5 GHz. ++wifi off switches all transmitters off until the next restart, ++wifi on switches them on again. ++wifi disable switches them off permanently, also after a restart, until ++wifi enable. On ESP32 chips with Bluetooth this covers Bluetooth too. The commands work over USB only, so that you cannot cut off your own connection.
  • Manual: There is now a user manual for the Rev5 board: setup over USB and Wi-Fi, talking to instruments, VISA, command overview, troubleshooting and firmware update.

What it looks like

In a terminal, or via Telnet over Wi-Fi, you select the instrument address and send the command. The adapter returns the instrument’s answer:

++addr 20
*IDN?
Rohde&Schwarz,UPL,…

With ++findlstn the adapter lists all instruments currently on the bus. Handy when you no longer remember which address you gave to which instrument.

My bench software builds on the adapter. It drives the instruments over Wi-Fi and has a control panel for each of them in the browser. The picture shows the desk of the beta version: on the left the SME03 and SMIQ03B signal generators, in the middle the FSIQ 7 and FSP-30 spectrum analysers, top right the FMA modulation analyser. Bottom right, an automatic FM deviation measurement is running. It finds the carrier null and compares the measured spectral lines with the Bessel function. The instruments sit on two adapters.

Browser interface with control panels for two signal generators, two spectrum analysers, a modulation analyser and an FM deviation run with a bar chart
The bench in the browser: five instruments via two AR488-ESP32 adapters on Wi-Fi.

Instruments that already work

I have controlled all of the following instruments through the AR488-ESP32 adapters (R&S = Rohde & Schwarz). They report maker, model and firmware on the bus:

Instrument Type Firmware
R&S CMS54 radio test set 5.00
R&S CMS radio test set 6.07
R&S FMA modulation analyzer 2.40
R&S FSIQ 7 spectrum analyzer 4.20
R&S FSP-30 spectrum analyzer 2.80
R&S NRVD power meter 1.52 / 1.40
R&S SME03 signal generator 4.66
R&S SMIQ03B (two units) signal generator 5.93HX
R&S UPL audio analyzer 0.25
HP 66312A power supply A.01.03
STABILOCK 4015 (Wavetek) radio test set Computer 1.60

The STABILOCK 4015 has no *IDN?; it answers UNIT;SERNR and needs CR+LF as line end. This can be set on the adapter, too.

Where it comes from

The firmware is a joint effort; my part is the changes above:

  • AR488 by Twilight-Logic, the original for Arduino boards. It goes back to the work of Emanuele Girlando.
  • AR488-ESP32 by David Douard, the port to the ESP32.
  • WilheJo/AR488-ESP32, the pinout of the Rev4 and Rev5 boards.
  • My version: dc3ax/AR488-ESP32, a fork of douardda/AR488-ESP32 with the full history of all predecessors, licensed under GPL-3.0 like the original. Development continues here; my earlier copy at astralix/AR488-ESP32 is archived and points there.

If you run one of these adapters yourself: feedback and bug reports are welcome on GitHub.

  • #GPIB
  • #AR488
  • #ESP32
  • #Firmware
  • #Rohde & Schwarz