File carrier_nda_core.h¶
FileList > carrier_nda > carrier_nda_core.h
Go to the source code of this file
Non-data-aided (NDA) M-th-power carrier-tracking loop. More...
#include "doppler/boxcar/boxcar_core.h"#include "doppler/clib_common.h"#include "doppler/dp_state.h"#include "doppler/jm_perf.h"#include "doppler/lo/lo_core.h"#include "doppler/lockdet/lockdet_core.h"#include "doppler/loop_filter/loop_filter_core.h"#include "doppler/dp_tlm/dp_tlm_core.h"#include <math.h>#include "doppler/telemetry/telemetry_core.h"#include "doppler/detection/detection_core.h"
Classes¶
| Type | Name |
|---|---|
| struct | carrier_nda_tlm_t Telemetry attachment: a borrowed context + this object's probe ids. NULL ctx (the default) means detached — the probe site is then a single predicted-not-taken branch per block loop. Zeroed in state blobs and preserved across set_state (DP_DEFINE_POD_STATE_TLM). |
| struct | dp_carrier_nda_state_t NDA M-th-power carrier loop state. |
Public Functions¶
| Type | Name |
|---|---|
| JM_FORCEINLINE JM_HOT int | carrier_nda_arm_step (dp_carrier_nda_state_t * s, float _Complex d, double * pe, double * lock) Slide the moving-average arm by one sample; discriminate the output. |
| JM_FORCEINLINE void | carrier_nda_disc (float _Complex z, int m, double * pe, double * lock) The M-th-power discriminator on an arm sample, normalized by its own amplitude law. |
| JM_FORCEINLINE double | carrier_nda_loop_error (double pe) The discriminator's error as a unit-slope loop takes it: divided by CARRIER_NDA_DISC_SLOPE. The one place every loop on this discriminator scales it __carrier_nda_steer() and MpskReceiver'smpsk_rx_steer() __ so bn means the closed loop's noise bandwidth at high SNR for every M (#3224). Dividing by 2 is exact. |
| JM_FORCEINLINE JM_HOT void | carrier_nda_steer (dp_carrier_nda_state_t * s, double pe) Steer the NCO with a phase error through the loop filter. |
| JM_FORCEINLINE JM_HOT void | carrier_nda_update (dp_carrier_nda_state_t * s, float _Complex z, double noise_pw) One loop update on a caller's integrate-and-dump z: the discriminator with the configured denominator, the configured lock statistic, and the steer. |
| JM_FORCEINLINE JM_HOT float _Complex | carrier_nda_wipeoff (dp_carrier_nda_state_t * s, float _Complex x) Per-sample carrier wipe-off: de-rotate x by the NCO, advance it. |
| void | dp_carrier_nda_configure_lock (dp_carrier_nda_state_t * state, double up_thresh, double down_thresh, uint32_t n_up, uint32_t n_down) Re-tune the carrier lock detector's geometry directly. |
| dp_carrier_nda_state_t * | dp_carrier_nda_create (double bn, double zeta, double init_norm_freq, size_t sps, int n, int m) Create an NDA carrier loop instance. |
| void | dp_carrier_nda_destroy (dp_carrier_nda_state_t * state) Destroy an NDA carrier loop instance and release all memory. |
| double | dp_carrier_nda_get_block_thresh (const dp_carrier_nda_state_t * state) The block lock's threshold on R (0 when the EMA decides). |
| double | dp_carrier_nda_get_bn (const dp_carrier_nda_state_t * state) Loop noise bandwidth currently in use. |
| double | dp_carrier_nda_get_last_error (const dp_carrier_nda_state_t * state) Last phase error from the M-th-power discriminator, raw. |
| double | dp_carrier_nda_get_lock (const dp_carrier_nda_state_t * state) Lock-signal EMA: Re((z/|z|)^M) smoothed per sample by CARRIER_NDA_LOCK_ALPHA. |
| dp_lockdet_rule_t | dp_carrier_nda_get_lock_rule (const dp_carrier_nda_state_t * state) The lock decision's rule (thresholds and verify counts). |
| int | dp_carrier_nda_get_locked (const dp_carrier_nda_state_t * state) Current lock decision (1 = locked, 0 = not), with the configured verify-count / hysteresis rule applied (see dp_carrier_nda_configure_lock). |
| int | dp_carrier_nda_get_m (const dp_carrier_nda_state_t * state) Constellation order the discriminator strips. |
| int | dp_carrier_nda_get_n (const dp_carrier_nda_state_t * state) Arm-window divisor: the moving average spans sps / n samples. |
| double | dp_carrier_nda_get_nco_freq (const dp_carrier_nda_state_t * state) Instantaneous NCO frequency command = centre + full loop-filter output (integ + kp*e), cycles/sample. Mean rides a ramp with no lag; variance is the loop stress. See the impl for the estimator-vs-command distinction. |
| double | dp_carrier_nda_get_nco_phase_ahead (const dp_carrier_nda_state_t * state, size_t ahead) The carrier phase the NCO will apply ahead samples from now, with no loop update in between. |
| double | dp_carrier_nda_get_norm_freq (const dp_carrier_nda_state_t * state) Tracked carrier frequency: the NCO centre plus the loop's integrated correction (integrator only, smoothed), spread over the update period. |
| size_t | dp_carrier_nda_get_sps (const dp_carrier_nda_state_t * state) Samples per symbol the arm window is sized from. |
| void | dp_carrier_nda_get_state (const dp_carrier_nda_state_t * state, void * blob) Serialize the full loop state into blob . |
| void | dp_carrier_nda_hold (dp_carrier_nda_state_t * state) Hold the loop: the NCO runs on the integrator alone until the next update. |
| void | dp_carrier_nda_init (dp_carrier_nda_state_t * s, double bn, double zeta, double init_norm_freq, size_t sps, int n, int m) Initialise an NDA carrier loop in place (no allocation). |
| void | dp_carrier_nda_reset (dp_carrier_nda_state_t * state) Re-seed the loop to its create-time frequency/phase; keep config. |
| int | dp_carrier_nda_set_block_lock (dp_carrier_nda_state_t * state, uint32_t len, double pfa, uint32_t n_up, uint32_t n_down) Decide the lock on a block: the ratio of sums over len updates, against the exact threshold atpfa . |
| int | dp_carrier_nda_set_bn (dp_carrier_nda_state_t * state, double val) Retune bn, keeping zeta. A bn outside dp_loop_filter_params_ok() is refused ( DP_ERR_INVALID ) and changes nothing: the gains, their rad->cycle scale and the reported bn all stay (doppler#2112). As a writable property a refusal raises ValueError (doppler#1987). |
| int | dp_carrier_nda_set_denominator (dp_carrier_nda_state_t * state, double alpha, double gamma_d) Choose what divides the phase error: the update's power averaged with weight alpha , less the caller's noise power whengamma_d is set. |
| void | dp_carrier_nda_set_norm_freq (dp_carrier_nda_state_t * state, double val) Re-seed the loop at a new carrier frequency. |
| int | dp_carrier_nda_set_state (dp_carrier_nda_state_t * state, const void * blob) Restore a state written by dp_carrier_nda_get_state() . |
| int | dp_carrier_nda_set_telemetry (dp_carrier_nda_state_t * state, dp_tlm_t * tlm, const char * prefix, uint32_t decim) Attach (or detach) a telemetry context and register the carrier loop's probes on it. Registers five probes, emitted once per input sample (this is a sample-rate loop — use decim to thin the stream): "<prefix>.lock" (the lock statistic: the EMA, ~1 when phase-locked, or the last block's R), "<prefix>.e" (the M-th-power phase discriminator — the loop stress), "<prefix>.freq" (the tracked carrier frequency, cycles/sample), "<prefix>.locked" (the verify-counted lockdet decision, 0/1) and "<prefix>.nco" (the full NCO command, cycles/sample). Passing NULL detaches. Setup path, never hot: call before the producer thread starts stepping; the context is borrowed and must outlive the attachment (SPSC rules indp_tlm/dp_tlm_core.h ). |
| int | dp_carrier_nda_set_update_period (dp_carrier_nda_state_t * state, double t_upd) Set the loop's update period: t_upd samples a loop update. |
| size_t | dp_carrier_nda_state_bytes (const dp_carrier_nda_state_t * state) Serialized-state byte size. |
| size_t | dp_carrier_nda_steps (dp_carrier_nda_state_t * state, const float _Complex * x, size_t x_len, float _Complex * out, size_t max_out) De-rotate a cf32 block with the recovered carrier and return the de-rotated stream (one output per input sample). |
| size_t | dp_carrier_nda_steps_max_out (dp_carrier_nda_state_t * state) Output capacity hint for dp_carrier_nda_steps() : always 0. |
| void | dp_carrier_nda_tlm_flush (const dp_carrier_nda_state_t * s) Emit the carrier loop's telemetry records for the current sample. |
Macros¶
| Type | Name |
|---|---|
| define | CARRIER_NDA_BLOCK_MAX_LEN 10000000uThe largest block a block lock takes, updates. Its threshold is dp_det_threshold_f() 's F(len, len) quantile, a bisection on a continued fraction capped at 300 terms. Against scipy's f.isf , the threshold r it gives holds to 1e-9 relative at 1e7 and fails outright between 2e8 and 5e8 (r even turns negative at 2^31). A block of 1e7 code periods is about 50 minutes at the 415.1-B-1 point. |
| define | CARRIER_NDA_DEN_AVERAGED 1An average of |z|^2 (an EMA, booted as a cumulative mean). Its mean is signal plus noise, so the gain isgamma/(gamma + 1) at update SNR gamma. M = 2 only. |
| define | CARRIER_NDA_DEN_LIMITER 0The denominator in force (the state's den , whichdp_carrier_nda_set_denominator() derives from its arguments): the update's own|z|^2 , a per-update limiter (the default, and the onecarrier_nda_disc() computes). GainE[1/(1 + n/A)] , falling with SNR. |
| define | CARRIER_NDA_DEN_STEP 13.815510557964274The averaged and unit denominators' floor, as a fraction of the update's own |z|^2 : the denominator is never under|z|^2 / this , so the error 2IQ over it, at most|z|^2 over it, is never past this in magnitude. Derived from a chosen rate, 1e-6: on noise alone|z|^2 over its mean is exponential,P(|z|^2 > x mean) = e^-x , so x = -ln(1e-6) engages the floor on one update in 10^6. With a signal the unit form compares|z|^2 with the signal's powerA^2 (its denominator's value), the noncentral chi-square tailQ_1(sqrt(2 gamma), sqrt(2 x gamma)) at update SNR gamma: at the 415.1-B-1 floor's window sums, 2.6e-9 at gamma 2.397 (2.2 GHz) and 1.3e-7 at 1.884 (2.8 GHz), under the noise-only rate; the averaged form, againstA^2 + N , 7e-14 and 3e-12. Printed by test_carrier_nda_core.c's 17c throughdp_marcum_q() . Otherwise it engages only on a level step the running average has not yet followed (a burst, a gain step upstream), which the quotient would hand the loop unbounded. |
| define | CARRIER_NDA_DEN_UNIT 2That average less the caller's noise power, clamped between avg * gamma_d/(gamma_d + 1) and avg, with gamma_d the design update SNR: gain 1 where the estimate holds, never above the design point's, never the averaged form's sign. M = 2 only. |
| define | CARRIER_NDA_DISC_SLOPE 2.0The discriminator's slope at lock, error per radian of carrier phase, at every M: sin 2 theta at M = 2 and the {1, 1/2, 1/4} scale that makes it 2 at 4 and 8 too.What has slope 2 is the raw discriminator output:carrier_nda_disc() ,last_error , the.e probe anddp_carrier_nda_get_last_error() .What the filter is handed has slope 1: a loop filter's gains assume the rest of its loop has unit gain (dp_loop_filter_init() ), so the error reaches the filter divided by this, throughcarrier_nda_loop_error() , andbn andzeta are then the closed loop's (#3224). |
| define | CARRIER_NDA_EPS 1e-12Numerical guard on the arm sample's power |z|^2: at or below it (or NaN) the discriminator outputs 0 for both phase error and lock signal (not tunable). |
| define | CARRIER_NDA_INV_2PI 0.15915494309189535 /\* 1 / (2\*pi) \*/1/(2*pi): rad -> cycles scale folded into the loop gains so the loop filter outputs the NCO control in cycles/sample. |
| define | CARRIER_NDA_LOCK_ALPHA 0.05EMA smoothing (per sample) for the lock metric: alpha = det_ema_alpha(0.0, 15.9), giving N_eff = (2-alpha)/alpha = 39 effective looks (>= the 30-look floor). |
| define | CARRIER_NDA_LOCK_NORM_SD 0.11322770341445956Analytic H0 sd of the limited lock statistic AFTER the EMA above: sqrt(Var_look * alpha/(2-alpha)) with Var_look = 1/2 exactly, for every M. A threshold of eta * this has per-look Pfa = Q(eta). |
| define | CARRIER_NDA_STATE_MAGIC [**DP\_FOURCC**](dp__state_8h.md#define-dp_fourcc) ('C', 'N', 'D', 'A')State-blob magic for CarrierNda (FourCC "CNDA"). |
| define | CARRIER_NDA_STATE_VERSION /* multi line expression */State-blob layout version (v6: the composer's options). |
Detailed Description¶
A carrier-recovery loop that locks without data and without symbol timing — the cold-start / acquisition counterpart to the decision-directed dp_carrier_mpsk_state_t loop. Per sample it de-rotates the input with the integer-phase dp_lo_state_t NCO (carrier wipe-off); it filters the de-rotated samples through a free-running I/Q boxcar moving average of sps/n samples (one output per input sample — no rate change), and on every sample runs the M-th-power phase discriminator, filters the error through an embedded dp_loop_filter_state_t, and steers the NCO frequency + phase.
Raising the arm sample z to the Mth power strips the M-PSK data modulation, leaving M times the carrier phase — so the discriminator is independent of the data symbols and of symbol timing. That is what lets it acquire a bare/unmodulated carrier, or a modulated carrier before timing lock. It is the M-fold-ambiguous acquisition aid; a decision-directed loop gives the low-jitter steady state (resolve the M-fold ambiguity downstream).
The M-th power is computed by repeated complex squaring (z²→z⁴→z⁸) of the unit-magnitude sample z/|z|. Each level yields a phase error and a lock signal:
* phase_error = Im((z/|z|)^M) scaled by 1, ½, ¼ for M = 2, 4, 8 — the scale normalizes the phase-detector gain so the S-curve slope at lock is 2 for every M (one bn behaves identically across M).
* lock_signal = Re((z/|z|)^M) — the M-th power of a limited sample, so it is bounded in ±1 and its H0 variance is 1/2 for every M. ~1 when phase-locked, zero-mean with no carrier. That M-independence is what makes one lock_thresh mean one Pfa at every order; the threshold chain is derived above CARRIER_NDA_LOCK_ALPHA. Its EMA (lock) is the carrier lock metric. See docs/design/mpsk.md §4.2, "Limiting — what makes the
threshold a Pfa", for the derivation.
The block API (dp_carrier_nda_steps) is the Python face and emits the de-rotated sample stream; the JM_FORCEINLINE carrier_nda_wipeoff()/_arm_step()/_steer() are the same loop's three steps as a C composition API, for a caller that runs the loop inside its own sample loop.
Note:
The input SCALE does not matter, and there is no AGC here. The discriminator divides out its own amplitude law (|z|^M) exactly, so both outputs — and with them the loop gain — are invariant to input scale over the whole float range: measured identical to 6.5e-7 relative from an amplitude of 1e-5 to 1e15, at every M a few float eps, which is the rounding floor a float detector has and not a level dependence. The measurement is test_carrier_nda_core.c section 9; this file carried a tighter 5e-7 that the test itself had already corrected, so the number here now comes from the thing that runs it. This loop used to embed a slow arm AGC whose only job was to manufacture |z| = 1 so a raw Im(z^M) would behave; that condition no longer has to be manufactured, and the AGC is gone. A receiver needs exactly one AGC, for its own signal path, and not one per detector (docs/design/mpsk.md §3.2, "The NDA discriminator +
lock signal").
SCALE is not Es/N0, and only the first of them is invariant here. Section 9 scales a clean phasor, so it holds signal and noise in the same ratio; that is homogeneity of degree zero, plus — the reason the test earns its place — a float-RANGE gate, since forming |z|^M at the end instead returns 0 below |z| = 0.032 and NaN above 1e4 at M = 8. It says nothing about level relative to NOISE, and it should not be read as though it did: per-sample division by the instantaneous |s+n| is a hard limiter, so the S-curve slope genuinely does depend on Es/N0. That dependence is measured, as loop SNR against the un-normalised form across 0–20 dB and every M, in docs/design/mpsk.md §3.2 — the penalty is real at 0–3 dB, where the link cannot be closed anyway, and from ~6 dB up normalising is equal or better. This distinction was read the other way once (gh-795), which is why it is spelled out rather than implied.
** **
A caller must start the residual carrier inside a window, and there are two separate limits on that window. Which one binds decides whether a violation is obvious or silent, so both belong here rather than only in the design of whatever composes this.
Loop capture, roughly k * bn / M. Where pull-in is prompt and predictable: k is 1/4 for settling within 2/bn samples (the validation report's §2.5 seeding rule), and a residual inside bn/M settles within 5/bn. This is the tighter bound at every shipped setting and it is the one a caller normally meets. Violating it is LOUD: the tracked frequency walks and locked never asserts, which is unmistakable in telemetry.
The aliasing ceiling, 1/(2M) cycles per sample. The discriminator runs once per input sample, so an M-th power folds when the residual advances more than half a cycle per update i.e. at a residual of 1/(2M) cyc/sample, with stable false locks spaced 1/M apart. The M-fold ambiguity is therefore a FREQUENCY ambiguity as well as a phase one. Violating this is SILENT and it is this object's worst failure mode: the loop sits still at the wrong frequency and reports a healthy lock statistic measured on QPSK at a residual of one quarter the update rate, tracked frequency 2e-6 against a true 0.03125 and a lock statistic of +0.83 against the ~1.0 a real lock reads. Nothing self-referenced detects it: the constellation is stationary, so EVM and blind M2M4 both look clean. It takes an external frequency reference, a sync word, or a coarse estimate seeded through init_norm_freq.
Both scale as 1/M, so an 8PSK caller needs four times tighter tuning than BPSK at the same bandwidth. See docs/design/mpsk.md §3.4 and §3.5.
** **
The ceiling is linear in the rate the discriminator updates at, and nothing else in the loop depends on that rate so it is free margin for whoever picks it. Stepping this object per input sample, which is what dp_carrier_nda_steps does, is the widest setting available and puts the ceiling tens of times beyond loop capture. A composer that instead taps a DECIMATED stream inherits a proportionally tighter ceiling: at two samples per symbol it falls to one symbol rate over M, which is the regime the QPSK false lock above was measured in. The rule for a composition is to choose the tap so the ceiling stays clear of loop capture at every M it supports, which makes the silent failure structurally unreachable and leaves only the loud one.
** **
bn (with zeta) is the closed loop's: the discriminator's slope at lock, 2 at every M, is divided out before the loop filter (carrier_nda_loop_error(), #3224), so bn is the loop's noise bandwidth and zeta its damping whenever the discriminator's gain is its high-SNR value. Measured, test_carrier_nda_core.c section 18: 1.00 to 1.04 of bn at every M and denominator. At finite SNR the gain falls by what each denominator gives, and the loop's bandwidth and damping with it:
* the limiter (the default): its gain falls with the SNR at the discriminator (0.62 at 3.8 dB a look); there bn is the design value of a loop that runs narrower;
* the averaged form: gamma/(gamma + 1) at update SNR gamma;
* the unit form: 1, while the caller's noise power holds. Until #3224 the slope went undivided and the loop ran about 1.67 times wider than bn said, at a damping near 1.0.
** **
A composer that runs the loop on its own integrate-and-dump (a despreader's window sum once a code period, say) drives it through the composition API, carrier_nda_wipeoff() once a sample and carrier_nda_update() once a sum, and sets up to three options, each off by default, so dp_carrier_nda_steps() and every existing caller are unchanged:
* the update period, dp_carrier_nda_set_update_period(): bn becomes per update and the loop's command is spread over the samples of an update, as Costas does;
* the denominator, dp_carrier_nda_set_denominator(): the phase error over an average of |z|^2 (the averaged form, gain gamma/(gamma+1)), or over that average less the caller's noise power, clamped (the unit form, gain 1), in place of the per-update limiter;
* a block lock, dp_carrier_nda_set_block_lock(): the ratio of sums R = sum(I^2 - Q^2) / sum(I^2 + Q^2) over a block, against the exact Beta threshold at a Pfa, in place of the per-sample EMA. The two M-th-power options are derived at M = 2 only and refused at 4 and 8, whose laws are not derived. The derivation and the numbers at the 415.1-B-1 point are docs/design/async-dsss-receiver.md, "The
pre-despread carrier loop" (in §4.10, the tracking stage).
** **
n sets the arm window to sps / n samples, and the window is not free: the arm averages across data transitions, so its coherent gain after the M-th power falls as the window widens. For the half-symbol arm (n = 2) the gain is 1/2 + 1/(M+1) 5/6 at BPSK, 7/10 at QPSK, 11/18 at 8PSK against unity for a constant-modulus input. A caller choosing n is choosing a sensitivity loss, and the validation report is the evidence for what each choice costs.
// QPSK NDA carrier loop, 8 samples/symbol, 2-sample moving-average arm
dp_carrier_nda_state_t *c = dp_carrier_nda_create(0.01, 0.707, 0.0, 8, 4, 4);
float _Complex derot[1024];
size_t k = dp_carrier_nda_steps(c, rx, rx_len, derot, 1024);
double f = dp_carrier_nda_get_norm_freq(c); // tracked carrier (cyc/sample)
dp_carrier_nda_destroy(c);
Public Functions Documentation¶
function carrier_nda_arm_step¶
Slide the moving-average arm by one sample; discriminate the output.
JM_FORCEINLINE JM_HOT int carrier_nda_arm_step (
dp_carrier_nda_state_t * s,
float _Complex d,
double * pe,
double * lock
)
The arm is a free-running boxcar moving average of the last arm_len de-rotated samples — one output per input sample, no rate change (not a decimating integrate-and-dump). It updates the running window sum in O(1) (add d, subtract the sample leaving the window), runs the M-th-power discriminator on the window average, writes pe and lock, and returns 1 every call.
Parameters:
sCarrier loop state. Must be non-NULL.dOne de-rotated sample (from carrier_nda_wipeoff).peReceives the phase error.lockReceives the lock signal.
Returns:
Always 1 (one discriminator output per input sample).
function carrier_nda_disc¶
The M-th-power discriminator on an arm sample, normalized by its own amplitude law.
Runs the repeated-squaring recursion z²→z⁴→z⁸ on the unit- magnitude sample z/|z| and writes the phase error (= scaled Im((z/|z|)^M)) and the lock signal (Re((z/|z|)^M)). Both outputs are therefore invariant to the input's scale, which is what lets this loop run with no AGC in front of it — see the amplitude note at the top of this file, and docs/design/mpsk.md §3.2, "The NDA discriminator + lock
signal", for the squaring-loss measurement that says normalizing is equal or better from ~6 dB Es/N0 up: loop SNR against the raw form, 4e5 samples per point, tabulated over 0–20 dB and M = 2/4/8.
Parameters:
zArm moving-average sample (any scale; only its phase is used).mConstellation order (2, 4, 8).peReceives the phase error.lockReceives the lock signal.
function carrier_nda_loop_error¶
The discriminator's error as a unit-slope loop takes it: divided by CARRIER_NDA_DISC_SLOPE. The one place every loop on this discriminator scales it __carrier_nda_steer() and MpskReceiver'smpsk_rx_steer() __ sobn means the closed loop's noise bandwidth at high SNR for every M (#3224). Dividing by 2 is exact.
Parameters:
peThe discriminator's output.
Returns:
The error in radians of carrier phase, slope 1 at lock.
function carrier_nda_steer¶
Steer the NCO with a phase error through the loop filter.
Filters pe and stores the PI filter's output (integ + kp*pe, in cycles an update) spread over the update's t_upd samples, cycles a sample, as the frequency control the next carrier_nda_wipeoff() feeds the LO. At the default t_upd of 1 the division is exact and the control is the filter's output.
Parameters:
sCarrier loop state. Must be non-NULL.pePhase error from the NDA discriminator (carrier_nda_arm_step).
function carrier_nda_update¶
One loop update on a caller's integrate-and-dump z: the discriminator with the configured denominator, the configured lock statistic, and the steer.
JM_FORCEINLINE JM_HOT void carrier_nda_update (
dp_carrier_nda_state_t * s,
float _Complex z,
double noise_pw
)
The composition API's update, for a caller that forms its own arm (a despread window sum, once a code period) and calls carrier_nda_wipeoff() once a sample in between. With every option at its default it is exactly dp_carrier_nda_steps()'s per-sample update: carrier_nda_disc() on z, the lock EMA and its decision, the steer.
- The error is
Im(z^M)over the configured denominator:|z|^M(the limiter, carrier_nda_disc()), the running average of|z|^2(averaged, M = 2), or that average lessnoise_pw, clamped (unit, M = 2). The running average takeszbefore it divides, and boots as a cumulative mean: the weight is the larger of 1/n andden_alpha. - The lock is the EMA of
Re((z/|z|)^M)and its decision, or, with a block lock set, the ratio of sums over the block, decided once a block against its threshold.
Parameters:
sCarrier loop state. Must be non-NULL.zThe update's arm sample (any scale).noise_pwThe noise power inz'sown units (E|n|^2of one update), read by the unit denominator only; pass 0 otherwise.
function carrier_nda_wipeoff¶
Per-sample carrier wipe-off: de-rotate x by the NCO, advance it.
JM_FORCEINLINE JM_HOT float _Complex carrier_nda_wipeoff (
dp_carrier_nda_state_t * s,
float _Complex x
)
Parameters:
sCarrier loop state. Must be non-NULL.xOne input sample.
Returns:
The de-rotated sample to feed the moving-average arm.
function dp_carrier_nda_configure_lock¶
Re-tune the carrier lock detector's geometry directly.
void dp_carrier_nda_configure_lock (
dp_carrier_nda_state_t * state,
double up_thresh,
double down_thresh,
uint32_t n_up,
uint32_t n_down
)
Full lockdet control, mirroring dp_costas_configure_lock(): a split declare/drop threshold pair on the lock-signal EMA (level hysteresis) and both verify counts (time hysteresis). Defaults (0.5/0.4, 64 up / 32 down) start from MpskReceiver's own carrier lock-indicator thresholds, but size n_up independently: lock is a fast per-sample EMA, so consecutive looks are highly autocorrelated and MpskReceiver's own n_up=8 does not compound the false-declare rate the way it would for independent looks (direct Monte Carlo against a noise-only, no-carrier input found real false locks at n_up=8; n_up=64 was the smallest verify count that reliably eliminated them see carrier_nda_core.c's CARRIER_NDA_LOCK_DEFAULT_* comment for the exact trial data). A live lock survives the re-tune; the in-flight verify run restarts. It re-tunes the EMA's rule: with a block lock set (dp_carrier_nda_set_block_lock()), it returns to the EMA first, so block_thresh and the rule in force never disagree.
Parameters:
stateMust be non-NULL.up_threshDeclare threshold on the lock-signal EMA.down_threshDrop threshold; choose <= up_thresh for level hysteresis.n_upConsecutive above-threshold samples to declare; clamped >= 1.n_downConsecutive below-threshold samples to drop; clamped >= 1.
function dp_carrier_nda_create¶
Create an NDA carrier loop instance.
dp_carrier_nda_state_t * dp_carrier_nda_create (
double bn,
double zeta,
double init_norm_freq,
size_t sps,
int n,
int m
)
Parameters:
bnLoop noise bandwidth (default 0.01), of the closed loop given a unit-slope detector (see LoopFilter). The detector's slope is 2 per radian at every M and level (doppler#3224), so the delivered bandwidth is 5/3 ofbnat damping 0.707 until that is fixed; it also falls with the SNR per arm.zetaDamping factor (default 0.707).init_norm_freqSeed carrier frequency, cycles/sample (default 0.0).spsSamples per symbol (default 8).nMA window divisor: window = sps/n (default 4; spsn==0).mConstellation order M, 2/4/8 (default 4 = QPSK).
Returns:
Heap-allocated state, or NULL on invalid args / allocation failure.
Note:
Caller must call dp_carrier_nda_destroy() when done.
function dp_carrier_nda_destroy¶
Destroy an NDA carrier loop instance and release all memory.
Parameters:
stateMay be NULL.
function dp_carrier_nda_get_block_thresh¶
The block lock's threshold on R (0 when the EMA decides).
Parameters:
stateMust be non-NULL.
Returns:
The threshold set_block_lock() derived, or 0.
function dp_carrier_nda_get_bn¶
Loop noise bandwidth currently in use.
Parameters:
stateMust be non-NULL.
Returns:
bn per update, cycles an update: cycles/sample at the default update period of 1. The create() value or the last one dp_carrier_nda_set_bn() accepted.
function dp_carrier_nda_get_last_error¶
Last phase error from the M-th-power discriminator, raw.
Im((z/|z|)^M) scaled by 1, 1/2, 1/4 for M = 2, 4, 8, which equalizes the S-curve slope across M at CARRIER_NDA_DISC_SLOPE (2); with an averaged or unit denominator, 2IQ over that denominator, slope 2 at unit amplitude. This is the discriminator's output, as the .e probe reads it, NOT what the loop filter is handed: the filter takes it divided by the slope, carrier_nda_loop_error(), slope 1.
Parameters:
stateMust be non-NULL.
Returns:
Dimensionless error, bounded in magnitude by 1 with the limiter and by CARRIER_NDA_DEN_STEP with the averaged or unit denominator; 0 before the first sample.
function dp_carrier_nda_get_lock¶
Lock-signal EMA: Re((z/|z|)^M) smoothed per sample by CARRIER_NDA_LOCK_ALPHA.
Parameters:
stateMust be non-NULL.
Returns:
Value from -1 to 1; ~1 at lock, zero-mean (sd CARRIER_NDA_LOCK_NORM_SD) with no carrier; 0 after create/reset.
function dp_carrier_nda_get_lock_rule¶
The lock decision's rule (thresholds and verify counts).
Parameters:
stateMust be non-NULL.
Returns:
The rule the lock detector holds.
function dp_carrier_nda_get_locked¶
Current lock decision (1 = locked, 0 = not), with the configured verify-count / hysteresis rule applied (see dp_carrier_nda_configure_lock).
Parameters:
stateMust be non-NULL.
Returns:
1 when locked, 0 otherwise (0 after create/reset).
function dp_carrier_nda_get_m¶
Constellation order the discriminator strips.
Parameters:
stateMust be non-NULL.
Returns:
M: 2, 4 or 8, fixed at create.
function dp_carrier_nda_get_n¶
Arm-window divisor: the moving average spans sps / n samples.
Parameters:
stateMust be non-NULL.
Returns:
n, fixed at create.
function dp_carrier_nda_get_nco_freq¶
Instantaneous NCO frequency command = centre + full loop-filter output (integ + kp*e), cycles/sample. Mean rides a ramp with no lag; variance is the loop stress. See the impl for the estimator-vs-command distinction.
Parameters:
stateMust be non-NULL.
Returns:
Frequency in cycles/sample; the seed frequency until the loop has run.
function dp_carrier_nda_get_nco_phase_ahead¶
The carrier phase the NCO will apply ahead samples from now, with no loop update in between.
carrier_nda_wipeoff() advances the NCO by its centre increment plus the loop's control, both fixed between updates, so ahead samples on the phase word is that sum ahead times, in the NCO's own 32-bit arithmetic: exact for every sample before the next update. A composition holding samples not yet wiped asks this for the phase at the newest one.
Parameters:
stateMust be non-NULL.aheadSamples from the next one to be wiped (0 = that one).
Returns:
Phase in cycles, in [0, 1).
function dp_carrier_nda_get_norm_freq¶
Tracked carrier frequency: the NCO centre plus the loop's integrated correction (integrator only, smoothed), spread over the update period.
Under a frequency ramp it lags the true carrier by the Type-II ramp error; see dp_carrier_nda_get_nco_freq() for the full command.
Parameters:
stateMust be non-NULL.
Returns:
Frequency in cycles/sample; the seed frequency until the loop has run.
function dp_carrier_nda_get_sps¶
Samples per symbol the arm window is sized from.
Parameters:
stateMust be non-NULL.
Returns:
sps, in samples, fixed at create.
function dp_carrier_nda_get_state¶
Serialize the full loop state into blob .
A whole-struct snapshot (config, NCO, loop filter, boxcar arm, lock EMA and detector) with the telemetry attachment zeroed.
Parameters:
stateMust be non-NULL.blobCaller-owned buffer of at least dp_carrier_nda_state_bytes() bytes.
function dp_carrier_nda_hold¶
Hold the loop: the NCO runs on the integrator alone until the next update.
carrier_nda_steer() commands (integ + kp*e) / t_upd cycles a sample, and carrier_nda_wipeoff() applies that command every sample until the next update: the proportional term kp*e is spread over the update's t_upd samples, a phase step of kp*e in all. A composer that stops updating (a coast, or a period whose update it skips) would otherwise go on applying that step every update interval, a frequency bias of kp*e / t_upd for as long as it holds. This sets the command to integ / t_upd, the integrator's frequency, as a coast should run. The integrator, the lock and the NCO's phase are unchanged; the next update steers as usual.
Parameters:
stateMust be non-NULL.
function dp_carrier_nda_init¶
Initialise an NDA carrier loop in place (no allocation).
void dp_carrier_nda_init (
dp_carrier_nda_state_t * s,
double bn,
double zeta,
double init_norm_freq,
size_t sps,
int n,
int m
)
Parameters:
sState to initialise. Must be non-NULL.bnLoop noise bandwidth, cycles/sample (per-sample loop).zetaDamping factor (1.0 = critical; 0.707 usual).init_norm_freqSeed carrier frequency, cycles/sample.spsSamples per symbol.nMA window divisor: window = sps/n samples (sps % n == 0, sps/n <= BOXCAR_MAX_LEN).mConstellation order M (2, 4, 8).
Unguarded, as the by-value path: the caller checks (bn, zeta) with dp_loop_filter_params_ok() first. Outside it the loop filter is not written at all config_loop refuses and changes nothing so an in-place init leaves the gains and bn/zeta unset, since seed() zeroes integ (doppler#2103).
function dp_carrier_nda_reset¶
Re-seed the loop to its create-time frequency/phase; keep config.
Restores the object to its post-create state: the carrier NCO is reset to the seed frequency it was constructed with (init_norm_freq) with zero phase, the moving-average arm, the loop-filter integrator and the lock EMA are cleared, and the lock detector is dropped. The configured (bn, zeta), the arm geometry (sps, n) and the constellation order m are preserved, so the same object can re-acquire a fresh capture.
Parameters:
stateMust be non-NULL.>>> import numpy as np >>> from doppler.track import CarrierNda >>> c = CarrierNda(bn=0.01, zeta=0.707, init_norm_freq=0.0, ... sps=8, n=4, m=4) >>> rng = np.random.default_rng(0) >>> k = np.arange(40000) >>> x = (np.exp(2j * np.pi * 0.001 * k) + 0.05 * ( ... rng.standard_normal(k.size) ... + 1j * rng.standard_normal(k.size))).astype(np.complex64) >>> _ = c.steps(x) >>> round(c.norm_freq, 4), round(c.lock, 2) # acquired the carrier (0.001, 0.99) >>> c.reset() >>> round(c.norm_freq, 4), round(c.lock, 2) # back to seed, unlocked (0.0, 0.0)
function dp_carrier_nda_set_block_lock¶
Decide the lock on a block: the ratio of sums over len updates, against the exact threshold atpfa .
int dp_carrier_nda_set_block_lock (
dp_carrier_nda_state_t * state,
uint32_t len,
double pfa,
uint32_t n_up,
uint32_t n_down
)
R = sum(I^2 - Q^2) / sum(I^2 + Q^2) over a block of updates, dumped once a block. On noise alone (R + 1)/2 is exactly Beta(len/2, len/2): the block's own total power is the noise reference, so the threshold needs no noise estimate. It is that law's upper pfa point, through dp_det_threshold_f() (R > r is X/Y > (1 + r)/(1 - r) for X, Y chi-square on len degrees). The decision takes n_up blocks above it to declare and n_down below it to drop (one threshold, time hysteresis only). lock then reads the last block's R.
len 0 returns to the per-sample EMA and its default rule (dp_carrier_nda_configure_lock()'s). M = 2 only. Either way the lock decision restarts unlocked, and the block in progress is cleared.
Parameters:
stateMust be non-NULL.lenUpdates a block, 2 to CARRIER_NDA_BLOCK_MAX_LEN; or 0 for the EMA.pfaThe false-alarm rate a block, in (0, 1/2): at 1/2 or more the threshold is at or under 0 and the lock declares on noise as often as not.n_upBlocks above the threshold to declare; clamped >= 1.n_downBlocks below it to drop; clamped >= 1.
Returns:
DP_OK, or DP_ERR_INVALID (nothing changes) for an M other than 2, a len of 1 or past CARRIER_NDA_BLOCK_MAX_LEN, or a pfa out of range.
>>> from doppler.track import CarrierNda
>>> c = CarrierNda(bn=0.012, sps=8, n=1, m=2)
>>> c.set_block_lock(31, 1e-3, 2, 3)
>>> round(c.block_thresh, 3) # the Beta(15.5, 15.5) upper 1e-3 point
0.518
function dp_carrier_nda_set_bn¶
Retune bn, keeping zeta. A bn outside dp_loop_filter_params_ok() is refused (DP_ERR_INVALID ) and changes nothing: the gains, their rad->cycle scale and the reported bn all stay (doppler#2112). As a writable property a refusal raises ValueError (doppler#1987).
Parameters:
stateMust be non-NULL.valNew loop noise bandwidth, cycles/sample.
Returns:
DP_OK, or DP_ERR_INVALID if refused (nothing changes).
function dp_carrier_nda_set_denominator¶
Choose what divides the phase error: the update's power averaged with weight alpha , less the caller's noise power whengamma_d is set.
One parametrization covers the three forms:
* alpha = 1, gamma_d = 0: one update's own |z|^2, the limiter (the default; carrier_nda_disc()'s arithmetic, exactly);
* alpha < 1, gamma_d = 0: the average, the averaged form;
* gamma_d > 0: the average less the noise, clamped between the design point's signal share, avg * gamma_d/(gamma_d + 1), and the average itself, the unit form. At update SNR gamma the limiter's gain falls with the SNR, the averaged form's is gamma/(gamma + 1), and the unit form's is 1 while the caller's noise power holds (carrier_nda_update()). The clamp keeps the unit form's gain at most the design point's 1, and its sign the average's, at boot or when the noise estimate is off.
Every form but the limiter is derived at M = 2 only and refused at M = 4 and 8. Setting a form clears the running average; the loop's other state is untouched.
Parameters:
stateMust be non-NULL.alphaThe average's EMA weight an update, in (0, 1]: 1/256 at the 415.1-B-1 point, 1 for the limiter.gamma_dThe design update SNR, linear: > 0 for the unit form, 0 otherwise.
Returns:
DP_OK, or DP_ERR_INVALID (nothing changes) for an alpha outside (0, 1], a gamma_d negative or not finite, or a form other than the limiter at an M other than 2.
>>> from doppler.track import CarrierNda
>>> c = CarrierNda(bn=0.01, sps=8, n=1, m=2)
>>> c.set_denominator(1.0 / 256.0, 2.4) # the unit form, gamma_d 3.8 dB
>>> c.set_denominator(1.0, 0.0) # back to the limiter
function dp_carrier_nda_set_norm_freq¶
Re-seed the loop at a new carrier frequency.
Not a gentle nudge: it resets the loop filter, re-initializes the NCO (phase included) at val, clears the moving-average arm, the lock EMA and the lock decision, and makes val the frequency a later dp_carrier_nda_reset() returns to.
Parameters:
stateMust be non-NULL.valNew carrier centre frequency, cycles/sample.
function dp_carrier_nda_set_state¶
Restore a state written by dp_carrier_nda_get_state() .
Restores every field, config included, but keeps the receiver's own telemetry attachment. The payload is decoded into a temporary and checked first, so on rejection state is untouched.
Parameters:
stateMust be non-NULL.blobBlob from dp_carrier_nda_get_state().
Returns:
DP_OK, or DP_ERR_INVALID on a magic, version, endian or size mismatch or a payload the object's check refuses.
function dp_carrier_nda_set_telemetry¶
Attach (or detach) a telemetry context and register the carrier loop's probes on it. Registers five probes, emitted once per input sample (this is a sample-rate loop — use decim to thin the stream): "<prefix>.lock" (the lock statistic: the EMA, ~1 when phase-locked, or the last block's R), "<prefix>.e" (the M-th-power phase discriminator — the loop stress), "<prefix>.freq" (the tracked carrier frequency, cycles/sample), "<prefix>.locked" (the verify-counted lockdet decision, 0/1) and "<prefix>.nco" (the full NCO command, cycles/sample). Passing NULL detaches. Setup path, never hot: call before the producer thread starts stepping; the context is borrowed and must outlive the attachment (SPSC rules indp_tlm/dp_tlm_core.h ).
int dp_carrier_nda_set_telemetry (
dp_carrier_nda_state_t * state,
dp_tlm_t * tlm,
const char * prefix,
uint32_t decim
)
Parameters:
stateMust be non-NULL.tlmTelemetry context to attach, or NULL to detach.prefixProbe-name prefix, e.g. "car" or "rx.car".decimEmit every decim-th sample; >= 1.
Returns:
DP_OK, or DP_ERR_INVALID when the probe table cannot take all five probes (the attach fails whole; everything stays detached).
>>> import numpy as np
>>> from doppler.track import CarrierNda
>>> from doppler.telemetry import Telemetry
>>> tlm = Telemetry(1 << 14)
>>> c = CarrierNda(bn=0.01, sps=8, n=4, m=4)
>>> c.set_telemetry(tlm, "car", decim=8)
>>> sorted(tlm.probe_names)
['car.e', 'car.freq', 'car.lock', 'car.locked', 'car.nco']
>>> x = np.exp(2j * np.pi * 0.005 * np.arange(4096)).astype(
... np.complex64)
>>> _ = c.steps(x)
>>> recs = tlm.read()
>>> len(recs[recs["probe"] == tlm.probe_id("car.e")]) == 4096 // 8
True
function dp_carrier_nda_set_update_period¶
Set the loop's update period: t_upd samples a loop update.
For a composer that updates the loop once a block (carrier_nda_update() once a sum, carrier_nda_wipeoff() once a sample). The loop is designed per update: bn becomes the noise bandwidth times the update period (B_L * t_upd / fs), and the filter's output, a frequency in cycles an update, is spread over the update's samples (carrier_nda_steer()). The frequency readouts follow. The configured bn and zeta are kept. On a running loop the integrator, which holds cycles an update, is rescaled by the new period over the old, so the tracked frequency (cycles a sample) and the command held for the next sample are unchanged by the call; the NCO and the lock are not touched.
dp_carrier_nda_steps() runs the loop once a sample, so it is defined at the default 1 only: at any other period it writes nothing and returns 0.
Parameters:
stateMust be non-NULL.t_updSamples an update, finite and >= 1 (it may be fractional: a code period of 2,750.4 samples).
Returns:
DP_OK, or DP_ERR_INVALID (nothing changes) for a period that is not finite or under 1.
>>> import numpy as np
>>> from doppler.track import CarrierNda
>>> c = CarrierNda(bn=0.012, sps=8, n=1, m=2)
>>> c.set_update_period(3500.0) # once a code period of 3,500 samples
>>> len(c.steps(np.ones(8, dtype=np.complex64))) # steps() is per sample
0
function dp_carrier_nda_state_bytes¶
Serialized-state byte size.
Parameters:
stateMust be non-NULL (its contents do not affect the size).
Returns:
Bytes: the dp_state_hdr_t envelope plus the whole struct.
function dp_carrier_nda_steps¶
De-rotate a cf32 block with the recovered carrier and return the de-rotated stream (one output per input sample).
size_t dp_carrier_nda_steps (
dp_carrier_nda_state_t * state,
const float _Complex * x,
size_t x_len,
float _Complex * out,
size_t max_out
)
Runs the non-data-aided carrier loop over the block: each sample is wiped off by the integer-phase NCO, the de-rotated sample slides the I/Q moving-average arm, and the M-th-power discriminator (which strips the M-PSK data modulation) steers the NCO frequency and phase. Because the discriminator is data- and timing-independent, this acquires the carrier with no symbol timing and no data present — a bare carrier, or a modulated carrier before timing lock. It resolves to one of m carrier phases (M-fold ambiguity, resolved downstream). Read norm_freq for the tracked carrier (cycles/sample) and lock for the carrier lock metric.
Parameters:
stateMust be non-NULL.xInput samples (average power at or below unity).x_lenNumber of input samples.outDe-rotated samples, one per input.max_outCapacity ofout.
Returns:
Number of de-rotated samples written to out (equals x_len); 0, with nothing written, when an update period other than 1 is set (dp_carrier_nda_set_update_period()).
>>> import numpy as np
>>> from doppler.track import CarrierNda
>>> c = CarrierNda(bn=0.01, zeta=0.707, init_norm_freq=0.0,
... sps=8, n=4, m=4)
>>> rng = np.random.default_rng(0)
>>> k = np.arange(40000)
>>> x = (np.exp(2j * np.pi * 0.001 * k) + 0.05 * (
... rng.standard_normal(k.size)
... + 1j * rng.standard_normal(k.size))).astype(np.complex64)
>>> y = c.steps(x) # de-rotated toward DC
>>> y.shape[0]
40000
>>> round(c.norm_freq, 4) # tracked carrier, cycles/sample
0.001
>>> c.lock > 0.5 # carrier lock metric, ~1 at lock
True
function dp_carrier_nda_steps_max_out¶
Output capacity hint for dp_carrier_nda_steps() : always 0.
The output is one sample per input, so size out to the input length.
Parameters:
stateUnused.
Returns:
0 (no state-derived bound).
function dp_carrier_nda_tlm_flush¶
Emit the carrier loop's telemetry records for the current sample.
Out-of-line on purpose: the emit machinery must not inline into the per-sample hot loop (inlined ring-write expansions bloat the loop body and an extern call site forces per-iteration state reloads — both measured ~20% slower detached on other loops). Callers gate on s->tlm.ctx. This loop updates every sample, so the natural call rate is per sample — decim (set at attach) is the throttle. Records "<prefix>.lock" (the lock-signal EMA), "<prefix>.e" (the M-th-power phase discriminator — the loop stress), "<prefix>.freq" (the tracked carrier, NCO centre + integrated correction, cycles/sample) and "<prefix>.locked" (the verify-counted lockdet decision, 0/1) and "<prefix>.nco" (the full NCO command, centre plus integ + kp*e spread over the update, cycles/sample: dp_carrier_nda_get_nco_freq()). A composer that updates once a block calls this once an update; summed over the update's samples, .nco is the phase the LO advanced by.
Parameters:
sState with a non-NULL tlm.ctx (caller-checked).
Macro Definition Documentation¶
define CARRIER_NDA_BLOCK_MAX_LEN¶
The largest block a block lock takes, updates. Its threshold is dp_det_threshold_f() 's F(len, len) quantile, a bisection on a continued fraction capped at 300 terms. Against scipy'sf.isf , the threshold r it gives holds to 1e-9 relative at 1e7 and fails outright between 2e8 and 5e8 (r even turns negative at 2^31). A block of 1e7 code periods is about 50 minutes at the 415.1-B-1 point.
define CARRIER_NDA_DEN_AVERAGED¶
An average of |z|^2 (an EMA, booted as a cumulative mean). Its mean is signal plus noise, so the gain isgamma/(gamma + 1) at update SNR gamma. M = 2 only.
define CARRIER_NDA_DEN_LIMITER¶
The denominator in force (the state's den , whichdp_carrier_nda_set_denominator() derives from its arguments): the update's own|z|^2 , a per-update limiter (the default, and the onecarrier_nda_disc() computes). GainE[1/(1 + n/A)] , falling with SNR.
define CARRIER_NDA_DEN_STEP¶
The averaged and unit denominators' floor, as a fraction of the update's own |z|^2 : the denominator is never under|z|^2 / this , so the error 2IQ over it, at most|z|^2 over it, is never past this in magnitude. Derived from a chosen rate, 1e-6: on noise alone|z|^2 over its mean is exponential,P(|z|^2 > x mean) = e^-x , so x = -ln(1e-6) engages the floor on one update in 10^6. With a signal the unit form compares|z|^2 with the signal's powerA^2 (its denominator's value), the noncentral chi-square tailQ_1(sqrt(2 gamma), sqrt(2 x gamma)) at update SNR gamma: at the 415.1-B-1 floor's window sums, 2.6e-9 at gamma 2.397 (2.2 GHz) and 1.3e-7 at 1.884 (2.8 GHz), under the noise-only rate; the averaged form, againstA^2 + N , 7e-14 and 3e-12. Printed by test_carrier_nda_core.c's 17c throughdp_marcum_q() . Otherwise it engages only on a level step the running average has not yet followed (a burst, a gain step upstream), which the quotient would hand the loop unbounded.
define CARRIER_NDA_DEN_UNIT¶
That average less the caller's noise power, clamped between avg * gamma_d/(gamma_d + 1) and avg, with gamma_d the design update SNR: gain 1 where the estimate holds, never above the design point's, never the averaged form's sign. M = 2 only.
define CARRIER_NDA_DISC_SLOPE¶
The discriminator's slope at lock, error per radian of carrier phase, at every M: sin 2 theta at M = 2 and the {1, 1/2, 1/4} scale that makes it 2 at 4 and 8 too.What has slope 2 is the raw discriminator output:carrier_nda_disc() ,last_error , the.e probe anddp_carrier_nda_get_last_error() .What the filter is handed has slope 1: a loop filter's gains assume the rest of its loop has unit gain (dp_loop_filter_init() ), so the error reaches the filter divided by this, throughcarrier_nda_loop_error() , andbn andzeta are then the closed loop's (#3224).
define CARRIER_NDA_EPS¶
Numerical guard on the arm sample's power |z|^2: at or below it (or NaN) the discriminator outputs 0 for both phase error and lock signal (not tunable).
define CARRIER_NDA_INV_2PI¶
1/(2*pi): rad -> cycles scale folded into the loop gains so the loop filter outputs the NCO control in cycles/sample.
define CARRIER_NDA_LOCK_ALPHA¶
EMA smoothing (per sample) for the lock metric: alpha = det_ema_alpha(0.0, 15.9), giving N_eff = (2-alpha)/alpha = 39 effective looks (>= the 30-look floor).
define CARRIER_NDA_LOCK_NORM_SD¶
Analytic H0 sd of the limited lock statistic AFTER the EMA above: sqrt(Var_look * alpha/(2-alpha)) with Var_look = 1/2 exactly, for every M. A threshold of eta * this has per-look Pfa = Q(eta).
define CARRIER_NDA_STATE_MAGIC¶
State-blob magic for CarrierNda (FourCC "CNDA").
define CARRIER_NDA_STATE_VERSION¶
State-blob layout version (v6: the composer's options).
The documentation for this class was generated from the following file native/inc/doppler/carrier_nda/carrier_nda_core.h