Add differential part to coarse frequency control

This commit is contained in:
Thomas Kolb 2024-06-08 01:54:42 +02:00 committed by Simon Ruderich
parent 2f2834026e
commit 26a2558535
2 changed files with 12 additions and 1 deletions

View file

@ -31,6 +31,9 @@
#define PLL_BW_HEADER 0.03f
#define PLL_BW_DATA 0.01f
#define COARSE_FREQ_EST_P 0.05f
#define COARSE_FREQ_EST_D 0.01f
static void update_nco_pll(nco_crcf nco, float phase_error, float bw)
{
const float pll_alpha = bw; // phase adjustment factor
@ -136,7 +139,9 @@ static bool acquire_preamble(layer1_rx_t *rx, const float complex sample, bool d
// this case.
if(freq_est != 0.0f) {
// apply the frequency adjustment
float freq_adjustment = freq_est / RRC_SPS / FREQ_EST_L;
float x = freq_est / RRC_SPS;
float freq_adjustment = COARSE_FREQ_EST_P * x + COARSE_FREQ_EST_D * (x - rx->freq_est_last);
rx->freq_est_last = x;
nco_crcf_adjust_frequency(rx->carrier_coarse_nco, freq_adjustment);
// limit the absolute frequency offset value
@ -543,6 +548,9 @@ result_t layer1_rx_init(layer1_rx_t *rx, rx_callback_t callback)
// Correlator for preamble search
correlator_init(&rx->preamble_correlator, preamble_get_symbols(), preamble_get_symbol_count());
// initialize coarse frequency control
rx->freq_est_last = 0.0f;
// precalculate encoded header length in symbols
unsigned int hdr_bps = modem_get_bps(rx->hdr_demod);
rx->hdr_len_enc_bytes = fec_get_enc_msg_length(HEADER_CHANNEL_CODE, HEADER_SIZE_BYTES);

View file

@ -62,6 +62,9 @@ typedef struct layer1_rx_s
// Callback function to notify user of certain events
rx_callback_t callback;
// Frequency estimation PD control
float freq_est_last;
// Precalcuated header lengths
unsigned int hdr_len_symbols;
unsigned int hdr_len_enc_bytes;