Skip to content
LumenaryAcademy
Waves 80 min

Modulation

How information rides on a carrier wave, from AM and FM radio to the constellations, pulse shapes and OFDM symbols of Wi-Fi and 5G.

Code tested · 6AI-draftedAwaiting review by an electrical engineer

Your guides: Chloe · The Physicist, Margaret · The Bench Engineer, Gideon · The Design Reviewer

MotivationH

Putting information on a wave

A voice is a signal from about 100 Hz to a few kilohertz. You cannot radiate it directly: a half-wave antenna at 3 kHz would be 50 km long, and if every radio station transmitted its audio as it is, they would all occupy the same few kilohertz and drown each other out. The solution, used by every radio system since the early twentieth century, is modulation: take a high-frequency sine wave, the carrier, and vary one of its properties in step with the message. The carrier's frequency is chosen for convenient antennas (antennas and radio links), the propagation the service needs, and a slot of spectrum that no neighbour is using.

There are only three things one can change about a sine wave: its amplitude, its frequency and its phase. This lesson starts with the analog versions, AM and FM, which are still on the air, and moves to digital modulation, where the message is a stream of bits and the questions become: how many bits per second fit in a given bandwidth, and how many of them arrive wrong? It ends with OFDM, the scheme behind Wi-Fi, 4G, 5G, digital television and DSL.

IntuitionH

Two knobs on every carrier: I and Q

A carrier at frequency fcf_c modulated in amplitude and phase can always be written as

s(t)=A(t)cos⁡(2πfct+ϕ(t))=I(t)cos⁡(2πfct)−Q(t)sin⁡(2πfct),s(t) = A(t)\cos\big(2\pi f_c t + \phi(t)\big) = I(t)\cos(2\pi f_c t) - Q(t)\sin(2\pi f_c t),

where I=Acos⁡ϕI = A\cos\phi is the in-phase component and Q=Asin⁡ϕQ = A\sin\phi the quadrature component. Equivalently, s(t)=Re{x(t) ej2πfct}s(t) = \text{Re}\{x(t)\,e^{j2\pi f_c t}\} with the complex envelope x(t)=I(t)+jQ(t)x(t) = I(t) + jQ(t). This is the phasor of AC circuits, except that now it is allowed to move slowly: the carrier spins the phasor at fcf_c, and the message steers it.

The practical consequence is enormous. A modulator does not need to know anything about AM, FM or QAM: it takes two baseband signals, II and QQ, multiplies them by a cosine and a sine of the carrier and adds them. The direct-conversion receiver of the last lesson does the reverse and hands II and QQ to a processor. Every modulation scheme is then just a choice of path for the point I+jQI + jQ in the complex plane, and can be generated and decoded in software.

DefinitionsH

Analog modulation

Definition— amplitude modulation (AM)

With a message m(t)m(t) scaled so that ∣m(t)∣≤1|m(t)| \le 1 and a modulation index 0<μ≤10 \lt \mu \le 1, an AM signal is s(t)=Ac [1+μ m(t)]cos⁡(2πfct)s(t) = A_c\,[1 + \mu\,m(t)]\cos(2\pi f_c t). Its envelope follows the message.

Definition— frequency and phase modulation (FM and PM)

In FM, the instantaneous frequency is fc+Δf m(t)f_c + \Delta f\,m(t), where Δf\Delta f is the peak deviation: s(t)=Accos⁡ ⁣(2πfct+2πΔf∫0tm(τ) dτ)s(t) = A_c\cos\!\big(2\pi f_c t + 2\pi\Delta f\int_0^t m(\tau)\,d\tau\big). In PM, the phase itself follows the message: s(t)=Accos⁡(2πfct+kpm(t))s(t) = A_c\cos(2\pi f_c t + k_p m(t)). For a sinusoidal message of frequency fmf_m, the FM modulation index is β=Δf/fm\beta = \Delta f/f_m.

messageAMFMtime →
A message (top), the same message as AM (middle: the carrier's amplitude follows the message, and the dashed envelope is a copy of it) and as FM (bottom: the carrier's amplitude is constant, and its frequency rises and falls with the message).

FM and PM are two views of one thing: FM is PM of the integral of the message. Both are called angle modulation, and both have a constant envelope, which lets the transmitter use an efficient amplifier running flat out, and makes the signal immune to amplitude disturbances.

