Modulation, part 2: sending bits over a real channel
Part 1 put sounds on a carrier. This page sends bits: the ones and zeros of a text message, a photo, or a phone call that has already been turned into bits. Wi-Fi, 4G and 5G, digital TV and radio, satellite links and the old dial-up modems all do this, and they all face the same problems: noise, a receiver whose clock and carrier don’t quite match the transmitter’s, and echoes.
The page starts with the simplest scheme and adds one fix at a time. It ends with a modem that sends a message from your loudspeaker to your microphone, in two ways, so you can compare them in your own room.
It leans on three earlier pages:
- Part 1, for carriers, I and Q, and the arrow they make.
- Finding signals below the noise, for the matched filter, Q(·) and false alarms.
- Designing FIR filters, for filters and their frequency responses.
A few terms first:
- A symbol is one short stretch of carrier, set to one of a few possible states (an amplitude, a phase, or both). Each symbol carries one or more bits.
- The symbol rate is how many symbols are sent each second, measured in baud. The bit rate is the symbol rate × the bits per symbol. The figures here use 1000 baud, so a symbol lasts 1 ms.
- The bit error rate (BER) is the fraction of bits that arrive wrong.
1 · The simplest: BPSK
Section titled “1 · The simplest: BPSK”Binary phase-shift keying (BPSK) sends one bit per symbol by flipping the carrier over: a 0 is sent as , and a 1 as (the same wave, half a cycle out). The receiver multiplies by its own carrier, as in Part 1, and then has to decide, symbol by symbol, which of the two arrived.
The best way to decide is the matched filter from the finding-signals page. For a symbol that’s a steady stretch of carrier, it just averages across the symbol. Noise averages towards zero, and the symbol doesn’t. Then the decision is simple: above zero means 0, below zero means 1.
How much noise matters depends on how much energy each bit has. The usual measure is : the energy per bit against the noise’s power per hertz of bandwidth. It’s the fairest way to compare schemes that send different numbers of bits per symbol, or at different rates. After the matched filter, BPSK’s output is ±1 plus Gaussian noise, so it goes wrong with probability , the same Q(·) as on the finding-signals page.
Top: 10 bits as sent (dashed) and as they arrive with noise (blue), at 4 carrier cycles per symbol. Middle: the matched filter’s output for the first 300 bits, with each wrong decision in orange. Bottom: the output for all 200,000 bits: the bits sent as +1 (blue) and those sent as −1 (green) make two bell curves, and the decision line between them.
At = 6 dB, 509 of the 200,000 bits go wrong (0.25%), against 0.24% in theory. At 0 dB, the bell curves overlap heavily and 7.9% go wrong. At 10 dB, none of the 200,000 do. Each extra decibel matters more than the last: the curves’ tails fall away very fast.
2 · More bits per symbol
Section titled “2 · More bits per symbol”Part 1 found that one carrier has two knobs: how much cosine (I) and how much sine (Q). BPSK only uses one. Each symbol is really a point on the I/Q plane, and a set of allowed points is a constellation:
- QPSK (quadrature phase-shift keying): four points, one in each quarter, so 2 bits per symbol. It’s two BPSKs at once, one on I and one on Q.
- 8-PSK: eight points round a circle, 3 bits per symbol.
- 16-QAM (quadrature amplitude modulation): a 4 × 4 grid, 4 bits per symbol.
The receiver chooses the nearest point to whatever arrives. More points means more bits per symbol, but packed closer together at the same average power, so less noise is needed to push a symbol into its neighbour’s patch.
Which bits go with which point matters too. Noise almost always moves a symbol to a neighbouring point. With Gray coding, neighbouring points differ in only one bit, so most mistakes cost one bit, not two or three. (The code is named after Frank Gray, who patented it in 1953 for a different job.)
The square: 3000 received symbols, with each mistaken one in orange, and each point’s bit pattern. Beside it: bit error rates against : the theory for each scheme (lines), and this run (the dot). BPSK’s line is hidden under QPSK’s: per bit, they’re the same.
At = 6 dB, QPSK’s bit error rate is 0.25%, the same as BPSK’s: it sends twice the bits with twice the energy per symbol, so each bit is just as safe. 8-PSK reaches 2.0%, and 16-QAM 2.7%. Turn off Gray coding: QPSK rises to 0.36%, and 16-QAM at 10 dB rises from 0.17% to 0.22%, because more of its mistakes now cost two bits.
That’s the trade every modem makes. Wi-Fi switches between BPSK and 1024-QAM (10 bits per symbol) depending on how clean the signal is. How far this can go, and what the true limit is, is the subject of a later page, on the Shannon limit.
3 · Pulse shaping
Section titled “3 · Pulse shaping”So far each symbol has been a stretch of carrier switched on and off sharply: a rectangular pulse. Sharp edges need lots of frequencies, so the signal’s spectrum spreads well beyond its own channel and into the neighbours’. That’s the same problem as the rectangular window on the FIR design page.
Smoother pulses are more compact in frequency, but they last longer, so each symbol overlaps its neighbours. That overlap is inter-symbol interference (ISI): at the moment the receiver samples one symbol, the tails of the others add to it. The trick, found by Harry Nyquist in 1928, is to use pulses that overlap but cross zero exactly at every other symbol’s sampling moment. Then, at the right moments, each symbol is heard alone.
The sinc pulse, , does this, and its spectrum is a perfect rectangle exactly one symbol rate wide. But it goes on forever, and dies away slowly. The raised-cosine pulse is the practical answer. Its spectrum’s edges are rounded off, which makes the pulse die away much faster, while keeping the zero crossings. The roll-off β says how much wider than the sinc’s spectrum it is: 0.35 means 35% wider.
One more refinement. The receiver needs a matched filter, and the transmitter a pulse shape. Splitting the raised cosine into two halves, a root-raised cosine at each end, does both jobs at once: each half is the other’s matched filter, and together they make a raised cosine with its zero crossings.
The eye diagram shows how well this works. Cut the received signal into pieces two symbols long, and draw them all on top of each other. Where the traces bunch together at the sampling moment, the eye is open and decisions are easy. Where they smear, ISI is closing it.
Top: one symbol’s pulse. Middle: the spectrum of the transmitted signal, with the next channels either side (orange, 1.5 × the symbol rate away). Bottom: the eye diagram of what the receiver sees, with the sampling moment dashed. The readouts are measured on 3000 symbols with no noise.
Rectangular pulses keep the eye fully open, but put −14.6 dB of their power into each neighbouring channel. The sinc, cut off after 8 symbols, leaks −44.4 dB, all from where it was cut off. A raised cosine with a roll-off of 0.35 leaks only −71.7 dB, with the eye still fully open. Push the roll-off to 1, though, and the spectrum is wider than the channel spacing allows: −27.8 dB.
Root-raised cosine at both ends: −55.7 dB, with the eye 99.3% open (a root-raised cosine is longer, so cutting it off after 8 symbols costs a little). Remove the receiver’s half, and the eye closes to 66.1%: the transmitter’s half on its own doesn’t cross zero in the right places.
4 · Symbol timing
Section titled “4 · Symbol timing”The receiver has to sample each symbol at the right moment: the middle of the eye. But its clock is a separate crystal from the transmitter’s, and no two crystals agree exactly. Typical ones differ by a few tens of parts per million. That sounds tiny, but it adds up: at 0.1%, the sampling moment slides by a whole symbol every 1000 symbols.
So the receiver has to keep adjusting when it samples. The Gardner timing detector (Floyd Gardner, 1986) is one of the simplest ways. Between two different symbols, the signal swings from one to the other, crossing the middle halfway. So as well as sampling each symbol, it samples halfway between symbols. If that halfway sample isn’t on the crossing, it’s early or late, and which way the swing goes says which. A small fraction of that error nudges the next sampling moment, and a slower part learns the steady clock difference. That’s a loop: measure, correct, measure again.
QPSK, root-raised-cosine pulses, at = 20 dB (the energy per symbol against the noise), with the receiver’s clock running fast. The square: the symbols sampled, second half. Beside it: where the receiver samples, against each symbol’s best moment.
With the clock 0.2% fast and no loop, the sampling moment slides 3 whole symbols over the 1500, and 1289 of the 2960 bits go wrong. Even 0.05% costs 491. Turn on the loop: no bits wrong, and the sampling stays within 0.06 of a symbol of the best moment. At 1%, it still gets every bit right, within 0.41.
5 · Carrier recovery
Section titled “5 · Carrier recovery”The receiver’s carrier has the same problem. A small frequency error makes the received constellation spin, exactly as Part 1’s I/Q arrow did. The receiver has to work out the carrier’s phase from the symbols themselves, and keep following it.
A Costas loop (John Costas, 1956) does it for QPSK. Turn each symbol back by the current phase estimate, see how far it is from the nearest corner of the square, and nudge the estimate by a fraction of that angle. Like the timing loop, a second, slower part learns the steady frequency difference. That makes it a phase-locked loop: a loop that locks onto a phase and follows it.
There’s a catch. QPSK looks the same turned by a quarter turn, so the loop can’t tell whether it has locked on the right way round, or 90°, 180° or 270° off. All the symbols then land neatly on the wrong corners. The fix is differential coding: send each pair of bits as a turn from the previous symbol (0°, 90°, 180° or 270°), not as a corner. A receiver that’s locked on a quarter-turn out still sees the right turns.
QPSK at = 12 dB, arriving with a frequency error and a starting phase error. The square: the symbols, second half (after the loop has settled). Beside it: the carrier’s actual phase (dashed) and the loop’s estimate (blue), wrapped to ±180°.
With a 5 Hz error and no loop, the constellation is a smeared ring, and 999 of the 2000 bits in the second half are wrong: a coin toss. Turn on the loop: it locks to within 10° after 45 symbols, and none are wrong. Now set the starting phase to 70°. The loop locks a quarter-turn out, and 1000 bits are wrong, though the constellation looks perfect. Turn on differential coding: none wrong.
6 · Echoes
Section titled “6 · Echoes”Radio waves and sound both bounce: off buildings, hills, walls and furniture. The receiver hears the direct path, plus delayed and weaker copies. That’s multipath, and it’s the echo the finding-signals page measured in your room.
An echo that arrives a symbol or two late adds the previous symbols on top of the current one: ISI again, now caused by the channel, not the pulses. Seen as frequencies, a delayed copy adds to the direct sound at some frequencies and cancels it at others, carving notches into the band, just like a comb filter.
QPSK through one echo, at = 25 dB. The square: the symbols as received. Beside it: the eye diagram. Below: the channel’s gain across frequency, with the signal’s band in green.
With no echo, the eye is 76% open (the rest is noise). An echo at 60% strength, 1.5 symbols late, closes it to 1%: each of the four corners has split into a grid of small clusters, one for each combination of the earlier symbols the echo adds in. No bits are wrong yet, but at 90%, 677 of the 6000 are. Move the delay: the notches move, and the damage changes, because the echo’s phase depends on its delay.
7 · Equalisers
Section titled “7 · Equalisers”An equaliser is a filter at the receiver that undoes the channel: it flattens the notches back out, and with them the ISI.
The naive way is zero-forcing: work out the channel’s response, and use a filter that’s its exact inverse, so channel × equaliser = 1 at every frequency. The trouble is the notches. Where the channel cuts a frequency right down, the inverse boosts it right up, and boosts the noise there with it.
The better way doesn’t insist on a perfect inverse. The MMSE equaliser (minimum mean square error) balances leftover ISI against amplified noise, and minimises the total. It’s the same calculation as zero-forcing, with one change: the noise’s power is added in, which stops it chasing a deep notch at any cost.
Both need to know the channel. A real receiver doesn’t, so it learns. The LMS algorithm (least mean squares, Bernard Widrow and Ted Hoff, 1960) starts with a filter that does nothing, compares each output with what should have been sent, and nudges every tap a little to shrink the error. To know what should have been sent, the transmitter starts with a training sequence the receiver already knows. After that, the equaliser trusts its own decisions (decision-directed), which lets it keep following a channel that slowly changes. LMS ends up close to the MMSE equaliser, without ever being told the channel.
QPSK through a chosen channel, then the equaliser (31 taps, one per symbol). The square: the symbols after the equaliser, from symbol 2000 on. Beside it: the error power over time (for LMS, training in green). Below: the channel’s response (dashed), the equaliser’s (orange), and the two together (blue).
The deep notch at = 15 dB: with no equaliser, 728 of the 4000 bits counted are wrong. Zero-forcing fills in most of the notch (31 taps can’t quite reach the bottom of it), but raises the noise by 5.9 dB doing it, leaving an MER of 8.6 dB and 11 bits wrong. MMSE gives 10.7 dB and 2 wrong. LMS, which has to learn the channel from scratch, gives 9.5 dB and 10 wrong.
Turn the noise up to = 10 dB and the difference grows: zero-forcing gets 236 bits wrong, MMSE 38, and LMS 60. The MER (modulation error ratio) is the symbols’ power against the leftover error’s, after choosing the nearest points. With noise alone, it’s the SNR.
8 · OFDM
Section titled “8 · OFDM”Equalisers get hard as echoes get longer. A room’s echoes last tens of milliseconds, and at a million symbols a second, a city’s radio echoes last dozens of symbols. OFDM (orthogonal frequency-division multiplexing) takes another approach: instead of one fast stream of short symbols, send many slow streams side by side, each on its own carrier, each symbol lasting much longer than the echoes.
The carriers are spaced so that each one fits a whole number of cycles in a symbol. Then, as with the DFT’s bins on the Fourier page, they’re orthogonal: an FFT at the receiver separates them perfectly. In fact the transmitter makes the whole set with one inverse FFT, and the receiver takes it apart with one FFT.
Two more ideas make it work:
- The cyclic prefix. Before each OFDM symbol, the transmitter repeats its last few samples. As long as the prefix is longer than the echoes, every echo of the symbol’s start lands inside the prefix, which the receiver throws away. What’s left looks to each carrier as if the echo just changed its size and phase.
- One multiply per carrier. Each carrier only needs its own size and phase undone: a one-tap equaliser, measured from a known training symbol. There’s no long filter to learn.
OFDM with 64 carriers (48 used), through one echo, at = 25 dB. The square: every carrier’s symbols, after its one-tap equaliser. Beside it: each carrier’s gain, measured from the training symbol: the echo’s notches, carrier by carrier.
With the echo 6 samples late at 60% and a prefix of 8 samples, the MER is 20.0 dB and no bits are wrong, for 11% of the time spent on the prefix. Shorten the prefix to 4: the echo spills past it, the carriers interfere with each other, the MER drops to 9.1 dB and 6 bits go wrong. With no prefix, 37 do.
OFDM is how Wi-Fi, 4G, 5G, digital TV and DAB radio all work. Its weakness is the notches. A carrier in a deep notch arrives too weak to read, however good the others are. Real systems spread each bit’s information across many carriers with an error-correcting code (another page on the roadmap), so a few lost carriers don’t matter.
9 · Your own acoustic modem
Section titled “9 · Your own acoustic modem”Now both approaches, through a real room. Type a message and choose a modem:
- Single carrier: QPSK at 1000 baud on a 3 kHz carrier, with root-raised-cosine pulses (roll-off 0.5). The receiver uses an LMS equaliser (41 taps, half a symbol apart) trained on 300 known symbols, with a Costas loop running on its output.
- OFDM: 4096-point symbols (85 ms), with a 21 ms cyclic prefix and carriers from 1.5 to 5 kHz. Every 8th carrier is a known pilot, which lets the receiver follow the carrier’s drift. To survive the room’s notches without an error-correcting code, every symbol is sent twice, on two carriers 1.75 kHz apart, and the receiver combines the two copies, weighting each by how strongly its carrier arrived (maximal-ratio combining). That’s the simplest kind of code, and it halves the bit rate.
- OFDM with an error-correcting code: the same carriers, but with a real code in place of sending everything twice, at the same rate. It’s explained on the error-correcting codes page.
Both start with a short chirp, which the receiver finds with a matched filter, so it knows where the message begins. The chirp also says which modem follows: it rises (1 → 6 kHz) before the single carrier, falls (6 → 1 kHz) before OFDM, and rises then falls before coded OFDM. The three hardly match each other at all, so a receiver can listen for all of them and know which modem to use. The message itself is a length byte, the text, and a 16-bit CRC (cyclic redundancy check): check bits calculated from the message, which almost any corruption would change. If the CRC still matches, the message arrived intact.
The two squares: the received symbols before the receiver’s corrections, and after them. Below: the recording, with the chirp’s position, and either the equaliser’s error power (single carrier) or the room’s gain carrier by carrier (OFDM).
The readouts give the measured SNR: the MER of the received symbols, which the receiver can work out for itself, from how far each symbol lands from its nearest point. They also count the bits that arrived wrong: this figure knows what was sent, though a real receiver wouldn’t. Before anything is recorded, the figure uses a made-up room: the direct sound, four reflections up to 13 ms later, and a reverberant tail.
In the made-up rooms, the message shown arrives intact both ways. Single carrier measures 13.1 dB with the microphone close by, and 10.2 dB in the echoey room. OFDM measures 19.1 and 14.4 dB. OFDM’s long symbols and prefix shrug off most of the reverberation, while the single carrier’s equaliser reaches only 24 ms past the direct sound, so the room’s long tail stays as noise. Fill the message to its 64 bytes, in the echoey room: the single carrier gets 4 of its 536 bits wrong, and the checksum says so. OFDM gets them all right.
Use loudspeakers, not headphones. A quiet room helps, and so does turning off any processing on the microphone (see below).
Two computers: open this page on both. On one, press Listen: it records for 10 seconds. On the other, press Send only while the first is listening. The listening computer works out which modem was used from the chirp, and decodes the message. It can’t count the bits that went wrong, because it doesn’t know what was sent: like a real receiver, it has only the checksum and the measured SNR to go on. The two computers’ clocks will differ slightly, which the receivers’ loops follow, as in sections 4 and 5.
The direction the microphone faces matters a lot. Aimed at the loudspeaker, it mostly hears the direct sound, the easiest channel there is. A directional microphone aimed away hears mostly the room’s reverberation, the hardest: neither modem here is built for that. Real acoustic and radio modems survive it with slower, more robust symbols and error-correcting codes.
Turn off the microphone’s processing
Section titled “Turn off the microphone’s processing”Audio interfaces, mixers and video-call apps often process a microphone’s signal to flatter a voice: a compressor that turns loud moments down, a noise gate that mutes quiet ones, and “enhancers” that add harmonics. None of it sounds like distortion, but a modem isn’t a voice. A compressor keeps nudging the gain up and down, and to the receiver that looks like a channel that never sits still.
OFDM suffers most. Its many carriers add up to a signal whose peaks stand far above its average, about 17 dB here, so it makes a compressor work hard. And it corrects itself only once per symbol, every 85 ms, while the single carrier’s equaliser and phase loop follow changes continuously.
In one test with a studio microphone on an audio interface, OFDM measured 15.2 dB with the interface’s processing on, and the single carrier 25.3 dB. With all the processing switched off, and nothing else changed, OFDM measured 24.4 dB and the single carrier 26.6 dB. The tell-tale sign was that OFDM improved a lot when the loudspeaker was turned down: a room’s echoes scale with the volume, but a compressor only acts on loud signals. This is why measurement software turns such processing off, and why many video-call apps offer an “original sound” mode for music. This page asks the browser to turn off its own voice processing, but it can’t reach settings inside an interface or mixer.
Nothing you record leaves your computer.
Summary
Section titled “Summary”- BPSK sends a bit by flipping the carrier. The matched filter is the best receiver, and errors follow .
- QPSK, 8-PSK and QAM use both I and Q to send more bits per symbol, at the cost of more energy per bit for the same error rate. Gray coding makes most mistakes cost one bit.
- Pulse shaping keeps the spectrum inside its channel. Raised-cosine pulses overlap, but cross zero at the other symbols’ sampling moments. Split as root-raised cosines, they’re also the matched filter.
- Timing and carrier recovery are loops that measure and correct, continuously: Gardner for the timing, Costas for the carrier. Differential coding removes the quarter-turn ambiguity.
- Echoes cause ISI and notches. Equalisers undo them: zero-forcing amplifies noise in the notches, MMSE balances, and LMS learns from a training sequence.
- OFDM sends many slow carriers instead, with a cyclic prefix longer than the echoes and one multiply per carrier. It needs error-correcting codes to cope with notches.
Further reading
Section titled “Further reading”- H. Nyquist, “Certain topics in telegraph transmission theory”, Transactions of the AIEE 47 (1928): the conditions for pulses that don’t interfere.
- B. Widrow and M. E. Hoff, “Adaptive switching circuits”, IRE WESCON Convention Record (1960): the LMS algorithm.
- J. P. Costas, “Synchronous communications”, Proceedings of the IRE 44 (1956).
- F. M. Gardner, “A BPSK/QPSK timing-error detector for sampled receivers”, IEEE Transactions on Communications 34 (1986).
- M. Rice, Digital Communications: A Discrete-Time Approach, Pearson (2009): everything on this page, step by step, with discrete-time examples.
- J. G. Proakis and M. Salehi, Digital Communications, 5th edition, McGraw-Hill (2007): the standard reference.