Back to resources
HIL
Testing
Analog

One Test, Three Signals: Analog In, Logic Out and the Bus, on One Clock

A sensor fault is an analog event, the alarm is a pin, the report is a CAN frame. We test all three in one capture: the DAC steps the input at t = 0, and the ADC and logic analyzer record the response on the same timebase.

Edward Viaene · December 3, 2026 · 7 min read

Most hardware tests check one signal at a time. Set an input, wait a bit, read an output. That works until the question is about order and time: did the alarm pin go high before or after the heater turned off, and how long after the sensor failed? Two separate captures can't answer that, because they don't share a clock.

The BenchPod can. Its DAC, ADC and logic analyzer all start from one hardware trigger in the FPGA, so a step on the analog input, a voltage on an analog output and an edge on a GPIO land on one timeline. In this article we use that to test a sensor fault end to end: the analog cause, the digital alarm, the analog reaction and the CAN report, in one test.

The device: our thermostat node

The device under test is the process node from Testing a Real Product: A Thermostat Node, End to End, an open source example in `process-node-stm32`. It reads a process temperature on an analog input (0.5 V + 20 mV/°C), runs a PI controller at 50 Hz and drives a heater on an analog output. If the sensor reading leaves the plausible range of 0.3-3.1 V while it regulates, it raises a pv_fault alarm and trips the heater off.

Here's what each signal does and where the pod sees it:

SignalNode pinPod sideIn the capture
Process sensorPA13.3 V DAC output, through a resistorthe stimulus, a step at a known time
HeaterPA4ADC inputanalog, volts
AlarmPB0LA5logic, one edge
Alarm reportCANthe pod's CAN portframe 0x0A0

The alarm is debounced over two readings, and the node samples its input at 100 Hz. So the spec we test is simple: after the sensor fails, the alarm pin goes high within about 30 ms, the heater output is off by then too, and a CAN frame reports it.

The stimulus starts with the capture

The trick is on_capture=True. It arms the DAC to start its waveform on the next capture's hardware t = 0, so the step happens at a time we know to one DAC sample, not "roughly when Python got around to it".

We play a short waveform: 20 ms of a healthy 1.0 V (25 °C), then 0 V, a shorted sensor. At 10 kS/s that's 2000 samples, which the pod plays straight from its own buffer (longer waveforms stream from its external memory). The capture is shorter than the waveform, so the replay never loops back to 1.0 V inside our window.

import time
from embeddedci.benchpod import BenchPod

PV_FAULT = 0x02          # bit in the alarm frame's active mask (alarm.h)
ALARM_LA = 5             # PB0
STEP_AT_S = 0.020
DAC_RATE = 10_000

def test_shorted_sensor_on_one_clock(benchpod, wiring, node):
    node.init(500_000)
    with benchpod.open_can(bitrate=500_000, term=True) as bus:
        # A healthy sensor and a regulating node: 25 degC, setpoint 60, heater on.
        benchpod.dac_output(wiring.ain_path, volts=1.0)
        node.aout("200")
        node.ctl("on 60")
        time.sleep(1.0)

        step = [1.0] * int(STEP_AT_S * DAC_RATE) + [0.0] * int(0.180 * DAC_RATE)
        with benchpod.replay(step, dac_path=wiring.ain_path, sample_rate_hz=DAC_RATE, on_capture=True):
            cc = benchpod.capture_correlated(
                adc_samples=6000, adc_sample_rate_hz=40_000,     # 150 ms of the heater
                la_samples=15_000, la_sample_rate_hz=100_000,    # 150 ms of the pins, 10 us steps
            )

capture_correlated returns two captures, cc.adc and cc.la, that started on the same edge. Sample i of the ADC is at i / cc.adc.sample_rate_hz seconds, and the logic analyzer's edge times use the same zero. The DAC step is at STEP_AT_S on that same clock.

One assertion across all of it

