S8 · Lesson 52 · Modem lab
Building a complete QPSK modem with root-raised-cosine pulse shaping, a matched-filter receiver and an AWGN channel calibrated in Eb/N0, and measuring its bit error rate against theory
The first half of this course derived the pieces of a digital link one formula at a time: pulse shaping, matched filtering, the AWGN channel, error probability. In this lab you'll assemble them into a working QPSK modem and check it the way a communications engineer would, by sending tens of thousands of random bits through simulated noise and counting errors. If every scale factor is right, the measured bit error rate lands on ; if one is wrong, the curve shifts by decibels and the test tells you.
Predict
The transmitter and receiver each use a root-raised-cosine filter. Why does the cascade cause no intersymbol interference at the sampling instants?
An RRC pulse alone isn't Nyquist: its own samples at other symbol instants aren't zero. Convolved with itself (the matched filter), its spectrum squares into a raised cosine, which satisfies Nyquist's criterion. Splitting the shaping this way gets zero ISI and the optimal matched filter at the same time.
Name it
The root raised cosine
With t in symbol periods and rolloff β:
with the limits and . Sampled at sps samples per symbol over ±span symbols and scaled to unit energy.
The link
- Modulator: bits in pairs → (Gray-coded, unit energy), one symbol every sps samples, filtered by h.
- Channel: complex white Gaussian noise. With unit-energy symbols and pulses, the energy per symbol is 1 in sample units, so is the complex noise variance per sample, in each of the real and imaginary parts.
- Demodulator: filter by h again, sample every sps samples starting at the combined delay, len(h) − 1, and decide each bit by a sign.
Expected: , 2.4 × 10⁻³ at 6 dB and 1.25 × 10⁻² at 4 dB.
Worked example
How many bits must be simulated to measure a 10⁻³ error rate to about ±20%?
Show the solution
- Spread of an error count. Error counts are roughly Poisson, so the relative spread is
- Errors needed. ±20% needs about 25 errors:
- Bits needed. At 10⁻³ that's about
- The lab's runs. Its 40,000-bit runs at 4 and 6 dB collect roughly 500 and 100 errors, enough to land within the tests' 20 to 25% windows.
Answer about 25,000 bits.
Worked example
At Eb/N0 = 3 dB, what noise variance should the channel add?
Show the solution
- Linear Eb/N0.
- Per symbol.
- Noise density. per complex sample.
- Per component. That's the standard deviation in each of the real and imaginary parts.
Answer = 0.2506 per complex sample: a standard deviation of 0.354 in each of the real and imaginary parts.
Check
Step 1. Write rrc(beta, span, sps): unit-energy root-raised-cosine taps.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 2. Write qpsk_mod and qpsk_demod: Gray-coded QPSK with pulse shaping and a matched-filter receiver.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 3. Write awgn(x, ebn0_db, sps, rng): complex noise scaled to a given Eb/N0.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why does the modem sample at delay len(h) − 1?
Each filter in the chain is a symmetric pulse with its peak at its center tap, (len(h) − 1)/2 samples from its start. The transmit filter delays a symbol's peak by that much and the receive filter by the same again, so the peak of the combined raised-cosine pulse appears len(h) − 1 samples after the symbol was placed. Sampling there catches each symbol at its peak, where the other symbols' pulses all pass through zero, so the decision sees only its own symbol plus noise. Sampling even one sample early or late would catch the neighbors' tails and add intersymbol interference.
Practice
Keep practicing
3 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.