50
Introduction GNU Radio Architecture Programming the GNU Radio References GNU Radio An introduction Jesper M. Kristensen Department of Electronic Systems [email protected] Programmerbare digitale enheder Tuesday 6/3 2007 Programmerbare digitale enheder GNU Radio 1 / 36

Gnu radio lecture

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU RadioAn introduction

Jesper M. KristensenDepartment of Electronic Systems

[email protected]

Programmerbare digitale enhederTuesday 6/3 2007

Programmerbare digitale enheder GNU Radio 1 / 36

Page 2: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Outline

1 IntroductionWhat is GNU RadioSoftware Radio

2 GNU Radio ArchitectureHardware ArchitectureSoftware Architecture

3 Programming the GNU RadioGNU Radio "‘Hello World"’FM radioSoftware development

4 References

Programmerbare digitale enheder GNU Radio 2 / 36

Page 3: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

What is GNU RadioSoftware Radio

Outline

1 IntroductionWhat is GNU RadioSoftware Radio

2 GNU Radio ArchitectureHardware ArchitectureSoftware Architecture

3 Programming the GNU RadioGNU Radio "‘Hello World"’FM radioSoftware development

4 References

Programmerbare digitale enheder GNU Radio 3 / 36

Page 4: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

What is GNU RadioSoftware Radio

A Framework

An open source software toolkitSupports, Linux, Mac OS and Windows

Creating signal processing applicationsDefining waveforms in softwareProcessing waveforms in software

A hardware platformUSRP, universal software radio peripheral, low cost HW platform forpreprocessing

ADC &DACFPGAUSB 2.0 Interface to Host PC

A framework for building software radio transceivers

Programmerbare digitale enheder GNU Radio 4 / 36

Page 5: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

What is GNU RadioSoftware Radio

Prerequisites

Using the GNU radio is cross disciplinaryRequiring know-how in the fields of

Computer programmingCommunications systemsDigital signal processingAnalog as well as digital hardware

Hardware is also open sourceSchematics are available

Programmerbare digitale enheder GNU Radio 5 / 36

Page 6: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

What is GNU RadioSoftware Radio

Outline

1 IntroductionWhat is GNU RadioSoftware Radio

2 GNU Radio ArchitectureHardware ArchitectureSoftware Architecture

3 Programming the GNU RadioGNU Radio "‘Hello World"’FM radioSoftware development

4 References

Programmerbare digitale enheder GNU Radio 6 / 36

Page 7: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

What is GNU RadioSoftware Radio

Software Radio

An implementation technologyA technique for moving digital signal processing as close aspossible to the antenna

Replacing rigid Hardware...with flexible software based solutions

Software Radio defintionA software (defined) radio is a radio that includes a transmitter in whichthe operating parameters of the transmitter, including the frequencyrange, modulation type or maximum radiated or conducted outputpower can be altered by making a change in software without makingany hardware changes.

Programmerbare digitale enheder GNU Radio 7 / 36

Page 8: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

What is GNU RadioSoftware Radio

Alternative definitions

Quoting the SDR forum:Software Defined Radio (SDR) is a collection of hardware and softwaretechnologies that enable reconfigurable system architectures for wirelessnetworks and user terminals. SDR provides an efficient and comparativelyinexpensive solution to the problem of building multi-mode, multi-band,multi-functional wireless devices that can be enhanced using softwareupgrades. As such, SDR can really be considered an enabling technologythat is applicable across a wide range of areas within the wireless industry.SDR-enabled devices... can be dynamically programmed in software toreconfigure the characteristics of equipment. In other words, the same pieceof "hardware" can be modified to perform different functions at differenttimes...

Programmerbare digitale enheder GNU Radio 8 / 36

Page 9: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

What is GNU RadioSoftware Radio

Defining software radio using tiers...

The SDR Forum has defined the following tiers, describing evolvingcapabilities in terms of flexibility

