Your First Flowgraph: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
(''Id'' should not end with .py, and two related clarifications)
 
(32 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Template:TutorialNavigation}}
<div style="float:right">
{{Template:BeginnerTutorials}}
</div>
This tutorial describes how to create and run your first flowgraph in GNU Radio.


This tutorial will guide you through creating and running your first flowgraph in GNURadio. This guide assumes you have already installed GNURadio. You can find the installation instructions here: [[InstallingGR|Installing GNURadio]]
This guide assumes GNU Radio is installed. The GNU Radio installation structures are here: [[InstallingGR|Installing GNU Radio]]. The next tutorial, [[Python Variables in GRC]], describes how Python data types are used in GNU Radio Companion (GRC).


== Starting GNURadio Companion ==
== Starting GNU Radio Companion ==
The GNURadio Companion (GRC) is a visual editor for assembling and flowgraphs. GRC uses ''.grc'' files which are then translated into Python ''.py'' flowgraphs.
The GNU Radio Companion (GRC) is a visual editor for creating and running flowgraphs. GRC uses ''.grc'' files which are then translated into Python ''.py'' flowgraphs.


Open a terminal by pressing ''CTRL'' + ''ALT'' + ''T'' or by right-clicking on the desktop and selecting ''Open in Terminal'':
Open a terminal by pressing ''CTRL'' + ''ALT'' + ''T'' or by right-clicking on the desktop and selecting ''Open in Terminal'':
Line 10: Line 13:
[[File:OpenTerminal.png|500px]]
[[File:OpenTerminal.png|500px]]


In the terminal, type:
Type in the terminal:


<pre>$ gnuradio-companion &</pre>
<pre>$ gnuradio-companion &</pre>


The GRC window will then appear:
The GRC window opens:


[[File:NewGRCFlowgraph.png|500px]]
[[File:NewGRCFlowgraph.png|500px]]




Double click the ''Options'' block on the upper left hand corner and name your flowgraph by editing the ''Id'' and ''Title'' entries:
Double click the ''Options'' block and name the flowgraph by editing the ''Id'' and ''Title'':


[[File:NameYourFlowgraph.png|500px]]
[[File:NameYourFlowgraph.png|500px]]


The ''Id'' will be the filename of the Python flowgraph which in this case will be ''sineWaveFlowgraph.py''. The ''Title'' entry is a description of the flowgraph. Click ''OK'' to save your changes.
The ''Id'' is the filename of the Python flowgraph. Name it ''sineWaveFlowgraph''. The ''Title'' is a description of the flowgraph. Click ''OK'' to save the changes.


Click ''File : Save'' to save your GRC Flowgraph.
Click ''File : Save'' to save the GRC Flowgraph.


[[File:GRCClickSave.png|500px]]
[[File:GRCClickSave.png|500px]]


 
Enter ''sineWaveGRC.grc'' as the name for the ''.grc'' file to distinguish it from the Id.
Enter a name for your ''.grc'' file which is ''sineWaveGRC.grc'' to distinguish it from the ''.py'' flowgraph.


[[File:EnterGRCName.png|500px]]
[[File:EnterGRCName.png|500px]]


Now that the GRC file is named and saved, blocks can be added to create your first flowgraph.
The GRC file is named and saved.


== Adding Blocks ==
== Adding Blocks ==
GNURadio comes with a large pre-existing library of signal processing blocks. The blocks can be browsed using the arrows in the right hand column, or you may search for blocks by using ''CTRL+F'' or by selecting the magnifying glass (highlighted in red):
 
Blocks are added to create the first flowgraph. GNU Radio comes with a library of signal processing blocks. The blocks can be browsed using the arrows on the right. Blocks may also be searched for using ''CTRL + F'' or by selecting the magnifying glass (highlighted in <span style="color:red">red</span>):


[[File:SearchBlockLibrary.png|500px]]
[[File:SearchBlockLibrary.png|500px]]
Line 45: Line 48:
[[File:SearchSignalSourceBlock.png|250px]]
[[File:SearchSignalSourceBlock.png|250px]]


Now search for ''Throttle'', ''QT GUI Frequency Sink'' and ''QT GUI Time Sink''. Drag and drop each of the blocks into the workspace so the flowgraph looks like the following:
Now search for ''Throttle'', ''QT GUI Frequency Sink'' and ''QT GUI Time Sink''. Drag and drop each of the blocks into the workspace. The flowgraph should like the following:


[[File:UnconnectedFlowgraph.png|500px]]
[[File:UnconnectedFlowgraph.png|500px]]


The ''Signal Source'' block will create a complex sinusoid, ''QT GUI Frequency Sink'' will display the magnitude of the frequency spectrum of the complex sinusoid and ''QT GUI Time Sink'' will display the time domain. The ''Throttle'' block is used for flow control in the absence of radio hardware.
The ''Signal Source'' block will create a complex sinusoid, ''QT GUI Frequency Sink'' will display the magnitude of the frequency spectrum and ''QT GUI Time Sink'' will display the time domain. The ''Throttle'' block is used for flow control in the absence of radio hardware.


The blocks need to be connected. First click the output of ''Signal Source'' (highlighted in red) and then click the input to the ''Throttle'' (highlighted in orange).
The blocks need to be connected. First click the output of ''Signal Source'' (highlighted in '''<span style="color:red">red</span>''') and then click the input to the ''Throttle'' (highlighted in '''<span style="color:orange">orange</span>''').


[[File:MakeFirstConnection.png|500px]]
[[File:MakeFirstConnection.png|500px]]


