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
- Weak signals: the initial edge threshold drops from 120 to 32 ADC counts, with a floor of six times the estimated background noise. Falling hysteresis starts at 16 counts. The baseline follows the low level, freezes during a pulse and recovers after sustained illumination; pulses no longer raise their own baseline. Reset clears noise, amplitude, timing and diagnostics together.
- Wider sequence: 5–30 Hz, 3–60% duty and 2–60 ms width, all gates required. Three supporting intervals among the last four can establish a candidate. Periods may vary by 25% around an exponentially smoothed cadence. Two successive rejected intervals discard that cadence. Once two intervals support it, a roughly doubled interval may bridge one missing pulse; it adds only one observed interval, never an invented extra vote.
- Faster delivery: recognition uses complete pulses and queues an event on the sampling task immediately, independent of the 100 ms status publication. A clean 10 Hz / 20 ms train starting from a settled baseline first matches at about 320 ms after its first rise in the synthetic 1 kHz test. Main-loop logging and sound can still add scheduling latency.
- Useful near-misses: frequency, duty and width remain visible when rejected. The dashboard shows the rejection reason, support out of four, actual threshold, pulse/rejection counts, longest sampling gap and measurement age. When a missing pulse is inferred, measured frequency remains unchanged; sequence Hz is separate.
- Raw acquisition: five seconds of actual timestamped 12-bit ADC samples, independent of detection, GPS and SD. A 72 KB PSRAM buffer holds up to 6,000 samples. Capture is explicitly unavailable if allocation fails. It freezes when complete; changing mode or toggling OPT101 stops it and labels it interrupted. A new recording replaces the previous one. Power cycling loses it.
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
- 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. - 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.
- 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.
- 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.
- 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.