Skip to content

Add software adaptive gain control, ported from dump1090-fa#35

Open
tytech039 wants to merge 2 commits into
flightaware:masterfrom
tytech039:adaptive-gain
Open

Add software adaptive gain control, ported from dump1090-fa#35
tytech039 wants to merge 2 commits into
flightaware:masterfrom
tytech039:adaptive-gain

Conversation

@tytech039

Copy link
Copy Markdown

This ports dump1090-fa's adaptive gain feature (README.adaptive-gain.md, adaptive.c) to dump978. Two independent modes, both off by default and available only with --sdr:

  • --adaptive-range (dynamic range mode): tracks the noise floor and holds the highest gain that still meets a target dynamic range (default: 60% of the SDR's gain range in dB, ~30dB for an RTLSDR).
  • --adaptive-burst (burst mode): backs the gain off when loud, message-length, undecodable bursts suggest receiver overload, and raises it again once things quieten down.

Implementation notes

  • The full set of dump1090-fa tuning options is exposed under the same names and defaults (--adaptive-min-gain, --adaptive-max-gain, --adaptive-duty-cycle, and the per-mode knobs). Adaptive gain requires manual gain control and is rejected in combination with --sdr-auto-gain.
  • Gain is stepped through a table built from the SoapySDR gain range, falling back to 1dB steps if the device reports no step size.
  • Magnitudes are fed from a new SampleConverter::ConvertMag16 output; decoded message extents are excluded from burst detection as in dump1090. All adaptive work runs on the SDR rx thread, serialized with readStream.
  • Burst detection is adjusted for UAT timing rather than copied verbatim: dump1090 counts loud-window runs of 2–5 windows (80–200µs), matching Mode S frames. UAT downlink frames are 276/420 bits at 1.041667Mbps (~265µs/~403µs), so this accepts runs of 5–13 windows; shorter runs (e.g. DME pulses) and longer ones (ground uplink frames, continuous interference) are ignored. A decoded message's samples are also carried across the adaptive feed boundary so a message clipped at a buffer edge isn't miscounted as an undecoded burst on the next call.
  • Gain changes and a once-a-minute status line are logged to stderr; a README section documents the feature.

Licensing

adaptive.h/adaptive.cc/adaptive_tests.cc retain dump1090's GPLv2+ license headers (copyright FlightAware in both projects). Note this differs from dump978's 2-clause BSD license — happy to adjust if you'd prefer to relicense your own code under BSD here.

Testing

adaptive_tests.cc covers the ported logic and runs under make test alongside fec_tests.

Port dump1090-fa's adaptive.c to dump978. Two independent modes, both
off by default and available only with --sdr:

 * --adaptive-range: track the noise floor and hold the highest gain
   that still meets a target dynamic range
 * --adaptive-burst: back the gain off when loud, message-length,
   undecodable bursts indicate receiver overload

The full set of dump1090-fa tuning options is exposed with the same
defaults. Gain is stepped through a table built from the SoapySDR gain
range (1dB steps if the device reports no step size). Magnitudes are
fed from a new SampleConverter::ConvertMag16 output; decoded message
extents are excluded from burst detection as in dump1090. All adaptive
work runs on the SDR rx thread, serialized with readStream.

adaptive.h/adaptive.cc retain dump1090's GPLv2+ license headers
(copyright FlightAware in both projects); note that this differs from
dump978's 2-clause BSD license.
dump1090 counts loud-window runs of 2..5 windows (80..200us) as candidate
undecoded messages, matching Mode S frames of 64/120us. UAT downlink
frames are 276/420 bits at 1.041667Mbps (~265us/~403us, ~7/~11 windows),
so accept runs of 5..13 windows instead; runs shorter than that (e.g.
DME pulses) or longer (ground uplink frames, continuous interference)
are ignored.

Also carry a decoded message's samples across the adaptive feed boundary
so its remainder is fed as decoded rather than undecoded on the next
call; with the wider run-length bounds, a clipped decoded message could
otherwise be miscounted as an undecoded burst.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant