Essay series · 1 essay
Keeping Time: Pacing Output and Following Clocks with a Phase-Locked Loop (PLL)
A program that sends or receives things at a steady rate has to keep time. Usually that sounds like a timer. Sometimes it means following a clock that isn’t yours, one that runs a little fast or slow and reports in late.
Those are different problems, and they need different tools. Pacing on your own clock needs exact arithmetic and no feedback at all. Following someone else’s clock needs a phase-locked loop, and a phase-locked loop needs answers to questions its textbook equations leave open.
The first essay, Whose Clock?, separates the two problems, follows what the textbook equations left out, and asks how to check code that can only estimate. Ports to other languages, held to one shared specification, are planned.
The Go implementation is pll.
-
Part 1
Whose Clock?
Why a constant-rate sender doesn't need a phase-locked loop, where one is actually needed, the questions its equations leave open, and how to check an implementation that can't be exact.