Linux Format

GNU RADIO: Tune in, drop out

Sean Conway provides step-by-step instructio­ns to construct an FM radio receiver using the versatile GNU Radio software.

- Credit: www.gnuradio.org

Sean Conway prepares for self-isolation in the Canadian wilderness by constructi­ng an FM radio receiver, using GNU Radio and a suitable software-defined radio adaptor.

The fun this issue is all about configurin­g a computer as a radio receiver. An introducti­on to GNU Radio concepts and its basic set up was provided in LXF261. This tutorial will expand on that knowledge to construct an FM radio receiver circuit with a flow graph. An antenna attached to a software-defined radio (SDR) dongle will capture a frequency-modulated (FM) broadcast radio-frequency (RF) signal. The signal will be digitally processed using GNU Radio software running on an Ubuntu 18.04 computer to produce an audio output. The reader can skip the set-up instructio­ns that follow if they have completed the steps in LXF261 to install the GNU Radio applicatio­n.

Let’s refresh the Ubuntu install with: sudo apt-get update -y && sudo apt-get upgrade -y sudo reboot sudo apt-get install rtl-sdr gnuradio gr-osmosdr

After installing the RTL-SDR dongle, use the command line to confirm that the hardware has been detected: sudo rtl_test -t

The command response Found Rafael Micro R820T tuner, and other details contained in message, confirms that the SDR dongle has been detected. Ignore the No E4000 tuner error. Locate GNU Radio Companion (GRC) icon in Ubuntu and start the applicatio­n.

GRC is the applicatio­n software for the user to access GNU Radio. GRC and GNU Radio are software projects supported by different developmen­t teams. The layout of GRC has changed through different versions. This tutorial was made using GNU Radio Companion version 3.7.11 as there appears to be some issues with the latest 3.8 release.

Here is a refresher of some of the GRC and GNU Radio concepts: GNU Radio uses flow graphs constructe­d with blocks (see below) that contain one or more ports with specific data types to process signals. The data type between blocks must match in order to establish a connection.

A block performs one signal-processing operation, such as generating signals, playing signals, establishi­ng variables, and providing access to hardware (such as the speaker).

Source Blocks have only output ports and Sink Blocks have only input ports. Every flow graph requires a minimum of one Source Block and one Sink Block in order to function.

Flow graphs are assembled and run in the GNU Radiocompa­nion (GRC) applicatio­n workspace. Libraries are organised into categories of blocks. The search function is a novice’s friend when trying to navigate the Libraries.

GNU Radio provides a number of methods to identify errors. Users need to look for hints provided by the software to resolve the errors. Extra messaging is available inside the property box of blocks.

The goal of this tutorial is to construct an FM receiver block by block using GRC. To explore the features of

GNU Radio, this tutorial will build the FM radio circuit flow graphs (see bottom left) in three stages.

Stage one is constructi­ng a flow graph to receive an FM signal and play audio (section 1). Stage two adds some testing capabiliti­es to the flow graph (section 2). Stage three will enhance the flow graph operation by automating some of the functions associated with the receiver (section 3).

Some readers may find creating flow graphs difficult. The LXF Archive and DVD provides the three fully built flow graphs 92_1_fm_radio_qt_fmbasic.grc, 92_1_fm_ radio_qt_fmbasic_vis.grc and 92_1_fm_radio_qt_ Enhanced.grc for this tutorial. If the reader wishes to avoid the step-by-step instructio­ns and just have a working flow graph they can load the files.

With GRC started, use the File Menu > New to start a QT GUI workspace. Using the File Menu, save the workspace. From the Library, navigate the Categories Area Core > (no modules specified) > Sources > RTLSDR Source, to drag the source Block RTL-SDR Source Block to the workspace. The operation of the dongle used for this exercise is supported under this block. The osmocom source is a block developed for other types of SDR device.

The SDR device architectu­re design converts an analogue signal to a digital signal. The antenna collects RF that is amplified through the low-noise amplifier (LNA) and filtered using the band pass filters. The SDR uses mixers, a local oscillator (LO) and filters to generate complex frequencie­s. Two signals are produced that are then converted to digital using analogue-to-digital converters (ADC).

The SDR device produces a digital output that is manipulate­d using this RTL-SDR Source Block in GNU

Radio software in order to generate a signal output for the flow graph.

Open the properties of the RTL-SDR Source Block by double-clicking the block or right-clicking and selecting properties. Let us make some configurat­ion changes to support the FM receiver build.

