Software Defined Radio
Software Defined Radio
Software-defined radio (SDR) along with its hardware can be used to illustrate examples of the physical layer
implementation in the OSI model.
SDR is a radio communication system in which components that have been traditionally implemented in hardware
(e.g. mixers, filters, amplifiers, modulators/demodulators, detectors, etc.) are instead implemented by means of
software on a personal computer or embedded system.
SDRs turn a standard PC into a next-generation wireless prototyping tool. However, RF (Radio Frequency) front-
end, ADC (Analog to Digital Converters) and DAC (Digital to Analog Converters) are still needed. As it is indeed
the always the case for the physical layer, it is not possible with SDR to totally bypath the hardware.
Figure 1 and Figure 2 show a traditional radio receiver and the equivalent receiver implemented on SDR, respectively.
SDR uses RF to IF, ADC and DAC and an FPGA unit. Our aim is to program the FPGA unit to perform what a
typical radio does.
Spread spectrum and ultrawideband techniques allow several transmitters to transmit in the same place on
the same frequency with very little interference, typically combined with one or more error detection and
correction techniques to fix all the errors caused by that interference.
Software defined antennas adaptively "lock onto" a directional signal, so that receivers can better reject
interference from other directions, allowing it to detect fainter transmissions.
Cognitive radio techniques: each radio measures the spectrum in use and communicates that information
to other cooperating radios, so that transmitters can avoid mutual interference by selecting unused
frequencies. Alternatively, each radio connects to a geolocation database to obtain information about the
spectrum occupancy in its location and, flexibly, adjusts its operating frequency and/or transmit power not
to cause interference to other wireless services.
Dynamic transmitter power adjustment, based on information communicated from the receivers, lowering
transmit power to the minimum necessary, reducing the near-far problem and reducing interference to
others, and extending battery life in portable equipment.
Wireless mesh network where every added radio increases total capacity and reduces the power required at
any one node.[3] Each node only transmits loudly enough for the message to hop to the nearest node in
that direction, reducing near-far problem and reducing interference to others.
You can present applications with real-world signals such as multiple input, multiple output (MIMO) and
LTE/WiFi testbed.
Cautions:
Never allow metal objects to touch the circuit board while powered.
Never allow the board to directly or indirectly come into contact with any voltage spikes.
Never allow any water, or condensing moisture, to come into contact with the boards.
How to install:
Method1:
https://kb.ettus.com/Live_SDR_Environment
Method2:
https://kb.ettus.com/Building_and_Installing_the_USRP_Open_Source_Toolchain_(UHD_and_GNU_Radio)_o
n_Windows
When the waves reach the microphone, it converts the varying pressure into an electrical signal, a
variable voltage:
Now that the signal is electrical, we can work with it. The audio signal, at this point, is analog - a
computer can't yet deal with it; for computational processing, a signal has to be digital, which means
two things:
It can only be one of a limited number of values.
It only exists for a non-infinite amount of time.
This digital signal can thus be represented by a sequence of numbers, called samples. A fixed time
interval between samples leads to a signal sampling rate.
The process of taking a physical quantity (voltage) and converting it to digital samples is done by an
Analog-to-Digital Converter (ADC). The complementary device, a Digital-to-Analog Converter
(DAC), takes numbers from a digital computer and converts them to an analog signal.
Now that we have a sequence of numbers, our computer can do anything with it. It might, for example,
apply digital filters, compress it, recognize speech, or transmit the signal using a digital link.
Applying Digital Signal Processing to Radio Transmissions
The same principles as for sounds can be applied to radio waves:
A signal, here electromagnetic waves, can be converted into a varying voltage using an antenna.
This electrical signal is then on a 'carrier frequency', which is usually several Mega- or even Gigahertz.
Using different types of receivers (e.g. Superheterodyne Receiver, Direct Conversion, Low
Intermediate Frequency Receivers), which can be acquired commercially as dedicated software radio
peripherals, are already available to users (e.g. amateur radio receivers connected to sound cards) or
can be obtained when re-purposing cheaply available consumer digital TV receivers (the
notorious RTL-SDR project).
A modular, flowgraph based Approach to Digital Signal Processing
To process digital signals, it is straight-forward to think of the individual processing stages (filtering,
correction, analysis, detection...) as processing blocks, which can be connected using simple flow-
indicating arrows:
When building a signal processing application, one will build up a complete graph of blocks. Such a
graph is called flowgraph in GNU Radio.
GNU Radio is a framework to develop these processing blocks and create flowgraphs, which
comprise radio processing applications.
As a GNU Radio user, you can combine existing blocks into a high-level flowgraph that does
something as complex as receiving digitally modulated signals and GNU Radio will automatically
move the signal data between these and cause processing of the data when it is ready for processing.
GNU Radio comes with a large set of existing blocks. Just to give you but a small excerpt of what's
available in a standard installation, here's some of the most popular block categories and a few of
their members:
Waveform Generators
Constant Source
Noise Source
Signal Source (e.g. Sine, Square, Saw Tooth)
Modulators
AM Demod
Continuous Phase Modulation
PSK Mod / Demod
DPSK Mod / Demod
GMSK Mod / Demod
QAM Mod / Demod
WBFM Receive
NBFM Receive
Instrumentation (i.e., GUIs)
Constellation Sink
Frequency Sink
Histogram Sink
Number Sink
Time Raster Sink
Time Sink
Waterfall Sink
Math Operators
Abs
Add
Complex Conjugate
Divide
Integrate
Log10
Multiply
RMS
Subtract
Channel Models
Channel Model
Fading Model
Dynamic Channel Model
Frequency Selective Fading Model
Filters
Band Pass / Reject Filter
Low / High Pass Filter
IIR Filter
Generic Filterbank
Hilbert
Decimating FIR Filter
Root Raised Cosine Filter
FFT Filter
Fourier Analysis
FFT
Log Power FFT
Goertzel (Resamplers)
Fractional Resampler
Polyphase Arbitrary Resampler
Rational Resampler (Synchronizers)
Clock Recovery MM
Correlate and Sync
Costas Loop
FLL Band-Edge
PLL Freq Det
PN Correlator
Polyphase Clock Sync
Using these blocks, many standard tasks, like normalizing signals, synchronization, measurements,
and visualization can be done by just connecting the appropriate block to your signal processing
flow graph.
Also, you can write your own blocks, that either combine existing blocks with some intelligence to
provide new functionality together with some logic, or you can develop your own block that
operates on the input data and outputs data.
Thus, GNU Radio is mainly a framework for the development of signal processing blocks and their
interaction. It comes with an extensive standard library of blocks, and there are a lot of systems
available that a developer might build upon. However, GNU Radio itself is not a software that is
ready to do something specific -- it's the user's job to build something useful out of it, though it
already comes with a lot of useful working examples. Think of it as a set of building blocks.
Tutorial: GNU Radio Companion
Objectives
Create flowgraphs using the standard block libraries
Learn how to debug flowgraphs with the instrumentation blocks
Understand how sampling and throttle works in GNU Radio
Learn how to use the documentation to figure out block's functionality
The tutorial is meant to be hands on, so please take a few breaks from reading here and there to
experiment. We will reiterate that these tutorials as simply meant as guides and that the best way to
learn something is to try it out: come up with a question, think of a possible solution, and try it out.
Let us begin by starting up the GRC! This is usually done by opening up a terminal window (ctrl+alt+t
in Ubuntu) and typing:
$ gnuradio-companion
If you are unable to open GRC then you need to go back to Installing GR and troubleshoot the
installation.
Searching for Blocks
The Library contains the different blocks installed in the GRC block paths. Here we find blocks that
are preinstalled in GNU Radio and blocks that are installed on the system. At first it seems daunting
to look for blocks. For instance, if we want to generate a waveform, what category should we look in?
We see there is a Waveform Generators category, okay not bad. But what if we wanted to find some
way to display our data but aren't sure of the best way to display it yet? We know from tutorial 1 that
this is known as a sink; however, looking through the list there is no Sinks category. The solution is
to use the Search feature by either clicking the magnifying glass icon or typing Ctrl+f and then start
typing a keyword to identify the block. We see a white box appear at the top of the Library with a
cursor. If we type "sink", we can find all the blocks that contain the words "sink" and the categories we
will find each block in.
For now, let's add the block called QT GUI Time Sink by clicking on its name and dragging it to the
Workspace or double-clicking on its name for it to be placed automatically in the Workspace.
Modifying Block Properties
The workspace (main area of the screen) contains all of our blocks that make up our flowgraph, and
inside each block we can see all the different block parameters. There is, however, one special block
that each new flowgraph starts with and is required to have, called the Options Block. Let us double-
click on the Options Block to examine its properties. We see a window as below:
These block properties can be changed from the defaults to accomplish different tasks. Let's remove
part of the current name and notice the ID turns blue. This color means that the information has been
edited, but has not been saved. Let us change the parameter Window Size to "300,300" and click OK.
Yikes! Almost all the workspace got cutoff! Let's do a ctrl+z to go back to our default size. If we go
back to the Options Block properties, we can see that there are different tabs and one is titled
documentation.
If we read a couple lines, we can see that the property ID is actually used for the name of the python
file the flowgraph generates.
So now let's remove the entire ID string. Notice now that at the bottom appears an error
message. Also notice that the parameter ID is now red to show us exactly where the error occured.
To keep things organized, let us change the ID to "tutorial_two_1". Let us also make sure that the
property Generate Options is set to "QT GUI" since we are using a QT GUI sink and not a WX GUI
sink. Newer versions of GNU Radio default to using QT GUI. The ID field allows us to more easily
manage our file space. While we save the GRC flowgraph as a <filename>.grc, generating and
executing this flowgraph produces another output. GRC is a graphical interface that sits on top of the
normal GNU Radio programming environment that is in Python. GRC translates the flowgraph we
create in the GUI canvas here into a Python script, so when we execute a flowgraph, we are really
running a Python program. The ID is used to name that Python file, saved into the same directory as
the .grc file. By default, the ID is top_block and so it creates a file called top_block.py. Changing
the ID allows us to change the saved file name for better file management.
Another result of this GRC-Python connection is that GRC is actually all Python. In fact, all entry
boxes in block properties or variables that we use are interpreted as Python. That means that we can
set properties using Python calls, such as calling a numpy or other GNU Radio functions. A common
use of this is to call into the filter.firdes filter design tool from GNU Radio to build our filter taps.
Another key to notice is the different colors present in the fields we can enter information. These
actually correspond to different data types which we will cover later in this tutorial.
My First Flowgraph
Now that we have a better understanding of how to find blocks, how to add them to the workspace,
and how to edit the block properties, let's proceed to construct the following flowgraph of a Signal
Sourcebeing sent to a Throttle Block and then to our Time Sink by clicking on the data type colored
ports/tabs one after the other to make connections:
This section of the interface contains commands present in most software such as new, open, save,
copy, paste. Let's begin by saving our work so far and titling our flow graph tutorial_two. Important
tools here are Generate flowgraph, Execute flowgraph, and Kill flowgraph all accessible through F5,
F6, and F7 respectively. A good reference is available in Help->Types that shows the color mapping
of types which we will look into later.
A Note on Generate Options
Let us click the Generate button and turn our eyes to the Terminal at the bottom of the window. We
should see it generated a Python file with the same name as the ID from our Options Block. The
terminal displays important messages such as errors and warnings. Two common errors are when we
mismatch the generate options with the graphical tools we are using. For instance, if we were to use
the WX GUI as our generate options but have a QT GUI graphic then we would get in the terminal:
And if we were to use the QT GUI generate options with a WX GUI graphic we would get in the
terminal:
It should be noted that we are doing away with WX GUI in future releases so only use QT GUI.
Examining the Output
Let's go ahead and Execute the flowgraph to see our sine wave.
We should get the above which is a complex sinusoid of the form e jwt. Let us keep things simple by
avoiding complex signals for now. First we want to kill the flowgraph with the Kill flowgraph button
or by simply closing the Time Sink GUI. Now is a good time to go over data types in GNU Radio by
opening up the Help->Types window.
We can see common data types seen in many programming languages. We can see our blocks (blue
ports) are currently Complex Float 32 type which means they contain both a real and imaginary part
each being a Float 32 type. We can reason that when the Time Sink takes in a complex data type, it
outputs both the real and imaginary part on separate channels. So let's now change the Signal Source to
a float by going into its block properties and changing the Output Type parameter. We see that its
port turns orange, there is now a red arrow pointing to the Throttle Block, and in the Toolbar there
is a red "-" button (red) that reads "View flow graph errors". Let's go ahead and click that.
We see that in the specified connection, there is size mismatch. This is due to our data type size
mismatch. GNU Radio will not allow us to chain together blocks of different data sizes, so let's change
the data type of all of our subsequent blocks. We can now generate and execute as before.
We now see our sine wave on one channel. We can click on the screen and move the mouse to zoom
and rescale.
A More Complex Flowgraph
Now that we are able to create flowgraphs on our own, lets try creating a more complicated flowgraph
with many specific parameters. This example flowgraph demonstrates many new concepts in GNU
Radio like using tabbed windows and QT GUI Ranges. Note that not all block parameters are
displayed in the main window, so use the text below (not just the screenshot) to set the parameters of
each block.
Time & Frequency Flowgraph
Detailed Changes:
- We are starting a new flowgraph with ID "tutorial_two_3"
- In QT GUI Tab Widget, ID to "tab", Num Tabs to 2, Label 0 to "Time", Label 1 to "Frequency"
- In QT GUI Range, ID to "samp_rate", Default Value to "5*freq", Start to "0.5*freq", Stop to
"20*freq", Step to "200"
- In Variable, ID to "freq", Value to "2e3"
- In Signal Source, Frequency to "freq", Waveform to "Sine"
- In QT GUI Time Sink, GUI Hint to "tab@0". In QT GUI Frequency Sink, GUI Hint to "tab@1"
- In Throttle, Sample Rate to 32e3 (more on why later)
Once we have verified our changes, let's Generate, and Execute. It should produce a window that has
two tabs, one showing the time domain and one showing the frequency domain. There should also be
a slider at the bottom to control the sample rate (of the signal source) in realtime. Changing this slider
should change the observed frequency in the time and frequency sinks.
Sampling rate is an interesting subject in GNU Radio -- and, indeed, any software radio platform.
Please see the Extras on Sampling Rate page that explores how changing the sample rates in the above
flowgraph affects the signals.
Conclusion
And that is it for now with GRC. Let us know your thoughts before going on to the python tutorial.
Hint: you have both Tutorials and Documentation of GNU Radio on the desktop of the bootable
system. Please get also familiar with the Documentation.
Exercise: Follow the link below to get familiar with the usage of the hardware and using the hardware
to listen to the RTS radio channel. Plot the constellation diagram.
https://wiki.gnuradio.org/index.php/Guided_Tutorial_Hardware_Considerations
Check point: Please show the outcome of the exercise to the lab instructor.
Optional task: Try to receive the Wifi signal in the environment and plot the spectrum.
Some general resources:
http://sdr.ninja/ https://www.rtl-sdr.com/
https://wiki.gnuradio.org/index.php/Guided_Tutorial_Introduction
https://wiki.gnuradio.org/index.php/Guided_Tutorial_GRC