Simulation example: Narrowband FM transceiver: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
(completed and tested)
 
(4 intermediate revisions by the same user not shown)
Line 8: Line 8:
* [[Guided_Tutorial_GRC|'''Intro to GR usage: GRC and flowgraphs''']]
* [[Guided_Tutorial_GRC|'''Intro to GR usage: GRC and flowgraphs''']]
* [[Sample_Rate_Tutorial|'''Understanding sample rate''']]
* [[Sample_Rate_Tutorial|'''Understanding sample rate''']]
* [[FAQ#The_Community:_Where_you_get_help.2C_advice_and_code|'''Where to get help''']]


== NBFM receiver ==
== NBFM receiver ==
Line 17: Line 18:
[[File:NFM_rcv_fg.png|800px]]
[[File:NFM_rcv_fg.png|800px]]


The GR version 3.8 file can be found at [https://raw.githubusercontent.com/duggabe/gr-control/main/Receivers/NFM_rcv.grc] Copy and paste it into a local file as `NFM_rcv.grc`
The GR version 3.8 file can be found at [https://raw.githubusercontent.com/duggabe/gr-control/maint-3.8/Receivers/NFM_rcv.grc] Copy and paste it into a local file as `NFM_rcv.grc`


=== Block descriptions ===
=== Block descriptions ===
Line 32: Line 33:
=== Test receiver section ===
=== Test receiver section ===


To test the receiver, 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.
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.


== NBFM transmitter ==
== NBFM transmitter ==
Line 42: Line 43:
[[File:NFM_xmt_1_fg.png|800px]]
[[File:NFM_xmt_1_fg.png|800px]]


The GR version 3.8 file can be found at [https://raw.githubusercontent.com/duggabe/gr-control/main/Transmitters/NFM_xmt.grc] Copy and paste it into a local file as `NFM_xmt.grc`
The GR version 3.8 file can be found at [https://raw.githubusercontent.com/duggabe/gr-control/maint-3.8/Transmitters/NFM_xmt.grc] Copy and paste it into a local file as `NFM_xmt.grc`


=== Block descriptions ===
=== Block descriptions ===
Line 90: Line 91:
== What do to next ==
== 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.
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 which can use either a B200mini or a Pluto SDR. It has been tested with GNU Radio version 3.10.10.0.

Latest revision as of 21:30, 15 May 2024

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

NBFM receiver

Flowgraph

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

NFM rcv fg.png

The GR version 3.8 file can be found at [1] 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#Device_Name
    • 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.

NBFM transmitter

Flowgraph

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

NFM xmt 1 fg.png

The GR version 3.8 file can be found at [2] 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#Device_Name
    • 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

  • Open another terminal window.
  • change to whatever directory you used to generate the flowgraph for NFM_rcv
  • execute the following command:
   python3 -u NFM_rcv.py
  • 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 which can use either a B200mini or a Pluto SDR. It has been tested with GNU Radio version 3.10.10.0.