0
1
mirror of https://github.com/radio95-rnt/fm95.git synced 2026-02-26 19:23:51 +01:00

use atan2 for pll phase error

This commit is contained in:
2025-03-24 19:54:49 +01:00
parent 0a27b39c43
commit ad1856f255
2 changed files with 2 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
{
"port": 13452,
"time": 1742831052343,
"time": 1742842256267,
"version": "0.0.3"
}

View File

@@ -30,7 +30,7 @@ float apply_pll(PLL *pll, float ref_sample) {
float vco_output = sinf(pll->phase);
if (pll->quadrature_mode) vco_output = sinf(pll->phase + (M_PI / 2.0f));
phase_error = ref_sample * vco_output;
phase_error = atan2f(ref_sample, vco_output);;
pll->loop_filter_state += pll->ki * phase_error / pll->sample_rate;
float loop_output = pll->loop_filter_state + pll->kp * phase_error;