Sensor Signal Filtering
Design the signal chain from sensor output to reported value. Keep raw samples,
filtered values, timing, saturation, and fault flags observable; a filter must
not conceal a broken sensor or unsafe voltage.
Intake gate
Record or label unknowns before selecting a component or algorithm:
- exact board, MCU, core/framework, ADC channel, resolution, reference, input
range, acquisition time, and toolchain versions
- sensor part/module, output type and drive impedance, supply, cable length,
expected signal bandwidth, valid range, warm-up, and failure behavior
- sample period/jitter budget, acceptable latency, step-response requirement,
threshold policy, calibration model, and available measurement tools
Resolve the board with board-support before board-specific ADC advice. For
physical or multi-session work, load embedded-project-loop first and keep its
measurement gate open.
Workflow
- Capture raw samples at a stated, repeatable rate before filtering. Separate
sensor dynamics from spikes, aliasing, quantization, ADC settling, rail/
ground noise, EMI, and calibration error.
- Set the sampling rate from the signal bandwidth and latency budget. Check
Nyquist and alias attenuation; do not use a software filter to recover
information already aliased into the band.
- Choose one filter with an explicit window/alpha/model and calculate its
startup behavior, delay, memory, CPU cost, and effect on thresholds.
Common starting choices are moving-average for bounded windows, median for
isolated spikes, and EMA/IIR for low-cost smoothing; model-based filters
require a stated model and noise assumptions.
- Check the analog path: sensor loading, RC cutoff, ADC acquisition/settling,
reference and ground, cable/noise coupling, input protection, voltage
limits, decoupling, and motor/radio current return paths.
- Implement raw-plus-filtered telemetry and fault/saturation indicators.
Validate deterministic vectors on the host before target compilation.
- Change one causal variable per hardware iteration. Measure the ADC pin and
supply/ground with the same configuration used by the firmware.
Load on demand
- Read
references/filter-selection.md for
sampling math, algorithm tradeoffs, calibration order, and latency choices.
- Read
references/analog-front-end.md for
RC/input networks, ADC drive/settling, wiring, protection, and measurements.
- Read
references/verification-and-tdd.md
for host, simulation, build, target, and system gates.
- Use the diagnostic-only
examples/adc-filter-pipeline.ino
as a board-neutral fixed-rate EMA starting point; fill in board-specific ADC
assumptions before converting counts to volts. Reusable generated filtering
patterns remain owned by arduino-code-generator.
- Run the deterministic helper with
python3 scripts/filter_benchmark.py --help or a captured vector. It is a design/TDD
aid, not a replacement for target timing or electrical measurements.
The existing arduino-code-generator filtering pattern
owns reusable code snippets. This skill owns signal-chain diagnosis, filter
selection, hardware interaction, and evidence boundaries. Use
circuit-debugger for fault isolation, wiring-safety-check for logic and
rail limits, and sensor-calibration-workbench only after detection and signal
integrity are established.
Output contract
Use the shared Arduino skill contract:
state assumptions, required tools and versions, implementation steps,
tests/evidence, known limitations, and recovery/security notes.
- Build proof: host tests and an exact-board compile, if run.
- Upload proof: an uploader result for a named port/image, if run.
- Hardware proof: measured ADC pin, rail/ground, waveform, or wiring result.
- System proof: observed sensor behavior under the real load/environment.
- Deployment proof: field rollout, rollback, and maintenance evidence.
Never promote a passing host test, HTTP response, serial banner, or CI job to
hardware or system proof. If the board, sensor, circuit, or measurement is
unknown, stop at a bounded plan and name the next measurement.
1---
2name: sensor-signal-filtering
3description: Use when the main problem is a noisy or aliased analog/ADC signal and the task needs signal-chain diagnosis or filter-path selection across sampling, anti-aliasing, RC/input conditioning, ADC source impedance/settling, latency, startup, saturation, or raw/fault observability. Apply it when software filtering and hardware signal conditioning interact, even when the request only says that an analog sensor is unstable. Hand reusable Arduino snippets to arduino-code-generator, board facts to board-support, voltage/pin/rail safety to wiring-safety-check or circuit-debugger, and calibration after detection to sensor-calibration-workbench.
4metadata: {triggers: "ADC noise, analog sensor filtering, sensor signal conditioning, RC low-pass, anti-aliasing, EMA, median filter, moving average, source impedance, ADC settling"}
5---
6
7# Sensor Signal Filtering
8
9Design the signal chain from sensor output to reported value. Keep raw samples,
10filtered values, timing, saturation, and fault flags observable; a filter must
11not conceal a broken sensor or unsafe voltage.
12
13## Intake gate
14
15Record or label unknowns before selecting a component or algorithm:
16
17- exact board, MCU, core/framework, ADC channel, resolution, reference, input
18 range, acquisition time, and toolchain versions
19- sensor part/module, output type and drive impedance, supply, cable length,
20 expected signal bandwidth, valid range, warm-up, and failure behavior
21- sample period/jitter budget, acceptable latency, step-response requirement,
22 threshold policy, calibration model, and available measurement tools
23
24Resolve the board with `board-support` before board-specific ADC advice. For
25physical or multi-session work, load `embedded-project-loop` first and keep its
26measurement gate open.
27
28## Workflow
29
301. Capture raw samples at a stated, repeatable rate before filtering. Separate
31 sensor dynamics from spikes, aliasing, quantization, ADC settling, rail/
32 ground noise, EMI, and calibration error.
332. Set the sampling rate from the signal bandwidth and latency budget. Check
34 Nyquist and alias attenuation; do not use a software filter to recover
35 information already aliased into the band.
363. Choose one filter with an explicit window/alpha/model and calculate its
37 startup behavior, delay, memory, CPU cost, and effect on thresholds.
38 Common starting choices are moving-average for bounded windows, median for
39 isolated spikes, and EMA/IIR for low-cost smoothing; model-based filters
40 require a stated model and noise assumptions.
414. Check the analog path: sensor loading, RC cutoff, ADC acquisition/settling,
42 reference and ground, cable/noise coupling, input protection, voltage
43 limits, decoupling, and motor/radio current return paths.
445. Implement raw-plus-filtered telemetry and fault/saturation indicators.
45 Validate deterministic vectors on the host before target compilation.
466. Change one causal variable per hardware iteration. Measure the ADC pin and
47 supply/ground with the same configuration used by the firmware.
48
49## Load on demand
50
51- Read [`references/filter-selection.md`](references/filter-selection.md) for
52 sampling math, algorithm tradeoffs, calibration order, and latency choices.
53- Read [`references/analog-front-end.md`](references/analog-front-end.md) for
54 RC/input networks, ADC drive/settling, wiring, protection, and measurements.
55- Read [`references/verification-and-tdd.md`](references/verification-and-tdd.md)
56 for host, simulation, build, target, and system gates.
57- Use the diagnostic-only [`examples/adc-filter-pipeline.ino`](examples/adc-filter-pipeline.ino)
58 as a board-neutral fixed-rate EMA starting point; fill in board-specific ADC
59 assumptions before converting counts to volts. Reusable generated filtering
60 patterns remain owned by `arduino-code-generator`.
61- Run the deterministic helper with `python3
62 scripts/filter_benchmark.py --help` or a captured vector. It is a design/TDD
63 aid, not a replacement for target timing or electrical measurements.
64
65The existing [`arduino-code-generator` filtering pattern](../arduino-code-generator/references/patterns-filtering.md)
66owns reusable code snippets. This skill owns signal-chain diagnosis, filter
67selection, hardware interaction, and evidence boundaries. Use
68`circuit-debugger` for fault isolation, `wiring-safety-check` for logic and
69rail limits, and `sensor-calibration-workbench` only after detection and signal
70integrity are established.
71
72## Output contract
73
74Use the [shared Arduino skill contract](../../docs/arduino-skill-contract.md):
75state assumptions, required tools and versions, implementation steps,
76tests/evidence, known limitations, and recovery/security notes.
77
78- **Build proof:** host tests and an exact-board compile, if run.
79- **Upload proof:** an uploader result for a named port/image, if run.
80- **Hardware proof:** measured ADC pin, rail/ground, waveform, or wiring result.
81- **System proof:** observed sensor behavior under the real load/environment.
82- **Deployment proof:** field rollout, rollback, and maintenance evidence.
83
84Never promote a passing host test, HTTP response, serial banner, or CI job to
85hardware or system proof. If the board, sensor, circuit, or measurement is
86unknown, stop at a bounded plan and name the next measurement.