You will notice that the ''Signal Source'' block text has changed from red to black. The red text shows a user that a block still has an input or output that needs to be connected before the flowgraph can be run. Now connect the throttle output to the frequency sink and time sink:
The ''Signal Source'' block text changed from '''<span style="color:red">red</span>''' to '''black'''. The '''<span style="color:red">red</span>''' text means a block still has an input or output that needs to be connected before the flowgraph can be run. Connect the throttle output to the frequency sink and time sink:


[[File:ConnectedFlowgraph.png|500px]]
[[File:ConnectedFlowgraph.png|500px]]
Line 61: Line 64:
== Running The Flowgraph ==
== Running The Flowgraph ==


Press the ''Play'' button (highlighted in red) to run the flowgraph:
Press the ''Play'' button (highlighted in '''<span style="color:red">red</span>''') to run the flowgraph:


[[File:RunFlowgraphButton.png|250px]]
[[File:RunFlowgraphButton.png|250px]]


A new window will pop-up displaying the signal in the time domain and frequency domain:
A new window displays the signal in the time domain and frequency domain:


[[File:FrequencySinkTimeSink.png|500px]]
[[File:FrequencySinkTimeSink.png|500px]]


Success! Your flowgraph is now running.
Success! The flowgraph is running.


Opening your file browser shows that that there are two files, ''sineWaveGRC.grc'' which is a file that contains the information for the visual display of the flowgraph in GRC, and ''sineWaveFlowgraph.py'' which contains the actual Python-based flowgraph code.
Open the file browser. There are two files. The first file is ''sineWaveGRC.grc'', containing the information for the display of the flowgraph in GRC. The second file is ''sineWaveFlowgraph.py'', containing the actual Python flowgraph code. The ''Id'' in the Options block determines the name of the ''.py'' file.


[[File:GRCandPy.png|250px]]
[[File:GRCandPy.png|250px]]


Continue onto the next tutorial which describes [[Variables in Flowgraphs|Variables in Flowgraphs]].
Continue onto the next tutorial, [[Python Variables in GRC]], which describes how Python data types are used in GRC.

Latest revision as of 02:42, 27 February 2023

Beginner Tutorials

Introducing GNU Radio

  1. What is GNU Radio?
  2. Installing GNU Radio
  3. Your First Flowgraph

Flowgraph Fundamentals

  1. Python Variables in GRC
  2. Variables in Flowgraphs
  3. Runtime Updating Variables
  4. Signal Data Types
  5. Converting Data Types
  6. Packing Bits
  7. Streams and Vectors
  8. Hier Blocks and Parameters

Creating and Modifying Python Blocks

  1. Creating Your First Block
  2. Python Block With Vectors
  3. Python Block Message Passing
  4. Python Block Tags

DSP Blocks

  1. Low Pass Filter Example
  2. Designing Filter Taps
  3. Sample Rate Change
  4. Frequency Shifting
  5. Reading and Writing Binary Files

SDR Hardware

  1. RTL-SDR FM Receiver
  2. B200-B205mini FM Receiver

This tutorial describes how to create and run your first flowgraph in GNU Radio.

This guide assumes GNU Radio is installed. The GNU Radio installation structures are here: Installing GNU Radio. The next tutorial, Python Variables in GRC, describes how Python data types are used in GNU Radio Companion (GRC).

Starting GNU Radio Companion

The GNU Radio Companion (GRC) is a visual editor for creating and running flowgraphs. GRC uses .grc files which are then translated into Python .py flowgraphs.

Open a terminal by pressing CTRL + ALT + T or by right-clicking on the desktop and selecting Open in Terminal:

OpenTerminal.png

Type in the terminal:

$ gnuradio-companion &

The GRC window opens:

NewGRCFlowgraph.png


Double click the Options block and name the flowgraph by editing the Id and Title:

NameYourFlowgraph.png

The Id is the filename of the Python flowgraph. Name it sineWaveFlowgraph. The Title is a description of the flowgraph. Click OK to save the changes.

Click File : Save to save the GRC Flowgraph.

GRCClickSave.png

Enter sineWaveGRC.grc as the name for the .grc file to distinguish it from the Id.

EnterGRCName.png

The GRC file is named and saved.

Adding Blocks

Blocks are added to create the first flowgraph. GNU Radio comes with a library of signal processing blocks. The blocks can be browsed using the arrows on the right. Blocks may also be searched for using CTRL + F or by selecting the magnifying glass (highlighted in red):

SearchBlockLibrary.png

Search for the Signal Source block and then drag and drop it into the GRC workspace:

SearchSignalSourceBlock.png

Now search for Throttle, QT GUI Frequency Sink and QT GUI Time Sink. Drag and drop each of the blocks into the workspace. The flowgraph should like the following:

UnconnectedFlowgraph.png

The Signal Source block will create a complex sinusoid, QT GUI Frequency Sink will display the magnitude of the frequency spectrum and QT GUI Time Sink will display the time domain. The Throttle block is used for flow control in the absence of radio hardware.

The blocks need to be connected. First click the output of Signal Source (highlighted in red) and then click the input to the Throttle (highlighted in orange).

MakeFirstConnection.png

The Signal Source block text changed from red to black. The red text means a block still has an input or output that needs to be connected before the flowgraph can be run. Connect the throttle output to the frequency sink and time sink:

ConnectedFlowgraph.png

Running The Flowgraph

Press the Play button (highlighted in red) to run the flowgraph:

RunFlowgraphButton.png

A new window displays the signal in the time domain and frequency domain:

FrequencySinkTimeSink.png

Success! The flowgraph is running.

Open the file browser. There are two files. The first file is sineWaveGRC.grc, containing the information for the display of the flowgraph in GRC. The second file is sineWaveFlowgraph.py, containing the actual Python flowgraph code. The Id in the Options block determines the name of the .py file.

GRCandPy.png

Continue onto the next tutorial, Python Variables in GRC, which describes how Python data types are used in GRC.