ExplanationH

Spectra of AM and FM, and Carson's rule

The spectrum shows what each scheme costs in bandwidth. For a single message tone, m(t)=cos⁡(2πfmt)m(t) = \cos(2\pi f_m t), AM gives

s(t)=Accos⁡(2πfct)+μAc2cos⁡(2π(fc+fm)t)+μAc2cos⁡(2π(fc−fm)t):s(t) = A_c\cos(2\pi f_c t) + \frac{\mu A_c}{2}\cos\big(2\pi(f_c + f_m)t\big) + \frac{\mu A_c}{2}\cos\big(2\pi(f_c - f_m)t\big):

a carrier and two sidebands, so AM occupies twice the message bandwidth. FM is less tidy. The tone produces lines at fc±nfmf_c \pm nf_m for every integer nn, with amplitudes given by Bessel functions Jn(β)J_n(\beta); in principle the spectrum is infinite, but the lines die out quickly once nn exceeds β+1\beta + 1. That observation is Carson's rule: about 98 % of an FM signal's power lies within

B≈2(Δf+fm).B \approx 2(\Delta f + f_m).

The program builds both signals, measures their spectra with the FFT of sampling and the FFT, compares the FM lines with Bessel functions, and checks Carson's rule.

python
import numpy as np

fs, T = 200_000, 0.1                     # sample rate (Hz) and duration (s): 0.1 s gives 10 Hz bins
t = np.arange(int(fs * T)) / fs
fc, fm = 20_000, 1_000                   # carrier and message (a single tone) frequencies
message = np.cos(2 * np.pi * fm * t)

def spectrum_lines(s, label, threshold=0.01):
    """Print the amplitude of every spectral line above the threshold (single-sided)."""
    amp = 2 * np.abs(np.fft.rfft(s)) / len(s)
    freqs = np.fft.rfftfreq(len(s), 1 / fs)
    lines = [(f, a) for f, a in zip(freqs, amp) if a > threshold]
    print(label, " ".join(f"{f / 1e3:.0f}k:{a:.3f}" for f, a in lines))
    return freqs, amp

# AM with modulation index m = 0.5
m = 0.5
am = (1 + m * message) * np.cos(2 * np.pi * fc * t)
spectrum_lines(am, "AM lines (kHz:amplitude):")
print(f"fraction of AM power in the sidebands: {m**2 / (2 + m**2):.3f}")

# FM with peak deviation 5 kHz, so beta = 5
dev = 5_000
beta = dev / fm
phase = 2 * np.pi * dev * np.cumsum(message) / fs        # integral of the instantaneous frequency
fmsig = np.cos(2 * np.pi * fc * t + phase)
freqs, amp = spectrum_lines(fmsig, "FM lines (kHz:amplitude):", threshold=0.05)

def bessel_j(n, x, steps=20000):                        # J_n(x) = (1/pi) * integral of cos(n tau - x sin tau)
    tau = (np.arange(steps) + 0.5) * np.pi / steps
    return np.mean(np.cos(n * tau - x * np.sin(tau)))

print("Bessel |J_n(5)| for n = 0..8:", " ".join(f"{abs(bessel_j(n, beta)):.3f}" for n in range(9)))
power = amp**2 / 2
order = np.argsort(np.abs(freqs - fc))                  # widen a band around fc until it holds 98 %
inside = np.cumsum(power[order]) / power.sum()
bw98 = 2 * np.abs(freqs[order][np.searchsorted(inside, 0.98)] - fc)
print(f"measured 98 % bandwidth: {bw98 / 1e3:.0f} kHz; Carson's rule 2(df + fm): {2 * (dev + fm) / 1e3:.0f} kHz")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

AM with μ=0.5\mu = 0.5 shows the carrier at 20 kHz and two sidebands of amplitude μ/2=0.25\mu/2 = 0.25, and only 11 % of the transmitted power is in the sidebands, which are the only part carrying the message. That waste is the price of a receiver as simple as a diode and a capacitor following the envelope, and it is why AM broadcasting is inefficient and why variants that suppress the carrier (DSB-SC) or one sideband as well (SSB, used by aviation and amateur HF radio) exist.

