I write test software for electromechanical parts for a living, and I kept noticing the same thing: every bench task started as a quick PyVISA script and slowly turned into a mess. Hard-coded limits, no report, copy-paste between instruments, and nothing you could hand to someone else. So I built a small tool to fix that for myself, and I open-sourced it. This is how it works.
The idea: the test is data, not code
Instead of writing a Python script per test, you describe the test in a YAML file — which instruments, which SCPI commands, and the pass/fail limits — and a runner executes it and writes a report.
Here's a trimmed plan that checks a DC power supply's output with a DMM:
name: DC Power Supply Check
variables: {v_set: 5.0, i_lim: 1.0}
instruments:
psu: {resource: "TCPIP0::192.168.1.20::inst0::INSTR"}
dmm: {resource: "USB0::0x2A8D::0x1301::MY00000001::INSTR"}
setup:
- {instrument: psu, write: "APPL CH1,{v_set},{i_lim}"}
- {instrument: psu, write: "OUTP CH1,ON"}
steps:
- name: No-load voltage
instrument: dmm
query: "MEAS:VOLT:DC? 10,0.0001"
units: V
limits: {nominal: "{v_set}", tol_pct: 0.5}
teardown:
- {instrument: psu, write: "OUTP CH1,OFF"}
Run it, tagging the unit's serial number:
python -m benchplan run psu.yaml --serial SN-0042 --operator me
You get a colour PASS/FAIL on the console, a self-contained HTML report, a JSON record, and a row per step appended to results.csv — each with the measured value, the limit, the serial number and a timestamp. The exit code is 0 for pass and 1 for fail, so it drops straight into a fixture controller or CI.
The part I didn't expect to like: it runs with no hardware
Every instrument can be simulated inside the plan file — you write a few regex rules that answer the SCPI queries, with noise if you want it. That means you can write and demo an entire test before the DUT or the instruments exist, and the whole thing is unit-testable. python -m benchplan demo runs a full power-supply acceptance test on three simulated instruments and opens a report.
That simulation turned out to be the feature I use the most: I develop the plan on my laptop, then swap sim://psu for a real VISA address at the bench and delete the sim block.
Limits that match how datasheets actually read
Limits aren't just min/max. You can write a target with tolerance (nominal: 5.0, tol_pct: 0.5), an exact match (equals: CC), a set (one_of: [CV, CC]), or a regex, and they can reference variables and earlier measurements — so load regulation is just a derived step:
- name: Load regulation
expr: "(v_nl - v_fl) / v_nl * 100"
units: "%"
limits: {max: 0.5}
It's open source
benchplan is MIT-licensed and on GitHub. It's pure Python (PyYAML only for the core), and the expression evaluator is sandboxed so a plan file can't run arbitrary code. 99 tests.
👉 Repo: https://github.com/jashopcenter-stack/benchplan
If you'd rather not start from a blank file, I also put together a paid Instrument Automation Starter Kit that bundles benchplan with ready-to-use drivers for Rigol, Keysight and Siglent instruments, four runnable test plans, example scripts, and a 20-page PDF guide. It's the batteries-included version: https://shopcentered.gumroad.com/l/xeqouf
Either way — I'd genuinely like feedback from other people who automate benches. What instruments should I add a driver for next?
Top comments (0)