The SNUADC firmware¶
The public SNUADC firmware explains the board's timing: it sends no time stamps, samples on its 16 MHz crystal, loses time rather than bunching samples after a stall, reads its channels one after another, and truncates its values. The predicted fault at the wrap of its microsecond counter is real but intermittent: over the whole release, the PPG and arterial timelines step together 4,295 s apart about five times as often as at other spacings, at roughly one wrap in four, and not at all on some ports.
| Date | 2026-10-13 |
| Status | current |
| Methods | Reading the source, Clocks carried in the signal |
| Techniques | Predict, then test |
| Clocks | SNUADC sample clock, Monitor analogue output clock |
| Devices | SNUADC, Vital Recorder |
| Variables | ECG lead II (SNUADC), Arterial pressure (SNUADC), Plethysmogram (SNUADC) |
Background¶
Several measured behaviours (the stamp sawtooth, the signal lost at resets, a sub-millisecond skew between channels) needed a mechanism. The board's firmware is public.
Data¶
Source: github.com/vitaldb/snuadc, firmware/SNUADC/SNUADC.ino (an Arduino sketch for an ATmega32U4), and the board design in the same repository (artwork/snuadc.net, the KiCad netlist, and artwork/snuadc-bom.csv; read 5 November). The wrap prediction was tested on the 6 longest files with the 240 Hz monitor line in ART and PLETH (17 October; rerun 2 November), then on all 36 of the 56 such files measured whose continuous stretch spans at least one wrap (74.6 h, 50 wraps due; 3 November). Whole release (4 November): the monitor-line scan of all 5,714 recordings of the full-release sawtooth scan found the line in both channels in 1,579; 828 of them have a continuous stretch spanning at least one wrap (1,785 h, 1,138 wraps due).
Method¶
The sampling, transmission and calibration code was read for what it predicts about timing and values, and each
prediction was checked against the measurements in the atlas. One prediction (extra samples at each wrap of the
microsecond counter, every 2³² µs = 4,295 s of uptime) was tested directly: a fine step search on the sample-count
timeline of the 240 Hz monitor line (standard error 0.05–0.16 ms) for steps shared by ART and PLETH and 4,295 s
apart, against the same count at 427 other spacings from 2,000 to 6,500 s
(tools/wrap_test.py): python tools/wrap_test.py select --lines
$W/monitor_lines/lines.jsonl --root $R --out $W/wrap_test/files.json, then python tools/wrap_test.py run --files
$W/wrap_test/files.json --root $R --out $W/wrap_test (the six) and the same with --out $W/wrap_test_wide
--min-wraps 1 (all 36; the summary repeats the control without the first six). Whole release: bash
scripts/run_wrap_full.sh (WSL; monitor_lines scan and agg, then wrap_test select and run with --min-wraps 1
--first $W/wrap_test/files.json), and the checks python tools/wrap_checks.py --wrap
$W/wrap_full/run_phase/wrap_test.json --units $W/results/sync_full/units.csv --modes
$W/results/sync_full/snuadc_mode_label.json --ports $W/pat_census/aggf/cases.csv --out $W/wrap_full/checks
(tools/wrap_checks.py): steps in pairs against the rest, pairs at 2 and 3 times the wrap,
by port and correction mode, and the phase of the pairs since each ART stream began.
Results¶
- No time stamps in the stream. Each sample is 4 × 3 bytes (two 10-bit channels per 3 bytes) over USB serial. The board sends no time, so the recorder stamps by sample count: the reason the SNUADC sawtooth and the stamp model exist.
- Crystal clock. Sampling is timed by micros() on the 16 MHz crystal, so the long-term rate is the crystal's; crystal tolerance gives the tens of ppm measured against the recorder.
- No catch-up after an overrun. The schedule is us_next = max(us_next + us_wait, now): a late sample resets the schedule instead of sending extra samples, so a stall of more than 2 ms loses time rather than bunching samples. The rate is set by the recorder (500 Hz = 2,000 µs exactly; up to 1,000 Hz).
- Channel skew. The 8 channels (pins A11, A6, A0–A5, in that order) are read one after another, about 0.1 ms each, so the last is read up to about 0.8 ms after the first. Which track each pin carries is not stated.
- Value scale. A 10-bit converter on the internal 2.56 V reference; a two-point calibration in EEPROM maps −4 V and +4 V to counts 102.4 and 921.6; the result is truncated (not rounded) and clamped to 0–1023. Truncation biases values down by half a count (about 0.5 mmHg for arterial pressure). The arterial ceiling near count 917 is the monitor's +4 V output (about 400 mmHg); the ECG clips at 0 and 1023.
- No filtering in the signal band. Each input passes a 300 kΩ / 75 kΩ divider to the reference and an LM2902 stage with a gain of 1.25, so the converter sees 0.25 × input + 1.24 V (a TLV431 reference). The only capacitors in the path are 20 pF across the 75 kΩ feedback resistor (a pole near 106 kHz) and 10 Ω with 100 nF at the converter pin (near 159 kHz); the firmware takes one reading per channel per sample and averages only while calibrating. The board is flat to about 100 kHz: any band limit, notch or change of filtering in a SNUADC track is the monitor's.
- No anti-aliasing filter. Sampling at 500 Hz with no filter below about 100 kHz, anything the monitor puts out above 250 Hz folds into the record, including the steps of the monitor's own output updates.
- Event inputs. Two event jacks are sent as flag bits with each sample: a possible same-clock marker, if any case used them.
- The wrap fault is real, at some wraps. Over the whole release (828 recordings, 1,138 wraps due), 260 pairs of shared ART and PLETH steps lie 4,295 s apart, against 52 at a typical other spacing (at most 129 of 427 spacings); without the six recordings that first suggested it, 254 against 52. The excess repeats at twice the wrap (50 pairs against 11, at most 34) and is consistent at three times (4 against 1.5, from only 43 recordings long enough). 124 of the 265 recordings spanning two wraps show a pair.
- Intermittent, and absent on some setups. About 0.25 pairs per wrap due without stamp corrections and 0.15 in step mode, but 1 in 33 wraps in frequent-correction mode; by port 0.15–0.56, and none on COM3 (34 wraps due), COM45 (25) or COM4 in frequent-correction mode (30), where the typical rate predicts 6–9.
- Its steps look like the others. Steps in a pair are a median −1.1 ms (93% negative), the other shared steps −0.9 ms (81% negative): about half a 2 ms sample, so not simply one extra or lost sample.
- The counter does not restart with the recording. Measured from the first sample of each ART stream, the pairs fall at all phases of the 4,295 s cycle (only weakly uneven: Rayleigh R = 0.16; the first pair a median 2,125 s in, p5–p95 270–10,375 s), as for a board that keeps running between recordings.
- History. The six longest files (6 pairs against 0.3 expected) and then 36 files (11 against 2.6, with the 30 new ones alone not significant) gave conflicting readings; the whole release settles it. The first statement (17 October) that no pairs were seen came from a coarser step search and is withdrawn.
Discussion¶
The signal lost at each reset, about 20 ms, is the block the recorder discards when it re-anchors the count, not a stall of the board (Lee 2026, About 20 ms of signal lost at every SNUADC reset). The firmware's stall rule would lose time the same way, but nothing shows it acting at resets. The channel skew fits the ART–PLETH phase difference at 240 Hz (a median 0.37 ms, 0.29–0.46 ms in 69 recordings; Monitor clocks in the waveforms' spectral lines). The wrap fault is intermittent, about half a sample, and missing on some ports and in frequent-correction mode. The public code predicts a fault at every wrap, so either it depends on where in the 2 ms cycle the wrap falls, or the boards differ in firmware. Frequent-correction mode is not a setting but the recorder's rule applied to a converter whose crystal runs slower than the PC's clock (Lee 2026), so the fault's rarity there may come from the board, its firmware or its rate, and the data cannot yet tell which. For the timing it adds a step of about 1 ms to all SNUADC channels together at roughly one wrap in four: below the stamp model's error, and shared by every SNUADC channel, so the delays between them are untouched.
The analogue path matters for any reading of filtering from the waveforms: the board adds none in the band, so the response measured in a SNUADC track is that of the monitor's output stage, and a change within a recording is a monitor setting or the monitor's own processing, not the converter. Measured over the release, the ECG's is a low-pass of about 20 Hz, fourth order, the same on every unit (What frequencies each waveform carries). Without an anti-aliasing filter, the monitor's output update rate is sampled as it is; the 240 Hz line in arterial pressure and the plethysmogram (Monitor clocks in the waveforms' spectral lines) is consistent with this.
Observations it supports¶
| Observation | Status | Summary |
|---|---|---|
| About 20 ms of signal lost at every SNUADC reset | established | At each step-mode reset the acquisition pauses for about 20 ms inside the last record before the new timing, and that time is never sampled: about 19 ms on the sample count (17.3–20.3 ms; Signal lost at a SNUADC step-mode correction), about 2 ms more once the filler sample is counted. Every record still holds 100 samples, so nothing in the file shows it. |
| SNUADC sends no time; the recorder stamps by count | established | The SNUADC board streams samples with no time stamps. Every SNUADC time in VitalDB is the recorder's model of the board's clock: the sample count at the nominal rate, pulled back when it drifts too far. |
| SNUADC values are 10-bit codes, though the recorder's device list gives 12 bits | established | Every SNUADC channel in the release stores codes 0–1023 and nothing above, so 10 bits with a step of 0.0098746 V. The Vital Recorder paper describes the SNUADC as a 10-bit converter, and the public firmware reads a 10-bit converter, but the recorder's current device list gives 12 bits. |
| SNUADC channels are read one after another | likely | The SNUADC firmware reads its 8 channels in turn, about 0.1 ms each, so within one sample the last channel is read up to about 0.8 ms after the first. The channel order is not known. |
| SNUADC values are truncated to the count below | likely | The SNUADC firmware truncates each calibrated value instead of rounding it, so every value sits half a count low on average (about 0.5 mmHg for arterial pressure). Values clamp at counts 0 and 1023. |
| SNUADC has two event inputs | open | The firmware sends two event-jack flags with every sample. If any case used them, they would be markers on the SNUADC's own clock. |
Limitations¶
Read, not tested on the device. The deployed firmware and board versions are unknown (the netlist is dated March 2016); the channel-to-track mapping is unknown. Component tolerances are not stated, so the corner frequencies are nominal.
Open questions¶
- Which firmware ran (unexplained phenomenon). The deployed version, and which converter channel feeds which track, are not known. The firmware was published in November 2018 and the same code was used before then, but which version ran on each unit was not recorded (Lee 2026).
- Missing output codes and the stored scale (next step). With the nominal parts, ±4 V reaches the converter as raw counts of about 96 and 896 (800 apart), which the calibration stretches to 819.2 apart: about one output count in 42 should never occur, a pattern the value histograms can test. The nominal scale (9.77 mV of input per count, count 0 at −5.0 V) does not match the scale stored for the ECG exactly (0.009875 mV per count from −4.956 mV), which leaves the monitor's output scale to be measured.
- Channel skew as a timing component (next step). The channels are read in turn, so each SNUADC track sits a fixed fraction of a millisecond after the one read before it (ART leads PLETH by a median 0.37 ms, Monitor clocks in the waveforms' spectral lines). No timing form carries this yet. It is below the 2 ms sample spacing, whose rectangular component (0.58 ms per track) already dominates any pair within SNUADC, so it is left open. It would matter for sub-millisecond work within SNUADC, such as transit times between arterial pressure and the plethysmogram. Measuring it would take the hum phase across all tracks and the channel-to-track mapping.
- How Vital Recorder stamps SNUADC samples (next step). The board sends no time, so Vital Recorder assigns every stamp. Its rule is inferred from the data (the stamp sawtooth and its corrections); a description or the code would test the stamp model directly. Asked of the dataset's creator.
Code¶
References¶
- VitalDB. SNUADC: firmware and hardware of the VitalDB analogue-to-digital converter. GitHub. ↗
- Lee H-C. Personal communication (email to A. J. Goodwin), October 2026. ↗
- Lee H-C. Correspondence with A. J. Goodwin, November 2026. ↗
- Lee H-C. Correspondence with A. J. Goodwin, 9 November 2026 (on the v2 draft). ↗