Tier 0The Hardware Radio: The radio is implemented using hardwarecomponents only and cannot be modified except through physicalintervention.Tier 1Software Controlled Radio (SCR): Only the control functions of anSCR are implemented in software - thus only limited functions arechangeable using software. Typically this extends to inter-connects,power levels etc. but not to frequency bands and/or modulation typesetc.

Programmerbare digitale enheder GNU Radio 9 / 36

Page 10: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

What is GNU RadioSoftware Radio

Defining software radio using tiers...

Tier 2Software Defined Radio (SDR): SDRs provide software control of avariety of modulation techniques, wide-band or narrow-band operation,communications security functions (such as hopping), and waveformrequirements of current and evolving standards over a broad frequencyrange. The frequency bands covered may still be constrained at thefront-end requiring a switch in the antenna system.Tier 3Ideal Software Radio (ISR): ISRs provide dramatic improvement overan SDR by eliminating the analog amplification or heterodyne mixingprior to digital-analog conversion. Programmability extends to the entiresystem with analog conversion only at the antenna, speaker andmicrophones.

Programmerbare digitale enheder GNU Radio 10 / 36

Page 11: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

What is GNU RadioSoftware Radio

Defining software radio using tiers...

Tier 4Ultimate Software Radio (USR): USRs are defined for comparisonpurposes only. It accepts fully programmable traffic and controlinformation and supports a broad range of frequencies, air-interfaces &applications software. It can switch from one air interface format toanother in milliseconds, use GPS to track the users location, storemoney using smartcard technology, or provide video so that the user canwatch a local broadcast station or receive a satellite transmission.Cognitive radio (CR) is a form of wireless communication in which atransceiver can intelligently detect which communication channels are inuse and which are not, and instantly move into vacant channels whileavoiding occupied ones. This optimizes the use of availableradio-frequency (RF) spectrum while minimizing interference to otherusers.

Programmerbare digitale enheder GNU Radio 11 / 36

Page 12: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

What is GNU RadioSoftware Radio

S(D)R and Transceiver architetures

Two basic transceiver architecturesThe heterodyneThe zero IF

���

����

���

����

���

��� ���

������������

Programmerbare digitale enheder GNU Radio 12 / 36

Page 13: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

What is GNU RadioSoftware Radio

S(D)R and Transceiver architetures

Two basic transceiver architecturesThe heterodyneThe zero IF

���

����

���

����

���

��� ���

������������

Programmerbare digitale enheder GNU Radio 12 / 36

Page 14: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

Outline

1 IntroductionWhat is GNU RadioSoftware Radio

2 GNU Radio ArchitectureHardware ArchitectureSoftware Architecture

3 Programming the GNU RadioGNU Radio "‘Hello World"’FM radioSoftware development

4 References

Programmerbare digitale enheder GNU Radio 13 / 36

Page 15: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

GNU Radio block schematic

����������

� ��������

�������������

������������

���������������

������

������������ �

���!��

"���#����������������������������� "�$��%�&����

Programmerbare digitale enheder GNU Radio 14 / 36

Page 16: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

GNU Radio block schematic in more detail

�����

������

�����

������� ���������������

�������� �!�"�����

Programmerbare digitale enheder GNU Radio 15 / 36

Page 17: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

The Universal Software Radio Peripheral

Basic USRP facts4*ADC, 12 bit @ 64MSPS4*DAC, 14 bit @ 128MSPSAltera EP1C12 FPGA forpreprocessing tasksAnalog and Digital I/O for auxilliaryI/OSupporting

Two Receive daughter boardsTwo Transmit daughter boards

USB 2.0 interface to host PC

Programmerbare digitale enheder GNU Radio 16 / 36

Page 18: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

More photos of the USRP

Programmerbare digitale enheder GNU Radio 17 / 36

Page 19: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

ADC&DAC frontend, AD9862

Some more ADC specsSampling signals up 32 MHz(Nyquist sampling)IF sampling up to 100MHz

