Difference between revisions of "User:Duggabe"

From GNU Radio
Jump to: navigation, search
(RTL-SDR dongle)
(DRAFT 2nd REVISION)
Line 1: Line 1:
 
<!-- Guided_Tutorial_Hardware_Considerations -->
 
<!-- Guided_Tutorial_Hardware_Considerations -->
 
<!-- "Using GNU Radio with Hardware" -->
 
<!-- "Using GNU Radio with Hardware" -->
<!-- 10 May 2020 -->
+
<!-- 14 May 2020 -->
= DRAFT REVISION Guided_Tutorial_Hardware_Considerations =
+
= DRAFT 2nd REVISION Guided_Tutorial_Hardware_Considerations =
 
== Introduction ==
 
== Introduction ==
  
One of the great strengths of GNU Radio is how easy it is to move from simulation to real-world operation. In this tutorial, we will build on what you have learned so far and create a complete FM radio receiver which you can use to listen to your local FM radio stations. Also we will discuss considerations that come into play when working with real-world radio hardware.
+
One of the more basic (and also incredibly useful) things you can do in GNU Radio with a receiver is to create a software radio spectrum analyzer. This is also a great first step because it will verify that your hardware is working correctly. Later we will create a broadcast FM receiver.
  
 
== Prerequisites ==
 
== Prerequisites ==
  
* [[SuggestedReading|Our Suggested Reading list]]
 
 
* Tutorials:
 
* Tutorials:
 
** [[Guided_Tutorial_Introduction|'''A brief introduction to GNU Radio, SDR, and DSP''']]
 
** [[Guided_Tutorial_Introduction|'''A brief introduction to GNU Radio, SDR, and DSP''']]
Line 17: Line 16:
 
== What Will I Need? ==
 
== What Will I Need? ==
  
Even if you don't have an actual radio to work with, this tutorial is still useful. The "Signal Processing" portion produces an FM radio with input from a pre-recorded file. To load that file, do the following steps:
+
There is a large and growing number of vendors who provide hardware with GNU Radio drivers.They span from very cheap ($20) receivers to very high-performance tens-of-thousands-of-dollars systems. Parameters for four of the most popular devices are presented below. Other devices are listed in [[Hardware]].
  
* Go to https://github.com/gnuradio/gr-tutorial/blob/master/examples/tutorial6/fm_101.8MHz_1Msps.cfile in your browser and click Download.
+
== Creating a Software Radio Spectrum Analyzer ==
** If not the default, select your Downloads directory.
 
  
This tutorial will be most useful, however, if you have a piece of radio hardware that you can use with GNU Radio. There are a large number of vendors who provide hardware with GNU Radio drivers. They span from very cheap $20 receivers to very high-performance tens-of-thousands-of-dollars systems. See [[Hardware]] for additional information.
+
Using gnuradio-companion (GRC) and the following Block descriptions, build this flowgraph.<br>
  
== Building an FM Radio Receiver ==
+
(put flowgraph here)
 
 
This tutorial is divided into two sections: "Signal Processing" and "Hardware". Various popular hardware devices are shown so that you can build with your available device.
 
 
 
In the "Signal Processing" section we will build the Software Defined Radio (SDR) portion of the flowgraph and test it. Then, using that as a base, we will "plug in" a hardware device of your choice. So, <b>building the "Signal Processing" portion is required in any case</b>. After that, substituting a hardware device will follow easily.
 
 
 
=== GNU Radio Signal Processing ===
 
 
 
Using gnuradio-companion (GRC) and the following Block descriptions, build this flowgraph:<br>
 
 
 
[[File:FM_receiver_fg.png|800px]]
 
 
 
==== Block descriptions ====
 
 
 
* The Options block identifies the filename for the flowgraph, a title, author, etc.
 
** id: FM_receive
 
** Title: Broadcast FM receiver
 
** enter other fields as desired
 
** click Apply
 
** click OK
 
** click on File -> Save As&nbsp;&nbsp;Use the file name 'FM_receive'. The extension '.grc' is added automatically
 
 
 
* Variable block - defines the sample rate for the flowgraph
 
** id: samp_rate
 
** value: 384000
 
 
 
* Variable block - defines the decimation factor for the rational resampler
 
