Monday, December 14, 2015

Simple FM-receiver with RTLSDR-dongle and gnuradio-companion

GNU Radio is a free software development toolkit which makes the task of signal processing the input from sources such as the cheap 10$-rtlsdr dongles easier.

Bundled together with  GNU Radio is gnuradio-companion which is a python  code generator tool.
Gnuradio-companion is used to build 'flowgraphs'. When the flowgraph is constructed and 'compiled', python code is generated that creates and connects the blocks in the flowgraph. These blocks then step by step 'clean' and demodulate the incoming signal .

Below is the flowgraph I built using gnuradio-companion. A RTLSDR dongle is used as signal source to receive on a frequency containing FM-radio:


Note that the rtlsdr-dongle is just receiving the signal and not demodulating it. The signal is fed into gnu-radio companion for processing and demodulation.

Info about the flowgraph

RTLSDR source has samplerate set to 2.0e6Mhz/s

Ch0 frequency in the source-block is associated with the wxgui-slider variable where max is 110Mhz,min 90 Mhz,default 97.796Mhz.
Outgoing signals are then fed to a wxgui FFT-sink, a waterfall sink and a rational resampler.The FFT(Fast Fourier Transform)-sink and waterfall sink are mainly there to get a quick visual view of any signals coming in from the signal source.

In the rational resampler the decimation rate is set to 4 to reduce the signal by 1/4. This is done to prevent the CPU from overloading. To further clean up the signal it is fed into a lowpass-filter,where the cutoff frequency is set to 100000Hz and the transition width is set to 1000000.

Then the signal is sent to a wideband-FM-demodulator block,WBFM-receive, where the quadrature
rate is set to 500000 and decimation to 1.

Afterwards another resampler-block with interpolation 48 and decimation 500 prepare the signal for next block which is the audio sink. Finally the signal is sent to the computer-sound card which in gnuradio-companion is represented by an audio-sink.Most computer soundcards operate with samplerate 48Khz so it is essential that this is set in the audio sink.

Note: Sometimes the property device-name in the audio-sink must be defined.
Usually it can be left empty but if no sound is produced  try to set device-name as 'pulse' incase your OS uses pulseaudio to handle sound.

If alsa is used on your OS, device-name parameter of audio sink could be set as 'hw:0,0' or 'plughw:0,0'

When the flowgraph is generated(i.e compiled) and executed FM-radio should be heard from
sound card accompanied by an output similar to: