---
title: Phase-locked loops
heading: A feedback loop that makes an oscillator track the phase of an incoming signal, the phase detector, loop filter and controlled oscillator, the second-order loop's natural frequency and damping, its response to a frequency step, noise bandwidth, and frequency synthesizers that multiply a crystal reference
eyebrow: D5 · Lesson 11 · Phase-locked loops
xp: 40
---

::: hook
Every radio, every Ethernet port and every processor clock depends on a phase-locked loop. A PLL compares an oscillator's phase with a reference, filters the difference, and nudges the oscillator until the two march in step. Locked to a noisy received carrier, it recovers a clean one for demodulation; locked to a crystal through a frequency divider, it makes a gigahertz clock with the crystal's stability. It's a control loop (D3) whose controlled variable happens to be phase, and the same ideas of damping, bandwidth and stability decide how well it works.
:::

::: play
- The phase error of a second-order PLL after the input's frequency jumps by Δf, with loop natural frequency $f_n$ and damping ratio ζ.
- The error rises as the input pulls ahead, then the loop filter's integrator catches up and the error returns to zero: a type-2 loop tracks a frequency step with no lasting phase error.
- A wider loop recovers faster with a smaller peak error, but lets through more of the input's noise.
:::

```sim plot
view: graph
x: t = 0..30
y: e = -0.5..2
slider: D = 10..1000 step 10 = 100
slider: n = 20..500 step 5 = 100
slider: z = 0.2..2 step 0.01 = 0.71
plot: D/n*Re(exp(-z*2*pi*n*t/1000)*sinh(sqrt(z^2 - 1 + 1e-9)*2*pi*n*t/1000)/sqrt(z^2 - 1 + 1e-9)) | samples: 500 | label: phase error, rad (t in ms, Δf and fn in Hz)
readout: peak phase error for a damping of 0.707, rad = 0.456*D/n | digits: 3
readout: noise bandwidth, Hz = pi*n*(z + 1/(4*z)) | digits: 4
```

::: predict
## A Wi-Fi radio's synthesizer locks to a 1 MHz reference through a divide-by-N counter. What N gives 2.412 GHz, the center of channel 1?

- [ ] 2.412
- [ ] 241.2
- [x] 2412
- [ ] 2,412,000

::: reveal
The loop locks when the divided-down VCO matches the reference: $f_\text{out}/N = f_\text{ref}$, so $N = 2.412\text{ GHz}/1\text{ MHz} = 2412$. Changing N by one moves the output by the 1 MHz reference: the channel step. Channel 6, at 2.437 GHz, needs N = 2437.
:::
:::

::: nameit
## The loop

1. A **phase detector** outputs a signal proportional to the phase difference between the input and the oscillator (a multiplier, an XOR gate or a phase-frequency detector with a charge pump).
2. A **loop filter**, usually proportional plus integral, smooths it.
3. A **voltage-controlled oscillator** (or a numerically controlled one in software) changes its frequency in proportion to the filter's output.

Because frequency is the derivative of phase, the oscillator acts as an integrator in the phase loop. With a PI loop filter the loop is second order, described by a natural frequency $\omega_n = 2\pi f_n$ and damping ratio ζ (0.707 is the common choice), and it's **type 2**: a step in the input's frequency leaves no steady phase error.

## Frequency step

For a frequency step Δω and ζ < 1, the phase error is

$$\theta_e(t) = \frac{\Delta\omega}{\omega_n}e^{-\zeta\omega_nt}\frac{\sin\left(\sqrt{1 - \zeta^2}\,\omega_nt\right)}{\sqrt{1 - \zeta^2}}$$

peaking at $0.456\,\Delta\omega/\omega_n$ for ζ = 0.707. If the peak exceeds the phase detector's range, the loop slips cycles before it relocks.

## Noise bandwidth

The loop passes input noise within its **noise bandwidth**

$$B_L = \frac{\omega_n}{2}\left(\zeta + \frac{1}{4\zeta}\right) \text{ Hz}$$

so a narrow loop gives a cleaner recovered carrier but tracks changes slowly.

## Synthesizers

Dividing the oscillator by N before the phase detector makes it lock at $f_\text{out} = Nf_\text{ref}$. A fractional-N divider, switching N between neighbors, gets finer steps from a fast reference.
:::

::: example
## A loop with $f_n$ = 100 Hz and ζ = 0.707 sees a 1 kHz frequency step. What's the peak phase error, and its noise bandwidth?

::: solution
1. **Size of the step.**
   $$\begin{aligned} \frac{\Delta\omega}{\omega_n} &= \frac{1000}{100} \\ &= 10\ \text{rad} \end{aligned}$$
2. **Peak phase error.** At ζ = 0.707 the peak is 0.456 of that:
   $$\begin{aligned} \phi_{pk} &= 0.456 \times 10 \\ &= 4.56\ \text{rad} \\ &= 261^\circ \end{aligned}$$
3. **Cycle slip.** That's more than a phase detector's half-cycle, so the loop would slip a cycle.
4. **Noise bandwidth.**
   $$\begin{aligned} B_L &= \pi \times 100 \\ &\quad \times (0.707 + 0.354) \\ &= 333\ \text{Hz} \end{aligned}$$

**Answer:** the peak phase error is 4.56 rad (261°), enough to slip a cycle, and the noise bandwidth is 333 Hz.
:::
:::

::: example
## Why does the sim's peak at ζ = 0.5 come out higher?

::: solution
1. **Why it climbs further.** With less damping the loop pulls the phase back more gently at first, so the error climbs further before it turns.
2. **The peak factor.**
   $$e^{-\zeta\tan^{-1}(\sqrt{1 - \zeta^2}/\zeta)/\sqrt{1 - \zeta^2}}$$
3. **Compare the dampings.** It's 0.546 at ζ = 0.5, against 0.456 at 0.707 and 0.368 near critical damping.

**Answer:** less damping lets the error climb further before the loop turns it, so the peak factor rises to 0.546 at ζ = 0.5 from 0.456 at 0.707.
:::
:::

::: example
## The loop with $f_n$ = 100 Hz and ζ = 0.707: about how long does it take to lock after a step?

::: solution
1. **Decay rate.** Its transients decay as $e^{-\zeta\omega_nt}$, with
   $$\begin{aligned} \zeta\omega_n &= 0.707 \times 628 \\ &= 444\ \text{s}^{-1} \end{aligned}$$
2. **Settling to 2%.**
   $$\frac{4}{444\ \text{s}^{-1}} = 9.0\ \text{ms}$$
3. **The trade-off.** Narrower loops reject more noise but take longer to lock, which is why many loops start wide and narrow once locked.

**Answer:** it locks in about 9.0 ms.
:::
:::

::: check
given: f = 2412 | 2437 | 5180; r = 2 | 4 | 10
answer: f/r
tolerance: 0.5%

## A synthesizer must make {f} MHz from a {r} MHz reference. What divider N does it need?

::: right
Right. $N = f_\text{out}/f_\text{ref}$ = {answer}.
:::

::: misses
- [f*r] The loop divides the output down to the reference.
- [any] Not yet. Output over reference.
:::
:::

::: check
given: n = 10 | 100 | 1000; z = 0.5 | 0.707 | 1
answer: pi*n*(z + 1/(4*z))
unit: Hz
tolerance: 0.5%

## A second-order PLL has $f_n$ = {n} Hz and ζ = {z}. What's its noise bandwidth?

::: right
Right. $(\omega_n/2)(\zeta + 1/4\zeta)$ = {answer} Hz.
:::

::: misses
- [n*(z + 1/(4*z))] Use $\omega_n = 2\pi f_n$, then halve.
- [any] Not yet. The second-order loop's noise bandwidth.
:::
:::

::: check
given: D = 10 | 50 | 200; n = 50 | 100 | 500
answer: 0.456*D/n
tolerance: 1%

## A PLL with ζ = 0.707 and $f_n$ = {n} Hz sees the input frequency jump by {D} Hz. What's its peak phase error?

::: right
Right. $0.456\,\Delta\omega/\omega_n$ = {answer} rad.
:::

::: misses
- [D/n] That's $\Delta\omega/\omega_n$; the damped loop peaks at 0.456 of it.
- [any] Not yet. The frequency-step response's peak.
:::
:::

::: check
given: r = 0.1 | 1 | 10; N = 100 | 1000 | 4000
answer: r*N
unit: MHz
tolerance: 0.5%

## A synthesizer divides by {N} and locks to a {r} MHz reference. What frequency does it make?

::: right
Right. $Nf_\text{ref}$ = {answer} MHz.
:::

::: misses
- [r/N] The output runs N times faster than the reference.
- [any] Not yet. The divided output matches the reference.
:::
:::

::: check
kind: parts
given: f = 10 | 100 | 1000; z = 0.5 | 0.707 | 1

## A PLL has natural frequency {f} Hz and damping {z}.

::: part
answer: 4/(z*2*pi*f)*1000
unit: ms
tolerance: 0.5%

### About how long does it take to lock after a step?

::: misses
- [any] $4/(\zeta\omega_n)$.
:::
:::

::: part
answer: pi*f*(z + 1/(4*z))
unit: Hz
tolerance: 0.5%

### What is its noise bandwidth, $B_L = \tfrac{\omega_n}{2}(\zeta + \tfrac1{4\zeta})$?

::: misses
- [any] With $\omega_n = 2\pi f_n$.
:::
:::
:::

::: check
kind: parts
given: d = 100 | 1000; f = 10 | 100

## A PLL with natural frequency {f} Hz and ζ = 0.707 sees a {d} Hz frequency step.

::: part
answer: 2*pi*d/(2*pi*f)
unit: rad
tolerance: 0.5%

### What is $\Delta\omega/\omega_n$, which sets the scale of the phase error?

::: misses
- [any] $\Delta f/f_n$.
:::
:::

::: part
answer: 0.456*d/f
unit: rad
tolerance: 1%

### At ζ = 0.707 the peak error is about $0.456\,\Delta\omega/\omega_n$. What is it?

::: misses
- [any] 0.456 × the ratio.
:::
:::
:::

::: explain
## Why does a PLL with an integrator in its loop filter end up with no phase error after a frequency step?

::: model
After the input's frequency jumps, the oscillator must run at the new frequency to keep up, which requires a new, steady control voltage. With only proportional gain in the loop filter, that voltage can only come from a steady phase error, so some error would remain. An integrator in the loop filter keeps accumulating the phase error for as long as any exists and holds its output once the error is gone, so it can supply the new steady control voltage on its own. The loop therefore settles with the oscillator at the new frequency and the phase error back at zero, which is why practical PLLs use proportional-plus-integral loop filters.
:::
:::

::: practice

::: check
given: n = 1 | 10000; z = 0.4 | 1.5
answer: pi*n*(z + 1/(4*z))
unit: Hz
tolerance: 0.5%

## Noise bandwidth: $f_n$ = {n} Hz, ζ = {z}?

::: misses
- [any] $\pi f_n(\zeta + 1/4\zeta)$.
:::
:::

::: check
given: f = 100 | 10000; r = 0.01 | 50
answer: f/r
tolerance: 0.5%

## Divider for {f} MHz from {r} MHz?

::: misses
- [any] $f_\text{out}/f_\text{ref}$.
:::
:::
:::
