From 455795dc86210c52f5ec6d9bad11104e618bbbaa Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Sun, 23 Mar 2025 18:09:18 +0100 Subject: [PATCH] change pll settings --- README.md | 2 +- lib/filters.c | 6 +++--- lib/filters.h | 2 +- src/fm95.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bee48a0..6d22ef9 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ make Done! # CPU Usage? -Should run completly fine on a pi 5, right now with the preemp, on a pi 3b, its 20% +Should run completly fine on a pi 5, right now with the preemp, on a pi 3b, its 32% # Recommendations use a lpf, for example swh-plugins's lowpass_iir, for example: diff --git a/lib/filters.c b/lib/filters.c index 764ed19..9391c31 100644 --- a/lib/filters.c +++ b/lib/filters.c @@ -14,12 +14,12 @@ float hard_clip(float sample, float threshold) { return fmaxf(-threshold, fminf(threshold, sample)); } -void init_pll(PLL *pll, float freq, float loop_filter_bandwidth, int quadrature_mode, int sample_rate) { +void init_pll(PLL *pll, float freq, float loop_filter_bandwidth, float damping, int quadrature_mode, int sample_rate) { pll->phase = 0.0f; pll->freq = freq; pll->loop_filter_state = 0.0f; pll->kp = M_2PI * loop_filter_bandwidth; - pll->ki = 0.25f * pll->kp * pll->kp; + pll->ki = (4.0f*damping*damping) * pll->kp * pll->kp; pll->last_output = 0.0f; pll->sample_rate = sample_rate; pll->quadrature_mode = quadrature_mode; @@ -29,7 +29,7 @@ float apply_pll(PLL *pll, float ref_sample) { float phase_error; float vco_output = sinf(pll->phase); - if (pll->quadrature_mode) vco_output = sinf(pll->phase + (M_PI / 2.0f)); // 90 degrees + if (pll->quadrature_mode) vco_output = sinf(pll->phase + (M_PI / 2.0f)); phase_error = ref_sample * pll->last_output; diff --git a/lib/filters.h b/lib/filters.h index d1fa31b..2c80cae 100644 --- a/lib/filters.h +++ b/lib/filters.h @@ -26,5 +26,5 @@ typedef struct { int sample_rate; int quadrature_mode; } PLL; -void init_pll(PLL *pll, float freq, float loop_filter_bandwidth, int quadrature_mode, int sample_rate); +void init_pll(PLL *pll, float freq, float loop_filter_bandwidth, float damping, int quadrature_mode, int sample_rate); float apply_pll(PLL *pll, float ref_sample); \ No newline at end of file diff --git a/src/fm95.c b/src/fm95.c index bf4c193..b1c54b8 100644 --- a/src/fm95.c +++ b/src/fm95.c @@ -416,7 +416,7 @@ int main(int argc, char **argv) { init_preemphasis(&preemp_r, preemphasis_tau, sample_rate); PLL rds2_pll; - init_pll(&rds2_pll, 66500, 1, 10000, sample_rate); + init_pll(&rds2_pll, 66500, 4000, 2, 1, sample_rate); // #endregion signal(SIGINT, stop);