** id: rf_decim
 
** value: 1000
 
 
 
* Variable block - defines the interpolation factor for the rational resampler
 
** id: interp
 
** value: 384
 
 
 
* Variable block - defines the FM modulation deviation in Hertz
 
** id: deviation
 
** value: 75000
 
 
 
* Variable block - defines the audio decimation factor for the FM demodulator
 
** id: audio_decim
 
** value: 8
 
 
 
* The QT GUI Range block creates an Audio gain (volume) control
 
** id: volume
 
** default value: 0.3
 
** start: 0.0
 
** stop: 1.0
 
** step: 0.1
 
** Widget: slider (or you can choose whichever you like)
 
 
 
* File Source - reads the pre-recorded FM station data file
 
** File: $HOME/Downloads/fm_101.8MHz_1Msps.cfile    (use your file path; you also can browse to find the file by clicking the three dots next to the filename)
 
** Output Type: Complex
 
** Repeat: Yes
 
** leave the other parameters as default values
 
 
 
The Rational Resampler interpolates (multiplies) the sample rate by the Interpolation factor and decimates (divides) the sample rate by the Decimation factor to produce the output sample rate. In this case, the 1MB input is divided by 1000 and multiplied by 384 to produce an output rate of 384000 samples per second.
 
* Rational Resampler
 
** Type: Complex -> Complex (Complex Taps)
 
** Interpolation: interp
 
** Decimation: rf_decim
 
** Taps: leave blank
 
** Fractional BW: 0
 
 
 
* FM Demod - the 384kHz input signal is demodulated and then decimated by 8 to produce a 48kHz signal for the Audio Output.
 
** Channel Rate: samp_rate
 
** Audio Decimation: audio_decim
 
** Deviation: deviation
 
** Audio Pass: 16000
 
** Audio Stop: 20000
 
 
 
* The value of the volume control is used as a multiplier in the Multiply Const block.
 
** IO Type: float
 
** Constant: volume
 
 
 
* The speaker output is created by an Audio Sink block. The parameters are:
 
** Sample rate: set to 48kHz (use the pull-down)
 
** 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
 
 
 