Now the test reads like the spec:

        # Logic: when did the alarm pin go high?
        alarm_t = cc.la.first_edge(ALARM_LA, "rising", after=STEP_AT_S)
        assert alarm_t is not None, "the alarm pin never went high"
        latency = alarm_t - STEP_AT_S
        assert 0.010 <= latency <= 0.035, f"alarm {latency * 1e3:.1f} ms after the fault"

        # Analog: when did the heater output drop?
        rate = cc.adc.sample_rate_hz
        heater_off_t = next(i / rate for i, v in enumerate(cc.adc.volts)
                            if i / rate >= STEP_AT_S and v < 0.1)
        assert heater_off_t <= alarm_t + 0.025, "the heater stayed on after the alarm"

        # Bus: the same alarm, reported on CAN.
        frame = bus.expect(can_id=0x0A0, timeout=1.0)
        assert frame.data[0] & PV_FAULT, str(frame)

    node.ctl("off")
    benchpod.dac_output("off")

The lower bound on the latency matters as much as the upper one. An alarm 2 ms after the fault means the debounce is gone, and the first noisy reading in the field will trip the heater. A separate "set the input, poll the pin" test would never see that, because its timing is set by the test's own round trips.

The tolerances come from the firmware's design, not from what we happened to measure: two readings at 10 ms apart, plus up to one period of phase between the step and the next sample, plus the alarm output itself, which the node sets within 0.5 ms of the confirming reading.

Why this needs one clock

Run the same test as three separate steps and every number gets worse:

ApproachWhat you know about timing
Set the DAC, then poll the alarm pinthe latency plus your network and Python round trips
Two separate captures, ADC then LAnothing about order: they started at different times
capture_correlated with on_capturestimulus, analog and logic on one FPGA clock

The pod's ADC runs up to about 400 kS/s, the logic analyzer up to 48 MS/s on all 14 channels (see A 48 MS/s Logic Analyzer From a Firmware Update). For a control loop at 50 Hz, 40 kS/s on the analog side and 100 kS/s on the pins is plenty, and it keeps the capture short.

The same pattern works with a recorded signal instead of a step. Capture a real sensor once, then replay it with on_capture=True and a fault spliced in; Recording and Replaying Analog Signals shows the replay side.

When the stimulus is a bus command

Sometimes the thing that starts the reaction isn't analog at all. It's a command on I2C or SPI: "start a conversion", "enter low power", "open the valve". Then you want t = 0 to be the moment that command went out.

capture_la(send=...) does that. The pod arms the capture, runs one I2C, SPI or GPIO transaction in the same command, and triggers on the line the transaction starts with. Our node can play an I2C target with a 256-byte register file (i2c target 42 on its console), so we can show it on the same wires:

from embeddedci.benchpod import Trigger

def test_command_and_capture(benchpod, wiring, node):
    node.cmd("i2c target 42", r"I2C target on=1")
    benchpod.enable_pullup(1, 2)                      # SCL on LA1, SDA on LA2
    with benchpod.open_i2c(sda=2, scl=1, hz=400_000) as i2c:
        cap = benchpod.capture_la(8192, sample_rate_hz=12e6,
                                  trigger=Trigger(2, "falling"),       # SDA: the START
                                  send=i2c.send(0x42, b"\x10", read=2))
    assert cap.send_result.ok
    txns = benchpod.decode(cap, "i2c", sda=2, scl=1)
    assert [m.address for t in txns for m in t.messages][:2] == [0x42, 0x42]

The send keeps 64 samples from before the trigger, so the decoder sees the START itself. On your own board, the write would be the command, and the response you time would be a pin, an interrupt line or a second bus, all in the same cap, measured from the START with cap.first_edge(...).

It works over the cloud too: the send and the capture run on the pod in one command, so a few hundred milliseconds of network latency can't land between them.

What you need

  • Firmware with gateware v55 or later for send (I2C and SPI master). capture_correlated and on_capture are in every current firmware release.
  • The analog module for the DAC and ADC parts. A digital-only pod still runs the send and logic analyzer half.
  • The embeddedci SDK. The full API is in the pytest docs, and every call here is also an MCP tool (capture_correlated, replay, capture_la) if you'd rather have an agent explore it first. See Driving the BenchPod with Claude.

The point isn't any one signal. It's that a fault in a real product crosses domains: a voltage becomes a decision becomes a pin becomes a message. Testing it on one clock is how you check the whole chain, and the order it happens in.