0% found this document useful (0 votes)
1K views8 pages

Gnu Radio Tutorial

1. GNU Radio Companion (GRC) is a graphical interface that allows users to build signal processing flow graphs in GNU Radio. This tutorial introduces users to using GRC through a series of exercises. 2. The tutorial walks through creating a simple flow graph with a signal source, throttle, and scope sink to display a 1 kHz sinusoid. 3. Additional exercises explore manipulating sample rates, adding filters and additional signal sources, and observing the output on other sinks like FFT and audio sinks. The tutorial introduces key GNU Radio blocks and concepts.

Uploaded by

Tuan Do Trong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views8 pages

Gnu Radio Tutorial

1. GNU Radio Companion (GRC) is a graphical interface that allows users to build signal processing flow graphs in GNU Radio. This tutorial introduces users to using GRC through a series of exercises. 2. The tutorial walks through creating a simple flow graph with a signal source, throttle, and scope sink to display a 1 kHz sinusoid. 3. Additional exercises explore manipulating sample rates, adding filters and additional signal sources, and observing the output on other sinks like FFT and audio sinks. The tutorial introduces key GNU Radio blocks and concepts.

Uploaded by

Tuan Do Trong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Using GNU Radio Companion: Tutorial 1

GNU Radio Companion (GRC) is a graphical user interface that allows you to build GNU Radio
flow graphs. It is an excellent way to learn the basics of GNU Radio. This is the first in a series
of tutorials that will introduce you to the use of GRC.
1. Open a terminal window using: Applications > Accessories > Terminal. At the prompt type:
grc
An untitled GRC window similar to the one below should open.

2. Double click on the Options block. This block sets some general parameters for the flow
graph. Leave the ID as top_block. Type in a project title (such as Tutorial 1) and author.
Set Generate Options to WX GUI, Run to Autostart, and Realtime Scheduling to Off. Then
close the properties window. The other block that is present is the Variable block. It is used
to set the sample rate. That will be discussed later in the tutorial.
3. On the right side of the window is a list of the blocks that are available. By expanding any of
the categories (click on triangle to the left) you can see the blocks available. Explore each of
the categories so that you have an idea of what is available.

4. Open the Sources category and double click on the Signal Source. Note that a Signal Source
block will now appear in the main window. Double click on the block and the properties
window will open. Adjust the settings to match those as shown in the figure below and close
the window. This Signal Source is now set to output a real valued 1KHz sinusoid with an
amplitude of .5.

5. In order to view this wave we need one of the graphical sinks. Expand the Graphical Sink
category and double click on the Scope Sink. It should appear in the main window. Double
click on the block and change the Type to Float. Leave the other Parameters at their default
values and close the properties window.
6. In order to connect these two blocks, click once on the out port of the Signal Source, and
then once on the in port of the Scope Sink. The following flow graph should be displayed.

7. You may have noticed a warning in the message window indicating that the flow graph may
not have flow control. Add a Throttle block between the source and the sink as shown in the
figure below. Make sure to change the Throttle Type to Float. Note that before you do that,
the Generate flow graph icon cannot be selected. This is because there is an error in the flow
graph. Generate and execute the flow graph to confirm that it still works.

8. In order to observe the operation of this simple system we must generate the flow graph and
then execute it. Click first on the Generate the flow graph icon. A box will come up in
which you enter the name of the file. Name this file: tutorial1.grc and save.

9. Click the Execute the flow graph icon. A scope plot should open displaying several cycles
of the sinusoid. Confirm that the frequency and amplitude match the value that you expect.
Experiment with the controls on the scope plot.
10. Change the Channel Options, Marker setting to Dot Large. Now you can see the actual
sample values. Recall that the Variable block set the sampling rate to 32000 samples/second
or 32 samples/ms. Note that there are in fact 32 samples within one cycle of the wave.
11. Close the Scope Plot and reduce the sample rate to 10000 by double clicking on the Variable
block. Re-generate and execute the flow graph. Note that there are now fewer points per
cycle. How low can you drop the sample rate? Recall that the Nyquist sampling theorem
requires that we sample at more than two times the highest frequency. Experiment with this
and see how the output changes as you drop below the Nyquist rate.
12. Close the Scope Plot and change the sample rate back to 32000. Add an FFT Sink (under
Graphical Sinks) to your window. Change the Type to Float and leave the remaining
parameters at their default values.
13. Connect this to the output of the Signal Source by clicking on the out port of the Signal
Source and then the in port of the FFT Sink. Generate and execute the flow graph. You
should observe the scope as before along with an FFT plot correctly showing the frequency
of the input at 1KHz. Close the output windows.
14. Explore the other Graphical Sinks (Number Sink, Waterfall Sink, and Histo Sink) to see how
they display the Signal Source.
15. Create the flow graph shown below. The Audio Sink is found in the Sinks category.
Generate and execute the flow graph. The graphical display of the scope and FFT should
open as before. However, now you should also hear the 1KHz tone. The Audio Sink block