<b>TESTING:</b> See [[#Testing|Testing]] section below.
 
 
 
=== Hardware Front End ===
 
 
 
Now that you have gotten this far, you need to save a copy of your flowgraph before proceeding.
 
 
 
* click on File -> Save Copy
 
 
 
That way you will have the baseline flowgraph if you choose to use a different hardware device (or to start over).
 
 
 
==== Preparation for hardware ====
 
 
 
For each of the hardware blocks presented below, we will be replacing the File Source block with a hardware block. In addition, four of the five Variable blocks may need to have new values. 
 
 
 
Also, for the Audio Sink block, set:
 
* OK to Block: No
 
 
 
==== ADALM-PLUTO ====
 
 
 
The ADALM-PLUTO (PlutoSDR) is a portable, self-contained RF learning module which is supported by GNU Radio source and sink blocks. It can operate from 70MHz to 3.8GHz.
 
 
 
Using gnuradio-companion (GRC) and the following Block descriptions, build this flowgraph from our "Signal Processing" baseline.<br>
 
 
 
[[File:Pluto_FM_fg.png|800px]]
 
 
 
The actual source and sink blocks are created by an 'Industrial I/O' module. See https://wiki.analog.com/resources/tools-software/linux-software/gnuradio for details.
 
 
 
* Delete the File Source block and replace it with a PlutoSDR Source block. Set the parameters as follows:
 
** IIO context URI: "ip:192.168.2.1"  (without the quotes)
 
** LO Frequency: tuning
 
** Sample Rate: samp_rate
 
** RF Bandwidth: 500000
 
** Buffer size: 16384
 
** Quadrature: True
 
** RF DC Correction: True
 
** BB DC Correction: True
 
** Gain Mode (Rx1): Fast Attack
 
** Filter: (leave blank)
 
** Filter Auto: True
 
 
 
* Add a QT GUI Chooser block for the tuning control
 
** id: tuning
 
** Label: Station
 
** Type: int
 
** Num Options: 4
 
** Option 0 (Default): 102100000  (enter your favorite FM stations for all of these)
 
** Label 0: WDRM
 
** Option 1: 96900000
 
** Label 1: WRSA
 
** Option 2: 89300000
 
** Label 2: WLRH
 
** Option 3: 99100000
 
** Label 3: WAHR
 
** Widget: Radio Buttons
 
** Orientation: Horizontal
 
 
 
Change the following Variable block values.
 
  
* Variable block - defines the sample rate for the flowgraph
+
=== Parameters For Popular Devices ===
** id: samp_rate
 
** value: 1920000
 
  
* Variable block - defines the decimation factor for the rational resampler
+
This example uses an [https://kb.ettus.com/B200/B210/B200mini/B205mini Ettus Research USRP B200] and uses the [https://github.com/EttusResearch/uhd USRP Hardware Driver (UHD)].
** id: rf_decim
 
** value: 5
 
  
* Variable block - defines the interpolation factor for the rational resampler
+
* The USRP B200 provides a fully integrated, single board Universal Software Radio Peripheral platform with continuous frequency coverage from 70 MHz to 6 GHz. In order to use UHD blocks, you must have UHD installed. See [https://kb.ettus.com/Building_and_Installing_the_USRP_Open-Source_Toolchain_(UHD_and_GNU_Radio)_on_Linux Installing the USRP].
** id: interp
 
** value: 1
 
 
 
* Variable block - defines the audio decimation factor for the FM demodulator
 
** id: audio_decim
 
** value: 8
 
 
 
<b>TESTING:</b> See [[#Testing|Testing]] section below.
 
 
 
==== UHD / USRP ====
 
 
 
The USRP B200 provides a fully integrated, single board Universal Software Radio Peripheral platform with continuous frequency coverage from 70 MHz to 6 GHz.
 
 
 
Using gnuradio-companion (GRC) and the following Block descriptions, build this flowgraph from our "Signal Processing" baseline.<br>
 
 
 
[[File:USRP_FM_fg.png|800px]]
 
 
 
* Delete the File Source block and replace it with a UHD: USRP Source block. Set the parameters as follows:
 
 
** General Tab
 
** General Tab
 
*** Output Type: Complex float32
 
*** Output Type: Complex float32
Line 208: Line 48:
 
** RF Options Tab
 
** RF Options Tab
 
*** Ch0: Center Freq (Hz): tuning
 
*** Ch0: Center Freq (Hz): tuning
*** Ch0: AGC: Enabled
+
*** Ch0: AGC: Disabled
 +
*** Ch0: Gain Value: rf_gain
 +
*** Ch0: Gain Type: Absolute (dB)
 
*** Ch0: Antenna: TX/RX
 
*** Ch0: Antenna: TX/RX
 
*** Ch0: Bandwidth (Hz): 500000
 
*** Ch0: Bandwidth (Hz): 500000
 +
<br>
  
* Add a QT GUI Range block for the tuning control
+
* The ADALM-PLUTO (PlutoSDR) is a portable, self-contained RF learning module which is supported by GNU Radio source and sink blocks. It can operate from 70MHz to 3.8GHz. The source and sink blocks are created by an 'Industrial I/O' module. See https://wiki.analog.com/resources/tools-software/linux-software/gnuradio for details.
** id: tuning
+
** IIO context URI: "ip:192.168.2.1" (without the quotes)
** Label: Frequency
+
** LO Frequency: tuning
** Type: int
+
** Sample Rate: samp_rate
** default value: 102100000 (enter your favorite FM station)
+
** RF Bandwidth: 500000
** start: 88000000
+
** Buffer size: 16384
** stop: 108000000
+
** Quadrature: True
** step: 200000
+
** RF DC Correction: True
** Widget: Counter + Slider (or you can choose whichever you like)
+
** BB DC Correction: True
 
+
** Gain Mode (Rx1): Manual
Change the following Variable block values.
+
** Manual Gain (Rx1)(dB): rf_gain
 
+
** Filter: (leave blank)
* Variable block - defines the sample rate for the flowgraph
+
** Filter Auto: True
** id: samp_rate
+
<br>
** value: 1920000
 
 
 
* Variable block - defines the decimation factor for the rational resampler
 
** id: rf_decim
 
** value: 10
 
 
 
* Variable block - defines the interpolation factor for the rational resampler
 
** id: interp
 
** value: 1
 
 
 
* Variable block - defines the audio decimation factor for the FM demodulator
 
** id: audio_decim
 
** value: 4
 
 
 
<b>TESTING:</b> See [[#Testing|Testing]] section below.
 
  
==== RTL-SDR dongle ====
+
* The RTL-SDR is a receive-only, low-cost, self-contained RF signal tuner supported by GNU Radio. There are several varieties of this device; the one used in this section is the V.3 Model. The full description is RTL2832U R820T2 TCXC + BIAS T + HF. The device has a frequency range of 500 kHz to 1766 MHz, with operation from 500 kHz to 24 MHz in direct sampling mode. The source block is created by an Out of Tree module. See https://github.com/osmocom/gr-osmosdr for details.
 
 
The RTL-SDR is a receive-only, low-cost, self-contained RF signal tuner supported by GNU Radio. There are several varieties of this device; the one used in this section is the V.3 Model. The full description is RTL2832U R820T2 TCXC + BIAS T + HF. The device has a frequency range of 500 kHz to 1766 MHz, with operation from 500 kHz to 24 MHz in direct sampling mode. The spec sheet can be found [https://www.rtl-sdr.com/wp-content/uploads/2018/02/RTL-SDR-Blog-V3-Datasheet.pdf here].
 
 
 
Using gnuradio-companion (GRC) and the following Block descriptions, build this flowgraph from our "Signal Processing" baseline.<br>
 
 
 
[[File:RTLSDR_receive_fg.png|800px]]
 
 
 
The source block is created by an Out of Tree module. See https://github.com/osmocom/gr-osmosdr for details.
 
 
 
* Delete the File Source block and replace it with an OsmoSDR RTL-SDR Source block. Set the parameters as follows:
 
 
** Output Type: Complex Float32
 
** Output Type: Complex Float32
 
** Device Arguments: rtl=0
 
** Device Arguments: rtl=0
Line 261: Line 79:
 
** Ch0: BB Gain (dB): 20
 
** Ch0: BB Gain (dB): 20
 
** Ch0: Bandwidth (Hz): 200000
 
** Ch0: Bandwidth (Hz): 200000
 +
<br>
  
* Add a QT GUI Range block for the tuning control
+
* The FunCube Pro+ is a receive only USB "dongle" with a range of 150kHz to 240MHz and 420MHz to 1.9GHz. The source block is created by an Out of Tree module. See https://github.com/dl1ksv/gr-fcdproplus for details.
** id: tuning
 
** Label: tuning
 
** Type: int
 
** default value: 100300000  (enter your favorite FM station)
 
** start: 87900000
 
** stop: 108100000
 
** step: 100000
 
** Widget: Counter + Slider (or you can choose whichever you like)
 
 
 
* Variable block - defines the sample rate for the flowgraph
 
** id: samp_rate
 
** value: 240000
 
 
 
Since the sample rate is set at 240kHz, there is no need to decimate it before input to the FM Demod block. Therefore the Rational Resampler can be removed.
 
 
 
* Variable block - defines the audio decimation factor for the FM demodulator
 
** id: audio_decim
 
** value: 5
 
 
 
<b>TESTING:</b> See [[#Testing|Testing]] section below.
 
 
 
==== FunCube Pro+ ====
 
 
 
The FunCube Pro+ is a small, receive only USB "dongle" with a range of 150kHz to 240MHz and 420MHz to 1.9GHz.
 
 
 
Using gnuradio-companion (GRC) and the following Block descriptions, build this flowgraph from our "Signal Processing" baseline.<br>
 
 
 
[[File:FunCube_FM_fg.png|800px]]
 
 
 
The source block is created by an Out of Tree module. See https://github.com/dl1ksv/gr-fcdproplus for details.
 
 
 
* Delete the File Source block and replace it with a FunCube dongle Pro+ block. Set the parameters as follows:
 
 
** Device Name: (see [[Audio_Source#Device_Name]] for details)
 
** Device Name: (see [[Audio_Source#Device_Name]] for details)
 
** Unit: 1
 
** Unit: 1
Line 301: Line 88:
 
** Frequency (Unit Hz): tuning
 
** Frequency (Unit Hz): tuning
 
** Frequency corr. (ppm): 0  (frequency correction in parts per million)
 
** Frequency corr. (ppm): 0  (frequency correction in parts per million)
** If gain: 1
+
** If gain: rf_gain
  
Since the fixed sample rate of the FunCube Pro+ is 192kHz, there is no need to decimate it before input to the FM Demod block. Therefore the Rational Resampler can be removed.
+
=== Tuning and Using the Spectrum Analyzer ===
  
* Add a QT GUI Chooser block for the tuning control
+
Set the following parameters in the QT GUI Sink
** id: tuning
+
* Center Frequency (Hz): tuning
** Label: Station
+
* Bandwidth (Hz): samp_rate
** Type: int
+
* Show RF Freq: Yes
** Num Options: 4
 
** Option 0 (Default): 102100000  (enter your favorite FM stations for all of these)
 
** Label 0: WDRM
 
** Option 1: 96900000
 
** Label 1: WRSA
 
** Option 2: 89300000
 
** Label 2: WLRH
 
** Option 3: 99100000
 
** Label 3: WAHR
 
** Widget: Radio Buttons
 
** Orientation: Horizontal
 
  
* Variable block - defines the sample rate for the flowgraph
+
The analyzer can be tuned with the Frequency control widget. If you check the "Display RF Frequencies" box in the run-time GUI window, then the scale on the 'Frequency Display' and 'Waterfall Display' tabs will show the actual frequencies with the tuned frequency in the center.
** id: samp_rate
 
** value: 192000
 
  
* Variable block - defines the audio decimation factor for the FM demodulator
+
== Building an FM Radio Receiver ==
** id: audio_decim
 
** value: 4
 
  
=== Testing ===
+
Now that you have a basic receiver application running with a real-time display of your received data, let's build a useful application! Leave your current flowgraph in place. We will simply add more functionality rather than replacing what is already there.
  
Using GRC, click the Run icon or click Run -> Execute from the menu. After a few seconds, a GUI window will open with the Volume control (and Chooser or slider). You should hear the radio station. If the GUI window doesn't appear, look at your terminal screen for error messages.
+
Choose the flowgraph below for your hardware device.
  
If the sound is distorted or has interruptions, try the following:
+
<b>UHD / USRP</b>
* adjust the rf_gain setting
 
* For the Audio Sink block, change OK to Block
 
  
To terminate the process cleanly, click on the 'X' in the upper corner of the GUI window rather than using Control-C.
+
[[File:USRP_FM_fg.png|800px]]
 +
<hr>
  
== Further Study ==
+
<b>ADALM-PLUTO</b>
  
Once you have a working radio, you can experiment with different settings.
+
[[File:Pluto_FM_fg.png|800px]]
* sample rate
+
<hr>
* band width
 
* RF gain - manual or AGC
 
  
If you add a QT GUI Sink block connected to the source block, you will get plots of Frequency, Time, Waterfall, and Constellation.
+
<b>RTL-SDR dongle</b>
 +
 
 +
[[File:RTLSDR_receive_fg.png|800px]]
 +
<hr>
 +
 
 +
<b>FunCube Pro+</b>
 +
 
 +
[[File:FunCube_FM_fg.png|800px]]

Revision as of 17:17, 14 May 2020

DRAFT 2nd REVISION Guided_Tutorial_Hardware_Considerations

Introduction

One of the more basic (and also incredibly useful) things you can do in GNU Radio with a receiver is to create a software radio spectrum analyzer. This is also a great first step because it will verify that your hardware is working correctly. Later we will create a broadcast FM receiver.

Prerequisites

What Will I Need?

There is a large and growing number of vendors who provide hardware with GNU Radio drivers.They span from very cheap ($20) receivers to very high-performance tens-of-thousands-of-dollars systems. Parameters for four of the most popular devices are presented below. Other devices are listed in Hardware.

Creating a Software Radio Spectrum Analyzer

Using gnuradio-companion (GRC) and the following Block descriptions, build this flowgraph.

(put flowgraph here)

Parameters For Popular Devices

This example uses an Ettus Research USRP B200 and uses the USRP Hardware Driver (UHD).

  • The USRP B200 provides a fully integrated, single board Universal Software Radio Peripheral platform with continuous frequency coverage from 70 MHz to 6 GHz. In order to use UHD blocks, you must have UHD installed. See Installing the USRP.
    • General Tab
      • Output Type: Complex float32
      • Wire Format: Automatic
      • Stream args: (blank)
      • Stream channels: []
      • Device Address: "serial=xxxxxx" (supply your serial number)
      • Device Arguments: ""
      • Sync: No Sync
      • Clock Rate (Hz): Default
      • Num Mboards: 1
      • Mb0: Clock Source: Default
      • Mb0: Time Source: Default
      • Mb0: Subdev Spec: (blank)
      • Num Channels: 1
      • Samp rate (sps): samp_rate
    • Advanced Tab
      • Show LO Controls: False
    • RF Options Tab
      • Ch0: Center Freq (Hz): tuning
      • Ch0: AGC: Disabled
      • Ch0: Gain Value: rf_gain
      • Ch0: Gain Type: Absolute (dB)
      • Ch0: Antenna: TX/RX
      • Ch0: Bandwidth (Hz): 500000


  • The ADALM-PLUTO (PlutoSDR) is a portable, self-contained RF learning module which is supported by GNU Radio source and sink blocks. It can operate from 70MHz to 3.8GHz. The source and sink blocks are created by an 'Industrial I/O' module. See https://wiki.analog.com/resources/tools-software/linux-software/gnuradio for details.
    • IIO context URI: "ip:192.168.2.1" (without the quotes)
    • LO Frequency: tuning
    • Sample Rate: samp_rate
    • RF Bandwidth: 500000
    • Buffer size: 16384
    • Quadrature: True
    • RF DC Correction: True
    • BB DC Correction: True
    • Gain Mode (Rx1): Manual
    • Manual Gain (Rx1)(dB): rf_gain
    • Filter: (leave blank)
    • Filter Auto: True


  • The RTL-SDR is a receive-only, low-cost, self-contained RF signal tuner supported by GNU Radio. There are several varieties of this device; the one used in this section is the V.3 Model. The full description is RTL2832U R820T2 TCXC + BIAS T + HF. The device has a frequency range of 500 kHz to 1766 MHz, with operation from 500 kHz to 24 MHz in direct sampling mode. The source block is created by an Out of Tree module. See https://github.com/osmocom/gr-osmosdr for details.
    • Output Type: Complex Float32
    • Device Arguments: rtl=0
    • Sample Rate (sps): samp_rate
    • Ch0: Frequency (Hz): tuning
    • Ch0: RF Gain (dB): rf_gain
    • Ch0: IF Gain (dB): 20
    • Ch0: BB Gain (dB): 20
    • Ch0: Bandwidth (Hz): 200000


  • The FunCube Pro+ is a receive only USB "dongle" with a range of 150kHz to 240MHz and 420MHz to 1.9GHz. The source block is created by an Out of Tree module. See https://github.com/dl1ksv/gr-fcdproplus for details.
    • Device Name: (see Audio_Source#Device_Name for details)
    • Unit: 1
    • Lna enable, disable: 1 (enables low noise amplifier)
    • Mixer gain enable, disable: 1
    • Frequency (Unit Hz): tuning
    • Frequency corr. (ppm): 0 (frequency correction in parts per million)
    • If gain: rf_gain

Tuning and Using the Spectrum Analyzer

Set the following parameters in the QT GUI Sink

  • Center Frequency (Hz): tuning
  • Bandwidth (Hz): samp_rate
  • Show RF Freq: Yes

The analyzer can be tuned with the Frequency control widget. If you check the "Display RF Frequencies" box in the run-time GUI window, then the scale on the 'Frequency Display' and 'Waterfall Display' tabs will show the actual frequencies with the tuned frequency in the center.

Building an FM Radio Receiver

Now that you have a basic receiver application running with a real-time display of your received data, let's build a useful application! Leave your current flowgraph in place. We will simply add more functionality rather than replacing what is already there.

Choose the flowgraph below for your hardware device.

UHD / USRP

USRP FM fg.png


ADALM-PLUTO

Pluto FM fg.png


RTL-SDR dongle

RTLSDR receive fg.png


FunCube Pro+

FunCube FM fg.png