Fault Injection & Debugging

Testing ADC Vref drift, open-circuit and shorted thermistors

Drive exact pin voltages from 0.0 V to Vref in suite.yaml and verify every over-temperature and low-battery threshold.

Analog scaling bugs hide in fixed-point division, lookup-table interpolation edges and missing open-wire checks. Testing every corner on a bench requires programmable voltage sources.

CircuitTwin drives deterministic voltages directly into MCU ADC pins or external ADS1115/ADS1220 twins, sweeping normal, open-circuit and shorted conditions in milliseconds.

Analog fault matrix corners

ConditionPin voltageRequired firmware state
Normal 25 C NTCDivider nominal voltageReports 25 C +/- 0.5 C
Open-circuit probeFull Vref (3.3 V / 5.0 V)Sets SENSOR_OPEN fault and disables heater
Shorted to GND0.000 VSets SENSOR_SHORT fault and disables heater

Local CLI workflow

Shell - run analog thermistor sweep
ct test matrix run --json --junit results/adc-sweep.xml tests/adc-faults.yaml

Suite & fault configuration

tests/adc-faults.yaml
version: 1
board: stm32f4-discovery
firmware: build/adc_monitor.elf
matrix:
  - name: ntc-open-circuit
    stimuli:
      - at_ms: 0
        target: mcu
        pin: PA0
        voltage_v: 3.30
    expect:
      console_contains: "FAULT_NTC_OPEN"
  - name: ntc-shorted-gnd
    stimuli:
      - at_ms: 0
        target: mcu
        pin: PA0
        voltage_v: 0.00
    expect:
      console_contains: "FAULT_NTC_SHORT"

CI pipeline integration

.github/workflows/adc-faults.yml
name: ADC Analog Fault Sweep
on: [push, pull_request]
jobs:
  adc:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: circuittwin/action@v1
        with:
          suite: tests/adc-faults.yaml

Troubleshooting checklist

SymptomFix
ADC reading lags voltage stepCheck software moving-average filter depth and extend timeout_ms to cover settle time.
Fixed-point voltage overflows 16-bit intPromote raw_code * vref_mv to uint32_t before dividing by 4095.

Frequently asked questions

QuestionAnswer
How do I calculate exact NTC stimulus voltages for suite.yaml?Use our free ADC Resolution, LSB & NTC Thermistor Calculator to convert any temperature in degrees C into exact divider voltage and ready-to-paste suite.yaml.

Related boards & component twins

More in Fault Injection & Debugging