Download presentation
Presentation is loading. Please wait.
Published byShannon Dixon Modified over 8 years ago
1
GNU Radio Jiewen Huang 1/31/2011
2
2 Outline What is GNU Radio? Basic Concepts Developing Applications HW2 Introduction
3
What is GNU Radio? Software toolkit for signal processing Software radio construction Rapid development USRP (Universal Software Radio Peripheral) Hardware frontend for sending and receiving waveforms
4
GNU Radio Components Hardware Frontend Host Computer RF Frontend (Daugtherboard) ADC/DAC and Digital Frontend (USRP) http://mobiledevices.kom.aau.dk/fileadmin/mobiledevices/teaching/software_testing/Gnu_radio_lecture.pdf GNU Radio Software
5
GNU Radio Software Opensource software (GPL) Don't know how something works? Take a look! Existing examples: 802.11b(Wi-Fi), ATSC (HDTV), OFDM, DBPSK, DQPSK Features Extensive library of signal processing blocks (C++/ and assembly) Python environment for composing blocks (flow graph)
6
GNU Radio Hardware Sends/receives waveforms USRP Features USB 2.0 interface (480Mbps) FPGA (customizable) 64Msps Digital to Analog converters 128Msps Analog to Digital converteres Daughterboards for different frequency ranges Available Daughterboard 400-500Mhz, 800-1000Mhz, 1150-1450Mhz, 1.5-2.1Ghz, 2.3-2.9Ghz
7
GNU Radio Hardware Schematic RX/TX Daughterboar d ADC/DAC http://mobiledevices.kom.aau.dk/fileadmin/mobiledevices/teaching/software_testing/Gnu_radio_lecture.pdf Host Computer FPGA USB Interface
8
8 Outline What is GNU Radio? Basic Concepts Developing Applications HW2 Introduction
9
Basics: Blocks Signal Processing Block Accepts 0 or more input streams Produces 0 or more output streams Source: No input noise_source, signal_source, usrp_source Sink: No outputs audio_alsa_sink, usrp_sink
10
Basics: Data Streams Blocks operate on streams of data 153 379 412
11
Basics: Data Types Blocks operate on certain data types char, short, int, float, complex Vectors Input Signature: Data types for input streams Output Signature: Data types for output streams Two streams of float One stream of complex
12
Basics: Flow Graph Blocks composed as a flow graph Data stream flowing from sources to sinks
13
Example: OFDM Synchronizer http://gnuradio.org/trac/raw-attachment/wiki/Wireless/gr_ofdm.pdf
14
GNU Radio Companion
15
GNU Radio Companion (Cont'd) GNU Radio Companion Design flow graphs graphically Generate runnable code Demonstration
16
16 Outline What is GNU Radio? Basic Concepts Developing Applications HW2 Introduction
17
Development Architecture http://mobiledevices.kom.aau.dk/fileadmin/mobiledevices/teaching/software_testing/Gnu_radio_lecture.pdf Python Application development Flow graph construction C++ Signal processing blocks Python Application management (e.g., GUI) Flow graph construction Non-streaming code (e.g., MAC-layer) C++ Signal processing blocks Certain routines also coded in assembly Why is the hybrid structure?
18
Dial Tone Example #!/usr/bin/env python from gnuradio import gr from gnuradio import audio from gnuradio.eng_option import eng_option from optparse import OptionParser class my_top_block(gr.top_block): def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) ampl = 0.1 src0 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 350, ampl) src1 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 440, ampl) dst = audio.sink (sample_rate, options.audio_output) self.connect (src0, (dst, 0)) self.connect (src1, (dst, 1)) if __name__ == '__main__': try: my_top_block().run() except KeyboardInterrupt: pass
19
Dial Tone Example (1) from gnuradio import gr from gnuradio import audio from gnuradio.eng_option import eng_option from optparse import OptionParser Import modules from GNU Radio library
20
Dial Tone Example (2) class my_top_block(gr.top_block): def __init__(self): gr.top_block.__init__(self) Define container for Flow Graph; gr.top_block class maintains the graph
21
Dial Tone Example (3) parser = OptionParser(option_class=eng_option) parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 Define and parse command-line options
22
Dial Tone Example (4) sample_rate = int(options.sample_rate) ampl = 0.1 src0 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 350, ampl) src1 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 440, ampl) dst = audio.sink (sample_rate, options.audio_output) self.connect (src0, (dst, 0)) self.connect (src1, (dst, 1)) Create and connect signal processing blocks
23
Dial Tone Example (5) if __name__ == '__main__': try: my_top_block().run() except KeyboardInterrupt: pass Run the flow graph when the program is executed
24
Creating Your Own Block Basics A block is a C++ class Typically derived from gr_block or gr_sync_block class Three components my_block_xx.h : Block definition my_block_xx.cc : Block implementation my_block_xx.i : Python bindings (SWIG interface)
25
Block Definition #include class my_block_cc; typedef boost::shared_ptr cs434_my_block_cc_sptr; cs434_my_block_cc_sptr cs434_make_my_block_cc(); class my_block_cc : public gr_sync_block { private: unsigned int d_count; friend cs434_my_block_cc_sptr cs434_make_my_block_cc(); cs434_my_block_cc(); public: int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); }; Create instances of block Method for processing input streams and producing output streams
26
Block Implementation (1) #ifdef HAVE_CONFIG_H #include "config.h" #endif #include cs434_my_block_cc_sptr cs434_make_my_block_cc() { return cs434_my_block_cc_sptr(new cs434_my_block_cc()); } cs434_my_block_cc::cs434_my_block_cc() : gr_sync_block("my_block_cc", gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signature(1, 1, sizeof(gr_complex))), d_count(0) { } Helper method to create block Define input and output signatures
27
Block Implementation (2) int cs434_my_block_cc::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { const gr_complex* in = (const gr_complex*)input_items[0]; gr_complex* out = (gr_complex*)output_items[0]; memcpy(out, in, sizeof(*out) * noutput_items); for (int i = 0; i < noutput_items; ++i) fprintf(stderr, "%u\t \n", d_count++, in[i].real(), in[i].imag()); return noutput_items; } Copy input stream to output stream Return number of items processed Echo samples stderr
28
SWIG Interface GR_SWIG_BLOCK_MAGIC(cs434, my_block_cc); cs434_my_block_cc_sptr cs434_make_my_block_cc(); class cs434_my_block_cc : public gr_sync_block { private: cs434_my_block_cc(); }; Condensed copy of block definition (in header file)
29
29 Outline What is GNU Radio? Basic Concepts Developing Applications HW2 Introduction
30
HW2 Overview Implement MAC layer for a wireless device Link-layer header Carrier-sensing and backoff Link-layer acknowledgments Template code at https://www-net.cs.yale.edu/svn/courses/cs434/spring09/hw4/gr-cs434-hw4/
31
Useful Links Homepage (download, more links, etc) http://gnuradio.org/trac/ More comprehensive tutorial http://gnuradio.org/trac/wiki/Tutorials/WritePythonApplications Available Signal Processing Blocks http://gnuradio.org/doc/doxygen/hierarchy.html GNU Radio Mailing List Archives http://www.gnu.org/software/gnuradio/mailinglists.html CGRAN: 3 rd Party GNU Radio Apps https://www.cgran.org/ OFDM Implementation Presentation http://gnuradio.org/trac/wiki/Wireless
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.