If internal buffers bypassed,up to 250MHz

full range of ADC is 2Vpp(optimized SNR)

Programmerbare digitale enheder GNU Radio 18 / 36

Page 20: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

The FPGA

RX/TX paths implemented inthe FPGA

Connections controlled viasoftwareRX pathTX path

���

����

����

���

���

����

����

���

���

�� ������������������ ��

������

�� ������������������ ��

������

��

��

��

��

���

����

Programmerbare digitale enheder GNU Radio 19 / 36

Page 21: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

The FPGA

RX/TX paths implemented inthe FPGA

Connections controlled viasoftwareRX pathTX path ���

������

��� �����

�� �

��� �����

�� �

����������

�����������

����������

������������������� �����������

���� �!��" ��� ������

���� ��#�������� ��$�%&�'�����������(����

)������*�+

Programmerbare digitale enheder GNU Radio 19 / 36

Page 22: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

The FPGA

RX/TX paths implemented inthe FPGA

Connections controlled viasoftwareRX pathTX path

������������

������������

�����

����

�����

����

������

�� ��

�� ��

�� ��

�� ��

���

���

�� �������������

�������

Programmerbare digitale enheder GNU Radio 19 / 36

Page 23: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

The USB interface

The USB interface supports (ideally) 32Mbyte/sthis limits the achievable datarates

Examples of datarates

Complex samples are interleaved across the USB interface

Having one channel with complex samples gives 8Mbit/s

Having multiple channels (up to 4) reduces the rate per channelaccordingly

Finally adding TX channels again reduces achievable rates as combinedrates is limited by 32Mbyte/s.

�� �� �� ��

Programmerbare digitale enheder GNU Radio 20 / 36

Page 24: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

The USB interface

The USB interface supports (ideally) 32Mbyte/sthis limits the achievable datarates

Examples of datarates

Complex samples are interleaved across the USB interface

Having one channel with complex samples gives 8Mbit/s

Having multiple channels (up to 4) reduces the rate per channelaccordingly

Finally adding TX channels again reduces achievable rates as combinedrates is limited by 32Mbyte/s.

�� �� �� �� �� �� �� �� �� ��

Programmerbare digitale enheder GNU Radio 20 / 36

Page 25: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

The USB interface

The USB interface supports (ideally) 32Mbyte/sthis limits the achievable datarates

Examples of datarates

Complex samples are interleaved across the USB interface

Having one channel with complex samples gives 8Mbit/s

Having multiple channels (up to 4) reduces the rate per channelaccordingly

Finally adding TX channels again reduces achievable rates as combinedrates is limited by 32Mbyte/s.

Programmerbare digitale enheder GNU Radio 20 / 36

Page 26: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

Hardware architecture in conclusion

GNU radio supports up to 4 independent real sampling channelsor 2 independent complex sampling channels2 independent TX channels are supportedAchievable rates are limited by the USB 32Mbyte/s.

Programmerbare digitale enheder GNU Radio 21 / 36

Page 27: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

Outline

1 IntroductionWhat is GNU RadioSoftware Radio

2 GNU Radio ArchitectureHardware ArchitectureSoftware Architecture

3 Programming the GNU RadioGNU Radio "‘Hello World"’FM radioSoftware development

4 References

Programmerbare digitale enheder GNU Radio 22 / 36

Page 28: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

Hardware ArchitectureSoftware Architecture

A 3 tier architecture

Python scripting language used forcreating "‘signal flow graphs"’

C++ used for creating signal processingblocks

An already existing library ofsignalling blocksOFDM functionality is currentlybeing added tested and will beadded to the library.

The scheduler is using Python’s built-inmodule threading, to control the ‘starting’,‘stopping’ or ‘waiting’ operations of thesignal flow graph.

GNU Radio Software architecture

PythonApplication development,

creating flow graphs

C++Signal processing

modules

SchedulerControlling flow

