Synchronisation: phase-locked loops, Costas loops and timing recovery
| Problem | Lock a local oscillator to a received carrier, recover the carrier of suppressed-carrier modulation, and find the right instants to sample each symbol |
| Devised by | Henri de Bellescize (1932), the phase-locked loop; John Costas (1956), the Costas loop; Kurt Mueller and Markus Müller (1976), timing recovery; C. W. Farrow (1988), the variable fractional-delay filter |
| Accuracy | A type-2 loop tracks a phase and a constant frequency offset with zero steady-state error; the Lagrange interpolator’s error falls with its order (table below) |
| Cost | A few operations per sample for the loops; multiply-adds per output for an order- Farrow interpolator |
| Read first | Modulation: constellations, OFDM and FM |
| API | PhaseLockedLoop, LoopFilter, CostasLoop (CostasModulation), MuellerTimingRecovery, mueller_timing_detector, FarrowFilter, farrow_filter |
Overview
A receiver’s oscillator never runs at exactly the transmitter’s frequency, and its sampling clock never matches the transmitter’s symbol clock. Both must be recovered from the signal itself. A phase-locked loop (PLL) compares the incoming phase with its own oscillator and steers it with the filtered error until they agree. A Costas loop does the same for modulated signals whose carrier is suppressed, using a phase detector that ignores the data. Timing recovery steers the sampling instant: a timing-error detector such as Mueller and Müller’s measures how early or late the samples are, and an interpolator, here a Farrow filter, computes the signal between the samples actually taken.
Where it is used
A receiver does not know the transmitter’s exact frequency, phase or sampling instants, and must lock onto all three.
- Carrier recovery. Phase-locked loops and Costas loops keep a radio receiver in step with the incoming carrier, as in GPS receivers, FM tuners, satellite modems and cellular phones.
- Clock and timing recovery. Serial data links (Ethernet, USB, PCIe) and digital modems find the right sampling instant from the data itself.
- Beyond radio. The phase-locked loop is also a clock multiplier in every processor, a speed regulator in motors, and the core of frequency synthesisers.
History
Henri de Bellescize (1932) patented the phase-locked loop for synchronous radio reception. PLLs spread through television (to lock horizontal sweep), space communications (Jet Propulsion Laboratory, 1950s), and every modern clock and frequency synthesiser. John Costas (1956), at General Electric, invented the loop that bears his name for suppressed-carrier communication. Kurt Mueller and Markus Müller (1976) derived a timing-error detector needing only one sample per symbol, and C. W. Farrow (1988) introduced the filter structure that interpolates at a continuously variable fractional delay. Floyd Gardner’s Phaselock Techniques and Michael Rice’s Digital Communications are the standard engineering references.
The idea
The loop
A receiver’s oscillator never matches the transmitter’s exactly. A small frequency difference makes the received constellation rotate steadily, and an unknown phase leaves it at an arbitrary angle. Before symbols can be decided, the receiver must estimate the phase of the incoming carrier and follow it as it drifts. A phase-locked loop (PLL) does this by feedback: it generates its own copy of the carrier, measures how far the copy is from the input, and corrects the copy.
Every loop here has three parts.
- A phase detector compares the input with the local copy and produces an error , ideally the phase difference between them.
- A loop filter smooths the error and decides how to respond.
- A numerically controlled oscillator generates the local copy at the phase the filter commands.
The loop filter is proportional-integral. It keeps an estimate of the frequency (the phase advance per sample) as well as the phase:
The proportional term corrects the phase directly. The integral term accumulates the error into the frequency estimate. The second is what allows the loop to follow a frequency offset: with a proportional term alone, a constant frequency difference would need a constant error to keep driving the correction, so the loop would always lag. With the integrator, the frequency estimate settles at the true offset and the phase error falls to zero. This is called a type-2 loop.
The two gains are not chosen directly. They follow from two more meaningful quantities: the normalised noise bandwidth , which sets how fast the loop reacts, and the damping , which sets how much it overshoots (0.707 is the usual choice). With , and . A wider bandwidth acquires faster and tracks changes better, but it also follows more of the noise:
Figure 16.6. PLL acquisition.
The PLL’s detector is : multiplying the input by removes the estimated phase, and the angle of what remains is the error. It is exact for any phase error, so the loop pulls in from any initial phase.
Costas loops
A plain PLL needs an unmodulated carrier. A data signal has none: in BPSK the received phase is , where the data bit flips it by 180° at random. A phase detector for such a signal must not care which way the symbol points.
The Costas loop achieves this by using the receiver’s own decisions. After the estimated phase has been removed, a BPSK symbol should lie on the real axis, at or , so its imaginary part should be zero. A residual phase error tilts the symbol and makes proportional to , the sign depending on the data. Multiplying by the sign of the real part , which is the decision about the data, cancels that sign: the detector gives whichever bit was sent. Since it cannot tell a symbol from its negative, the loop can lock with the constellation upside down, a 180° ambiguity. For QPSK the detector removes the four symbols in the same way and locks with a 90° ambiguity. The ambiguity is resolved by differential coding, which puts the information in the changes of phase, or by a known preamble:
Figure 16.7. Costas loop on QPSK.
The loop’s frequency estimate settles at 0.00373 radians per symbol (true 0.00400). The estimate fluctuates with the noise in proportion to the loop bandwidth.
Timing recovery
The receiver samples the signal several times per symbol, samples per symbol, with a clock that is not synchronised to the transmitter’s. Each symbol is a pulse, and it should be read at the peak of the pulse, where it is strongest and the neighbouring pulses pass through zero. The receiver must find that instant and track it, which is a second feedback loop of the same three-part form, with a timing error detector in place of the phase detector.
The Mueller-Müller detector works at one sample per symbol. It compares consecutive symbol-rate samples with the decisions made from them:
If the samples are taken at the pulse peaks, each sample contains only its own symbol and the two terms cancel on average. If the sampling is early or late, each sample also contains a little of its neighbour, and the two terms no longer balance: the detector’s average output is positive for one sign of the timing error and negative for the other. A loop filter turns it into the next sampling position. That position generally falls between two of the available samples, so an interpolator evaluates the signal there:
Figure 16.8. Timing recovery.
After acquisition the symbols’ error vector magnitude is 0.59% and the estimated symbol period 4.0000 samples (nominal 4).
Fractional delay: the Farrow filter
Evaluating a signal at with means fitting a polynomial through neighbouring samples. Lagrange interpolation of order through samples is a set of fixed FIR filters whose outputs combine as . That is the Farrow structure: only the cheap Horner step depends on , so the delay can change every sample. Higher orders are exact for polynomials of higher degree and accurate to higher frequencies:
Table 16.2. Fractional-delay error of Lagrange (Farrow) interpolators by order and frequency.
| Lagrange order | error at 0.05 cycles/sample | at 0.15 | at 0.30 |
|---|---|---|---|
| 1 | 1.2e-2 | 1.0e-1 | 3.9e-1 |
| 3 | 2.1e-4 | 1.6e-2 | 2.1e-1 |
| 5 | 4.4e-6 | 2.8e-3 | 1.2e-1 |
| 7 | 9.3e-8 | 5.1e-4 | 7.0e-2 |
Cubic interpolation (order 3), the usual choice for timing recovery, has an error of (−74 dB) at 0.05 cycles per sample, one reason receivers oversample by four or more.
Algorithm
Each loop processes one input sample (or one symbol) at a time.
PLL.
- Remove the estimated phase: multiply the input by .
- Detect: the error is the argument of the result.
- Filter and advance: , then .
Costas loop.
- Multiply the input by , and normalise the result to unit magnitude, so that the detector’s gain does not depend on the signal level.
- Detect with the data-stripping rule: for BPSK, or for QPSK.
- Filter and advance, as for the PLL.
- The derotated sample from step 1 is the output, ready for the decision device.
Mueller-Müller timing recovery, with the position of the next symbol within the sample stream and the current estimate of the samples per symbol. For each symbol:
- interpolate the signal at position with the Farrow filter to get the symbol-rate sample ;
- decide the symbol (the nearest constellation point);
- compute the timing error from this and the previous symbol, , limited to ;
- update the period estimate by a small multiple of , keeping it within of its nominal value;
- advance the position: .
Farrow interpolation of order at fractional delay : compute the fixed FIR filter outputs from the neighbouring samples, and combine them by Horner’s rule in .
Implementation
let theta = normalized_bandwidth / (damping + 0.25 / damping);
let denominator = 1.0 + 2.0 * damping * theta + theta * theta;
Ok(LoopFilter { proportional: 4.0 * damping * theta / denominator, integral: 4.0 * theta * theta / denominator, phase: 0.0, frequency: 0.0 })
}
/// Advances the NCO with the detector error (radians).
pub fn update(&mut self, error: f64) {
self.frequency += self.integral * error;
self.phase = (self.phase + self.proportional * error + self.frequency + PI).rem_euclid(TAU) - PI;
}
while (self.pos.floor() as usize) + 2 < self.buffer.len() {
let i = self.pos.floor() as usize;
let mu = self.pos - i as f64;
let y = self.interpolator.interpolate_window(&self.buffer[i - 1..=i + 2], mu)?;
let d = self.constellation.slice(y);
let err = mueller_timing_detector(self.prev_sample, y, self.prev_decision, d).clamp(-1.0, 1.0);
self.omega = (self.omega + self.gain_omega * err).clamp(self.nominal_omega - self.omega_limit, self.nominal_omega + self.omega_limit);
self.pos += self.omega + self.gain_mu * err;
self.prev_sample = y;
self.prev_decision = d;
self.last_error = err;
out.push(y);
}
// Sub-filter outputs v_m, then Horner in mu.
let v = |m: usize| -> T {
window.iter().zip(&self.coefficients[m]).fold(T::zero(), |acc, (&x, &c)| acc + x.f_scale(c))
};
let mut y = v(self.order);
for m in (0..self.order).rev() {
y = y.f_scale(mu) + v(m);
}
Ok(y)
- The Costas loops take one sample per symbol (after timing recovery); the PLL takes any complex tone.
MuellerTimingRecoveryinterpolates with a cubic Farrow filter and implementsStreamOperator, emitting one sample per recovered symbol.farrow_filter(x, delay, order)delays a whole signal by a fraction of a sample.
In practice
//! Carrier and timing synchronisation: PLL, Costas loop, Mueller-Müller timing recovery and Farrow interpolation.
use lib_jsl_dsp::discrete::digital_communications::constellations::Constellation;
use lib_jsl_dsp::discrete::digital_communications::farrow_filter::farrow_filter;
use lib_jsl_dsp::discrete::digital_communications::mueller_timing_detector::MuellerTimingRecovery;
use lib_jsl_dsp::discrete::stream_operator::StreamOperator;
use lib_jsl_dsp::discrete::synchronization::costas_loop::{CostasLoop, CostasModulation};
use lib_jsl_dsp::discrete::synchronization::phase_locked_loop::PhaseLockedLoop;
use num_complex::Complex;
use std::f64::consts::PI;
fn main() {
let mut pll = PhaseLockedLoop::new(0.02, 0.707).unwrap();
for n in 0..2000 {
pll.step(Complex::from_polar(1.0, 2.0 * PI * 0.01 * n as f64 + 1.0));
}
println!("PLL frequency {:.5} cycles/sample (true 0.01000)", pll.frequency() / (2.0 * PI));
// BPSK symbols with a phase offset and a slow frequency offset.
let mut costas = CostasLoop::new(CostasModulation::Bpsk, 0.02, 0.707).unwrap();
let mut state = 1u64;
let out: Vec<Complex<f64>> = (0..3000)
.map(|n| {
state = state.wrapping_mul(6364136223846793005).wrapping_add(1);
let s = if state >> 63 == 1 { 1.0 } else { -1.0 };
costas.step(Complex::from_polar(s, 0.5 + 0.002 * n as f64)).0
})
.collect();
println!("Costas: residual imaginary part {:.1e}, phase ambiguity ±1 on the real axis: {:.3}", out[2999].im.abs(), out[2999].re);
// A fractional delay of 0.25 samples with cubic Lagrange interpolation.
let x: Vec<f64> = (0..50).map(|n| (0.2 * n as f64).sin()).collect();
let y = farrow_filter(&x, 0.25, 3).unwrap();
println!("Farrow delay 0.25: y[20] = {:.5}, sin(0.2 × 19.75) = {:.5}", y[20], (0.2f64 * 19.75).sin());
// Timing recovery on an oversampled QPSK stream with a timing offset.
let qpsk = Constellation::qpsk();
let symbols: Vec<Complex<f64>> = (0..800).map(|k| qpsk.points()[(k * 7 + k / 3) % 4]).collect();
let mut stream = Vec::new();
for (k, &s) in symbols.iter().enumerate() {
let next = symbols.get(k + 1).copied().unwrap_or(s);
for i in 0..4 {
let t = (i as f64 + 0.3) / 4.0;
stream.push(s * (1.0 - t) + next * t); // a linear "pulse": sampled 0.3 samples late
}
}
let mut mm = MuellerTimingRecovery::new(4.0, qpsk.clone()).unwrap();
let rec = mm.process(&stream).unwrap().unwrap();
let late: f64 = rec[600..].iter().map(|y| (y - qpsk.slice(*y)).norm()).fold(0.0, f64::max);
println!("Mueller-Müller: {} symbols out, worst error after settling {late:.3}", rec.len());
}
PLL frequency 0.01000 cycles/sample (true 0.01000)
Costas: residual imaginary part 2.2e-16, phase ambiguity ±1 on the real axis: -1.000
Farrow delay 0.25: y[20] = -0.72317, sin(0.2 × 19.75) = -0.72319
Mueller-Müller: 800 symbols out, worst error after settling 0.123
The BPSK Costas loop locked with the 180° ambiguity: the recovered symbols are the transmitted ones negated. The Mueller-Müller example’s residual error comes from the crude linear pulse, not from the loop.
Strengths
- Standard, well-understood loops with gains set from bandwidth and damping; detectors that work through the data.
- Farrow interpolation makes timing recovery possible at any oversampling ratio.
Weaknesses
- Phase ambiguities in Costas loops; frequency offsets beyond the pull-in range need a coarse estimator first.
- The Mueller-Müller detector relies on correct decisions, so it needs a reasonable signal-to-noise ratio and carrier lock.
Exercises
- Linearise the type-2 loop and find its closed-loop transfer function and natural frequency in terms of and .
- Show that the BPSK Costas detector’s output is whatever the data, and explain the 180° ambiguity.
- Show that the Mueller-Müller error is zero on average for a Nyquist pulse sampled at its peaks.
- Derive the cubic Lagrange interpolation coefficients as polynomials in .
- Measure how long the PLL takes to lock as a function of for a fixed frequency offset, and compare with the loop’s theoretical acquisition time.
Hints and answers
- Linearising, the loop with PI filter and an NCO integrator is (with unit detector gain), so and .
- with and , where : because . The error is unchanged under , which is why the loop locks to either phase.
- For a Nyquist pulse the intersymbol interference at the sampling instants is zero, so the expected product of the sample difference and the symbol decision vanishes at the correct sampling phase.
- Cubic Lagrange through samples at at fractional offset : , , , .
- Lock time falls as the loop bandwidth rises (acquisition time of the order of or longer for a frequency offset); plot the measured time against on a log-log scale.
Further reading
- F. M. Gardner, Phaselock Techniques, 3rd ed., Wiley, 2005.
- M. Rice, Digital Communications: A Discrete-Time Approach, Pearson, 2009, chapters 7–8 and appendix C.
- K. H. Mueller and M. Müller, “Timing recovery in digital synchronous data receivers”, IEEE Transactions on Communications 24 (1976) 516–531.
- C. W. Farrow, “A continuously variable digital delay element”, Proceedings of the IEEE International Symposium on Circuits and Systems (1988) 2641–2645.