1 / 32

GNU Radio

GNU Radio. Outline. What is GNU Radio? Basic Concepts Developing Applications. 2. 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.

gwyn
Télécharger la présentation

GNU Radio

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GNU Radio

  2. Outline • What is GNU Radio? • Basic Concepts • Developing Applications 2

  3. What is GNU Radio? • Software toolkit for signalprocessing • Software radio construction • Rapid development • USRP (Universal Software Radio Peripheral) • Hardware frontend for sendingand receiving waveforms

  4. GNU Radio Components Hardware Frontend Host Computer RF Frontend (Daugtherboard) ADC/DAC and Digital Frontend (USRP) GNU Radio Software http://mobiledevices.kom.aau.dk/fileadmin/mobiledevices/teaching/software_testing/Gnu_radio_lecture.pdf

  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 Host Computer RX/TXDaughterboard ADC/DAC FPGA USB Interface http://mobiledevices.kom.aau.dk/fileadmin/mobiledevices/teaching/software_testing/Gnu_radio_lecture.pdf

  8. Outline • What is GNU Radio? • Basic Concepts • Developing Applications 8

  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 1 5 3 4 12 12 3 7 9

  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 streamsof float One streamof 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 graphsgraphically • Generate runnable code • Demonstration

  16. Outline • What is GNU Radio? • Basic Concepts • Developing Applications 16

  17. Development Architecture PythonApplication developmentFlow graph construction • 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? C++Signal processing blocks http://mobiledevices.kom.aau.dk/fileadmin/mobiledevices/teaching/software_testing/Gnu_radio_lecture.pdf

  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 thegraph

  21. Dial Tone Example (3) Define and parse command-line options 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

  22. Dial Tone Example (4) Create and connect signal processing blocks 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))

  23. Dial Tone Example (5) Run the flow graph when the program is executed if __name__ == '__main__': try: my_top_block().run() except KeyboardInterrupt: pass

  24. 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: 3rd Party GNU Radio Apps • https://www.cgran.org/ • OFDM Implementation Presentation • http://gnuradio.org/trac/wiki/Wireless

  25. Backup

  26. 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)

  27. Block Definition #include <gr_sync_block.h> class my_block_cc; typedef boost::shared_ptr<cs434_my_block_cc> 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 andproducing output streams

  28. Block Implementation (1) #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <my_block_cc.h> #include <gr_io_signature.h> 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

  29. 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<%.6f, %.6f>\n", d_count++, in[i].real(), in[i].imag()); return noutput_items; } Copy input stream to output stream Echo samples stderr Return number of items processed

  30. SWIG Interface Condensed copy of block definition (in header file) 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(); };

  31. Outline • What is GNU Radio? • Basic Concepts • Developing Applications • HW2 Introduction 31

  32. 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/

More Related