lab2
lab2
(real/imaginary) format and most of the signal pro- band power that might interfere with users of other
cessing operates on these complex signals. channels and receivers use them to reject signals
As an example, in this lab we will translate the fre- present on other channels.
quency of signal by multiplying it by a complex sinu- Low-pass filters are also used when changing the
soid. GNU Radio also includes blocks that convert sampling rate of digitized signals. Increasing (“inter-
between signal of different types (e.g. byte, float and polation”) or decreasing (“decimation”) the sampling
complex). rate requires post- or pre-low-pass filtering the signal
to avoid aliasing.
ML PRBS There are many digital filter types (IIR, FIR), archi-
tectures (parallel, cascade, FFT) and design methods
In evaluating, testing and implementing communi-
(window, mini-max). In this lab we will use a simple
cation systems we often need a signal that has statis-
window-based design of an FIR filter to interpolate
tics similar to that of a random binary source but
a low-bandwidth baseband signal’s sampling rate to
which is deterministic. This is called a pseudo-
the higher rate required by the SDR transmitter.
random bit sequence (PRBS).
The most common type of PRBS is the Maximal-
Length PRBS (ML-PRBS) which has certain desirable Variables and GUI Widgets
properties, including having the maximum possible
period for a given generator complexity. A GNU Radio flowgraph is actually a Python script.
An ML-PRBS can be generated using flip-flops and This allows us to embed variables (using the “Vari-
xor gates to compute feedback in a circuit called a able” block) and arbitrary Python code into a flow-
linear-feedback shift register (LFSR). graph.
It’s also possible to include blocks that create
Filters user interface components (“widgets”) that are active
while the block is running. These can be used to dis-
The radio spectrum is divided into bands which are play waveforms or frequency spectra and to change
allocated to different uses (broadcasting, cellular, values of variables 2 . These variables can be used
radio-navigation, etc.). Each band is typically divided in expressions that configure the operation of blocks.
into smaller ranges, called channels with each chan- You saw examples of this in the UI presented by the
nel allocated to a different set of users.
Filtering is a important part of most communica- 2
Parameters whose names are underlined in a block’s prop-
tion systems. Transmitters use them to limit out-of- erties dialog box can be updated during flowgraph execution.
2
previous lab which was implemented using GNU Ra- Configure the Flowgraph
dio.
Use the File ▶ Open menu item to start a new QT
GUI flowgraph. Then add, configure and connect the
Procedure
following blocks:
In this lab you will practice using GNU radio by
building a transmitter that incorporates some typical Variable Add a second variable with ID interp.
blocks. The flowgraph generates a ML-PRBS, mul- This will be used to set the interpolation ratio
tiplies it by a complex exponential to shift the fre- between baseband samples and RF samples.
quency and then interpolates to increase the sam-
pling rate. Add a third variable with ID bb_rate that has
The diagram in figure 1 shows the flowgraph. the value samp_rate/interp. Note that the
value of a variable can be set to an arbitrary
Using GRC
Python expression. The code generated for each
block is shown in the “Generated Code” tab.
Start GRC. Under the View menu enable the Block
Tree Panel, Console Panel and Variable Editor. Make GLFSR Source This block (Galois LFSR) generates
sure ‘Hide Variables’ is not checked. a PRBS. Configure this block as follows:
The easiest way to add a block is to search for it by
name. Click on the magnifying glass icon ( ) on the
menu bar or type Control-F. Type part of the block
name and double-click on the desired block name.
This adds it to the flowgraph. You can them move the
block by dragging it (any connections will follow).
To connect block outputs to inputs click on the out-
put port and then click on the input port you want to
connect it to.
As in any diagram, the blocks should be arranged
Degree, 𝑁, is the number of bits in the shift reg-
so that the logical flow is left-to-right and top-to-
ister. The PRBS period is 2 − 1 bits. Configure
bottom whenever possible.
𝑁 = 3 which will generate a PRBS with a pe-
Samples flowing between blocks can be of differ-
riod 7 bits. Mask defines the LFSR taps. If speci-
ent types. Bits are typically transferred in the least-
fied as 0 a suitable generator polynomial for the
significant bit of a Byte type and signal samples are
specified degree will be chosen. Note that float
typically Float or Complex types. In GRC the color
outputs have values ±1 while byte outputs have
of the input and output connectors reflects the signal
values 0 or 1.
type (e.g. orange for floats, blue for complex).
If there is a mismatch between the signal types the
connector will be drawn in red. Type Conversions Type conversions are some-
You can double-click on a block to open up its times required. For example, the GLFSR
properties dialog box. This allows you to configure Source above is configured to output floats but
the input and output types and other aspects of the these need to be converted to Complex values.
block’s operation. The block’s title and some of the Add a Float To Complex block that sets the
block’s properties are displayed inside the block in imaginary component to zero by connecting a
the flowgraph. Constant Source with value 0.
Some blocks define data structures rather than
process samples. An example is Variable blocks that Signal Source Add a [Co-]Sinusoidal signal source
set the value of a variable. This variable can be used with a Complex output whose amplitude is
when configuring other blocks. By default a variable, 1 and whose frequency is set by the variable
samp_rate, is included in a new flowgraph. f_offset. It is configured as follows:
3
that is created when the flowgraph executes. In
addition to input types, ranges, labels, etc, the
GUI Hint provides some control over the posi-
tioning of the GUI elements (and use of tabs).
For example, a hint of [1,2] means to place that
GUI element on the first row, second column.
filter.firdes.low_pass_2(1,samp_rate,
0.5*samp_rate/interp,0.02*samp_rate,60)
4
Select Run ▶ Execute, press F6, or press on the
run ( ) icon. This will convert the flowgraph to a
Python script and run it.
To capture the GNU Radio Companion GUI you
can use the Windows Snipping Tool. To capture the
spectrum analyzer display plug a USB flash drive into
the connector on the analyzers front panel4 . Select
View the RF Spectrum File (Shift-7) ▶ Directory Management and select USB
as the Current Location. Select Back and Save ▶ Save
Screen as JPEG to save an image file showing the spec-
Configure the spectrum analyzer for a center fre- trum analyzer display.
quency of 222.5 MHz, a span of 5 MHz, reference
level of 10 dBm and resolution/video bandwidths of
10 kHz and 3 kHz respectively. Additional Test Cases
Capture the baseband spectrum shown on the Make the following changes and capture the result-
GNU Radio Companion run-time window (“Top ing baseband signal and RF spectrum:
Block”) and the RF spectrum as displayed on the
spectrum analyzer: • shift the signal up in frequency by 1 MHz using
the GUI slider
Lab Report
4
Spectrum analyzers with older (version 1.x) firmware may
show errors when trying to save to USB drives lager than 2 GB.
The instructor may be able to lend you a small USB drive or
(worst-case) you can crop a photo of the screen taken with your
phone.
5
• What is the result of multiplying 𝑒
by 𝑒 ? What is/are the resulting fre-
quency(ies)? How does this differ from
multiplying two real sinusoids?