FM with β=5\beta = 5 shows lines 1 kHz apart whose heights match ∣Jn(5)∣|J_n(5)| exactly; the lines at ±2\pm 2 kHz almost vanish because J2(5)J_2(5) happens to be small, and even the carrier line has shrunk to 0.178, because in FM the total power is fixed and the modulation redistributes it. The measured 98 % bandwidth is 12 kHz, as Carson's rule predicts. Broadcast FM uses Δf=75\Delta f = 75 kHz and audio up to 15 kHz, so Carson gives 180 kHz, which is why FM stations are spaced 200 kHz (or in some regions 100 kHz, with geographical separation) apart.

FM spends bandwidth to buy quality: above a threshold signal-to-noise ratio, widening the deviation improves the output SNR roughly as β2\beta^2. Below the threshold, the improvement collapses and the receiver output turns to crackle. That trade of bandwidth for noise immunity is our first glimpse of Shannon's theorem in information theory.

ExplanationH

Digital modulation and constellations

In digital modulation, time is divided into symbol periods of length TsT_s, and in each one the transmitter sends one of MM possible waveforms, carrying log⁡2M\log_2 M bits. The symbol rate is Rs=1/TsR_s = 1/T_s (in baud) and the bit rate Rb=Rslog⁡2MR_b = R_s\log_2 M. Each symbol is a point I+jQI + jQ in the complex plane, and the set of points is the constellation.

  • ASK (amplitude-shift keying) uses different amplitudes; its simplest form, on–off keying, is how infrared remote controls and many cheap 433 MHz sensors send bits.
  • FSK (frequency-shift keying) uses different frequencies. It has a constant envelope, so it suits cheap, efficient transmitters: Bluetooth Low Energy uses a filtered form, Gaussian FSK.
  • PSK (phase-shift keying) uses phases at a constant amplitude: BPSK has two (00 and 180°180°), QPSK four, 8-PSK eight.
  • QAM (quadrature amplitude modulation) uses a grid of points in both II and QQ: 16-QAM carries 4 bits per symbol, 256-QAM 8, and Wi-Fi 7 goes up to 4096-QAM, 12 bits per symbol.
10BPSK: 1 bit/symbol00011110QPSK: 2 bits/symbol16-QAM: 4 bits/symbolIQIQIQ
Constellations of BPSK, QPSK and 16-QAM, with I horizontal and Q vertical. The QPSK points are labelled with a Gray code: neighbouring points differ in one bit, so the most likely error, mistaking a point for its neighbour, costs only one bit. The dotted lines on 16-QAM are the receiver's decision boundaries.

Denser constellations carry more bits per symbol, but at the same average power their points are closer together, so less noise is needed to push a received point across a decision boundary. Every scheme is therefore a trade between spectral efficiency (bits per second per hertz) and power efficiency (the energy per bit needed for a target error rate). The natural measure of the second is Eb/N0E_b/N_0, the energy per bit divided by the noise power spectral density; it is related to the signal-to-noise ratio in a bandwidth BB by SNR=(Eb/N0)(Rb/B)\text{SNR} = (E_b/N_0)(R_b/B).

Theorem— Bit error rate of BPSK

BPSK sends ±Eb\pm\sqrt{E_b} in additive white Gaussian noise of power spectral density N0/2N_0/2. With a matched filter and a decision at zero, the probability of a bit error is

Pb=Q ⁣(2EbN0)=12erfc⁡ ⁣(EbN0),P_b = Q\!\left(\sqrt{\frac{2E_b}{N_0}}\right) = \frac{1}{2}\operatorname{erfc}\!\left(\sqrt{\frac{E_b}{N_0}}\right),

where Q(x)Q(x) is the probability that a standard normal variable exceeds xx.

Proof

After the matched filter (which correlates the received signal with the pulse shape), the decision variable is y=±Eb+ny = \pm\sqrt{E_b} + n, where nn is Gaussian with mean zero and variance N0/2N_0/2. If +Eb+\sqrt{E_b} was sent, an error occurs when n<−Ebn \lt -\sqrt{E_b}, which has probability Q(Eb/N0/2)=Q(2Eb/N0)Q\big(\sqrt{E_b}/\sqrt{N_0/2}\big) = Q\big(\sqrt{2E_b/N_0}\big); by symmetry the same holds for −Eb-\sqrt{E_b}. The identity Q(x)=12erfc⁡(x/2)Q(x) = \frac12\operatorname{erfc}(x/\sqrt2) gives the second form.

