Radio from scratch · Chapter 21

Digital radio from space

Before you startThis chapter uses:

Russia's Meteor-M weather satellites circle the Earth from pole to pole, 830 km up, and broadcast what their cameras see, unencrypted, to anyone with a $30 dongle and a homemade antenna. The signal is called LRPT (low rate picture transmission): around 137.1 or 137.9 MHz, 72,000 symbols a second (a symbol is one piece of data sent as one arrow position: section 2), a strip of picture at a time as the satellite sweeps over you. Chapter 20's TV was analog: the voltage was the brightness. This one is digital: numbers, packed, protected and modulated. Everything that makes digital radio work is in it.

This chapter and the next build a link with the same structure (we simplified two layers, noted where they come up). This one gets from the antenna to clean symbols: catching a signal whose frequency slides, finding where each symbol starts, and reading its arrow. Chapter 22 turns symbols into a picture that survives the errors. The question for this chapter: how does a receiver read 72,000 arrows a second, when it doesn't know their frequency, their timing or their data?

A pass, and a frequency that slides

A satellite in low orbit is above your horizon for at most about 15 minutes, a few times a day. Coming toward you, its signal is squeezed to a higher frequency; going away, stretched lower: the Doppler shift, the same thing that drops an ambulance siren's pitch as it passes. At 137.9 MHz and 7.45 km/s it slides by about ±3 kHz. Choose how high the pass goes:

The Doppler shift changes fastest when the satellite is…

Overhead, its motion swings from "toward you" to "away from you" in a few minutes, so the curve is steepest there (up to about 50 Hz a second on an overhead pass). The receiver has to track that, which is the last section's job.

Symbols: one arrow position at a time

Before we can fix that sliding Doppler frequency from section 1, we need to see what the satellite's transmitter is actually putting on the air during those 15 minutes. FM sends music as a smooth wobble. A digital transmitter instead holds its arrow at one of a few positions for a fixed time, a symbol, then moves to the next. LRPT sends 72,000 symbols a second, so each lasts about 14 µs. Jumping instantly between positions would splash energy far outside the channel (sharp edges are made of fast arrows, chapter 4), so each symbol is sent as a smooth bump, a pulse shape. LRPT's is called root-raised-cosine. The bumps of neighboring symbols overlap, but are designed so they don't disturb each other at the right moments.

Predict: the receiver takes several samples during each symbol, all noisy. Which gives the best estimate of the symbol's value?

Every sample carries some of the symbol, and each has its own independent noise. Averaging them, weighted by how much of the symbol is in each, keeps all the symbol and averages away the noise (chapter 6). Try it below.

The gray staircase is what was meant (+1 or −1 for each symbol, one shadow only to keep the picture readable); the blue dots are what arrives, eight noisy samples per symbol. Tick Matched filter: the receiver filters with the pulse's own shape as the weights (chapter 6's weighted average). The yellow result is smooth, and at each symbol's middle (the white marks) it lands close to +1 or −1. In this picture the filter improves the signal-to-noise ratio at the middles by about 9 dB, because it collects all eight samples' worth of the symbol instead of one. No other filter can do better on this kind of noise: weighting each moment by how much of the symbol it holds is the best possible. That's why it's called the matched filter.

A symbol is one arrow position held for a fixed time. Filtering with the pulse's own shape collects all of its energy before the receiver looks.

Why is the matched filter about 9 dB better than one sample?
  1. Each of the 8 samples across a symbol carries some of the symbol, and each has its own independent noise.
  2. Adding 8 samples adds the symbol's parts as numbers: the symbol grows about 8 times.
  3. Independent noises add as powers (chapter 3): 8 times the power, √8 times the RMS.
  4. So the signal-to-noise ratio grows 8 times: 10 · log₁₀ 8 = 9.0 dB.
  5. Weighting by the pulse's shape does this best when the samples hold unequal parts of the symbol. The script measures 8.8 dB.

When to look: the middle of each symbol

