Editing Guided Tutorial GRC

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
[[Category:Guided Tutorials]]
+
<. [[Guided_Tutorial_Introduction|Previous: Introduction]]
 +
>. [[Guided_Tutorial_GNU_Radio_in_Python|Next: Programming GNU Radio in Python]]
  
 
= Tutorial: GNU Radio Companion =
 
= Tutorial: GNU Radio Companion =
Line 13: Line 14:
  
 
* Basic knowledge of git
 
* Basic knowledge of git
* [[InstallingGR|GNU Radio 3.8.0.0 or later]]
+
* [[InstallingGR|GNU Radio 3.7.4 or later]]
* [[Guided_Tutorial_Introduction|A brief introduction to GNU Radio, SDR, and DSP]]
+
* [[Guided_Tutorial_Introduction|Tutorial 1: Intro to GNU Radio]]
  
  
Line 23: Line 24:
 
We have seen in Tutorial 1 that GNU Radio is a collection of tools that can be used to develop radio systems in software as opposed to completely in hardware. In this tutorial, we start off simple and explore how to use the GNU Radio Companion (GRC), GNU Radio's graphical tool, to create different tones. We should keep in the back of our mind that GRC was created to simplify the use of GNU Radio by allowing us to create python files graphically as opposed to creating them in code alone (we will discuss this more later).
 
We have seen in Tutorial 1 that GNU Radio is a collection of tools that can be used to develop radio systems in software as opposed to completely in hardware. In this tutorial, we start off simple and explore how to use the GNU Radio Companion (GRC), GNU Radio's graphical tool, to create different tones. We should keep in the back of our mind that GRC was created to simplify the use of GNU Radio by allowing us to create python files graphically as opposed to creating them in code alone (we will discuss this more later).
  
The first thing to cover is the interface. There are five parts: <span style="color:gray">Library</span>, <span style="color:red">Toolbar</span>, <span style="color:green">Terminal</span>, <span style="color:blue">Workspace</span> and <span style="color:yellow"> variables.
+
The first thing to cover is the interface. There are four parts: <span style="color:gray">Library</span>, <span style="color:red">Toolbar</span>, <span style="color:green">Terminal</span>, and <span style="color:blue">Workspace</span>.
  
 
[[File:unity-2d-shell_008.png|600px|]]
 
[[File:unity-2d-shell_008.png|600px|]]
Line 46: Line 47:
 
[[File:properties_options.png|400px|]]
 
[[File:properties_options.png|400px|]]
  
These block properties can be changed from the defaults to accomplish different tasks. Let's remove part of the current name and notice the <span style="color:red">ID turns blue</span>. This color means that the information has been edited, but has not been saved. If we go back to the '''Options Block''' properties, we can see that <span style="background:yellow">there are different tabs and one is titled documentation</span>.
+
These block properties can be changed from the defaults to accomplish different tasks. Let's remove part of the current name and notice the <span style="color:red">ID turns blue</span>. This color means that the information has been edited, but has not been saved. Let us <span style="color:green">change the parameter '''Window Size''' to &quot;300,300&quot;</span> 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 <span style="background:yellow">there are different tabs and one is titled documentation</span>.
  
 
[[File:id_python.png|400px|]]
 
[[File:id_python.png|400px|]]
Line 56: Line 57:
 
So now let's remove the entire ID string. Notice now that at the bottom appears an <span style="color:red">error message.</span> Also notice that the <span style="color:red">parameter '''ID''' is now red</span> to show us exactly where the error occured.
 
So now let's remove the entire ID string. Notice now that at the bottom appears an <span style="color:red">error message.</span> Also notice that the <span style="color:red">parameter '''ID''' is now red</span> to show us exactly where the error occured.
  
To keep things organized, let us change the '''ID''' to &quot;tutorial_two_1&quot;. Let us also make sure that the property '''Generate Options''' is set to &quot;QT GUI&quot; since we are using a graphical sink. 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 '''default''' and so it creates a file called '''default.py'''. Changing the '''ID''' allows us to change the saved file name for better file management. In GNUradio 3.8 you will get an error if you don't change the default id, so you need to change this id in order to run the flowgraph.
+
To keep things organized, let us change the '''ID''' to &quot;tutorial_two_1&quot;. Let us also make sure that the property '''Generate Options''' is set to &quot;QT GUI&quot; 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 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.
Line 75: Line 76:
  
 
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 <span style="color:blue">'''Generate''' flowgraph,</span> <span style="color:red">'''Execute''' flowgraph,</span> and '''Kill''' flowgraph all accessible through F5, F6, and F7 respectively. A good reference is available in '''Help'''-&gt;'''Types''' that shows the color mapping of types which we will look into later.
 
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 <span style="color:blue">'''Generate''' flowgraph,</span> <span style="color:red">'''Execute''' flowgraph,</span> and '''Kill''' flowgraph all accessible through F5, F6, and F7 respectively. A good reference is available in '''Help'''-&gt;'''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:
 +
 +
[[File:wxgen_qtflow.png|600px|]]
 +
 +
And if we were to use the QT GUI generate options with a WX GUI graphic we would get in the terminal:
 +
 +
[[File:qtgen_wxflow.png|600px|]]
 +
 +
It should be noted that we are doing away with WX GUI in future releases so only use QT GUI.
  
 
=== Examining the Output ===
 
=== Examining the Output ===
Line 96: Line 109:
 
We now see our sine wave on one channel. We can click on the screen and move the mouse to zoom and rescale.
 
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 ==
+
== Using the Companion ==
  
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.
+
Now that we are able to create flowgraphs on our own, we should explore some of the useful features in GNU Radio. Let's begin with the flowgraph below:
 +
 
 +