directs the signal to the audio card of your computer. Depending on the sampling rate of the
audio card in your computer, you may get an error message in the GRC message window:
Audio_alsa_sink[hw:0,0]: unable to support sampling rate
32000, card requested 44100 instead.
If you do see a message similar to this, stop the execution and double click on the variable
block to change the sample rate to 44100 (or whatever your error message indicates).
Generate and execute the flow graph again and the error message should be gone.

16. Construct the flow graph shown below. Set the sample rate to 32000. The two Signal
Sources should have frequencies of 1000 and 800, respectively. The Add block is found in
the Operators category.

17. Generate and execute the flow graph. On the Scope plot you should observe a waveform
corresponding to the sum of two sinusoids. On the FFT plot you should see components at
both 800 and 1000 Hz. Unfortunately, the FFT plot does not provide enough resolution to
clearly see the two distinct components. Note that the maximum frequency displayed on this
plot is 16KHz. This is one-half of the 32KHz sample rate. In order to obtain better
resolution, we can lower the sample rate. Try lowering the sample rate to 10KHz.
18. Replace the Add block with a Multiply block. What output do you expect from the product
of two sinusoids? Confirm your result on the Scope and FFT displays.
19. Modify the flow graph to include a Low Pass Filter block as shown in the figure below. This
block is found in the Filters category and is the first Low Pass Filter listed. Recall that the
Multiply block outputs a 200Hz and a 1.8KHz sinusoid. We want to create a filter that will
pass the 200Hz and block the 1.8KHz component. Set the low pass filter to have a cutoff
frequency of 1KHz and a transition width of 200 Hz. Use a Rectangular Window. Generate
and execute the flow graph. You should observe that only the 200Hz component passes
through the filter. Experiment with the High Pass Filter.

20. Using the same flow graph, change the sample rate variable to 20000. Change the
Decimation in the Low Pass Filter to 2. Decimation decreases the number of samples that
are processed. A decimation factor of two means that the output of the filter will have a
sample rate equal to one-half of the input sample rate, or in this case only 10000 samples/sec.
This is a sufficient sample rate for the frequencies that we are dealing with. Generate and
execute the flow graph. What frequency do you observe on the FFT? Measure it precisely
by letting the cursor hover over the peak of the observed component.
21. You should have observed that the FFT is now measuring a signal around 400 Hz, rather than
the expected 200Hz. Why is this error occurring? It is because the sample rate on the FFT
has not been adjusted to properly measure its input. Double click on the FFT Sink block and
change the sample rate to samp_rate/2. Generate and execute the flow graph. You should
now read the correct frequency.

22. Open a file browser in Ubuntu (Places Home Folder). Go to the directory that contains
the GRC file that you have been working on. If you are unsure as to where this is, the path to
this file is shown in the bottom portion of the GRC window. In addition to saving a .grc
file with your flow graph, note that there is also a file titled top_block.py. Double click on
this block. You will be given the option to Run or Display this file. Select Display. This is
the Python file that is generated by GRC. It is this file that is being run when you execute the
flow graph. You can modify this file and run it from the terminal window. This allows you
to use features that are not included in GRC. Keep in mind that every time you run your flow
graph in GRC, it will overwrite the Python script that is generated. So, if you make changes
directly in the Python script that you want to keep, save it under another name.

Common questions

Powered by AI

