Invisible airwaves crackle with life
Bright antenna bristle with the energy
Emotional feedback on a timeless wavelength
Bearing a gift beyond price, almost free
From The Spirit Of Radio, Rush. (Track 1 of Permanent Waves (1980))
[Lyrics: Neil Peart. © Anthem Entertainment Group. Core Music Publishing.]
This is pretty much where physics started for me…
With help and advice from my uncle Benny, and with a “recipe” from that wonderful Ladybird making a Transistor Radio book shown in the photo, as a science-and-sci-fi fixated ten year old back in 1978 I built a crystal radio from a diode, a variable capacitor, a coil wound around a ferrite rod, and a long length of wire (which was slung up in the attic of the family house, “threaded” out through a vent on the side of our house, and tied to a tree on the other side of the garden.)
Unfortunately, that’s not the original book — nor the original crystal radio — shown above. But it is a second-hand copy of roughly the same vintage (published 1972) as that we used. Strolling through Cambridge (MA, not the one ‘down south’) a few months ago, I spotted what I thought was that Ladybird book in a bookshop window. It turns out that it was just a postcard of the cover — grrr — but that was still enough to get me eagerly hunting online for a second-hand copy of making a Transistor Radio that I could order.
The wave of nostalgia that hit me when the book arrived a week or so later was, to say the least, palpable. Brady Haran had suggested many moons ago that a Sixty Symbols video where I built a crystal radio from the Ladybird “blueprint” might make for a neat project, and he was (as ever) dead right. We had a lot of fun making this…
I casually state in the video that the diode rectifies the electrical signal, only allowing current to flow one way. That’s of course true, and it accurately describes the role of the diode in the crystal radio. But just why is it that rectification allows us to recover audio information, with frequencies in the sub-20 kHz range, from a radio wave whose frequency is ~ 1 MHz? Like so many problems in physics (and elsewhere), the answer is beautifully simple if we consider the Fourier domain. However, to my mind there’s a great deal of unnecessary complicating detail in textbooks and online resources on the subject of AM radio — and modulation in general — that I feel needlessly obscures the core, and ever-so-elegant, principle.
Sixty Symbols videos — certainly those to which I contribute — are not meant to be tutorials, lectures, or lessons. They’re there to pique interest in a topic. I want viewers to come away from a video thinking that they’d like to find out more. (And if they’re a little — or a lot — perplexed or bamboozled by my explanations at times, good.) Sixty Symbols is the start, not the end, of the learning process.
But sometimes I really want to explain the physics in a more in-depth, tutorial style. And that is very definitely the case for the crystal radio. Not only was that humble receiver such an important factor in my getting hooked on physics but it’s an amazing demonstration of the power and elegance of a Fourier perspective on signal processing. So I spent a few hours over the weekend writing some Mathematica code  to simulate the process of amplitude modulation and demodulation that underpins just how the crystal radio works. I hope this will help demystify (de)modulation for those who, like me, struggled to get their head round the concept as a student.
Let’s start with the simplest possible wave — a pure sinusoidal tone. We’ll choose a 1 kHz frequency. It looks like this…
…and it sounds like this:
Yawn. An irritating, characterless whistle.
But this boring, characterless tone can teach us a lot.
A much more “compact” way of looking at any wave is to plot its frequency (aka Fourier) spectrum. In the case of that 1 kHz sine wave, it’s very straight-forward to interpret…
There is no new information in the figures above — they’re simply alternative representations of exactly the same waveform data. Instead of plotting how the wave varies in time, we are representing it in a much more compact, and therefore much more easily interpretable, form. The main figure is what’s known as the power spectrum — it shows the power associated with different frequencies.  Don’t worry about the numbers on the y-axis. (Not that you can in any case — I’ve not shown them so you won’t get distracted.) Focus instead on the x-axis. We have a peak at 1000 Hz. And nothing else. A single, solitary peak, the height of which is proportional to the “volume”  of the note.
The inset shows what’s known as a spectrogram. This tells us how the frequency spectrum varies in time, with the brightness on the plot now representing the “volume” of the waveform. In this case, the note is a constant 1 kHz frequency, so we have a simple flat line (at 1 kHz on the y-axis) across the 1 second duration of the note.
“Never mind the aggravation. Modulation. Gimme another key.”
To transmit this incredibly boring signal via conventional AM radio, we’d first need to imprint it on a carrier wave having a frequency in the 535 – 1605 kHz range. I didn’t use frequencies quite that high in the Mathematica simulation because that would be overkill (and would dramatically slow down processing speed due to the sheer volume of data; a 1 MHz signal, for example, would require a minimum of a 2 MHz digital sample rate for accurate representation, as Nyquist and Shannon (and others before them) showed us many moons ago.) But we can see exactly the same (mathematical) physics in action and understand AM modulation/ demodulation using much lower frequencies.
So let’s just pluck a carrier frequency out of the air. We’ll opt for 21.12 kHz, for no particular reason. We’re going to imprint our audio information — that single sine wave — onto our carrier wave; more technically, we’re going to modulate the carrier wave with the audio information. In this case, “modulate” just means multiply:
fmod(t)= (1 + m fsignal (t)) fcarrier(t)
where fmod(t) is our modulated wave, fsignal (t) is our signal (i.e. that boring sine whistle), and fcarrier(t) is our carrier wave (which is another sine wave but at a much higher frequency (i.e. 21.12 kHz)). That m variable in the equation above is the modulation depth — it controls the extent to which we imprint our signal on the carrier. (I’ve set m to a value of 1.0 for this example but tweaked it a little for the demos further down this post.)
Here’s what a couple of milliseconds of our carrier wave looks like…
(You really only need to see a couple of milliseconds — it just repeats this cycle over and over.)
And here’s what our modulated wave, fmod(t), looks like over the same period of time:
The much more slowly varying 1 kHz frequency modulates the carrier, causing its amplitude to vary up and down.
Now here’s the especially neat trick that becomes so much easier to understand in Fourier space. What does the frequency spectrum of the modulated waveform look like? You might initially think that it contains two frequencies — the 1 kHz signal and the 21.12 kHz carrier.
Here’s what it looks like:
There are three frequency components! And there’s no sign at all of a peak at 1 kHz in the spectrum. Our carrier frequency is certainly still there, standing tall and proud at 21.12 kHz. But it’s accompanied by two neighbours, or sidebands as they’re more commonly known. So where has our audio signal gone?
Rest easy. All the audio information is still there. It’s in those sidebands. The lower frequency sideband is at 20.12 kHz (i.e. 21.12 – 1.00 kHz), while its “sibling” is at 22.12 kHz (i.e. 21.12 + 1.00 kHz). The origin of the sidebands can be understand on the basis of secondary/high school trigonometry: multiply two sine functions, sin(A) and sin(B) and we end up with two cosines, one with a frequency of A-B, the other with a frequency of A+B. [Don’t worry about the sine-cosine transformation. A sine is just a phase-shifted version of a cosine. They both sinusoids. See also Footnote 5]. Or, in slightly more mathematical terms:
sin(A) sin(B)=½ [cos(A-B)-cos(A+B)]
The audio information is embedded in the sidebands. We’ve just moved the 1 kHz audio information to a higher frequency (above the audible threshold of 20 kHz). A real world AM transmitter would transfer the audio it’s broadcasting (be it music, comedy, news, the abomination that is Country & Western, or reports of the latest Trump family gaffe) to sidebands of a carrier frequency over one hundred times higher than the 21.12 kHz used in the simulation. But that’s just a matter of scale. The fundamental maths and physics are exactly the same. 
Rectifying the situation.
So the audio information is still there. It’s just been transposed to a different frequency. How do we recover it?
Remarkably, in a real radio we can recover the audio, i.e. demodulate the signal, using a very basic electronic component: a diode. That’s what I used as a ten year old (because it’s what the Ladybird book recommended). But as that Sixty Symbols video up there shows, we can use an even more humble “component” — a ‘rusty’ penny! — to recover our audio. The metal-semiconductor junction — a Schottky barrier — formed by the tip of the wire touching on the oxidised surface of the penny is enough to allow electrons to flow one way but not the other.
And that rectifies the modulated waveform…
The signal is now only positive. (It’s very easy to simulate the action of a diode in code simply by removing all the negative parts of the waveform. )
Now usually at this point in explanations of AM radio and modulation/demodulation, there’s a long discussion about the role of low pass filtering, and RC time constants and the like on the signal. That is, of course, important in the context of filtering out frequencies we don’t want — and I’ve judiciously filtered out frequencies above 20 kHz in the demodulated examples in this post — but we don’t need all that to understand how the diode demodulates the audio information from the radio signal. We just need the wisdom of Fourier again. Here’s what the power spectrum of that rectified signal looks like:
And if you’d prefer to see the spectrogram, here it is:
The most important thing to realise here is that simply by rectifying the radio signal we’ve recovered our original audio signal! There it is, back at 1 kHz in both the power spectrum and the spectrogram. (There’s also a spike at 0 Hz and new components at, and around, twice and four times the carrier frequency.  But we can filter those out.) What is key is that the rectification process (i.e. the demodulation) has recovered our original signal from the modulated waveform.
Here’s what our demodulated waveform sounds like…
“…and echoes with the sounds”
Radio would be exceptionally boring if all that was broadcast were single sine waves. (Although it’s got to be said that BBC R4 around about 7:00 pm any weekday evening is even less interesting than that monotone whistle.) So let’s take a slightly more exciting audio sample…
This has a rather more complicated frequency spectrum, as one might imagine…
But if the modulation-demodulation process works for one frequency, it will work for all frequencies. Here’s that audio signal modulating a 42 kHz carrier wave…
And this is its spectrum:
It might not look like it at first glance but exactly the same transposition of the audio spectrum as we observed for that solitary sine wave has occurred. The audio spectrum has been shifted to upper and lower sidebands around the carrier frequency of 42 kHz.
Here’s what that modulated waveform sounds like:
No, there’s no error. If you didn’t hear anything when you clicked the “Play” button, that’s good. All of the frequency spectrum is outside the audible range.
Now we demodulate…
…and instead of the void in the 0 – 20 kHz frequency range that we had for the modulated spectrum, we’ve recovered the audio spectrum.
This is the demodulated signal:
Turn Up The Radio
So that’s the modulation-demodulation process captured in code. Now let’s add in a few more “radio stations” across our frequency spectrum…
You might be able to guess just how many stations there are.
The four sharp lines running horizontally across the spectrum above arise from the four different carrier frequencies I’ve chosen: 42 kHz, 55 kHz, 65 kHz, and 75 kHz. Now, ideally, I’d separate those carrier frequencies from each other by at least 20 kHz, to ensure no overlap when it comes to the ~ 20 kHz audio bandwidth, but I had to draw a compromise between processing time, avoiding artefacts due to aliasing , modulation/demodulation quality, and “fidelity” of sound reproduction. It turns out that the ~ 10 kHz separation of the “radio station” carrier frequencies is more than good enough to demonstrate the remaining principle we need to cover in order to understand how an AM radio works : tuning.
If we don’t have a mechanism for selecting a particular carrier frequency, all of the audio signal from each of the stations will overlap when we demodulate and all we’ll hear will be a chorus — or, more accurately, a cacophony — of sounds. In the crystal radio we use a tuned circuit, formed by a capacitor and inductor, to select different frequencies. As I describe in that Sixty Symbols video above (and the accompanying “extras” clip), the capacitor-inductor circuit has a particular resonance frequency, f0 , defined by a very simple equation:
f0 = 1/(2𝜋(√LC))
So, by changing the value of the capacitance, we can tune the resonant frequency of the circuit and thus select different parts of the spectrum. For example, let’s say we select a resonant frequency of 42 kHz. Our tuned circuit would select a band of frequencies centred on that 42 kHz resonance. (The width of that band depends, in turn, on something called the quality factor (Q-factor) of the resonance.) Something like this:
In the land of Mathematica we can use the simple BandpassFilter function to mimic the action of the LC circuit in the crystal radio. This video sketches out what happens when we vary the value of the centre of the bandpass filter:
Now we have a mechanism for selecting one radio station from another! If the stations are a little too close together in frequency (and/or our bandpass filter is not selective enough) then we can sometimes hear two overlapping signals from different stations.
And at this point we have all the elements in place to modulate, demodulate, tune in, and tune out. I’ll leave you with the video below, which shows the Mathematica radio simulation being put through its paces as the frequency is tuned across the various stations. As Autograph — those purveyors of quality 80s hair metal — put it so aptly, things go better with rock…
Image of AM/FM tuning dial from http://nicelittlestatic.com/tag/radiotimekeeping/
 This was my first foray into Mathematica. I’ve got to say a big thank you to Noah (Hardwicke) for his invaluable advice and expertise in all things Mathematica. I’m also immensely grateful to my colleague Paul Glover for a couple of very helpful conversations on modulation and demodulation (and the loan of Paul’s treasured Introduction To Communication Systems (FG Stremler).)
 For those who’d like a little more technical detail, the power spectrum is the modulus squared of the Fourier transform of the signal. (The Fourier transform is complex-valued — it has real and imaginary parts; the modulus squared is real-valued.) By plotting this, we’re throwing away all phase information. For example, the power spectrum of a 1 kHz sine wave is identical to the power spectrum of a 1 kHz cosine wave. Phase is a whole other can of worms in Fourier space that we can fortunately avoid when it comes to understanding amplitude modulation and demodulation.