graphs

Programmerbare digitale enheder GNU Radio 23 / 36

Page 29: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Outline

1 IntroductionWhat is GNU RadioSoftware Radio

2 GNU Radio ArchitectureHardware ArchitectureSoftware Architecture

3 Programming the GNU RadioGNU Radio "‘Hello World"’FM radioSoftware development

4 References

Programmerbare digitale enheder GNU Radio 24 / 36

Page 30: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

GNU Radio ‘Hello World’ application

Hello World Example: Dial Tone Output

#!/usr/bin/env python

from gnuradio import grfrom gnuradio import audio

def build_graph ():sampling_freq = 48000ampl = 0.1

fg = gr.flow_graph ()src0 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 350, ampl)src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 440, ampl)dst = audio.sink (sampling_freq)fg.connect ((src0, 0), (dst, 0))fg.connect ((src1, 0), (dst, 1))

return fg

if __name__ == ’__main__’:fg = build_graph ()fg.start ()raw_input (’Press Enter to quit: ’)fg.stop ()

Programmerbare digitale enheder GNU Radio 25 / 36

Page 31: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Hello world step-by-step

#!/usr/bin/env python

from gnuradio import grfrom gnuradio import audio

def build_graph ():sampling_freq = 48000ampl = 0.1fg = gr.flow_graph ()src0 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 350, ampl)src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 440, ampl)dst = audio.sink (sampling_freq)fg.connect ((src0, 0), (dst, 0))fg.connect ((src1, 0), (dst, 1))

return fg

if __name__ == ’__main__’:fg = build_graph ()fg.start ()raw_input (’Press Enter to quit: ’)fg.stop ()

Makes the python codeexecutable by executing $chmod +x"‘filename.py"’

Programmerbare digitale enheder GNU Radio 26 / 36

Page 32: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Hello world step-by-step

#!/usr/bin/env python

from gnuradio import grfrom gnuradio import audio

def build_graph ():sampling_freq = 48000ampl = 0.1fg = gr.flow_graph ()src0 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 350, ampl)src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 440, ampl)dst = audio.sink (sampling_freq)fg.connect ((src0, 0), (dst, 0))fg.connect ((src1, 0), (dst, 1))

return fg

if __name__ == ’__main__’:fg = build_graph ()fg.start ()raw_input (’Press Enter to quit: ’)fg.stop ()

Importing nessecary modulesmodules from GNU radio library

Programmerbare digitale enheder GNU Radio 26 / 36

Page 33: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Hello world step-by-step

#!/usr/bin/env python

from gnuradio import grfrom gnuradio import audio

def build_graph ():

sampling_freq = 48000ampl = 0.1fg = gr.flow_graph ()src0 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 350, ampl)src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 440, ampl)dst = audio.sink (sampling_freq)fg.connect ((src0, 0), (dst, 0))fg.connect ((src1, 0), (dst, 1))

return fg

if __name__ == ’__main__’:fg = build_graph ()fg.start ()raw_input (’Press Enter to quit: ’)fg.stop ()

setting up signal flow graph

Programmerbare digitale enheder GNU Radio 26 / 36

Page 34: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Hello world step-by-step

#!/usr/bin/env python

from gnuradio import grfrom gnuradio import audio

def build_graph ():sampling_freq = 48000ampl = 0.1

fg = gr.flow_graph ()src0 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 350, ampl)src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 440, ampl)dst = audio.sink (sampling_freq)fg.connect ((src0, 0), (dst, 0))fg.connect ((src1, 0), (dst, 1))

return fg

if __name__ == ’__main__’:fg = build_graph ()fg.start ()raw_input (’Press Enter to quit: ’)fg.stop ()

Sampling frequency andamplitude on soundcard

Programmerbare digitale enheder GNU Radio 26 / 36

Page 35: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Hello world step-by-step

#!/usr/bin/env python

from gnuradio import grfrom gnuradio import audio

