Simulation example: Narrowband FM transceiver

This tutorial explains how a Narrowband FM (NBFM) signal can be generated and received. Rather than using any real hardware for transmission, the signal is sent via a socket from the transmit section to the receive section. The only actual hardware involved is the computer's microphone input and speaker output. In the case of a Raspberry Pi computer, which has no microphone input, three alternatives are presented.

This tutorial can be performed with GNU Radio (GR) version 3.8 and later. It has been tested with GR version 3.8.2. The Graphical User Interface gnuradio-companion (GRC) is used to create a flowgraph for each section.

Prerequisites

 * Intro to GR usage: GRC and flowgraphs
 * Understanding sample rate
 * Where to get help

Flowgraph
Using gnuradio-companion (GRC) and the following Block descriptions, build this flowgraph for the receiver section:



The GR version 3.8 file can be found at Copy and paste it into a local file as `NFM_rcv.grc`

Block descriptions

 * Data is received from the transmitter via a ZMQ_SUB_Source at a sample rate of 576kHz. NOTE: Change the address of the ZMQ_SUB_Source to `tcp://127.0.0.1:49203` so it will connect to the transmitter.
 * It is filtered to a bandwidth of 6kHz and decimated (reduced) by a factor of 3 by the FFT_Filter, giving an output sample rate of 192kHz.
 * A Simple_Squelch mutes the audio when the input is less than the squelch level.
 * The NBFM_Receive block demodulates the input and produces an output sample rate of 48kHz which matches the desired audio rate.
 * The Multiply_Const block implements a Volume control.
 * The speaker output is defined by an Audio_Sink block.
 * Device name: for most speakers (or headphone jacks) built into the computer, the Device name can be left blank; for other cases, see Audio_Sink
 * OK to Block: Yes

Test receiver section
Without the transmitter, there is not much to test, but you can generate and run the flowgraph. After a few seconds, a GUI window will open showing Volume and Squelch controls as well as a waterfall spectrum display. Note that the waterfall will not be running since there is no input data. To terminate the process cleanly, click on the 'X' in the upper corner of the GUI rather than using Control-C.

Flowgraph
Using gnuradio-companion (GRC) and the following Block descriptions, build this flowgraph for the transmitter section:



The GR version 3.8 file can be found at Copy and paste it into a local file as `NFM_xmt.grc`

Block descriptions

 * The microphone input is defined by an Audio_Source block. The parameters are:
 * Sample rate: set to 48khz (use the pull-down)
 * Device name: for most microphone jacks built into the computer, the Device name can be left blank; for other cases, see Audio_Source
 * OK to Block: No
 * The audio is filtered to a range of 300 to 5000 Hz by the Band_Pass_Filter.
 * The Multiply_Const block implements an Audio Gain control.
 * Most repeaters utilize a tone to trigger the transmitter.
 * The PL (Private Line) tone can be selected by the QT_GUI_Chooser. Using a value of 0.0 turns off the PL.
 * The Signal_Source generates the PL tone.
 * The audio signal plus PL tone is fed into a NBFM_Transmit block. The output sample rate is 192kHz.
 * The Low_Pass_Filter limits the signal to 5kHz.
 * A Repeat block interpolates (multiplies) the sample rate by 3, giving an output rate of 576kHz.
 * The transmit signal is fed to a ZMQ_PUB_Sink with an address of `tcp://127.0.0.1:49203`, matching the port of the receiver.

Note for Raspberry Pi
Since a Raspberry Pi has no audio input jack, there are three alternatives:


 * 1) use a USB audio dongle and a microphone
 * 2) use a USB headset with microphone
 * 3) use a USB webcam with microphone

Testing
When using GRC, doing a Generate and/or Run creates a Python file with the same name as the .grc file. You can execute the Python file without running GRC again.

For testing this system we will use two processes, so we will need two terminal windows.

Terminal 2
python3 -u NFM_rcv.py
 * Open another terminal window.
 * change to whatever directory you used to generate the flowgraph for NFM_rcv
 * execute the following command:
 * After a few seconds, a GUI window will open showing Volume and Squelch controls as well as a waterfall spectrum display.

Terminal 1

 * going back to the GRC window, since you just finished building the `NFM_xmt.grc` flowgraph, you can just do a Run. After a few seconds, a GUI window will open with the Audio gain control and the GUI Frequency Sink.

Speaking into the microphone should show a change in the pattern on the QT GUI Time Sink. The level of modulation can be adjusted with the transmit gain control. You should hear your voice from the speakers. The speaker volume can be adjusted with the receive volume control.

To terminate each of the processes cleanly, click on the 'X' in the upper corner of the GUI rather than using Control-C.

What do to next
The files used in this simulation are part of a package in https://github.com/duggabe/gr-control If you clone that repository, you will have a complete NBFM transceiver using a Pluto SDR.