File measure_core.h¶
FileList > doppler > measure > measure_core.h
Go to the source code of this file
Measure module — shared result structs and module-level helpers. More...
#include "doppler/clib_common.h"
Classes¶
| Type | Name |
|---|---|
| struct | imd_meas_t Two-tone intermodulation result (IMD2/IMD3/TOI). |
| struct | npr_meas_t Noise Power Ratio (notched-noise loading) result. |
| struct | time_stats_t Time-domain capture statistics (AC-coupled crest/PAPR). |
| struct | tone_meas_t Single-tone dynamic-measurement bag. |
Public Functions¶
| Type | Name |
|---|---|
| double | dp_coherent_freq (double fs, double f_target, size_t N) Nearest leakage-free coherent test frequency. |
| size_t | dp_measure_min_samples (double fs, double target_rbw, size_t bits, double dynamic_range_db, int complex_input) Samples needed to reach a target resolution bandwidth. |
| double | dp_measure_proc_gain (size_t nfft) FFT processing gain in dB: 10*log10(nfft / 2). |
| size_t | dp_measure_rec_nfft (size_t n, size_t pad) Recommended zero-padded transform length: next_pow_two(n * max(pad, 1)). |
Public Static Functions¶
| Type | Name |
|---|---|
| double | measure_dr_from_bits (size_t bits) Default dynamic-range target (dB) implied by an ADC bit depth. |
| double | measure_resolve_dr (double dynamic_range_db, size_t bits) Resolve the dynamic-range target from the override/bits/default chain. |
Macros¶
| Type | Name |
|---|---|
| define | MEASURE_DR_DEFAULT_DB 120.0Dynamic-range target (dB) when neither bits nor an explicit override is given (general DUT): deep enough for ~19-bit measurements. The fallback of measure_resolve_dr(). |
| define | MEASURE_DR_MARGIN_DB 12.0Sidelobe headroom (dB) below the ideal converter SNR. |
| define | MEASURE_PAD 2uZero-pad factor every measurement object hands its PSD core: nfft = next_pow_two(n * MEASURE_PAD), so a capture of n samples is transformed at no less than twice its own length. |
| define | MEASURE_SPUR_SIDELOBES 1.0Extra main-lobe widths excluded past the first null when searching for spurs (or, in IMDMeasure, for the second tone), so a component's near-in sidelobes are never mistaken for a spur. |
Detailed Description¶
The doppler.measure objects (ToneMeasure, …) each own a window + FFT and analyse a time-domain capture, returning one of these plain-C result bags by value. Every spectral metric integrates a component's power over its window MAIN LOBE (IEEE Std 1241) rather than reading a single peak bin, so the reading is independent of where the tone falls between FFT bins.
Public Functions Documentation¶
function dp_coherent_freq¶
Nearest leakage-free coherent test frequency.
Snaps f_target to J * fs / N where J is the nearest integer cycle count that is coprime with N — an integer number of cycles in the capture (no leakage) with J coprime to N (so quantisation-noise correlation is minimised).
J starts at round(f_target * N / fs), is clamped to [1, N-1], then moved by the smallest distance that makes it coprime with N; on a tie the higher J wins.
Parameters:
fsSample rate (Hz, > 0).f_targetDesired test frequency (Hz).NCapture length (samples, >= 2).
Returns:
The coherent frequency J * fs / N (Hz), or 0 if N < 2 or fs <= 0.
function dp_measure_min_samples¶
Samples needed to reach a target resolution bandwidth.
size_t dp_measure_min_samples (
double fs,
double target_rbw,
size_t bits,
double dynamic_range_db,
int complex_input
)
Plans a capture for the same auto-Kaiser window the measurement objects use: the dynamic-range target (from dynamic_range_db, else bits) selects the Kaiser beta, whose ENBW (read from a PSD kernel at a reference length, so it is the analysers' own periodic window, #2053) sets the bins-per-RBW. RBW = ENBW * fs / n, so n = ceil(ENBW * fs / target_rbw).
Parameters:
fsSample rate (Hz, > 0).target_rbwDesired resolution bandwidth (Hz). When <= 0 it defaults to span/1000, where span = fs/2 for real captures and fs for complex (complex_input).bitsADC depth: sets the dynamic-range target when no explicit override is given.dynamic_range_dbExplicit dynamic-range target (dB); used when > 0.complex_inputNon-zero if the capture is complex (span = fs).
Returns:
Required capture length, or 0 on bad args.
function dp_measure_proc_gain¶
FFT processing gain in dB: 10*log10(nfft / 2).
How far a single bin's noise sits below the total noise power for an nfft-point transform of a real capture. A transform shorter than two bins has no gain to report (nfft = 1 would read -3 dB and nfft = 0 -inf), so it is refused with NaN, which no caller can mistake for a gain.
Parameters:
nfftTransform length (bins), at least 2.
Returns:
Processing gain (dB), or NaN when nfft < 2.
function dp_measure_rec_nfft¶
Recommended zero-padded transform length: next_pow_two(n * max(pad, 1)).
The same rule the measurement objects apply (with pad = MEASURE_PAD), exposed so a caller can plan an FFT size before building an analyser.
Parameters:
nCapture length (samples).padZero-pad factor; 0 is treated as 1.
Returns:
The smallest power of two >= n * pad (1 when n is 0).
Public Static Functions Documentation¶
function measure_dr_from_bits¶
Default dynamic-range target (dB) implied by an ADC bit depth.
Ideal quantisation SNR is 6.02*bits + 1.76 dB; add MEASURE_DR_MARGIN_DB of headroom so the window's first sidelobe sits below the converter's own floor.
Parameters:
bitsADC depth in bits (> 0).
Returns:
Dynamic-range / sidelobe-attenuation target in dB.
function measure_resolve_dr¶
Resolve the dynamic-range target from the override/bits/default chain.
Parameters:
dynamic_range_dbExplicit target (dB); used when > 0.bitsADC depth; used (via measure_dr_from_bits) when the override is unset and bits > 0.
Returns:
Dynamic-range / sidelobe-attenuation target in dB.
Macro Definition Documentation¶
define MEASURE_DR_DEFAULT_DB¶
Dynamic-range target (dB) when neither bits nor an explicit override is given (general DUT): deep enough for ~19-bit measurements. The fallback of measure_resolve_dr().
define MEASURE_DR_MARGIN_DB¶
Sidelobe headroom (dB) below the ideal converter SNR.
A B-bit ADC's spur/noise floor sits at -(6.02*B+1.76) dBc, so measure_dr_from_bits() targets sidelobes this much deeper to be sure window leakage stays under the floor being measured.
define MEASURE_PAD¶
Zero-pad factor every measurement object hands its PSD core: nfft = next_pow_two(n * MEASURE_PAD), so a capture of n samples is transformed at no less than twice its own length.
define MEASURE_SPUR_SIDELOBES¶
Extra main-lobe widths excluded past the first null when searching for spurs (or, in IMDMeasure, for the second tone), so a component's near-in sidelobes are never mistaken for a spur.
The documentation for this class was generated from the following file native/inc/doppler/measure/measure_core.h