Communications System Toolbox
This model shows how to use the RTL-SDR radio with MATLAB® and Simulink® to build an FM stereo receiver. The model plays out the left and right channels.
This example is implemented in two versions:
The following text describes the Simulink version, but both versions have the same functionality.
|On this page…|
This is the top-level block diagram of the model.
The RTL-SDR Receiver block takes in the baseband discrete-time complex samples from the RTL-SDR hardware. Set the sampling rate of the RTL-SDR device to 240 ksps. Prior to FM demodulation, a rate converter resamples the signal again to a rate of 152 kHz. This sample rate is convenient for downstream processing in the stereo decoder. An FM demodulator follows the 152 kHz resampler, and is implemented in the same fashion as the one described in FM Monophonic Receiver with RTL-SDR Hardware.
Below is the block diagram of the stereo decoder inside the FM Receiver subsystem.
The peaking filter picks out the 19 kHz pilot tone, from which a 38 kHz carrier is created via an open loop technique. The technique exploits trigonometric identities and the fact that the 19 kHz tone is sampled precisely eight times per cycle. The carrier is used to downconvert the L-R signal, centered at 38 kHz, to baseband. The Gain Compensation is to compensate for the L-R signal loss during the transmission. A resampler then converts the sampling rate to 48 kHz. This rate is one of the native sampling rates of the output audio device. During the rate conversion, the resampling filter removes the undesirable signals above 15 kHz. Next, the baseband L+R and L-R signals pass through a 75 microsecond deemphasis filter [ 1 ]. Finally, a MATLAB® Function block separates the L and R signals, and the audio device plays them out.
Set the Center Frequency to a local FM radio station, click the run button, and listen to the sound from the audio device. Change the Center Frequency to listen to a different station.
If you hear some dropouts or delay in the sound, run the model under Accelerator mode. From the model menu, select Simulation->Accelerator, then click the run button.
If you insert a Spectrum Scope block right before the 19n/6 resampler, the spectrum looks like the following. The black spectrum contains L+R at baseband, L-R at 38 kHz, and the 19 kHz tone. The red spectrum is the downconverted signal with L-R at baseband.
The figure below shows the spectrum of the left (black) and the right (red) channel corresponding to the spectrum above. This spectrum represents music from a broadcast FM station. There is some stereo separation between the left and the right channel up to 20 kHz.
The figure below illustrates the separation between left and right channels achieved by the model with a known, controlled source. It shows the spectrum of the left (black) and the right (red) channel for a stereo test signal transmitted by a hand-held FM transmitter. The test signal consists of a single 500 Hz tone in the left channel and a single 1 kHz tone in the right channel. The model achieves approximately 20 dB separation between left and right channels.
If you have your own FM transmitter that can transmit .wma files, you can duplicate the test that shows the channel separation result above. Load the sdruFMStereoTestSignal.wma file into your transmitter. The channel separation can be easily observed from the Spectrum Scope block and heard from the audio device. You can also adjust the Gain Compensation to see its effect on stereo separation.
To optimize the filtering speed, you can combine the resampling filter in the 19n/6 resampler and the deemphasis filter into a single filter.
The following script is used in this example: