You are on page 1of 30

GNU RADIO

SUBMITTED TO:
SUBMITTED BY:
MR. S. NAITHANI
MITTAL

PRATEEK

CONTENT:
1.
2.
3.
4.
5.
6.
7.
8.

What is gnu radio?


What does GNU Radio exactly do?
Core concepts of GNU Radio
What does we do in GNU Radio?
Installation of GNU Radio
Working of GNU Radio with Python
Creating our own block
Current issues

What is GNU Radio?

Free & open-software development


toolkit.

Used to create software defined radios.

Support both wireless communication


research & real world radio systems.

A platform for experimenting with


digital communications

What is software defined radio?

Get the software close to the antenna


Radio which performs the required signal
processing in software
Advantage : software can be easily
replaced
Same software radio can be used for
different applications

What does exactly a software


radio do?

Performs all the signal processing


Can be used to push data into and
receive data out of digital stream
Extending GNU Radio is easy
Creating a missing block and adding it is
very easy

Core Concepts of GNU Radio

Flow Graphs :
- Graphs through which data flows
- Many applications contain nothing other
than flow graphs
- Nodes are called blocks, and the data
flows along the edges
- Signal processing is done in the blocks
- Blocks are written in C++(might also
be python)

Example:

In the flow graph, data flows from left to


right.
Blocks are connected at ports
The first block has no input port, it
produces samples. Such a block, with only
output ports, is called a source.
Block with no outputs, is called a sink

MS:

Generally, block output is called as items

However, an item can be anything that can


be represented digitally

An item can be anything, a sample, a bunch


of bits, a set of filter coefficients or whatever

Meta data:

A stream of samples is much more


interesting when there is parsable
metadata connected to that stream, such
as the time of reception, centre frequency,
sampling rate or even protocol-specific
information such as node identification.

In GNU Radio, adding metadata to sample


streams is done via a mechanism called
stream tags.

What should you know by now?

All signal processing is done through flow


graphs

A block does one signal processing


operation, such as filtering, adding,
transforming, decoding, hardware access or
many others.

Data passes between blocks in various


formats, basically any kind of data type you
can define.

Every flow graph needs at least one sink

Sampling Rate :

Sampling rate or sampling frequency


defines the number of samples per
second (or per other unit) taken from a
continuous signal to make a discrete or
digital signal.

It defines the rate at which a block


consumes the items or produce the
items.

What does we do in GNU Radio

Design the flow graph


Choose the blocks
Define the connections and tell GNU
Radio about all of this
Once the flow graph is defined, we
execute the flow graph
GNU Radio does it by calling the blocks
one after another and makes sure the
items are passed from one block to
another.

Installation of GNU Radio:

Open the terminal window(ctrl+alt+t) in


your in ubuntu

Type the following command:


sudo apt-get install gnu radio

Press enter and then wait for few minutes

Few more important command:

To open the GNU Radio:


$ gnuradio-companion

To create a directory(folder):
mkdir <directory name>

To open any directory:


cd <directory name>

To run any command:


sudo apt install <command>

(Contd.)

module Installing :
Uninstalling:
mkdir build
uninstall
cd build
ldconfig
cmake . .
make j8
sudo make install
sudo config

sudo make
sudo

Working of GNU radio with


python
Let us take a Dial tone example on GRC:
When we click the Generate button, the
terminal tells us it produced a .py file so let's
open that to examine its code

Code:

#!/usr/bin/env Python
from gnuradio import analog
from gnuradio import audio
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio.eng_option import
eng_option
from gnuradio.filter import firdes
from optparse import OptionParser

Code:

class tutorial_three(gr.top_block):
def __init__(self):
gr.top_block.__init__(self, "Tutorial Three")
self.samp_rate = samp_rate = 32000
self.audio_sink_0 = audio.sink(samp_rate, "", True)
self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate,
analog.GR_SIN_WAVE, 350, .1, 0)
self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate,
analog.GR_SIN_WAVE, 440, .1, 0)
self.connect((self.analog_sig_source_x_1, 0), (self.audio_sink_0, 1))
self.connect((self.analog_sig_source_x_0, 0), (self.audio_sink_0, 0))
def get_samp_rate(self):
return self.samp_rate

Code:

def set_samp_rate(self, samp_rate): self.samp_rate =


samp_rate
self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
self.analog_sig_source_x_1.set_sampling_freq(self.samp_rate)
if __name__ == '__main__':
parser = OptionParser(option_class=eng_option,
usage="%prog: [options]")
(options, args) = parser.parse_args()
tb = tutorial_three()
tb.start()
raw_input('Press Enter to quit: ')
tb.stop()
tb.wait()

Creating our own block

$ gr_modtool newmod tutorial


Creating out-of-tree module in ./gr-tutorial...
Done.
Use 'gr_modtool add' to add a new block to
this currently empty module.
We should now see a new folder, gr-tutorial,
in our current directory.
gr-tutorial$ ls
apps cmake CMakeLists.txt docs examples
grc include lib Python swig

Creating our own block:

Since we are dealing with Python in this


tutorial we only need to concern ourselves
with the Python folder and the grc folder.

We will dive into the synchronous 1:1 input


to output block to make explaining things
easier

Now we know the language and the type of


block (synchronous block) we can now add a
block to our module.

Creating our own block:

When prompted for a name simply enter


"multiply_py_ff", when prompted for an
argument list enter "multiple", and when
prompted for Python QA (Quality Assurance)
code type "y", or just hit enter.

gr-tutorial$ gr_modtool add -t sync -l python


GNU Radio module name identified: tutorial
Language: Python
Enter name of block/code (without module
name prefix): multiply_py_ff

Creating our own block:

Block/code identifier: multiply_py_ff


Enter valid argument list, including
default arguments: multiple
Add Python QA code? [Y/n] y
Adding file 'Python/multiply_py_ff.py'...
Adding file
'Python/qa_multiply_py_ff.py'...
Editing Python/CMakeLists.txt...
Adding file
'grc/tutorial_multiply_py_ff.xml'...
Editing grc/CMakeLists.txt...

Modifying the Python block file:


multiply_py_ff.py file without any changes gives the following:

import numpy
from gnuradio import gr class multiply_py_ff(gr.sync_block):
""" docstring for block multiply_py_ff ""
def __init__(self, multiple): gr.sync_block.__init__(self,
name="multiply_py_ff", in_sig=[<+numpy.float+>],
out_sig=[<+numpy.float+>])
self.multiple = multiple
def work(self, input_items, output_items):
in0 = input_items[0]
out = output_items[0]
# <+signal processing here+>
out[:] = in0
return len(output_items[0])

View How to use variable multiple...


def __init__(self, multiple): self.multiple =
multiple gr.sync_block.__init__(self,
"<+...+>: placeholders from gr_modtool
and tell us where we need to alter things
in_sig=[<+numpy.float+>]
out_sig=[<+numpy.float+>]

Installing Python Blocks:

First, we need to get out of the /grc


directory and create a build directory
called "build". Inside the build directory,
we can then run a series of commands:
cmake ../
Make
sudo make install
sudo ldconfig
We should then open up the GRC and
take a look at the new block.

New block:

Current issues:

Need a USRP + Microtune 4937

Need a python IDE

A long way to be commercialized


High performance CPU
requirement
The software is still under
development

Why SDR?

Flexibility
Quicker time to market
Multiple personalities (chameleon)
New things are possible:
Multiple channels at the same
time
Better spectrum utilization

Disadvantages:

Higher power consumption than


dedicated ASIC approach

More MIPS required

Higher cost (today)

You might also like