Skip to Content

← All functionalities

Fuse test benchRaspberry PLC 19RSCPISerie USBControl

Driving a programmable power supply over SCPI from a PLC

Automating a SCPI power supply with Python turns a manual lab instrument into the muscle of an automated test rig. This example drives an Ametek Sorensen XG (0-5 V / 0-220 A) from a Raspberry PLC 19R over USB serial at 9600 baud: device addressing with *ADR, current and voltage setpoints with SOUR:CURR and SOUR:VOLT, output switching and telemetry readback. It is the exact pattern we run in a real fuse test bench deployment.

Why SCPI plus a PLC beats a lab PC

The Raspberry PLC sits permanently wired in the cabinet: DIN-rail mount, 24 V supply, industrial I/O for interlocks and beacons. The same Linux box that talks SCPI to the supply also reads the shunt, drives relays and renders the HMI — one device, no fragile desktop PC on a bench. Python's pyserial is all it takes to speak to the instrument.

The SCPI command set that matters

Four commands cover the whole workflow: *ADR n selects the unit on a shared bus, SOUR:VOLT caps the voltage (5 V for fuse testing), SOUR:CURR sets the test current, and OUTP ON/OFF gates the power stage. A 50 ms pause after each write keeps the XG's parser happy at 9600 baud.

Ramping instead of stepping

Slamming 200 A into a shunt from zero stresses cabling and connectors. The example ramps the setpoint in 5 A steps with telemetry readback (MEAS:CURR?) at each stage, and a finally block guarantees the output is cut even if the script crashes mid-test.

A snippet from the implementation

Straight from the example as deployed on the Raspberry PLC 19R — copy it freely:

def current_ramp(supply, target_a, step_a=5.0, wait_s=0.5):
    """Raise the setpoint in steps to avoid stressing shunt and wiring."""
    setpoint = 0.0
    while setpoint < target_a:
        setpoint = min(setpoint + step_a, target_a)
        supply.set_current(setpoint)
        print("  setpoint %.1f A -> supply measures %.2f A"
              % (setpoint, supply.read_current()))
        time.sleep(wait_s)

The full example is a complete program — wiring header, setup and main loop — ready to adapt to your application.

Frequently asked questions

Does this work with other SCPI power supplies?

Mostly yes. SOUR:CURR, SOUR:VOLT and OUTP are standard SCPI, so Keysight, Rigol or EA supplies accept the same core commands. Only the addressing (*ADR) and timing details are Sorensen-specific.

Why 9600 baud instead of something faster?

The XG's serial interface is most reliable at 9600 with short pauses between commands. Test sequences change setpoints every few hundred milliseconds at most, so bandwidth is never the bottleneck.

How do I know the real current matches the setpoint?

You measure it independently. In the full bench the current is read from a shunt through an ADS1015 ADC, and a closed-loop calibration routine trims the SCPI setpoint until the measured value converges.

Related functionalities