Skip to content

File measure_core.h

FileList > inc > measure > measure_core.h

Go to the source code of this file

Measure module — shared result structs and module-level helpers. More...

  • #include "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 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 measure_proc_gain (size_t nfft)
FFT processing gain in dB: 10*log10(nfft / 2).
size_t measure_rec_nfft (size_t n, size_t pad)
Recommended zero-padded transform length: next_pow2(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.0
define MEASURE_DR_MARGIN_DB 12.0
define MEASURE_PAD 2u
define MEASURE_SPUR_SIDELOBES 1.0

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 out-parameter. 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.

double dp_coherent_freq (
    double fs,
    double f_target,
    size_t N
) 

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).

Returns:

The coherent frequency (Hz), or 0 on bad args.


function measure_min_samples

Samples needed to reach a target resolution bandwidth.

size_t 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 (measured via kaiser_enbw) sets the bins-per-RBW. RBW = ENBW * fs / n, so n = ceil(ENBW * fs / target_rbw).

Parameters:

  • fs Sample rate (Hz, > 0).
  • target_rbw Desired resolution bandwidth (Hz). When <= 0 it defaults to span/1000, where span = fs/2 for real captures and fs for complex (complex_input).
  • bits ADC depth: sets the dynamic-range target when no explicit override is given.
  • dynamic_range_db Explicit dynamic-range target (dB); used when > 0.
  • complex_input Non-zero if the capture is complex (span = fs).

Returns:

Required capture length, or 0 on bad args.


function measure_proc_gain

FFT processing gain in dB: 10*log10(nfft / 2).

double measure_proc_gain (
    size_t nfft
) 


function measure_rec_nfft

Recommended zero-padded transform length: next_pow2(n * max(pad,1)).

size_t measure_rec_nfft (
    size_t n,
    size_t pad
) 


Public Static Functions Documentation

function measure_dr_from_bits

Default dynamic-range target (dB) implied by an ADC bit depth.

static inline double measure_dr_from_bits (
    size_t bits
) 

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:

  • bits ADC 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.

static inline double measure_resolve_dr (
    double dynamic_range_db,
    size_t bits
) 

Parameters:

  • dynamic_range_db Explicit target (dB); used when > 0.
  • bits ADC 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

#define MEASURE_DR_DEFAULT_DB `120.0`

define MEASURE_DR_MARGIN_DB

#define MEASURE_DR_MARGIN_DB `12.0`

define MEASURE_PAD

#define MEASURE_PAD `2u`

define MEASURE_SPUR_SIDELOBES

#define MEASURE_SPUR_SIDELOBES `1.0`


The documentation for this class was generated from the following file native/inc/measure/measure_core.h