Set Ch0: Frequency Hz variable to Fm_freq, set Ch0: Freq. Corr. (ppm) to a value of 1, set Ch0: DC Offset Mode to value Automatic, set Ch0: Gain Mode to value Manual. When complete, the terminal screen at the bottom of the property box will display errors. These will be resolved later for the block to work. Select the OK button to continue.

Right-click the Variable Block on the screen and enter the Properties screen. Set Value to 2e6. For kilo and mega entries it might seem easier to use the long form. Once you start making entries in the gigahertz, you will find counting zeros much more difficult. GNU

Radio flow graph best practice suggests that you use scientific notation for variable entries.

Right-click the Variable Block on the screen again and select copy and then right-click again to paste the copied block to the workspace. This same operation could have been performed by dragging the Core > Variables > Variable Block from the Library and over to the workspace.

The objective is to play audio from an Fm-broadcaste­d signal. In the author’s rural area, a reasonable signal level was achieved using the FM radio station broadcasti­ng on frequency 92.1MHZ. The reader will need to identify local radio stations with a strong signal in their area and replace the 92.1MHZ with that local frequency.

Open the properties of the new Variable Block and change the ID field value to Fm_freq and the Value field to the chosen local FM broadcast frequency in your area (i.e. 92.1e6 for the author). Select the OK button to save the settings. Defining the new Variable Block will have resolved the warning message displayed in the RTL-SDR Source Block.

Pull in a Low Pass Filter Block into the workspace from the Library Categories and modify the properties to reflect the following: Decimation = int(samp_rate/ down_rate), Gain = 2, Cutoff Freq = 100e3, Transition Width =10e3 and Window = Blackman. Select OK to save the settings.

Now left-click the port on the RTL-SDR Source Block and left-click the left port on the Low Pass Filter Block to establish a connection.

The low Pass Filter Block is showing (i.e. text in Red) an error. To resolve the issue, we need to create a Variable Block with the ID field = down_rate and Value field = 250e3.

The output from our Source Block was processed by the Low Pass Filter (LPF) Block. The LPF, using variable values, decimated the incoming signal. Decimation is the process of reducing the sample rate. The LPF reduces the sample rate, so that the rate is lower to match the input of the next Block.

Wide-band frequency modulated (WBFM) transmissi­on bandwidth is typically 200K. The LPF is looking at one side, so it is set to 100khz. The transition width reflects how sharp the filter. is

The lower the transition number the more square or sharp the filter becomes.

The smaller the transition width the more calculatio­n is required, increasing the load on the CPU.

Locate and drag a WBFM Receiver Block to the workspace from the Library. Change field values to reflect Quadrature Rate= down_rate and Audio Decimation = 1. The WBFM receiver block is responsibl­e for the audio decoding. The Quadrature rate is set to the output of the LPF. Make a connection between the port on the LPF and the Receiver Block.

The WBFM Receiver Block has two ports – blue and orange. Blue ports are currently Complex Float 32 type, which means they contain both a real and an imaginary part, each being a Float 32 type. The orange port is Float 32. The mapping for the data types can be found using the Toolbar Help Menu > types.

Use the search button on the Toolbar to locate a Rational Resampler Block and drag it to the workspace. Change the properties to reflect the following: Type = Float-float(real Taps), Interpolat­ion = 24 and Decimation = 250, select OK to save. Connect the Input Block port to the WBFM Receive Block output port.

The Rational Resampler Block aligns sample rates. The block takes the input signal after decimation and then outputs a signal at the rate of interpolat­ion, Interpolat­ion inserts zero-valued samples between the original samples to increase the sample rate. Interpolat­ion can be used to match the sampling rate of another block, in this case the 250K input from the WBFM Receive Block to the Audio Sink Block of 24khz.

Drag a Multiply Constant and set the fields and values defined. IO Type= Float and Constant = 0.5 and select OK to save. Make a connection between the Rational Resampler and this Block. Multiply Block multiplies the input by a constant. The output = input * constant scalar/vector (element-wise if vector). The

Block is used to provide audio padding or signal attenuatio­n, to prevent over-driving the next block.

The flow graph started with a Source Block (e.g. RTL-SDR Source) and must end with a Sink Block (e.g. Audio Sink). Find the block in the Library and make a connection to the last block installed. Modify the properties to reflect: Sample Rate = 24khz, and select OK to save.

The Audio Sink Block is responsibl­e for generating audio from the computer. The sample_rate must match the rate provided by the preceding block.

With the final block of the flow graph in place, select the Toolbar start icon (yellow/green arrow) to start the flow graph. If this is a new flow graph constructi­on, the applicatio­n forces you to do some file administra­tion tasks before the flow graph will function.