∎

QPSK is two BPSK signals, on II and on QQ, which do not disturb each other (they are orthogonal), so with Gray coding its bit error rate is the same function of Eb/N0E_b/N_0: twice the bits in the same bandwidth for no extra energy per bit. Let us check both claims by simulation, with two million bits per point and a fixed random seed.

python
import math
import numpy as np

rng = np.random.default_rng(2026)
n_bits = 2_000_000

print("Eb/N0   BPSK simulated   QPSK simulated   theory Q(sqrt(2 Eb/N0))")
for ebn0_db in range(0, 10):
    ebn0 = 10 ** (ebn0_db / 10)
    bits = rng.integers(0, 2, n_bits)

    # BPSK: one bit per symbol, symbol energy Eb = 1, noise variance N0/2 per real dimension
    x = 1.0 - 2.0 * bits                                   # 0 -> +1, 1 -> -1
    y = x + rng.normal(0, math.sqrt(1 / (2 * ebn0)), n_bits)
    ber_bpsk = np.mean((y < 0) != (bits == 1))

    # QPSK: two bits per symbol (I and Q), symbol energy 2 Eb, Gray-coded
    i_bits, q_bits = bits[0::2], bits[1::2]
    s = (1.0 - 2.0 * i_bits) + 1j * (1.0 - 2.0 * q_bits)
    noise = rng.normal(0, math.sqrt(1 / (2 * ebn0)), (2, len(s)))
    r = s + noise[0] + 1j * noise[1]
    errors = np.sum((r.real < 0) != (i_bits == 1)) + np.sum((r.imag < 0) != (q_bits == 1))
    ber_qpsk = errors / n_bits

    theory = 0.5 * math.erfc(math.sqrt(ebn0))
    print(f"{ebn0_db:3d} dB   {ber_bpsk:14.2e}   {ber_qpsk:14.2e}   {theory:14.2e}")

for target in (1e-3, 1e-6):                                # Eb/N0 needed for a target BER
    lo, hi = 0.0, 20.0
    for _ in range(60):
        mid = (lo + hi) / 2
        lo, hi = (mid, hi) if 0.5 * math.erfc(math.sqrt(10 ** (mid / 10))) > target else (lo, mid)
    print(f"BER {target:.0e} needs Eb/N0 = {mid:.1f} dB")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

The simulated points follow the theory closely down to 10−510^{-5}, where only about 60 errors are counted and the statistics start to wobble, and BPSK and QPSK are indistinguishable. Reading the last lines: a link that must deliver one error in a million bits needs Eb/N0=10.5E_b/N_0 = 10.5 dB with BPSK.

ExplanationH

Pulse shaping and inter-symbol interference

So far each symbol was an instant. In reality each symbol is sent as a pulse p(t)p(t), and the transmitted baseband signal is x(t)=∑kak p(t−kTs)x(t) = \sum_k a_k\,p(t - kT_s), where aka_k are the constellation points. The pulse shape decides two things: how much spectrum the signal occupies, and whether the symbols interfere with each other.

Rectangular pulses are the obvious choice and the worst for spectrum: their spectrum is a sinc, sinc2(fTs)\text{sinc}^2(fT_s) in power, whose tails decay only as 1/f21/f^2 and splash power into neighbouring channels. Making the pulses smoother narrows the spectrum but stretches them in time, and then each pulse overlaps its neighbours: inter-symbol interference (ISI). A channel that filters the signal (a long cable, a bandwidth-limited amplifier) does the same.

Theorem— Nyquist criterion for zero ISI

A pulse p(t)p(t) with p(0)=1p(0) = 1 causes no inter-symbol interference at the sampling instants, p(kTs)=0p(kT_s) = 0 for every integer k≠0k \ne 0, if and only if its spectrum P(f)P(f) satisfies ∑nP(f−n/Ts)=Ts\sum_n P(f - n/T_s) = T_s for all ff.