def build_graph ():sampling_freq = 48000ampl = 0.1fg = gr.flow_graph ()

src0 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 350, ampl)src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 440, ampl)dst = audio.sink (sampling_freq)fg.connect ((src0, 0), (dst, 0))fg.connect ((src1, 0), (dst, 1))

return fg

if __name__ == ’__main__’:fg = build_graph ()fg.start ()raw_input (’Press Enter to quit: ’)fg.stop ()

Instantiating a flow graph objectfrom flow graph class

Programmerbare digitale enheder GNU Radio 26 / 36

Page 36: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Hello world step-by-step

#!/usr/bin/env python

from gnuradio import grfrom gnuradio import audio

def build_graph ():sampling_freq = 48000ampl = 0.1fg = gr.flow_graph ()src0 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 350, ampl)src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 440, ampl)

dst = audio.sink (sampling_freq)fg.connect ((src0, 0), (dst, 0))fg.connect ((src1, 0), (dst, 1))

return fg

if __name__ == ’__main__’:fg = build_graph ()fg.start ()raw_input (’Press Enter to quit: ’)fg.stop ()

Setting up sinewaves at 350and 440 Hz

Programmerbare digitale enheder GNU Radio 26 / 36

Page 37: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Hello world step-by-step

#!/usr/bin/env python

from gnuradio import grfrom gnuradio import audio

def build_graph ():sampling_freq = 48000ampl = 0.1fg = gr.flow_graph ()src0 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 350, ampl)src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 440, ampl)dst = audio.sink (sampling_freq)

fg.connect ((src0, 0), (dst, 0))fg.connect ((src1, 0), (dst, 1))

return fg

if __name__ == ’__main__’:fg = build_graph ()fg.start ()raw_input (’Press Enter to quit: ’)fg.stop ()

defining destination to besoundcard

Programmerbare digitale enheder GNU Radio 26 / 36

Page 38: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Hello world step-by-step

#!/usr/bin/env python

from gnuradio import grfrom gnuradio import audio

def build_graph ():sampling_freq = 48000ampl = 0.1fg = gr.flow_graph ()src0 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 350, ampl)src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 440, ampl)dst = audio.sink (sampling_freq)fg.connect ((src0, 0), (dst, 0))fg.connect ((src1, 0), (dst, 1))

return fg

if __name__ == ’__main__’:fg = build_graph ()fg.start ()raw_input (’Press Enter to quit: ’)fg.stop ()

connecting source anddestinations, left and rightchannel

Programmerbare digitale enheder GNU Radio 26 / 36

Page 39: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Hello world step-by-step

#!/usr/bin/env python

from gnuradio import grfrom gnuradio import audio

def build_graph ():sampling_freq = 48000ampl = 0.1fg = gr.flow_graph ()src0 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 350, ampl)src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 440, ampl)dst = audio.sink (sampling_freq)fg.connect ((src0, 0), (dst, 0))fg.connect ((src1, 0), (dst, 1))

return fg

if __name__ == ’__main__’:fg = build_graph ()fg.start ()raw_input (’Press Enter to quit: ’)fg.stop ()

returning created flow graph

Programmerbare digitale enheder GNU Radio 26 / 36

Page 40: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Hello world step-by-step

#!/usr/bin/env python

from gnuradio import grfrom gnuradio import audio

def build_graph ():sampling_freq = 48000ampl = 0.1fg = gr.flow_graph ()src0 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 350, ampl)src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 440, ampl)dst = audio.sink (sampling_freq)fg.connect ((src0, 0), (dst, 0))fg.connect ((src1, 0), (dst, 1))

return fg

if __name__ == ’__main__’:fg = build_graph ()fg.start ()raw_input (’Press Enter to quit: ’)fg.stop ()

Create code to execute theflowgraph

Programmerbare digitale enheder GNU Radio 26 / 36

Page 41: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Outline

1 IntroductionWhat is GNU RadioSoftware Radio

