In a previous document (Using RTL-SDR with Labview Chapter 1 Labview on Windows), it was shown that a simple €20.00 dvb-t dongle can be used as a frontend to a labview based SDR system. This document provided a library and instructions to the user that made it possible to retrieve the IQ streams from the rtl-sdr and showed a simple spectrum display of the signal received.
After this post, there were some questions with regards to an FM demodulator to listen to FM broadcasts. In this document, I will describe a simple, mono FM demodulator which can be used to listen to FM broadcast stations. I will not go into detail on FM modulation. There are many sources that can do this way better than myself. Search on ni.com or on wikipedia for the relevant information.
In order to demodulate a broadcast FM signal, it's important to understand the structure of this signal, as there is much more information contained in the FM signal than just the mono audio information. The following image should make things clearer:
As you can see, the mono audio is only occupies a relatively small part of the channel bandwidth from 30Hz to 15kHz. This is the portion that we will be focussing on.
As the name implies, FM, or frequency modulation, uses a baseband signal to modulate the frequency of a carrier signal. The amplititude of the signal stays the same. This is an advantage over amplitude modulation, where the information to be transmitted is contained within the modulated amplitude of the carrier. If the AM signal is weakend significantly, information is lost. Since the information for FM is contained in the zero-crossings of the signal, theoretically only a small signal level is required to reconstruct the entire baseband information.
The basic structure of the used demodulator is shown in the image below:
Here is a short description of the chain:
The signal is received from the rtl-sdr device as IQ data. This is converted to a complex signal and the phase is extraced.
The phase correction removes phase discontinuities.
The key demodulation component in the chain is the phase derivative. The phase derivative takes the phase of the signal and creates a second signal that is composed only of the changes in frequency. This is then the demodulated signal.
The low pass filter is used to filter out frequencies above 15kHz, which do not contain the desired information.
The rational resample takes the signal, which is still at the sampled rate (in the examples case 286650Hz) and resamples it to something the sound card can handle. In this case, we are using a decimation factor of 13, which results in a 22050Hz audio stream. Actually, I worked this out the other way around. I wanted a 22050Hz audio stream and checked which sample rate would give me an integer decimation while keeping the RF sampling rate as low as possible.
The attached project provides an application which performs exactly these steps, allowing the user to tune to a frequency and listen to the mono part of the fm broadcast. The demodulation is handled in a subvi, aptly named FM_Demodulation.vi, which looks like this:
As you can see, all the steps for fm demodulation are present. I've tried to comment the code as good as possible, and to adhere to the Labview coding guidelines. There are some parts which could probably be further split into subvi's, but I wanted the software to be easy to read and be understandable to everyone.