Skip to content

DSSS Receivers

The doppler.dsss module provides a full DSSS receiver: two despreaders that track and despread once a signal is acquired — Despreader, the continuous DLL+Costas receiver (GPS-like, always tracking), and BurstDespreader, the preamble-aware payload tracker for latency-bound bursts — and the receivers that compose them. The searches that find the code phase and Doppler in the first place are the searches of Correlator (framing="continuous" and framing="burst") and the acquire API's BurstCapture.

Source: src/doppler/dsss/__init__.py

PolynomialPhaseEstimator — feedforward frequency + chirp-rate estimator

PolynomialPhaseEstimator recovers the frequency and chirp rate (Doppler and Doppler rate) of a complex sequence in one shot — no tracking loop — via a coherent (chirp-rate × frequency) matched-filter surface: for each rate hypothesis it dechirps the sequence and FFTs it, and the surface's global peak (parabola-interpolated in both axes) gives (r, f). Being fully coherent it is the matched-filter-optimal estimator, so it holds at low SNR. The single max_rate knob spans both regimes: max_rate = 0 collapses to one FFT — pure Doppler, near-static — while max_rate > 0 searches a ±max_rate dechirp bank for a severe LEO chirp (cost scales with the rate span). The caller strips modulation first (data-aided wipe, or square an M-PSK stream for the non-data-aided case). estimate(x) returns a PolynomialPhaseEstimate(freq_norm, rate_norm, snr_db) record in normalized units (cycles/sample and cycles/sample²); scale by the sequence's sample rate for Hz. It is the feedforward front-end for chirping-burst demodulation.

BurstDemod — feedforward DSSS frame demodulator

BurstDemod is the whole post-acquisition payload chain, in C, with no tracking loops: it estimates the residual Doppler and Doppler rate feedforward (composing PolynomialPhaseEstimator over the unmodulated preamble), dechirps the burst at sample rate, despreads the short data code to soft BPSK symbols, frame-syncs against a known word, and checks a CRC-16 trailer. The one max_rate knob spans both operating points: near-static Doppler (0, a single-FFT estimate) and a severe LEO chirp (> 0, the coherent rate search). It is one-shot per burst — seed it from acquisition and call demod.

The frame is [sync header][payload][CRC-16 trailer] in BPSK symbols (no FEC). demod(x) returns the whole frame's bits, sync header first, then payload, then the CRC trailer (the example below slices all three); the read-back properties report frame_valid (CRC), est_freq_hz, est_rate_hz, frame_offset, and n_symbols.

import numpy as np
from doppler.dsss import BurstDemod

# Build a burst: 5x acquisition preamble, then a spread frame
# [Barker-13 sync | payload | CRC-16]. A real receiver takes (f0, code
# phase) from the burst `Correlator`/`BurstCapture`; here we seed a known
# prior so the block runs.
acq_code = ((np.arange(500) * 2654435761 >> 13) & 1).astype(np.uint8)
data_code = ((np.arange(50) * 40503 >> 7) & 1).astype(np.uint8)
sync_word = np.array([0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0], np.uint8)
payload = ((np.arange(64) * 7 + 3) & 1).astype(np.uint8)

def _crc16(bits):                          # CRC-16/CCITT, MSB-first
    c = 0xFFFF
    for b in bits:
        c ^= (int(b) & 1) << 15
        c = ((c << 1) ^ 0x1021) & 0xFFFF if c & 0x8000 else (c << 1) & 0xFFFF
    return c

def _sign(b):                              # 0/1 chips -> +1/-1 BPSK
    return np.where(np.asarray(b) & 1, -1.0, 1.0)

# ONE description of the frame: the transmitter spreads it, the receiver is
# told it (its sync word and its length), and nobody sums field lengths.
from doppler.wfm import Frame
desc = Frame(sync=sync_word, payload=payload, crc="crc16")
frame = desc.bits()                        # sync | payload | CRC-16
chips = [np.tile(_sign(acq_code), 5)]      # unmodulated preamble
chips += [_sign(b) * _sign(data_code) for b in frame]
f0, preamble_start = 0.012, 0              # cyc/sample; from acquisition
bb = np.repeat(np.concatenate(chips), 4).astype(np.complex64)
nn = np.arange(len(bb))
rx = (bb * np.exp(2j * np.pi * f0 * nn)).astype(np.complex64)

d = BurstDemod(data_code, desc, spc=4, chip_rate=1e6, carrier_hz=0.0,
               max_rate=0.0, est_segments=10)
d.set_preamble(acq_code, reps=5)
d.set_prior(f0, preamble_start)
frame = d.demod(rx)                 # the FRAME's bits, sync word first
# The demodulator stops at decisions; the frame is undone one layer up.
from doppler.wfm import crc16
payload = frame[13:13 + 64]
rx_crc = 0
for b in frame[13 + 64:][:16]:
    rx_crc = (rx_crc << 1) | int(b)
assert rx_crc == int(crc16(payload))            # the CHECK is the caller's

Despreader — continuous tracking receiver

A complete continuous DSSS-BPSK receiver in one object: Despreader composes a carrier loop (Costas, FLL-assisted) and a code loop (Dll) on a single shared per-sample integrate-and-dump. Per sample it wipes the carrier (integer-NCO) and feeds the de-rotated sample to the DLL's early/prompt/late correlators; per code period it dumps the prompt and updates both loops — the code loop on the early/late envelopes, the carrier loop on the same prompt. steps() emits one despread prompt symbol per code period; bits() turns the prompts into hard data bits.

bn_fll > 0 enables FLL-assisted carrier pull-in. When a data bit spans periods_per_bit code periods (GPS C/A: 20), bits() bit-syncs — it histograms the prompt sign-flip positions to find the bit boundary (bit_phase), then coherently sums periods_per_bit prompts per bit. Each bit follows the library's one polarity, the one mpsk_core.h defines: bit b is sent as 1 - 2b, so a negative prompt sum is a 1, exactly as doppler.cvt.nrz_to_bin decides. The despreader is seeded by acquisition (coarse carrier frequency + code phase) and tracks the residual.

import numpy as np
from doppler.dsss import Despreader
from doppler.wfm import Synth

code = np.random.default_rng(1).integers(0, 2, 127).astype(np.uint8)
rx = Synth(type="pn", pn_length=7, sps=8).steps(127 * 8 * 4)  # PN-spread IQ

d = Despreader(code, sps=8, init_norm_freq=0.0, init_chip=0.0,
               bn_carrier=0.05, bn_code=0.005, bn_fll=0.03,
               zeta=0.707, spacing=0.5, periods_per_bit=1)
symbols = d.steps(rx)   # one despread prompt per code period
bits    = d.bits(rx)    # hard data bits (bit-synced when periods_per_bit > 1)

BurstDespreader — tracking receiver

Seeded with a coarse frequency and code-phase estimate (from the 2-D detector or the burst search, both flavors of Correlator), the BurstDespreader locks the signal with a code-tracking delay-locked loop and a carrier-tracking Costas loop, despreads the payload, and emits symbols.

How it works

Every dimension is a run-time parameter — spreading code, spreading factor (sf), samples-per-chip (sps), loop bandwidths. Per input sample the despreader wipes the carrier (an inline NCO driven by the Costas loop), then correlates against early / prompt / late replicas of the code. Once per code period it dumps the three accumulators:

  • the prompt accumulator is the despread symbol — its sign is the BPSK decision, its phase/magnitude the soft information;
  • the non-coherent early-minus-late envelope drives the DLL (track.LoopFilter) → code phase/rate;
  • the decision-directed product drives the Costas loop → carrier frequency/phase.

Seeding from acquisition. init_norm_freq is the carrier frequency in cycles/sample and init_chip_phase the code phase in chips; the caller converts the detector's (Doppler bin, code-phase chip) into those units (the bin→Hz map depends on the search grid, so it stays application-side).

Distinct acquisition vs data codes. Real bursts use a long acquisition code for the preamble and a different (often shorter) data code for the payload. set_acq(acq_code, acq_reps) enables preamble-aided pull-in — track the unmodulated, repeated acquisition preamble coherently (a full ±π discriminator, so even a wide residual pulls in), then switch to the data code at the payload. Omit it for payload-only operation (seeded from acquisition).

Tracking state is readable: norm_freq (carrier estimate), code_phase, lock_metric (0–1), snr_est. The cf32 symbol output chains over the stream module's dp_header_t framing like any other DSP block.

Despread a payload seeded from acquisition

import numpy as np
from doppler.dsss import BurstDespreader

# data_code: 0/1 spreading chips; seed from the acquisition peak.
# rx is the received capture (reuse the burst built above).
data_code = ((np.arange(32) * 40503 >> 7) & 1).astype(np.uint8)
acq_freq, acq_chip = 0.012, 0.0
d = BurstDespreader(data_code, sf=32, sps=2,
               init_norm_freq=acq_freq, init_chip_phase=acq_chip)
symbols = d.steps(rx)        # complex64 prompt symbols
bits    = d.bits(rx)         # or hard BPSK bits (0/1)
round(d.lock_metric, 2)      # ~1.0 once locked

Preamble-aided pull-in with a distinct acquisition code

burst = rx                        # a received capture (from above)
d = BurstDespreader(data_code, sf=32, sps=2)
d.set_acq(acq_code, acq_reps=5)   # 5-rep preamble pulls the loops in
symbols = d.steps(burst)          # preamble emits nothing; payload follows

DsssReceiver — the composed continuous receiver

The single-object form of Correlator -> Dll(segments) -> RateConverter -> MpskReceiver: only code/chip_rate/symbol_rate are required, everything else defaults to this project's own validated values, with configure_search_raw/configure_lock_raw/configure_chain_raw as the power-user escape hatches. See the DsssReceiver gallery page for the full story this composes.

configure_search_raw bypasses the mislock-avoiding auto-sizer