Once you have given the file a name, the flow graph tab will display it (but only if you have more than one tab –i.e. flow graph – open.) The tab for the workspace will contain the name assigned to the flow graph file. You can have more than one tab available. This become really handy when you’re making multiple versions because of changes.

If the variable for the local FM broadcast station in your area is correct, the flow graph should start producing audio from the computer.

If your flow graph failed to generate audio, take a look at the Toolbar for a red error button indication. Look at the blocks themselves for red text or messages inside the blocks – they are there to assist you in troublesho­oting the problem. You can also read messages provided in the Terminal window (i.e. lower left side of the console) in order to determine the cause of the problem.

When the flow graph is executed, a pop-up screen labelled Top Block will be displayed, along with the audio from the computer speaker. This Top Block window contains nothing for the moment. It will become populated later, as we explore more of the GNU Radio block features.

To stop the flow graph and put an end to audio, use the Toolbar Kill icon or close down the Top Block pop-up window that was opened by the program when the flow graph started.

The flow graph design provided was simple and is intended to explore some of the digital-processing capabiliti­es of GNU Radio. If the reader performs an

internet search for GNU Radio and FM receivers, they will find–like the Perl programmin­g language–a number of different results to accomplish this same task.

Visual testing (2)

Let’s expand the flow graph to add some measuring capabiliti­es, to augment the audio with a visual indication of what is happening.

Drag and drop two Sink Blocks from the Library labelled QT GUI Waterfall Sink and QT GUI Sink. Connect both Sink Blocks to the output of the RTL-SDR Source Block. Block outputs are capable of supporting more than one connection. Modify the properties of each block to reflect Centre Frequency (Hz) = Fm_freq, and select OK to save.

Executing the flow graph will produce the audio but also graphs of the data streams. The QT GUI Waterfall plot is contained in the QT GUI Sink under a tab of the set of plots. Only one tab can be displayed at a time. Enabling two Sinks allows both waveform plots to be displayed at the same time.

A Sink Block for frequency could be added to provide a plot of the audio signal. This would provide a graphical view of audio signal separate from the RF signal.

Enhance and zoom (3)

The last flow graph changes are provided to highlight some of GNU Radio options that automate and provide added functional­ity. Make a copy of the flow graph just completed by saving the file to a different name. Add the descriptor enhanced to the file name to reflect the flow graph has enhanced features.

To start the next flow graph, delete the Variable Block with the ID Fm_freq. You will notice a number of blocks now have red warning indication­s. The issue creating the messages will be corrected shortly.

Drag and drop a QT GUI Chooser Block from the Library, open the properties box, make the following edits, and select OK to save. Replace the labels and options values provided with local FM broadcast signal values for your area.

ID = Fm_freq

Type = Float

Default Value = 92.1e6

Option 0 = 92.1e6

Label 0 = 92.1FM

Option 1 = 99.9e6

Label 1 = 99.9FM

Option 2 = 107.1e6

Label 2 = 107.1FM

Widgets = Radio Buttons

Drag and drop two QT GUI Range Blocks from the Library to the workspace. In one block make the following edits, and save the block:

ID = Rf_gain type = int

Default Value = 15

Start = 10

Stop = 70

Step = 10

Minimum Length = 70

On the second QT GUI Range Block make the following edits:

ID = Af_gain type = int

Default Value = 100

Start = 0

Stop = 1000 #note (exponentia­l will fail)

Step = 1

Widgets = Knob

Minimum Length = 1

Running the flow graph with the enhancemen­ts provides some additional functional­ity in the Top Block pop-up window. Radio frequency selection buttons and two gain (i.e. amplificat­ion) controls are provided – one is used to control the gain on the incoming RF signal, while the other one is used to control the gain on the audio output.

This completes the tutorial on constructi­ng GNU

Radio flow graphs for an FM radio broadcast receiver. The RTL-SDR USB dongle with its associated antenna captured an analogue FM broadcast signal and converted it to digital. GNU Radio flow graphs digitally processed the incoming signal to produce audio. The flow graphs are performing the tasks of what physical electronic­s circuits would have done to the analogue signal, but in the confines of a workspace.

 ??  ??
 ??  ??
 ??  ?? OUR EXPERT Sean D. Conway having invested 40 years in technology careers, this retired IT security specialist continues to play with computers in his basement for the enjoyment of writing about it.
OUR EXPERT Sean D. Conway having invested 40 years in technology careers, this retired IT security specialist continues to play with computers in his basement for the enjoyment of writing about it.
 ??  ??
 ??  ??

Newspapers in English

Newspapers from Australia