The condition says that the copies of the pulse's spectrum, shifted by multiples of the symbol rate, add up to a constant. (It is the sampling theorem applied to the pulse: sampling pp at kTskT_s gives a single impulse exactly when the aliased spectrum is flat.) The narrowest pulse that satisfies it is the sinc, with a rectangular spectrum of width Rs/2R_s/2: the absolute minimum bandwidth, but with tails so long that a small timing error causes a lot of ISI. The raised-cosine pulses fix this with a gentle cosine roll-off in the spectrum, controlled by a roll-off factor α\alpha between 0 and 1. They occupy a baseband bandwidth of (1+α)Rs/2(1 + \alpha)R_s/2, so a passband signal at RsR_s symbols per second needs (1+α)Rs(1 + \alpha)R_s hertz. In practice the shaping is split equally between transmitter and receiver as two root-raised-cosine filters, which together give a raised cosine and make the receiver filter the matched filter.

The program sends 4000 random BPSK symbols with four pulse shapes, measures the eye opening (the worst-case sample at the symbol instants, as a fraction of the ideal 1; 1 is perfect and 0 means a wrong decision is possible without any noise), and computes the 99 % occupied bandwidth of each pulse's spectrum.

python
import numpy as np

rng = np.random.default_rng(7)
sps = 16                                          # samples per symbol
symbols = rng.choice([-1.0, 1.0], 4000)

def raised_cosine(alpha, span=8):
    """Raised-cosine pulse sampled at sps per symbol, truncated to +-span symbols, peak 1."""
    t = np.arange(-span * sps, span * sps + 1) / sps          # time in symbol periods
    with np.errstate(divide="ignore", invalid="ignore"):
        p = np.sinc(t) * np.cos(np.pi * alpha * t) / (1 - (2 * alpha * t) ** 2)
    p[np.abs(np.abs(2 * alpha * t) - 1) < 1e-9] = np.pi / 4 * np.sinc(1 / (2 * alpha))
    return p

def rc_lowpass(x, tau):                           # first-order RC filter, time constant in symbols
    a = np.exp(-1 / (tau * sps))
    y, acc = np.empty_like(x), 0.0
    for i, v in enumerate(x):
        acc = a * acc + (1 - a) * v
        y[i] = acc
    return y

def transmit(pulse):
    up = np.zeros(len(symbols) * sps)
    up[::sps] = symbols
    return np.convolve(up, pulse)

def eye(wave, first_peak, offset=0):
    """Smallest correct-sign sample at the symbol instants: 1 = wide open, 0 or less = closed."""
    at = first_peak + offset + sps * np.arange(100, len(symbols) - 100)
    return (wave[at] * symbols[100:len(symbols) - 100]).min()

def occupied_bandwidth(power, f_max=500.0, df=1e-3):
    """Frequency (in units of the symbol rate) below which 99 % of the power lies."""
    f = np.arange(0, f_max, df) + df / 2
    p = power(f)
    return f[np.searchsorted(np.cumsum(p) / p.sum(), 0.99)]

def rc_spectrum(alpha):
    def power(f):
        f1, f2 = (1 - alpha) / 2, (1 + alpha) / 2
        roll = 0.5 * (1 + np.cos(np.pi / alpha * (f - f1)))
        return np.where(f <= f1, 1.0, np.where(f <= f2, roll, 0.0)) ** 2
    return power

rect = np.ones(sps)
rc = raised_cosine(0.35)
rows = [
    ("rectangular pulses", eye(transmit(rect), sps // 2),
     lambda f: np.sinc(f) ** 2),
    ("rectangular, then RC low-pass", eye(rc_lowpass(transmit(rect), 0.5), sps - 1),
     lambda f: np.sinc(f) ** 2 / (1 + (2 * np.pi * 0.5 * f) ** 2)),
    ("raised cosine, alpha = 0.35", eye(transmit(rc), 8 * sps), rc_spectrum(0.35)),
    ("raised cosine, 1/4 symbol late", eye(transmit(rc), 8 * sps, offset=sps // 4), rc_spectrum(0.35)),
]
print(f"{'pulse':32}{'eye opening':>12}{'99 % bandwidth':>18}")
for name, opening, power in rows:
    print(f"{name:32}{opening:12.3f}{occupied_bandwidth(power):12.2f} x Rs")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Rectangular pulses have a perfect eye but spread 99 % of their power over almost ten times the symbol rate. Filtering them with a simple RC low-pass narrows the spectrum but closes the eye by 27 %: ISI. The raised cosine with α=0.35\alpha = 0.35 has both a perfect eye and a 99 % bandwidth of only half the symbol rate. But it relies on accurate timing: sampled a quarter of a symbol late, its eye shrinks to 0.26. That is why every receiver includes a timing-recovery loop, and why engineers look at eye diagrams, all the symbol periods of a signal overlaid on an oscilloscope, to judge a link at a glance.

ExplanationH

OFDM: many slow carriers instead of one fast one

Radio waves reach a receiver by many paths, bouncing off buildings, hills and walls. Indoors the echoes are spread over tens to hundreds of nanoseconds, outdoors over microseconds. A single carrier sending 20 million symbols per second has symbols 50 ns long, so an echo 1 µs late smears each symbol over twenty of its successors, and undoing that needs a long, power-hungry equaliser.

Orthogonal frequency-division multiplexing (OFDM) turns the problem around. Instead of one carrier at 20 Msymbol/s, use N=64N = 64 (or 1024, or 4096) subcarriers, each at 1/N1/N of the rate, so each symbol is long compared with the echoes. Space the subcarriers exactly 1/T1/T apart, where TT is the symbol duration, so that they are orthogonal: their spectra overlap, but over one symbol each subcarrier's sinusoid integrates to zero against every other. Then the transmitter's job, putting a constellation point XkX_k on each subcarrier kk, is exactly an inverse DFT,

xn=1N∑k=0N−1Xk ej2πkn/N,x_n = \frac{1}{N}\sum_{k=0}^{N-1} X_k\,e^{j2\pi kn/N},

computed with an IFFT, and the receiver's job is an FFT.

One more trick makes it work over a multipath channel. Before transmitting each block of NN samples, copy its last LL samples to the front: the cyclic prefix.

Theorem— The cyclic prefix diagonalises the channel

Let the channel be a filter h0,…,hLh_0, \ldots, h_{L} (echoes up to LL samples late) and let each OFDM symbol carry a cyclic prefix of at least LL samples. After the receiver discards the prefix and takes the NN-point DFT, subcarrier kk receives Yk=HkXkY_k = H_kX_k (plus noise), where HkH_k is the DFT of the channel at subcarrier kk.

Proof

The channel performs a linear convolution. Because the prefix repeats the end of the block, the NN samples the receiver keeps are exactly what a circular convolution of the block with hh would give: each echo that reaches back past the start of the block finds a copy of the block's own end there, rather than the previous symbol. And the DFT turns circular convolution into multiplication, Yk=HkXkY_k = H_kX_k (the convolution theorem of Fourier analysis, in its discrete form).

∎

So equalisation, the expensive part of a single-carrier receiver, becomes one complex division per subcarrier. The program sends 50 OFDM symbols of 64 QPSK subcarriers through a channel with echoes up to 9 samples late, at a signal-to-noise ratio of 30 dB, and decodes them with cyclic prefixes of 16, 4 and 0 samples.

CPOFDM symbol 1 (N samples)CPOFDM symbol 2copy of the last samplesCPecho, delayedFFT window: only symbol 1 and its own prefixdirectecho
Why the cyclic prefix works. Top: two OFDM symbols, each preceded by a cyclic prefix (CP) that copies its last samples. Bottom: an echo of the same signal, arriving late. As long as the delay is shorter than the prefix, the receiver's FFT window for symbol 1 contains only symbol 1 and its own prefix, in both the direct path and the echo, so no symbol leaks into the next.
python
import numpy as np

rng = np.random.default_rng(11)
N, CP, n_sym = 64, 16, 50                        # subcarriers, cyclic-prefix length, OFDM symbols
qpsk = np.array([1 + 1j, -1 + 1j, -1 - 1j, 1 - 1j]) / np.sqrt(2)
data = qpsk[rng.integers(0, 4, (n_sym, N))]      # one QPSK symbol per subcarrier per OFDM symbol

h = np.array([0.8, 0, 0, 0.45j, 0, 0.3, 0, 0, 0, -0.15])   # multipath: echoes up to 9 samples late
H = np.fft.fft(h, N)                                       # the channel's gain on each subcarrier

def run(cp):
    tx = np.fft.ifft(data, axis=1)                           # each row: one OFDM symbol in time
    tx = np.hstack([tx[:, N - cp:], tx]).ravel()             # copy the last cp samples to the front
    rx = np.convolve(tx, h)[: len(tx)]
    noise_power = np.mean(np.abs(rx) ** 2) / 10 ** (30 / 10)  # 30 dB signal-to-noise ratio
    rx = rx + np.sqrt(noise_power / 2) * (rng.normal(size=rx.shape) + 1j * rng.normal(size=rx.shape))
    rx = rx.reshape(n_sym, N + cp)[:, cp:]                   # drop the prefix
    est = np.fft.fft(rx, axis=1) / H                         # FFT, then one division per subcarrier
    decided = qpsk[np.argmin(np.abs(est[..., None] - qpsk), axis=-1)]
    evm = np.sqrt(np.mean(np.abs(est - data) ** 2))
    return np.sum(decided != data), evm

print(f"channel gains |H_k| range from {np.abs(H).min():.2f} to {np.abs(H).max():.2f} across subcarriers")
for cp in (16, 4, 0):
    errors, evm = run(cp)
    print(f"cyclic prefix {cp:2d} samples: {errors:4d} symbol errors out of {n_sym * N}, "
          f"EVM {100 * evm:5.1f} %")
print(f"overhead of a 16-sample prefix: {16 / (N + 16):.0%} of the air time")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

With a 16-sample prefix, longer than the channel's 9-sample spread, all 3200 symbols arrive correctly, using nothing but an FFT and one division per subcarrier. With a 4-sample prefix, the end of each echo leaks into the next symbol and errors appear; with none, the constellation is badly smeared. The prefix costs 20 % of the air time here; real systems size it to the expected delay spread, typically 7 % (LTE's normal prefix) to 25 %.

OFDM has one notable cost: adding many independent subcarriers gives a signal that looks like Gaussian noise, with occasional peaks far above its average power (a high peak-to-average power ratio). Power amplifiers must be backed off to avoid clipping those peaks, which wastes energy. That is why LTE and 5G phones may transmit a "DFT-spread" variant of OFDM on the uplink, with lower peaks, while base stations, with more power to spare, use plain OFDM.

ExplanationH

The professional view

  • Who uses what. Wi-Fi has used OFDM since 802.11a (1999), and Wi-Fi 7 uses it with constellations from BPSK to 4096-QAM (IEEE 802.11); LTE and 5G NR use OFDM with flexible subcarrier spacing (3GPP); digital television (DVB-T2, ISDB-T, ATSC 3.0), digital radio (DAB) and DSL broadband use it too. Constant-envelope schemes survive where power efficiency rules: Bluetooth Low Energy, many satellite links, and FM broadcasting, which is still on the air in most countries.
  • Adaptive modulation and coding. Modern links measure the channel continuously and choose the modulation and code rate for each transmission, sometimes for each group of subcarriers: 1024-QAM near the access point, QPSK at the edge of coverage. The table of choices is the "MCS index" in Wi-Fi and cellular specifications.
  • Measurement. Transmitters are tested for error vector magnitude (EVM), the RMS distance between received and ideal constellation points, against limits in the standards (for dense constellations, a few per cent or less), and for spectral masks that bound the power leaking into neighbouring channels. Vector signal analysers do this, and open-source tools such as GNU Radio can too.
History & global context

A short history

Speech was first sent by amplitude modulation in the first decade of the twentieth century, by Reginald Fessenden among others, and AM broadcasting spread worldwide in the 1920s. Edwin Armstrong patented wideband FM in 1933 to defeat static, and FM broadcasting followed. Harry Nyquist's 1928 paper set the limit on how fast pulses can be sent through a channel without interfering. In 1966 Robert Chang at Bell Labs described orthogonal multicarrier transmission; in 1971 Stephen Weinstein and Paul Ebert showed that the DFT could generate it, and the cyclic prefix was proposed by Abraham Peled and Antonio Ruiz in 1980. OFDM waited until integrated circuits could run FFTs cheaply, and then, in the 1990s and 2000s, took over digital broadcasting, DSL, Wi-Fi and finally mobile networks.

Common misconceptionsH

Common misconceptions

Misconception

"FM is immune to noise." FM is immune to amplitude disturbances and, above its threshold, trades bandwidth for a large improvement in output SNR. Below the threshold (a weak, distant station) it degrades abruptly, more abruptly than AM.

Misconception

"A signal at 100 Mbit/s needs 100 MHz of bandwidth." Bandwidth is set by the symbol rate and the pulse shape: (1+α)Rs(1 + \alpha)R_s in passband. With 1024-QAM (10 bits per symbol) and α=0.25\alpha = 0.25, 100 Mbit/s needs 10 Msymbol/s and 12.5 MHz, before coding overhead.

Misconception

"OFDM subcarriers are separated by guard bands so they do not overlap." Their spectra overlap heavily; each subcarrier's sinc-shaped spectrum has its peak exactly at the other subcarriers' zeros. Orthogonality, not separation, keeps them apart, which is why OFDM is so spectrally efficient, and why it is sensitive to frequency offsets that break the orthogonality.

Misconception

"Denser constellations are always better." At a given Eb/N0E_b/N_0, 256-QAM makes far more errors than QPSK. Dense constellations pay off only when the SNR is high, which is why links adapt and why the fastest Wi-Fi rates are available only close to the access point.

Exercises

Exercises

1. Modulation

Warm-upHuman

A broadcast FM station uses a peak deviation of 75 kHz and audio up to 15 kHz. Estimate its bandwidth with Carson's rule, in kHz.

2. Modulation

Warm-upHuman

A microwave link sends 5 million symbols per second using 256-QAM and an error-correcting code of rate 3/4 (three information bits for every four bits sent). What is its information rate, in Mbit/s?

3. Modulation

CoreHuman

An AM transmitter is modulated by a single tone at the maximum index μ=1\mu = 1. What percentage of the transmitted power is in the two sidebands (the part that carries the message)? Give the nearest whole number.

4. Modulation

CoreHuman

A satellite modem sends 20 Msymbol/s with root-raised-cosine filtering of roll-off α = 0.25. What bandwidth does the modulated (passband) signal occupy, in MHz?

5. Modulation

CoreHuman

Which statements about OFDM are true? Select all that apply.

Choose all that apply

6. Modulation

CoreComputational

Write two functions:

  • bpsk_ber_theory(ebn0_db), returning Q(2Eb/N0)=12erfc⁡(Eb/N0)Q(\sqrt{2E_b/N_0}) = \tfrac12\operatorname{erfc}(\sqrt{E_b/N_0}) for Eb/N0E_b/N_0 given in dB;
  • bpsk_ber_sim(ebn0_db, n_bits, seed=0), which draws n_bits random bits with np.random.default_rng(seed), maps 0 to +1 and 1 to −1 (so Eb=1E_b = 1), adds Gaussian noise of variance N0/2N_0/2, decides by the sign, and returns the fraction of wrong bits.

The tests compare your simulation with your theory at 0, 3 and 6 dB.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

7. Modulation

StretchComputational

Build the two halves of an OFDM link:

  • ofdm_tx(X, cp): X has one row of NN constellation points per OFDM symbol. Take each row's inverse FFT, put a copy of its last cp samples in front, and return all symbols concatenated into one 1-D array.
  • ofdm_rx(y, N, cp, h): split the received stream into blocks of N+N + cp samples, drop each prefix, take the FFT of each block and divide by the channel's frequency response H=H = np.fft.fft(h, N). Return an array of the same shape as X.

The tests pass QPSK symbols through a channel with echoes up to 5 samples late and an 8-sample prefix, with no noise, and expect exact recovery.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Further reading and resources

  • Certain Topics in Telegraph Transmission Theory · Harry Nyquist · 1928Transactions of the AIEE, vol. 47. Where the condition for transmitting pulses without inter-symbol interference comes from.
  • Synthesis of Band-Limited Orthogonal Signals for Multichannel Data Transmission · Robert W. Chang · 1966Bell System Technical Journal, vol. 45. The founding paper of orthogonal frequency-division multiplexing.
  • Data Transmission by Frequency-Division Multiplexing Using the Discrete Fourier Transform · S. B. Weinstein and P. M. Ebert · 1971IEEE Transactions on Communication Technology. The idea of generating OFDM with the DFT, and so with the FFT.
  • IEEE 802.11 Wireless LAN Working GroupThe committee that writes the Wi-Fi standards, which have used OFDM since 802.11a.
  • 3GPPThe partnership that writes the LTE and 5G NR specifications.
  • GNU Radio tutorialsHands-on modulation and demodulation in software, with simulated or real radio hardware.