See the gallery page's own warning before pinning a large doppler_bins directly — DsssReceiver always has symbol_rate set, so the default auto-sizing exists specifically to avoid a confirmed mislock failure mode that a raw pin bypasses.

import numpy as np
from doppler.dsss import DsssReceiver

code = np.random.default_rng(1).integers(0, 2, 127).astype(np.uint8)
rx = DsssReceiver(code, chip_rate=3.0e6, symbol_rate=2100.0, sample_rate=6.0e6)
x = np.zeros(1024, dtype=np.complex64)   # no real signal here -- just show the call
syms = rx.steps(x)   # empty while searching; demodulated symbols once locked
rx.tracking          # 0 = searching, 1 = locked and demodulating

DsssBurstReceiver — the composed burst chain

DsssBurstReceiver is the burst-mode counterpart of DsssReceiver: it acquires a burst's preamble, captures it and demodulates the frame in one object, built from the frame description the transmitter spread. See its gallery page for a run, and BurstCapture if you want the burst's samples without the demodulation.

AsyncDsssReceiver — the packaged continuous async receiver

AsyncDsssReceiver wraps the whole acquire → carrier-refine → track chain behind one steps() call for the continuous asynchronous waveform (non-integer chips/symbol). It carries two carrier loops — a pre-despread Costas that tracks the Doppler dynamics before the code loop, and a post-despread mop-up loop — plus carrier→code aiding for coupled clock Doppler and a binary symbol-lock indicator. See the gallery page AsyncDsssReceiver: the specification waveform for an end-to-end decode through physically-coupled Doppler.

The receiver reports one consistent picture by value through status(). It carries no timestamp: the caller owns the sample clock and stamps it.

refine decides what a detection hands to tracking. True, the default, refines the search's Doppler first. False hands the search's own Doppler straight to tracking, with no refining state, which takes a search at least 25 code periods deep: set code_only_s (and doppler_rate) so coherent_bins reaches 25, or the receiver refuses to build. The pool takes the same flag for all its receivers. The name is a placeholder (async-dsss-receiver §4.4).

The carrier loop ahead of the code loop measures its error, once a code period, over one coherent sum: the code-period window the code loop's look-back picks, the window a data transition does not split. So a symbol must be at least a code period, or the receiver refuses to build (async-dsss-receiver §4.4).

At the CCSDS 415.1-B-1 point: Ccsds415Receiver and Ccsds415Pool

The receiver and the pool at the specification point the receiver is designed for take only the mission's code (1,023 chips) and the carrier. Every other number is the point's, stated once in doppler/ccsds/ccsds_415.h: 3,000 symbols a second, 11 MSa/s, a +/-1,500 Hz search, a Doppler rate of R_env (11 Hz/s), the code-only opening of each frame as the search's gap, and a carrier lock designed at the Es/N0 4 dB floor. The chip rate follows the carrier, doppler.ccsds.ccsds415_chip_rate(). A code of any other length is refused.

import numpy as np
from doppler.dsss import Ccsds415Pool, Ccsds415Receiver
from doppler.wfm import Gold

code = np.asarray(Gold().generate(1023), np.uint8)
rx = Ccsds415Receiver(code, carrier_freq_hz=2.8e9)
pool = Ccsds415Pool(code, n_receivers=4, carrier_freq_hz=2.8e9)

Each is the full class with the point's numbers, byte for byte: src/doppler/examples/ccsds415_receiver.py shows it and checks it.

AsyncDsssPool runs N AsyncDsssReceivers on one stream under a controller that owns the one search (design async-dsss-receiver §5, §8). A pooled receiver has no search of its own: it is idle until the controller seeds it. push() cuts the stream into code periods; in each, the search runs while any receiver is idle, then every receiver steps, in parallel when two or more hold a signal. At each code period the controller releases the lost, resets the later of two receivers on one code phase, seeds the idle receivers from the search's picks, and gives the search the phases already held, so N receivers hold N different signals. The result depends neither on how the stream is blocked nor on the thread count.

status(i) is receiver i's record, the same fields as ReceiverStatus.

Acquirer — a coarse-Doppler bank of burst searches

Acquirer covers a Doppler uncertainty wider than one burst search's native span with a bank of CoarseChannel searches, each mixed to its own center; each hit is a Detection in absolute coordinates. The coarse_doppler_bank_demo.py example finds a burst outside the center channel.

ASYNC_DSSS_RX_STATE — naming a receiver's state

ReceiverStatus.state and PoolReceiverStatus.state are the C async_dsss_rx_state_t value (ASYNC_DSSS_RX_SEARCHING .. _LOST), an int. ASYNC_DSSS_RX_STATE maps each value to its name, so a log line can say where the receiver is without a copy of the enum:

>>> from doppler.dsss import ASYNC_DSSS_RX_STATE
>>> ASYNC_DSSS_RX_STATE
{0: 'searching', 1: 'refining', 2: 'tracking', 3: 'idle', 4: 'lost'}