Skip to content

Commit

Permalink
Clamp PLL phase error to (-M_PI, +M_PI) (#94)
Browse files Browse the repository at this point in the history
After a period of digital silence, the PLL sometimes suddenly jumps
frequencies and can't recover. This was caused by a large transient
value of phase error (on the order of 10^5). Clamping the phase error
seems to improve this.
  • Loading branch information
windytan committed Aug 17, 2023
1 parent 4ef0854 commit 67c76f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
(#77)
* Fix an off-by-one bug in the RadioText decoder that sometimes caused missing
characters at the end of messages
* Fix runaway PLL after digital silence by clamping the phase error (#94)

## 0.20 (2021-03-08)

Expand Down
5 changes: 4 additions & 1 deletion src/subcarrier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ BitBuffer Subcarrier::processChunk(MPXBuffer<>& chunk) {
if (symbol.valid) {
// Modem here is only used to track PLL phase error
modem_.demodulate(symbol.data);
oscillator_.stepPLL(modem_.getPhaseError() * kPLLMultiplier);

float phase_error = std::min(std::max(modem_.getPhaseError(),
-float(M_PI)), float(M_PI));
oscillator_.stepPLL(phase_error * kPLLMultiplier);

auto biphase = biphase_decoder_.push(symbol.data);

Expand Down

0 comments on commit 67c76f5

Please sign in to comment.