OPT101 sequence tuning and field capture — XIAO 0.7.0

This release addresses weak/near-matching pulse trains. Its defaults are a broader experimental search profile, not a measured signature of your camera. The remaining tuning step is to record the actual source and background light.

Changes from 0.6.0

Sampling still requests 1,000 reads/s, with real timestamps and rate diagnostics. Gaps over 5 ms and ADC clipping (raw >= 4000) clear sequence history. A candidate expires after 2.5 learned periods, capped at 600 ms. The camera keeps its previous 8–12 Hz / half-rate-alias logic; radio rules and mode isolation remain separate. The shared portable core changes when rebuilding Pi from source, but Pi retains its own configured timing bounds. No new Pi image is part of this release.

Collect the data that will improve the next tuning pass

  1. Update with the web flasher. Leave Erase device unchecked to preserve settings. Join Flock Noir, open http://192.168.4.1, choose ALPR, and enable the wired OPT101.
  2. Cover/uncover OPT101 and check raw ADC response. Check measured sample rate, longest gap and clipping while camera/radios are active. The normalized scope exaggerates small signals; use raw CSV for amplitude and timing.
  3. While stationary and aimed at the source, press Record 5 seconds, wait for ready, then Download raw CSV. Keep the hotspot available for this. Collect several recordings when it matches and when it nearly matches.
  4. Repeat with the source out of view, then covered. Save each download under a distinct name, with notes for lighting, approximate distance/aim, target model if independently known, and whether the candidate alert appeared.
  5. Compare the actual rising intervals, widths, amplitude/noise and gaps. Capture ordinary lights too: the broader profile can accept unrelated low-frequency strobes. Those are essential negative controls for later tuning.

The CSV includes firmware/profile, completion state, requested rate and sample count in comment lines, then t_us,raw_adc,baseline_adc,threshold_adc,flags,reason. t_us is actual elapsed microseconds from the first saved sample, not an assumed sample index. Flags: 1=candidate matched, 2=pulse high, 4=ADC clipped. reason is the most recent detector decision, so it can persist between pulses. The buffer can start mid-sequence; it records the live state without resetting detection.

For offline analysis, compile the small replay tool against the same detector:

c++ -std=c++17 -O2 -I firmware/FlockNoir tools/replay_opt101.cpp -o replay_opt101
./replay_opt101 capture.csv > pulses.csv

It emits per-pulse observed/cadence Hz, width, duty, support and reason, with sample-rate/gap/range totals on stderr. Replay starts with a fresh baseline; its initial decisions can differ from a capture taken mid-sequence. Warm-up samples are therefore useful. Missing/invalid or unordered raw rows are rejected.

API: POST /api/ir/capture arms a recording (409 if unavailable, paused, disabled or already recording); /api/status reports irCaptureState/irCaptureSamples; GET /api/ir/capture.csv downloads the frozen data. A partial interrupted capture is downloadable and explicitly marked. Downloading does not resume recording.

Validation and limits

Host tests cover weak 45-count clean pulses, 5–29.4 Hz trains, a weak signal with noise/drifting ambient, alternating 90/110 ms intervals, one missing pulse, one bad width, starting high, gaps, complete reset, clipping, timestamp rollover and capture completion/interruption/capacity. Tested constant light, ramps, noise, strongly irregular trains, single-sample spikes and 50/60/100/120 Hz-like flicker are rejected. Camera alias, radio, fusion and packet regression tests also run. These are synthetic tests, not measurements of your ALPR or a false-positive rate. No new device flashing or outdoor validation has been performed for this build.

The TI datasheet gives OPT101 much more analog bandwidth than the requested ADC rate. This sampler still cannot reliably characterize sub-millisecond flashes or exclude aliases from faster illumination. Continuous IR supplies no pulse sequence. At 3.3 V, amplifier saturation can occur below ADC full-scale; a flat trace alone cannot diagnose it. Check light response and output headroom using the hardware guide. Neither a pulse match nor an unfiltered camera image proves ALPR identity.