2 GNU Radio ArchitectureHardware ArchitectureSoftware Architecture

3 Programming the GNU RadioGNU Radio "‘Hello World"’FM radioSoftware development

4 References

Programmerbare digitale enheder GNU Radio 27 / 36

Page 42: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Listening to FM radio

Listening to FM Radio on the GNU radio involvesSetting up the USRP

Selecting RX channelSetting up decimation factorSetting up possible gain factor

defining channel seletion filterimplementing demodulatordefining audio filtersending demodulated output to soundcard.

Programmerbare digitale enheder GNU Radio 28 / 36

Page 43: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

FM receiver block schematic

����� ���

�������� ����� ������������

�������������

������������ ������� ������

����������������������

Programmerbare digitale enheder GNU Radio 29 / 36

Page 44: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Outline

1 IntroductionWhat is GNU RadioSoftware Radio

2 GNU Radio ArchitectureHardware ArchitectureSoftware Architecture

3 Programming the GNU RadioGNU Radio "‘Hello World"’FM radioSoftware development

4 References

Programmerbare digitale enheder GNU Radio 30 / 36

Page 45: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Software development on GNU Radio

The application of PythonUsing Python for creating flow graphsAlso used for creating GUI’sand other non performance critical appplications

The application of C++Performance critical applications

Signal processing blockslike the FM demodulator

Programmerbare digitale enheder GNU Radio 31 / 36

Page 46: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Signal processing blocks in C++

Built as shared libaries

dynamically loaded using python’import’ feature

SWIG "‘Simplified Wrapper andInterface Generator"’ used for glue codeallowing python import.

C++ class "‘gr_block"’ is base for allsignal processing blocks

Derived classes gr_sync_block,gr_sync_decimator andgr_interpolator can also be useddepending on input/output raterelations

������������

������

����� ����� ����� ���������� ����� ��� �������

Programmerbare digitale enheder GNU Radio 32 / 36

Page 47: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Components needed in writing a C++ block

.h file for class declaration

.cc file for class definition

.i file defining how SWIG generate glue code binding the C++class into Python

Programmerbare digitale enheder GNU Radio 33 / 36

Page 48: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

Building a test framework

Using gr_unittest an extension to python unittestenabling checking for aproximate equality tuples of float andcomplex typeenabling automated test run’s

assuming block to be verified is "‘howto_square_ff"’assuming input and output specifications known

Programmerbare digitale enheder GNU Radio 34 / 36

Page 49: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

GNU Radio "‘Hello World"’FM radioSoftware development

qa_howto.py

from gnuradio import gr, gr_unittestimport howto

class qa_howto (gr_unittest.TestCase):

def setUp (self):self.fg = gr.flow_graph ()

def tearDown (self):self.fg = None

def test_001_square_ff (self):src_data = (-3, 4, -5.5, 2, 3)expected_result = (9, 16, 30.25, 4, 9)src = gr.vector_source_f (src_data)sqr = howto.square_ff ()dst = gr.vector_sink_f ()self.fg.connect (src, sqr)self.fg.connect (sqr, dst)self.fg.run ()result_data = dst.data ()self.assertFloatTuplesAlmostEqual (expected_result, result_data, 6)

if __name__ == ’__main__’:gr_unittest.main ()

Programmerbare digitale enheder GNU Radio 35 / 36

Page 50: Gnu radio lecture

IntroductionGNU Radio Architecture

Programming the GNU RadioReferences

For Further Reading

GNU Radio websitehttp://www.gnu.org/software/gnuradio/

GNU Radio tutorialshttp://www.nd.edu/ jnl/sdr/

How to Write a Signal Processing Blockhttp://www.gnu.org/software/gnuradio/doc/howto-write-a-block.html

Exploring GNU Radiohttp://www.gnu.org/software/gnuradio/doc/exploring-gnuradio.html

Programmerbare digitale enheder GNU Radio 36 / 36