mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-07-31 00:39:17 +02:00
use atan2 for pll phase error
This commit is contained in:
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"port": 13452,
|
"port": 13452,
|
||||||
"time": 1742831052343,
|
"time": 1742842256267,
|
||||||
"version": "0.0.3"
|
"version": "0.0.3"
|
||||||
}
|
}
|
||||||
+1
-1
@@ -30,7 +30,7 @@ float apply_pll(PLL *pll, float ref_sample) {
|
|||||||
float vco_output = sinf(pll->phase);
|
float vco_output = sinf(pll->phase);
|
||||||
if (pll->quadrature_mode) vco_output = sinf(pll->phase + (M_PI / 2.0f));
|
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;
|
pll->loop_filter_state += pll->ki * phase_error / pll->sample_rate;
|
||||||
float loop_output = pll->loop_filter_state + pll->kp * phase_error;
|
float loop_output = pll->loop_filter_state + pll->kp * phase_error;
|
||||||
|
|||||||
Reference in New Issue
Block a user