After the matched filter, each symbol is clearest at one moment, its middle. Sample there and the values are crisp; sample between two symbols and you get a blur of both. But the receiver's clock and the satellite's never quite agree (chapter 11's two clocks), so the right moment drifts slowly, and the receiver has to find it and keep finding it.

This is every symbol's stretch of the filtered signal drawn on top of the others: an eye diagram. Where the eye is open widest, the symbols are clearest; that's the middle. Slide the sampling moment away from it and the signal-to-noise ratio drops fast: a quarter of a symbol off costs about 10 dB here.

How does the receiver find the middle without knowing the data? Gardner's trick takes one extra sample, halfway between two symbols. When the two symbols differ (+1 then −1), the signal must cross zero exactly halfway. If the halfway sample isn't zero, the receiver is early or late: multiply it by the difference of the two symbols, and the sign of the result says which (positive: early; negative: late). The receiver nudges its sampling clock a little at every symbol, chapter 11's control loop again, this time steering time. When neighboring symbols are the same, the halfway sample tells nothing, and the difference is zero, so it adds nothing to the nudge.

Sample each symbol at its middle. Gardner's check of the halfway point between symbols says early or late, and keeps the receiver's clock there.

Where it breaks

Gardner's check needs changes. Between two equal symbols (+1, +1) the halfway sample isn't zero, and the difference of the two symbols is zero, so the check says nothing either way. A long run of equal symbols gives the clock no news, and it can drift off the middle. That's one reason the satellite scrambles its data before sending (chapter 22: XOR with a known pattern): it breaks long runs, so changes keep coming.

Four arrows for two bits: QPSK

In the last two sections we watched only one shadow (+1 or −1, one bit per symbol) to keep the waveform easy to read. To send twice as much picture during a short pass without taking up twice the radio bandwidth, the satellite uses both shadows (I and Q) at once: the carrier is chapter 1's spinning arrow again, and each symbol sets its angle to one of four positions, 45°, 135°, 225° or 315°: QPSK, two bits per symbol. Plotting each received symbol as a 2-D dot gives a constellation: four tight clusters when all is well. Noise blurs the clusters. And now the Doppler shift from section 1 comes back to bite us: a frequency error rotates every symbol a little more than the last, smearing the four clusters into a ring.

Es/N0 is chapter 3's signal-to-noise ratio, counted per symbol: one symbol's energy compared with the noise in a bandwidth as wide as the symbol rate. It's what decides how often noise pushes a symbol into the wrong quarter. The left picture is what the receiver gets; the right one is after it measured and removed the frequency error, then kept tracking it.

Finding the frequency: the 4th-power trick and the Costas loop

To remove the Doppler, the receiver first has to measure it, without knowing the data. The trick: raise every symbol to the 4th power (as a complex number, chapter 2: multiply its angle by four). The four QPSK angles, 45° + 90°·k, all become 180°: the data disappears, and what's left spins at exactly four times the frequency error. One FFT (chapter 4) of those 4th powers shows a single spike; divide its frequency by four.

\[ z = e^{j(\pi/4 + k\pi/2 + \Delta\omega\, n)} \quad\Rightarrow\quad z^4 = e^{j(\pi + 2k\pi + 4\Delta\omega\, n)} = -e^{j\,4\Delta\omega\, n} \]

In that line, n counts symbols, k (0 to 3) is which of the four positions a symbol uses, and Δω is the frequency error as an angle per symbol. Times four, the data's part becomes a whole number of turns (2kπ) and drops out.

Then a Costas loop keeps it locked as the Doppler slides: for each symbol, compare it to the nearest of the four points, and nudge the receiver's phase (and, more slowly, its frequency) by the angle it's off. It's chapter 11's control loop, steering an angle instead of a clock.

A Costas loop can lock with the constellation rotated by 0°, 90°, 180° or 270°: all four look identical. How does the receiver find out which is right?

Every frame of data starts with the same 32 bits, the sync word (0x1ACFFC1D in hexadecimal, chapter 3). Read with the wrong rotation, the bits are garbage and the word never appears; with the right one, it appears every frame. Our receiver tries all four until one finds two sync words in a row, then keeps only that one. Chapter 22 shows what else the sync word is for.

Raising each symbol to the 4th power erases QPSK's data and leaves four times the frequency error, which one FFT measures; a Costas loop then tracks the drift symbol by symbol.

In code

Show the real code (optional: everything it does is explained above)

The link is about 300 lines of code, transmitter and receiver. The receiver's front end, from this chapter, for every sample and then every symbol:

// matched filter: the transmitter's own pulse, used as filter weights (chapter 6)
let a = 0, b = 0; for (let j = 0; j < L; j++) { a += H[j] * m[2 * j]; b += H[j] * m[2 * j + 1]; }
// Gardner: the previous symbol minus this one, times the sample halfway between them
const e = (this.prevI - sI) * mI + (this.prevQ - sQ) * mQ;
this.t += this.rate + GAINS.g1 * e;                   // nudge where the next symbol is sampled
// Costas loop: how far the symbol sits off its nearest QPSK point, as an angle; steer phase and frequency
const err = Math.sign(zi) * zq - Math.sign(zq) * zi;
this.w += 0.0004 * err; this.cphase += this.w + 0.03 * err;

Chapter 22 picks up where this ends: four rotations into four decoders, the sync word, and the picture.

Where this chapter's numbers come from. The numbers this chapter computes come from a short checking script behind this page, which also checks each claim and stops if one is wrong. The symbols come from the same code as this page's pictures. Its output:

a pass rising to 10°: 11.4 min above the horizon, Doppler 2128 → -2128 Hz, closest 2428 km
a pass rising to 30°: 14.7 min above the horizon, Doppler 2814 → -2814 Hz, closest 1442 km
a pass rising to 90°: 15.6 min above the horizon, Doppler 3032 → -3032 Hz, closest 830 km
at 8 samples per symbol: one sample at the middle 10.9 dB, after the matched filter 19.7 dB (8.8 dB better)
sampling ¼ symbol early  : SNR 9.2 dB, Gardner's error +0.255
sampling at the middle   : SNR 19.7 dB, Gardner's error +0.006
sampling ¼ symbol late   : SNR 9.9 dB, Gardner's error -0.254
a -2000 Hz offset, Es/N0 8 dB: the 4th-power FFT measures -2000 Hz
a  1000 Hz offset, Es/N0 8 dB: the 4th-power FFT measures  1002 Hz
a  2500 Hz offset, Es/N0 8 dB: the 4th-power FFT measures  2500 Hz
all checks passed

Check yourself

Why does the frequency of a satellite's signal slide during a pass?

Doppler: approaching, the waves are compressed (higher frequency); receding, stretched (lower). The change is fastest as it flies past overhead.

Why filter with the pulse's own shape before looking at a symbol?

Every sample during the symbol carries some of it, each with its own noise. Weighting them by the pulse's shape keeps all of the symbol and averages away the most noise: about 9 dB better than one sample, here.

The halfway sample between a +1 and a −1 symbol is slightly negative. Is the receiver early or late?

Late: the signal has already crossed zero on its way to −1. (Previous − current = 2, times a negative halfway sample: a negative error, which the loop answers by sampling a little earlier.)

How does the 4th power remove QPSK's data?

Multiplying angles by four turns all four QPSK angles (45° + k·90°) into 180°, so only the frequency error remains, at four times its size.

Last updated