While we are driving on the way to our jobs, we have the 99.9% of our attention to the road, but I am sure that the other 0.1% of our attention is focus on the radio. Radio has been with us for most than 100 years, and today is its day, today is the World Radio Day. For this day I wanted to write a post dedicated to her, and also, this post will allow me to present some terms that will be used in future posts like mixers, modulation, base band… First of all let me explain how Radio works.
Radio waves travel through the air from the radio station to the receivers. If I connect my signal generator to a wire, and let the other side unconnected, the signal that I am applying is emitted to the air, but the distance and the way that this signal interact with the obstacles will depend of the characteristics of the signal. Regardless the way that we generate the signal we want to transmit, in every case we will need to increase the frequency of that signal in order to be able to transmit the signal. That is due to the fact that high frequency signals are easy to transmit through the air. To do that we need to modulate the signal, that is exactly what I have said, elevate the frequency of the signal. To do that we use mixers, that are essentially multipliers. According the way that we multiplicate the signals, we can find different modulation types.
For the broadcast radio that we listen in our cars or while we are working, two methods are used, Amplitude Modulation (AM), and Frequency Modulation (FM). In the AM, the audio signal generated in the radio station, the modulator signal or the base band signal, is multiplied by a high frequency signal, the carrier signal, and the result is a high frequency signal which amplitude is the modulator signal. On the other hand, the FM changes the frequency of the carrier signal according the frequency of the audio signal. In the next figure you can see the modulator signal on the top, and the AM and the FM modulation results.
The MATLAB code to obtain this plots is the next.
close all clear all clc %% AM generation fsample = 1; nsamples = 128; time = 0:0.00001:0.04; carrier = sin(1e3*2*pi*time); modulator = sin(50*pi*time); am_signal = modulator .* carrier; plot(am_signal) title("AM signal") fm_signal = sin((1e3+(modulator*200))*2*pi.*time); figure; plot(fm_signal) title("FM signal") figure; subplot(3,1,1) plot(modulator) title("Modulator signal") subplot(3,1,2) plot(am_signal) title("AM signal") subplot(3,1,3) plot(fm_signal) title("FM signal")
We can see this from the other point of view, from the vectors point of view. We have a rotating vector at a speed of fc*2*pi, being fc the carrier frequency. Over this vector we have the modulator signal. The modulator is represented by 2 different vectors rotating in opposite directions. For the AM modulation, the initial position of those vectors are the same, we say that those vector are in phase. While the vectors rotate, the module of the resulting vector is kept always in the same axis, but its module is varying, its amplitude changes.
For the case of FM, the initial position of the modulator vectors are in quadrature, that is a difference of pi/2 radians between them. In this case, while the vectors are rotating, the resulting vector describes a circle. This circle is translated in changes in the speed that the resulting vector is rotating (also changes in amplitude), or what is the same, changes in the frequency that the resulting vector is rotating. In other words, the resulting vector is accelerating and decelerating according the modulator signal.
With this very basic notions of radio signals, I will show you how you can design a FM receiver using GNU radio and USRP B205mini from Digilent. The GNURadio diagram for the FM receiver is very simple.
First of all we need to include the source of our signal. In this case, the signal is generated by the USRP so we need to include the USRP Source block. As we have said, the radio signal is modulated with a high frequency signal, with the carrier signal, and each radio station uses a different carrier, so we need to tune the USRP in the corresponding carrier frequency. To do that we need to configure the Center Frequency, in my case I want to hear the radio station that uses the carrier 94.2 MHz. Now we have to think that we have move the frequency spectrum 94.2 MHz to the left, so out new DC is what before was 94.2 MHz. Keep this in mind because now we have to configure the sampling frequency, and it is only 5 MHz.Then the output signal sampled at 5 MHz will be pass through a low pass filter. Audio signals has an spectrum of 20 Hz to 20 kHz, so we can attenuate all the frequencies above 20 kHz. In this case I have configured a cut frequency of 100 kHz, with a sampling rate of 5 MHz. Also I have used this filter to decimate the signal, that is, divide the number of samples by n. In this case the decimation factor is 20, so the output rate will be 5 MHz divided by 20, that is 250 kHz. Next, we need to include the Wave Band FM demodulator, with a quadrature rate that is the same of the sampling frequency, 250 kHz. Finally, the sound card of most computers can manage signals with a rate of 96 kHz, so we need to resample the signal to pass from 250 kHz to 96 kHz. This block performs the operation input_samples * Interpolation / Decimation, that has as a result 96 kHz. The output of this block will be connected to the Audio sink block, and the FM receiver is complete.
In the diagram I also have added two QT GUI Sink to check the signals in that points.
The next figure shows the frequency spectrum of the output signal. That signal contains the sound that out speakers will reproduce. We can see that the majority of the signal is contained in the first 7 kHz.
This block also allows us to see a cascade display, showing as red as more appears that frequency
Radio exists since more than a 100 years, but the way that we receive and process the radio signal has change. Inside the first receptors we can find many inductors, capacitor, operational amplifiers, analog multipliers.. and each of those elements execute only one function. Now we only need a RF IC that is in charge of all the analog stuffs for high frequency (multiplier, amplifier, filtering…), and an FPGA that is in charge of the configuration of the RF IF and all the digital processing in low frequency, that is the case of the USRP B205mini. If we want more integration in the market exists several solutions like the Zynq US+ RFSOC that includes RF tranceivers, or the RTL2832U. Whatever, receiving and playing with radio signals is becoming easier and easier, making it more affordable for everyone. Happy World Radio Day!