D13 · Lesson 5 · Software radio
How a software radio digitizes a wide slice of spectrum as complex I/Q samples, why complex samples tell positive from negative frequencies, tuning a station by multiplying with a complex exponential, a windowed-sinc channel filter, and decimating to a lower rate without letting the neighbors fold in
A software-defined radio does almost everything in code. Its hardware is a tuner that shifts a band of spectrum down near zero and an ADC pair that samples it as I and Q, the real and imaginary parts of a complex signal. Everything after that, choosing a station, filtering out the neighbors, demodulating and decoding, is arithmetic on those samples. This project builds a receiver that picks one narrowband FM station out of a 96 kHz-wide recording and decodes a data packet from it.
- Three FM stations in a slice of spectrum, 15 kHz apart, the one at 45 kHz four times as strong as the one at 30 kHz you want. The dashed markers show a ±4.8 kHz channel around the tuning frequency .
- Tune to each station. The channel filter will pass what's between the markers and throw away the rest.
- Notice how much energy sits just outside the channel: the filter's skirts have to fall fast, or a strong neighbor leaks in.
Predict
The recording is sampled at 96 kHz. You keep every 10th sample to get 9.6 kHz, without filtering first. Where does a strong station 20 kHz above the wanted one end up?
At 9.6 kHz, frequencies are only distinct modulo 9.6 kHz, so 20 kHz lands at 20 − 2 × 9.6 = 0.8 kHz, on top of the wanted signal and four times stronger. Decimation must always follow a low-pass filter that removes everything the new rate can't represent.
Name it
Complex baseband
With I and Q samples, , a component at frequency f is , and f can be negative: a 96 kHz complex stream covers −48 to +48 kHz with no mirror images. A real ADC alone would confuse f with −f.
Tuning
Multiplying by shifts every frequency down by , so the wanted station moves to 0 Hz.
The channel filter
A windowed-sinc low-pass with N taps, cutoff and a Hamming window:
normalized to unit gain at 0 Hz. Its response is 6 dB down at , the transition takes about , and the stopband sits about 53 dB down for the Hamming window (S7). With 129 taps at 96 kHz the transition is about 2.5 kHz wide.
Decimation
After filtering, keeping every D-th sample gives a rate without aliasing, since nothing remains above . Each factor of 10 also cuts the computation for every later stage by 10, and the filtering lowers the noise in the channel: the noise that was spread over 96 kHz is now confined to 9.6 kHz.
Worked example
Design the channel filter for a ±4.8 kHz channel at 96 kHz with a Hamming window. How many taps for a 2.5 kHz transition, and how does it do?
Show the solution
- Estimate the length.
- Pick an odd length with some margin. The estimate is only a guide, so go one odd length past it to 129 taps. An odd length keeps the delay a whole number of samples (64).
- Measured response. The lab's filter measures with no sidelobe above −55 dB beyond 7 kHz or above −63 dB beyond 20 kHz.
- A strong neighbor. A neighbor four times (12 dB) stronger 20 kHz away comes through at least below the wanted signal, under 0.3%.
Answer 129 taps, which pass 4 kHz at −0.6 dB and keep a neighbor 20 kHz away at least 51 dB below the wanted signal.
Worked example
A station sits at −25 kHz in the recording, and you tune to +10 kHz. Where does it land, and what happens after the filter and decimation by 10?
Show the solution
- Tune. Tuning to +10 kHz shifts the station to far into the stopband, where it's more than 80 dB down.
- Decimate to 9.6 kHz. What's left of it would alias to
- Is it a problem? At that level it's harmless.
Answer it lands at −35 kHz, more than 80 dB down, and after decimation its remains alias to 3.4 kHz, too weak to matter.
Check
Tune a station to 0 Hz, filter its channel and decimate to 9.6 kHz.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A signal 25 kHz from the tuned frequency survives into a decimated stream at 9.6 kHz. Where does it alias to, in absolute frequency from 0?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
About how many taps does a Hamming-windowed sinc filter need for a 1000 Hz transition at 96000 samples per second?
Check
A 240 kHz stream is filtered and decimated by 4. What's the new sample rate?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
A software radio samples complex I/Q at 2.4 MS/s, tuned to 100.9 MHz.
(a)
At what baseband frequency does a station at 100.3 MHz appear? (Negative if below the tuning.)
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
(b)
How much bandwidth do the complex samples cover in total?
Check
A software radio decimates 2048 kS/s down to 48 kS/s for one channel. What decimation factor is that?
Explain why
Why must a receiver filter before it decimates?
Keeping only every D-th sample lowers the sample rate, and at the new rate frequencies are only distinguishable up to half of it; anything higher folds back and lands on top of lower frequencies, where it can't be separated any more. In a recording full of other stations, those stations would fold right into the wanted channel. Low-pass filtering first removes everything above half the new rate while the higher rate can still tell them apart, so the decimated signal contains only the wanted channel and the noise within it.
Practice
Keep practicing
7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.