D13 · Lesson 7 · Software radio
Assembling the software radio from front-end gain to decoded text, planning the analog gain so the ADC is neither overloaded nor buried in its own noise, then tuning, filtering, demodulating FM and decoding an audio-tone packet with a CRC, all in code
The last step joins the pieces: the analog front end sets the level at the ADC, and the code does the rest. The station you want carries a packet the way amateur radio's APRS does: as audio tones, D12's 1200 and 2200 Hz FSK, sent over an ordinary narrowband FM transmitter. Your receiver has to tune to it in a recording that also holds two other stations, one much stronger, demodulate the FM to get the audio, and decode the packet from the audio, finding it at an unknown time and checking its CRC.
- The front end's level plan: an antenna signal passes an LNA, a mixer and an IF amplifier on its way to a 12-bit ADC whose full scale is 0 dBm.
- The ADC's own noise sits 6.02 × 12 + 1.76 = 74 dB below full scale across 48 kHz; in a 4.8 kHz channel, filtering lowers it a further 10 dB. The readouts show the headroom left before clipping and how far the signal sits above the ADC's noise.
- Too little gain buries a weak station in ADC noise; too much lets a strong neighbor clip the ADC, which wrecks every station at once. Find the gain that suits signals from −110 to −40 dBm.
Predict
A 12-bit ADC digitizes 48 kHz of spectrum, and the receiver keeps a 4.8 kHz channel. How far below full scale is the ADC's quantization noise within that channel?
Quantization noise is 6.02 × 12 + 1.76 = 74 dB below a full-scale sine, spread evenly over 0 to 48 kHz. The channel keeps a tenth of that band, so a tenth of the noise: 10 dB less, 84 dB below full scale. This processing gain is why software radios can use modest ADCs and still hear weak stations.
Name it
Gain planning
The analog gain before the ADC should put the strongest expected signal a few dB below full scale and the weakest wanted one comfortably above the ADC's noise in the channel:
The dynamic range between clipping and that floor is what lets a weak station be decoded next to a strong one. Real receivers add automatic gain control to slide the window with conditions.
The receiver chain
- Channelize: tune the station to 0 Hz, low-pass filter to ±4.8 kHz and decimate from 96 to 9.6 kHz (lesson 5).
- Demodulate: the discriminator turns the FM into audio (lesson 6).
- Decode: the audio carries 1200 baud FSK at 8 samples per bit, so D12's correlators recover the bits; the receiver tries each of 8 sampling offsets, searches for sync words one after another, reads each candidate frame and keeps the first whose CRC checks.
Why search for more than one sync word
Before the packet, the channel carries noise, and a random stretch of bits matches the sync word within one error about once every 3900 bits (D12). A receiver that gave up after the first match would sometimes miss a perfectly good packet behind a false one. Moving on to the next candidate costs little, and the CRC rejects the false ones.
Worked example
With 20 dB of LNA gain, what's the window of antenna levels the front end can handle?
Show the solution
- Gain to the ADC. The other stages add so with the LNA's 20 dB the ADC sees S + 31 dBm.
- The window. Clipping starts at S = −31 dBm, and the ADC's channel noise (−84 dBm at the ADC) is reached at S = −115 dBm:
- A weak station. A −110 dBm station then sits only 5 dB above the ADC noise, so the gain should be raised until the analog front end's own noise sits above the ADC's and sets the floor.
- The cost of more gain. More LNA gain helps the weak station but brings clipping down to −41 dBm.
Answer antenna levels from −115 dBm to −31 dBm, an 84 dB window.
Worked example
How long does the lab's longest message, "CQ from the software radio" (26 characters), take on the air?
Show the solution
- Frame length. D12's frame is
- Airtime at 1200 baud.
- The lead-in. The lab's recordings start up to 0.094 s (9000 samples at 96 kHz) earlier with unmodulated carrier, where the receiver's bits are just noise and the occasional false sync match.
Answer 0.24 s, after up to 0.094 s of unmodulated carrier in the lab's recordings.
Check
Build the whole receiver: tune the station, demodulate its FM and decode the packet from its audio.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
What SNR does an ideal 10-bit ADC give for a full-scale sine across its whole band?
Check
A receiver samples at 240 kHz and keeps a 4.8 kHz-wide channel. How much does filtering lower the ADC's noise in the channel?
Check
In the level plan above, the LNA has 20 dB of gain and the ADC clips at 0 dBm. At what antenna level does clipping begin?
Check
An AFSK packet at 1200 baud (Bell 202: 1200 and 2200 Hz tones) is sampled at 24 kHz and has 100 bits.
(a)
How many samples cover each bit?
(b)
How long does the packet last?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
How many cycles of a 2100 Hz tone fit in one 1200-baud bit?
Explain why
Why does a software radio filter and decimate before it demodulates?
The raw recording holds many stations and a wide band of noise at a high sample rate. Filtering to the wanted channel removes the other stations, which would otherwise corrupt the discriminator's phase measurement, and removes most of the noise, since noise is spread across the whole band and the channel keeps only a slice of it. Decimating afterward lowers the sample rate to one just wide enough for the channel, so every later step, demodulation and decoding, handles a tenth or less of the samples. Demodulating first would mix all the stations and the wideband noise into the audio, where they could no longer be separated.
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.