=== Time &amp; Frequency Flowgraph ===
  
 
[[File:tutorial_two_3.png|600px|tutorial_two_3.grc]]
 
[[File:tutorial_two_3.png|600px|tutorial_two_3.grc]]
Line 104: Line 119:
 
Detailed Changes:<br />
 
Detailed Changes:<br />
 
<span style="color:gray">- We are starting a new flowgraph with '''ID''' &quot;tutorial_two_3&quot;</span><br />
 
<span style="color:gray">- We are starting a new flowgraph with '''ID''' &quot;tutorial_two_3&quot;</span><br />
 +
<span style="background:yellow">- In '''QT GUI Tab Widget''', '''ID''' to &quot;tab&quot;, '''Num Tabs''' to 2, '''Label 0''' to &quot;Time&quot;, '''Label 1''' to &quot;Frequency&quot;</span><br />
 
<span style="color:blue">- In '''QT GUI Range''', '''ID''' to &quot;samp_rate&quot;, '''Default Value''' to &quot;5*freq&quot;, '''Start''' to &quot;0.5*freq&quot;, '''Stop''' to &quot;20*freq&quot;, '''Step''' to &quot;200&quot;</span><br />
 
<span style="color:blue">- In '''QT GUI Range''', '''ID''' to &quot;samp_rate&quot;, '''Default Value''' to &quot;5*freq&quot;, '''Start''' to &quot;0.5*freq&quot;, '''Stop''' to &quot;20*freq&quot;, '''Step''' to &quot;200&quot;</span><br />
 
<span style="color:green">- In '''Variable''', '''ID''' to &quot;freq&quot;, '''Value''' to &quot;2e3&quot;</span><br />
 
<span style="color:green">- In '''Variable''', '''ID''' to &quot;freq&quot;, '''Value''' to &quot;2e3&quot;</span><br />
 
<span style="color:purple">- In '''Signal Source''', '''Frequency''' to &quot;freq&quot;, '''Waveform''' to &quot;Sine&quot;</span><br />
 
<span style="color:purple">- In '''Signal Source''', '''Frequency''' to &quot;freq&quot;, '''Waveform''' to &quot;Sine&quot;</span><br />
</span><br />
+
<span style="color:red">- In '''QT GUI Time Sink''', '''GUI Hint''' to &quot;tab@0&quot;. In '''QT GUI Frequency Sink''', '''GUI Hint''' to &quot;tab@1&quot;</span><br />
 
- In '''Throttle''', '''Sample Rate''' to 32e3 (more on why later)
 
- 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.
+
Once we have verified our changes, let's '''Generate''', and '''Execute'''. We should produce the figure below:
 +
 
 +
Sampling rate is an interesting subject in GNU Radio -- and, indeed, any software radio platform. Please see the [[Guided_Tutorial_Extras_Sample_Rates|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 [https://wiki.gnuradio.org/index.php/Guided_Tutorial_GNU_Radio_in_Python python] tutorial.
 +
 
 +
=== Some Questions We Now Know! ===
 +
 
 +
1. If you put down a Signal Source and Abs block onto a canvas and connect them together without changing anything, an error occurs.<br />
 +
1a. How do we know there is an error?<br />
 +
1b. How do we figure out what the error is?<br />
 +
1c. How do we correct the error?
 +
 
 +
2. Say that we have two signals in our flowgraph that we wish to multiply together.<br />
 +
2a. How would we find a block that multiplies signals?<br />
 +
2b. How do we use the multiply block in GRC?<br />
 +
2c. What else can we do and change in this block?
 +
 
 +
3. If you saw a block had an unused, light gray input port on it, what kind of port would that be?
 +
 
 +
4. If you run a flowgraph and see the &quot;AttributeError: 'top_block_sptr' object has no attribute 'top_layout'&quot;, what is wrong and how can you fix it?
 +
 
 +
5. Signal processing questions
 +
 
 +
* Say we want to process speech audio data, and we have a microphone that won't let any frequencies in higher than 8 kHz. What is the minimum sampling rate we must use?
 +
* Now we want to digitize a radio signal that goes from 99.9 MHz to 100.1 MHz. How large is the minimum applicable sampling rate?
 +
 
 +
6. Answers
 +
* 16 kHz (2 * 8 kHz)
 +
* The bandwidth is 200 kHz, so we must sample at least at 400 kHz -- or 200 kHz if we have complex sampling, as we usually do in software radios.<br />
 +
 
 +
 
 +
=== Links to Further Resources ===
 +
 
 +
Links that are accessible without knowing much about how GNU Radio interacts with code. Not necessary to proceed.
  
Sampling rate is an interesting subject in GNU Radio -- and, indeed, any software radio platform. Please see the [[Sample_Rate_Tutorial|Sample rate tutorial]].
+
* [[TutorialsCoreConcepts|Core Concepts]]
 +
* [[Hardware|Hardware]]
 +
 
 +
[[Category:Guided Tutorials]]
 +
 
 +
 
 +
 
 +
-----
 +
&lt;. [[Guided_Tutorial_Introduction|Previous: Introduction]]
 +
&gt;. [[Guided_Tutorial_GNU_Radio_in_Python|Next: Programming GNU Radio in Python]]
 +
 
 +
[[Category:Guided Tutorials]]

Please note that all contributions to GNU Radio are considered to be released under the Creative Commons Attribution-ShareAlike (see GNU Radio:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)