To visualize both the time-domain and frequency-domain representation of a 1KHz sinusoidal signal in GNU Radio Companion, one must first add a Signal Source block configured to generate a 1KHz sinusoid. A Scope Sink block is added to visualize the time-domain waveform. Meanwhile, an FFT Sink block is required to analyze the frequency domain. The Output settings for both Sinks should be set to Float. By connecting these blocks appropriately and executing the flow graph, users can view the sinusoid in both domains .

To resolve an Audio Sink sampling rate error in GNU Radio Companion, you should adjust the sample rate in the Variable block to match the rate required by your audio card. For example, if the audio card's preferred rate is 44100 Hz, but the GRC project's sampling rate is 32000 Hz, you need to change the project’s sample rate to 44100 Hz. This ensures compatibility and eliminates the error .

The Throttle block in a GNU Radio Companion flow graph plays a critical role in controlling the flow of data within the application, especially when the flow graph includes data sources without inherent control mechanisms, such as the Signal Source. If the Throttle block is omitted, the computer can become overwhelmed by the excessive data rate, as there is no hardware clock to limit the processing speed, potentially leading to unresponsive behavior. Including the Throttle block with a set rate (e.g., matching the sample rate) ensures that CPU resources are appropriately managed .

In GNU Radio Companion, using an Add block with two sinusoids results in a waveform that is the arithmetic sum of the inputs—in frequency domain terms, the FFT plot will show two distinct peaks corresponding to the individual frequencies. Conversely, using a Multiply block generates a product that produces new frequencies (sum and difference of originals), specifically demonstrated by a 200Hz and a 1.8KHz sinusoid in the example from the tutorial. The time-domain signal is modulated, and the FFT output displays these modulation frequencies, illustrating key differences in signal processing outcomes between these operations .

Editing the 'top_block.py' file allows users to incorporate Python code and features not directly accessible through the GRC GUI, such as advanced signal processing routines and conditional logic. However, since running the flow graph in GRC regenerates the file, users should save modifications under a different filename to prevent overwriting their changes. This approach provides flexibility for complex designs and the incorporation of custom algorithms while safeguarding work from unintentional data loss due to GRC's automatic regeneration process .

Changing the sample rate in GNU Radio Companion affects the number of data points per cycle in the flow graph's output. When the sample rate is reduced below the Nyquist rate, which is twice the highest frequency of the signal, less than two data points per cycle are captured, leading to aliasing and incorrect representation of the signal. By experimenting with the sample rate, users can see how dropping it below the Nyquist threshold impacts signal fidelity, demonstrating the theorem's principle .

When combining multiple Signal Sources with different frequencies in GRC, the sample rate determines the Nyquist limit, affecting both the maximum frequency that can be accurately represented and the resolution of the Scope and FFT displays. For optimal resolution, the sample rate should be set to more than twice the highest frequency component. Lowering the sample rate can increase the resolution of distinct frequency components in the FFT, but should stay above the Nyquist rate to avoid aliasing. Adjustments should be managed carefully to balance between clarity and computational efficiency .

The initial setup steps for a GNU Radio Companion (GRC) project involve opening a terminal, typing 'grc' to start the GRC window, and configuring the Options block. The Options block requires setting a Project Title and Author, and configuring Generate Options to WX GUI, Run to Autostart, and Realtime Scheduling to Off. These steps are necessary because they establish the basic parameters and environment in which the flow graph will be built and executed, ensuring that the project is properly titled and the GUI can be seen on execution .

Implementing a Low Pass Filter in a GNU Radio Companion flow graph isolates a specific frequency component by attenuating frequencies above the designated cutoff. In the given scenario, setting a cutoff frequency at 1KHz with a 200Hz transition width using a Rectangular Window enables the passage of a 200Hz component while blocking a 1.8KHz component. This demonstrates filter design principles within GRC, showcasing how frequency components can be selectively isolated and modified, a fundamental aspect of signal processing .

Adjusting the sample rate on the FFT Sink in GRC is crucial when using a Decimation factor because the decimation reduces the number of samples, halving the effective sample rate as processed by the FFT. Without updating it to sample_rate/2, the frequency measurements displayed by the FFT will be inaccurate, potentially doubling the observed frequencies, as seen when measuring around 400Hz instead of 200Hz. This adjustment ensures that the FFT results correctly reflect the input signals' characteristics .

You might also like