I’m also only plotting a single-sided spectrum. No negative frequencies. For now.
 Very, very loosely speaking. Settle down, Fourier enthusiasts and sound engineers.
 Lyric from NOFX’s “Thank God, It’s Monday” .
 See  above. The power spectrum doesn’t distinguish between sines and cosines (or any other phase difference for that matter).
 An even more elegant way of thinking about the modulation process, for those of you with some background in Fourier analysis, is as follows. A multiplication in the time domain is the same as a convolution in Fourier space (and vice versa). I’ve not included negative frequencies in the graphs above but they’re there (because we can represent sines and cosines in terms of sums and differences of complex exponential functions). Here’s what we have for the spectra of our signal and carrier wave (excuse the scribble)…
That * symbol in the scribble above represents a convolution. When we convolve the frequency spectra for our carrier and signal waveforms (and include the carrier wave), this is the result:
Lo and behold, we have sidebands. Multiplication in time domain = convolution in frequency domain.
 In Mathematica, I used the Clip function to do this.
 If you’ve studied Fourier analysis, ask yourself why this is. (Note that the sample frequency I was using is 192 kHz and that means the highest frequency I can reliably observe in the spectra is 96 kHz.)
 As we’ll hear a little further down the post, it also leads to some authentic “bleeding” of the sound from one station into another — an effect that many crystal radio enthusiasts had to endure in days gone by.