From 7dc08ba2875c0dace0432cd514add6ce2b085f44 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 3 Apr 2012 11:35:35 -0400 Subject: examples: Reworked locations and installation of examples. All python and GRC examples directly associated with a top-level component are now in that examples directory. Examples are split into c++, python, and grc dirs but are all installed into $prefix/share/gnuradio/examples/. --- gnuradio-examples/grc/CMakeLists.txt | 42 +- gnuradio-examples/grc/audio/cvsd_sweep.grc | 918 -------- gnuradio-examples/grc/audio/dial_tone.grc | 375 ---- .../grc/trellis/interference_cancellation.grc | 2177 ------------------- gnuradio-examples/grc/trellis/pccc.grc | 832 -------- gnuradio-examples/grc/trellis/pccc1.grc | 857 -------- gnuradio-examples/grc/trellis/readme.txt | 32 - gnuradio-examples/grc/trellis/sccc.grc | 832 -------- gnuradio-examples/grc/trellis/sccc1.grc | 857 -------- gnuradio-examples/grc/uhd/uhd_const_wave.grc | 1020 --------- gnuradio-examples/grc/uhd/uhd_dpsk_mod.grc | 2238 -------------------- gnuradio-examples/grc/uhd/uhd_fft.grc | 1025 --------- gnuradio-examples/grc/uhd/uhd_rx_dpsk.grc | 1431 ------------- .../grc/uhd/uhd_two_tone_loopback.grc | 2204 ------------------- gnuradio-examples/grc/uhd/uhd_tx_dpsk.grc | 1234 ----------- gnuradio-examples/grc/uhd/uhd_wbfm_receive.grc | 1365 ------------ gr-audio/CMakeLists.txt | 12 +- gr-audio/examples/c++/CMakeLists.txt | 6 + gr-audio/examples/grc/CMakeLists.txt | 27 + gr-audio/examples/grc/cvsd_sweep.grc | 918 ++++++++ gr-audio/examples/grc/dial_tone.grc | 375 ++++ gr-audio/examples/python/CMakeLists.txt | 2 +- gr-digital/CMakeLists.txt | 2 + gr-digital/examples/CMakeLists.txt | 6 +- gr-fcd/CMakeLists.txt | 12 +- gr-fcd/examples/CMakeLists.txt | 41 - gr-fcd/examples/c++/CMakeLists.txt | 31 + gr-fcd/examples/c++/fcd_nfm_rx.cc | 114 + gr-fcd/examples/fcd_apt_rx.grc | 704 ------ gr-fcd/examples/fcd_fft_wx.grc | 320 --- gr-fcd/examples/fcd_nfm_rx.cc | 114 - gr-fcd/examples/fcd_nfm_rx.grc | 1035 --------- gr-fcd/examples/grc/CMakeLists.txt | 26 + gr-fcd/examples/grc/fcd_apt_rx.grc | 704 ++++++ gr-fcd/examples/grc/fcd_fft_wx.grc | 320 +++ gr-fcd/examples/grc/fcd_nfm_rx.grc | 1035 +++++++++ gr-noaa/CMakeLists.txt | 2 + gr-noaa/examples/CMakeLists.txt | 8 +- gr-qtgui/CMakeLists.txt | 2 + gr-qtgui/examples/CMakeLists.txt | 4 +- gr-trellis/CMakeLists.txt | 5 +- gr-trellis/src/examples/CMakeLists.txt | 64 - gr-trellis/src/examples/README | 35 - gr-trellis/src/examples/fsm_files/awgn1o2_128.fsm | 265 --- gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm | 39 - gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm | 14 - gr-trellis/src/examples/fsm_files/awgn1o2_8.fsm | 24 - gr-trellis/src/examples/fsm_files/awgn2o3_16.fsm | 40 - gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm | 15 - .../src/examples/fsm_files/awgn2o3_4_msb.fsm | 46 - .../src/examples/fsm_files/awgn2o3_4_msbG.fsm | 60 - gr-trellis/src/examples/fsm_files/awgn2o3_8.fsm | 25 - gr-trellis/src/examples/fsm_files/awgn2o4_4.fsm | 36 - gr-trellis/src/examples/fsm_files/disconnected.fsm | 11 - gr-trellis/src/examples/fsm_files/irregular.fsm | 11 - gr-trellis/src/examples/fsm_files/joint_16_16.fsm | 523 ----- gr-trellis/src/examples/fsm_files/joint_4_16.fsm | 141 -- gr-trellis/src/examples/fsm_files/rep3.fsm | 8 - gr-trellis/src/examples/fsm_files/rep5.fsm | 7 - gr-trellis/src/examples/fsm_files/simple.fsm | 13 - gr-trellis/src/examples/fsm_utils.py | 239 --- gr-trellis/src/examples/grc/CMakeLists.txt | 30 + .../src/examples/grc/interference_cancellation.grc | 2177 +++++++++++++++++++ gr-trellis/src/examples/grc/pccc.grc | 832 ++++++++ gr-trellis/src/examples/grc/pccc1.grc | 857 ++++++++ gr-trellis/src/examples/grc/readme.txt | 32 + gr-trellis/src/examples/grc/sccc.grc | 832 ++++++++ gr-trellis/src/examples/grc/sccc1.grc | 857 ++++++++ gr-trellis/src/examples/python/CMakeLists.txt | 64 + gr-trellis/src/examples/python/README | 35 + .../src/examples/python/fsm_files/awgn1o2_128.fsm | 265 +++ .../src/examples/python/fsm_files/awgn1o2_16.fsm | 39 + .../src/examples/python/fsm_files/awgn1o2_4.fsm | 14 + .../src/examples/python/fsm_files/awgn1o2_8.fsm | 24 + .../src/examples/python/fsm_files/awgn2o3_16.fsm | 40 + .../src/examples/python/fsm_files/awgn2o3_4.fsm | 15 + .../examples/python/fsm_files/awgn2o3_4_msb.fsm | 46 + .../examples/python/fsm_files/awgn2o3_4_msbG.fsm | 60 + .../src/examples/python/fsm_files/awgn2o3_8.fsm | 25 + .../src/examples/python/fsm_files/awgn2o4_4.fsm | 36 + .../src/examples/python/fsm_files/disconnected.fsm | 11 + .../src/examples/python/fsm_files/irregular.fsm | 11 + .../src/examples/python/fsm_files/joint_16_16.fsm | 523 +++++ .../src/examples/python/fsm_files/joint_4_16.fsm | 141 ++ gr-trellis/src/examples/python/fsm_files/rep3.fsm | 8 + gr-trellis/src/examples/python/fsm_files/rep5.fsm | 7 + .../src/examples/python/fsm_files/simple.fsm | 13 + gr-trellis/src/examples/python/fsm_utils.py | 239 +++ gr-trellis/src/examples/python/test_cpm.py | 154 ++ gr-trellis/src/examples/python/test_pccc_turbo1.py | 119 ++ gr-trellis/src/examples/python/test_sccc_hard.py | 100 + gr-trellis/src/examples/python/test_sccc_soft.py | 107 + gr-trellis/src/examples/python/test_sccc_turbo.py | 142 ++ gr-trellis/src/examples/python/test_sccc_turbo1.py | 99 + gr-trellis/src/examples/python/test_sccc_turbo2.py | 101 + gr-trellis/src/examples/python/test_tcm.py | 126 ++ gr-trellis/src/examples/python/test_tcm_bit.py | 129 ++ .../src/examples/python/test_tcm_combined.py | 107 + .../src/examples/python/test_tcm_parallel.py | 113 + .../src/examples/python/test_turbo_equalization.py | 142 ++ .../examples/python/test_turbo_equalization1.py | 146 ++ .../examples/python/test_turbo_equalization2.py | 146 ++ .../examples/python/test_viterbi_equalization.py | 93 + .../examples/python/test_viterbi_equalization1.py | 102 + gr-trellis/src/examples/test_cpm.py | 154 -- gr-trellis/src/examples/test_pccc_turbo1.py | 119 -- gr-trellis/src/examples/test_sccc_hard.py | 100 - gr-trellis/src/examples/test_sccc_soft.py | 107 - gr-trellis/src/examples/test_sccc_turbo.py | 142 -- gr-trellis/src/examples/test_sccc_turbo1.py | 99 - gr-trellis/src/examples/test_sccc_turbo2.py | 101 - gr-trellis/src/examples/test_tcm.py | 126 -- gr-trellis/src/examples/test_tcm_bit.py | 129 -- gr-trellis/src/examples/test_tcm_combined.py | 107 - gr-trellis/src/examples/test_tcm_parallel.py | 113 - gr-trellis/src/examples/test_turbo_equalization.py | 142 -- .../src/examples/test_turbo_equalization1.py | 146 -- .../src/examples/test_turbo_equalization2.py | 146 -- .../src/examples/test_viterbi_equalization.py | 93 - .../src/examples/test_viterbi_equalization1.py | 102 - gr-uhd/CMakeLists.txt | 13 +- gr-uhd/examples/CMakeLists.txt | 67 - gr-uhd/examples/c++/CMakeLists.txt | 45 + gr-uhd/examples/c++/tag_sink_demo.h | 66 + gr-uhd/examples/c++/tag_source_demo.h | 128 ++ gr-uhd/examples/c++/tags_demo.cc | 139 ++ gr-uhd/examples/fm_tx4.py | 208 -- gr-uhd/examples/fm_tx_2_daughterboards.py | 212 -- gr-uhd/examples/grc/CMakeLists.txt | 31 + gr-uhd/examples/grc/uhd_const_wave.grc | 1020 +++++++++ gr-uhd/examples/grc/uhd_dpsk_mod.grc | 2238 ++++++++++++++++++++ gr-uhd/examples/grc/uhd_fft.grc | 1025 +++++++++ gr-uhd/examples/grc/uhd_rx_dpsk.grc | 1431 +++++++++++++ gr-uhd/examples/grc/uhd_two_tone_loopback.grc | 2204 +++++++++++++++++++ gr-uhd/examples/grc/uhd_tx_dpsk.grc | 1234 +++++++++++ gr-uhd/examples/grc/uhd_wbfm_receive.grc | 1365 ++++++++++++ gr-uhd/examples/max_power.py | 140 -- gr-uhd/examples/python/CMakeLists.txt | 42 + gr-uhd/examples/python/fm_tx4.py | 208 ++ gr-uhd/examples/python/fm_tx_2_daughterboards.py | 212 ++ gr-uhd/examples/python/max_power.py | 140 ++ gr-uhd/examples/python/usrp_am_mw_rcv.py | 315 +++ gr-uhd/examples/python/usrp_nbfm_ptt.py | 489 +++++ gr-uhd/examples/python/usrp_nbfm_rcv.py | 380 ++++ gr-uhd/examples/python/usrp_spectrum_sense.py | 258 +++ gr-uhd/examples/python/usrp_tv_rcv.py | 443 ++++ gr-uhd/examples/python/usrp_tv_rcv_nogui.py | 214 ++ gr-uhd/examples/python/usrp_wfm_rcv.py | 286 +++ gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py | 154 ++ gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py | 349 +++ gr-uhd/examples/python/usrp_wfm_rcv_nogui.py | 175 ++ gr-uhd/examples/python/usrp_wfm_rcv_pll.py | 346 +++ gr-uhd/examples/python/usrp_wfm_rcv_sca.py | 403 ++++ gr-uhd/examples/python/usrp_wxapt_rcv.py | 282 +++ gr-uhd/examples/tag_sink_demo.h | 66 - gr-uhd/examples/tag_source_demo.h | 128 -- gr-uhd/examples/tags_demo.cc | 139 -- gr-uhd/examples/usrp_am_mw_rcv.py | 315 --- gr-uhd/examples/usrp_nbfm_ptt.py | 489 ----- gr-uhd/examples/usrp_nbfm_rcv.py | 380 ---- gr-uhd/examples/usrp_spectrum_sense.py | 258 --- gr-uhd/examples/usrp_tv_rcv.py | 443 ---- gr-uhd/examples/usrp_tv_rcv_nogui.py | 214 -- gr-uhd/examples/usrp_wfm_rcv.py | 286 --- gr-uhd/examples/usrp_wfm_rcv2_nogui.py | 154 -- gr-uhd/examples/usrp_wfm_rcv_fmdet.py | 349 --- gr-uhd/examples/usrp_wfm_rcv_nogui.py | 175 -- gr-uhd/examples/usrp_wfm_rcv_pll.py | 346 --- gr-uhd/examples/usrp_wfm_rcv_sca.py | 403 ---- gr-uhd/examples/usrp_wxapt_rcv.py | 282 --- gr-vocoder/CMakeLists.txt | 2 + gr-vocoder/examples/CMakeLists.txt | 2 +- 172 files changed, 28396 insertions(+), 28262 deletions(-) delete mode 100644 gnuradio-examples/grc/audio/cvsd_sweep.grc delete mode 100644 gnuradio-examples/grc/audio/dial_tone.grc delete mode 100644 gnuradio-examples/grc/trellis/interference_cancellation.grc delete mode 100644 gnuradio-examples/grc/trellis/pccc.grc delete mode 100644 gnuradio-examples/grc/trellis/pccc1.grc delete mode 100644 gnuradio-examples/grc/trellis/readme.txt delete mode 100644 gnuradio-examples/grc/trellis/sccc.grc delete mode 100644 gnuradio-examples/grc/trellis/sccc1.grc delete mode 100644 gnuradio-examples/grc/uhd/uhd_const_wave.grc delete mode 100644 gnuradio-examples/grc/uhd/uhd_dpsk_mod.grc delete mode 100644 gnuradio-examples/grc/uhd/uhd_fft.grc delete mode 100644 gnuradio-examples/grc/uhd/uhd_rx_dpsk.grc delete mode 100644 gnuradio-examples/grc/uhd/uhd_two_tone_loopback.grc delete mode 100644 gnuradio-examples/grc/uhd/uhd_tx_dpsk.grc delete mode 100644 gnuradio-examples/grc/uhd/uhd_wbfm_receive.grc create mode 100644 gr-audio/examples/grc/CMakeLists.txt create mode 100644 gr-audio/examples/grc/cvsd_sweep.grc create mode 100644 gr-audio/examples/grc/dial_tone.grc delete mode 100644 gr-fcd/examples/CMakeLists.txt create mode 100644 gr-fcd/examples/c++/CMakeLists.txt create mode 100644 gr-fcd/examples/c++/fcd_nfm_rx.cc delete mode 100644 gr-fcd/examples/fcd_apt_rx.grc delete mode 100644 gr-fcd/examples/fcd_fft_wx.grc delete mode 100644 gr-fcd/examples/fcd_nfm_rx.cc delete mode 100644 gr-fcd/examples/fcd_nfm_rx.grc create mode 100644 gr-fcd/examples/grc/CMakeLists.txt create mode 100644 gr-fcd/examples/grc/fcd_apt_rx.grc create mode 100644 gr-fcd/examples/grc/fcd_fft_wx.grc create mode 100644 gr-fcd/examples/grc/fcd_nfm_rx.grc delete mode 100644 gr-trellis/src/examples/CMakeLists.txt delete mode 100644 gr-trellis/src/examples/README delete mode 100644 gr-trellis/src/examples/fsm_files/awgn1o2_128.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/awgn1o2_8.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/awgn2o3_16.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/awgn2o3_4_msb.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/awgn2o3_4_msbG.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/awgn2o3_8.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/awgn2o4_4.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/disconnected.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/irregular.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/joint_16_16.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/joint_4_16.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/rep3.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/rep5.fsm delete mode 100644 gr-trellis/src/examples/fsm_files/simple.fsm delete mode 100755 gr-trellis/src/examples/fsm_utils.py create mode 100644 gr-trellis/src/examples/grc/CMakeLists.txt create mode 100644 gr-trellis/src/examples/grc/interference_cancellation.grc create mode 100644 gr-trellis/src/examples/grc/pccc.grc create mode 100644 gr-trellis/src/examples/grc/pccc1.grc create mode 100644 gr-trellis/src/examples/grc/readme.txt create mode 100644 gr-trellis/src/examples/grc/sccc.grc create mode 100644 gr-trellis/src/examples/grc/sccc1.grc create mode 100644 gr-trellis/src/examples/python/CMakeLists.txt create mode 100644 gr-trellis/src/examples/python/README create mode 100644 gr-trellis/src/examples/python/fsm_files/awgn1o2_128.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/awgn1o2_16.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/awgn1o2_4.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/awgn1o2_8.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/awgn2o3_16.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/awgn2o3_4.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/awgn2o3_4_msb.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/awgn2o3_4_msbG.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/awgn2o3_8.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/awgn2o4_4.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/disconnected.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/irregular.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/joint_16_16.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/joint_4_16.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/rep3.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/rep5.fsm create mode 100644 gr-trellis/src/examples/python/fsm_files/simple.fsm create mode 100755 gr-trellis/src/examples/python/fsm_utils.py create mode 100755 gr-trellis/src/examples/python/test_cpm.py create mode 100755 gr-trellis/src/examples/python/test_pccc_turbo1.py create mode 100755 gr-trellis/src/examples/python/test_sccc_hard.py create mode 100755 gr-trellis/src/examples/python/test_sccc_soft.py create mode 100755 gr-trellis/src/examples/python/test_sccc_turbo.py create mode 100755 gr-trellis/src/examples/python/test_sccc_turbo1.py create mode 100755 gr-trellis/src/examples/python/test_sccc_turbo2.py create mode 100755 gr-trellis/src/examples/python/test_tcm.py create mode 100755 gr-trellis/src/examples/python/test_tcm_bit.py create mode 100755 gr-trellis/src/examples/python/test_tcm_combined.py create mode 100755 gr-trellis/src/examples/python/test_tcm_parallel.py create mode 100755 gr-trellis/src/examples/python/test_turbo_equalization.py create mode 100755 gr-trellis/src/examples/python/test_turbo_equalization1.py create mode 100755 gr-trellis/src/examples/python/test_turbo_equalization2.py create mode 100755 gr-trellis/src/examples/python/test_viterbi_equalization.py create mode 100755 gr-trellis/src/examples/python/test_viterbi_equalization1.py delete mode 100755 gr-trellis/src/examples/test_cpm.py delete mode 100755 gr-trellis/src/examples/test_pccc_turbo1.py delete mode 100755 gr-trellis/src/examples/test_sccc_hard.py delete mode 100755 gr-trellis/src/examples/test_sccc_soft.py delete mode 100755 gr-trellis/src/examples/test_sccc_turbo.py delete mode 100755 gr-trellis/src/examples/test_sccc_turbo1.py delete mode 100755 gr-trellis/src/examples/test_sccc_turbo2.py delete mode 100755 gr-trellis/src/examples/test_tcm.py delete mode 100755 gr-trellis/src/examples/test_tcm_bit.py delete mode 100755 gr-trellis/src/examples/test_tcm_combined.py delete mode 100755 gr-trellis/src/examples/test_tcm_parallel.py delete mode 100755 gr-trellis/src/examples/test_turbo_equalization.py delete mode 100755 gr-trellis/src/examples/test_turbo_equalization1.py delete mode 100755 gr-trellis/src/examples/test_turbo_equalization2.py delete mode 100755 gr-trellis/src/examples/test_viterbi_equalization.py delete mode 100755 gr-trellis/src/examples/test_viterbi_equalization1.py delete mode 100644 gr-uhd/examples/CMakeLists.txt create mode 100644 gr-uhd/examples/c++/CMakeLists.txt create mode 100644 gr-uhd/examples/c++/tag_sink_demo.h create mode 100644 gr-uhd/examples/c++/tag_source_demo.h create mode 100644 gr-uhd/examples/c++/tags_demo.cc delete mode 100755 gr-uhd/examples/fm_tx4.py delete mode 100755 gr-uhd/examples/fm_tx_2_daughterboards.py create mode 100644 gr-uhd/examples/grc/CMakeLists.txt create mode 100644 gr-uhd/examples/grc/uhd_const_wave.grc create mode 100644 gr-uhd/examples/grc/uhd_dpsk_mod.grc create mode 100644 gr-uhd/examples/grc/uhd_fft.grc create mode 100644 gr-uhd/examples/grc/uhd_rx_dpsk.grc create mode 100644 gr-uhd/examples/grc/uhd_two_tone_loopback.grc create mode 100644 gr-uhd/examples/grc/uhd_tx_dpsk.grc create mode 100644 gr-uhd/examples/grc/uhd_wbfm_receive.grc delete mode 100755 gr-uhd/examples/max_power.py create mode 100644 gr-uhd/examples/python/CMakeLists.txt create mode 100755 gr-uhd/examples/python/fm_tx4.py create mode 100755 gr-uhd/examples/python/fm_tx_2_daughterboards.py create mode 100755 gr-uhd/examples/python/max_power.py create mode 100755 gr-uhd/examples/python/usrp_am_mw_rcv.py create mode 100755 gr-uhd/examples/python/usrp_nbfm_ptt.py create mode 100755 gr-uhd/examples/python/usrp_nbfm_rcv.py create mode 100755 gr-uhd/examples/python/usrp_spectrum_sense.py create mode 100755 gr-uhd/examples/python/usrp_tv_rcv.py create mode 100755 gr-uhd/examples/python/usrp_tv_rcv_nogui.py create mode 100755 gr-uhd/examples/python/usrp_wfm_rcv.py create mode 100755 gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py create mode 100755 gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py create mode 100755 gr-uhd/examples/python/usrp_wfm_rcv_nogui.py create mode 100755 gr-uhd/examples/python/usrp_wfm_rcv_pll.py create mode 100755 gr-uhd/examples/python/usrp_wfm_rcv_sca.py create mode 100755 gr-uhd/examples/python/usrp_wxapt_rcv.py delete mode 100644 gr-uhd/examples/tag_sink_demo.h delete mode 100644 gr-uhd/examples/tag_source_demo.h delete mode 100644 gr-uhd/examples/tags_demo.cc delete mode 100755 gr-uhd/examples/usrp_am_mw_rcv.py delete mode 100755 gr-uhd/examples/usrp_nbfm_ptt.py delete mode 100755 gr-uhd/examples/usrp_nbfm_rcv.py delete mode 100755 gr-uhd/examples/usrp_spectrum_sense.py delete mode 100755 gr-uhd/examples/usrp_tv_rcv.py delete mode 100755 gr-uhd/examples/usrp_tv_rcv_nogui.py delete mode 100755 gr-uhd/examples/usrp_wfm_rcv.py delete mode 100755 gr-uhd/examples/usrp_wfm_rcv2_nogui.py delete mode 100755 gr-uhd/examples/usrp_wfm_rcv_fmdet.py delete mode 100755 gr-uhd/examples/usrp_wfm_rcv_nogui.py delete mode 100755 gr-uhd/examples/usrp_wfm_rcv_pll.py delete mode 100755 gr-uhd/examples/usrp_wfm_rcv_sca.py delete mode 100755 gr-uhd/examples/usrp_wxapt_rcv.py diff --git a/gnuradio-examples/grc/CMakeLists.txt b/gnuradio-examples/grc/CMakeLists.txt index 75f10d86a..680172cfa 100644 --- a/gnuradio-examples/grc/CMakeLists.txt +++ b/gnuradio-examples/grc/CMakeLists.txt @@ -17,15 +17,6 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -# AUDIO -install( - FILES - audio/cvsd_sweep.grc - audio/dial_tone.grc - DESTINATION ${GR_PKG_DATA_DIR}/examples/grc/audio - COMPONENT "gnuadio-examples" -) - # DEMOD install( FILES @@ -33,7 +24,7 @@ install( demod/mpsk_demod.grc demod/pam_sync.grc demod/pam_timing.grc - DESTINATION ${GR_PKG_DATA_DIR}/examples/grc/demod + DESTINATION ${GR_PKG_DATA_DIR}/examples/demod COMPONENT "gnuadio-examples" ) @@ -43,34 +34,7 @@ install( simple/ber_simulation.grc simple/dpsk_loopback.grc simple/variable_config.grc - DESTINATION ${GR_PKG_DATA_DIR}/examples/grc/simple - COMPONENT "gnuadio-examples" -) - -# TRELLIS -install( - FILES - trellis/interference_cancellation.grc - trellis/pccc1.grc - trellis/pccc.grc - trellis/sccc1.grc - trellis/sccc.grc - trellis/readme.txt - DESTINATION ${GR_PKG_DATA_DIR}/examples/grc/trellis - COMPONENT "gnuadio-examples" -) - -# UHD -install( - FILES - uhd/uhd_const_wave.grc - uhd/uhd_dpsk_mod.grc - uhd/uhd_fft.grc - uhd/uhd_rx_dpsk.grc - uhd/uhd_two_tone_loopback.grc - uhd/uhd_tx_dpsk.grc - uhd/uhd_wbfm_receive.grc - DESTINATION ${GR_PKG_DATA_DIR}/examples/grc/uhd + DESTINATION ${GR_PKG_DATA_DIR}/examples/simple COMPONENT "gnuadio-examples" ) @@ -81,6 +45,6 @@ install( xmlrpc/xmlrpc_client.grc xmlrpc/xmlrpc_client_script.py xmlrpc/xmlrpc_server.grc - DESTINATION ${GR_PKG_DATA_DIR}/examples/grc/xmlrpc + DESTINATION ${GR_PKG_DATA_DIR}/examples/xmlrpc COMPONENT "gnuadio-examples" ) diff --git a/gnuradio-examples/grc/audio/cvsd_sweep.grc b/gnuradio-examples/grc/audio/cvsd_sweep.grc deleted file mode 100644 index b645b747a..000000000 --- a/gnuradio-examples/grc/audio/cvsd_sweep.grc +++ /dev/null @@ -1,918 +0,0 @@ - - - Sat Sep 19 20:30:08 2009 - - import - - id - import_0 - - - _enabled - True - - - import - import math - - - _coordinate - (157, 11) - - - _rotation - 0 - - - - vocoder_cvsd_decode_bf - - id - vocoder_cvsd_decode_bf_0 - - - _enabled - True - - - resample - resample - - - bw - bw - - - _coordinate - (887, 340) - - - _rotation - 0 - - - - gr_sig_source_x - - id - tri_source - - - _enabled - True - - - type - float - - - samp_rate - audio_rate - - - waveform - gr.GR_TRI_WAVE - - - freq - 0.05 - - - amp - 0.5 - - - offset - 0 - - - _coordinate - (44, 316) - - - _rotation - 0 - - - - gr_throttle - - id - throttle - - - _enabled - True - - - type - float - - - samples_per_second - audio_rate - - - vlen - 1 - - - _coordinate - (238, 348) - - - _rotation - 0 - - - - gr_vco_f - - id - vco - - - _enabled - True - - - samp_rate - audio_rate - - - sensitivity - audio_rate*2*math.pi - - - amplitude - 0.9 - - - _coordinate - (427, 332) - - - _rotation - 0 - - - - vocoder_cvsd_encode_fb - - id - enc - - - _enabled - True - - - resample - resample - - - bw - bw - - - _coordinate - (655, 340) - - - _rotation - 0 - - - - gr_packed_to_unpacked_xx - - id - p2u - - - _enabled - True - - - type - byte - - - bits_per_chunk - 1 - - - endianness - gr.GR_MSB_FIRST - - - _coordinate - (648, 415) - - - _rotation - 180 - - - - gr_char_to_float - - id - c2f - - - _enabled - True - - - _coordinate - (676, 483) - - - _rotation - 0 - - - - audio_sink - - id - audio_sink - - - _enabled - True - - - samp_rate - audio_rate - - - device_name - plughw:0,0 - - - ok_to_block - True - - - num_inputs - 1 - - - _coordinate - (1127, 340) - - - _rotation - 0 - - - - variable - - id - audio_rate - - - _enabled - True - - - value - 8000 - - - _coordinate - (251, 10) - - - _rotation - 0 - - - - variable - - id - resample - - - _enabled - True - - - value - 8 - - - _coordinate - (344, 11) - - - _rotation - 0 - - - - variable - - id - bw - - - _enabled - True - - - value - 0.5 - - - _coordinate - (431, 11) - - - _rotation - 0 - - - - notebook - - id - displays - - - _enabled - True - - - style - wx.NB_TOP - - - labels - ['Original','Encoded','Decoded'] - - - grid_pos - - - - notebook - - - - _coordinate - (12, 106) - - - _rotation - 0 - - - - wxgui_fftsink2 - - id - orig_fft - - - _enabled - True - - - type - float - - - title - Original Spectrum - - - samp_rate - audio_rate - - - baseband_freq - 0 - - - y_per_div - 10 - - - y_divs - 10 - - - ref_level - 0 - - - ref_scale - 2.0 - - - fft_size - 1024 - - - fft_rate - 30 - - - peak_hold - False - - - average - False - - - avg_alpha - 0 - - - grid_pos - 0, 0, 1, 1 - - - notebook - displays, 0 - - - _coordinate - (415, 97) - - - _rotation - 180 - - - - wxgui_scopesink2 - - id - orig_scope - - - _enabled - True - - - type - float - - - title - Original Waveform - - - samp_rate - audio_rate - - - v_scale - 0 - - - t_scale - 0 - - - ac_couple - False - - - xy_mode - False - - - num_inputs - 1 - - - grid_pos - 1, 0, 1, 1 - - - notebook - displays, 0 - - - _coordinate - (414, 425) - - - _rotation - 180 - - - - wxgui_fftsink2 - - id - enc_fft - - - _enabled - True - - - type - float - - - title - Encoded Spectrum - - - samp_rate - audio_rate*resample - - - baseband_freq - 0 - - - y_per_div - 10 - - - y_divs - 8 - - - ref_level - 10 - - - ref_scale - 2.0 - - - fft_size - 1024 - - - fft_rate - 30 - - - peak_hold - False - - - average - False - - - avg_alpha - 0 - - - grid_pos - 1, 0, 1, 1 - - - notebook - displays, 1 - - - _coordinate - (610, 551) - - - _rotation - 180 - - - - wxgui_scopesink2 - - id - enc_scope - - - _enabled - True - - - type - float - - - title - Encoded Waveform - - - samp_rate - audio_rate*resample - - - v_scale - 0.5 - - - t_scale - 20.0/(audio_rate*resample) - - - ac_couple - False - - - xy_mode - False - - - num_inputs - 1 - - - grid_pos - 0, 0, 1, 1 - - - notebook - displays, 1 - - - _coordinate - (858, 591) - - - _rotation - 0 - - - - wxgui_fftsink2 - - id - dec_fft - - - _enabled - True - - - type - float - - - title - Decoded Spectrum - - - samp_rate - audio_rate - - - baseband_freq - 0 - - - y_per_div - 5 - - - y_divs - 10 - - - ref_level - 10 - - - ref_scale - 0.1 - - - fft_size - 1024 - - - fft_rate - 30 - - - peak_hold - False - - - average - False - - - avg_alpha - 0 - - - grid_pos - 0, 0, 1, 1 - - - notebook - displays, 2 - - - _coordinate - (891, 98) - - - _rotation - 180 - - - - wxgui_scopesink2 - - id - dec_scope - - - _enabled - True - - - type - float - - - title - Decoded Waveform - - - samp_rate - audio_rate - - - v_scale - 0 - - - t_scale - 0 - - - ac_couple - False - - - xy_mode - False - - - num_inputs - 1 - - - grid_pos - 1, 0, 1, 1 - - - notebook - displays, 2 - - - _coordinate - (889, 422) - - - _rotation - 180 - - - - options - - id - cvsd_sweep - - - _enabled - True - - - title - CVSD Vocoder Test - - - author - - - - description - - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - vco - orig_fft - 0 - 0 - - - tri_source - throttle - 0 - 0 - - - throttle - vco - 0 - 0 - - - vco - enc - 0 - 0 - - - enc - vocoder_cvsd_decode_bf_0 - 0 - 0 - - - vco - orig_scope - 0 - 0 - - - vocoder_cvsd_decode_bf_0 - dec_fft - 0 - 0 - - - vocoder_cvsd_decode_bf_0 - dec_scope - 0 - 0 - - - vocoder_cvsd_decode_bf_0 - audio_sink - 0 - 0 - - - enc - p2u - 0 - 0 - - - p2u - c2f - 0 - 0 - - - c2f - enc_fft - 0 - 0 - - - c2f - enc_scope - 0 - 0 - - diff --git a/gnuradio-examples/grc/audio/dial_tone.grc b/gnuradio-examples/grc/audio/dial_tone.grc deleted file mode 100644 index ac8cbef27..000000000 --- a/gnuradio-examples/grc/audio/dial_tone.grc +++ /dev/null @@ -1,375 +0,0 @@ - - - Thu Jul 24 14:27:48 2008 - - options - - id - dial_tone - - - _enabled - True - - - title - Dial Tone - - - author - Example - - - description - example flow graph - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - gr_add_xx - - id - gr_add_xx - - - _enabled - True - - - type - float - - - num_inputs - 3 - - - vlen - 1 - - - _coordinate - (513, 277) - - - _rotation - 0 - - - - audio_sink - - id - audio_sink - - - _enabled - True - - - samp_rate - 32000 - - - device_name - - - - ok_to_block - True - - - num_inputs - 1 - - - _coordinate - (699, 112) - - - _rotation - 0 - - - - gr_noise_source_x - - id - gr_noise_source_x - - - _enabled - True - - - type - float - - - noise_type - gr.GR_GAUSSIAN - - - amp - noise - - - seed - 42 - - - _coordinate - (238, 380) - - - _rotation - 0 - - - - gr_sig_source_x - - id - gr_sig_source_x - - - _enabled - True - - - type - float - - - samp_rate - samp_rate - - - waveform - gr.GR_COS_WAVE - - - freq - 440 - - - amp - ampl - - - offset - 0 - - - _coordinate - (240, 208) - - - _rotation - 0 - - - - gr_sig_source_x - - id - gr_sig_source_x0 - - - _enabled - True - - - type - float - - - samp_rate - samp_rate - - - waveform - gr.GR_COS_WAVE - - - freq - 350 - - - amp - ampl - - - offset - 0 - - - _coordinate - (240, 38) - - - _rotation - 0 - - - - variable_slider - - id - ampl - - - _enabled - True - - - label - Volume - - - value - .4 - - - min - 0 - - - max - .5 - - - num_steps - 100 - - - slider_type - horizontal - - - grid_pos - 0, 0, 1, 2 - - - _coordinate - (634, 413) - - - _rotation - 0 - - - - variable_slider - - id - noise - - - _enabled - True - - - label - Noise - - - value - .005 - - - min - 0 - - - max - .2 - - - num_steps - 100 - - - slider_type - horizontal - - - grid_pos - 1, 0, 1, 2 - - - _coordinate - (443, 412) - - - _rotation - 0 - - - - variable - - id - samp_rate - - - _enabled - True - - - value - 32000 - - - _coordinate - (11, 171) - - - _rotation - 0 - - - - gr_sig_source_x0 - gr_add_xx - 0 - 0 - - - gr_sig_source_x - gr_add_xx - 0 - 1 - - - gr_noise_source_x - gr_add_xx - 0 - 2 - - - gr_add_xx - audio_sink - 0 - 0 - - diff --git a/gnuradio-examples/grc/trellis/interference_cancellation.grc b/gnuradio-examples/grc/trellis/interference_cancellation.grc deleted file mode 100644 index 7674b4bf1..000000000 --- a/gnuradio-examples/grc/trellis/interference_cancellation.grc +++ /dev/null @@ -1,2177 +0,0 @@ - - - Wed Aug 31 17:40:25 2011 - - options - - id - int_cancellation - - - _enabled - True - - - title - Superposition Coding - - - author - AA - - - description - gnuradio flow graph - - - window_size - 2048, 2048 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - variable_slider - - id - alpha - - - _enabled - True - - - label - P1/P - - - value - 0.6 - - - min - 0 - - - max - 1.0 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (243, 11) - - - _rotation - 0 - - - - variable_slider - - id - snr_db - - - _enabled - True - - - label - P/sigma^2 (dB) - - - value - 16 - - - min - 0 - - - max - 20 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (447, 14) - - - _rotation - 0 - - - - variable - - id - noisevar - - - _enabled - True - - - value - 10**(-snr_db/10) - - - _coordinate - (637, 13) - - - _rotation - 0 - - - - random_source_x - - id - random_source_x_0 - - - _enabled - True - - - type - short - - - min - 0 - - - max - 2 - - - num_samps - 1000 - - - repeat - True - - - _coordinate - (21, 170) - - - _rotation - 0 - - - - gr_multiply_const_vxx - - id - gr_multiply_const_vxx_0 - - - _enabled - True - - - type - complex - - - const - alpha**0.5 - - - vlen - 1 - - - _coordinate - (988, 196) - - - _rotation - 0 - - - - random_source_x - - id - random_source_x_1 - - - _enabled - True - - - type - short - - - min - 0 - - - max - 2 - - - num_samps - 1000 - - - repeat - True - - - _coordinate - (25, 291) - - - _rotation - 0 - - - - gr_chunks_to_symbols_xx - - id - gr_chunks_to_symbols_xx_1 - - - _enabled - True - - - in_type - short - - - out_type - complex - - - symbol_table - 1,1j,-1j,-1 - - - dimension - 1 - - - num_ports - 1 - - - _coordinate - (660, 311) - - - _rotation - 0 - - - - gr_multiply_const_vxx - - id - gr_multiply_const_vxx_1 - - - _enabled - True - - - type - complex - - - const - (1-alpha)**0.5 - - - vlen - 1 - - - _coordinate - (994, 319) - - - _rotation - 0 - - - - gr_add_xx - - id - gr_add_xx_0 - - - _enabled - True - - - type - complex - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (1224, 244) - - - _rotation - 0 - - - - gr_noise_source_x - - id - gr_noise_source_x_0 - - - _enabled - True - - - type - complex - - - noise_type - gr.GR_GAUSSIAN - - - amp - noisevar - - - seed - 42 - - - _coordinate - (1146, 369) - - - _rotation - 0 - - - - gr_sub_xx - - id - gr_sub_xx_0 - - - _enabled - True - - - type - short - - - vlen - 1 - - - num_inputs - 2 - - - _coordinate - (536, 529) - - - _rotation - 0 - - - - gr_multiply_xx - - id - gr_multiply_xx_0 - - - _enabled - True - - - type - short - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (771, 525) - - - _rotation - 0 - - - - gr_short_to_float - - id - gr_short_to_float_0 - - - _enabled - True - - - _coordinate - (994, 545) - - - _rotation - 0 - - - - gr_sub_xx - - id - gr_sub_xx_3 - - - _enabled - True - - - type - short - - - vlen - 1 - - - num_inputs - 2 - - - _coordinate - (535, 792) - - - _rotation - 0 - - - - gr_multiply_xx - - id - gr_multiply_xx_1 - - - _enabled - True - - - type - short - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (785, 779) - - - _rotation - 0 - - - - gr_short_to_float - - id - gr_short_to_float_2 - - - _enabled - True - - - _coordinate - (1005, 798) - - - _rotation - 0 - - - - gr_chunks_to_symbols_xx - - id - gr_chunks_to_symbols_xx_2 - - - _enabled - True - - - in_type - short - - - out_type - complex - - - symbol_table - 1,1j,-1j,-1 - - - dimension - 1 - - - num_ports - 1 - - - _coordinate - (405, 998) - - - _rotation - 0 - - - - gr_multiply_const_vxx - - id - gr_multiply_const_vxx_2 - - - _enabled - True - - - type - complex - - - const - alpha**0.5 - - - vlen - 1 - - - _coordinate - (710, 1008) - - - _rotation - 0 - - - - gr_sub_xx - - id - gr_sub_xx_2 - - - _enabled - True - - - type - complex - - - vlen - 1 - - - num_inputs - 2 - - - _coordinate - (944, 978) - - - _rotation - 0 - - - - gr_sub_xx - - id - gr_sub_xx_1 - - - _enabled - True - - - type - short - - - vlen - 1 - - - num_inputs - 2 - - - _coordinate - (540, 1141) - - - _rotation - 0 - - - - gr_multiply_xx - - id - gr_multiply_xx_2 - - - _enabled - True - - - type - short - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (796, 1136) - - - _rotation - 0 - - - - gr_short_to_float - - id - gr_short_to_float_1 - - - _enabled - True - - - _coordinate - (1009, 1156) - - - _rotation - 0 - - - - gr_chunks_to_symbols_xx - - id - gr_chunks_to_symbols_xx_2_0 - - - _enabled - True - - - in_type - short - - - out_type - complex - - - symbol_table - 1,1j,-1j,-1 - - - dimension - 1 - - - num_ports - 1 - - - _coordinate - (420, 1368) - - - _rotation - 0 - - - - gr_multiply_const_vxx - - id - gr_multiply_const_vxx_2_0 - - - _enabled - True - - - type - complex - - - const - (1-alpha)**0.5 - - - vlen - 1 - - - _coordinate - (733, 1374) - - - _rotation - 0 - - - - gr_sub_xx - - id - gr_sub_xx_2_0 - - - _enabled - True - - - type - complex - - - vlen - 1 - - - num_inputs - 2 - - - _coordinate - (975, 1342) - - - _rotation - 0 - - - - gr_sub_xx - - id - gr_sub_xx_1_0 - - - _enabled - True - - - type - short - - - vlen - 1 - - - num_inputs - 2 - - - _coordinate - (559, 1536) - - - _rotation - 0 - - - - gr_multiply_xx - - id - gr_multiply_xx_2_0 - - - _enabled - True - - - type - short - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (771, 1530) - - - _rotation - 0 - - - - gr_short_to_float - - id - gr_short_to_float_1_0 - - - _enabled - True - - - _coordinate - (1010, 1551) - - - _rotation - 0 - - - - trellis_encoder_xx - - id - trellis_encoder_xx_1 - - - _enabled - True - - - type - ss - - - fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" - - - init_state - 0 - - - _coordinate - (336, 311) - - - _rotation - 0 - - - - trellis_viterbi_combined_xx - - id - trellis_viterbi_combined_xx_1 - - - _enabled - True - - - type - c - - - out_type - s - - - fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" - - - block_size - 1000 - - - init_state - -1 - - - final_state - -1 - - - dim - 1 - - - table - alpha**0.5*1,alpha**0.5*1j,alpha**0.5*(-1j),alpha**0.5*(-1) - - - metric_type - trellis.TRELLIS_EUCLIDEAN - - - _coordinate - (79, 501) - - - _rotation - 0 - - - - trellis_viterbi_combined_xx - - id - trellis_viterbi_combined_xx_2 - - - _enabled - True - - - type - c - - - out_type - s - - - fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" - - - block_size - 1000 - - - init_state - -1 - - - final_state - -1 - - - dim - 1 - - - table - (1-alpha)**0.5*1,(1-alpha)**0.5*1j,(1-alpha)**0.5*(-1j),(1-alpha)**0.5*(-1) - - - metric_type - trellis.TRELLIS_EUCLIDEAN - - - _coordinate - (82, 766) - - - _rotation - 0 - - - - trellis_encoder_xx - - id - trellis_encoder_xx_2 - - - _enabled - True - - - type - ss - - - fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" - - - init_state - 0 - - - _coordinate - (89, 998) - - - _rotation - 0 - - - - trellis_viterbi_combined_xx - - id - trellis_viterbi_combined_xx_0 - - - _enabled - True - - - type - c - - - out_type - s - - - fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" - - - block_size - 1000 - - - init_state - -1 - - - final_state - -1 - - - dim - 1 - - - table - (1-alpha)**0.5*1,(1-alpha)**0.5*1j,(1-alpha)**0.5*(-1j),(1-alpha)**0.5*(-1) - - - metric_type - trellis.TRELLIS_EUCLIDEAN - - - _coordinate - (83, 1111) - - - _rotation - 0 - - - - trellis_encoder_xx - - id - trellis_encoder_xx_2_0 - - - _enabled - True - - - type - ss - - - fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" - - - init_state - 0 - - - _coordinate - (105, 1367) - - - _rotation - 0 - - - - trellis_viterbi_combined_xx - - id - trellis_viterbi_combined_xx_0_0 - - - _enabled - True - - - type - c - - - out_type - s - - - fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" - - - block_size - 1000 - - - init_state - -1 - - - final_state - -1 - - - dim - 1 - - - table - alpha**0.5*1,alpha**0.5*1j,alpha**0.5*(-1j),alpha**0.5*(-1) - - - metric_type - trellis.TRELLIS_EUCLIDEAN - - - _coordinate - (75, 1495) - - - _rotation - 0 - - - - gr_add_xx - - id - gr_add_xx_1 - - - _enabled - True - - - type - complex - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (1400, 262) - - - _rotation - 0 - - - - wxgui_scopesink2 - - id - wxgui_scopesink2_0 - - - _enabled - True - - - type - complex - - - title - Scope Plot - - - samp_rate - R - - - v_scale - 0 - - - v_offset - 0 - - - t_scale - 0 - - - ac_couple - False - - - xy_mode - True - - - num_inputs - 1 - - - win_size - - - - grid_pos - - - - notebook - - - - trig_mode - gr.gr_TRIG_MODE_AUTO - - - y_axis_label - Counts - - - _coordinate - (1533, 149) - - - _rotation - 0 - - - - variable - - id - prefix - - - _enabled - True - - - value - "/n/harrisville/x/anastas/gnuradio_trunk/" - - - _coordinate - (871, 14) - - - _rotation - 0 - - - - trellis_encoder_xx - - id - trellis_encoder_xx_0 - - - _enabled - True - - - type - ss - - - fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" - - - init_state - 0 - - - _coordinate - (340, 187) - - - _rotation - 0 - - - - gr_throttle - - id - gr_throttle_0 - - - _enabled - True - - - type - short - - - samples_per_second - R - - - vlen - 1 - - - _coordinate - (534, 149) - - - _rotation - 0 - - - - gr_chunks_to_symbols_xx - - id - gr_chunks_to_symbols_xx_0 - - - _enabled - True - - - in_type - short - - - out_type - complex - - - symbol_table - 1,1j,-1j,-1 - - - dimension - 1 - - - num_ports - 1 - - - _coordinate - (682, 186) - - - _rotation - 0 - - - - variable - - id - R - - - _enabled - True - - - value - 100e3 - - - _coordinate - (748, 12) - - - _rotation - 0 - - - - wxgui_numbersink2 - - id - wxgui_numbersink2_0 - - - _enabled - True - - - type - float - - - title - BER 1 (raw) - - - units - BER - - - samp_rate - R - - - min_value - 0 - - - max_value - 1 - - - factor - 1.0 - - - decimal_places - 6 - - - ref_level - 0 - - - number_rate - 15 - - - peak_hold - False - - - average - True - - - avg_alpha - 0.001 - - - show_gauge - True - - - win_size - - - - grid_pos - 0,0,1,1 - - - notebook - - - - _coordinate - (1267, 410) - - - _rotation - 0 - - - - wxgui_numbersink2 - - id - wxgui_numbersink2_2 - - - _enabled - True - - - type - float - - - title - BER 2 (raw) - - - units - BER - - - samp_rate - R - - - min_value - 0 - - - max_value - 1.0 - - - factor - 1.0 - - - decimal_places - 6 - - - ref_level - 0 - - - number_rate - 15 - - - peak_hold - False - - - average - True - - - avg_alpha - 0.001 - - - show_gauge - True - - - win_size - - - - grid_pos - 0,1,1,1 - - - notebook - - - - _coordinate - (1260, 659) - - - _rotation - 0 - - - - wxgui_numbersink2 - - id - wxgui_numbersink2_3 - - - _enabled - True - - - type - float - - - title - BER 2 (after cancelling user 1) - - - units - BER - - - samp_rate - R - - - min_value - 0 - - - max_value - 1.0 - - - factor - 1.0 - - - decimal_places - 6 - - - ref_level - 0 - - - number_rate - 15 - - - peak_hold - False - - - average - True - - - avg_alpha - 0.001 - - - show_gauge - True - - - win_size - - - - grid_pos - 1,1,1,1 - - - notebook - - - - _coordinate - (1262, 1020) - - - _rotation - 0 - - - - wxgui_numbersink2 - - id - wxgui_numbersink2_3_0 - - - _enabled - True - - - type - float - - - title - BER 1 (after cancelling user 2) - - - units - BER - - - samp_rate - R - - - min_value - 0 - - - max_value - 1.0 - - - factor - 1.0 - - - decimal_places - 6 - - - ref_level - 0 - - - number_rate - 15 - - - peak_hold - False - - - average - True - - - avg_alpha - 0.001 - - - show_gauge - True - - - win_size - - - - grid_pos - 1,0,1,1 - - - notebook - - - - _coordinate - (1269, 1417) - - - _rotation - 0 - - - - random_source_x_1 - trellis_encoder_xx_1 - 0 - 0 - - - trellis_encoder_xx_1 - gr_chunks_to_symbols_xx_1 - 0 - 0 - - - gr_chunks_to_symbols_xx_0 - gr_multiply_const_vxx_0 - 0 - 0 - - - gr_multiply_const_vxx_0 - gr_add_xx_0 - 0 - 0 - - - gr_add_xx_0 - gr_add_xx_1 - 0 - 0 - - - gr_noise_source_x_0 - gr_add_xx_1 - 0 - 1 - - - gr_chunks_to_symbols_xx_1 - gr_multiply_const_vxx_1 - 0 - 0 - - - gr_multiply_const_vxx_1 - gr_add_xx_0 - 0 - 1 - - - gr_sub_xx_0 - gr_multiply_xx_0 - 0 - 0 - - - gr_sub_xx_0 - gr_multiply_xx_0 - 0 - 1 - - - gr_multiply_xx_0 - gr_short_to_float_0 - 0 - 0 - - - gr_short_to_float_0 - wxgui_numbersink2_0 - 0 - 0 - - - gr_multiply_xx_2 - gr_short_to_float_1 - 0 - 0 - - - random_source_x_0 - trellis_encoder_xx_0 - 0 - 0 - - - gr_add_xx_1 - trellis_viterbi_combined_xx_1 - 0 - 0 - - - random_source_x_0 - gr_sub_xx_0 - 0 - 0 - - - trellis_viterbi_combined_xx_1 - gr_sub_xx_0 - 0 - 1 - - - trellis_viterbi_combined_xx_0 - gr_sub_xx_1 - 0 - 1 - - - random_source_x_1 - gr_sub_xx_1 - 0 - 0 - - - gr_sub_xx_1 - gr_multiply_xx_2 - 0 - 0 - - - gr_sub_xx_1 - gr_multiply_xx_2 - 0 - 1 - - - gr_sub_xx_2 - trellis_viterbi_combined_xx_0 - 0 - 0 - - - gr_add_xx_1 - gr_sub_xx_2 - 0 - 0 - - - trellis_encoder_xx_2 - gr_chunks_to_symbols_xx_2 - 0 - 0 - - - gr_chunks_to_symbols_xx_2 - gr_multiply_const_vxx_2 - 0 - 0 - - - gr_multiply_const_vxx_2 - gr_sub_xx_2 - 0 - 1 - - - trellis_viterbi_combined_xx_1 - trellis_encoder_xx_2 - 0 - 0 - - - gr_multiply_xx_1 - gr_short_to_float_2 - 0 - 0 - - - gr_short_to_float_2 - wxgui_numbersink2_2 - 0 - 0 - - - trellis_viterbi_combined_xx_2 - gr_sub_xx_3 - 0 - 1 - - - gr_sub_xx_3 - gr_multiply_xx_1 - 0 - 0 - - - gr_sub_xx_3 - gr_multiply_xx_1 - 0 - 1 - - - gr_add_xx_1 - trellis_viterbi_combined_xx_2 - 0 - 0 - - - random_source_x_1 - gr_sub_xx_3 - 0 - 0 - - - gr_short_to_float_1 - wxgui_numbersink2_3 - 0 - 0 - - - trellis_encoder_xx_2_0 - gr_chunks_to_symbols_xx_2_0 - 0 - 0 - - - gr_chunks_to_symbols_xx_2_0 - gr_multiply_const_vxx_2_0 - 0 - 0 - - - trellis_viterbi_combined_xx_2 - trellis_encoder_xx_2_0 - 0 - 0 - - - gr_multiply_xx_2_0 - gr_short_to_float_1_0 - 0 - 0 - - - trellis_viterbi_combined_xx_0_0 - gr_sub_xx_1_0 - 0 - 1 - - - gr_sub_xx_1_0 - gr_multiply_xx_2_0 - 0 - 0 - - - gr_sub_xx_1_0 - gr_multiply_xx_2_0 - 0 - 1 - - - gr_sub_xx_2_0 - trellis_viterbi_combined_xx_0_0 - 0 - 0 - - - gr_short_to_float_1_0 - wxgui_numbersink2_3_0 - 0 - 0 - - - gr_add_xx_1 - gr_sub_xx_2_0 - 0 - 0 - - - random_source_x_0 - gr_sub_xx_1_0 - 0 - 0 - - - gr_multiply_const_vxx_2_0 - gr_sub_xx_2_0 - 0 - 1 - - - gr_add_xx_1 - wxgui_scopesink2_0 - 0 - 0 - - - trellis_encoder_xx_0 - gr_throttle_0 - 0 - 0 - - - gr_throttle_0 - gr_chunks_to_symbols_xx_0 - 0 - 0 - - diff --git a/gnuradio-examples/grc/trellis/pccc.grc b/gnuradio-examples/grc/trellis/pccc.grc deleted file mode 100644 index c3111c321..000000000 --- a/gnuradio-examples/grc/trellis/pccc.grc +++ /dev/null @@ -1,832 +0,0 @@ - - - Thu Sep 1 12:53:13 2011 - - options - - id - sccc1 - - - _enabled - True - - - title - Serially Concatenated Convolutional Code - - - author - AA - - - description - gnuradio flow graph - - - window_size - 2048, 2048 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - variable - - id - noisevar - - - _enabled - True - - - value - 10**(-snr_db/10) - - - _coordinate - (389, 15) - - - _rotation - 0 - - - - variable - - id - prefix - - - _enabled - True - - - value - "/n/harrisville/x/anastas/gnuradio_trunk/" - - - _coordinate - (590, 15) - - - _rotation - 0 - - - - variable - - id - block - - - _enabled - True - - - value - 1000 - - - _coordinate - (764, 16) - - - _rotation - 0 - - - - variable_slider - - id - snr_db - - - _enabled - True - - - label - SNR (dB) - - - value - 5 - - - min - -10 - - - max - 10 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (229, 13) - - - _rotation - 0 - - - - gr_multiply_xx - - id - gr_multiply_xx_2_0 - - - _enabled - True - - - type - short - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (392, 591) - - - _rotation - 0 - - - - gr_short_to_float - - id - gr_short_to_float_1_0 - - - _enabled - True - - - _coordinate - (535, 609) - - - _rotation - 0 - - - - wxgui_numbersink2 - - id - wxgui_numbersink2_3_0 - - - _enabled - True - - - type - float - - - title - BER - - - units - BER - - - samp_rate - R - - - min_value - 0 - - - max_value - 1.0 - - - factor - 1.0 - - - decimal_places - 6 - - - ref_level - 0 - - - number_rate - 15 - - - peak_hold - False - - - average - True - - - avg_alpha - 0.001 - - - show_gauge - True - - - win_size - - - - grid_pos - 1,0,1,1 - - - notebook - - - - _coordinate - (713, 426) - - - _rotation - 0 - - - - gr_noise_source_x - - id - gr_noise_source_x_0 - - - _enabled - True - - - type - float - - - noise_type - gr.GR_GAUSSIAN - - - amp - noisevar - - - seed - 42 - - - _coordinate - (672, 290) - - - _rotation - 0 - - - - wxgui_scopesink2 - - id - wxgui_scopesink2_0 - - - _enabled - False - - - type - float - - - title - Scope Plot - - - samp_rate - R - - - v_scale - 0 - - - v_offset - 0 - - - t_scale - 0 - - - ac_couple - False - - - xy_mode - False - - - num_inputs - 1 - - - win_size - - - - grid_pos - - - - notebook - - - - trig_mode - gr.gr_TRIG_MODE_AUTO - - - y_axis_label - Counts - - - _coordinate - (952, 73) - - - _rotation - 0 - - - - random_source_x - - id - random_source_x_0 - - - _enabled - True - - - type - short - - - min - 0 - - - max - 2 - - - num_samps - 1000 - - - repeat - True - - - _coordinate - (21, 170) - - - _rotation - 0 - - - - gr_throttle - - id - gr_throttle_0 - - - _enabled - True - - - type - short - - - samples_per_second - R - - - vlen - 1 - - - _coordinate - (517, 103) - - - _rotation - 0 - - - - gr_chunks_to_symbols_xx - - id - gr_chunks_to_symbols_xx_0 - - - _enabled - True - - - in_type - short - - - out_type - float - - - symbol_table - -7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7,0, 0,-7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7 - - - dimension - 2 - - - num_ports - 1 - - - _coordinate - (551, 184) - - - _rotation - 0 - - - - trellis_pccc_encoder_xx - - id - trellis_pccc_encoder_xx_0 - - - _enabled - True - - - type - ss - - - o_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" - - - o_init_state - 0 - - - i_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" - - - i_init_state - 0 - - - interleaver_args - trellis.interleaver(block,666) - - - bl - block - - - _coordinate - (236, 147) - - - _rotation - 0 - - - - variable - - id - R - - - _enabled - True - - - value - 100e3 - - - _coordinate - (482, 17) - - - _rotation - 0 - - - - gr_add_xx - - id - gr_add_xx_1 - - - _enabled - True - - - type - float - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (951, 256) - - - _rotation - 0 - - - - trellis_pccc_decoder_combined_xx - - id - trellis_pccc_decoder_combined_xx_0 - - - _enabled - True - - - type - f - - - out_type - s - - - o_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" - - - o_init_state - 0 - - - o_final_state - -1 - - - i_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" - - - i_init_state - 0 - - - i_final_state - -1 - - - interleaver - trellis.interleaver(block,666) - - - block_size - block - - - iterations - 10 - - - dim - 2 - - - table - -7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7,0, 0,-7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7 - - - metric_type - trellis.TRELLIS_EUCLIDEAN - - - siso_type - trellis.TRELLIS_MIN_SUM - - - scaling - 1.0 - - - _coordinate - (196, 274) - - - _rotation - 0 - - - - gr_sub_xx - - id - gr_sub_xx_0 - - - _enabled - True - - - type - short - - - vlen - 1 - - - num_inputs - 2 - - - _coordinate - (217, 597) - - - _rotation - 0 - - - - random_source_x_0 - gr_sub_xx_0 - 0 - 0 - - - gr_throttle_0 - gr_chunks_to_symbols_xx_0 - 0 - 0 - - - gr_add_xx_1 - wxgui_scopesink2_0 - 0 - 0 - - - gr_noise_source_x_0 - gr_add_xx_1 - 0 - 1 - - - gr_chunks_to_symbols_xx_0 - gr_add_xx_1 - 0 - 0 - - - gr_multiply_xx_2_0 - gr_short_to_float_1_0 - 0 - 0 - - - gr_short_to_float_1_0 - wxgui_numbersink2_3_0 - 0 - 0 - - - gr_sub_xx_0 - gr_multiply_xx_2_0 - 0 - 0 - - - gr_sub_xx_0 - gr_multiply_xx_2_0 - 0 - 1 - - - random_source_x_0 - trellis_pccc_encoder_xx_0 - 0 - 0 - - - trellis_pccc_encoder_xx_0 - gr_throttle_0 - 0 - 0 - - - gr_add_xx_1 - trellis_pccc_decoder_combined_xx_0 - 0 - 0 - - - trellis_pccc_decoder_combined_xx_0 - gr_sub_xx_0 - 0 - 1 - - diff --git a/gnuradio-examples/grc/trellis/pccc1.grc b/gnuradio-examples/grc/trellis/pccc1.grc deleted file mode 100644 index 15a63707e..000000000 --- a/gnuradio-examples/grc/trellis/pccc1.grc +++ /dev/null @@ -1,857 +0,0 @@ - - - Wed Aug 31 20:34:39 2011 - - options - - id - sccc1 - - - _enabled - True - - - title - Serially Concatenated Convolutional Code - - - author - AA - - - description - gnuradio flow graph - - - window_size - 2048, 2048 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - variable - - id - noisevar - - - _enabled - True - - - value - 10**(-snr_db/10) - - - _coordinate - (389, 15) - - - _rotation - 0 - - - - variable - - id - prefix - - - _enabled - True - - - value - "/n/harrisville/x/anastas/gnuradio_trunk/" - - - _coordinate - (590, 15) - - - _rotation - 0 - - - - variable - - id - block - - - _enabled - True - - - value - 1000 - - - _coordinate - (764, 16) - - - _rotation - 0 - - - - variable_slider - - id - snr_db - - - _enabled - True - - - label - SNR (dB) - - - value - 5 - - - min - -10 - - - max - 10 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (229, 13) - - - _rotation - 0 - - - - gr_multiply_xx - - id - gr_multiply_xx_2_0 - - - _enabled - True - - - type - short - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (392, 591) - - - _rotation - 0 - - - - gr_short_to_float - - id - gr_short_to_float_1_0 - - - _enabled - True - - - _coordinate - (535, 609) - - - _rotation - 0 - - - - wxgui_numbersink2 - - id - wxgui_numbersink2_3_0 - - - _enabled - True - - - type - float - - - title - BER - - - units - BER - - - samp_rate - R - - - min_value - 0 - - - max_value - 1.0 - - - factor - 1.0 - - - decimal_places - 6 - - - ref_level - 0 - - - number_rate - 15 - - - peak_hold - False - - - average - True - - - avg_alpha - 0.001 - - - show_gauge - True - - - win_size - - - - grid_pos - 1,0,1,1 - - - notebook - - - - _coordinate - (713, 426) - - - _rotation - 0 - - - - gr_noise_source_x - - id - gr_noise_source_x_0 - - - _enabled - True - - - type - float - - - noise_type - gr.GR_GAUSSIAN - - - amp - noisevar - - - seed - 42 - - - _coordinate - (672, 290) - - - _rotation - 0 - - - - gr_add_xx - - id - gr_add_xx_1 - - - _enabled - True - - - type - float - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (951, 256) - - - _rotation - 0 - - - - wxgui_scopesink2 - - id - wxgui_scopesink2_0 - - - _enabled - False - - - type - float - - - title - Scope Plot - - - samp_rate - R - - - v_scale - 0 - - - v_offset - 0 - - - t_scale - 0 - - - ac_couple - False - - - xy_mode - False - - - num_inputs - 1 - - - win_size - - - - grid_pos - - - - notebook - - - - trig_mode - gr.gr_TRIG_MODE_AUTO - - - y_axis_label - Counts - - - _coordinate - (952, 73) - - - _rotation - 0 - - - - random_source_x - - id - random_source_x_0 - - - _enabled - True - - - type - short - - - min - 0 - - - max - 2 - - - num_samps - 1000 - - - repeat - True - - - _coordinate - (21, 170) - - - _rotation - 0 - - - - gr_throttle - - id - gr_throttle_0 - - - _enabled - True - - - type - short - - - samples_per_second - R - - - vlen - 1 - - - _coordinate - (517, 103) - - - _rotation - 0 - - - - gr_sub_xx - - id - gr_sub_xx_0 - - - _enabled - True - - - type - short - - - vlen - 1 - - - num_inputs - 2 - - - _coordinate - (217, 597) - - - _rotation - 0 - - - - gr_chunks_to_symbols_xx - - id - gr_chunks_to_symbols_xx_0 - - - _enabled - True - - - in_type - short - - - out_type - float - - - symbol_table - -7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7,0, 0,-7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7 - - - dimension - 2 - - - num_ports - 1 - - - _coordinate - (551, 184) - - - _rotation - 0 - - - - trellis_pccc_encoder_xx - - id - trellis_pccc_encoder_xx_0 - - - _enabled - True - - - type - ss - - - o_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" - - - o_init_state - 0 - - - i_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" - - - i_init_state - 0 - - - interleaver_args - trellis.interleaver(block,666) - - - bl - block - - - _coordinate - (236, 147) - - - _rotation - 0 - - - - trellis_pccc_decoder_x - - id - trellis_pccc_decoder_x_0 - - - _enabled - True - - - out_type - s - - - o_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" - - - o_init_state - 0 - - - o_final_state - -1 - - - i_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" - - - i_init_state - 0 - - - i_final_state - -1 - - - interleaver - trellis.interleaver(block,666) - - - block_size - block - - - iterations - 10 - - - siso_type - trellis.TRELLIS_MIN_SUM - - - _coordinate - (357, 304) - - - _rotation - 0 - - - - trellis_metrics_x - - id - trellis_metrics_x_0 - - - _enabled - True - - - type - f - - - card - 16 - - - dim - 2 - - - table - -7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7,0, 0,-7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7 - - - metric_type - trellis.TRELLIS_EUCLIDEAN - - - _coordinate - (58, 354) - - - _rotation - 0 - - - - variable - - id - R - - - _enabled - True - - - value - 100e3 - - - _coordinate - (482, 17) - - - _rotation - 0 - - - - random_source_x_0 - gr_sub_xx_0 - 0 - 0 - - - gr_throttle_0 - gr_chunks_to_symbols_xx_0 - 0 - 0 - - - gr_add_xx_1 - wxgui_scopesink2_0 - 0 - 0 - - - gr_noise_source_x_0 - gr_add_xx_1 - 0 - 1 - - - gr_chunks_to_symbols_xx_0 - gr_add_xx_1 - 0 - 0 - - - gr_multiply_xx_2_0 - gr_short_to_float_1_0 - 0 - 0 - - - gr_short_to_float_1_0 - wxgui_numbersink2_3_0 - 0 - 0 - - - gr_sub_xx_0 - gr_multiply_xx_2_0 - 0 - 0 - - - gr_sub_xx_0 - gr_multiply_xx_2_0 - 0 - 1 - - - gr_add_xx_1 - trellis_metrics_x_0 - 0 - 0 - - - random_source_x_0 - trellis_pccc_encoder_xx_0 - 0 - 0 - - - trellis_pccc_encoder_xx_0 - gr_throttle_0 - 0 - 0 - - - trellis_metrics_x_0 - trellis_pccc_decoder_x_0 - 0 - 0 - - - trellis_pccc_decoder_x_0 - gr_sub_xx_0 - 0 - 1 - - diff --git a/gnuradio-examples/grc/trellis/readme.txt b/gnuradio-examples/grc/trellis/readme.txt deleted file mode 100644 index 9c7363af8..000000000 --- a/gnuradio-examples/grc/trellis/readme.txt +++ /dev/null @@ -1,32 +0,0 @@ -These are examples of using gr-trellis in grc. - -INTERFERENCE CANCELLATION -------------------------- -Two users are transmitting simultaneously using convolutionally encoded QPSK, each with power P1=alpha*P and P2=(1-alpha)*P. -The combined signal is observed in noise and four different receivers are considered: -1) A viterbi decoder decoding user 1 assuming user 2 is noise -2) A viterbi decoder decoding user 2 assuming user 1 is noise -3) A viterbi decoder decoding user 1 first - and then reencoding this signal, subtracting it from the observation - and then running a Viterbi decoder decoding user 2 -4) A viterbi decoder decoding user 2 first - and then reencoding this signal, subtracting it from the observation - and then running a Viterbi decoder decoding user 1 - -You can change the signal to noise ratio P/sigma^2 and the allocation of power to the two users, alpha. - - -Serially Concatenated Convolutional Codes ------------------------------------------ -An SCCC can be defined by an outer and an inner FSM together with an interleaver -and a modulation type. You can change the SNR and observe the estimated BER. -In sccc.grc the decoding and metric calculation are combined; in sccc1.grc they are separate. - -Parallel Concatenated Convolutional Codes ------------------------------------------ -A PCCC can be defined by two FSMs together with an interleaver -and a modulation type. You can change the SNR and observe the estimated BER. -In pccc1.grc the decoding and metric calculation are separate. - - -Enjoy. diff --git a/gnuradio-examples/grc/trellis/sccc.grc b/gnuradio-examples/grc/trellis/sccc.grc deleted file mode 100644 index e8f656f63..000000000 --- a/gnuradio-examples/grc/trellis/sccc.grc +++ /dev/null @@ -1,832 +0,0 @@ - - - Wed Aug 31 19:57:09 2011 - - options - - id - sccc - - - _enabled - True - - - title - Serially Concatenated Convolutional Code - - - author - AA - - - description - gnuradio flow graph - - - window_size - 2048, 2048 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - variable - - id - noisevar - - - _enabled - True - - - value - 10**(-snr_db/10) - - - _coordinate - (389, 15) - - - _rotation - 0 - - - - random_source_x - - id - random_source_x_0 - - - _enabled - True - - - type - short - - - min - 0 - - - max - 2 - - - num_samps - 1000 - - - repeat - True - - - _coordinate - (21, 170) - - - _rotation - 0 - - - - variable - - id - prefix - - - _enabled - True - - - value - "/n/harrisville/x/anastas/gnuradio_trunk/" - - - _coordinate - (590, 15) - - - _rotation - 0 - - - - variable - - id - block - - - _enabled - True - - - value - 1000 - - - _coordinate - (764, 16) - - - _rotation - 0 - - - - gr_add_xx - - id - gr_add_xx_1 - - - _enabled - True - - - type - complex - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (951, 256) - - - _rotation - 0 - - - - gr_sub_xx - - id - gr_sub_xx_0 - - - _enabled - True - - - type - short - - - vlen - 1 - - - num_inputs - 2 - - - _coordinate - (445, 517) - - - _rotation - 0 - - - - gr_multiply_xx - - id - gr_multiply_xx_2_0 - - - _enabled - True - - - type - short - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (228.25, 798.39170361874085) - - - _rotation - 0 - - - - gr_short_to_float - - id - gr_short_to_float_1_0 - - - _enabled - True - - - _coordinate - (416, 815) - - - _rotation - 0 - - - - variable_slider - - id - snr_db - - - _enabled - True - - - label - SNR (dB) - - - value - 5 - - - min - -10 - - - max - 10 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (229, 13) - - - _rotation - 0 - - - - variable - - id - R - - - _enabled - True - - - value - 10e3 - - - _coordinate - (482, 17) - - - _rotation - 0 - - - - wxgui_scopesink2 - - id - wxgui_scopesink2_0 - - - _enabled - False - - - type - complex - - - title - Scope Plot - - - samp_rate - R - - - v_scale - 0 - - - v_offset - 0 - - - t_scale - 0 - - - ac_couple - False - - - xy_mode - True - - - num_inputs - 1 - - - win_size - - - - grid_pos - - - - notebook - - - - trig_mode - gr.gr_TRIG_MODE_AUTO - - - y_axis_label - Counts - - - _coordinate - (952, 73) - - - _rotation - 0 - - - - gr_throttle - - id - gr_throttle_0 - - - _enabled - True - - - type - short - - - samples_per_second - R - - - vlen - 1 - - - _coordinate - (514, 105) - - - _rotation - 0 - - - - gr_chunks_to_symbols_xx - - id - gr_chunks_to_symbols_xx_0 - - - _enabled - True - - - in_type - short - - - out_type - complex - - - symbol_table - 1,0,1j,0,-1j,0,-1,0, 0,1,0,1j,0,-1j,0,-1 - - - dimension - 2 - - - num_ports - 1 - - - _coordinate - (551, 184) - - - _rotation - 0 - - - - gr_noise_source_x - - id - gr_noise_source_x_0 - - - _enabled - True - - - type - complex - - - noise_type - gr.GR_GAUSSIAN - - - amp - noisevar - - - seed - 42 - - - _coordinate - (672, 290) - - - _rotation - 0 - - - - trellis_sccc_encoder_xx - - id - trellis_sccc_encoder_xx_0 - - - _enabled - True - - - type - ss - - - o_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" - - - o_init_state - 0 - - - i_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm" - - - i_init_state - 0 - - - interleaver_args - trellis.interleaver(block,666) - - - bl - block - - - _coordinate - (242, 154) - - - _rotation - 0 - - - - wxgui_numbersink2 - - id - wxgui_numbersink2_3_0 - - - _enabled - True - - - type - float - - - title - BER - - - units - BER - - - samp_rate - R - - - min_value - 0 - - - max_value - 1.0 - - - factor - 1.0 - - - decimal_places - 6 - - - ref_level - 0 - - - number_rate - 15 - - - peak_hold - False - - - average - True - - - avg_alpha - 0.001 - - - show_gauge - True - - - win_size - - - - grid_pos - 1,0,1,1 - - - notebook - - - - _coordinate - (688, 572) - - - _rotation - 0 - - - - trellis_sccc_decoder_combined_xx - - id - trellis_sccc_decoder_combined_xx_0 - - - _enabled - True - - - type - c - - - out_type - s - - - o_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" - - - o_init_state - 0 - - - o_final_state - -1 - - - i_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm" - - - i_init_state - 0 - - - i_final_state - -1 - - - interleaver - trellis.interleaver(block,666) - - - block_size - block - - - iterations - 5 - - - dim - 2 - - - table - 1,0,1j,0,-1j,0,-1,0, 0,1,0,1j,0,-1j,0,-1 - - - metric_type - trellis.TRELLIS_EUCLIDEAN - - - siso_type - trellis.TRELLIS_SUM_PRODUCT - - - scaling - 1.0 - - - _coordinate - (159, 335) - - - _rotation - 0 - - - - random_source_x_0 - gr_sub_xx_0 - 0 - 0 - - - gr_throttle_0 - gr_chunks_to_symbols_xx_0 - 0 - 0 - - - gr_add_xx_1 - wxgui_scopesink2_0 - 0 - 0 - - - gr_noise_source_x_0 - gr_add_xx_1 - 0 - 1 - - - gr_chunks_to_symbols_xx_0 - gr_add_xx_1 - 0 - 0 - - - random_source_x_0 - trellis_sccc_encoder_xx_0 - 0 - 0 - - - trellis_sccc_encoder_xx_0 - gr_throttle_0 - 0 - 0 - - - gr_add_xx_1 - trellis_sccc_decoder_combined_xx_0 - 0 - 0 - - - trellis_sccc_decoder_combined_xx_0 - gr_sub_xx_0 - 0 - 1 - - - gr_multiply_xx_2_0 - gr_short_to_float_1_0 - 0 - 0 - - - gr_short_to_float_1_0 - wxgui_numbersink2_3_0 - 0 - 0 - - - gr_sub_xx_0 - gr_multiply_xx_2_0 - 0 - 0 - - - gr_sub_xx_0 - gr_multiply_xx_2_0 - 0 - 1 - - diff --git a/gnuradio-examples/grc/trellis/sccc1.grc b/gnuradio-examples/grc/trellis/sccc1.grc deleted file mode 100644 index 0be59d0c4..000000000 --- a/gnuradio-examples/grc/trellis/sccc1.grc +++ /dev/null @@ -1,857 +0,0 @@ - - - Wed Aug 31 20:09:23 2011 - - options - - id - sccc1 - - - _enabled - True - - - title - Serially Concatenated Convolutional Code - - - author - AA - - - description - gnuradio flow graph - - - window_size - 2048, 2048 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - variable - - id - noisevar - - - _enabled - True - - - value - 10**(-snr_db/10) - - - _coordinate - (389, 15) - - - _rotation - 0 - - - - random_source_x - - id - random_source_x_0 - - - _enabled - True - - - type - short - - - min - 0 - - - max - 2 - - - num_samps - 1000 - - - repeat - True - - - _coordinate - (21, 170) - - - _rotation - 0 - - - - variable - - id - prefix - - - _enabled - True - - - value - "/n/harrisville/x/anastas/gnuradio_trunk/" - - - _coordinate - (590, 15) - - - _rotation - 0 - - - - variable - - id - block - - - _enabled - True - - - value - 1000 - - - _coordinate - (764, 16) - - - _rotation - 0 - - - - variable_slider - - id - snr_db - - - _enabled - True - - - label - SNR (dB) - - - value - 5 - - - min - -10 - - - max - 10 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (229, 13) - - - _rotation - 0 - - - - variable - - id - R - - - _enabled - True - - - value - 10e3 - - - _coordinate - (482, 17) - - - _rotation - 0 - - - - trellis_sccc_encoder_xx - - id - trellis_sccc_encoder_xx_0 - - - _enabled - True - - - type - ss - - - o_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" - - - o_init_state - 0 - - - i_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm" - - - i_init_state - 0 - - - interleaver_args - trellis.interleaver(block,666) - - - bl - block - - - _coordinate - (242, 154) - - - _rotation - 0 - - - - trellis_sccc_decoder_x - - id - trellis_sccc_decoder_x_0 - - - _enabled - True - - - out_type - s - - - o_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" - - - o_init_state - 0 - - - o_final_state - -1 - - - i_fsm_args - prefix+"gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm" - - - i_init_state - 0 - - - i_final_state - -1 - - - interleaver - trellis.interleaver(block,666) - - - block_size - block - - - iterations - 10 - - - siso_type - trellis.TRELLIS_MIN_SUM - - - _coordinate - (333, 305) - - - _rotation - 0 - - - - gr_sub_xx - - id - gr_sub_xx_0 - - - _enabled - True - - - type - short - - - vlen - 1 - - - num_inputs - 2 - - - _coordinate - (217, 597) - - - _rotation - 0 - - - - gr_multiply_xx - - id - gr_multiply_xx_2_0 - - - _enabled - True - - - type - short - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (392, 591) - - - _rotation - 0 - - - - gr_short_to_float - - id - gr_short_to_float_1_0 - - - _enabled - True - - - _coordinate - (535, 609) - - - _rotation - 0 - - - - wxgui_numbersink2 - - id - wxgui_numbersink2_3_0 - - - _enabled - True - - - type - float - - - title - BER - - - units - BER - - - samp_rate - R - - - min_value - 0 - - - max_value - 1.0 - - - factor - 1.0 - - - decimal_places - 6 - - - ref_level - 0 - - - number_rate - 15 - - - peak_hold - False - - - average - True - - - avg_alpha - 0.001 - - - show_gauge - True - - - win_size - - - - grid_pos - 1,0,1,1 - - - notebook - - - - _coordinate - (713, 426) - - - _rotation - 0 - - - - gr_noise_source_x - - id - gr_noise_source_x_0 - - - _enabled - True - - - type - float - - - noise_type - gr.GR_GAUSSIAN - - - amp - noisevar - - - seed - 42 - - - _coordinate - (672, 290) - - - _rotation - 0 - - - - gr_add_xx - - id - gr_add_xx_1 - - - _enabled - True - - - type - float - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (951, 256) - - - _rotation - 0 - - - - trellis_metrics_x - - id - trellis_metrics_x_0 - - - _enabled - True - - - type - f - - - card - 8 - - - dim - 1 - - - table - -7, -5, -3, -1, 1, 3, 5, 7 - - - metric_type - trellis.TRELLIS_EUCLIDEAN - - - _coordinate - (58, 354) - - - _rotation - 0 - - - - gr_throttle - - id - gr_throttle_0 - - - _enabled - True - - - type - short - - - samples_per_second - R - - - vlen - 1 - - - _coordinate - (517, 103) - - - _rotation - 0 - - - - wxgui_scopesink2 - - id - wxgui_scopesink2_0 - - - _enabled - False - - - type - float - - - title - Scope Plot - - - samp_rate - R - - - v_scale - 0 - - - v_offset - 0 - - - t_scale - 0 - - - ac_couple - False - - - xy_mode - False - - - num_inputs - 1 - - - win_size - - - - grid_pos - - - - notebook - - - - trig_mode - gr.gr_TRIG_MODE_AUTO - - - y_axis_label - Counts - - - _coordinate - (952, 73) - - - _rotation - 0 - - - - gr_chunks_to_symbols_xx - - id - gr_chunks_to_symbols_xx_0 - - - _enabled - True - - - in_type - short - - - out_type - float - - - symbol_table - -7, -5, -3, -1, 1, 3, 5, 7 - - - dimension - 1 - - - num_ports - 1 - - - _coordinate - (551, 184) - - - _rotation - 0 - - - - random_source_x_0 - gr_sub_xx_0 - 0 - 0 - - - gr_throttle_0 - gr_chunks_to_symbols_xx_0 - 0 - 0 - - - gr_add_xx_1 - wxgui_scopesink2_0 - 0 - 0 - - - gr_noise_source_x_0 - gr_add_xx_1 - 0 - 1 - - - gr_chunks_to_symbols_xx_0 - gr_add_xx_1 - 0 - 0 - - - random_source_x_0 - trellis_sccc_encoder_xx_0 - 0 - 0 - - - trellis_sccc_encoder_xx_0 - gr_throttle_0 - 0 - 0 - - - gr_multiply_xx_2_0 - gr_short_to_float_1_0 - 0 - 0 - - - gr_short_to_float_1_0 - wxgui_numbersink2_3_0 - 0 - 0 - - - gr_sub_xx_0 - gr_multiply_xx_2_0 - 0 - 0 - - - gr_sub_xx_0 - gr_multiply_xx_2_0 - 0 - 1 - - - gr_add_xx_1 - trellis_metrics_x_0 - 0 - 0 - - - trellis_metrics_x_0 - trellis_sccc_decoder_x_0 - 0 - 0 - - - trellis_sccc_decoder_x_0 - gr_sub_xx_0 - 0 - 1 - - diff --git a/gnuradio-examples/grc/uhd/uhd_const_wave.grc b/gnuradio-examples/grc/uhd/uhd_const_wave.grc deleted file mode 100644 index c64721c83..000000000 --- a/gnuradio-examples/grc/uhd/uhd_const_wave.grc +++ /dev/null @@ -1,1020 +0,0 @@ - - - Sat Oct 8 10:24:27 2011 - - const_source_x - - id - const_source_x_0 - - - _enabled - True - - - type - complex - - - const - ampl - - - _coordinate - (102, 193) - - - _rotation - 0 - - - - variable_slider - - id - ampl - - - _enabled - True - - - label - Amplitude - - - value - .1 - - - min - 0 - - - max - 1 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (174, 313) - - - _rotation - 0 - - - - variable_slider - - id - tun_gain - - - _enabled - True - - - label - UHD Gain - - - value - gain - - - min - 0 - - - max - 20 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (318, 314) - - - _rotation - 0 - - - - variable_slider - - id - tun_freq - - - _enabled - True - - - label - UHD Freq (Hz) - - - value - freq - - - min - 2.4e9 - - - max - 2.5e9 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (24, 315) - - - _rotation - 0 - - - - options - - id - uhd_const_wave - - - _enabled - True - - - title - UHD Constant Wave - - - author - Example - - - description - Tune UHD Device - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - parameter - - id - address - - - _enabled - True - - - label - IP Address - - - value - addr=192.168.11.2 - - - type - string - - - short_id - a - - - _coordinate - (188, 12) - - - _rotation - 0 - - - - parameter - - id - samp_rate - - - _enabled - True - - - label - Sample Rate - - - value - 1e6 - - - type - eng_float - - - short_id - s - - - _coordinate - (342, 14) - - - _rotation - 0 - - - - uhd_usrp_sink - - id - uhd_usrp_sink_0 - - - _enabled - True - - - type - complex - - - dev_addr - address - - - sync - - - - clock_rate - 0.0 - - - num_mboards - 1 - - - ref_source0 - - - - sd_spec0 - - - - ref_source1 - - - - sd_spec1 - - - - ref_source2 - - - - sd_spec2 - - - - ref_source3 - - - - sd_spec3 - - - - ref_source4 - - - - sd_spec4 - - - - ref_source5 - - - - sd_spec5 - - - - ref_source6 - - - - sd_spec6 - - - - ref_source7 - - - - sd_spec7 - - - - nchan - 1 - - - samp_rate - samp_rate - - - center_freq0 - tun_freq - - - gain0 - tun_gain - - - ant0 - - - - bw0 - 0 - - - center_freq1 - 0 - - - gain1 - 0 - - - ant1 - - - - bw1 - 0 - - - center_freq2 - 0 - - - gain2 - 0 - - - ant2 - - - - bw2 - 0 - - - center_freq3 - 0 - - - gain3 - 0 - - - ant3 - - - - bw3 - 0 - - - center_freq4 - 0 - - - gain4 - 0 - - - ant4 - - - - bw4 - 0 - - - center_freq5 - 0 - - - gain5 - 0 - - - ant5 - - - - bw5 - 0 - - - center_freq6 - 0 - - - gain6 - 0 - - - ant6 - - - - bw6 - 0 - - - center_freq7 - 0 - - - gain7 - 0 - - - ant7 - - - - bw7 - 0 - - - center_freq8 - 0 - - - gain8 - 0 - - - ant8 - - - - bw8 - 0 - - - center_freq9 - 0 - - - gain9 - 0 - - - ant9 - - - - bw9 - 0 - - - center_freq10 - 0 - - - gain10 - 0 - - - ant10 - - - - bw10 - 0 - - - center_freq11 - 0 - - - gain11 - 0 - - - ant11 - - - - bw11 - 0 - - - center_freq12 - 0 - - - gain12 - 0 - - - ant12 - - - - bw12 - 0 - - - center_freq13 - 0 - - - gain13 - 0 - - - ant13 - - - - bw13 - 0 - - - center_freq14 - 0 - - - gain14 - 0 - - - ant14 - - - - bw14 - 0 - - - center_freq15 - 0 - - - gain15 - 0 - - - ant15 - - - - bw15 - 0 - - - center_freq16 - 0 - - - gain16 - 0 - - - ant16 - - - - bw16 - 0 - - - center_freq17 - 0 - - - gain17 - 0 - - - ant17 - - - - bw17 - 0 - - - center_freq18 - 0 - - - gain18 - 0 - - - ant18 - - - - bw18 - 0 - - - center_freq19 - 0 - - - gain19 - 0 - - - ant19 - - - - bw19 - 0 - - - center_freq20 - 0 - - - gain20 - 0 - - - ant20 - - - - bw20 - 0 - - - center_freq21 - 0 - - - gain21 - 0 - - - ant21 - - - - bw21 - 0 - - - center_freq22 - 0 - - - gain22 - 0 - - - ant22 - - - - bw22 - 0 - - - center_freq23 - 0 - - - gain23 - 0 - - - ant23 - - - - bw23 - 0 - - - center_freq24 - 0 - - - gain24 - 0 - - - ant24 - - - - bw24 - 0 - - - center_freq25 - 0 - - - gain25 - 0 - - - ant25 - - - - bw25 - 0 - - - center_freq26 - 0 - - - gain26 - 0 - - - ant26 - - - - bw26 - 0 - - - center_freq27 - 0 - - - gain27 - 0 - - - ant27 - - - - bw27 - 0 - - - center_freq28 - 0 - - - gain28 - 0 - - - ant28 - - - - bw28 - 0 - - - center_freq29 - 0 - - - gain29 - 0 - - - ant29 - - - - bw29 - 0 - - - center_freq30 - 0 - - - gain30 - 0 - - - ant30 - - - - bw30 - 0 - - - center_freq31 - 0 - - - gain31 - 0 - - - ant31 - - - - bw31 - 0 - - - _coordinate - (308, 169) - - - _rotation - 0 - - - - parameter - - id - freq - - - _enabled - True - - - label - Default Frequency - - - value - 2.45e9 - - - type - eng_float - - - short_id - f - - - _coordinate - (468, 14) - - - _rotation - 0 - - - - parameter - - id - gain - - - _enabled - True - - - label - Default Gain - - - value - 0 - - - type - eng_float - - - short_id - g - - - _coordinate - (616, 13) - - - _rotation - 0 - - - - const_source_x_0 - uhd_usrp_sink_0 - 0 - 0 - - diff --git a/gnuradio-examples/grc/uhd/uhd_dpsk_mod.grc b/gnuradio-examples/grc/uhd/uhd_dpsk_mod.grc deleted file mode 100644 index 18ae9c3db..000000000 --- a/gnuradio-examples/grc/uhd/uhd_dpsk_mod.grc +++ /dev/null @@ -1,2238 +0,0 @@ - - - Sat Oct 8 14:44:48 2011 - - options - - id - uhd_dpsk_mod - - - _enabled - True - - - title - UHD DPSK Modulation - - - author - Example - - - description - Generate a DPSK signal - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - variable - - id - samps_per_sym - - - _enabled - True - - - value - 8 - - - _coordinate - (33, 280) - - - _rotation - 0 - - - - wxgui_fftsink2 - - id - wxgui_fftsink2_0 - - - _enabled - True - - - type - complex - - - title - FFT Plot - - - samp_rate - samp_rate - - - baseband_freq - tun_freq - - - y_per_div - 10 - - - y_divs - 10 - - - ref_level - 10 - - - ref_scale - 2.0 - - - fft_size - 1024 - - - fft_rate - 30 - - - peak_hold - False - - - average - False - - - avg_alpha - 0 - - - win - None - - - win_size - - - - grid_pos - - - - notebook - - - - _coordinate - (697, 248) - - - _rotation - 0 - - - - wxgui_scopesink2 - - id - wxgui_scopesink2_0 - - - _enabled - False - - - type - complex - - - title - Scope Plot - - - samp_rate - samp_rate - - - v_scale - 0 - - - v_offset - 0 - - - t_scale - 1e-6 - - - ac_couple - False - - - xy_mode - True - - - num_inputs - 1 - - - win_size - - - - grid_pos - - - - notebook - - - - trig_mode - gr.gr_TRIG_MODE_AUTO - - - y_axis_label - Counts - - - _coordinate - (469, 355) - - - _rotation - 0 - - - - random_source_x - - id - random_source_x_0 - - - _enabled - True - - - type - byte - - - min - 0 - - - max - 256 - - - num_samps - 1000 - - - repeat - True - - - _coordinate - (245, 139) - - - _rotation - 0 - - - - gr_multiply_const_vxx - - id - gr_multiply_const_vxx_0 - - - _enabled - True - - - type - complex - - - const - ampl - - - vlen - 1 - - - _coordinate - (647, 163) - - - _rotation - 0 - - - - variable_slider - - id - tun_rx_gain - - - _enabled - True - - - label - UHD RX Gain - - - value - rx_gain - - - min - 0 - - - max - 20 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (477, 509) - - - _rotation - 0 - - - - variable_slider - - id - rx_freq_off - - - _enabled - True - - - label - RX Freq Offset (Hz) - - - value - freq_offset - - - min - -50e3 - - - max - +50e3 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (190, 507) - - - _rotation - 0 - - - - parameter - - id - rx_gain - - - _enabled - True - - - label - Default RX Gain - - - value - 0 - - - type - eng_float - - - short_id - - - - _coordinate - (1137, 8) - - - _rotation - 0 - - - - parameter - - id - freq_offset - - - _enabled - True - - - label - Rx Frequency Offset - - - value - 0 - - - type - eng_float - - - short_id - o - - - _coordinate - (824, 8) - - - _rotation - 0 - - - - uhd_usrp_source - - id - uhd_usrp_source_0 - - - _enabled - True - - - type - complex - - - dev_addr - address1 - - - sync - - - - clock_rate - 0.0 - - - num_mboards - 1 - - - ref_source0 - - - - sd_spec0 - - - - ref_source1 - - - - sd_spec1 - - - - ref_source2 - - - - sd_spec2 - - - - ref_source3 - - - - sd_spec3 - - - - ref_source4 - - - - sd_spec4 - - - - ref_source5 - - - - sd_spec5 - - - - ref_source6 - - - - sd_spec6 - - - - ref_source7 - - - - sd_spec7 - - - - nchan - 1 - - - samp_rate - samp_rate - - - center_freq0 - tun_freq+rx_freq_off - - - gain0 - tun_rx_gain - - - ant0 - - - - bw0 - 0 - - - center_freq1 - 0 - - - gain1 - 0 - - - ant1 - - - - bw1 - 0 - - - center_freq2 - 0 - - - gain2 - 0 - - - ant2 - - - - bw2 - 0 - - - center_freq3 - 0 - - - gain3 - 0 - - - ant3 - - - - bw3 - 0 - - - center_freq4 - 0 - - - gain4 - 0 - - - ant4 - - - - bw4 - 0 - - - center_freq5 - 0 - - - gain5 - 0 - - - ant5 - - - - bw5 - 0 - - - center_freq6 - 0 - - - gain6 - 0 - - - ant6 - - - - bw6 - 0 - - - center_freq7 - 0 - - - gain7 - 0 - - - ant7 - - - - bw7 - 0 - - - center_freq8 - 0 - - - gain8 - 0 - - - ant8 - - - - bw8 - 0 - - - center_freq9 - 0 - - - gain9 - 0 - - - ant9 - - - - bw9 - 0 - - - center_freq10 - 0 - - - gain10 - 0 - - - ant10 - - - - bw10 - 0 - - - center_freq11 - 0 - - - gain11 - 0 - - - ant11 - - - - bw11 - 0 - - - center_freq12 - 0 - - - gain12 - 0 - - - ant12 - - - - bw12 - 0 - - - center_freq13 - 0 - - - gain13 - 0 - - - ant13 - - - - bw13 - 0 - - - center_freq14 - 0 - - - gain14 - 0 - - - ant14 - - - - bw14 - 0 - - - center_freq15 - 0 - - - gain15 - 0 - - - ant15 - - - - bw15 - 0 - - - center_freq16 - 0 - - - gain16 - 0 - - - ant16 - - - - bw16 - 0 - - - center_freq17 - 0 - - - gain17 - 0 - - - ant17 - - - - bw17 - 0 - - - center_freq18 - 0 - - - gain18 - 0 - - - ant18 - - - - bw18 - 0 - - - center_freq19 - 0 - - - gain19 - 0 - - - ant19 - - - - bw19 - 0 - - - center_freq20 - 0 - - - gain20 - 0 - - - ant20 - - - - bw20 - 0 - - - center_freq21 - 0 - - - gain21 - 0 - - - ant21 - - - - bw21 - 0 - - - center_freq22 - 0 - - - gain22 - 0 - - - ant22 - - - - bw22 - 0 - - - center_freq23 - 0 - - - gain23 - 0 - - - ant23 - - - - bw23 - 0 - - - center_freq24 - 0 - - - gain24 - 0 - - - ant24 - - - - bw24 - 0 - - - center_freq25 - 0 - - - gain25 - 0 - - - ant25 - - - - bw25 - 0 - - - center_freq26 - 0 - - - gain26 - 0 - - - ant26 - - - - bw26 - 0 - - - center_freq27 - 0 - - - gain27 - 0 - - - ant27 - - - - bw27 - 0 - - - center_freq28 - 0 - - - gain28 - 0 - - - ant28 - - - - bw28 - 0 - - - center_freq29 - 0 - - - gain29 - 0 - - - ant29 - - - - bw29 - 0 - - - center_freq30 - 0 - - - gain30 - 0 - - - ant30 - - - - bw30 - 0 - - - center_freq31 - 0 - - - gain31 - 0 - - - ant31 - - - - bw31 - 0 - - - _coordinate - (216, 288) - - - _rotation - 0 - - - - wxgui_constellationsink2 - - id - wxgui_constellationsink2_0 - - - _enabled - True - - - title - Constellation Plot - - - samp_rate - samp_rate - - - frame_rate - 5 - - - const_size - 2048 - - - M - 4 - - - theta - 0 - - - loop_bw - 6.28/100.0 - - - fmax - 0.06 - - - mu - 0.5 - - - gain_mu - 0.005 - - - symbol_rate - samp_rate/samps_per_sym - - - omega_limit - 0.005 - - - win_size - - - - grid_pos - - - - notebook - - - - _coordinate - (862, 336) - - - _rotation - 0 - - - - digital_dxpsk_mod - - id - digital_dxpsk_mod_0 - - - _enabled - True - - - type - dqpsk - - - samples_per_symbol - samps_per_sym - - - excess_bw - 0.35 - - - gray_coded - True - - - verbose - False - - - log - False - - - _coordinate - (426, 139) - - - _rotation - 0 - - - - variable_slider - - id - ampl - - - _enabled - True - - - label - Amplitude - - - value - .1 - - - min - 0 - - - max - 1 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (33, 353) - - - _rotation - 0 - - - - uhd_usrp_sink - - id - uhd_usrp_sink_0 - - - _enabled - True - - - type - complex - - - dev_addr - address0 - - - sync - - - - clock_rate - 0.0 - - - num_mboards - 1 - - - ref_source0 - - - - sd_spec0 - - - - ref_source1 - - - - sd_spec1 - - - - ref_source2 - - - - sd_spec2 - - - - ref_source3 - - - - sd_spec3 - - - - ref_source4 - - - - sd_spec4 - - - - ref_source5 - - - - sd_spec5 - - - - ref_source6 - - - - sd_spec6 - - - - ref_source7 - - - - sd_spec7 - - - - nchan - 1 - - - samp_rate - samp_rate - - - center_freq0 - tun_freq - - - gain0 - tun_rx_gain - - - ant0 - - - - bw0 - 0 - - - center_freq1 - 0 - - - gain1 - 0 - - - ant1 - - - - bw1 - 0 - - - center_freq2 - 0 - - - gain2 - 0 - - - ant2 - - - - bw2 - 0 - - - center_freq3 - 0 - - - gain3 - 0 - - - ant3 - - - - bw3 - 0 - - - center_freq4 - 0 - - - gain4 - 0 - - - ant4 - - - - bw4 - 0 - - - center_freq5 - 0 - - - gain5 - 0 - - - ant5 - - - - bw5 - 0 - - - center_freq6 - 0 - - - gain6 - 0 - - - ant6 - - - - bw6 - 0 - - - center_freq7 - 0 - - - gain7 - 0 - - - ant7 - - - - bw7 - 0 - - - center_freq8 - 0 - - - gain8 - 0 - - - ant8 - - - - bw8 - 0 - - - center_freq9 - 0 - - - gain9 - 0 - - - ant9 - - - - bw9 - 0 - - - center_freq10 - 0 - - - gain10 - 0 - - - ant10 - - - - bw10 - 0 - - - center_freq11 - 0 - - - gain11 - 0 - - - ant11 - - - - bw11 - 0 - - - center_freq12 - 0 - - - gain12 - 0 - - - ant12 - - - - bw12 - 0 - - - center_freq13 - 0 - - - gain13 - 0 - - - ant13 - - - - bw13 - 0 - - - center_freq14 - 0 - - - gain14 - 0 - - - ant14 - - - - bw14 - 0 - - - center_freq15 - 0 - - - gain15 - 0 - - - ant15 - - - - bw15 - 0 - - - center_freq16 - 0 - - - gain16 - 0 - - - ant16 - - - - bw16 - 0 - - - center_freq17 - 0 - - - gain17 - 0 - - - ant17 - - - - bw17 - 0 - - - center_freq18 - 0 - - - gain18 - 0 - - - ant18 - - - - bw18 - 0 - - - center_freq19 - 0 - - - gain19 - 0 - - - ant19 - - - - bw19 - 0 - - - center_freq20 - 0 - - - gain20 - 0 - - - ant20 - - - - bw20 - 0 - - - center_freq21 - 0 - - - gain21 - 0 - - - ant21 - - - - bw21 - 0 - - - center_freq22 - 0 - - - gain22 - 0 - - - ant22 - - - - bw22 - 0 - - - center_freq23 - 0 - - - gain23 - 0 - - - ant23 - - - - bw23 - 0 - - - center_freq24 - 0 - - - gain24 - 0 - - - ant24 - - - - bw24 - 0 - - - center_freq25 - 0 - - - gain25 - 0 - - - ant25 - - - - bw25 - 0 - - - center_freq26 - 0 - - - gain26 - 0 - - - ant26 - - - - bw26 - 0 - - - center_freq27 - 0 - - - gain27 - 0 - - - ant27 - - - - bw27 - 0 - - - center_freq28 - 0 - - - gain28 - 0 - - - ant28 - - - - bw28 - 0 - - - center_freq29 - 0 - - - gain29 - 0 - - - ant29 - - - - bw29 - 0 - - - center_freq30 - 0 - - - gain30 - 0 - - - ant30 - - - - bw30 - 0 - - - center_freq31 - 0 - - - gain31 - 0 - - - ant31 - - - - bw31 - 0 - - - _coordinate - (838, 139) - - - _rotation - 0 - - - - variable_slider - - id - tun_tx_gain - - - _enabled - True - - - label - UHD TX Gain - - - value - tx_gain - - - min - 0 - - - max - 20 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (351, 508) - - - _rotation - 0 - - - - parameter - - id - address0 - - - _enabled - True - - - label - IP Address, Dev 0 - - - value - addr=192.168.10.2 - - - type - string - - - short_id - - - - _coordinate - (197, 11) - - - _rotation - 0 - - - - parameter - - id - address1 - - - _enabled - True - - - label - IP Address, Dev 1 - - - value - addr=192.168.11.2 - - - type - string - - - short_id - - - - _coordinate - (357, 11) - - - _rotation - 0 - - - - parameter - - id - samp_rate - - - _enabled - True - - - label - Sample Rate - - - value - 1e6 - - - type - eng_float - - - short_id - s - - - _coordinate - (543, 8) - - - _rotation - 0 - - - - parameter - - id - freq - - - _enabled - True - - - label - Default Frequency - - - value - 2.45e9 - - - type - eng_float - - - short_id - f - - - _coordinate - (669, 8) - - - _rotation - 0 - - - - parameter - - id - tx_gain - - - _enabled - True - - - label - Default TX Gain - - - value - 0 - - - type - eng_float - - - short_id - - - - _coordinate - (1003, 8) - - - _rotation - 0 - - - - variable_slider - - id - tun_freq - - - _enabled - True - - - label - Freq (Hz) - - - value - freq - - - min - 2.4e9 - - - max - 2.5e9 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (35, 506) - - - _rotation - 0 - - - - uhd_usrp_source_0 - wxgui_fftsink2_0 - 0 - 0 - - - uhd_usrp_source_0 - wxgui_constellationsink2_0 - 0 - 0 - - - uhd_usrp_source_0 - wxgui_scopesink2_0 - 0 - 0 - - - gr_multiply_const_vxx_0 - uhd_usrp_sink_0 - 0 - 0 - - - random_source_x_0 - digital_dxpsk_mod_0 - 0 - 0 - - - digital_dxpsk_mod_0 - gr_multiply_const_vxx_0 - 0 - 0 - - diff --git a/gnuradio-examples/grc/uhd/uhd_fft.grc b/gnuradio-examples/grc/uhd/uhd_fft.grc deleted file mode 100644 index 29c375065..000000000 --- a/gnuradio-examples/grc/uhd/uhd_fft.grc +++ /dev/null @@ -1,1025 +0,0 @@ - - - Sat Oct 8 10:26:30 2011 - - options - - id - uhd_fft - - - _enabled - True - - - title - UHD FFT Plotter - - - author - Example - - - description - FFT waveform plot - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - parameter - - id - gain - - - _enabled - True - - - label - Default Gain - - - value - 0 - - - type - eng_float - - - short_id - g - - - _coordinate - (633, 17) - - - _rotation - 0 - - - - parameter - - id - freq - - - _enabled - True - - - label - Default Frequency - - - value - 2.45e9 - - - type - eng_float - - - short_id - f - - - _coordinate - (485, 18) - - - _rotation - 0 - - - - parameter - - id - address - - - _enabled - True - - - label - IP Address - - - value - addr=192.168.11.2 - - - type - string - - - short_id - a - - - _coordinate - (205, 16) - - - _rotation - 0 - - - - parameter - - id - samp_rate - - - _enabled - True - - - label - Sample Rate - - - value - 1e6 - - - type - eng_float - - - short_id - s - - - _coordinate - (359, 18) - - - _rotation - 0 - - - - wxgui_fftsink2 - - id - wxgui_fftsink2_0 - - - _enabled - True - - - type - complex - - - title - FFT Plot - - - samp_rate - samp_rate - - - baseband_freq - tun_freq - - - y_per_div - 10 - - - y_divs - 10 - - - ref_level - 10 - - - ref_scale - 2.0 - - - fft_size - 1024 - - - fft_rate - 30 - - - peak_hold - False - - - average - False - - - avg_alpha - 0 - - - win - None - - - win_size - - - - grid_pos - - - - notebook - - - - _coordinate - (479, 176) - - - _rotation - 0 - - - - uhd_usrp_source - - id - uhd_usrp_source_0 - - - _enabled - True - - - type - complex - - - dev_addr - address - - - sync - - - - clock_rate - 0.0 - - - num_mboards - 1 - - - ref_source0 - - - - sd_spec0 - - - - ref_source1 - - - - sd_spec1 - - - - ref_source2 - - - - sd_spec2 - - - - ref_source3 - - - - sd_spec3 - - - - ref_source4 - - - - sd_spec4 - - - - ref_source5 - - - - sd_spec5 - - - - ref_source6 - - - - sd_spec6 - - - - ref_source7 - - - - sd_spec7 - - - - nchan - 1 - - - samp_rate - samp_rate - - - center_freq0 - tun_freq - - - gain0 - tun_gain - - - ant0 - - - - bw0 - 0 - - - center_freq1 - 0 - - - gain1 - 0 - - - ant1 - - - - bw1 - 0 - - - center_freq2 - 0 - - - gain2 - 0 - - - ant2 - - - - bw2 - 0 - - - center_freq3 - 0 - - - gain3 - 0 - - - ant3 - - - - bw3 - 0 - - - center_freq4 - 0 - - - gain4 - 0 - - - ant4 - - - - bw4 - 0 - - - center_freq5 - 0 - - - gain5 - 0 - - - ant5 - - - - bw5 - 0 - - - center_freq6 - 0 - - - gain6 - 0 - - - ant6 - - - - bw6 - 0 - - - center_freq7 - 0 - - - gain7 - 0 - - - ant7 - - - - bw7 - 0 - - - center_freq8 - 0 - - - gain8 - 0 - - - ant8 - - - - bw8 - 0 - - - center_freq9 - 0 - - - gain9 - 0 - - - ant9 - - - - bw9 - 0 - - - center_freq10 - 0 - - - gain10 - 0 - - - ant10 - - - - bw10 - 0 - - - center_freq11 - 0 - - - gain11 - 0 - - - ant11 - - - - bw11 - 0 - - - center_freq12 - 0 - - - gain12 - 0 - - - ant12 - - - - bw12 - 0 - - - center_freq13 - 0 - - - gain13 - 0 - - - ant13 - - - - bw13 - 0 - - - center_freq14 - 0 - - - gain14 - 0 - - - ant14 - - - - bw14 - 0 - - - center_freq15 - 0 - - - gain15 - 0 - - - ant15 - - - - bw15 - 0 - - - center_freq16 - 0 - - - gain16 - 0 - - - ant16 - - - - bw16 - 0 - - - center_freq17 - 0 - - - gain17 - 0 - - - ant17 - - - - bw17 - 0 - - - center_freq18 - 0 - - - gain18 - 0 - - - ant18 - - - - bw18 - 0 - - - center_freq19 - 0 - - - gain19 - 0 - - - ant19 - - - - bw19 - 0 - - - center_freq20 - 0 - - - gain20 - 0 - - - ant20 - - - - bw20 - 0 - - - center_freq21 - 0 - - - gain21 - 0 - - - ant21 - - - - bw21 - 0 - - - center_freq22 - 0 - - - gain22 - 0 - - - ant22 - - - - bw22 - 0 - - - center_freq23 - 0 - - - gain23 - 0 - - - ant23 - - - - bw23 - 0 - - - center_freq24 - 0 - - - gain24 - 0 - - - ant24 - - - - bw24 - 0 - - - center_freq25 - 0 - - - gain25 - 0 - - - ant25 - - - - bw25 - 0 - - - center_freq26 - 0 - - - gain26 - 0 - - - ant26 - - - - bw26 - 0 - - - center_freq27 - 0 - - - gain27 - 0 - - - ant27 - - - - bw27 - 0 - - - center_freq28 - 0 - - - gain28 - 0 - - - ant28 - - - - bw28 - 0 - - - center_freq29 - 0 - - - gain29 - 0 - - - ant29 - - - - bw29 - 0 - - - center_freq30 - 0 - - - gain30 - 0 - - - ant30 - - - - bw30 - 0 - - - center_freq31 - 0 - - - gain31 - 0 - - - ant31 - - - - bw31 - 0 - - - _coordinate - (212, 216) - - - _rotation - 0 - - - - variable_slider - - id - tun_freq - - - _enabled - True - - - label - UHD Freq (Hz) - - - value - freq - - - min - 2.4e9 - - - max - 2.5e9 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (36, 376) - - - _rotation - 0 - - - - variable_slider - - id - tun_gain - - - _enabled - True - - - label - UHD Gain - - - value - gain - - - min - 0 - - - max - 20 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (177, 377) - - - _rotation - 0 - - - - uhd_usrp_source_0 - wxgui_fftsink2_0 - 0 - 0 - - diff --git a/gnuradio-examples/grc/uhd/uhd_rx_dpsk.grc b/gnuradio-examples/grc/uhd/uhd_rx_dpsk.grc deleted file mode 100644 index 73848ff3c..000000000 --- a/gnuradio-examples/grc/uhd/uhd_rx_dpsk.grc +++ /dev/null @@ -1,1431 +0,0 @@ - - - Sat Oct 8 15:08:55 2011 - - options - - id - uhd_rx_dpsk - - - _enabled - True - - - title - UHD RX DPSK - - - author - - - - description - - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (12, 9) - - - _rotation - 0 - - - - variable - - id - samps_per_sym - - - _enabled - True - - - value - 4 - - - _coordinate - (12, 88) - - - _rotation - 0 - - - - parameter - - id - samp_rate - - - _enabled - True - - - label - Sample Rate - - - value - 1e6 - - - type - eng_float - - - short_id - s - - - _coordinate - (339, 11) - - - _rotation - 0 - - - - parameter - - id - freq - - - _enabled - True - - - label - Default Frequency - - - value - 2.45e9 - - - type - eng_float - - - short_id - f - - - _coordinate - (466, 11) - - - _rotation - 0 - - - - parameter - - id - gain - - - _enabled - True - - - label - Default Gain - - - value - 0 - - - type - eng_float - - - short_id - g - - - _coordinate - (624, 14) - - - _rotation - 0 - - - - parameter - - id - address - - - _enabled - True - - - label - IP Address - - - value - addr=192.168.10.2 - - - type - string - - - short_id - a - - - _coordinate - (186, 10) - - - _rotation - 0 - - - - parameter - - id - freq_offset - - - _enabled - True - - - label - Rx Frequency Offset - - - value - 0 - - - type - eng_float - - - short_id - o - - - _coordinate - (748, 15) - - - _rotation - 0 - - - - variable_slider - - id - tun_freq - - - _enabled - True - - - label - Freq (Hz) - - - value - freq - - - min - 2.4e9 - - - max - 2.5e9 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (12, 436) - - - _rotation - 0 - - - - gr_null_sink - - id - gr_null_sink_0 - - - _enabled - True - - - type - byte - - - vlen - 1 - - - _coordinate - (615, 144) - - - _rotation - 0 - - - - variable_slider - - id - timing_bw - - - _enabled - True - - - label - Timing Loop BW - - - value - 6.28/100.0 - - - min - 0 - - - max - 1 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (604, 436) - - - _rotation - 0 - - - - variable_slider - - id - phase_bw - - - _enabled - True - - - label - Phase Loop BW - - - value - 6.28/100.0 - - - min - 0 - - - max - 1.0 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (461, 436) - - - _rotation - 0 - - - - wxgui_constellationsink2 - - id - wxgui_constellationsink2_0 - - - _enabled - True - - - title - Constellation Plot - - - samp_rate - samp_rate - - - frame_rate - 5 - - - const_size - 2048 - - - M - 4 - - - theta - 0 - - - loop_bw - 6.28/100.0 - - - fmax - 0.06 - - - mu - 0.5 - - - gain_mu - 0.005 - - - symbol_rate - samp_rate/samps_per_sym - - - omega_limit - 0.005 - - - win_size - - - - grid_pos - - - - notebook - - - - _coordinate - (931, 313) - - - _rotation - 0 - - - - wxgui_fftsink2 - - id - wxgui_fftsink2_0 - - - _enabled - True - - - type - complex - - - title - FFT Plot - - - samp_rate - samp_rate - - - baseband_freq - tun_freq - - - y_per_div - 10 - - - y_divs - 10 - - - ref_level - 10 - - - ref_scale - 2.0 - - - fft_size - 1024 - - - fft_rate - 30 - - - peak_hold - False - - - average - False - - - avg_alpha - 0 - - - win - None - - - win_size - - - - grid_pos - - - - notebook - - - - _coordinate - (710, 236) - - - _rotation - 0 - - - - digital_dxpsk_demod - - id - digital_dxpsk_demod_0 - - - _enabled - True - - - type - dqpsk - - - samples_per_symbol - samps_per_sym - - - excess_bw - 0.35 - - - phase_bw - 6.28/100.0 - - - timing_bw - 6.28/100.0 - - - omega_relative_limit - 0.005 - - - gray_coded - True - - - verbose - False - - - log - False - - - sync_out - False - - - _coordinate - (303, 154) - - - _rotation - 0 - - - - variable_slider - - id - rx_freq_off - - - _enabled - True - - - label - RX Freq Offset (Hz) - - - value - freq_offset - - - min - -100e3 - - - max - +100e3 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (149, 437) - - - _rotation - 0 - - - - variable_slider - - id - tun_gain - - - _enabled - True - - - label - UHD Gain - - - value - gain - - - min - 0 - - - max - 20 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (306, 438) - - - _rotation - 0 - - - - uhd_usrp_source - - id - uhd_usrp_source_0 - - - _enabled - True - - - type - complex - - - dev_addr - address - - - sync - - - - clock_rate - 0.0 - - - num_mboards - 1 - - - ref_source0 - - - - sd_spec0 - - - - ref_source1 - - - - sd_spec1 - - - - ref_source2 - - - - sd_spec2 - - - - ref_source3 - - - - sd_spec3 - - - - ref_source4 - - - - sd_spec4 - - - - ref_source5 - - - - sd_spec5 - - - - ref_source6 - - - - sd_spec6 - - - - ref_source7 - - - - sd_spec7 - - - - nchan - 1 - - - samp_rate - samp_rate - - - center_freq0 - tun_freq+rx_freq_off - - - gain0 - tun_gain - - - ant0 - - - - bw0 - 0 - - - center_freq1 - 0 - - - gain1 - 0 - - - ant1 - - - - bw1 - 0 - - - center_freq2 - 0 - - - gain2 - 0 - - - ant2 - - - - bw2 - 0 - - - center_freq3 - 0 - - - gain3 - 0 - - - ant3 - - - - bw3 - 0 - - - center_freq4 - 0 - - - gain4 - 0 - - - ant4 - - - - bw4 - 0 - - - center_freq5 - 0 - - - gain5 - 0 - - - ant5 - - - - bw5 - 0 - - - center_freq6 - 0 - - - gain6 - 0 - - - ant6 - - - - bw6 - 0 - - - center_freq7 - 0 - - - gain7 - 0 - - - ant7 - - - - bw7 - 0 - - - center_freq8 - 0 - - - gain8 - 0 - - - ant8 - - - - bw8 - 0 - - - center_freq9 - 0 - - - gain9 - 0 - - - ant9 - - - - bw9 - 0 - - - center_freq10 - 0 - - - gain10 - 0 - - - ant10 - - - - bw10 - 0 - - - center_freq11 - 0 - - - gain11 - 0 - - - ant11 - - - - bw11 - 0 - - - center_freq12 - 0 - - - gain12 - 0 - - - ant12 - - - - bw12 - 0 - - - center_freq13 - 0 - - - gain13 - 0 - - - ant13 - - - - bw13 - 0 - - - center_freq14 - 0 - - - gain14 - 0 - - - ant14 - - - - bw14 - 0 - - - center_freq15 - 0 - - - gain15 - 0 - - - ant15 - - - - bw15 - 0 - - - center_freq16 - 0 - - - gain16 - 0 - - - ant16 - - - - bw16 - 0 - - - center_freq17 - 0 - - - gain17 - 0 - - - ant17 - - - - bw17 - 0 - - - center_freq18 - 0 - - - gain18 - 0 - - - ant18 - - - - bw18 - 0 - - - center_freq19 - 0 - - - gain19 - 0 - - - ant19 - - - - bw19 - 0 - - - center_freq20 - 0 - - - gain20 - 0 - - - ant20 - - - - bw20 - 0 - - - center_freq21 - 0 - - - gain21 - 0 - - - ant21 - - - - bw21 - 0 - - - center_freq22 - 0 - - - gain22 - 0 - - - ant22 - - - - bw22 - 0 - - - center_freq23 - 0 - - - gain23 - 0 - - - ant23 - - - - bw23 - 0 - - - center_freq24 - 0 - - - gain24 - 0 - - - ant24 - - - - bw24 - 0 - - - center_freq25 - 0 - - - gain25 - 0 - - - ant25 - - - - bw25 - 0 - - - center_freq26 - 0 - - - gain26 - 0 - - - ant26 - - - - bw26 - 0 - - - center_freq27 - 0 - - - gain27 - 0 - - - ant27 - - - - bw27 - 0 - - - center_freq28 - 0 - - - gain28 - 0 - - - ant28 - - - - bw28 - 0 - - - center_freq29 - 0 - - - gain29 - 0 - - - ant29 - - - - bw29 - 0 - - - center_freq30 - 0 - - - gain30 - 0 - - - ant30 - - - - bw30 - 0 - - - center_freq31 - 0 - - - gain31 - 0 - - - ant31 - - - - bw31 - 0 - - - _coordinate - (18, 276) - - - _rotation - 0 - - - - digital_dxpsk_demod_0 - gr_null_sink_0 - 0 - 0 - - - uhd_usrp_source_0 - digital_dxpsk_demod_0 - 0 - 0 - - - uhd_usrp_source_0 - wxgui_constellationsink2_0 - 0 - 0 - - - uhd_usrp_source_0 - wxgui_fftsink2_0 - 0 - 0 - - diff --git a/gnuradio-examples/grc/uhd/uhd_two_tone_loopback.grc b/gnuradio-examples/grc/uhd/uhd_two_tone_loopback.grc deleted file mode 100644 index 8bcbc0792..000000000 --- a/gnuradio-examples/grc/uhd/uhd_two_tone_loopback.grc +++ /dev/null @@ -1,2204 +0,0 @@ - - - Sat Oct 8 15:27:04 2011 - - parameter - - id - tx_gain - - - _enabled - True - - - label - Default TX Gain - - - value - 0 - - - type - eng_float - - - short_id - - - - _coordinate - (999, 11) - - - _rotation - 0 - - - - parameter - - id - freq - - - _enabled - True - - - label - Default Frequency - - - value - 2.45e9 - - - type - eng_float - - - short_id - f - - - _coordinate - (665, 11) - - - _rotation - 0 - - - - parameter - - id - freq_offset - - - _enabled - True - - - label - Rx Frequency Offset - - - value - 0 - - - type - eng_float - - - short_id - o - - - _coordinate - (820, 11) - - - _rotation - 0 - - - - parameter - - id - address1 - - - _enabled - True - - - label - IP Address, Dev 1 - - - value - addr=192.168.11.2 - - - type - string - - - short_id - - - - _coordinate - (353, 14) - - - _rotation - 0 - - - - parameter - - id - address0 - - - _enabled - True - - - label - IP Address, Dev 0 - - - value - addr=192.168.10.2 - - - type - string - - - short_id - - - - _coordinate - (193, 14) - - - _rotation - 0 - - - - gr_sig_source_x - - id - gr_sig_source_x - - - _enabled - True - - - type - complex - - - samp_rate - samp_rate - - - waveform - gr.GR_COS_WAVE - - - freq - tone1 - - - amp - tone_ampl - - - offset - 0 - - - _coordinate - (258, 136) - - - _rotation - 0 - - - - gr_sig_source_x - - id - gr_sig_source_x0 - - - _enabled - True - - - type - complex - - - samp_rate - samp_rate - - - waveform - gr.GR_COS_WAVE - - - freq - tone2 - - - amp - tone_ampl - - - offset - 0 - - - _coordinate - (259, 248) - - - _rotation - 0 - - - - gr_noise_source_x - - id - gr_noise_source_x - - - _enabled - True - - - type - complex - - - noise_type - gr.GR_GAUSSIAN - - - amp - noise_ampl - - - seed - 42 - - - _coordinate - (279, 364) - - - _rotation - 0 - - - - uhd_usrp_sink - - id - uhd_usrp_sink_0 - - - _enabled - True - - - type - complex - - - dev_addr - address0 - - - sync - - - - clock_rate - 0.0 - - - num_mboards - 1 - - - ref_source0 - - - - sd_spec0 - - - - ref_source1 - - - - sd_spec1 - - - - ref_source2 - - - - sd_spec2 - - - - ref_source3 - - - - sd_spec3 - - - - ref_source4 - - - - sd_spec4 - - - - ref_source5 - - - - sd_spec5 - - - - ref_source6 - - - - sd_spec6 - - - - ref_source7 - - - - sd_spec7 - - - - nchan - 1 - - - samp_rate - samp_rate - - - center_freq0 - tun_freq - - - gain0 - tun_rx_gain - - - ant0 - - - - bw0 - 0 - - - center_freq1 - 0 - - - gain1 - 0 - - - ant1 - - - - bw1 - 0 - - - center_freq2 - 0 - - - gain2 - 0 - - - ant2 - - - - bw2 - 0 - - - center_freq3 - 0 - - - gain3 - 0 - - - ant3 - - - - bw3 - 0 - - - center_freq4 - 0 - - - gain4 - 0 - - - ant4 - - - - bw4 - 0 - - - center_freq5 - 0 - - - gain5 - 0 - - - ant5 - - - - bw5 - 0 - - - center_freq6 - 0 - - - gain6 - 0 - - - ant6 - - - - bw6 - 0 - - - center_freq7 - 0 - - - gain7 - 0 - - - ant7 - - - - bw7 - 0 - - - center_freq8 - 0 - - - gain8 - 0 - - - ant8 - - - - bw8 - 0 - - - center_freq9 - 0 - - - gain9 - 0 - - - ant9 - - - - bw9 - 0 - - - center_freq10 - 0 - - - gain10 - 0 - - - ant10 - - - - bw10 - 0 - - - center_freq11 - 0 - - - gain11 - 0 - - - ant11 - - - - bw11 - 0 - - - center_freq12 - 0 - - - gain12 - 0 - - - ant12 - - - - bw12 - 0 - - - center_freq13 - 0 - - - gain13 - 0 - - - ant13 - - - - bw13 - 0 - - - center_freq14 - 0 - - - gain14 - 0 - - - ant14 - - - - bw14 - 0 - - - center_freq15 - 0 - - - gain15 - 0 - - - ant15 - - - - bw15 - 0 - - - center_freq16 - 0 - - - gain16 - 0 - - - ant16 - - - - bw16 - 0 - - - center_freq17 - 0 - - - gain17 - 0 - - - ant17 - - - - bw17 - 0 - - - center_freq18 - 0 - - - gain18 - 0 - - - ant18 - - - - bw18 - 0 - - - center_freq19 - 0 - - - gain19 - 0 - - - ant19 - - - - bw19 - 0 - - - center_freq20 - 0 - - - gain20 - 0 - - - ant20 - - - - bw20 - 0 - - - center_freq21 - 0 - - - gain21 - 0 - - - ant21 - - - - bw21 - 0 - - - center_freq22 - 0 - - - gain22 - 0 - - - ant22 - - - - bw22 - 0 - - - center_freq23 - 0 - - - gain23 - 0 - - - ant23 - - - - bw23 - 0 - - - center_freq24 - 0 - - - gain24 - 0 - - - ant24 - - - - bw24 - 0 - - - center_freq25 - 0 - - - gain25 - 0 - - - ant25 - - - - bw25 - 0 - - - center_freq26 - 0 - - - gain26 - 0 - - - ant26 - - - - bw26 - 0 - - - center_freq27 - 0 - - - gain27 - 0 - - - ant27 - - - - bw27 - 0 - - - center_freq28 - 0 - - - gain28 - 0 - - - ant28 - - - - bw28 - 0 - - - center_freq29 - 0 - - - gain29 - 0 - - - ant29 - - - - bw29 - 0 - - - center_freq30 - 0 - - - gain30 - 0 - - - ant30 - - - - bw30 - 0 - - - center_freq31 - 0 - - - gain31 - 0 - - - ant31 - - - - bw31 - 0 - - - _coordinate - (669, 178) - - - _rotation - 0 - - - - parameter - - id - rx_gain - - - _enabled - True - - - label - Default RX Gain - - - value - 0 - - - type - eng_float - - - short_id - - - - _coordinate - (1139, 12) - - - _rotation - 0 - - - - variable_slider - - id - tone1 - - - _enabled - True - - - label - Tone 1 - - - value - 50e3 - - - min - -samp_rate/2 - - - max - samp_rate/2 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 0, 0, 1, 4 - - - notebook - - - - _coordinate - (161, 484) - - - _rotation - 0 - - - - variable_slider - - id - tone2 - - - _enabled - True - - - label - Tone 2 - - - value - 75e3 - - - min - -samp_rate/2 - - - max - samp_rate/2 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 0, 4, 1, 4 - - - notebook - - - - _coordinate - (308, 483) - - - _rotation - 0 - - - - variable_slider - - id - tun_tx_gain - - - _enabled - True - - - label - UHD TX Gain - - - value - tx_gain - - - min - 0 - - - max - 20 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (655, 486) - - - _rotation - 0 - - - - variable_slider - - id - tun_freq - - - _enabled - True - - - label - Freq (Hz) - - - value - freq - - - min - 2.4e9 - - - max - 2.5e9 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (514, 487) - - - _rotation - 0 - - - - variable_slider - - id - tun_rx_gain - - - _enabled - True - - - label - UHD RX Gain - - - value - rx_gain - - - min - 0 - - - max - 20 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (781, 487) - - - _rotation - 0 - - - - uhd_usrp_source - - id - uhd_usrp_source_0 - - - _enabled - True - - - type - complex - - - dev_addr - address1 - - - sync - - - - clock_rate - 0.0 - - - num_mboards - 1 - - - ref_source0 - - - - sd_spec0 - - - - ref_source1 - - - - sd_spec1 - - - - ref_source2 - - - - sd_spec2 - - - - ref_source3 - - - - sd_spec3 - - - - ref_source4 - - - - sd_spec4 - - - - ref_source5 - - - - sd_spec5 - - - - ref_source6 - - - - sd_spec6 - - - - ref_source7 - - - - sd_spec7 - - - - nchan - 1 - - - samp_rate - samp_rate - - - center_freq0 - tun_freq - - - gain0 - tun_rx_gain - - - ant0 - - - - bw0 - 0 - - - center_freq1 - 0 - - - gain1 - 0 - - - ant1 - - - - bw1 - 0 - - - center_freq2 - 0 - - - gain2 - 0 - - - ant2 - - - - bw2 - 0 - - - center_freq3 - 0 - - - gain3 - 0 - - - ant3 - - - - bw3 - 0 - - - center_freq4 - 0 - - - gain4 - 0 - - - ant4 - - - - bw4 - 0 - - - center_freq5 - 0 - - - gain5 - 0 - - - ant5 - - - - bw5 - 0 - - - center_freq6 - 0 - - - gain6 - 0 - - - ant6 - - - - bw6 - 0 - - - center_freq7 - 0 - - - gain7 - 0 - - - ant7 - - - - bw7 - 0 - - - center_freq8 - 0 - - - gain8 - 0 - - - ant8 - - - - bw8 - 0 - - - center_freq9 - 0 - - - gain9 - 0 - - - ant9 - - - - bw9 - 0 - - - center_freq10 - 0 - - - gain10 - 0 - - - ant10 - - - - bw10 - 0 - - - center_freq11 - 0 - - - gain11 - 0 - - - ant11 - - - - bw11 - 0 - - - center_freq12 - 0 - - - gain12 - 0 - - - ant12 - - - - bw12 - 0 - - - center_freq13 - 0 - - - gain13 - 0 - - - ant13 - - - - bw13 - 0 - - - center_freq14 - 0 - - - gain14 - 0 - - - ant14 - - - - bw14 - 0 - - - center_freq15 - 0 - - - gain15 - 0 - - - ant15 - - - - bw15 - 0 - - - center_freq16 - 0 - - - gain16 - 0 - - - ant16 - - - - bw16 - 0 - - - center_freq17 - 0 - - - gain17 - 0 - - - ant17 - - - - bw17 - 0 - - - center_freq18 - 0 - - - gain18 - 0 - - - ant18 - - - - bw18 - 0 - - - center_freq19 - 0 - - - gain19 - 0 - - - ant19 - - - - bw19 - 0 - - - center_freq20 - 0 - - - gain20 - 0 - - - ant20 - - - - bw20 - 0 - - - center_freq21 - 0 - - - gain21 - 0 - - - ant21 - - - - bw21 - 0 - - - center_freq22 - 0 - - - gain22 - 0 - - - ant22 - - - - bw22 - 0 - - - center_freq23 - 0 - - - gain23 - 0 - - - ant23 - - - - bw23 - 0 - - - center_freq24 - 0 - - - gain24 - 0 - - - ant24 - - - - bw24 - 0 - - - center_freq25 - 0 - - - gain25 - 0 - - - ant25 - - - - bw25 - 0 - - - center_freq26 - 0 - - - gain26 - 0 - - - ant26 - - - - bw26 - 0 - - - center_freq27 - 0 - - - gain27 - 0 - - - ant27 - - - - bw27 - 0 - - - center_freq28 - 0 - - - gain28 - 0 - - - ant28 - - - - bw28 - 0 - - - center_freq29 - 0 - - - gain29 - 0 - - - ant29 - - - - bw29 - 0 - - - center_freq30 - 0 - - - gain30 - 0 - - - ant30 - - - - bw30 - 0 - - - center_freq31 - 0 - - - gain31 - 0 - - - ant31 - - - - bw31 - 0 - - - _coordinate - (672, 320) - - - _rotation - 0 - - - - variable_slider - - id - tone_ampl - - - _enabled - True - - - label - Tone Ampl - - - value - 0.15 - - - min - 0 - - - max - 1 - - - num_steps - 100 - - - style - wx.SL_VERTICAL - - - converver - float_converter - - - grid_pos - 1, 0, 2, 1 - - - notebook - - - - _coordinate - (14, 485) - - - _rotation - 0 - - - - variable_slider - - id - noise_ampl - - - _enabled - True - - - label - Noise Ampl - - - value - 0.1 - - - min - 0 - - - max - 1 - - - num_steps - 100 - - - style - wx.SL_VERTICAL - - - converver - float_converter - - - grid_pos - 1, 1, 2, 1 - - - notebook - - - - _coordinate - (15, 335) - - - _rotation - 0 - - - - gr_add_xx - - id - gr_add_xx - - - _enabled - True - - - type - complex - - - num_inputs - 3 - - - vlen - 1 - - - _coordinate - (529, 172) - - - _rotation - 0 - - - - options - - id - uhd_two_tone_loopback - - - _enabled - True - - - title - UHD Loopback - 2 Tone - - - author - Example - - - description - Loopback test - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - wxgui_fftsink2 - - id - wxgui_fftsink2 - - - _enabled - True - - - type - complex - - - title - FFT Plot - - - samp_rate - samp_rate - - - baseband_freq - 0 - - - y_per_div - 10 - - - y_divs - 10 - - - ref_level - 0 - - - ref_scale - 2.0 - - - fft_size - 512*2 - - - fft_rate - 15 - - - peak_hold - False - - - average - False - - - avg_alpha - 0 - - - win - window.blackmanharris - - - win_size - - - - grid_pos - 1, 2, 2, 4 - - - notebook - - - - _coordinate - (1114, 264) - - - _rotation - 0 - - - - parameter - - id - samp_rate - - - _enabled - True - - - label - Sample Rate - - - value - 500e3 - - - type - eng_float - - - short_id - s - - - _coordinate - (539, 11) - - - _rotation - 0 - - - - gr_noise_source_x - gr_add_xx - 0 - 2 - - - gr_sig_source_x0 - gr_add_xx - 0 - 1 - - - gr_sig_source_x - gr_add_xx - 0 - 0 - - - gr_add_xx - uhd_usrp_sink_0 - 0 - 0 - - - uhd_usrp_source_0 - wxgui_fftsink2 - 0 - 0 - - diff --git a/gnuradio-examples/grc/uhd/uhd_tx_dpsk.grc b/gnuradio-examples/grc/uhd/uhd_tx_dpsk.grc deleted file mode 100644 index 281ba8429..000000000 --- a/gnuradio-examples/grc/uhd/uhd_tx_dpsk.grc +++ /dev/null @@ -1,1234 +0,0 @@ - - - Sat Oct 8 14:55:39 2011 - - variable - - id - samps_per_sym - - - _enabled - True - - - value - 4 - - - _coordinate - (10, 100) - - - _rotation - 0 - - - - variable_slider - - id - ampl - - - _enabled - True - - - label - Amplitude - - - value - .1 - - - min - 0 - - - max - 1 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (7, 299) - - - _rotation - 0 - - - - parameter - - id - samp_rate - - - _enabled - True - - - label - Sample Rate - - - value - 1e6 - - - type - eng_float - - - short_id - s - - - _coordinate - (334, 15) - - - _rotation - 0 - - - - parameter - - id - freq - - - _enabled - True - - - label - Default Frequency - - - value - 2.45e9 - - - type - eng_float - - - short_id - f - - - _coordinate - (463, 17) - - - _rotation - 0 - - - - variable_slider - - id - tun_gain - - - _enabled - True - - - label - UHD Gain - - - value - gain - - - min - 0 - - - max - 20 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (151, 441) - - - _rotation - 0 - - - - variable_slider - - id - tun_freq - - - _enabled - True - - - label - Freq (Hz) - - - value - freq - - - min - 2.4e9 - - - max - 2.5e9 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (7, 441) - - - _rotation - 0 - - - - random_source_x - - id - random_source_x_0 - - - _enabled - True - - - type - byte - - - min - 0 - - - max - 2**8 - - - num_samps - 1000 - - - repeat - True - - - _coordinate - (177, 162) - - - _rotation - 0 - - - - digital_dxpsk_mod - - id - digital_dxpsk_mod_0 - - - _enabled - True - - - type - dqpsk - - - samples_per_symbol - samps_per_sym - - - excess_bw - 0.35 - - - gray_coded - True - - - verbose - False - - - log - False - - - _coordinate - (366, 162) - - - _rotation - 0 - - - - parameter - - id - gain - - - _enabled - True - - - label - Default Gain - - - value - 0 - - - type - eng_float - - - short_id - g - - - _coordinate - (619, 15) - - - _rotation - 0 - - - - parameter - - id - address - - - _enabled - True - - - label - IP Address - - - value - addr=192.168.10.2 - - - type - string - - - short_id - a - - - _coordinate - (177, 14) - - - _rotation - 0 - - - - uhd_usrp_sink - - id - uhd_usrp_sink_0 - - - _enabled - True - - - type - complex - - - dev_addr - address - - - sync - - - - clock_rate - 0.0 - - - num_mboards - 1 - - - ref_source0 - - - - sd_spec0 - - - - ref_source1 - - - - sd_spec1 - - - - ref_source2 - - - - sd_spec2 - - - - ref_source3 - - - - sd_spec3 - - - - ref_source4 - - - - sd_spec4 - - - - ref_source5 - - - - sd_spec5 - - - - ref_source6 - - - - sd_spec6 - - - - ref_source7 - - - - sd_spec7 - - - - nchan - 1 - - - samp_rate - samp_rate - - - center_freq0 - tun_freq - - - gain0 - tun_gain - - - ant0 - - - - bw0 - 0 - - - center_freq1 - 0 - - - gain1 - 0 - - - ant1 - - - - bw1 - 0 - - - center_freq2 - 0 - - - gain2 - 0 - - - ant2 - - - - bw2 - 0 - - - center_freq3 - 0 - - - gain3 - 0 - - - ant3 - - - - bw3 - 0 - - - center_freq4 - 0 - - - gain4 - 0 - - - ant4 - - - - bw4 - 0 - - - center_freq5 - 0 - - - gain5 - 0 - - - ant5 - - - - bw5 - 0 - - - center_freq6 - 0 - - - gain6 - 0 - - - ant6 - - - - bw6 - 0 - - - center_freq7 - 0 - - - gain7 - 0 - - - ant7 - - - - bw7 - 0 - - - center_freq8 - 0 - - - gain8 - 0 - - - ant8 - - - - bw8 - 0 - - - center_freq9 - 0 - - - gain9 - 0 - - - ant9 - - - - bw9 - 0 - - - center_freq10 - 0 - - - gain10 - 0 - - - ant10 - - - - bw10 - 0 - - - center_freq11 - 0 - - - gain11 - 0 - - - ant11 - - - - bw11 - 0 - - - center_freq12 - 0 - - - gain12 - 0 - - - ant12 - - - - bw12 - 0 - - - center_freq13 - 0 - - - gain13 - 0 - - - ant13 - - - - bw13 - 0 - - - center_freq14 - 0 - - - gain14 - 0 - - - ant14 - - - - bw14 - 0 - - - center_freq15 - 0 - - - gain15 - 0 - - - ant15 - - - - bw15 - 0 - - - center_freq16 - 0 - - - gain16 - 0 - - - ant16 - - - - bw16 - 0 - - - center_freq17 - 0 - - - gain17 - 0 - - - ant17 - - - - bw17 - 0 - - - center_freq18 - 0 - - - gain18 - 0 - - - ant18 - - - - bw18 - 0 - - - center_freq19 - 0 - - - gain19 - 0 - - - ant19 - - - - bw19 - 0 - - - center_freq20 - 0 - - - gain20 - 0 - - - ant20 - - - - bw20 - 0 - - - center_freq21 - 0 - - - gain21 - 0 - - - ant21 - - - - bw21 - 0 - - - center_freq22 - 0 - - - gain22 - 0 - - - ant22 - - - - bw22 - 0 - - - center_freq23 - 0 - - - gain23 - 0 - - - ant23 - - - - bw23 - 0 - - - center_freq24 - 0 - - - gain24 - 0 - - - ant24 - - - - bw24 - 0 - - - center_freq25 - 0 - - - gain25 - 0 - - - ant25 - - - - bw25 - 0 - - - center_freq26 - 0 - - - gain26 - 0 - - - ant26 - - - - bw26 - 0 - - - center_freq27 - 0 - - - gain27 - 0 - - - ant27 - - - - bw27 - 0 - - - center_freq28 - 0 - - - gain28 - 0 - - - ant28 - - - - bw28 - 0 - - - center_freq29 - 0 - - - gain29 - 0 - - - ant29 - - - - bw29 - 0 - - - center_freq30 - 0 - - - gain30 - 0 - - - ant30 - - - - bw30 - 0 - - - center_freq31 - 0 - - - gain31 - 0 - - - ant31 - - - - bw31 - 0 - - - _coordinate - (783, 162) - - - _rotation - 0 - - - - gr_multiply_const_vxx - - id - gr_multiply_const_vxx_0 - - - _enabled - True - - - type - complex - - - const - ampl - - - vlen - 1 - - - _coordinate - (566, 186) - - - _rotation - 0 - - - - wxgui_fftsink2 - - id - wxgui_fftsink2_0 - - - _enabled - True - - - type - complex - - - title - Transmit Spectrum - - - samp_rate - samp_rate - - - baseband_freq - tun_freq - - - y_per_div - 10 - - - y_divs - 10 - - - ref_level - 0 - - - ref_scale - 2 - - - fft_size - 1024 - - - fft_rate - 20 - - - peak_hold - False - - - average - False - - - avg_alpha - 0 - - - win - None - - - win_size - - - - grid_pos - - - - notebook - - - - _coordinate - (827, 299) - - - _rotation - 0 - - - - options - - id - uhd_tx_dpsk - - - _enabled - True - - - title - UHD TX DPSK - - - author - - - - description - - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - random_source_x_0 - digital_dxpsk_mod_0 - 0 - 0 - - - gr_multiply_const_vxx_0 - wxgui_fftsink2_0 - 0 - 0 - - - gr_multiply_const_vxx_0 - uhd_usrp_sink_0 - 0 - 0 - - - digital_dxpsk_mod_0 - gr_multiply_const_vxx_0 - 0 - 0 - - diff --git a/gnuradio-examples/grc/uhd/uhd_wbfm_receive.grc b/gnuradio-examples/grc/uhd/uhd_wbfm_receive.grc deleted file mode 100644 index 62658a2eb..000000000 --- a/gnuradio-examples/grc/uhd/uhd_wbfm_receive.grc +++ /dev/null @@ -1,1365 +0,0 @@ - - - Sat Oct 8 15:18:49 2011 - - options - - id - uhd_wbfm_receive - - - _enabled - True - - - title - UHD WBFM Receive - - - author - Example - - - description - WBFM Receive - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - parameter - - id - gain - - - _enabled - True - - - label - Default Gain - - - value - 0 - - - type - eng_float - - - short_id - g - - - _coordinate - (631, 15) - - - _rotation - 0 - - - - parameter - - id - freq - - - _enabled - True - - - label - Default Frequency - - - value - 93.3e6 - - - type - eng_float - - - short_id - f - - - _coordinate - (479, 15) - - - _rotation - 0 - - - - variable_slider - - id - tun_freq - - - _enabled - True - - - label - Freq (Hz) - - - value - freq - - - min - 87.9e6 - - - max - 108.1e6 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (15, 441) - - - _rotation - 0 - - - - variable_slider - - id - fine - - - _enabled - True - - - label - Fine Freq (MHz) - - - value - 0 - - - min - -.1 - - - max - .1 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 0, 2, 1, 2 - - - notebook - - - - _coordinate - (277, 444) - - - _rotation - 0 - - - - variable_slider - - id - tun_gain - - - _enabled - True - - - label - UHD Gain - - - value - gain - - - min - 0 - - - max - 20 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (158, 440) - - - _rotation - 0 - - - - variable_slider - - id - volume - - - _enabled - True - - - label - Volume - - - value - 1 - - - min - 0 - - - max - 10 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 1, 0, 1, 4 - - - notebook - - - - _coordinate - (436, 446) - - - _rotation - 0 - - - - gr_multiply_const_vxx - - id - gr_multiply_const_vxx - - - _enabled - True - - - type - float - - - const - volume - - - vlen - 1 - - - _coordinate - (836, 161) - - - _rotation - 0 - - - - uhd_usrp_source - - id - uhd_usrp_source_0 - - - _enabled - True - - - type - complex - - - dev_addr - address - - - sync - - - - clock_rate - 0.0 - - - num_mboards - 1 - - - ref_source0 - - - - sd_spec0 - - - - ref_source1 - - - - sd_spec1 - - - - ref_source2 - - - - sd_spec2 - - - - ref_source3 - - - - sd_spec3 - - - - ref_source4 - - - - sd_spec4 - - - - ref_source5 - - - - sd_spec5 - - - - ref_source6 - - - - sd_spec6 - - - - ref_source7 - - - - sd_spec7 - - - - nchan - 1 - - - samp_rate - samp_rate - - - center_freq0 - tun_freq+fine - - - gain0 - tun_gain - - - ant0 - - - - bw0 - 0 - - - center_freq1 - 0 - - - gain1 - 0 - - - ant1 - - - - bw1 - 0 - - - center_freq2 - 0 - - - gain2 - 0 - - - ant2 - - - - bw2 - 0 - - - center_freq3 - 0 - - - gain3 - 0 - - - ant3 - - - - bw3 - 0 - - - center_freq4 - 0 - - - gain4 - 0 - - - ant4 - - - - bw4 - 0 - - - center_freq5 - 0 - - - gain5 - 0 - - - ant5 - - - - bw5 - 0 - - - center_freq6 - 0 - - - gain6 - 0 - - - ant6 - - - - bw6 - 0 - - - center_freq7 - 0 - - - gain7 - 0 - - - ant7 - - - - bw7 - 0 - - - center_freq8 - 0 - - - gain8 - 0 - - - ant8 - - - - bw8 - 0 - - - center_freq9 - 0 - - - gain9 - 0 - - - ant9 - - - - bw9 - 0 - - - center_freq10 - 0 - - - gain10 - 0 - - - ant10 - - - - bw10 - 0 - - - center_freq11 - 0 - - - gain11 - 0 - - - ant11 - - - - bw11 - 0 - - - center_freq12 - 0 - - - gain12 - 0 - - - ant12 - - - - bw12 - 0 - - - center_freq13 - 0 - - - gain13 - 0 - - - ant13 - - - - bw13 - 0 - - - center_freq14 - 0 - - - gain14 - 0 - - - ant14 - - - - bw14 - 0 - - - center_freq15 - 0 - - - gain15 - 0 - - - ant15 - - - - bw15 - 0 - - - center_freq16 - 0 - - - gain16 - 0 - - - ant16 - - - - bw16 - 0 - - - center_freq17 - 0 - - - gain17 - 0 - - - ant17 - - - - bw17 - 0 - - - center_freq18 - 0 - - - gain18 - 0 - - - ant18 - - - - bw18 - 0 - - - center_freq19 - 0 - - - gain19 - 0 - - - ant19 - - - - bw19 - 0 - - - center_freq20 - 0 - - - gain20 - 0 - - - ant20 - - - - bw20 - 0 - - - center_freq21 - 0 - - - gain21 - 0 - - - ant21 - - - - bw21 - 0 - - - center_freq22 - 0 - - - gain22 - 0 - - - ant22 - - - - bw22 - 0 - - - center_freq23 - 0 - - - gain23 - 0 - - - ant23 - - - - bw23 - 0 - - - center_freq24 - 0 - - - gain24 - 0 - - - ant24 - - - - bw24 - 0 - - - center_freq25 - 0 - - - gain25 - 0 - - - ant25 - - - - bw25 - 0 - - - center_freq26 - 0 - - - gain26 - 0 - - - ant26 - - - - bw26 - 0 - - - center_freq27 - 0 - - - gain27 - 0 - - - ant27 - - - - bw27 - 0 - - - center_freq28 - 0 - - - gain28 - 0 - - - ant28 - - - - bw28 - 0 - - - center_freq29 - 0 - - - gain29 - 0 - - - ant29 - - - - bw29 - 0 - - - center_freq30 - 0 - - - gain30 - 0 - - - ant30 - - - - bw30 - 0 - - - center_freq31 - 0 - - - gain31 - 0 - - - ant31 - - - - bw31 - 0 - - - _coordinate - (14, 165) - - - _rotation - 0 - - - - parameter - - id - address - - - _enabled - True - - - label - IP Address - - - value - addr=192.168.10.2 - - - type - string - - - short_id - a - - - _coordinate - (199, 14) - - - _rotation - 0 - - - - wxgui_fftsink2 - - id - wxgui_fftsink2 - - - _enabled - True - - - type - complex - - - title - FFT Plot - - - samp_rate - samp_rate - - - baseband_freq - (freq+fine)*1e6 - - - y_per_div - 10 - - - y_divs - 10 - - - ref_level - 0 - - - ref_scale - 2.0 - - - fft_size - 512 - - - fft_rate - 15 - - - peak_hold - False - - - average - False - - - avg_alpha - 0 - - - win - None - - - win_size - - - - grid_pos - 2, 0, 2, 4 - - - notebook - - - - _coordinate - (624, 278) - - - _rotation - 0 - - - - parameter - - id - samp_rate - - - _enabled - True - - - label - Sample Rate - - - value - 400e3 - - - type - eng_float - - - short_id - s - - - _coordinate - (352, 15) - - - _rotation - 0 - - - - parameter - - id - audio_output - - - _enabled - True - - - label - Audio Output Device - - - value - - - - type - string - - - short_id - O - - - _coordinate - (769, 13) - - - _rotation - 0 - - - - audio_sink - - id - audio_sink - - - _enabled - True - - - samp_rate - int(samp_rate/audio_decim) - - - device_name - audio_output - - - ok_to_block - True - - - num_inputs - 1 - - - _coordinate - (1023, 161) - - - _rotation - 0 - - - - blks2_wfm_rcv - - id - blks2_wfm_rcv - - - _enabled - True - - - quad_rate - samp_rate - - - audio_decimation - audio_decim - - - _coordinate - (626, 153) - - - _rotation - 0 - - - - low_pass_filter - - id - low_pass_filter_0 - - - _enabled - True - - - type - fir_filter_ccf - - - decim - 1 - - - interp - 1 - - - gain - 1 - - - samp_rate - samp_rate - - - cutoff_freq - 115e3 - - - width - 30e3 - - - win - firdes.WIN_HANN - - - beta - 6.76 - - - _coordinate - (326, 141) - - - _rotation - 0 - - - - variable - - id - audio_decim - - - _enabled - True - - - value - 10 - - - _coordinate - (19, 351) - - - _rotation - 0 - - - - gr_multiply_const_vxx - audio_sink - 0 - 0 - - - blks2_wfm_rcv - gr_multiply_const_vxx - 0 - 0 - - - low_pass_filter_0 - blks2_wfm_rcv - 0 - 0 - - - uhd_usrp_source_0 - low_pass_filter_0 - 0 - 0 - - - low_pass_filter_0 - wxgui_fftsink2 - 0 - 0 - - diff --git a/gr-audio/CMakeLists.txt b/gr-audio/CMakeLists.txt index 7038b9b0f..f9975cf08 100644 --- a/gr-audio/CMakeLists.txt +++ b/gr-audio/CMakeLists.txt @@ -33,6 +33,8 @@ GR_REGISTER_COMPONENT("gr-audio" ENABLE_GR_AUDIO GR_SET_GLOBAL(GR_AUDIO_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include) +SET(GR_PKG_AUDIO_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/audio) + ######################################################################## # Begin conditional configuration ######################################################################## @@ -65,6 +67,13 @@ CPACK_COMPONENT("audio_python" DEPENDS "core_python;audio_runtime" ) +CPACK_COMPONENT("audio_examples" + GROUP "Audio" + DISPLAY_NAME "Examples" + DESCRIPTION "Example programs" + DEPENDS "audio_runtime" +) + CPACK_COMPONENT("audio_swig" GROUP "Audio" DISPLAY_NAME "SWIG" @@ -77,12 +86,13 @@ CPACK_COMPONENT("audio_swig" ######################################################################## add_subdirectory(include) add_subdirectory(lib) -add_subdirectory(examples/c++) add_subdirectory(doc) +add_subdirectory(examples/c++) if(ENABLE_PYTHON) add_subdirectory(swig) add_subdirectory(grc) add_subdirectory(examples/python) + add_subdirectory(examples/grc) endif(ENABLE_PYTHON) ######################################################################## diff --git a/gr-audio/examples/c++/CMakeLists.txt b/gr-audio/examples/c++/CMakeLists.txt index 38490cce8..28bbc52a5 100644 --- a/gr-audio/examples/c++/CMakeLists.txt +++ b/gr-audio/examples/c++/CMakeLists.txt @@ -21,3 +21,9 @@ include_directories(${GR_AUDIO_INCLUDE_DIRS}) include_directories(${GNURADIO_CORE_INCLUDE_DIRS}) add_executable(dial_tone dial_tone.cc) target_link_libraries(dial_tone gnuradio-audio) + +INSTALL(TARGETS + dial_tone + DESTINATION ${GR_PKG_AUDIO_EXAMPLES_DIR} + COMPONENT "audio_examples" +) diff --git a/gr-audio/examples/grc/CMakeLists.txt b/gr-audio/examples/grc/CMakeLists.txt new file mode 100644 index 000000000..179b42fcc --- /dev/null +++ b/gr-audio/examples/grc/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +install( + FILES + cvsd_sweep.grc + dial_tone.grc + DESTINATION ${GR_PKG_AUDIO_EXAMPLES_DIR} + COMPONENT "audio_python" +) + diff --git a/gr-audio/examples/grc/cvsd_sweep.grc b/gr-audio/examples/grc/cvsd_sweep.grc new file mode 100644 index 000000000..b645b747a --- /dev/null +++ b/gr-audio/examples/grc/cvsd_sweep.grc @@ -0,0 +1,918 @@ + + + Sat Sep 19 20:30:08 2009 + + import + + id + import_0 + + + _enabled + True + + + import + import math + + + _coordinate + (157, 11) + + + _rotation + 0 + + + + vocoder_cvsd_decode_bf + + id + vocoder_cvsd_decode_bf_0 + + + _enabled + True + + + resample + resample + + + bw + bw + + + _coordinate + (887, 340) + + + _rotation + 0 + + + + gr_sig_source_x + + id + tri_source + + + _enabled + True + + + type + float + + + samp_rate + audio_rate + + + waveform + gr.GR_TRI_WAVE + + + freq + 0.05 + + + amp + 0.5 + + + offset + 0 + + + _coordinate + (44, 316) + + + _rotation + 0 + + + + gr_throttle + + id + throttle + + + _enabled + True + + + type + float + + + samples_per_second + audio_rate + + + vlen + 1 + + + _coordinate + (238, 348) + + + _rotation + 0 + + + + gr_vco_f + + id + vco + + + _enabled + True + + + samp_rate + audio_rate + + + sensitivity + audio_rate*2*math.pi + + + amplitude + 0.9 + + + _coordinate + (427, 332) + + + _rotation + 0 + + + + vocoder_cvsd_encode_fb + + id + enc + + + _enabled + True + + + resample + resample + + + bw + bw + + + _coordinate + (655, 340) + + + _rotation + 0 + + + + gr_packed_to_unpacked_xx + + id + p2u + + + _enabled + True + + + type + byte + + + bits_per_chunk + 1 + + + endianness + gr.GR_MSB_FIRST + + + _coordinate + (648, 415) + + + _rotation + 180 + + + + gr_char_to_float + + id + c2f + + + _enabled + True + + + _coordinate + (676, 483) + + + _rotation + 0 + + + + audio_sink + + id + audio_sink + + + _enabled + True + + + samp_rate + audio_rate + + + device_name + plughw:0,0 + + + ok_to_block + True + + + num_inputs + 1 + + + _coordinate + (1127, 340) + + + _rotation + 0 + + + + variable + + id + audio_rate + + + _enabled + True + + + value + 8000 + + + _coordinate + (251, 10) + + + _rotation + 0 + + + + variable + + id + resample + + + _enabled + True + + + value + 8 + + + _coordinate + (344, 11) + + + _rotation + 0 + + + + variable + + id + bw + + + _enabled + True + + + value + 0.5 + + + _coordinate + (431, 11) + + + _rotation + 0 + + + + notebook + + id + displays + + + _enabled + True + + + style + wx.NB_TOP + + + labels + ['Original','Encoded','Decoded'] + + + grid_pos + + + + notebook + + + + _coordinate + (12, 106) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + orig_fft + + + _enabled + True + + + type + float + + + title + Original Spectrum + + + samp_rate + audio_rate + + + baseband_freq + 0 + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 0 + + + ref_scale + 2.0 + + + fft_size + 1024 + + + fft_rate + 30 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + grid_pos + 0, 0, 1, 1 + + + notebook + displays, 0 + + + _coordinate + (415, 97) + + + _rotation + 180 + + + + wxgui_scopesink2 + + id + orig_scope + + + _enabled + True + + + type + float + + + title + Original Waveform + + + samp_rate + audio_rate + + + v_scale + 0 + + + t_scale + 0 + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + grid_pos + 1, 0, 1, 1 + + + notebook + displays, 0 + + + _coordinate + (414, 425) + + + _rotation + 180 + + + + wxgui_fftsink2 + + id + enc_fft + + + _enabled + True + + + type + float + + + title + Encoded Spectrum + + + samp_rate + audio_rate*resample + + + baseband_freq + 0 + + + y_per_div + 10 + + + y_divs + 8 + + + ref_level + 10 + + + ref_scale + 2.0 + + + fft_size + 1024 + + + fft_rate + 30 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + grid_pos + 1, 0, 1, 1 + + + notebook + displays, 1 + + + _coordinate + (610, 551) + + + _rotation + 180 + + + + wxgui_scopesink2 + + id + enc_scope + + + _enabled + True + + + type + float + + + title + Encoded Waveform + + + samp_rate + audio_rate*resample + + + v_scale + 0.5 + + + t_scale + 20.0/(audio_rate*resample) + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + grid_pos + 0, 0, 1, 1 + + + notebook + displays, 1 + + + _coordinate + (858, 591) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + dec_fft + + + _enabled + True + + + type + float + + + title + Decoded Spectrum + + + samp_rate + audio_rate + + + baseband_freq + 0 + + + y_per_div + 5 + + + y_divs + 10 + + + ref_level + 10 + + + ref_scale + 0.1 + + + fft_size + 1024 + + + fft_rate + 30 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + grid_pos + 0, 0, 1, 1 + + + notebook + displays, 2 + + + _coordinate + (891, 98) + + + _rotation + 180 + + + + wxgui_scopesink2 + + id + dec_scope + + + _enabled + True + + + type + float + + + title + Decoded Waveform + + + samp_rate + audio_rate + + + v_scale + 0 + + + t_scale + 0 + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + grid_pos + 1, 0, 1, 1 + + + notebook + displays, 2 + + + _coordinate + (889, 422) + + + _rotation + 180 + + + + options + + id + cvsd_sweep + + + _enabled + True + + + title + CVSD Vocoder Test + + + author + + + + description + + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + vco + orig_fft + 0 + 0 + + + tri_source + throttle + 0 + 0 + + + throttle + vco + 0 + 0 + + + vco + enc + 0 + 0 + + + enc + vocoder_cvsd_decode_bf_0 + 0 + 0 + + + vco + orig_scope + 0 + 0 + + + vocoder_cvsd_decode_bf_0 + dec_fft + 0 + 0 + + + vocoder_cvsd_decode_bf_0 + dec_scope + 0 + 0 + + + vocoder_cvsd_decode_bf_0 + audio_sink + 0 + 0 + + + enc + p2u + 0 + 0 + + + p2u + c2f + 0 + 0 + + + c2f + enc_fft + 0 + 0 + + + c2f + enc_scope + 0 + 0 + + diff --git a/gr-audio/examples/grc/dial_tone.grc b/gr-audio/examples/grc/dial_tone.grc new file mode 100644 index 000000000..ac8cbef27 --- /dev/null +++ b/gr-audio/examples/grc/dial_tone.grc @@ -0,0 +1,375 @@ + + + Thu Jul 24 14:27:48 2008 + + options + + id + dial_tone + + + _enabled + True + + + title + Dial Tone + + + author + Example + + + description + example flow graph + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + gr_add_xx + + id + gr_add_xx + + + _enabled + True + + + type + float + + + num_inputs + 3 + + + vlen + 1 + + + _coordinate + (513, 277) + + + _rotation + 0 + + + + audio_sink + + id + audio_sink + + + _enabled + True + + + samp_rate + 32000 + + + device_name + + + + ok_to_block + True + + + num_inputs + 1 + + + _coordinate + (699, 112) + + + _rotation + 0 + + + + gr_noise_source_x + + id + gr_noise_source_x + + + _enabled + True + + + type + float + + + noise_type + gr.GR_GAUSSIAN + + + amp + noise + + + seed + 42 + + + _coordinate + (238, 380) + + + _rotation + 0 + + + + gr_sig_source_x + + id + gr_sig_source_x + + + _enabled + True + + + type + float + + + samp_rate + samp_rate + + + waveform + gr.GR_COS_WAVE + + + freq + 440 + + + amp + ampl + + + offset + 0 + + + _coordinate + (240, 208) + + + _rotation + 0 + + + + gr_sig_source_x + + id + gr_sig_source_x0 + + + _enabled + True + + + type + float + + + samp_rate + samp_rate + + + waveform + gr.GR_COS_WAVE + + + freq + 350 + + + amp + ampl + + + offset + 0 + + + _coordinate + (240, 38) + + + _rotation + 0 + + + + variable_slider + + id + ampl + + + _enabled + True + + + label + Volume + + + value + .4 + + + min + 0 + + + max + .5 + + + num_steps + 100 + + + slider_type + horizontal + + + grid_pos + 0, 0, 1, 2 + + + _coordinate + (634, 413) + + + _rotation + 0 + + + + variable_slider + + id + noise + + + _enabled + True + + + label + Noise + + + value + .005 + + + min + 0 + + + max + .2 + + + num_steps + 100 + + + slider_type + horizontal + + + grid_pos + 1, 0, 1, 2 + + + _coordinate + (443, 412) + + + _rotation + 0 + + + + variable + + id + samp_rate + + + _enabled + True + + + value + 32000 + + + _coordinate + (11, 171) + + + _rotation + 0 + + + + gr_sig_source_x0 + gr_add_xx + 0 + 0 + + + gr_sig_source_x + gr_add_xx + 0 + 1 + + + gr_noise_source_x + gr_add_xx + 0 + 2 + + + gr_add_xx + audio_sink + 0 + 0 + + diff --git a/gr-audio/examples/python/CMakeLists.txt b/gr-audio/examples/python/CMakeLists.txt index 86ba86ac0..24e29e234 100644 --- a/gr-audio/examples/python/CMakeLists.txt +++ b/gr-audio/examples/python/CMakeLists.txt @@ -32,6 +32,6 @@ GR_PYTHON_INSTALL(PROGRAMS noise.py spectrum_inversion.py test_resampler.py - DESTINATION ${GR_PKG_DATA_DIR}/examples/audio + DESTINATION ${GR_PKG_AUDIO_EXAMPLES_DIR} COMPONENT "audio_python" ) diff --git a/gr-digital/CMakeLists.txt b/gr-digital/CMakeLists.txt index 099af0869..eb7ed67e1 100644 --- a/gr-digital/CMakeLists.txt +++ b/gr-digital/CMakeLists.txt @@ -39,6 +39,8 @@ GR_SET_GLOBAL(GR_DIGITAL_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/swig ) +SET(GR_PKG_DIGITAL_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/digital) + ######################################################################## # Begin conditional configuration ######################################################################## diff --git a/gr-digital/examples/CMakeLists.txt b/gr-digital/examples/CMakeLists.txt index 5c652fc83..12fca6009 100644 --- a/gr-digital/examples/CMakeLists.txt +++ b/gr-digital/examples/CMakeLists.txt @@ -26,7 +26,7 @@ GR_PYTHON_INSTALL(PROGRAMS run_length.py gen_whitener.py snr_estimators.py - DESTINATION ${GR_PKG_DATA_DIR}/examples/digital + DESTINATION ${GR_PKG_DIGITAL_EXAMPLES_DIR} COMPONENT "digital_python" ) @@ -41,7 +41,7 @@ GR_PYTHON_INSTALL(PROGRAMS narrowband/digital_bert_rx.py narrowband/digital_bert_tx.py narrowband/tunnel.py - DESTINATION ${GR_PKG_DATA_DIR}/examples/digital/narrowband + DESTINATION ${GR_PKG_DIGITAL_EXAMPLES_DIR}/narrowband COMPONENT "digital_python" ) @@ -55,6 +55,6 @@ GR_PYTHON_INSTALL(PROGRAMS ofdm/transmit_path.py ofdm/tunnel.py ofdm/uhd_interface.py - DESTINATION ${GR_PKG_DATA_DIR}/examples/digital/ofdm + DESTINATION ${GR_PKG_DIGITAL_EXAMPLES_DIR}/ofdm COMPONENT "digital_python" ) diff --git a/gr-fcd/CMakeLists.txt b/gr-fcd/CMakeLists.txt index e454c01fa..10dd8b8cd 100644 --- a/gr-fcd/CMakeLists.txt +++ b/gr-fcd/CMakeLists.txt @@ -51,6 +51,8 @@ GR_SET_GLOBAL(GR_FCD_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include/fcd ) +SET(GR_PKG_FCD_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/fcd) + ######################################################################## # Begin conditional configuration ######################################################################## @@ -83,6 +85,13 @@ CPACK_COMPONENT("fcd_python" DEPENDS "core_python;fcd_runtime" ) +CPACK_COMPONENT("fcd_examples" + GROUP "FCD" + DISPLAY_NAME "Examples" + DESCRIPTION "Example programs" + DEPENDS "fcd_runtime" +) + CPACK_COMPONENT("fcd_swig" GROUP "FCD" DISPLAY_NAME "SWIG" @@ -99,8 +108,9 @@ if(ENABLE_PYTHON) add_subdirectory(swig) add_subdirectory(python) add_subdirectory(grc) + add_subdirectory(examples/grc) endif(ENABLE_PYTHON) -add_subdirectory(examples) +add_subdirectory(examples/c++) add_subdirectory(doc) ######################################################################## diff --git a/gr-fcd/examples/CMakeLists.txt b/gr-fcd/examples/CMakeLists.txt deleted file mode 100644 index 477a6311b..000000000 --- a/gr-fcd/examples/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2012 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -include_directories(${GR_FCD_INCLUDE_DIRS}) -include_directories(${GNURADIO_CORE_INCLUDE_DIRS}) -include_directories(${GR_AUDIO_INCLUDE_DIRS}) - -add_executable(fcd_nfm_rx fcd_nfm_rx.cc) -target_link_libraries(fcd_nfm_rx gnuradio-fcd) - -INSTALL(TARGETS - fcd_nfm_rx - DESTINATION ${GR_PKG_DATA_DIR}/examples/fcd - COMPONENT "fcd_examples" -) - -if(ENABLE_PYTHON) - INSTALL(FILES - fcd_apt_rx.grc - fcd_fft_wx.grc - fcd_nfm_rx.grc - DESTINATION ${GR_PKG_DATA_DIR}/examples/fcd - COMPONENT "fcd_examples" - ) -endif() diff --git a/gr-fcd/examples/c++/CMakeLists.txt b/gr-fcd/examples/c++/CMakeLists.txt new file mode 100644 index 000000000..05574f4a8 --- /dev/null +++ b/gr-fcd/examples/c++/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +include_directories(${GR_FCD_INCLUDE_DIRS}) +include_directories(${GNURADIO_CORE_INCLUDE_DIRS}) +include_directories(${GR_AUDIO_INCLUDE_DIRS}) + +add_executable(fcd_nfm_rx fcd_nfm_rx.cc) +target_link_libraries(fcd_nfm_rx gnuradio-fcd) + +INSTALL(TARGETS + fcd_nfm_rx + DESTINATION ${GR_PKG_FCD_EXAMPLES_DIR} + COMPONENT "fcd_examples" +) diff --git a/gr-fcd/examples/c++/fcd_nfm_rx.cc b/gr-fcd/examples/c++/fcd_nfm_rx.cc new file mode 100644 index 000000000..97ef7cf19 --- /dev/null +++ b/gr-fcd/examples/c++/fcd_nfm_rx.cc @@ -0,0 +1,114 @@ +/* + * Copyright 2011 Free Software Foundation, Inc. + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +/* + * Simple GNU Radio C++ example for using the Funcube Dongle. + * + * Construct a simple narrow band FM receiver using the gr-fcd + * block as source. + * + * This example uses "hw:1" as FCD source device and the default + * audio device for output. + * + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +// Include header files for each block used in flowgraph +#include +#include +#include +#include +#include +#include + +// other includes +#include +#include + + +namespace po = boost::program_options; + +int main(int argc, char **argv) +{ + int rate = 48000; // Audio card sample rate + float pi = 3.141592654; + + + //variables to be set by po + std::string device; + int freq; + float gain; + + //setup the program options + po::options_description desc("Command line options"); + desc.add_options() + ("help", "This help message") + ("device", po::value(&device)->default_value("hw:1"), "Audio input device") + ("freq", po::value(&freq)->default_value(145500), "RF frequency in kHz") + ("gain", po::value(&gain)->default_value(20.0), "LNA gain in dB") + ; + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + //print the help message + if (vm.count("help")){ + std::cout << "Narrow band FM receiver example" << std::endl << desc << std::endl; + return ~0; + } + + + // Construct a top block that will contain flowgraph blocks. + gr_top_block_sptr tb = gr_make_top_block("fcd_nfm_rx"); + + // FCD source + fcd_source_c_sptr fcd = fcd_make_source_c(device); + fcd->set_freq_khz(freq); + fcd->set_lna_gain(gain); + + // Low pass filter + std::vector taps = gr_firdes::low_pass(1.0, 96000, 5000.0, 1000.0); + gr_fir_filter_ccf_sptr filter = gr_make_fir_filter_ccf (2, taps); + + // FM demodulator + // gain = sample_rate / (2*pi*max_dev) + gr_quadrature_demod_cf_sptr demod = gr_make_quadrature_demod_cf (rate/(2.0*pi*5000.0)); + + // Audio sink + audio_sink::sptr sink = audio_make_sink(rate); + + // Connect blocks + tb->connect(fcd, 0, filter, 0); + tb->connect(filter, 0, demod, 0); + tb->connect(demod, 0, sink, 0); + + // Tell GNU Radio runtime to start flowgraph threads; the foreground thread + // will block until either flowgraph exits (this example doesn't) or the + // application receives SIGINT (e.g., user hits CTRL-C). + // + // Real applications may use tb->start() which returns, allowing the foreground + // thread to proceed, then later use tb->stop(), followed by tb->wait(), to cleanup + // GNU Radio before exiting. + tb->run(); + + // Exit normally. + return 0; +} diff --git a/gr-fcd/examples/fcd_apt_rx.grc b/gr-fcd/examples/fcd_apt_rx.grc deleted file mode 100644 index c4d3e64d1..000000000 --- a/gr-fcd/examples/fcd_apt_rx.grc +++ /dev/null @@ -1,704 +0,0 @@ - - - Sun May 8 18:01:53 2011 - - options - - id - fcd_apt_rx - - - _enabled - True - - - title - NOAA APT Receiver - - - author - Alexandru Csete OZ9AEC - - - description - - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - variable - - id - samp_rate - - - _enabled - True - - - value - 96000 - - - _coordinate - (200, 9) - - - _rotation - 0 - - - - audio_sink - - id - audio_sink - - - _enabled - True - - - samp_rate - 48000 - - - device_name - - - - ok_to_block - True - - - num_inputs - 1 - - - _coordinate - (794, 355) - - - _rotation - 0 - - - - blks2_fm_demod_cf - - id - blks2_fm_demod_cf - - - _enabled - True - - - chan_rate - samp_rate - - - audio_decim - 2 - - - deviation - max_dev - - - audio_pass - 5000 - - - audio_stop - 7000 - - - gain - 1.0 - - - tau - 75e-6 - - - _coordinate - (568, 307) - - - _rotation - 0 - - - - blks2_rational_resampler_xxx - - id - blks2_rational_resampler_xxx_0 - - - _enabled - True - - - type - fff - - - decim - 48000 - - - interp - 11025 - - - taps - [] - - - fractional_bw - 0 - - - _coordinate - (516, 522) - - - _rotation - 0 - - - - variable - - id - wav_file - - - _enabled - True - - - value - prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".wav" - - - _coordinate - (762, 652) - - - _rotation - 0 - - - - variable - - id - prefix - - - _enabled - True - - - value - "FCD_APT_REC-" - - - _coordinate - (625, 653) - - - _rotation - 0 - - - - import - - id - import_0 - - - _enabled - True - - - import - from datetime import datetime - - - _coordinate - (508, 653) - - - _rotation - 0 - - - - gr_wavfile_sink - - id - wavfile_sink - - - _enabled - True - - - file - wav_file - - - nchan - 1 - - - samp_rate - 11025 - - - bits_per_sample - 16 - - - _coordinate - (805, 530) - - - _rotation - 0 - - - - variable_chooser - - id - sat_freq - - - _enabled - True - - - label - Satellite - - - value - 137500000 - - - choices - [137500000,137620000,137912500,137100000] - - - labels - ["NOAA-15","NOAA-17","NOAA-18","NOAA-19"] - - - type - drop_down - - - style - wx.RA_HORIZONTAL - - - grid_pos - 1,0,1,1 - - - notebook - - - - _coordinate - (18, 479) - - - _rotation - 0 - - - - variable - - id - max_dev - - - _enabled - True - - - value - 17000 - - - _coordinate - (299, 10) - - - _rotation - 0 - - - - variable_chooser - - id - fcd_lna_gain - - - _enabled - True - - - label - LNA gain [dB] - - - value - 20.0 - - - choices - [30.0, 25.0, 20.0, 17.5, 15.0, 12.5, 10.0, 7.5, 5.0, 2.5, 0.0, -2.5, -5.0] - - - labels - [] - - - type - drop_down - - - style - wx.RA_HORIZONTAL - - - grid_pos - 2,0,1,1 - - - notebook - - - - _coordinate - (207, 481) - - - _rotation - 0 - - - - variable_static_text - - id - rec_info - - - _enabled - True - - - label - Recording to - - - value - wav_file - - - converver - str_converter - - - formatter - None - - - grid_pos - 1,1,1,1 - - - notebook - - - - _coordinate - (641, 14) - - - _rotation - 0 - - - - low_pass_filter - - id - low_pass_filter - - - _enabled - True - - - type - fir_filter_ccf - - - decim - 1 - - - interp - 1 - - - gain - 1 - - - samp_rate - samp_rate - - - cutoff_freq - 25000 - - - width - 5000 - - - win - firdes.WIN_HAMMING - - - beta - 6.76 - - - _coordinate - (334, 307) - - - _rotation - 0 - - - - fcd_source_c - - id - fcd_source_c_0 - - - _enabled - True - - - device_name - hw:1 - - - freq - sat_freq - - - lna - fcd_lna_gain - - - ppm - -120 - - - dci - 0.0 - - - dcq - 0.0 - - - iq_phase - 0.0 - - - iq_gain - 1.0 - - - _coordinate - (25, 299) - - - _rotation - 0 - - - - wxgui_fftsink2 - - id - fftsink - - - _enabled - True - - - type - complex - - - title - FCD Spectrum - - - samp_rate - samp_rate - - - baseband_freq - sat_freq - - - y_per_div - 10 - - - y_divs - 10 - - - ref_level - 0.0 - - - ref_scale - 1.0 - - - fft_size - 512 - - - fft_rate - 15 - - - peak_hold - False - - - average - False - - - avg_alpha - 0 - - - win - None - - - win_size - - - - grid_pos - 0,0,1,2 - - - notebook - - - - _coordinate - (335, 103) - - - _rotation - 0 - - - - low_pass_filter - blks2_fm_demod_cf - 0 - 0 - - - blks2_fm_demod_cf - audio_sink - 0 - 0 - - - blks2_rational_resampler_xxx_0 - wavfile_sink - 0 - 0 - - - blks2_fm_demod_cf - blks2_rational_resampler_xxx_0 - 0 - 0 - - - fcd_source_c_0 - low_pass_filter - 0 - 0 - - - fcd_source_c_0 - fftsink - 0 - 0 - - diff --git a/gr-fcd/examples/fcd_fft_wx.grc b/gr-fcd/examples/fcd_fft_wx.grc deleted file mode 100644 index c045bbfa2..000000000 --- a/gr-fcd/examples/fcd_fft_wx.grc +++ /dev/null @@ -1,320 +0,0 @@ - - - Sun May 8 18:02:35 2011 - - options - - id - fcd_fft_wx - - - _enabled - True - - - title - Funcube Dongle FFT scope - - - author - Alexandru Csete OZ9AEC - - - description - - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - variable - - id - samp_rate - - - _enabled - True - - - value - 96000 - - - _coordinate - (201, 11) - - - _rotation - 0 - - - - variable_text_box - - id - fcd_freq - - - _enabled - True - - - label - FCD freq - - - value - 145500000 - - - converver - float_converter - - - formatter - None - - - grid_pos - 1,0,1,1 - - - notebook - - - - _coordinate - (300, 11) - - - _rotation - 0 - - - - variable_chooser - - id - fcd_lna_gain - - - _enabled - True - - - label - LNA gain [dB] - - - value - 20.0 - - - choices - [30.0, 25.0, 20.0, 17.5, 15.0, 12.5, 10.0, 7.5, 5.0, 2.5, 0.0, -2.5, -5.0] - - - labels - [] - - - type - drop_down - - - style - wx.RA_HORIZONTAL - - - grid_pos - 2,0,1,1 - - - notebook - - - - _coordinate - (446, 10) - - - _rotation - 0 - - - - wxgui_fftsink2 - - id - wxgui_fftsink2_0 - - - _enabled - True - - - type - complex - - - title - FCD Spectrum - - - samp_rate - samp_rate - - - baseband_freq - fcd_freq - - - y_per_div - 10 - - - y_divs - 10 - - - ref_level - 0 - - - ref_scale - 1.0 - - - fft_size - 512 - - - fft_rate - 15 - - - peak_hold - False - - - average - False - - - avg_alpha - 0 - - - win - None - - - win_size - - - - grid_pos - 0,0,1,2 - - - notebook - - - - _coordinate - (442, 176) - - - _rotation - 0 - - - - fcd_source_c - - id - fcd_source_c_1 - - - _enabled - True - - - device_name - hw:1 - - - freq - fcd_freq - - - lna - fcd_lna_gain - - - ppm - -120 - - - dci - 0.0 - - - dcq - 0.0 - - - iq_phase - 0.0 - - - iq_gain - 1.0 - - - _coordinate - (95, 192) - - - _rotation - 0 - - - - fcd_source_c_1 - wxgui_fftsink2_0 - 0 - 0 - - diff --git a/gr-fcd/examples/fcd_nfm_rx.cc b/gr-fcd/examples/fcd_nfm_rx.cc deleted file mode 100644 index 97ef7cf19..000000000 --- a/gr-fcd/examples/fcd_nfm_rx.cc +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * Simple GNU Radio C++ example for using the Funcube Dongle. - * - * Construct a simple narrow band FM receiver using the gr-fcd - * block as source. - * - * This example uses "hw:1" as FCD source device and the default - * audio device for output. - * - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -// Include header files for each block used in flowgraph -#include -#include -#include -#include -#include -#include - -// other includes -#include -#include - - -namespace po = boost::program_options; - -int main(int argc, char **argv) -{ - int rate = 48000; // Audio card sample rate - float pi = 3.141592654; - - - //variables to be set by po - std::string device; - int freq; - float gain; - - //setup the program options - po::options_description desc("Command line options"); - desc.add_options() - ("help", "This help message") - ("device", po::value(&device)->default_value("hw:1"), "Audio input device") - ("freq", po::value(&freq)->default_value(145500), "RF frequency in kHz") - ("gain", po::value(&gain)->default_value(20.0), "LNA gain in dB") - ; - po::variables_map vm; - po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); - - //print the help message - if (vm.count("help")){ - std::cout << "Narrow band FM receiver example" << std::endl << desc << std::endl; - return ~0; - } - - - // Construct a top block that will contain flowgraph blocks. - gr_top_block_sptr tb = gr_make_top_block("fcd_nfm_rx"); - - // FCD source - fcd_source_c_sptr fcd = fcd_make_source_c(device); - fcd->set_freq_khz(freq); - fcd->set_lna_gain(gain); - - // Low pass filter - std::vector taps = gr_firdes::low_pass(1.0, 96000, 5000.0, 1000.0); - gr_fir_filter_ccf_sptr filter = gr_make_fir_filter_ccf (2, taps); - - // FM demodulator - // gain = sample_rate / (2*pi*max_dev) - gr_quadrature_demod_cf_sptr demod = gr_make_quadrature_demod_cf (rate/(2.0*pi*5000.0)); - - // Audio sink - audio_sink::sptr sink = audio_make_sink(rate); - - // Connect blocks - tb->connect(fcd, 0, filter, 0); - tb->connect(filter, 0, demod, 0); - tb->connect(demod, 0, sink, 0); - - // Tell GNU Radio runtime to start flowgraph threads; the foreground thread - // will block until either flowgraph exits (this example doesn't) or the - // application receives SIGINT (e.g., user hits CTRL-C). - // - // Real applications may use tb->start() which returns, allowing the foreground - // thread to proceed, then later use tb->stop(), followed by tb->wait(), to cleanup - // GNU Radio before exiting. - tb->run(); - - // Exit normally. - return 0; -} diff --git a/gr-fcd/examples/fcd_nfm_rx.grc b/gr-fcd/examples/fcd_nfm_rx.grc deleted file mode 100644 index 9dac3fcb8..000000000 --- a/gr-fcd/examples/fcd_nfm_rx.grc +++ /dev/null @@ -1,1035 +0,0 @@ - - - Sun May 8 18:05:32 2011 - - options - - id - fcd_nfm_rx - - - _enabled - True - - - title - FCD FM Receiver - - - author - OZ9AEC - - - description - Simple FM receiver using the Funcube Dongle - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - variable_static_text - - id - rx_freq - - - _enabled - True - - - label - Receive - - - value - freq+(offset_coarse+offset_fine) - - - converver - float_converter - - - formatter - None - - - grid_pos - 5,3,1,1 - - - notebook - - - - _coordinate - (491, 10) - - - _rotation - 0 - - - - variable_slider - - id - offset_fine - - - _enabled - True - - - label - Fine tune - - - value - 0 - - - min - -1000 - - - max - 1000 - - - num_steps - 400 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 6,0,1,2 - - - notebook - - - - _coordinate - (9, 279) - - - _rotation - 0 - - - - variable_slider - - id - offset_coarse - - - _enabled - True - - - label - Coarse tune - - - value - 0 - - - min - -48000 - - - max - 48000 - - - num_steps - 960 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 6,2,1,2 - - - notebook - - - - _coordinate - (10, 130) - - - _rotation - 0 - - - - variable_slider - - id - width - - - _enabled - True - - - label - Filter - - - value - 10000 - - - min - 2000 - - - max - 40000 - - - num_steps - 760 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 7,0,1,1 - - - notebook - - - - _coordinate - (9, 431) - - - _rotation - 0 - - - - variable_slider - - id - trans - - - _enabled - True - - - label - Trans - - - value - 1500 - - - min - 500 - - - max - 5000 - - - num_steps - 900 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 8,0,1,1 - - - notebook - - - - _coordinate - (10, 577) - - - _rotation - 0 - - - - variable_slider - - id - af_gain - - - _enabled - True - - - label - VOL - - - value - 1 - - - min - 0 - - - max - 5 - - - num_steps - 50 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 8,1,1,1 - - - notebook - - - - _coordinate - (168, 726) - - - _rotation - 0 - - - - low_pass_filter - - id - low_pass_filter - - - _enabled - True - - - type - fir_filter_ccf - - - decim - 1 - - - interp - 1 - - - gain - 1 - - - samp_rate - samp_rate - - - cutoff_freq - width/2 - - - width - trans - - - win - firdes.WIN_HAMMING - - - beta - 6.76 - - - _coordinate - (742, 258) - - - _rotation - 0 - - - - gr_simple_squelch_cc - - id - gr_simple_squelch_cc_0 - - - _enabled - True - - - threshold - sql_lev - - - alpha - 1 - - - _coordinate - (226, 499) - - - _rotation - 0 - - - - blks2_nbfm_rx - - id - nbfm_normal - - - _enabled - True - - - audio_rate - 48000 - - - quad_rate - 96000 - - - tau - 75e-6 - - - max_dev - 5e3 - - - _coordinate - (441, 483) - - - _rotation - 0 - - - - gr_multiply_const_vxx - - id - gr_multiply_const_vxx_1 - - - _enabled - True - - - type - float - - - const - af_gain - - - vlen - 1 - - - _coordinate - (674, 507) - - - _rotation - 0 - - - - audio_sink - - id - audio_sink - - - _enabled - True - - - samp_rate - 48000 - - - device_name - - - - ok_to_block - True - - - num_inputs - 2 - - - _coordinate - (882, 511) - - - _rotation - 0 - - - - variable - - id - samp_rate - - - _enabled - True - - - value - 96000 - - - _coordinate - (210, 12) - - - _rotation - 0 - - - - wxgui_fftsink2 - - id - fftsink - - - _enabled - True - - - type - complex - - - title - - - - samp_rate - samp_rate - - - baseband_freq - rx_freq*display_selector - - - y_per_div - 10 - - - y_divs - 10 - - - ref_level - 0 - - - ref_scale - 1.0 - - - fft_size - 512 - - - fft_rate - 15 - - - peak_hold - False - - - average - True - - - avg_alpha - 0.5 - - - win - None - - - win_size - 800,300 - - - grid_pos - 0,0,5,4 - - - notebook - - - - _coordinate - (742, 24) - - - _rotation - 0 - - - - variable_slider - - id - sql_lev - - - _enabled - True - - - label - SQL - - - value - -100 - - - min - -100 - - - max - 0 - - - num_steps - 500 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 7,2,1,1 - - - notebook - - - - _coordinate - (328, 728) - - - _rotation - 0 - - - - variable - - id - xlate_filter_taps - - - _enabled - True - - - value - firdes.low_pass(1, samp_rate, 48000, 5000, firdes.WIN_HAMMING, 6.76) - - - _coordinate - (428, 294) - - - _rotation - 0 - - - - variable_chooser - - id - display_selector - - - _enabled - True - - - label - Spectrum - - - value - 0 - - - choices - [0, 1] - - - labels - ['Baseband','RF'] - - - type - drop_down - - - style - wx.RA_HORIZONTAL - - - grid_pos - 5,0,1,1 - - - notebook - - - - _coordinate - (481, 728) - - - _rotation - 0 - - - - variable_text_box - - id - freq - - - _enabled - True - - - label - FCD Freq - - - value - 144470000 - - - converver - float_converter - - - formatter - None - - - grid_pos - 5,1,1,1 - - - notebook - - - - _coordinate - (339, 9) - - - _rotation - 0 - - - - gr_freq_xlating_fir_filter_xxx - - id - xlating_fir_filter - - - _enabled - True - - - type - ccc - - - decim - 1 - - - taps - xlate_filter_taps - - - center_freq - -(offset_coarse+offset_fine) - - - samp_rate - samp_rate - - - _coordinate - (433, 189) - - - _rotation - 0 - - - - variable_slider - - id - rf_gain - - - _enabled - True - - - label - RF - - - value - 20 - - - min - -5 - - - max - 30 - - - num_steps - 35 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 7,1,1,1 - - - notebook - - - - _coordinate - (11, 725) - - - _rotation - 0 - - - - fcd_source_c - - id - fcd_source_c_1 - - - _enabled - True - - - device_name - hw:1 - - - freq - freq - - - lna - rf_gain - - - ppm - -120 - - - dci - 0.0 - - - dcq - 0.0 - - - iq_phase - 0.0 - - - iq_gain - 1.0 - - - _coordinate - (165, 157) - - - _rotation - 0 - - - - xlating_fir_filter - fftsink - 0 - 0 - - - xlating_fir_filter - low_pass_filter - 0 - 0 - - - low_pass_filter - gr_simple_squelch_cc_0 - 0 - 0 - - - gr_multiply_const_vxx_1 - audio_sink - 0 - 1 - - - gr_multiply_const_vxx_1 - audio_sink - 0 - 0 - - - gr_simple_squelch_cc_0 - nbfm_normal - 0 - 0 - - - nbfm_normal - gr_multiply_const_vxx_1 - 0 - 0 - - - fcd_source_c_1 - xlating_fir_filter - 0 - 0 - - diff --git a/gr-fcd/examples/grc/CMakeLists.txt b/gr-fcd/examples/grc/CMakeLists.txt new file mode 100644 index 000000000..e33fdf182 --- /dev/null +++ b/gr-fcd/examples/grc/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +INSTALL(FILES + fcd_apt_rx.grc + fcd_fft_wx.grc + fcd_nfm_rx.grc + DESTINATION ${GR_PKG_FCD_EXAMPLES_DIR} + COMPONENT "fcd_examples" +) \ No newline at end of file diff --git a/gr-fcd/examples/grc/fcd_apt_rx.grc b/gr-fcd/examples/grc/fcd_apt_rx.grc new file mode 100644 index 000000000..c4d3e64d1 --- /dev/null +++ b/gr-fcd/examples/grc/fcd_apt_rx.grc @@ -0,0 +1,704 @@ + + + Sun May 8 18:01:53 2011 + + options + + id + fcd_apt_rx + + + _enabled + True + + + title + NOAA APT Receiver + + + author + Alexandru Csete OZ9AEC + + + description + + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + samp_rate + + + _enabled + True + + + value + 96000 + + + _coordinate + (200, 9) + + + _rotation + 0 + + + + audio_sink + + id + audio_sink + + + _enabled + True + + + samp_rate + 48000 + + + device_name + + + + ok_to_block + True + + + num_inputs + 1 + + + _coordinate + (794, 355) + + + _rotation + 0 + + + + blks2_fm_demod_cf + + id + blks2_fm_demod_cf + + + _enabled + True + + + chan_rate + samp_rate + + + audio_decim + 2 + + + deviation + max_dev + + + audio_pass + 5000 + + + audio_stop + 7000 + + + gain + 1.0 + + + tau + 75e-6 + + + _coordinate + (568, 307) + + + _rotation + 0 + + + + blks2_rational_resampler_xxx + + id + blks2_rational_resampler_xxx_0 + + + _enabled + True + + + type + fff + + + decim + 48000 + + + interp + 11025 + + + taps + [] + + + fractional_bw + 0 + + + _coordinate + (516, 522) + + + _rotation + 0 + + + + variable + + id + wav_file + + + _enabled + True + + + value + prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".wav" + + + _coordinate + (762, 652) + + + _rotation + 0 + + + + variable + + id + prefix + + + _enabled + True + + + value + "FCD_APT_REC-" + + + _coordinate + (625, 653) + + + _rotation + 0 + + + + import + + id + import_0 + + + _enabled + True + + + import + from datetime import datetime + + + _coordinate + (508, 653) + + + _rotation + 0 + + + + gr_wavfile_sink + + id + wavfile_sink + + + _enabled + True + + + file + wav_file + + + nchan + 1 + + + samp_rate + 11025 + + + bits_per_sample + 16 + + + _coordinate + (805, 530) + + + _rotation + 0 + + + + variable_chooser + + id + sat_freq + + + _enabled + True + + + label + Satellite + + + value + 137500000 + + + choices + [137500000,137620000,137912500,137100000] + + + labels + ["NOAA-15","NOAA-17","NOAA-18","NOAA-19"] + + + type + drop_down + + + style + wx.RA_HORIZONTAL + + + grid_pos + 1,0,1,1 + + + notebook + + + + _coordinate + (18, 479) + + + _rotation + 0 + + + + variable + + id + max_dev + + + _enabled + True + + + value + 17000 + + + _coordinate + (299, 10) + + + _rotation + 0 + + + + variable_chooser + + id + fcd_lna_gain + + + _enabled + True + + + label + LNA gain [dB] + + + value + 20.0 + + + choices + [30.0, 25.0, 20.0, 17.5, 15.0, 12.5, 10.0, 7.5, 5.0, 2.5, 0.0, -2.5, -5.0] + + + labels + [] + + + type + drop_down + + + style + wx.RA_HORIZONTAL + + + grid_pos + 2,0,1,1 + + + notebook + + + + _coordinate + (207, 481) + + + _rotation + 0 + + + + variable_static_text + + id + rec_info + + + _enabled + True + + + label + Recording to + + + value + wav_file + + + converver + str_converter + + + formatter + None + + + grid_pos + 1,1,1,1 + + + notebook + + + + _coordinate + (641, 14) + + + _rotation + 0 + + + + low_pass_filter + + id + low_pass_filter + + + _enabled + True + + + type + fir_filter_ccf + + + decim + 1 + + + interp + 1 + + + gain + 1 + + + samp_rate + samp_rate + + + cutoff_freq + 25000 + + + width + 5000 + + + win + firdes.WIN_HAMMING + + + beta + 6.76 + + + _coordinate + (334, 307) + + + _rotation + 0 + + + + fcd_source_c + + id + fcd_source_c_0 + + + _enabled + True + + + device_name + hw:1 + + + freq + sat_freq + + + lna + fcd_lna_gain + + + ppm + -120 + + + dci + 0.0 + + + dcq + 0.0 + + + iq_phase + 0.0 + + + iq_gain + 1.0 + + + _coordinate + (25, 299) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + fftsink + + + _enabled + True + + + type + complex + + + title + FCD Spectrum + + + samp_rate + samp_rate + + + baseband_freq + sat_freq + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 0.0 + + + ref_scale + 1.0 + + + fft_size + 512 + + + fft_rate + 15 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + win + None + + + win_size + + + + grid_pos + 0,0,1,2 + + + notebook + + + + _coordinate + (335, 103) + + + _rotation + 0 + + + + low_pass_filter + blks2_fm_demod_cf + 0 + 0 + + + blks2_fm_demod_cf + audio_sink + 0 + 0 + + + blks2_rational_resampler_xxx_0 + wavfile_sink + 0 + 0 + + + blks2_fm_demod_cf + blks2_rational_resampler_xxx_0 + 0 + 0 + + + fcd_source_c_0 + low_pass_filter + 0 + 0 + + + fcd_source_c_0 + fftsink + 0 + 0 + + diff --git a/gr-fcd/examples/grc/fcd_fft_wx.grc b/gr-fcd/examples/grc/fcd_fft_wx.grc new file mode 100644 index 000000000..c045bbfa2 --- /dev/null +++ b/gr-fcd/examples/grc/fcd_fft_wx.grc @@ -0,0 +1,320 @@ + + + Sun May 8 18:02:35 2011 + + options + + id + fcd_fft_wx + + + _enabled + True + + + title + Funcube Dongle FFT scope + + + author + Alexandru Csete OZ9AEC + + + description + + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + samp_rate + + + _enabled + True + + + value + 96000 + + + _coordinate + (201, 11) + + + _rotation + 0 + + + + variable_text_box + + id + fcd_freq + + + _enabled + True + + + label + FCD freq + + + value + 145500000 + + + converver + float_converter + + + formatter + None + + + grid_pos + 1,0,1,1 + + + notebook + + + + _coordinate + (300, 11) + + + _rotation + 0 + + + + variable_chooser + + id + fcd_lna_gain + + + _enabled + True + + + label + LNA gain [dB] + + + value + 20.0 + + + choices + [30.0, 25.0, 20.0, 17.5, 15.0, 12.5, 10.0, 7.5, 5.0, 2.5, 0.0, -2.5, -5.0] + + + labels + [] + + + type + drop_down + + + style + wx.RA_HORIZONTAL + + + grid_pos + 2,0,1,1 + + + notebook + + + + _coordinate + (446, 10) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + wxgui_fftsink2_0 + + + _enabled + True + + + type + complex + + + title + FCD Spectrum + + + samp_rate + samp_rate + + + baseband_freq + fcd_freq + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 0 + + + ref_scale + 1.0 + + + fft_size + 512 + + + fft_rate + 15 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + win + None + + + win_size + + + + grid_pos + 0,0,1,2 + + + notebook + + + + _coordinate + (442, 176) + + + _rotation + 0 + + + + fcd_source_c + + id + fcd_source_c_1 + + + _enabled + True + + + device_name + hw:1 + + + freq + fcd_freq + + + lna + fcd_lna_gain + + + ppm + -120 + + + dci + 0.0 + + + dcq + 0.0 + + + iq_phase + 0.0 + + + iq_gain + 1.0 + + + _coordinate + (95, 192) + + + _rotation + 0 + + + + fcd_source_c_1 + wxgui_fftsink2_0 + 0 + 0 + + diff --git a/gr-fcd/examples/grc/fcd_nfm_rx.grc b/gr-fcd/examples/grc/fcd_nfm_rx.grc new file mode 100644 index 000000000..9dac3fcb8 --- /dev/null +++ b/gr-fcd/examples/grc/fcd_nfm_rx.grc @@ -0,0 +1,1035 @@ + + + Sun May 8 18:05:32 2011 + + options + + id + fcd_nfm_rx + + + _enabled + True + + + title + FCD FM Receiver + + + author + OZ9AEC + + + description + Simple FM receiver using the Funcube Dongle + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable_static_text + + id + rx_freq + + + _enabled + True + + + label + Receive + + + value + freq+(offset_coarse+offset_fine) + + + converver + float_converter + + + formatter + None + + + grid_pos + 5,3,1,1 + + + notebook + + + + _coordinate + (491, 10) + + + _rotation + 0 + + + + variable_slider + + id + offset_fine + + + _enabled + True + + + label + Fine tune + + + value + 0 + + + min + -1000 + + + max + 1000 + + + num_steps + 400 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 6,0,1,2 + + + notebook + + + + _coordinate + (9, 279) + + + _rotation + 0 + + + + variable_slider + + id + offset_coarse + + + _enabled + True + + + label + Coarse tune + + + value + 0 + + + min + -48000 + + + max + 48000 + + + num_steps + 960 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 6,2,1,2 + + + notebook + + + + _coordinate + (10, 130) + + + _rotation + 0 + + + + variable_slider + + id + width + + + _enabled + True + + + label + Filter + + + value + 10000 + + + min + 2000 + + + max + 40000 + + + num_steps + 760 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 7,0,1,1 + + + notebook + + + + _coordinate + (9, 431) + + + _rotation + 0 + + + + variable_slider + + id + trans + + + _enabled + True + + + label + Trans + + + value + 1500 + + + min + 500 + + + max + 5000 + + + num_steps + 900 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 8,0,1,1 + + + notebook + + + + _coordinate + (10, 577) + + + _rotation + 0 + + + + variable_slider + + id + af_gain + + + _enabled + True + + + label + VOL + + + value + 1 + + + min + 0 + + + max + 5 + + + num_steps + 50 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 8,1,1,1 + + + notebook + + + + _coordinate + (168, 726) + + + _rotation + 0 + + + + low_pass_filter + + id + low_pass_filter + + + _enabled + True + + + type + fir_filter_ccf + + + decim + 1 + + + interp + 1 + + + gain + 1 + + + samp_rate + samp_rate + + + cutoff_freq + width/2 + + + width + trans + + + win + firdes.WIN_HAMMING + + + beta + 6.76 + + + _coordinate + (742, 258) + + + _rotation + 0 + + + + gr_simple_squelch_cc + + id + gr_simple_squelch_cc_0 + + + _enabled + True + + + threshold + sql_lev + + + alpha + 1 + + + _coordinate + (226, 499) + + + _rotation + 0 + + + + blks2_nbfm_rx + + id + nbfm_normal + + + _enabled + True + + + audio_rate + 48000 + + + quad_rate + 96000 + + + tau + 75e-6 + + + max_dev + 5e3 + + + _coordinate + (441, 483) + + + _rotation + 0 + + + + gr_multiply_const_vxx + + id + gr_multiply_const_vxx_1 + + + _enabled + True + + + type + float + + + const + af_gain + + + vlen + 1 + + + _coordinate + (674, 507) + + + _rotation + 0 + + + + audio_sink + + id + audio_sink + + + _enabled + True + + + samp_rate + 48000 + + + device_name + + + + ok_to_block + True + + + num_inputs + 2 + + + _coordinate + (882, 511) + + + _rotation + 0 + + + + variable + + id + samp_rate + + + _enabled + True + + + value + 96000 + + + _coordinate + (210, 12) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + fftsink + + + _enabled + True + + + type + complex + + + title + + + + samp_rate + samp_rate + + + baseband_freq + rx_freq*display_selector + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 0 + + + ref_scale + 1.0 + + + fft_size + 512 + + + fft_rate + 15 + + + peak_hold + False + + + average + True + + + avg_alpha + 0.5 + + + win + None + + + win_size + 800,300 + + + grid_pos + 0,0,5,4 + + + notebook + + + + _coordinate + (742, 24) + + + _rotation + 0 + + + + variable_slider + + id + sql_lev + + + _enabled + True + + + label + SQL + + + value + -100 + + + min + -100 + + + max + 0 + + + num_steps + 500 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 7,2,1,1 + + + notebook + + + + _coordinate + (328, 728) + + + _rotation + 0 + + + + variable + + id + xlate_filter_taps + + + _enabled + True + + + value + firdes.low_pass(1, samp_rate, 48000, 5000, firdes.WIN_HAMMING, 6.76) + + + _coordinate + (428, 294) + + + _rotation + 0 + + + + variable_chooser + + id + display_selector + + + _enabled + True + + + label + Spectrum + + + value + 0 + + + choices + [0, 1] + + + labels + ['Baseband','RF'] + + + type + drop_down + + + style + wx.RA_HORIZONTAL + + + grid_pos + 5,0,1,1 + + + notebook + + + + _coordinate + (481, 728) + + + _rotation + 0 + + + + variable_text_box + + id + freq + + + _enabled + True + + + label + FCD Freq + + + value + 144470000 + + + converver + float_converter + + + formatter + None + + + grid_pos + 5,1,1,1 + + + notebook + + + + _coordinate + (339, 9) + + + _rotation + 0 + + + + gr_freq_xlating_fir_filter_xxx + + id + xlating_fir_filter + + + _enabled + True + + + type + ccc + + + decim + 1 + + + taps + xlate_filter_taps + + + center_freq + -(offset_coarse+offset_fine) + + + samp_rate + samp_rate + + + _coordinate + (433, 189) + + + _rotation + 0 + + + + variable_slider + + id + rf_gain + + + _enabled + True + + + label + RF + + + value + 20 + + + min + -5 + + + max + 30 + + + num_steps + 35 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 7,1,1,1 + + + notebook + + + + _coordinate + (11, 725) + + + _rotation + 0 + + + + fcd_source_c + + id + fcd_source_c_1 + + + _enabled + True + + + device_name + hw:1 + + + freq + freq + + + lna + rf_gain + + + ppm + -120 + + + dci + 0.0 + + + dcq + 0.0 + + + iq_phase + 0.0 + + + iq_gain + 1.0 + + + _coordinate + (165, 157) + + + _rotation + 0 + + + + xlating_fir_filter + fftsink + 0 + 0 + + + xlating_fir_filter + low_pass_filter + 0 + 0 + + + low_pass_filter + gr_simple_squelch_cc_0 + 0 + 0 + + + gr_multiply_const_vxx_1 + audio_sink + 0 + 1 + + + gr_multiply_const_vxx_1 + audio_sink + 0 + 0 + + + gr_simple_squelch_cc_0 + nbfm_normal + 0 + 0 + + + nbfm_normal + gr_multiply_const_vxx_1 + 0 + 0 + + + fcd_source_c_1 + xlating_fir_filter + 0 + 0 + + diff --git a/gr-noaa/CMakeLists.txt b/gr-noaa/CMakeLists.txt index eeec1cc8c..fc10caff4 100644 --- a/gr-noaa/CMakeLists.txt +++ b/gr-noaa/CMakeLists.txt @@ -35,6 +35,8 @@ GR_SET_GLOBAL(GR_NOAA_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/lib ) +SET(GR_PKG_NOAA_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/noaa) + ######################################################################## # Begin conditional configuration ######################################################################## diff --git a/gr-noaa/examples/CMakeLists.txt b/gr-noaa/examples/CMakeLists.txt index 4e5fd83e3..6994148df 100644 --- a/gr-noaa/examples/CMakeLists.txt +++ b/gr-noaa/examples/CMakeLists.txt @@ -17,15 +17,13 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -include(GrPython) - -GR_PYTHON_INSTALL( - PROGRAMS +INSTALL( + FILES hrpt_decode.grc hrpt_demod.grc file_rx_hrpt.grc usrp_rx_hrpt.grc usrp_rx_hrpt_nogui.grc - DESTINATION ${GR_PKG_DATA_DIR}/examples/noaa + DESTINATION ${GR_PKG_NOAA_EXAMPLES_DIR} COMPONENT "noaa_python" ) diff --git a/gr-qtgui/CMakeLists.txt b/gr-qtgui/CMakeLists.txt index a8fead401..32bf5bfcb 100644 --- a/gr-qtgui/CMakeLists.txt +++ b/gr-qtgui/CMakeLists.txt @@ -57,6 +57,8 @@ GR_SET_GLOBAL(GR_QTGUI_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/lib ) +SET(GR_PKG_QTGUI_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/qt-gui) + ######################################################################## # Begin conditional configuration ######################################################################## diff --git a/gr-qtgui/examples/CMakeLists.txt b/gr-qtgui/examples/CMakeLists.txt index 30fdc5e75..4622bec29 100644 --- a/gr-qtgui/examples/CMakeLists.txt +++ b/gr-qtgui/examples/CMakeLists.txt @@ -24,6 +24,6 @@ GR_PYTHON_INSTALL(PROGRAMS pyqt_example_f.py pyqt_time_c.py pyqt_time_f.py - DESTINATION ${GR_PKG_DATA_DIR}/examples/qt-gui - COMPONENT "gnuradio_examples" + DESTINATION ${GR_PKG_QTGUI_EXAMPLES_DIR} + COMPONENT "qtgui_python" ) diff --git a/gr-trellis/CMakeLists.txt b/gr-trellis/CMakeLists.txt index dc077571c..4e0ddc4eb 100644 --- a/gr-trellis/CMakeLists.txt +++ b/gr-trellis/CMakeLists.txt @@ -37,6 +37,8 @@ GR_SET_GLOBAL(GR_TRELLIS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/lib ) +SET(GR_PKG_TRELLIS_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/trellis) + ######################################################################## # Begin conditional configuration ######################################################################## @@ -97,7 +99,8 @@ add_subdirectory(doc) if(ENABLE_PYTHON) add_subdirectory(grc) add_subdirectory(src/python) - add_subdirectory(src/examples) + add_subdirectory(src/examples/python) + add_subdirectory(src/examples/grc) endif(ENABLE_PYTHON) ######################################################################## diff --git a/gr-trellis/src/examples/CMakeLists.txt b/gr-trellis/src/examples/CMakeLists.txt deleted file mode 100644 index 0d9589908..000000000 --- a/gr-trellis/src/examples/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -include(GrPython) - -GR_PYTHON_INSTALL( - PROGRAMS - fsm_utils.py - test_tcm.py - test_tcm_parallel.py - test_tcm_combined.py - test_sccc_hard.py - test_sccc_soft.py - test_sccc_turbo.py - test_viterbi_equalization1.py - test_viterbi_equalization.py - test_turbo_equalization.py - test_turbo_equalization1.py - test_turbo_equalization2.py - DESTINATION ${GR_PKG_DATA_DIR}/examples/trellis - COMPONENT "trellis_examples" -) - -install( - FILES README - DESTINATION ${GR_PKG_DATA_DIR}/examples/trellis - COMPONENT "trellis_examples" -) - -install( - FILES - fsm_files/awgn1o2_128.fsm - fsm_files/awgn1o2_16.fsm - fsm_files/awgn1o2_4.fsm - fsm_files/awgn1o2_8.fsm - fsm_files/awgn2o3_16.fsm - fsm_files/awgn2o3_4.fsm - fsm_files/awgn2o3_4_msb.fsm - fsm_files/awgn2o3_4_msbG.fsm - fsm_files/awgn2o3_8.fsm - fsm_files/awgn2o4_4.fsm - fsm_files/disconnected.fsm - fsm_files/rep3.fsm - fsm_files/rep5.fsm - fsm_files/simple.fsm - DESTINATION ${GR_PKG_DATA_DIR}/examples/trellis/fsm_files - COMPONENT "trellis_examples" -) diff --git a/gr-trellis/src/examples/README b/gr-trellis/src/examples/README deleted file mode 100644 index bd28e3d61..000000000 --- a/gr-trellis/src/examples/README +++ /dev/null @@ -1,35 +0,0 @@ -Here we have several test programs for use with the gr-trellis implementation. -Documentation can be found in -http://gnuradio.utah.edu/svn/gnuradio/trunk/gr-trellis/doc/gr-trellis.html - -fsm_utils.py contains several useful functions. - -fsm_files is a directory with some FSM definitions - -If you just want to see what these programs do run them; -in your terminal you will see something like this: - -$ ./test_tcm.py --esn0 6.0 --repetitions 1000 -100 98 9.80e-01 102400 9 8.79e-05 -200 198 9.90e-01 204800 20 9.77e-05 -300 298 9.93e-01 307200 40 1.30e-04 -400 398 9.95e-01 409600 1074 2.62e-03 -500 498 9.96e-01 512000 1081 2.11e-03 -600 598 9.97e-01 614400 1090 1.77e-03 -700 698 9.97e-01 716800 1097 1.53e-03 -800 798 9.98e-01 819200 1107 1.35e-03 -900 898 9.98e-01 921600 1120 1.22e-03 -1000 998 9.98e-01 1024000 1129 1.10e-03 -1000 998 9.98e-01 1024000 1129 1.10e-03 - -which gives you information about the: -number of transmitted packets -number of packets in error -estimated packet error rate -number of transmitted shorts (or symbols, or bits, depending on the specific program) -number of shorts (or symbols, or bits) in error -estimated short (or symbol, or bit) error rate - -for instance, the final number 1.10e-03 is the error rate estimate by sending 1000 -packets of 1024 shorts each, using an 1/2 4-state convolutional code -and QPSK modulation through an AWGN with Es/N0 = 6.0 dB diff --git a/gr-trellis/src/examples/fsm_files/awgn1o2_128.fsm b/gr-trellis/src/examples/fsm_files/awgn1o2_128.fsm deleted file mode 100644 index bb79c59da..000000000 --- a/gr-trellis/src/examples/fsm_files/awgn1o2_128.fsm +++ /dev/null @@ -1,265 +0,0 @@ -2 128 4 - -0 64 -0 64 -1 65 -1 65 -2 66 -2 66 -3 67 -3 67 -4 68 -4 68 -5 69 -5 69 -6 70 -6 70 -7 71 -7 71 -8 72 -8 72 -9 73 -9 73 -10 74 -10 74 -11 75 -11 75 -12 76 -12 76 -13 77 -13 77 -14 78 -14 78 -15 79 -15 79 -16 80 -16 80 -17 81 -17 81 -18 82 -18 82 -19 83 -19 83 -20 84 -20 84 -21 85 -21 85 -22 86 -22 86 -23 87 -23 87 -24 88 -24 88 -25 89 -25 89 -26 90 -26 90 -27 91 -27 91 -28 92 -28 92 -29 93 -29 93 -30 94 -30 94 -31 95 -31 95 -32 96 -32 96 -33 97 -33 97 -34 98 -34 98 -35 99 -35 99 -36 100 -36 100 -37 101 -37 101 -38 102 -38 102 -39 103 -39 103 -40 104 -40 104 -41 105 -41 105 -42 106 -42 106 -43 107 -43 107 -44 108 -44 108 -45 109 -45 109 -46 110 -46 110 -47 111 -47 111 -48 112 -48 112 -49 113 -49 113 -50 114 -50 114 -51 115 -51 115 -52 116 -52 116 -53 117 -53 117 -54 118 -54 118 -55 119 -55 119 -56 120 -56 120 -57 121 -57 121 -58 122 -58 122 -59 123 -59 123 -60 124 -60 124 -61 125 -61 125 -62 126 -62 126 -63 127 -63 127 - -0 3 -3 0 -1 2 -2 1 -3 0 -0 3 -2 1 -1 2 -1 2 -2 1 -0 3 -3 0 -2 1 -1 2 -3 0 -0 3 -1 2 -2 1 -0 3 -3 0 -2 1 -1 2 -3 0 -0 3 -0 3 -3 0 -1 2 -2 1 -3 0 -0 3 -2 1 -1 2 -2 1 -1 2 -3 0 -0 3 -1 2 -2 1 -0 3 -3 0 -3 0 -0 3 -2 1 -1 2 -0 3 -3 0 -1 2 -2 1 -3 0 -0 3 -2 1 -1 2 -0 3 -3 0 -1 2 -2 1 -2 1 -1 2 -3 0 -0 3 -1 2 -2 1 -0 3 -3 0 -2 1 -1 2 -3 0 -0 3 -1 2 -2 1 -0 3 -3 0 -3 0 -0 3 -2 1 -1 2 -0 3 -3 0 -1 2 -2 1 -3 0 -0 3 -2 1 -1 2 -0 3 -3 0 -1 2 -2 1 -2 1 -1 2 -3 0 -0 3 -1 2 -2 1 -0 3 -3 0 -0 3 -3 0 -1 2 -2 1 -3 0 -0 3 -2 1 -1 2 -1 2 -2 1 -0 3 -3 0 -2 1 -1 2 -3 0 -0 3 -1 2 -2 1 -0 3 -3 0 -2 1 -1 2 -3 0 -0 3 -0 3 -3 0 -1 2 -2 1 -3 0 -0 3 -2 1 -1 2 - - - -GM1o2_128=[1+D+D^2+D^5+D^7 1+D^3+D^4+D^5+D^6+D^7] - =[11100101 10011111] - =[229 159] diff --git a/gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm b/gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm deleted file mode 100644 index cdab41359..000000000 --- a/gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm +++ /dev/null @@ -1,39 +0,0 @@ -2 16 4 - -0 8 -0 8 -1 9 -1 9 -2 10 -2 10 -3 11 -3 11 -4 12 -4 12 -5 13 -5 13 -6 14 -6 14 -7 15 -7 15 - -0 3 -3 0 -1 2 -2 1 -1 2 -2 1 -0 3 -3 0 -2 1 -1 2 -3 0 -0 3 -3 0 -0 3 -2 1 -1 2 - - - -GM1o2_16=[1+D+D^4 1+D^2+D^3+D^4 ] = [25,23] (decimal) diff --git a/gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm b/gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm deleted file mode 100644 index fb316b5ef..000000000 --- a/gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm +++ /dev/null @@ -1,14 +0,0 @@ -2 4 4 - -0 2 -0 2 -1 3 -1 3 - -0 3 -3 0 -1 2 -2 1 - -AWGN CC from Proakis-Salehi pg 779 -GM1o2_4=[1+D^2, 1+D+D^2] = [5, 7] (in decimal); diff --git a/gr-trellis/src/examples/fsm_files/awgn1o2_8.fsm b/gr-trellis/src/examples/fsm_files/awgn1o2_8.fsm deleted file mode 100644 index 604bac6c2..000000000 --- a/gr-trellis/src/examples/fsm_files/awgn1o2_8.fsm +++ /dev/null @@ -1,24 +0,0 @@ -2 8 4 - -0 4 -0 4 -1 5 -1 5 -2 6 -2 6 -3 7 -3 7 - - -0 3 -3 0 -1 2 -2 1 -3 0 -0 3 -2 1 -1 2 - - -1/2 8-state code (Proakis pg. 493) -GM1o2_8=[ 1+D+D^3 1+D+D^2+D^3] =[13 , 15] (decimal) diff --git a/gr-trellis/src/examples/fsm_files/awgn2o3_16.fsm b/gr-trellis/src/examples/fsm_files/awgn2o3_16.fsm deleted file mode 100644 index 9630cd9af..000000000 --- a/gr-trellis/src/examples/fsm_files/awgn2o3_16.fsm +++ /dev/null @@ -1,40 +0,0 @@ -4 16 8 - -0 8 4 12 -0 8 4 12 -0 8 4 12 -0 8 4 12 -1 9 5 13 -1 9 5 13 -1 9 5 13 -1 9 5 13 -2 10 6 14 -2 10 6 14 -2 10 6 14 -2 10 6 14 -3 11 7 15 -3 11 7 15 -3 11 7 15 -3 11 7 15 - -0 1 7 6 -6 7 1 0 -3 2 4 5 -5 4 2 3 -2 3 5 4 -4 5 3 2 -1 0 6 7 -7 6 0 1 -4 5 3 2 -2 3 5 4 -7 6 0 1 -1 0 6 7 -6 7 1 0 -0 1 7 6 -5 4 2 3 -3 2 4 5 - - -2/3 code generated from the awgn 1/2 code with 16 states and puncturing the 4th bit. -d_free= - diff --git a/gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm b/gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm deleted file mode 100644 index 3ac57be18..000000000 --- a/gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm +++ /dev/null @@ -1,15 +0,0 @@ -4 4 8 - -0 1 2 3 -0 1 2 3 -0 1 2 3 -0 1 2 3 - -0 7 4 3 -3 4 7 0 -5 2 1 6 -6 1 2 5 - -I don't remeber how I generated this one... -it is a bit better than awgn2o3_4_msb and worse -than awgn2o3_4_msbG. diff --git a/gr-trellis/src/examples/fsm_files/awgn2o3_4_msb.fsm b/gr-trellis/src/examples/fsm_files/awgn2o3_4_msb.fsm deleted file mode 100644 index 551b71101..000000000 --- a/gr-trellis/src/examples/fsm_files/awgn2o3_4_msb.fsm +++ /dev/null @@ -1,46 +0,0 @@ -4 4 8 - -0 1 2 3 -0 1 2 3 -0 1 2 3 -0 1 2 3 - -0 5 3 6 -4 1 7 2 -7 2 4 1 -3 6 0 5 - - -This is generated by the 1/2 AWGN code (5 7) operated twice, ie, -(xk+1 xki) [xk-1 xk-2] -> [xk+1 xki]. -We also puncture the first (MSB) bit. -This code is worse than awgn2o3_4_msbG and slightly worse than -awgn2o3_4, BUT seems to be a good innner code for sctcm (with 8PSK natural). - -intermediate states: - -00 21 02 23 -00 21 02 23 -10 31 12 33 -10 31 12 33 - -output before puncturing: - -00 31 03 32 -30 01 33 02 -13 22 10 21 -23 12 20 11 - -output after punturing the MSB: - -00 11 03 12 -10 01 13 02 -13 02 10 01 -03 12 00 11 - -and in decimal: - -0 5 3 6 -4 1 7 2 -7 2 4 1 -3 6 0 5 diff --git a/gr-trellis/src/examples/fsm_files/awgn2o3_4_msbG.fsm b/gr-trellis/src/examples/fsm_files/awgn2o3_4_msbG.fsm deleted file mode 100644 index 8956c53da..000000000 --- a/gr-trellis/src/examples/fsm_files/awgn2o3_4_msbG.fsm +++ /dev/null @@ -1,60 +0,0 @@ -4 4 8 - -0 1 2 3 -0 1 2 3 -0 1 2 3 -0 1 2 3 - -0 4 2 6 -5 1 3 7 -3 7 5 1 - - -This is generated by the 1/2 AWGN code (5 7) operated twice, ie, -(xk+1 xki) [xk-1 xk-2] -> [xk+1 xki]. -We also puncture the first (MSB) bit and Gray map the symbols. - -intermediate states: - -00 21 02 23 -00 21 02 23 -10 31 12 33 -10 31 12 33 - -output before puncturing: - -00 31 03 32 -30 01 33 02 -13 22 10 21 -23 12 20 11 - -output after punturing the MSB: - -00 11 03 12 -10 01 13 02 -13 02 10 01 -03 12 00 11 - -and in decimal: - -0 5 3 6 -4 1 7 2 -7 2 4 1 -3 6 0 5 - -After Gray mapping: -label -> phase -0 -> 0 -1 -> 0 -2 -> 7 -3 -> 2 -4 -> 5 -5 -> 4 -6 -> 6 -7 -> 3 - -0 4 2 6 -5 1 3 7 -3 7 5 1 -2 6 0 4 - diff --git a/gr-trellis/src/examples/fsm_files/awgn2o3_8.fsm b/gr-trellis/src/examples/fsm_files/awgn2o3_8.fsm deleted file mode 100644 index 34deeb68c..000000000 --- a/gr-trellis/src/examples/fsm_files/awgn2o3_8.fsm +++ /dev/null @@ -1,25 +0,0 @@ -4 8 8 - -0 4 2 6 -0 4 2 6 -0 4 2 6 -0 4 2 6 -1 5 3 7 -1 5 3 7 -1 5 3 7 -1 5 3 7 - - -0 1 7 6 -6 7 1 0 -3 2 4 5 -5 4 2 3 -6 7 1 0 -0 1 7 6 -5 4 2 3 -3 2 4 5 - - - -This is generated by the 1/2 8-state AWGN code (15 17) by puncturing the fourth bit. ---> d_free=??? diff --git a/gr-trellis/src/examples/fsm_files/awgn2o4_4.fsm b/gr-trellis/src/examples/fsm_files/awgn2o4_4.fsm deleted file mode 100644 index a895be896..000000000 --- a/gr-trellis/src/examples/fsm_files/awgn2o4_4.fsm +++ /dev/null @@ -1,36 +0,0 @@ -4 4 16 - -0 1 2 3 -0 1 2 3 -0 1 2 3 -0 1 2 3 - - 0 13 3 14 -12 1 15 2 - 7 10 4 9 -11 6 8 5 - - -This is generated by the 1/2 AWGN code (5 7) operated twice, ie, -(xk+1 xki) [xk-1 xk-2] -> [xk+1 xki]. - -intermediate states: - -00 21 02 23 -00 21 02 23 -10 31 12 33 -10 31 12 33 - -output: - -00 31 03 32 -30 01 33 02 -13 22 10 21 -23 12 20 11 - -and in decimal: - - 0 13 3 14 -12 1 15 2 - 7 10 4 9 -11 6 8 5 diff --git a/gr-trellis/src/examples/fsm_files/disconnected.fsm b/gr-trellis/src/examples/fsm_files/disconnected.fsm deleted file mode 100644 index 847963e7b..000000000 --- a/gr-trellis/src/examples/fsm_files/disconnected.fsm +++ /dev/null @@ -1,11 +0,0 @@ -1 4 1 - -1 -0 -3 -2 - -0 -0 -0 -0 diff --git a/gr-trellis/src/examples/fsm_files/irregular.fsm b/gr-trellis/src/examples/fsm_files/irregular.fsm deleted file mode 100644 index 80b82b889..000000000 --- a/gr-trellis/src/examples/fsm_files/irregular.fsm +++ /dev/null @@ -1,11 +0,0 @@ -2 2 2 - -0 0 -0 1 - -0 1 -0 1 - - -useless irregular FSM for testing. state 0 has 3 incoming edges and state -1 has 1 incoming edge. diff --git a/gr-trellis/src/examples/fsm_files/joint_16_16.fsm b/gr-trellis/src/examples/fsm_files/joint_16_16.fsm deleted file mode 100644 index 3dae314b6..000000000 --- a/gr-trellis/src/examples/fsm_files/joint_16_16.fsm +++ /dev/null @@ -1,523 +0,0 @@ -4 256 16 - -0 8 128 136 -0 8 128 136 -1 9 129 137 -1 9 129 137 -2 10 130 138 -2 10 130 138 -3 11 131 139 -3 11 131 139 -4 12 132 140 -4 12 132 140 -5 13 133 141 -5 13 133 141 -6 14 134 142 -6 14 134 142 -7 15 135 143 -7 15 135 143 -0 8 128 136 -0 8 128 136 -1 9 129 137 -1 9 129 137 -2 10 130 138 -2 10 130 138 -3 11 131 139 -3 11 131 139 -4 12 132 140 -4 12 132 140 -5 13 133 141 -5 13 133 141 -6 14 134 142 -6 14 134 142 -7 15 135 143 -7 15 135 143 -16 24 144 152 -16 24 144 152 -17 25 145 153 -17 25 145 153 -18 26 146 154 -18 26 146 154 -19 27 147 155 -19 27 147 155 -20 28 148 156 -20 28 148 156 -21 29 149 157 -21 29 149 157 -22 30 150 158 -22 30 150 158 -23 31 151 159 -23 31 151 159 -16 24 144 152 -16 24 144 152 -17 25 145 153 -17 25 145 153 -18 26 146 154 -18 26 146 154 -19 27 147 155 -19 27 147 155 -20 28 148 156 -20 28 148 156 -21 29 149 157 -21 29 149 157 -22 30 150 158 -22 30 150 158 -23 31 151 159 -23 31 151 159 -32 40 160 168 -32 40 160 168 -33 41 161 169 -33 41 161 169 -34 42 162 170 -34 42 162 170 -35 43 163 171 -35 43 163 171 -36 44 164 172 -36 44 164 172 -37 45 165 173 -37 45 165 173 -38 46 166 174 -38 46 166 174 -39 47 167 175 -39 47 167 175 -32 40 160 168 -32 40 160 168 -33 41 161 169 -33 41 161 169 -34 42 162 170 -34 42 162 170 -35 43 163 171 -35 43 163 171 -36 44 164 172 -36 44 164 172 -37 45 165 173 -37 45 165 173 -38 46 166 174 -38 46 166 174 -39 47 167 175 -39 47 167 175 -48 56 176 184 -48 56 176 184 -49 57 177 185 -49 57 177 185 -50 58 178 186 -50 58 178 186 -51 59 179 187 -51 59 179 187 -52 60 180 188 -52 60 180 188 -53 61 181 189 -53 61 181 189 -54 62 182 190 -54 62 182 190 -55 63 183 191 -55 63 183 191 -48 56 176 184 -48 56 176 184 -49 57 177 185 -49 57 177 185 -50 58 178 186 -50 58 178 186 -51 59 179 187 -51 59 179 187 -52 60 180 188 -52 60 180 188 -53 61 181 189 -53 61 181 189 -54 62 182 190 -54 62 182 190 -55 63 183 191 -55 63 183 191 -64 72 192 200 -64 72 192 200 -65 73 193 201 -65 73 193 201 -66 74 194 202 -66 74 194 202 -67 75 195 203 -67 75 195 203 -68 76 196 204 -68 76 196 204 -69 77 197 205 -69 77 197 205 -70 78 198 206 -70 78 198 206 -71 79 199 207 -71 79 199 207 -64 72 192 200 -64 72 192 200 -65 73 193 201 -65 73 193 201 -66 74 194 202 -66 74 194 202 -67 75 195 203 -67 75 195 203 -68 76 196 204 -68 76 196 204 -69 77 197 205 -69 77 197 205 -70 78 198 206 -70 78 198 206 -71 79 199 207 -71 79 199 207 -80 88 208 216 -80 88 208 216 -81 89 209 217 -81 89 209 217 -82 90 210 218 -82 90 210 218 -83 91 211 219 -83 91 211 219 -84 92 212 220 -84 92 212 220 -85 93 213 221 -85 93 213 221 -86 94 214 222 -86 94 214 222 -87 95 215 223 -87 95 215 223 -80 88 208 216 -80 88 208 216 -81 89 209 217 -81 89 209 217 -82 90 210 218 -82 90 210 218 -83 91 211 219 -83 91 211 219 -84 92 212 220 -84 92 212 220 -85 93 213 221 -85 93 213 221 -86 94 214 222 -86 94 214 222 -87 95 215 223 -87 95 215 223 -96 104 224 232 -96 104 224 232 -97 105 225 233 -97 105 225 233 -98 106 226 234 -98 106 226 234 -99 107 227 235 -99 107 227 235 -100 108 228 236 -100 108 228 236 -101 109 229 237 -101 109 229 237 -102 110 230 238 -102 110 230 238 -103 111 231 239 -103 111 231 239 -96 104 224 232 -96 104 224 232 -97 105 225 233 -97 105 225 233 -98 106 226 234 -98 106 226 234 -99 107 227 235 -99 107 227 235 -100 108 228 236 -100 108 228 236 -101 109 229 237 -101 109 229 237 -102 110 230 238 -102 110 230 238 -103 111 231 239 -103 111 231 239 -112 120 240 248 -112 120 240 248 -113 121 241 249 -113 121 241 249 -114 122 242 250 -114 122 242 250 -115 123 243 251 -115 123 243 251 -116 124 244 252 -116 124 244 252 -117 125 245 253 -117 125 245 253 -118 126 246 254 -118 126 246 254 -119 127 247 255 -119 127 247 255 -112 120 240 248 -112 120 240 248 -113 121 241 249 -113 121 241 249 -114 122 242 250 -114 122 242 250 -115 123 243 251 -115 123 243 251 -116 124 244 252 -116 124 244 252 -117 125 245 253 -117 125 245 253 -118 126 246 254 -118 126 246 254 -119 127 247 255 -119 127 247 255 - -0 3 12 15 -3 0 15 12 -1 2 13 14 -2 1 14 13 -1 2 13 14 -2 1 14 13 -0 3 12 15 -3 0 15 12 -2 1 14 13 -1 2 13 14 -3 0 15 12 -0 3 12 15 -3 0 15 12 -0 3 12 15 -2 1 14 13 -1 2 13 14 -12 15 0 3 -15 12 3 0 -13 14 1 2 -14 13 2 1 -13 14 1 2 -14 13 2 1 -12 15 0 3 -15 12 3 0 -14 13 2 1 -13 14 1 2 -15 12 3 0 -12 15 0 3 -15 12 3 0 -12 15 0 3 -14 13 2 1 -13 14 1 2 -4 7 8 11 -7 4 11 8 -5 6 9 10 -6 5 10 9 -5 6 9 10 -6 5 10 9 -4 7 8 11 -7 4 11 8 -6 5 10 9 -5 6 9 10 -7 4 11 8 -4 7 8 11 -7 4 11 8 -4 7 8 11 -6 5 10 9 -5 6 9 10 -8 11 4 7 -11 8 7 4 -9 10 5 6 -10 9 6 5 -9 10 5 6 -10 9 6 5 -8 11 4 7 -11 8 7 4 -10 9 6 5 -9 10 5 6 -11 8 7 4 -8 11 4 7 -11 8 7 4 -8 11 4 7 -10 9 6 5 -9 10 5 6 -4 7 8 11 -7 4 11 8 -5 6 9 10 -6 5 10 9 -5 6 9 10 -6 5 10 9 -4 7 8 11 -7 4 11 8 -6 5 10 9 -5 6 9 10 -7 4 11 8 -4 7 8 11 -7 4 11 8 -4 7 8 11 -6 5 10 9 -5 6 9 10 -8 11 4 7 -11 8 7 4 -9 10 5 6 -10 9 6 5 -9 10 5 6 -10 9 6 5 -8 11 4 7 -11 8 7 4 -10 9 6 5 -9 10 5 6 -11 8 7 4 -8 11 4 7 -11 8 7 4 -8 11 4 7 -10 9 6 5 -9 10 5 6 -0 3 12 15 -3 0 15 12 -1 2 13 14 -2 1 14 13 -1 2 13 14 -2 1 14 13 -0 3 12 15 -3 0 15 12 -2 1 14 13 -1 2 13 14 -3 0 15 12 -0 3 12 15 -3 0 15 12 -0 3 12 15 -2 1 14 13 -1 2 13 14 -12 15 0 3 -15 12 3 0 -13 14 1 2 -14 13 2 1 -13 14 1 2 -14 13 2 1 -12 15 0 3 -15 12 3 0 -14 13 2 1 -13 14 1 2 -15 12 3 0 -12 15 0 3 -15 12 3 0 -12 15 0 3 -14 13 2 1 -13 14 1 2 -8 11 4 7 -11 8 7 4 -9 10 5 6 -10 9 6 5 -9 10 5 6 -10 9 6 5 -8 11 4 7 -11 8 7 4 -10 9 6 5 -9 10 5 6 -11 8 7 4 -8 11 4 7 -11 8 7 4 -8 11 4 7 -10 9 6 5 -9 10 5 6 -4 7 8 11 -7 4 11 8 -5 6 9 10 -6 5 10 9 -5 6 9 10 -6 5 10 9 -4 7 8 11 -7 4 11 8 -6 5 10 9 -5 6 9 10 -7 4 11 8 -4 7 8 11 -7 4 11 8 -4 7 8 11 -6 5 10 9 -5 6 9 10 -12 15 0 3 -15 12 3 0 -13 14 1 2 -14 13 2 1 -13 14 1 2 -14 13 2 1 -12 15 0 3 -15 12 3 0 -14 13 2 1 -13 14 1 2 -15 12 3 0 -12 15 0 3 -15 12 3 0 -12 15 0 3 -14 13 2 1 -13 14 1 2 -0 3 12 15 -3 0 15 12 -1 2 13 14 -2 1 14 13 -1 2 13 14 -2 1 14 13 -0 3 12 15 -3 0 15 12 -2 1 14 13 -1 2 13 14 -3 0 15 12 -0 3 12 15 -3 0 15 12 -0 3 12 15 -2 1 14 13 -1 2 13 14 -12 15 0 3 -15 12 3 0 -13 14 1 2 -14 13 2 1 -13 14 1 2 -14 13 2 1 -12 15 0 3 -15 12 3 0 -14 13 2 1 -13 14 1 2 -15 12 3 0 -12 15 0 3 -15 12 3 0 -12 15 0 3 -14 13 2 1 -13 14 1 2 -0 3 12 15 -3 0 15 12 -1 2 13 14 -2 1 14 13 -1 2 13 14 -2 1 14 13 -0 3 12 15 -3 0 15 12 -2 1 14 13 -1 2 13 14 -3 0 15 12 -0 3 12 15 -3 0 15 12 -0 3 12 15 -2 1 14 13 -1 2 13 14 -8 11 4 7 -11 8 7 4 -9 10 5 6 -10 9 6 5 -9 10 5 6 -10 9 6 5 -8 11 4 7 -11 8 7 4 -10 9 6 5 -9 10 5 6 -11 8 7 4 -8 11 4 7 -11 8 7 4 -8 11 4 7 -10 9 6 5 -9 10 5 6 -4 7 8 11 -7 4 11 8 -5 6 9 10 -6 5 10 9 -5 6 9 10 -6 5 10 9 -4 7 8 11 -7 4 11 8 -6 5 10 9 -5 6 9 10 -7 4 11 8 -4 7 8 11 -7 4 11 8 -4 7 8 11 -6 5 10 9 -5 6 9 10 - -This is the joint trellis of two trellises described in awgn1o2_16.fsm -It is useful for application of joint decoding... -It can be generated in python as follows: -> import trellis -> f1=trellis.fsm('awgn1o2_16.fsm') -> f=trellis.fsm(f1,f1) -> f.write_fsm_txt('joint_16_16.fsm') diff --git a/gr-trellis/src/examples/fsm_files/joint_4_16.fsm b/gr-trellis/src/examples/fsm_files/joint_4_16.fsm deleted file mode 100644 index 8f2cdab81..000000000 --- a/gr-trellis/src/examples/fsm_files/joint_4_16.fsm +++ /dev/null @@ -1,141 +0,0 @@ -4 64 16 - -0 8 32 40 -0 8 32 40 -1 9 33 41 -1 9 33 41 -2 10 34 42 -2 10 34 42 -3 11 35 43 -3 11 35 43 -4 12 36 44 -4 12 36 44 -5 13 37 45 -5 13 37 45 -6 14 38 46 -6 14 38 46 -7 15 39 47 -7 15 39 47 -0 8 32 40 -0 8 32 40 -1 9 33 41 -1 9 33 41 -2 10 34 42 -2 10 34 42 -3 11 35 43 -3 11 35 43 -4 12 36 44 -4 12 36 44 -5 13 37 45 -5 13 37 45 -6 14 38 46 -6 14 38 46 -7 15 39 47 -7 15 39 47 -16 24 48 56 -16 24 48 56 -17 25 49 57 -17 25 49 57 -18 26 50 58 -18 26 50 58 -19 27 51 59 -19 27 51 59 -20 28 52 60 -20 28 52 60 -21 29 53 61 -21 29 53 61 -22 30 54 62 -22 30 54 62 -23 31 55 63 -23 31 55 63 -16 24 48 56 -16 24 48 56 -17 25 49 57 -17 25 49 57 -18 26 50 58 -18 26 50 58 -19 27 51 59 -19 27 51 59 -20 28 52 60 -20 28 52 60 -21 29 53 61 -21 29 53 61 -22 30 54 62 -22 30 54 62 -23 31 55 63 -23 31 55 63 - -0 3 12 15 -3 0 15 12 -1 2 13 14 -2 1 14 13 -1 2 13 14 -2 1 14 13 -0 3 12 15 -3 0 15 12 -2 1 14 13 -1 2 13 14 -3 0 15 12 -0 3 12 15 -3 0 15 12 -0 3 12 15 -2 1 14 13 -1 2 13 14 -12 15 0 3 -15 12 3 0 -13 14 1 2 -14 13 2 1 -13 14 1 2 -14 13 2 1 -12 15 0 3 -15 12 3 0 -14 13 2 1 -13 14 1 2 -15 12 3 0 -12 15 0 3 -15 12 3 0 -12 15 0 3 -14 13 2 1 -13 14 1 2 -4 7 8 11 -7 4 11 8 -5 6 9 10 -6 5 10 9 -5 6 9 10 -6 5 10 9 -4 7 8 11 -7 4 11 8 -6 5 10 9 -5 6 9 10 -7 4 11 8 -4 7 8 11 -7 4 11 8 -4 7 8 11 -6 5 10 9 -5 6 9 10 -8 11 4 7 -11 8 7 4 -9 10 5 6 -10 9 6 5 -9 10 5 6 -10 9 6 5 -8 11 4 7 -11 8 7 4 -10 9 6 5 -9 10 5 6 -11 8 7 4 -8 11 4 7 -11 8 7 4 -8 11 4 7 -10 9 6 5 -9 10 5 6 - -This is the joint trellis of two trellises described in awgn1o2_4.fsm and awgn1o2_16.fsm -It is useful for application of joint decoding... -It can be generated in python as follows: -> import trellis -> f1=trellis.fsm('awgn1o2_4.fsm') -> f2=trellis.fsm('awgn1o2_16.fsm') -> f=trellis.fsm(f1,f2) -> f.write_fsm_txt('joint_4_16.fsm') - diff --git a/gr-trellis/src/examples/fsm_files/rep3.fsm b/gr-trellis/src/examples/fsm_files/rep3.fsm deleted file mode 100644 index ef1bd1f02..000000000 --- a/gr-trellis/src/examples/fsm_files/rep3.fsm +++ /dev/null @@ -1,8 +0,0 @@ -2 1 8 - -0 0 - -0 7 - -1/3 repetition code (with binary input). -There is only one state, since this is essentially a memoryless system. diff --git a/gr-trellis/src/examples/fsm_files/rep5.fsm b/gr-trellis/src/examples/fsm_files/rep5.fsm deleted file mode 100644 index 2aa5d77cf..000000000 --- a/gr-trellis/src/examples/fsm_files/rep5.fsm +++ /dev/null @@ -1,7 +0,0 @@ -2 1 32 - -0 0 - -0 31 - -1/5 repetition code diff --git a/gr-trellis/src/examples/fsm_files/simple.fsm b/gr-trellis/src/examples/fsm_files/simple.fsm deleted file mode 100644 index f27f6b4b0..000000000 --- a/gr-trellis/src/examples/fsm_files/simple.fsm +++ /dev/null @@ -1,13 +0,0 @@ -1 4 1 - -1 -2 -3 -0 - -0 -0 -0 -0 - -essentially this fsm has no inputs and no outputs; it just cycles through all 4 states. diff --git a/gr-trellis/src/examples/fsm_utils.py b/gr-trellis/src/examples/fsm_utils.py deleted file mode 100755 index e9243f899..000000000 --- a/gr-trellis/src/examples/fsm_utils.py +++ /dev/null @@ -1,239 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - - -import re -import math -import sys -import operator -import numpy - -from gnuradio import trellis - -try: - import scipy.linalg -except ImportError: - print "Error: Program requires scipy (see: www.scipy.org)." - sys.exit(1) - - - -###################################################################### -# Decimal to any base conversion. -# Convert 'num' to a list of 'l' numbers representing 'num' -# to base 'base' (most significant symbol first). -###################################################################### -def dec2base(num,base,l): - s=range(l) - n=num - for i in range(l): - s[l-i-1]=n%base - n=int(n/base) - if n!=0: - print 'Number ', num, ' requires more than ', l, 'digits.' - return s - - -###################################################################### -# Conversion from any base to decimal. -# Convert a list 's' of symbols to a decimal number -# (most significant symbol first) -###################################################################### -def base2dec(s,base): - num=0 - for i in range(len(s)): - num=num*base+s[i] - return num - - - - -###################################################################### -# Automatically generate the lookup table that maps the FSM outputs -# to channel inputs corresponding to a channel 'channel' and a modulation -# 'mod'. Optional normalization of channel to unit energy. -# This table is used by the 'metrics' block to translate -# channel outputs to metrics for use with the Viterbi algorithm. -# Limitations: currently supports only one-dimensional modulations. -###################################################################### -def make_isi_lookup(mod,channel,normalize): - dim=mod[0] - constellation = mod[1] - - if normalize: - p = 0 - for i in range(len(channel)): - p = p + channel[i]**2 - for i in range(len(channel)): - channel[i] = channel[i]/math.sqrt(p) - - lookup=range(len(constellation)**len(channel)) - for o in range(len(constellation)**len(channel)): - ss=dec2base(o,len(constellation),len(channel)) - ll=0 - for i in range(len(channel)): - ll=ll+constellation[ss[i]]*channel[i] - lookup[o]=ll - return (1,lookup) - - - - - - -###################################################################### -# Automatically generate the signals appropriate for CPM -# decomposition. -# This decomposition is based on the paper by B. Rimoldi -# "A decomposition approach to CPM", IEEE Trans. Info Theory, March 1988 -# See also my own notes at http://www.eecs.umich.edu/~anastas/docs/cpm.pdf -###################################################################### -def make_cpm_signals(K,P,M,L,q,frac): - - Q=numpy.size(q)/L - h=(1.0*K)/P - f0=-h*(M-1)/2 - dt=0.0; # maybe start at t=0.5 - t=(dt+numpy.arange(0,Q))/Q - qq=numpy.zeros(Q) - for m in range(L): - qq=qq + q[m*Q:m*Q+Q] - w=math.pi*h*(M-1)*t-2*math.pi*h*(M-1)*qq+math.pi*h*(L-1)*(M-1) - - X=(M**L)*P - PSI=numpy.empty((X,Q)) - for x in range(X): - xv=dec2base(x/P,M,L) - xv=numpy.append(xv, x%P) - qq1=numpy.zeros(Q) - for m in range(L): - qq1=qq1+xv[m]*q[m*Q:m*Q+Q] - psi=2*math.pi*h*xv[-1]+4*math.pi*h*qq1+w - #print psi - PSI[x]=psi - PSI = numpy.transpose(PSI) - SS=numpy.exp(1j*PSI) # contains all signals as columns - #print SS - - - # Now we need to orthogonalize the signals - F = scipy.linalg.orth(SS) # find an orthonormal basis for SS - #print numpy.dot(numpy.transpose(F.conjugate()),F) # check for orthonormality - S = numpy.dot(numpy.transpose(F.conjugate()),SS) - #print F - #print S - - # We only want to keep those dimensions that contain most - # of the energy of the overall constellation (eg, frac=0.9 ==> 90%) - # evaluate mean energy in each dimension - E=numpy.sum(numpy.absolute(S)**2,axis=1)/Q - E=E/numpy.sum(E) - #print E - Es = -numpy.sort(-E) - Esi = numpy.argsort(-E) - #print Es - #print Esi - Ecum=numpy.cumsum(Es) - #print Ecum - v0=numpy.searchsorted(Ecum,frac) - N = v0+1 - #print v0 - #print Esi[0:v0+1] - Ff=numpy.transpose(numpy.transpose(F)[Esi[0:v0+1]]) - #print Ff - Sf = S[Esi[0:v0+1]] - #print Sf - - - return (f0,SS,S,F,Sf,Ff,N) - #return f0 - - - - -###################################################################### -# A list of common modulations. -# Format: (dimensionality,constellation) -###################################################################### -pam2 = (1,[-1, 1]) -pam4 = (1,[-3, -1, 3, 1]) # includes Gray mapping -pam8 = (1,[-7, -5, -3, -1, 1, 3, 5, 7]) - -psk4=(2,[1, 0, \ - 0, 1, \ - 0, -1,\ - -1, 0]) # includes Gray mapping -psk8=(2,[math.cos(2*math.pi*0/8), math.sin(2*math.pi*0/8), \ - math.cos(2*math.pi*1/8), math.sin(2*math.pi*1/8), \ - math.cos(2*math.pi*2/8), math.sin(2*math.pi*2/8), \ - math.cos(2*math.pi*3/8), math.sin(2*math.pi*3/8), \ - math.cos(2*math.pi*4/8), math.sin(2*math.pi*4/8), \ - math.cos(2*math.pi*5/8), math.sin(2*math.pi*5/8), \ - math.cos(2*math.pi*6/8), math.sin(2*math.pi*6/8), \ - math.cos(2*math.pi*7/8), math.sin(2*math.pi*7/8)]) - -orth2 = (2,[1, 0, \ - 0, 1]) -orth4=(4,[1, 0, 0, 0, \ - 0, 1, 0, 0, \ - 0, 0, 1, 0, \ - 0, 0, 0, 1]) - -###################################################################### -# A list of channels to be tested -###################################################################### - -# C test channel (J. Proakis, Digital Communications, McGraw-Hill Inc., 2001) -c_channel = [0.227, 0.460, 0.688, 0.460, 0.227] - - - - - - - - - - -if __name__ == '__main__': - f1=trellis.fsm('fsm_files/awgn1o2_4.fsm') - #f2=trellis.fsm('fsm_files/awgn2o3_4.fsm') - #print f1.I(), f1.S(), f1.O() - #print f1.NS() - #print f1.OS() - #print f2.I(), f2.S(), f2.O() - #print f2.NS() - #print f2.OS() - ##f1.write_trellis_svg('f1.svg',4) - #f2.write_trellis_svg('f2.svg',4) - #f=fsm_concatenate(f1,f2) - #f=fsm_radix(f1,2) - - #print "----------\n" - #print f.I(), f.S(), f.O() - #print f.NS() - #print f.OS() - #f.write_trellis_svg('f.svg',4) - - q=numpy.arange(0,8)/(2.0*8) - (f0,SS,S,F,Sf,Ff,N) = make_cpm_signals(1,2,2,1,q,0.99) - diff --git a/gr-trellis/src/examples/grc/CMakeLists.txt b/gr-trellis/src/examples/grc/CMakeLists.txt new file mode 100644 index 000000000..51197a9f4 --- /dev/null +++ b/gr-trellis/src/examples/grc/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +install( + FILES + interference_cancellation.grc + pccc1.grc + pccc.grc + sccc1.grc + sccc.grc + readme.txt + DESTINATION ${GR_PKG_TRELLIS_EXAMPLES_DIR} + COMPONENT "trellis-examples" +) diff --git a/gr-trellis/src/examples/grc/interference_cancellation.grc b/gr-trellis/src/examples/grc/interference_cancellation.grc new file mode 100644 index 000000000..7674b4bf1 --- /dev/null +++ b/gr-trellis/src/examples/grc/interference_cancellation.grc @@ -0,0 +1,2177 @@ + + + Wed Aug 31 17:40:25 2011 + + options + + id + int_cancellation + + + _enabled + True + + + title + Superposition Coding + + + author + AA + + + description + gnuradio flow graph + + + window_size + 2048, 2048 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable_slider + + id + alpha + + + _enabled + True + + + label + P1/P + + + value + 0.6 + + + min + 0 + + + max + 1.0 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (243, 11) + + + _rotation + 0 + + + + variable_slider + + id + snr_db + + + _enabled + True + + + label + P/sigma^2 (dB) + + + value + 16 + + + min + 0 + + + max + 20 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (447, 14) + + + _rotation + 0 + + + + variable + + id + noisevar + + + _enabled + True + + + value + 10**(-snr_db/10) + + + _coordinate + (637, 13) + + + _rotation + 0 + + + + random_source_x + + id + random_source_x_0 + + + _enabled + True + + + type + short + + + min + 0 + + + max + 2 + + + num_samps + 1000 + + + repeat + True + + + _coordinate + (21, 170) + + + _rotation + 0 + + + + gr_multiply_const_vxx + + id + gr_multiply_const_vxx_0 + + + _enabled + True + + + type + complex + + + const + alpha**0.5 + + + vlen + 1 + + + _coordinate + (988, 196) + + + _rotation + 0 + + + + random_source_x + + id + random_source_x_1 + + + _enabled + True + + + type + short + + + min + 0 + + + max + 2 + + + num_samps + 1000 + + + repeat + True + + + _coordinate + (25, 291) + + + _rotation + 0 + + + + gr_chunks_to_symbols_xx + + id + gr_chunks_to_symbols_xx_1 + + + _enabled + True + + + in_type + short + + + out_type + complex + + + symbol_table + 1,1j,-1j,-1 + + + dimension + 1 + + + num_ports + 1 + + + _coordinate + (660, 311) + + + _rotation + 0 + + + + gr_multiply_const_vxx + + id + gr_multiply_const_vxx_1 + + + _enabled + True + + + type + complex + + + const + (1-alpha)**0.5 + + + vlen + 1 + + + _coordinate + (994, 319) + + + _rotation + 0 + + + + gr_add_xx + + id + gr_add_xx_0 + + + _enabled + True + + + type + complex + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (1224, 244) + + + _rotation + 0 + + + + gr_noise_source_x + + id + gr_noise_source_x_0 + + + _enabled + True + + + type + complex + + + noise_type + gr.GR_GAUSSIAN + + + amp + noisevar + + + seed + 42 + + + _coordinate + (1146, 369) + + + _rotation + 0 + + + + gr_sub_xx + + id + gr_sub_xx_0 + + + _enabled + True + + + type + short + + + vlen + 1 + + + num_inputs + 2 + + + _coordinate + (536, 529) + + + _rotation + 0 + + + + gr_multiply_xx + + id + gr_multiply_xx_0 + + + _enabled + True + + + type + short + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (771, 525) + + + _rotation + 0 + + + + gr_short_to_float + + id + gr_short_to_float_0 + + + _enabled + True + + + _coordinate + (994, 545) + + + _rotation + 0 + + + + gr_sub_xx + + id + gr_sub_xx_3 + + + _enabled + True + + + type + short + + + vlen + 1 + + + num_inputs + 2 + + + _coordinate + (535, 792) + + + _rotation + 0 + + + + gr_multiply_xx + + id + gr_multiply_xx_1 + + + _enabled + True + + + type + short + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (785, 779) + + + _rotation + 0 + + + + gr_short_to_float + + id + gr_short_to_float_2 + + + _enabled + True + + + _coordinate + (1005, 798) + + + _rotation + 0 + + + + gr_chunks_to_symbols_xx + + id + gr_chunks_to_symbols_xx_2 + + + _enabled + True + + + in_type + short + + + out_type + complex + + + symbol_table + 1,1j,-1j,-1 + + + dimension + 1 + + + num_ports + 1 + + + _coordinate + (405, 998) + + + _rotation + 0 + + + + gr_multiply_const_vxx + + id + gr_multiply_const_vxx_2 + + + _enabled + True + + + type + complex + + + const + alpha**0.5 + + + vlen + 1 + + + _coordinate + (710, 1008) + + + _rotation + 0 + + + + gr_sub_xx + + id + gr_sub_xx_2 + + + _enabled + True + + + type + complex + + + vlen + 1 + + + num_inputs + 2 + + + _coordinate + (944, 978) + + + _rotation + 0 + + + + gr_sub_xx + + id + gr_sub_xx_1 + + + _enabled + True + + + type + short + + + vlen + 1 + + + num_inputs + 2 + + + _coordinate + (540, 1141) + + + _rotation + 0 + + + + gr_multiply_xx + + id + gr_multiply_xx_2 + + + _enabled + True + + + type + short + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (796, 1136) + + + _rotation + 0 + + + + gr_short_to_float + + id + gr_short_to_float_1 + + + _enabled + True + + + _coordinate + (1009, 1156) + + + _rotation + 0 + + + + gr_chunks_to_symbols_xx + + id + gr_chunks_to_symbols_xx_2_0 + + + _enabled + True + + + in_type + short + + + out_type + complex + + + symbol_table + 1,1j,-1j,-1 + + + dimension + 1 + + + num_ports + 1 + + + _coordinate + (420, 1368) + + + _rotation + 0 + + + + gr_multiply_const_vxx + + id + gr_multiply_const_vxx_2_0 + + + _enabled + True + + + type + complex + + + const + (1-alpha)**0.5 + + + vlen + 1 + + + _coordinate + (733, 1374) + + + _rotation + 0 + + + + gr_sub_xx + + id + gr_sub_xx_2_0 + + + _enabled + True + + + type + complex + + + vlen + 1 + + + num_inputs + 2 + + + _coordinate + (975, 1342) + + + _rotation + 0 + + + + gr_sub_xx + + id + gr_sub_xx_1_0 + + + _enabled + True + + + type + short + + + vlen + 1 + + + num_inputs + 2 + + + _coordinate + (559, 1536) + + + _rotation + 0 + + + + gr_multiply_xx + + id + gr_multiply_xx_2_0 + + + _enabled + True + + + type + short + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (771, 1530) + + + _rotation + 0 + + + + gr_short_to_float + + id + gr_short_to_float_1_0 + + + _enabled + True + + + _coordinate + (1010, 1551) + + + _rotation + 0 + + + + trellis_encoder_xx + + id + trellis_encoder_xx_1 + + + _enabled + True + + + type + ss + + + fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" + + + init_state + 0 + + + _coordinate + (336, 311) + + + _rotation + 0 + + + + trellis_viterbi_combined_xx + + id + trellis_viterbi_combined_xx_1 + + + _enabled + True + + + type + c + + + out_type + s + + + fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" + + + block_size + 1000 + + + init_state + -1 + + + final_state + -1 + + + dim + 1 + + + table + alpha**0.5*1,alpha**0.5*1j,alpha**0.5*(-1j),alpha**0.5*(-1) + + + metric_type + trellis.TRELLIS_EUCLIDEAN + + + _coordinate + (79, 501) + + + _rotation + 0 + + + + trellis_viterbi_combined_xx + + id + trellis_viterbi_combined_xx_2 + + + _enabled + True + + + type + c + + + out_type + s + + + fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" + + + block_size + 1000 + + + init_state + -1 + + + final_state + -1 + + + dim + 1 + + + table + (1-alpha)**0.5*1,(1-alpha)**0.5*1j,(1-alpha)**0.5*(-1j),(1-alpha)**0.5*(-1) + + + metric_type + trellis.TRELLIS_EUCLIDEAN + + + _coordinate + (82, 766) + + + _rotation + 0 + + + + trellis_encoder_xx + + id + trellis_encoder_xx_2 + + + _enabled + True + + + type + ss + + + fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" + + + init_state + 0 + + + _coordinate + (89, 998) + + + _rotation + 0 + + + + trellis_viterbi_combined_xx + + id + trellis_viterbi_combined_xx_0 + + + _enabled + True + + + type + c + + + out_type + s + + + fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" + + + block_size + 1000 + + + init_state + -1 + + + final_state + -1 + + + dim + 1 + + + table + (1-alpha)**0.5*1,(1-alpha)**0.5*1j,(1-alpha)**0.5*(-1j),(1-alpha)**0.5*(-1) + + + metric_type + trellis.TRELLIS_EUCLIDEAN + + + _coordinate + (83, 1111) + + + _rotation + 0 + + + + trellis_encoder_xx + + id + trellis_encoder_xx_2_0 + + + _enabled + True + + + type + ss + + + fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" + + + init_state + 0 + + + _coordinate + (105, 1367) + + + _rotation + 0 + + + + trellis_viterbi_combined_xx + + id + trellis_viterbi_combined_xx_0_0 + + + _enabled + True + + + type + c + + + out_type + s + + + fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" + + + block_size + 1000 + + + init_state + -1 + + + final_state + -1 + + + dim + 1 + + + table + alpha**0.5*1,alpha**0.5*1j,alpha**0.5*(-1j),alpha**0.5*(-1) + + + metric_type + trellis.TRELLIS_EUCLIDEAN + + + _coordinate + (75, 1495) + + + _rotation + 0 + + + + gr_add_xx + + id + gr_add_xx_1 + + + _enabled + True + + + type + complex + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (1400, 262) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + wxgui_scopesink2_0 + + + _enabled + True + + + type + complex + + + title + Scope Plot + + + samp_rate + R + + + v_scale + 0 + + + v_offset + 0 + + + t_scale + 0 + + + ac_couple + False + + + xy_mode + True + + + num_inputs + 1 + + + win_size + + + + grid_pos + + + + notebook + + + + trig_mode + gr.gr_TRIG_MODE_AUTO + + + y_axis_label + Counts + + + _coordinate + (1533, 149) + + + _rotation + 0 + + + + variable + + id + prefix + + + _enabled + True + + + value + "/n/harrisville/x/anastas/gnuradio_trunk/" + + + _coordinate + (871, 14) + + + _rotation + 0 + + + + trellis_encoder_xx + + id + trellis_encoder_xx_0 + + + _enabled + True + + + type + ss + + + fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_16.fsm" + + + init_state + 0 + + + _coordinate + (340, 187) + + + _rotation + 0 + + + + gr_throttle + + id + gr_throttle_0 + + + _enabled + True + + + type + short + + + samples_per_second + R + + + vlen + 1 + + + _coordinate + (534, 149) + + + _rotation + 0 + + + + gr_chunks_to_symbols_xx + + id + gr_chunks_to_symbols_xx_0 + + + _enabled + True + + + in_type + short + + + out_type + complex + + + symbol_table + 1,1j,-1j,-1 + + + dimension + 1 + + + num_ports + 1 + + + _coordinate + (682, 186) + + + _rotation + 0 + + + + variable + + id + R + + + _enabled + True + + + value + 100e3 + + + _coordinate + (748, 12) + + + _rotation + 0 + + + + wxgui_numbersink2 + + id + wxgui_numbersink2_0 + + + _enabled + True + + + type + float + + + title + BER 1 (raw) + + + units + BER + + + samp_rate + R + + + min_value + 0 + + + max_value + 1 + + + factor + 1.0 + + + decimal_places + 6 + + + ref_level + 0 + + + number_rate + 15 + + + peak_hold + False + + + average + True + + + avg_alpha + 0.001 + + + show_gauge + True + + + win_size + + + + grid_pos + 0,0,1,1 + + + notebook + + + + _coordinate + (1267, 410) + + + _rotation + 0 + + + + wxgui_numbersink2 + + id + wxgui_numbersink2_2 + + + _enabled + True + + + type + float + + + title + BER 2 (raw) + + + units + BER + + + samp_rate + R + + + min_value + 0 + + + max_value + 1.0 + + + factor + 1.0 + + + decimal_places + 6 + + + ref_level + 0 + + + number_rate + 15 + + + peak_hold + False + + + average + True + + + avg_alpha + 0.001 + + + show_gauge + True + + + win_size + + + + grid_pos + 0,1,1,1 + + + notebook + + + + _coordinate + (1260, 659) + + + _rotation + 0 + + + + wxgui_numbersink2 + + id + wxgui_numbersink2_3 + + + _enabled + True + + + type + float + + + title + BER 2 (after cancelling user 1) + + + units + BER + + + samp_rate + R + + + min_value + 0 + + + max_value + 1.0 + + + factor + 1.0 + + + decimal_places + 6 + + + ref_level + 0 + + + number_rate + 15 + + + peak_hold + False + + + average + True + + + avg_alpha + 0.001 + + + show_gauge + True + + + win_size + + + + grid_pos + 1,1,1,1 + + + notebook + + + + _coordinate + (1262, 1020) + + + _rotation + 0 + + + + wxgui_numbersink2 + + id + wxgui_numbersink2_3_0 + + + _enabled + True + + + type + float + + + title + BER 1 (after cancelling user 2) + + + units + BER + + + samp_rate + R + + + min_value + 0 + + + max_value + 1.0 + + + factor + 1.0 + + + decimal_places + 6 + + + ref_level + 0 + + + number_rate + 15 + + + peak_hold + False + + + average + True + + + avg_alpha + 0.001 + + + show_gauge + True + + + win_size + + + + grid_pos + 1,0,1,1 + + + notebook + + + + _coordinate + (1269, 1417) + + + _rotation + 0 + + + + random_source_x_1 + trellis_encoder_xx_1 + 0 + 0 + + + trellis_encoder_xx_1 + gr_chunks_to_symbols_xx_1 + 0 + 0 + + + gr_chunks_to_symbols_xx_0 + gr_multiply_const_vxx_0 + 0 + 0 + + + gr_multiply_const_vxx_0 + gr_add_xx_0 + 0 + 0 + + + gr_add_xx_0 + gr_add_xx_1 + 0 + 0 + + + gr_noise_source_x_0 + gr_add_xx_1 + 0 + 1 + + + gr_chunks_to_symbols_xx_1 + gr_multiply_const_vxx_1 + 0 + 0 + + + gr_multiply_const_vxx_1 + gr_add_xx_0 + 0 + 1 + + + gr_sub_xx_0 + gr_multiply_xx_0 + 0 + 0 + + + gr_sub_xx_0 + gr_multiply_xx_0 + 0 + 1 + + + gr_multiply_xx_0 + gr_short_to_float_0 + 0 + 0 + + + gr_short_to_float_0 + wxgui_numbersink2_0 + 0 + 0 + + + gr_multiply_xx_2 + gr_short_to_float_1 + 0 + 0 + + + random_source_x_0 + trellis_encoder_xx_0 + 0 + 0 + + + gr_add_xx_1 + trellis_viterbi_combined_xx_1 + 0 + 0 + + + random_source_x_0 + gr_sub_xx_0 + 0 + 0 + + + trellis_viterbi_combined_xx_1 + gr_sub_xx_0 + 0 + 1 + + + trellis_viterbi_combined_xx_0 + gr_sub_xx_1 + 0 + 1 + + + random_source_x_1 + gr_sub_xx_1 + 0 + 0 + + + gr_sub_xx_1 + gr_multiply_xx_2 + 0 + 0 + + + gr_sub_xx_1 + gr_multiply_xx_2 + 0 + 1 + + + gr_sub_xx_2 + trellis_viterbi_combined_xx_0 + 0 + 0 + + + gr_add_xx_1 + gr_sub_xx_2 + 0 + 0 + + + trellis_encoder_xx_2 + gr_chunks_to_symbols_xx_2 + 0 + 0 + + + gr_chunks_to_symbols_xx_2 + gr_multiply_const_vxx_2 + 0 + 0 + + + gr_multiply_const_vxx_2 + gr_sub_xx_2 + 0 + 1 + + + trellis_viterbi_combined_xx_1 + trellis_encoder_xx_2 + 0 + 0 + + + gr_multiply_xx_1 + gr_short_to_float_2 + 0 + 0 + + + gr_short_to_float_2 + wxgui_numbersink2_2 + 0 + 0 + + + trellis_viterbi_combined_xx_2 + gr_sub_xx_3 + 0 + 1 + + + gr_sub_xx_3 + gr_multiply_xx_1 + 0 + 0 + + + gr_sub_xx_3 + gr_multiply_xx_1 + 0 + 1 + + + gr_add_xx_1 + trellis_viterbi_combined_xx_2 + 0 + 0 + + + random_source_x_1 + gr_sub_xx_3 + 0 + 0 + + + gr_short_to_float_1 + wxgui_numbersink2_3 + 0 + 0 + + + trellis_encoder_xx_2_0 + gr_chunks_to_symbols_xx_2_0 + 0 + 0 + + + gr_chunks_to_symbols_xx_2_0 + gr_multiply_const_vxx_2_0 + 0 + 0 + + + trellis_viterbi_combined_xx_2 + trellis_encoder_xx_2_0 + 0 + 0 + + + gr_multiply_xx_2_0 + gr_short_to_float_1_0 + 0 + 0 + + + trellis_viterbi_combined_xx_0_0 + gr_sub_xx_1_0 + 0 + 1 + + + gr_sub_xx_1_0 + gr_multiply_xx_2_0 + 0 + 0 + + + gr_sub_xx_1_0 + gr_multiply_xx_2_0 + 0 + 1 + + + gr_sub_xx_2_0 + trellis_viterbi_combined_xx_0_0 + 0 + 0 + + + gr_short_to_float_1_0 + wxgui_numbersink2_3_0 + 0 + 0 + + + gr_add_xx_1 + gr_sub_xx_2_0 + 0 + 0 + + + random_source_x_0 + gr_sub_xx_1_0 + 0 + 0 + + + gr_multiply_const_vxx_2_0 + gr_sub_xx_2_0 + 0 + 1 + + + gr_add_xx_1 + wxgui_scopesink2_0 + 0 + 0 + + + trellis_encoder_xx_0 + gr_throttle_0 + 0 + 0 + + + gr_throttle_0 + gr_chunks_to_symbols_xx_0 + 0 + 0 + + diff --git a/gr-trellis/src/examples/grc/pccc.grc b/gr-trellis/src/examples/grc/pccc.grc new file mode 100644 index 000000000..c3111c321 --- /dev/null +++ b/gr-trellis/src/examples/grc/pccc.grc @@ -0,0 +1,832 @@ + + + Thu Sep 1 12:53:13 2011 + + options + + id + sccc1 + + + _enabled + True + + + title + Serially Concatenated Convolutional Code + + + author + AA + + + description + gnuradio flow graph + + + window_size + 2048, 2048 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + noisevar + + + _enabled + True + + + value + 10**(-snr_db/10) + + + _coordinate + (389, 15) + + + _rotation + 0 + + + + variable + + id + prefix + + + _enabled + True + + + value + "/n/harrisville/x/anastas/gnuradio_trunk/" + + + _coordinate + (590, 15) + + + _rotation + 0 + + + + variable + + id + block + + + _enabled + True + + + value + 1000 + + + _coordinate + (764, 16) + + + _rotation + 0 + + + + variable_slider + + id + snr_db + + + _enabled + True + + + label + SNR (dB) + + + value + 5 + + + min + -10 + + + max + 10 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (229, 13) + + + _rotation + 0 + + + + gr_multiply_xx + + id + gr_multiply_xx_2_0 + + + _enabled + True + + + type + short + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (392, 591) + + + _rotation + 0 + + + + gr_short_to_float + + id + gr_short_to_float_1_0 + + + _enabled + True + + + _coordinate + (535, 609) + + + _rotation + 0 + + + + wxgui_numbersink2 + + id + wxgui_numbersink2_3_0 + + + _enabled + True + + + type + float + + + title + BER + + + units + BER + + + samp_rate + R + + + min_value + 0 + + + max_value + 1.0 + + + factor + 1.0 + + + decimal_places + 6 + + + ref_level + 0 + + + number_rate + 15 + + + peak_hold + False + + + average + True + + + avg_alpha + 0.001 + + + show_gauge + True + + + win_size + + + + grid_pos + 1,0,1,1 + + + notebook + + + + _coordinate + (713, 426) + + + _rotation + 0 + + + + gr_noise_source_x + + id + gr_noise_source_x_0 + + + _enabled + True + + + type + float + + + noise_type + gr.GR_GAUSSIAN + + + amp + noisevar + + + seed + 42 + + + _coordinate + (672, 290) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + wxgui_scopesink2_0 + + + _enabled + False + + + type + float + + + title + Scope Plot + + + samp_rate + R + + + v_scale + 0 + + + v_offset + 0 + + + t_scale + 0 + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + win_size + + + + grid_pos + + + + notebook + + + + trig_mode + gr.gr_TRIG_MODE_AUTO + + + y_axis_label + Counts + + + _coordinate + (952, 73) + + + _rotation + 0 + + + + random_source_x + + id + random_source_x_0 + + + _enabled + True + + + type + short + + + min + 0 + + + max + 2 + + + num_samps + 1000 + + + repeat + True + + + _coordinate + (21, 170) + + + _rotation + 0 + + + + gr_throttle + + id + gr_throttle_0 + + + _enabled + True + + + type + short + + + samples_per_second + R + + + vlen + 1 + + + _coordinate + (517, 103) + + + _rotation + 0 + + + + gr_chunks_to_symbols_xx + + id + gr_chunks_to_symbols_xx_0 + + + _enabled + True + + + in_type + short + + + out_type + float + + + symbol_table + -7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7,0, 0,-7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7 + + + dimension + 2 + + + num_ports + 1 + + + _coordinate + (551, 184) + + + _rotation + 0 + + + + trellis_pccc_encoder_xx + + id + trellis_pccc_encoder_xx_0 + + + _enabled + True + + + type + ss + + + o_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" + + + o_init_state + 0 + + + i_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" + + + i_init_state + 0 + + + interleaver_args + trellis.interleaver(block,666) + + + bl + block + + + _coordinate + (236, 147) + + + _rotation + 0 + + + + variable + + id + R + + + _enabled + True + + + value + 100e3 + + + _coordinate + (482, 17) + + + _rotation + 0 + + + + gr_add_xx + + id + gr_add_xx_1 + + + _enabled + True + + + type + float + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (951, 256) + + + _rotation + 0 + + + + trellis_pccc_decoder_combined_xx + + id + trellis_pccc_decoder_combined_xx_0 + + + _enabled + True + + + type + f + + + out_type + s + + + o_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" + + + o_init_state + 0 + + + o_final_state + -1 + + + i_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" + + + i_init_state + 0 + + + i_final_state + -1 + + + interleaver + trellis.interleaver(block,666) + + + block_size + block + + + iterations + 10 + + + dim + 2 + + + table + -7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7,0, 0,-7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7 + + + metric_type + trellis.TRELLIS_EUCLIDEAN + + + siso_type + trellis.TRELLIS_MIN_SUM + + + scaling + 1.0 + + + _coordinate + (196, 274) + + + _rotation + 0 + + + + gr_sub_xx + + id + gr_sub_xx_0 + + + _enabled + True + + + type + short + + + vlen + 1 + + + num_inputs + 2 + + + _coordinate + (217, 597) + + + _rotation + 0 + + + + random_source_x_0 + gr_sub_xx_0 + 0 + 0 + + + gr_throttle_0 + gr_chunks_to_symbols_xx_0 + 0 + 0 + + + gr_add_xx_1 + wxgui_scopesink2_0 + 0 + 0 + + + gr_noise_source_x_0 + gr_add_xx_1 + 0 + 1 + + + gr_chunks_to_symbols_xx_0 + gr_add_xx_1 + 0 + 0 + + + gr_multiply_xx_2_0 + gr_short_to_float_1_0 + 0 + 0 + + + gr_short_to_float_1_0 + wxgui_numbersink2_3_0 + 0 + 0 + + + gr_sub_xx_0 + gr_multiply_xx_2_0 + 0 + 0 + + + gr_sub_xx_0 + gr_multiply_xx_2_0 + 0 + 1 + + + random_source_x_0 + trellis_pccc_encoder_xx_0 + 0 + 0 + + + trellis_pccc_encoder_xx_0 + gr_throttle_0 + 0 + 0 + + + gr_add_xx_1 + trellis_pccc_decoder_combined_xx_0 + 0 + 0 + + + trellis_pccc_decoder_combined_xx_0 + gr_sub_xx_0 + 0 + 1 + + diff --git a/gr-trellis/src/examples/grc/pccc1.grc b/gr-trellis/src/examples/grc/pccc1.grc new file mode 100644 index 000000000..15a63707e --- /dev/null +++ b/gr-trellis/src/examples/grc/pccc1.grc @@ -0,0 +1,857 @@ + + + Wed Aug 31 20:34:39 2011 + + options + + id + sccc1 + + + _enabled + True + + + title + Serially Concatenated Convolutional Code + + + author + AA + + + description + gnuradio flow graph + + + window_size + 2048, 2048 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + noisevar + + + _enabled + True + + + value + 10**(-snr_db/10) + + + _coordinate + (389, 15) + + + _rotation + 0 + + + + variable + + id + prefix + + + _enabled + True + + + value + "/n/harrisville/x/anastas/gnuradio_trunk/" + + + _coordinate + (590, 15) + + + _rotation + 0 + + + + variable + + id + block + + + _enabled + True + + + value + 1000 + + + _coordinate + (764, 16) + + + _rotation + 0 + + + + variable_slider + + id + snr_db + + + _enabled + True + + + label + SNR (dB) + + + value + 5 + + + min + -10 + + + max + 10 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (229, 13) + + + _rotation + 0 + + + + gr_multiply_xx + + id + gr_multiply_xx_2_0 + + + _enabled + True + + + type + short + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (392, 591) + + + _rotation + 0 + + + + gr_short_to_float + + id + gr_short_to_float_1_0 + + + _enabled + True + + + _coordinate + (535, 609) + + + _rotation + 0 + + + + wxgui_numbersink2 + + id + wxgui_numbersink2_3_0 + + + _enabled + True + + + type + float + + + title + BER + + + units + BER + + + samp_rate + R + + + min_value + 0 + + + max_value + 1.0 + + + factor + 1.0 + + + decimal_places + 6 + + + ref_level + 0 + + + number_rate + 15 + + + peak_hold + False + + + average + True + + + avg_alpha + 0.001 + + + show_gauge + True + + + win_size + + + + grid_pos + 1,0,1,1 + + + notebook + + + + _coordinate + (713, 426) + + + _rotation + 0 + + + + gr_noise_source_x + + id + gr_noise_source_x_0 + + + _enabled + True + + + type + float + + + noise_type + gr.GR_GAUSSIAN + + + amp + noisevar + + + seed + 42 + + + _coordinate + (672, 290) + + + _rotation + 0 + + + + gr_add_xx + + id + gr_add_xx_1 + + + _enabled + True + + + type + float + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (951, 256) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + wxgui_scopesink2_0 + + + _enabled + False + + + type + float + + + title + Scope Plot + + + samp_rate + R + + + v_scale + 0 + + + v_offset + 0 + + + t_scale + 0 + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + win_size + + + + grid_pos + + + + notebook + + + + trig_mode + gr.gr_TRIG_MODE_AUTO + + + y_axis_label + Counts + + + _coordinate + (952, 73) + + + _rotation + 0 + + + + random_source_x + + id + random_source_x_0 + + + _enabled + True + + + type + short + + + min + 0 + + + max + 2 + + + num_samps + 1000 + + + repeat + True + + + _coordinate + (21, 170) + + + _rotation + 0 + + + + gr_throttle + + id + gr_throttle_0 + + + _enabled + True + + + type + short + + + samples_per_second + R + + + vlen + 1 + + + _coordinate + (517, 103) + + + _rotation + 0 + + + + gr_sub_xx + + id + gr_sub_xx_0 + + + _enabled + True + + + type + short + + + vlen + 1 + + + num_inputs + 2 + + + _coordinate + (217, 597) + + + _rotation + 0 + + + + gr_chunks_to_symbols_xx + + id + gr_chunks_to_symbols_xx_0 + + + _enabled + True + + + in_type + short + + + out_type + float + + + symbol_table + -7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7,0, 0,-7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7 + + + dimension + 2 + + + num_ports + 1 + + + _coordinate + (551, 184) + + + _rotation + 0 + + + + trellis_pccc_encoder_xx + + id + trellis_pccc_encoder_xx_0 + + + _enabled + True + + + type + ss + + + o_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" + + + o_init_state + 0 + + + i_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" + + + i_init_state + 0 + + + interleaver_args + trellis.interleaver(block,666) + + + bl + block + + + _coordinate + (236, 147) + + + _rotation + 0 + + + + trellis_pccc_decoder_x + + id + trellis_pccc_decoder_x_0 + + + _enabled + True + + + out_type + s + + + o_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" + + + o_init_state + 0 + + + o_final_state + -1 + + + i_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" + + + i_init_state + 0 + + + i_final_state + -1 + + + interleaver + trellis.interleaver(block,666) + + + block_size + block + + + iterations + 10 + + + siso_type + trellis.TRELLIS_MIN_SUM + + + _coordinate + (357, 304) + + + _rotation + 0 + + + + trellis_metrics_x + + id + trellis_metrics_x_0 + + + _enabled + True + + + type + f + + + card + 16 + + + dim + 2 + + + table + -7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7,0, 0,-7,0, -5,0, -3,0, -1,0, 1,0, 3,0, 5,0, 7 + + + metric_type + trellis.TRELLIS_EUCLIDEAN + + + _coordinate + (58, 354) + + + _rotation + 0 + + + + variable + + id + R + + + _enabled + True + + + value + 100e3 + + + _coordinate + (482, 17) + + + _rotation + 0 + + + + random_source_x_0 + gr_sub_xx_0 + 0 + 0 + + + gr_throttle_0 + gr_chunks_to_symbols_xx_0 + 0 + 0 + + + gr_add_xx_1 + wxgui_scopesink2_0 + 0 + 0 + + + gr_noise_source_x_0 + gr_add_xx_1 + 0 + 1 + + + gr_chunks_to_symbols_xx_0 + gr_add_xx_1 + 0 + 0 + + + gr_multiply_xx_2_0 + gr_short_to_float_1_0 + 0 + 0 + + + gr_short_to_float_1_0 + wxgui_numbersink2_3_0 + 0 + 0 + + + gr_sub_xx_0 + gr_multiply_xx_2_0 + 0 + 0 + + + gr_sub_xx_0 + gr_multiply_xx_2_0 + 0 + 1 + + + gr_add_xx_1 + trellis_metrics_x_0 + 0 + 0 + + + random_source_x_0 + trellis_pccc_encoder_xx_0 + 0 + 0 + + + trellis_pccc_encoder_xx_0 + gr_throttle_0 + 0 + 0 + + + trellis_metrics_x_0 + trellis_pccc_decoder_x_0 + 0 + 0 + + + trellis_pccc_decoder_x_0 + gr_sub_xx_0 + 0 + 1 + + diff --git a/gr-trellis/src/examples/grc/readme.txt b/gr-trellis/src/examples/grc/readme.txt new file mode 100644 index 000000000..9c7363af8 --- /dev/null +++ b/gr-trellis/src/examples/grc/readme.txt @@ -0,0 +1,32 @@ +These are examples of using gr-trellis in grc. + +INTERFERENCE CANCELLATION +------------------------- +Two users are transmitting simultaneously using convolutionally encoded QPSK, each with power P1=alpha*P and P2=(1-alpha)*P. +The combined signal is observed in noise and four different receivers are considered: +1) A viterbi decoder decoding user 1 assuming user 2 is noise +2) A viterbi decoder decoding user 2 assuming user 1 is noise +3) A viterbi decoder decoding user 1 first + and then reencoding this signal, subtracting it from the observation + and then running a Viterbi decoder decoding user 2 +4) A viterbi decoder decoding user 2 first + and then reencoding this signal, subtracting it from the observation + and then running a Viterbi decoder decoding user 1 + +You can change the signal to noise ratio P/sigma^2 and the allocation of power to the two users, alpha. + + +Serially Concatenated Convolutional Codes +----------------------------------------- +An SCCC can be defined by an outer and an inner FSM together with an interleaver +and a modulation type. You can change the SNR and observe the estimated BER. +In sccc.grc the decoding and metric calculation are combined; in sccc1.grc they are separate. + +Parallel Concatenated Convolutional Codes +----------------------------------------- +A PCCC can be defined by two FSMs together with an interleaver +and a modulation type. You can change the SNR and observe the estimated BER. +In pccc1.grc the decoding and metric calculation are separate. + + +Enjoy. diff --git a/gr-trellis/src/examples/grc/sccc.grc b/gr-trellis/src/examples/grc/sccc.grc new file mode 100644 index 000000000..e8f656f63 --- /dev/null +++ b/gr-trellis/src/examples/grc/sccc.grc @@ -0,0 +1,832 @@ + + + Wed Aug 31 19:57:09 2011 + + options + + id + sccc + + + _enabled + True + + + title + Serially Concatenated Convolutional Code + + + author + AA + + + description + gnuradio flow graph + + + window_size + 2048, 2048 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + noisevar + + + _enabled + True + + + value + 10**(-snr_db/10) + + + _coordinate + (389, 15) + + + _rotation + 0 + + + + random_source_x + + id + random_source_x_0 + + + _enabled + True + + + type + short + + + min + 0 + + + max + 2 + + + num_samps + 1000 + + + repeat + True + + + _coordinate + (21, 170) + + + _rotation + 0 + + + + variable + + id + prefix + + + _enabled + True + + + value + "/n/harrisville/x/anastas/gnuradio_trunk/" + + + _coordinate + (590, 15) + + + _rotation + 0 + + + + variable + + id + block + + + _enabled + True + + + value + 1000 + + + _coordinate + (764, 16) + + + _rotation + 0 + + + + gr_add_xx + + id + gr_add_xx_1 + + + _enabled + True + + + type + complex + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (951, 256) + + + _rotation + 0 + + + + gr_sub_xx + + id + gr_sub_xx_0 + + + _enabled + True + + + type + short + + + vlen + 1 + + + num_inputs + 2 + + + _coordinate + (445, 517) + + + _rotation + 0 + + + + gr_multiply_xx + + id + gr_multiply_xx_2_0 + + + _enabled + True + + + type + short + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (228.25, 798.39170361874085) + + + _rotation + 0 + + + + gr_short_to_float + + id + gr_short_to_float_1_0 + + + _enabled + True + + + _coordinate + (416, 815) + + + _rotation + 0 + + + + variable_slider + + id + snr_db + + + _enabled + True + + + label + SNR (dB) + + + value + 5 + + + min + -10 + + + max + 10 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (229, 13) + + + _rotation + 0 + + + + variable + + id + R + + + _enabled + True + + + value + 10e3 + + + _coordinate + (482, 17) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + wxgui_scopesink2_0 + + + _enabled + False + + + type + complex + + + title + Scope Plot + + + samp_rate + R + + + v_scale + 0 + + + v_offset + 0 + + + t_scale + 0 + + + ac_couple + False + + + xy_mode + True + + + num_inputs + 1 + + + win_size + + + + grid_pos + + + + notebook + + + + trig_mode + gr.gr_TRIG_MODE_AUTO + + + y_axis_label + Counts + + + _coordinate + (952, 73) + + + _rotation + 0 + + + + gr_throttle + + id + gr_throttle_0 + + + _enabled + True + + + type + short + + + samples_per_second + R + + + vlen + 1 + + + _coordinate + (514, 105) + + + _rotation + 0 + + + + gr_chunks_to_symbols_xx + + id + gr_chunks_to_symbols_xx_0 + + + _enabled + True + + + in_type + short + + + out_type + complex + + + symbol_table + 1,0,1j,0,-1j,0,-1,0, 0,1,0,1j,0,-1j,0,-1 + + + dimension + 2 + + + num_ports + 1 + + + _coordinate + (551, 184) + + + _rotation + 0 + + + + gr_noise_source_x + + id + gr_noise_source_x_0 + + + _enabled + True + + + type + complex + + + noise_type + gr.GR_GAUSSIAN + + + amp + noisevar + + + seed + 42 + + + _coordinate + (672, 290) + + + _rotation + 0 + + + + trellis_sccc_encoder_xx + + id + trellis_sccc_encoder_xx_0 + + + _enabled + True + + + type + ss + + + o_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" + + + o_init_state + 0 + + + i_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm" + + + i_init_state + 0 + + + interleaver_args + trellis.interleaver(block,666) + + + bl + block + + + _coordinate + (242, 154) + + + _rotation + 0 + + + + wxgui_numbersink2 + + id + wxgui_numbersink2_3_0 + + + _enabled + True + + + type + float + + + title + BER + + + units + BER + + + samp_rate + R + + + min_value + 0 + + + max_value + 1.0 + + + factor + 1.0 + + + decimal_places + 6 + + + ref_level + 0 + + + number_rate + 15 + + + peak_hold + False + + + average + True + + + avg_alpha + 0.001 + + + show_gauge + True + + + win_size + + + + grid_pos + 1,0,1,1 + + + notebook + + + + _coordinate + (688, 572) + + + _rotation + 0 + + + + trellis_sccc_decoder_combined_xx + + id + trellis_sccc_decoder_combined_xx_0 + + + _enabled + True + + + type + c + + + out_type + s + + + o_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" + + + o_init_state + 0 + + + o_final_state + -1 + + + i_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm" + + + i_init_state + 0 + + + i_final_state + -1 + + + interleaver + trellis.interleaver(block,666) + + + block_size + block + + + iterations + 5 + + + dim + 2 + + + table + 1,0,1j,0,-1j,0,-1,0, 0,1,0,1j,0,-1j,0,-1 + + + metric_type + trellis.TRELLIS_EUCLIDEAN + + + siso_type + trellis.TRELLIS_SUM_PRODUCT + + + scaling + 1.0 + + + _coordinate + (159, 335) + + + _rotation + 0 + + + + random_source_x_0 + gr_sub_xx_0 + 0 + 0 + + + gr_throttle_0 + gr_chunks_to_symbols_xx_0 + 0 + 0 + + + gr_add_xx_1 + wxgui_scopesink2_0 + 0 + 0 + + + gr_noise_source_x_0 + gr_add_xx_1 + 0 + 1 + + + gr_chunks_to_symbols_xx_0 + gr_add_xx_1 + 0 + 0 + + + random_source_x_0 + trellis_sccc_encoder_xx_0 + 0 + 0 + + + trellis_sccc_encoder_xx_0 + gr_throttle_0 + 0 + 0 + + + gr_add_xx_1 + trellis_sccc_decoder_combined_xx_0 + 0 + 0 + + + trellis_sccc_decoder_combined_xx_0 + gr_sub_xx_0 + 0 + 1 + + + gr_multiply_xx_2_0 + gr_short_to_float_1_0 + 0 + 0 + + + gr_short_to_float_1_0 + wxgui_numbersink2_3_0 + 0 + 0 + + + gr_sub_xx_0 + gr_multiply_xx_2_0 + 0 + 0 + + + gr_sub_xx_0 + gr_multiply_xx_2_0 + 0 + 1 + + diff --git a/gr-trellis/src/examples/grc/sccc1.grc b/gr-trellis/src/examples/grc/sccc1.grc new file mode 100644 index 000000000..0be59d0c4 --- /dev/null +++ b/gr-trellis/src/examples/grc/sccc1.grc @@ -0,0 +1,857 @@ + + + Wed Aug 31 20:09:23 2011 + + options + + id + sccc1 + + + _enabled + True + + + title + Serially Concatenated Convolutional Code + + + author + AA + + + description + gnuradio flow graph + + + window_size + 2048, 2048 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + noisevar + + + _enabled + True + + + value + 10**(-snr_db/10) + + + _coordinate + (389, 15) + + + _rotation + 0 + + + + random_source_x + + id + random_source_x_0 + + + _enabled + True + + + type + short + + + min + 0 + + + max + 2 + + + num_samps + 1000 + + + repeat + True + + + _coordinate + (21, 170) + + + _rotation + 0 + + + + variable + + id + prefix + + + _enabled + True + + + value + "/n/harrisville/x/anastas/gnuradio_trunk/" + + + _coordinate + (590, 15) + + + _rotation + 0 + + + + variable + + id + block + + + _enabled + True + + + value + 1000 + + + _coordinate + (764, 16) + + + _rotation + 0 + + + + variable_slider + + id + snr_db + + + _enabled + True + + + label + SNR (dB) + + + value + 5 + + + min + -10 + + + max + 10 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (229, 13) + + + _rotation + 0 + + + + variable + + id + R + + + _enabled + True + + + value + 10e3 + + + _coordinate + (482, 17) + + + _rotation + 0 + + + + trellis_sccc_encoder_xx + + id + trellis_sccc_encoder_xx_0 + + + _enabled + True + + + type + ss + + + o_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" + + + o_init_state + 0 + + + i_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm" + + + i_init_state + 0 + + + interleaver_args + trellis.interleaver(block,666) + + + bl + block + + + _coordinate + (242, 154) + + + _rotation + 0 + + + + trellis_sccc_decoder_x + + id + trellis_sccc_decoder_x_0 + + + _enabled + True + + + out_type + s + + + o_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn1o2_4.fsm" + + + o_init_state + 0 + + + o_final_state + -1 + + + i_fsm_args + prefix+"gr-trellis/src/examples/fsm_files/awgn2o3_4.fsm" + + + i_init_state + 0 + + + i_final_state + -1 + + + interleaver + trellis.interleaver(block,666) + + + block_size + block + + + iterations + 10 + + + siso_type + trellis.TRELLIS_MIN_SUM + + + _coordinate + (333, 305) + + + _rotation + 0 + + + + gr_sub_xx + + id + gr_sub_xx_0 + + + _enabled + True + + + type + short + + + vlen + 1 + + + num_inputs + 2 + + + _coordinate + (217, 597) + + + _rotation + 0 + + + + gr_multiply_xx + + id + gr_multiply_xx_2_0 + + + _enabled + True + + + type + short + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (392, 591) + + + _rotation + 0 + + + + gr_short_to_float + + id + gr_short_to_float_1_0 + + + _enabled + True + + + _coordinate + (535, 609) + + + _rotation + 0 + + + + wxgui_numbersink2 + + id + wxgui_numbersink2_3_0 + + + _enabled + True + + + type + float + + + title + BER + + + units + BER + + + samp_rate + R + + + min_value + 0 + + + max_value + 1.0 + + + factor + 1.0 + + + decimal_places + 6 + + + ref_level + 0 + + + number_rate + 15 + + + peak_hold + False + + + average + True + + + avg_alpha + 0.001 + + + show_gauge + True + + + win_size + + + + grid_pos + 1,0,1,1 + + + notebook + + + + _coordinate + (713, 426) + + + _rotation + 0 + + + + gr_noise_source_x + + id + gr_noise_source_x_0 + + + _enabled + True + + + type + float + + + noise_type + gr.GR_GAUSSIAN + + + amp + noisevar + + + seed + 42 + + + _coordinate + (672, 290) + + + _rotation + 0 + + + + gr_add_xx + + id + gr_add_xx_1 + + + _enabled + True + + + type + float + + + num_inputs + 2 + + + vlen + 1 + + + _coordinate + (951, 256) + + + _rotation + 0 + + + + trellis_metrics_x + + id + trellis_metrics_x_0 + + + _enabled + True + + + type + f + + + card + 8 + + + dim + 1 + + + table + -7, -5, -3, -1, 1, 3, 5, 7 + + + metric_type + trellis.TRELLIS_EUCLIDEAN + + + _coordinate + (58, 354) + + + _rotation + 0 + + + + gr_throttle + + id + gr_throttle_0 + + + _enabled + True + + + type + short + + + samples_per_second + R + + + vlen + 1 + + + _coordinate + (517, 103) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + wxgui_scopesink2_0 + + + _enabled + False + + + type + float + + + title + Scope Plot + + + samp_rate + R + + + v_scale + 0 + + + v_offset + 0 + + + t_scale + 0 + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + win_size + + + + grid_pos + + + + notebook + + + + trig_mode + gr.gr_TRIG_MODE_AUTO + + + y_axis_label + Counts + + + _coordinate + (952, 73) + + + _rotation + 0 + + + + gr_chunks_to_symbols_xx + + id + gr_chunks_to_symbols_xx_0 + + + _enabled + True + + + in_type + short + + + out_type + float + + + symbol_table + -7, -5, -3, -1, 1, 3, 5, 7 + + + dimension + 1 + + + num_ports + 1 + + + _coordinate + (551, 184) + + + _rotation + 0 + + + + random_source_x_0 + gr_sub_xx_0 + 0 + 0 + + + gr_throttle_0 + gr_chunks_to_symbols_xx_0 + 0 + 0 + + + gr_add_xx_1 + wxgui_scopesink2_0 + 0 + 0 + + + gr_noise_source_x_0 + gr_add_xx_1 + 0 + 1 + + + gr_chunks_to_symbols_xx_0 + gr_add_xx_1 + 0 + 0 + + + random_source_x_0 + trellis_sccc_encoder_xx_0 + 0 + 0 + + + trellis_sccc_encoder_xx_0 + gr_throttle_0 + 0 + 0 + + + gr_multiply_xx_2_0 + gr_short_to_float_1_0 + 0 + 0 + + + gr_short_to_float_1_0 + wxgui_numbersink2_3_0 + 0 + 0 + + + gr_sub_xx_0 + gr_multiply_xx_2_0 + 0 + 0 + + + gr_sub_xx_0 + gr_multiply_xx_2_0 + 0 + 1 + + + gr_add_xx_1 + trellis_metrics_x_0 + 0 + 0 + + + trellis_metrics_x_0 + trellis_sccc_decoder_x_0 + 0 + 0 + + + trellis_sccc_decoder_x_0 + gr_sub_xx_0 + 0 + 1 + + diff --git a/gr-trellis/src/examples/python/CMakeLists.txt b/gr-trellis/src/examples/python/CMakeLists.txt new file mode 100644 index 000000000..e2c7e70ff --- /dev/null +++ b/gr-trellis/src/examples/python/CMakeLists.txt @@ -0,0 +1,64 @@ +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +include(GrPython) + +GR_PYTHON_INSTALL( + PROGRAMS + fsm_utils.py + test_tcm.py + test_tcm_parallel.py + test_tcm_combined.py + test_sccc_hard.py + test_sccc_soft.py + test_sccc_turbo.py + test_viterbi_equalization1.py + test_viterbi_equalization.py + test_turbo_equalization.py + test_turbo_equalization1.py + test_turbo_equalization2.py + DESTINATION ${GR_PKG_TRELLIS_EXAMPLES_DIR} + COMPONENT "trellis_examples" +) + +install( + FILES README + DESTINATION ${GR_PKG_DATA_DIR}/examples/trellis + COMPONENT "trellis_examples" +) + +install( + FILES + fsm_files/awgn1o2_128.fsm + fsm_files/awgn1o2_16.fsm + fsm_files/awgn1o2_4.fsm + fsm_files/awgn1o2_8.fsm + fsm_files/awgn2o3_16.fsm + fsm_files/awgn2o3_4.fsm + fsm_files/awgn2o3_4_msb.fsm + fsm_files/awgn2o3_4_msbG.fsm + fsm_files/awgn2o3_8.fsm + fsm_files/awgn2o4_4.fsm + fsm_files/disconnected.fsm + fsm_files/rep3.fsm + fsm_files/rep5.fsm + fsm_files/simple.fsm + DESTINATION ${GR_PKG_TRELLIS_EXAMPLES_DIR}/fsm_files + COMPONENT "trellis_examples" +) diff --git a/gr-trellis/src/examples/python/README b/gr-trellis/src/examples/python/README new file mode 100644 index 000000000..bd28e3d61 --- /dev/null +++ b/gr-trellis/src/examples/python/README @@ -0,0 +1,35 @@ +Here we have several test programs for use with the gr-trellis implementation. +Documentation can be found in +http://gnuradio.utah.edu/svn/gnuradio/trunk/gr-trellis/doc/gr-trellis.html + +fsm_utils.py contains several useful functions. + +fsm_files is a directory with some FSM definitions + +If you just want to see what these programs do run them; +in your terminal you will see something like this: + +$ ./test_tcm.py --esn0 6.0 --repetitions 1000 +100 98 9.80e-01 102400 9 8.79e-05 +200 198 9.90e-01 204800 20 9.77e-05 +300 298 9.93e-01 307200 40 1.30e-04 +400 398 9.95e-01 409600 1074 2.62e-03 +500 498 9.96e-01 512000 1081 2.11e-03 +600 598 9.97e-01 614400 1090 1.77e-03 +700 698 9.97e-01 716800 1097 1.53e-03 +800 798 9.98e-01 819200 1107 1.35e-03 +900 898 9.98e-01 921600 1120 1.22e-03 +1000 998 9.98e-01 1024000 1129 1.10e-03 +1000 998 9.98e-01 1024000 1129 1.10e-03 + +which gives you information about the: +number of transmitted packets +number of packets in error +estimated packet error rate +number of transmitted shorts (or symbols, or bits, depending on the specific program) +number of shorts (or symbols, or bits) in error +estimated short (or symbol, or bit) error rate + +for instance, the final number 1.10e-03 is the error rate estimate by sending 1000 +packets of 1024 shorts each, using an 1/2 4-state convolutional code +and QPSK modulation through an AWGN with Es/N0 = 6.0 dB diff --git a/gr-trellis/src/examples/python/fsm_files/awgn1o2_128.fsm b/gr-trellis/src/examples/python/fsm_files/awgn1o2_128.fsm new file mode 100644 index 000000000..bb79c59da --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/awgn1o2_128.fsm @@ -0,0 +1,265 @@ +2 128 4 + +0 64 +0 64 +1 65 +1 65 +2 66 +2 66 +3 67 +3 67 +4 68 +4 68 +5 69 +5 69 +6 70 +6 70 +7 71 +7 71 +8 72 +8 72 +9 73 +9 73 +10 74 +10 74 +11 75 +11 75 +12 76 +12 76 +13 77 +13 77 +14 78 +14 78 +15 79 +15 79 +16 80 +16 80 +17 81 +17 81 +18 82 +18 82 +19 83 +19 83 +20 84 +20 84 +21 85 +21 85 +22 86 +22 86 +23 87 +23 87 +24 88 +24 88 +25 89 +25 89 +26 90 +26 90 +27 91 +27 91 +28 92 +28 92 +29 93 +29 93 +30 94 +30 94 +31 95 +31 95 +32 96 +32 96 +33 97 +33 97 +34 98 +34 98 +35 99 +35 99 +36 100 +36 100 +37 101 +37 101 +38 102 +38 102 +39 103 +39 103 +40 104 +40 104 +41 105 +41 105 +42 106 +42 106 +43 107 +43 107 +44 108 +44 108 +45 109 +45 109 +46 110 +46 110 +47 111 +47 111 +48 112 +48 112 +49 113 +49 113 +50 114 +50 114 +51 115 +51 115 +52 116 +52 116 +53 117 +53 117 +54 118 +54 118 +55 119 +55 119 +56 120 +56 120 +57 121 +57 121 +58 122 +58 122 +59 123 +59 123 +60 124 +60 124 +61 125 +61 125 +62 126 +62 126 +63 127 +63 127 + +0 3 +3 0 +1 2 +2 1 +3 0 +0 3 +2 1 +1 2 +1 2 +2 1 +0 3 +3 0 +2 1 +1 2 +3 0 +0 3 +1 2 +2 1 +0 3 +3 0 +2 1 +1 2 +3 0 +0 3 +0 3 +3 0 +1 2 +2 1 +3 0 +0 3 +2 1 +1 2 +2 1 +1 2 +3 0 +0 3 +1 2 +2 1 +0 3 +3 0 +3 0 +0 3 +2 1 +1 2 +0 3 +3 0 +1 2 +2 1 +3 0 +0 3 +2 1 +1 2 +0 3 +3 0 +1 2 +2 1 +2 1 +1 2 +3 0 +0 3 +1 2 +2 1 +0 3 +3 0 +2 1 +1 2 +3 0 +0 3 +1 2 +2 1 +0 3 +3 0 +3 0 +0 3 +2 1 +1 2 +0 3 +3 0 +1 2 +2 1 +3 0 +0 3 +2 1 +1 2 +0 3 +3 0 +1 2 +2 1 +2 1 +1 2 +3 0 +0 3 +1 2 +2 1 +0 3 +3 0 +0 3 +3 0 +1 2 +2 1 +3 0 +0 3 +2 1 +1 2 +1 2 +2 1 +0 3 +3 0 +2 1 +1 2 +3 0 +0 3 +1 2 +2 1 +0 3 +3 0 +2 1 +1 2 +3 0 +0 3 +0 3 +3 0 +1 2 +2 1 +3 0 +0 3 +2 1 +1 2 + + + +GM1o2_128=[1+D+D^2+D^5+D^7 1+D^3+D^4+D^5+D^6+D^7] + =[11100101 10011111] + =[229 159] diff --git a/gr-trellis/src/examples/python/fsm_files/awgn1o2_16.fsm b/gr-trellis/src/examples/python/fsm_files/awgn1o2_16.fsm new file mode 100644 index 000000000..cdab41359 --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/awgn1o2_16.fsm @@ -0,0 +1,39 @@ +2 16 4 + +0 8 +0 8 +1 9 +1 9 +2 10 +2 10 +3 11 +3 11 +4 12 +4 12 +5 13 +5 13 +6 14 +6 14 +7 15 +7 15 + +0 3 +3 0 +1 2 +2 1 +1 2 +2 1 +0 3 +3 0 +2 1 +1 2 +3 0 +0 3 +3 0 +0 3 +2 1 +1 2 + + + +GM1o2_16=[1+D+D^4 1+D^2+D^3+D^4 ] = [25,23] (decimal) diff --git a/gr-trellis/src/examples/python/fsm_files/awgn1o2_4.fsm b/gr-trellis/src/examples/python/fsm_files/awgn1o2_4.fsm new file mode 100644 index 000000000..fb316b5ef --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/awgn1o2_4.fsm @@ -0,0 +1,14 @@ +2 4 4 + +0 2 +0 2 +1 3 +1 3 + +0 3 +3 0 +1 2 +2 1 + +AWGN CC from Proakis-Salehi pg 779 +GM1o2_4=[1+D^2, 1+D+D^2] = [5, 7] (in decimal); diff --git a/gr-trellis/src/examples/python/fsm_files/awgn1o2_8.fsm b/gr-trellis/src/examples/python/fsm_files/awgn1o2_8.fsm new file mode 100644 index 000000000..604bac6c2 --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/awgn1o2_8.fsm @@ -0,0 +1,24 @@ +2 8 4 + +0 4 +0 4 +1 5 +1 5 +2 6 +2 6 +3 7 +3 7 + + +0 3 +3 0 +1 2 +2 1 +3 0 +0 3 +2 1 +1 2 + + +1/2 8-state code (Proakis pg. 493) +GM1o2_8=[ 1+D+D^3 1+D+D^2+D^3] =[13 , 15] (decimal) diff --git a/gr-trellis/src/examples/python/fsm_files/awgn2o3_16.fsm b/gr-trellis/src/examples/python/fsm_files/awgn2o3_16.fsm new file mode 100644 index 000000000..9630cd9af --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/awgn2o3_16.fsm @@ -0,0 +1,40 @@ +4 16 8 + +0 8 4 12 +0 8 4 12 +0 8 4 12 +0 8 4 12 +1 9 5 13 +1 9 5 13 +1 9 5 13 +1 9 5 13 +2 10 6 14 +2 10 6 14 +2 10 6 14 +2 10 6 14 +3 11 7 15 +3 11 7 15 +3 11 7 15 +3 11 7 15 + +0 1 7 6 +6 7 1 0 +3 2 4 5 +5 4 2 3 +2 3 5 4 +4 5 3 2 +1 0 6 7 +7 6 0 1 +4 5 3 2 +2 3 5 4 +7 6 0 1 +1 0 6 7 +6 7 1 0 +0 1 7 6 +5 4 2 3 +3 2 4 5 + + +2/3 code generated from the awgn 1/2 code with 16 states and puncturing the 4th bit. +d_free= + diff --git a/gr-trellis/src/examples/python/fsm_files/awgn2o3_4.fsm b/gr-trellis/src/examples/python/fsm_files/awgn2o3_4.fsm new file mode 100644 index 000000000..3ac57be18 --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/awgn2o3_4.fsm @@ -0,0 +1,15 @@ +4 4 8 + +0 1 2 3 +0 1 2 3 +0 1 2 3 +0 1 2 3 + +0 7 4 3 +3 4 7 0 +5 2 1 6 +6 1 2 5 + +I don't remeber how I generated this one... +it is a bit better than awgn2o3_4_msb and worse +than awgn2o3_4_msbG. diff --git a/gr-trellis/src/examples/python/fsm_files/awgn2o3_4_msb.fsm b/gr-trellis/src/examples/python/fsm_files/awgn2o3_4_msb.fsm new file mode 100644 index 000000000..551b71101 --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/awgn2o3_4_msb.fsm @@ -0,0 +1,46 @@ +4 4 8 + +0 1 2 3 +0 1 2 3 +0 1 2 3 +0 1 2 3 + +0 5 3 6 +4 1 7 2 +7 2 4 1 +3 6 0 5 + + +This is generated by the 1/2 AWGN code (5 7) operated twice, ie, +(xk+1 xki) [xk-1 xk-2] -> [xk+1 xki]. +We also puncture the first (MSB) bit. +This code is worse than awgn2o3_4_msbG and slightly worse than +awgn2o3_4, BUT seems to be a good innner code for sctcm (with 8PSK natural). + +intermediate states: + +00 21 02 23 +00 21 02 23 +10 31 12 33 +10 31 12 33 + +output before puncturing: + +00 31 03 32 +30 01 33 02 +13 22 10 21 +23 12 20 11 + +output after punturing the MSB: + +00 11 03 12 +10 01 13 02 +13 02 10 01 +03 12 00 11 + +and in decimal: + +0 5 3 6 +4 1 7 2 +7 2 4 1 +3 6 0 5 diff --git a/gr-trellis/src/examples/python/fsm_files/awgn2o3_4_msbG.fsm b/gr-trellis/src/examples/python/fsm_files/awgn2o3_4_msbG.fsm new file mode 100644 index 000000000..8956c53da --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/awgn2o3_4_msbG.fsm @@ -0,0 +1,60 @@ +4 4 8 + +0 1 2 3 +0 1 2 3 +0 1 2 3 +0 1 2 3 + +0 4 2 6 +5 1 3 7 +3 7 5 1 + + +This is generated by the 1/2 AWGN code (5 7) operated twice, ie, +(xk+1 xki) [xk-1 xk-2] -> [xk+1 xki]. +We also puncture the first (MSB) bit and Gray map the symbols. + +intermediate states: + +00 21 02 23 +00 21 02 23 +10 31 12 33 +10 31 12 33 + +output before puncturing: + +00 31 03 32 +30 01 33 02 +13 22 10 21 +23 12 20 11 + +output after punturing the MSB: + +00 11 03 12 +10 01 13 02 +13 02 10 01 +03 12 00 11 + +and in decimal: + +0 5 3 6 +4 1 7 2 +7 2 4 1 +3 6 0 5 + +After Gray mapping: +label -> phase +0 -> 0 +1 -> 0 +2 -> 7 +3 -> 2 +4 -> 5 +5 -> 4 +6 -> 6 +7 -> 3 + +0 4 2 6 +5 1 3 7 +3 7 5 1 +2 6 0 4 + diff --git a/gr-trellis/src/examples/python/fsm_files/awgn2o3_8.fsm b/gr-trellis/src/examples/python/fsm_files/awgn2o3_8.fsm new file mode 100644 index 000000000..34deeb68c --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/awgn2o3_8.fsm @@ -0,0 +1,25 @@ +4 8 8 + +0 4 2 6 +0 4 2 6 +0 4 2 6 +0 4 2 6 +1 5 3 7 +1 5 3 7 +1 5 3 7 +1 5 3 7 + + +0 1 7 6 +6 7 1 0 +3 2 4 5 +5 4 2 3 +6 7 1 0 +0 1 7 6 +5 4 2 3 +3 2 4 5 + + + +This is generated by the 1/2 8-state AWGN code (15 17) by puncturing the fourth bit. +--> d_free=??? diff --git a/gr-trellis/src/examples/python/fsm_files/awgn2o4_4.fsm b/gr-trellis/src/examples/python/fsm_files/awgn2o4_4.fsm new file mode 100644 index 000000000..a895be896 --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/awgn2o4_4.fsm @@ -0,0 +1,36 @@ +4 4 16 + +0 1 2 3 +0 1 2 3 +0 1 2 3 +0 1 2 3 + + 0 13 3 14 +12 1 15 2 + 7 10 4 9 +11 6 8 5 + + +This is generated by the 1/2 AWGN code (5 7) operated twice, ie, +(xk+1 xki) [xk-1 xk-2] -> [xk+1 xki]. + +intermediate states: + +00 21 02 23 +00 21 02 23 +10 31 12 33 +10 31 12 33 + +output: + +00 31 03 32 +30 01 33 02 +13 22 10 21 +23 12 20 11 + +and in decimal: + + 0 13 3 14 +12 1 15 2 + 7 10 4 9 +11 6 8 5 diff --git a/gr-trellis/src/examples/python/fsm_files/disconnected.fsm b/gr-trellis/src/examples/python/fsm_files/disconnected.fsm new file mode 100644 index 000000000..847963e7b --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/disconnected.fsm @@ -0,0 +1,11 @@ +1 4 1 + +1 +0 +3 +2 + +0 +0 +0 +0 diff --git a/gr-trellis/src/examples/python/fsm_files/irregular.fsm b/gr-trellis/src/examples/python/fsm_files/irregular.fsm new file mode 100644 index 000000000..80b82b889 --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/irregular.fsm @@ -0,0 +1,11 @@ +2 2 2 + +0 0 +0 1 + +0 1 +0 1 + + +useless irregular FSM for testing. state 0 has 3 incoming edges and state +1 has 1 incoming edge. diff --git a/gr-trellis/src/examples/python/fsm_files/joint_16_16.fsm b/gr-trellis/src/examples/python/fsm_files/joint_16_16.fsm new file mode 100644 index 000000000..3dae314b6 --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/joint_16_16.fsm @@ -0,0 +1,523 @@ +4 256 16 + +0 8 128 136 +0 8 128 136 +1 9 129 137 +1 9 129 137 +2 10 130 138 +2 10 130 138 +3 11 131 139 +3 11 131 139 +4 12 132 140 +4 12 132 140 +5 13 133 141 +5 13 133 141 +6 14 134 142 +6 14 134 142 +7 15 135 143 +7 15 135 143 +0 8 128 136 +0 8 128 136 +1 9 129 137 +1 9 129 137 +2 10 130 138 +2 10 130 138 +3 11 131 139 +3 11 131 139 +4 12 132 140 +4 12 132 140 +5 13 133 141 +5 13 133 141 +6 14 134 142 +6 14 134 142 +7 15 135 143 +7 15 135 143 +16 24 144 152 +16 24 144 152 +17 25 145 153 +17 25 145 153 +18 26 146 154 +18 26 146 154 +19 27 147 155 +19 27 147 155 +20 28 148 156 +20 28 148 156 +21 29 149 157 +21 29 149 157 +22 30 150 158 +22 30 150 158 +23 31 151 159 +23 31 151 159 +16 24 144 152 +16 24 144 152 +17 25 145 153 +17 25 145 153 +18 26 146 154 +18 26 146 154 +19 27 147 155 +19 27 147 155 +20 28 148 156 +20 28 148 156 +21 29 149 157 +21 29 149 157 +22 30 150 158 +22 30 150 158 +23 31 151 159 +23 31 151 159 +32 40 160 168 +32 40 160 168 +33 41 161 169 +33 41 161 169 +34 42 162 170 +34 42 162 170 +35 43 163 171 +35 43 163 171 +36 44 164 172 +36 44 164 172 +37 45 165 173 +37 45 165 173 +38 46 166 174 +38 46 166 174 +39 47 167 175 +39 47 167 175 +32 40 160 168 +32 40 160 168 +33 41 161 169 +33 41 161 169 +34 42 162 170 +34 42 162 170 +35 43 163 171 +35 43 163 171 +36 44 164 172 +36 44 164 172 +37 45 165 173 +37 45 165 173 +38 46 166 174 +38 46 166 174 +39 47 167 175 +39 47 167 175 +48 56 176 184 +48 56 176 184 +49 57 177 185 +49 57 177 185 +50 58 178 186 +50 58 178 186 +51 59 179 187 +51 59 179 187 +52 60 180 188 +52 60 180 188 +53 61 181 189 +53 61 181 189 +54 62 182 190 +54 62 182 190 +55 63 183 191 +55 63 183 191 +48 56 176 184 +48 56 176 184 +49 57 177 185 +49 57 177 185 +50 58 178 186 +50 58 178 186 +51 59 179 187 +51 59 179 187 +52 60 180 188 +52 60 180 188 +53 61 181 189 +53 61 181 189 +54 62 182 190 +54 62 182 190 +55 63 183 191 +55 63 183 191 +64 72 192 200 +64 72 192 200 +65 73 193 201 +65 73 193 201 +66 74 194 202 +66 74 194 202 +67 75 195 203 +67 75 195 203 +68 76 196 204 +68 76 196 204 +69 77 197 205 +69 77 197 205 +70 78 198 206 +70 78 198 206 +71 79 199 207 +71 79 199 207 +64 72 192 200 +64 72 192 200 +65 73 193 201 +65 73 193 201 +66 74 194 202 +66 74 194 202 +67 75 195 203 +67 75 195 203 +68 76 196 204 +68 76 196 204 +69 77 197 205 +69 77 197 205 +70 78 198 206 +70 78 198 206 +71 79 199 207 +71 79 199 207 +80 88 208 216 +80 88 208 216 +81 89 209 217 +81 89 209 217 +82 90 210 218 +82 90 210 218 +83 91 211 219 +83 91 211 219 +84 92 212 220 +84 92 212 220 +85 93 213 221 +85 93 213 221 +86 94 214 222 +86 94 214 222 +87 95 215 223 +87 95 215 223 +80 88 208 216 +80 88 208 216 +81 89 209 217 +81 89 209 217 +82 90 210 218 +82 90 210 218 +83 91 211 219 +83 91 211 219 +84 92 212 220 +84 92 212 220 +85 93 213 221 +85 93 213 221 +86 94 214 222 +86 94 214 222 +87 95 215 223 +87 95 215 223 +96 104 224 232 +96 104 224 232 +97 105 225 233 +97 105 225 233 +98 106 226 234 +98 106 226 234 +99 107 227 235 +99 107 227 235 +100 108 228 236 +100 108 228 236 +101 109 229 237 +101 109 229 237 +102 110 230 238 +102 110 230 238 +103 111 231 239 +103 111 231 239 +96 104 224 232 +96 104 224 232 +97 105 225 233 +97 105 225 233 +98 106 226 234 +98 106 226 234 +99 107 227 235 +99 107 227 235 +100 108 228 236 +100 108 228 236 +101 109 229 237 +101 109 229 237 +102 110 230 238 +102 110 230 238 +103 111 231 239 +103 111 231 239 +112 120 240 248 +112 120 240 248 +113 121 241 249 +113 121 241 249 +114 122 242 250 +114 122 242 250 +115 123 243 251 +115 123 243 251 +116 124 244 252 +116 124 244 252 +117 125 245 253 +117 125 245 253 +118 126 246 254 +118 126 246 254 +119 127 247 255 +119 127 247 255 +112 120 240 248 +112 120 240 248 +113 121 241 249 +113 121 241 249 +114 122 242 250 +114 122 242 250 +115 123 243 251 +115 123 243 251 +116 124 244 252 +116 124 244 252 +117 125 245 253 +117 125 245 253 +118 126 246 254 +118 126 246 254 +119 127 247 255 +119 127 247 255 + +0 3 12 15 +3 0 15 12 +1 2 13 14 +2 1 14 13 +1 2 13 14 +2 1 14 13 +0 3 12 15 +3 0 15 12 +2 1 14 13 +1 2 13 14 +3 0 15 12 +0 3 12 15 +3 0 15 12 +0 3 12 15 +2 1 14 13 +1 2 13 14 +12 15 0 3 +15 12 3 0 +13 14 1 2 +14 13 2 1 +13 14 1 2 +14 13 2 1 +12 15 0 3 +15 12 3 0 +14 13 2 1 +13 14 1 2 +15 12 3 0 +12 15 0 3 +15 12 3 0 +12 15 0 3 +14 13 2 1 +13 14 1 2 +4 7 8 11 +7 4 11 8 +5 6 9 10 +6 5 10 9 +5 6 9 10 +6 5 10 9 +4 7 8 11 +7 4 11 8 +6 5 10 9 +5 6 9 10 +7 4 11 8 +4 7 8 11 +7 4 11 8 +4 7 8 11 +6 5 10 9 +5 6 9 10 +8 11 4 7 +11 8 7 4 +9 10 5 6 +10 9 6 5 +9 10 5 6 +10 9 6 5 +8 11 4 7 +11 8 7 4 +10 9 6 5 +9 10 5 6 +11 8 7 4 +8 11 4 7 +11 8 7 4 +8 11 4 7 +10 9 6 5 +9 10 5 6 +4 7 8 11 +7 4 11 8 +5 6 9 10 +6 5 10 9 +5 6 9 10 +6 5 10 9 +4 7 8 11 +7 4 11 8 +6 5 10 9 +5 6 9 10 +7 4 11 8 +4 7 8 11 +7 4 11 8 +4 7 8 11 +6 5 10 9 +5 6 9 10 +8 11 4 7 +11 8 7 4 +9 10 5 6 +10 9 6 5 +9 10 5 6 +10 9 6 5 +8 11 4 7 +11 8 7 4 +10 9 6 5 +9 10 5 6 +11 8 7 4 +8 11 4 7 +11 8 7 4 +8 11 4 7 +10 9 6 5 +9 10 5 6 +0 3 12 15 +3 0 15 12 +1 2 13 14 +2 1 14 13 +1 2 13 14 +2 1 14 13 +0 3 12 15 +3 0 15 12 +2 1 14 13 +1 2 13 14 +3 0 15 12 +0 3 12 15 +3 0 15 12 +0 3 12 15 +2 1 14 13 +1 2 13 14 +12 15 0 3 +15 12 3 0 +13 14 1 2 +14 13 2 1 +13 14 1 2 +14 13 2 1 +12 15 0 3 +15 12 3 0 +14 13 2 1 +13 14 1 2 +15 12 3 0 +12 15 0 3 +15 12 3 0 +12 15 0 3 +14 13 2 1 +13 14 1 2 +8 11 4 7 +11 8 7 4 +9 10 5 6 +10 9 6 5 +9 10 5 6 +10 9 6 5 +8 11 4 7 +11 8 7 4 +10 9 6 5 +9 10 5 6 +11 8 7 4 +8 11 4 7 +11 8 7 4 +8 11 4 7 +10 9 6 5 +9 10 5 6 +4 7 8 11 +7 4 11 8 +5 6 9 10 +6 5 10 9 +5 6 9 10 +6 5 10 9 +4 7 8 11 +7 4 11 8 +6 5 10 9 +5 6 9 10 +7 4 11 8 +4 7 8 11 +7 4 11 8 +4 7 8 11 +6 5 10 9 +5 6 9 10 +12 15 0 3 +15 12 3 0 +13 14 1 2 +14 13 2 1 +13 14 1 2 +14 13 2 1 +12 15 0 3 +15 12 3 0 +14 13 2 1 +13 14 1 2 +15 12 3 0 +12 15 0 3 +15 12 3 0 +12 15 0 3 +14 13 2 1 +13 14 1 2 +0 3 12 15 +3 0 15 12 +1 2 13 14 +2 1 14 13 +1 2 13 14 +2 1 14 13 +0 3 12 15 +3 0 15 12 +2 1 14 13 +1 2 13 14 +3 0 15 12 +0 3 12 15 +3 0 15 12 +0 3 12 15 +2 1 14 13 +1 2 13 14 +12 15 0 3 +15 12 3 0 +13 14 1 2 +14 13 2 1 +13 14 1 2 +14 13 2 1 +12 15 0 3 +15 12 3 0 +14 13 2 1 +13 14 1 2 +15 12 3 0 +12 15 0 3 +15 12 3 0 +12 15 0 3 +14 13 2 1 +13 14 1 2 +0 3 12 15 +3 0 15 12 +1 2 13 14 +2 1 14 13 +1 2 13 14 +2 1 14 13 +0 3 12 15 +3 0 15 12 +2 1 14 13 +1 2 13 14 +3 0 15 12 +0 3 12 15 +3 0 15 12 +0 3 12 15 +2 1 14 13 +1 2 13 14 +8 11 4 7 +11 8 7 4 +9 10 5 6 +10 9 6 5 +9 10 5 6 +10 9 6 5 +8 11 4 7 +11 8 7 4 +10 9 6 5 +9 10 5 6 +11 8 7 4 +8 11 4 7 +11 8 7 4 +8 11 4 7 +10 9 6 5 +9 10 5 6 +4 7 8 11 +7 4 11 8 +5 6 9 10 +6 5 10 9 +5 6 9 10 +6 5 10 9 +4 7 8 11 +7 4 11 8 +6 5 10 9 +5 6 9 10 +7 4 11 8 +4 7 8 11 +7 4 11 8 +4 7 8 11 +6 5 10 9 +5 6 9 10 + +This is the joint trellis of two trellises described in awgn1o2_16.fsm +It is useful for application of joint decoding... +It can be generated in python as follows: +> import trellis +> f1=trellis.fsm('awgn1o2_16.fsm') +> f=trellis.fsm(f1,f1) +> f.write_fsm_txt('joint_16_16.fsm') diff --git a/gr-trellis/src/examples/python/fsm_files/joint_4_16.fsm b/gr-trellis/src/examples/python/fsm_files/joint_4_16.fsm new file mode 100644 index 000000000..8f2cdab81 --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/joint_4_16.fsm @@ -0,0 +1,141 @@ +4 64 16 + +0 8 32 40 +0 8 32 40 +1 9 33 41 +1 9 33 41 +2 10 34 42 +2 10 34 42 +3 11 35 43 +3 11 35 43 +4 12 36 44 +4 12 36 44 +5 13 37 45 +5 13 37 45 +6 14 38 46 +6 14 38 46 +7 15 39 47 +7 15 39 47 +0 8 32 40 +0 8 32 40 +1 9 33 41 +1 9 33 41 +2 10 34 42 +2 10 34 42 +3 11 35 43 +3 11 35 43 +4 12 36 44 +4 12 36 44 +5 13 37 45 +5 13 37 45 +6 14 38 46 +6 14 38 46 +7 15 39 47 +7 15 39 47 +16 24 48 56 +16 24 48 56 +17 25 49 57 +17 25 49 57 +18 26 50 58 +18 26 50 58 +19 27 51 59 +19 27 51 59 +20 28 52 60 +20 28 52 60 +21 29 53 61 +21 29 53 61 +22 30 54 62 +22 30 54 62 +23 31 55 63 +23 31 55 63 +16 24 48 56 +16 24 48 56 +17 25 49 57 +17 25 49 57 +18 26 50 58 +18 26 50 58 +19 27 51 59 +19 27 51 59 +20 28 52 60 +20 28 52 60 +21 29 53 61 +21 29 53 61 +22 30 54 62 +22 30 54 62 +23 31 55 63 +23 31 55 63 + +0 3 12 15 +3 0 15 12 +1 2 13 14 +2 1 14 13 +1 2 13 14 +2 1 14 13 +0 3 12 15 +3 0 15 12 +2 1 14 13 +1 2 13 14 +3 0 15 12 +0 3 12 15 +3 0 15 12 +0 3 12 15 +2 1 14 13 +1 2 13 14 +12 15 0 3 +15 12 3 0 +13 14 1 2 +14 13 2 1 +13 14 1 2 +14 13 2 1 +12 15 0 3 +15 12 3 0 +14 13 2 1 +13 14 1 2 +15 12 3 0 +12 15 0 3 +15 12 3 0 +12 15 0 3 +14 13 2 1 +13 14 1 2 +4 7 8 11 +7 4 11 8 +5 6 9 10 +6 5 10 9 +5 6 9 10 +6 5 10 9 +4 7 8 11 +7 4 11 8 +6 5 10 9 +5 6 9 10 +7 4 11 8 +4 7 8 11 +7 4 11 8 +4 7 8 11 +6 5 10 9 +5 6 9 10 +8 11 4 7 +11 8 7 4 +9 10 5 6 +10 9 6 5 +9 10 5 6 +10 9 6 5 +8 11 4 7 +11 8 7 4 +10 9 6 5 +9 10 5 6 +11 8 7 4 +8 11 4 7 +11 8 7 4 +8 11 4 7 +10 9 6 5 +9 10 5 6 + +This is the joint trellis of two trellises described in awgn1o2_4.fsm and awgn1o2_16.fsm +It is useful for application of joint decoding... +It can be generated in python as follows: +> import trellis +> f1=trellis.fsm('awgn1o2_4.fsm') +> f2=trellis.fsm('awgn1o2_16.fsm') +> f=trellis.fsm(f1,f2) +> f.write_fsm_txt('joint_4_16.fsm') + diff --git a/gr-trellis/src/examples/python/fsm_files/rep3.fsm b/gr-trellis/src/examples/python/fsm_files/rep3.fsm new file mode 100644 index 000000000..ef1bd1f02 --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/rep3.fsm @@ -0,0 +1,8 @@ +2 1 8 + +0 0 + +0 7 + +1/3 repetition code (with binary input). +There is only one state, since this is essentially a memoryless system. diff --git a/gr-trellis/src/examples/python/fsm_files/rep5.fsm b/gr-trellis/src/examples/python/fsm_files/rep5.fsm new file mode 100644 index 000000000..2aa5d77cf --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/rep5.fsm @@ -0,0 +1,7 @@ +2 1 32 + +0 0 + +0 31 + +1/5 repetition code diff --git a/gr-trellis/src/examples/python/fsm_files/simple.fsm b/gr-trellis/src/examples/python/fsm_files/simple.fsm new file mode 100644 index 000000000..f27f6b4b0 --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_files/simple.fsm @@ -0,0 +1,13 @@ +1 4 1 + +1 +2 +3 +0 + +0 +0 +0 +0 + +essentially this fsm has no inputs and no outputs; it just cycles through all 4 states. diff --git a/gr-trellis/src/examples/python/fsm_utils.py b/gr-trellis/src/examples/python/fsm_utils.py new file mode 100755 index 000000000..e9243f899 --- /dev/null +++ b/gr-trellis/src/examples/python/fsm_utils.py @@ -0,0 +1,239 @@ +#!/usr/bin/env python +# +# Copyright 2004 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + + +import re +import math +import sys +import operator +import numpy + +from gnuradio import trellis + +try: + import scipy.linalg +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) + + + +###################################################################### +# Decimal to any base conversion. +# Convert 'num' to a list of 'l' numbers representing 'num' +# to base 'base' (most significant symbol first). +###################################################################### +def dec2base(num,base,l): + s=range(l) + n=num + for i in range(l): + s[l-i-1]=n%base + n=int(n/base) + if n!=0: + print 'Number ', num, ' requires more than ', l, 'digits.' + return s + + +###################################################################### +# Conversion from any base to decimal. +# Convert a list 's' of symbols to a decimal number +# (most significant symbol first) +###################################################################### +def base2dec(s,base): + num=0 + for i in range(len(s)): + num=num*base+s[i] + return num + + + + +###################################################################### +# Automatically generate the lookup table that maps the FSM outputs +# to channel inputs corresponding to a channel 'channel' and a modulation +# 'mod'. Optional normalization of channel to unit energy. +# This table is used by the 'metrics' block to translate +# channel outputs to metrics for use with the Viterbi algorithm. +# Limitations: currently supports only one-dimensional modulations. +###################################################################### +def make_isi_lookup(mod,channel,normalize): + dim=mod[0] + constellation = mod[1] + + if normalize: + p = 0 + for i in range(len(channel)): + p = p + channel[i]**2 + for i in range(len(channel)): + channel[i] = channel[i]/math.sqrt(p) + + lookup=range(len(constellation)**len(channel)) + for o in range(len(constellation)**len(channel)): + ss=dec2base(o,len(constellation),len(channel)) + ll=0 + for i in range(len(channel)): + ll=ll+constellation[ss[i]]*channel[i] + lookup[o]=ll + return (1,lookup) + + + + + + +###################################################################### +# Automatically generate the signals appropriate for CPM +# decomposition. +# This decomposition is based on the paper by B. Rimoldi +# "A decomposition approach to CPM", IEEE Trans. Info Theory, March 1988 +# See also my own notes at http://www.eecs.umich.edu/~anastas/docs/cpm.pdf +###################################################################### +def make_cpm_signals(K,P,M,L,q,frac): + + Q=numpy.size(q)/L + h=(1.0*K)/P + f0=-h*(M-1)/2 + dt=0.0; # maybe start at t=0.5 + t=(dt+numpy.arange(0,Q))/Q + qq=numpy.zeros(Q) + for m in range(L): + qq=qq + q[m*Q:m*Q+Q] + w=math.pi*h*(M-1)*t-2*math.pi*h*(M-1)*qq+math.pi*h*(L-1)*(M-1) + + X=(M**L)*P + PSI=numpy.empty((X,Q)) + for x in range(X): + xv=dec2base(x/P,M,L) + xv=numpy.append(xv, x%P) + qq1=numpy.zeros(Q) + for m in range(L): + qq1=qq1+xv[m]*q[m*Q:m*Q+Q] + psi=2*math.pi*h*xv[-1]+4*math.pi*h*qq1+w + #print psi + PSI[x]=psi + PSI = numpy.transpose(PSI) + SS=numpy.exp(1j*PSI) # contains all signals as columns + #print SS + + + # Now we need to orthogonalize the signals + F = scipy.linalg.orth(SS) # find an orthonormal basis for SS + #print numpy.dot(numpy.transpose(F.conjugate()),F) # check for orthonormality + S = numpy.dot(numpy.transpose(F.conjugate()),SS) + #print F + #print S + + # We only want to keep those dimensions that contain most + # of the energy of the overall constellation (eg, frac=0.9 ==> 90%) + # evaluate mean energy in each dimension + E=numpy.sum(numpy.absolute(S)**2,axis=1)/Q + E=E/numpy.sum(E) + #print E + Es = -numpy.sort(-E) + Esi = numpy.argsort(-E) + #print Es + #print Esi + Ecum=numpy.cumsum(Es) + #print Ecum + v0=numpy.searchsorted(Ecum,frac) + N = v0+1 + #print v0 + #print Esi[0:v0+1] + Ff=numpy.transpose(numpy.transpose(F)[Esi[0:v0+1]]) + #print Ff + Sf = S[Esi[0:v0+1]] + #print Sf + + + return (f0,SS,S,F,Sf,Ff,N) + #return f0 + + + + +###################################################################### +# A list of common modulations. +# Format: (dimensionality,constellation) +###################################################################### +pam2 = (1,[-1, 1]) +pam4 = (1,[-3, -1, 3, 1]) # includes Gray mapping +pam8 = (1,[-7, -5, -3, -1, 1, 3, 5, 7]) + +psk4=(2,[1, 0, \ + 0, 1, \ + 0, -1,\ + -1, 0]) # includes Gray mapping +psk8=(2,[math.cos(2*math.pi*0/8), math.sin(2*math.pi*0/8), \ + math.cos(2*math.pi*1/8), math.sin(2*math.pi*1/8), \ + math.cos(2*math.pi*2/8), math.sin(2*math.pi*2/8), \ + math.cos(2*math.pi*3/8), math.sin(2*math.pi*3/8), \ + math.cos(2*math.pi*4/8), math.sin(2*math.pi*4/8), \ + math.cos(2*math.pi*5/8), math.sin(2*math.pi*5/8), \ + math.cos(2*math.pi*6/8), math.sin(2*math.pi*6/8), \ + math.cos(2*math.pi*7/8), math.sin(2*math.pi*7/8)]) + +orth2 = (2,[1, 0, \ + 0, 1]) +orth4=(4,[1, 0, 0, 0, \ + 0, 1, 0, 0, \ + 0, 0, 1, 0, \ + 0, 0, 0, 1]) + +###################################################################### +# A list of channels to be tested +###################################################################### + +# C test channel (J. Proakis, Digital Communications, McGraw-Hill Inc., 2001) +c_channel = [0.227, 0.460, 0.688, 0.460, 0.227] + + + + + + + + + + +if __name__ == '__main__': + f1=trellis.fsm('fsm_files/awgn1o2_4.fsm') + #f2=trellis.fsm('fsm_files/awgn2o3_4.fsm') + #print f1.I(), f1.S(), f1.O() + #print f1.NS() + #print f1.OS() + #print f2.I(), f2.S(), f2.O() + #print f2.NS() + #print f2.OS() + ##f1.write_trellis_svg('f1.svg',4) + #f2.write_trellis_svg('f2.svg',4) + #f=fsm_concatenate(f1,f2) + #f=fsm_radix(f1,2) + + #print "----------\n" + #print f.I(), f.S(), f.O() + #print f.NS() + #print f.OS() + #f.write_trellis_svg('f.svg',4) + + q=numpy.arange(0,8)/(2.0*8) + (f0,SS,S,F,Sf,Ff,N) = make_cpm_signals(1,2,2,1,q,0.99) + diff --git a/gr-trellis/src/examples/python/test_cpm.py b/gr-trellis/src/examples/python/test_cpm.py new file mode 100755 index 000000000..06d54b1a6 --- /dev/null +++ b/gr-trellis/src/examples/python/test_cpm.py @@ -0,0 +1,154 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: CPM test +# Author: Achilleas Anastasopoulos +# Description: gnuradio flow graph +# Generated: Thu Feb 19 23:16:23 2009 +################################################## + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio.gr import firdes +from grc_gnuradio import blks2 as grc_blks2 +import math +import numpy +import fsm_utils +from gnuradio import trellis + +try: + import scipy.stats +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) + +def run_test(seed,blocksize): + tb = gr.top_block() + + ################################################## + # Variables + ################################################## + M = 2 + K = 1 + P = 2 + h = (1.0*K)/P + L = 3 + Q = 4 + frac = 0.99 + f = trellis.fsm(P,M,L) + + # CPFSK signals + #p = numpy.ones(Q)/(2.0) + #q = numpy.cumsum(p)/(1.0*Q) + + # GMSK signals + BT=0.3; + tt=numpy.arange(0,L*Q)/(1.0*Q)-L/2.0; + #print tt + p=(0.5*scipy.stats.erfc(2*math.pi*BT*(tt-0.5)/math.sqrt(math.log(2.0))/math.sqrt(2.0))-0.5*scipy.stats.erfc(2*math.pi*BT*(tt+0.5)/math.sqrt(math.log(2.0))/math.sqrt(2.0)))/2.0; + p=p/sum(p)*Q/2.0; + #print p + q=numpy.cumsum(p)/Q; + q=q/q[-1]/2.0; + #print q + + (f0T,SS,S,F,Sf,Ff,N) = fsm_utils.make_cpm_signals(K,P,M,L,q,frac) + #print N + #print Ff + Ffa = numpy.insert(Ff,Q,numpy.zeros(N),axis=0) + #print Ffa + MF = numpy.fliplr(numpy.transpose(Ffa)) + #print MF + E = numpy.sum(numpy.abs(Sf)**2,axis=0) + Es = numpy.sum(E)/f.O() + #print Es + + constellation = numpy.reshape(numpy.transpose(Sf),N*f.O()) + #print Ff + #print Sf + #print constellation + #print numpy.max(numpy.abs(SS - numpy.dot(Ff , Sf))) + + EsN0_db = 10.0 + N0 = Es * 10.0**(-(1.0*EsN0_db)/10.0) + #N0 = 0.0 + #print N0 + head = 4 + tail = 4 + numpy.random.seed(seed*666) + data = numpy.random.randint(0, M, head+blocksize+tail+1) + #data = numpy.zeros(blocksize+1+head+tail,'int') + for i in range(head): + data[i]=0 + for i in range(tail+1): + data[-i]=0 + + + + ################################################## + # Blocks + ################################################## + random_source_x_0 = gr.vector_source_b(data.tolist(), False) + gr_chunks_to_symbols_xx_0 = gr.chunks_to_symbols_bf((-1, 1), 1) + gr_interp_fir_filter_xxx_0 = gr.interp_fir_filter_fff(Q, p) + gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc(2*math.pi*h*(1.0/Q)) + + gr_add_vxx_0 = gr.add_vcc(1) + gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, (N0/2.0)**0.5, -long(seed)) + + gr_multiply_vxx_0 = gr.multiply_vcc(1) + gr_sig_source_x_0 = gr.sig_source_c(Q, gr.GR_COS_WAVE, -f0T, 1, 0) + # only works for N=2, do it manually for N>2... + gr_fir_filter_xxx_0_0 = gr.fir_filter_ccc(Q, MF[0].conjugate()) + gr_fir_filter_xxx_0_0_0 = gr.fir_filter_ccc(Q, MF[1].conjugate()) + gr_streams_to_stream_0 = gr.streams_to_stream(gr.sizeof_gr_complex*1, int(N)) + gr_skiphead_0 = gr.skiphead(gr.sizeof_gr_complex*1, int(N*(1+0))) + viterbi = trellis.viterbi_combined_cb(f, head+blocksize+tail, 0, -1, int(N), + constellation, digital.TRELLIS_EUCLIDEAN) + + gr_vector_sink_x_0 = gr.vector_sink_b() + + ################################################## + # Connections + ################################################## + tb.connect((random_source_x_0, 0), (gr_chunks_to_symbols_xx_0, 0)) + tb.connect((gr_chunks_to_symbols_xx_0, 0), (gr_interp_fir_filter_xxx_0, 0)) + tb.connect((gr_interp_fir_filter_xxx_0, 0), (gr_frequency_modulator_fc_0, 0)) + tb.connect((gr_frequency_modulator_fc_0, 0), (gr_add_vxx_0, 0)) + tb.connect((gr_noise_source_x_0, 0), (gr_add_vxx_0, 1)) + tb.connect((gr_add_vxx_0, 0), (gr_multiply_vxx_0, 0)) + tb.connect((gr_sig_source_x_0, 0), (gr_multiply_vxx_0, 1)) + tb.connect((gr_multiply_vxx_0, 0), (gr_fir_filter_xxx_0_0, 0)) + tb.connect((gr_multiply_vxx_0, 0), (gr_fir_filter_xxx_0_0_0, 0)) + tb.connect((gr_fir_filter_xxx_0_0, 0), (gr_streams_to_stream_0, 0)) + tb.connect((gr_fir_filter_xxx_0_0_0, 0), (gr_streams_to_stream_0, 1)) + tb.connect((gr_streams_to_stream_0, 0), (gr_skiphead_0, 0)) + tb.connect((gr_skiphead_0, 0), (viterbi, 0)) + tb.connect((viterbi, 0), (gr_vector_sink_x_0, 0)) + + + tb.run() + dataest = gr_vector_sink_x_0.data() + #print data + #print numpy.array(dataest) + perr = 0 + err = 0 + for i in range(blocksize): + if data[head+i] != dataest[head+i]: + #print i + err += 1 + if err != 0 : + perr = 1 + return (err,perr) + +if __name__ == '__main__': + blocksize = 1000 + ss=0 + ee=0 + for i in range(10000): + (s,e) = run_test(i,blocksize) + ss += s + ee += e + if (i+1) % 100 == 0: + print i+1,ss,ee,(1.0*ss)/(i+1)/(1.0*blocksize),(1.0*ee)/(i+1) + print i+1,ss,ee,(1.0*ss)/(i+1)/(1.0*blocksize),(1.0*ee)/(i+1) diff --git a/gr-trellis/src/examples/python/test_pccc_turbo1.py b/gr-trellis/src/examples/python/test_pccc_turbo1.py new file mode 100755 index 000000000..7f1ea26ae --- /dev/null +++ b/gr-trellis/src/examples/python/test_pccc_turbo1.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import random +import fsm_utils + + +def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,seed): + tb = gr.top_block () + + + # TX + src = gr.lfsr_32k_source_s() + src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality + #src = gr.vector_source_s([0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1],False) + enc = trellis.pccc_encoder_ss(fo,0,fi,0,interleaver,K) + code = gr.vector_sink_s() + mod = gr.chunks_to_symbols_sf(constellation,dimensionality) + + # CHANNEL + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + metrics_in = trellis.metrics_f(fi.O()*fo.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO + scale = gr.multiply_const_ff(1.0/N0) + dec = trellis.pccc_decoder_s(fo,0,-1,fi,0,-1,interleaver,K,IT,trellis.TRELLIS_MIN_SUM) + + fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts + dst = gr.check_lfsr_32k_s() + + tb.connect (src,src_head,s2fsmi,enc,mod) + #tb.connect (src,enc,mod) + #tb.connect(enc,code) + tb.connect (mod,(add,0)) + tb.connect (noise,(add,1)) + tb.connect (add,metrics_in,scale,dec,fsmi2s,dst) + + tb.run() + + #print code.data() + + ntotal = dst.ntotal () + nright = dst.nright () + runlength = dst.runlength () + return (ntotal,ntotal-nright) + + +def main(args): + nargs = len (args) + if nargs == 5: + fname_out=args[0] + fname_in=args[1] + esn0_db=float(args[2]) # Es/No in dB + IT=int(args[3]) + rep=int(args[4]) # number of times the experiment is run to collect enough errors + else: + sys.stderr.write ('usage: test_pccc_turbo.py fsm_name_1 fsm_fname_2 Es/No_db iterations repetitions\n') + sys.exit (1) + + # system parameters + Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) + fo=trellis.fsm(fname_out) # get the outer FSM specification from a file + fi=trellis.fsm(fname_in) # get the innner FSM specification from a file + bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol + if fo.I() != fi.I(): + sys.stderr.write ('Incompatible input cardinality between two FSMs.\n') + sys.exit (1) + K=Kb/bitspersymbol # packet size in trellis steps + interleaver=trellis.interleaver(K,666) # construct a random interleaver + #modulation = fsm_utils.psk8 # see fsm_utlis.py for available predefined modulations + dimensionality = 4 + constellation = [ 1, 0, 1, 0,\ + 1, 0,-1, 0,\ + 1, 0, 0, 1,\ + 1, 0, 0,-1,\ + -1, 0, 1, 0,\ + -1, 0,-1, 0,\ + -1, 0, 0, 1,\ + -1, 0, 0,-1,\ + 0, 1, 1, 0,\ + 0, 1,-1, 0,\ + 0, 1, 0, 1,\ + 0, 1, 0,-1,\ + 0,-1, 1, 0,\ + 0,-1,-1, 0,\ + 0,-1, 0, 1,\ + 0,-1, 0,-1,] # equivalent to 2 QPSK symbols + if len(constellation)/dimensionality != fi.O()*fo.O(): + sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') + sys.exit (1) + # calculate average symbol energy + Es = 0 + for i in range(len(constellation)): + Es = Es + constellation[i]**2 + Es = Es / (len(constellation)/dimensionality) + N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + for i in range(rep): + (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%10==0): # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + +if __name__ == '__main__': + main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/python/test_sccc_hard.py b/gr-trellis/src/examples/python/test_sccc_hard.py new file mode 100755 index 000000000..e732ac2c0 --- /dev/null +++ b/gr-trellis/src/examples/python/test_sccc_hard.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import random +import fsm_utils + +def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): + tb = gr.top_block () + + + # TX + src = gr.lfsr_32k_source_s() + src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality + enc_out = trellis.encoder_ss(fo,0) # initial state = 0 + inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) + enc_in = trellis.encoder_ss(fi,0) # initial state = 0 + mod = gr.chunks_to_symbols_sf(constellation,dimensionality) + + # CHANNEL + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + metrics_in = trellis.metrics_f(fi.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner Viterbi + va_in = trellis.viterbi_s(fi,K,0,-1) # Put -1 if the Initial/Final states are not set. + deinter = trellis.permutation(interleaver.K(),interleaver.DEINTER(),1,gr.sizeof_short) + metrics_out = trellis.metrics_s(fo.O(),1,[0,1,2,3],digital.TRELLIS_HARD_SYMBOL) # data preprocessing to generate metrics for outer Viterbi (hard decisions) + va_out = trellis.viterbi_s(fo,K,0,-1) # Put -1 if the Initial/Final states are not set. + fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts + dst = gr.check_lfsr_32k_s() + + tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) + tb.connect (mod,(add,0)) + tb.connect (noise,(add,1)) + tb.connect (add,metrics_in) + tb.connect (metrics_in,va_in,deinter,metrics_out,va_out,fsmi2s,dst) + + tb.run() + + ntotal = dst.ntotal () + nright = dst.nright () + runlength = dst.runlength () + return (ntotal,ntotal-nright) + + +def main(args): + nargs = len (args) + if nargs == 4: + fname_out=args[0] + fname_in=args[1] + esn0_db=float(args[2]) # Es/No in dB + rep=int(args[3]) # number of times the experiment is run to collect enough errors + else: + sys.stderr.write ('usage: test_tcm.py fsm_name_out fsm_fname_in Es/No_db repetitions\n') + sys.exit (1) + + # system parameters + Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) + fo=trellis.fsm(fname_out) # get the outer FSM specification from a file + fi=trellis.fsm(fname_in) # get the innner FSM specification from a file + bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol + if fo.O() != fi.I(): + sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') + sys.exit (1) + K=Kb/bitspersymbol # packet size in trellis steps + interleaver=trellis.interleaver(K,666) # construct a random interleaver + modulation = fsm_utils.psk8 # see fsm_utlis.py for available predefined modulations + dimensionality = modulation[0] + constellation = modulation[1] + if len(constellation)/dimensionality != fi.O(): + sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') + sys.exit (1) + # calculate average symbol energy + Es = 0 + for i in range(len(constellation)): + Es = Es + constellation[i]**2 + Es = Es / (len(constellation)/dimensionality) + N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + for i in range(rep): + (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%100==0) : # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + +if __name__ == '__main__': + main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/python/test_sccc_soft.py b/gr-trellis/src/examples/python/test_sccc_soft.py new file mode 100755 index 000000000..1c71e4ca7 --- /dev/null +++ b/gr-trellis/src/examples/python/test_sccc_soft.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import random +import fsm_utils + + + + +def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): + tb = gr.top_block () + + + # TX + src = gr.lfsr_32k_source_s() + src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality + enc_out = trellis.encoder_ss(fo,0) # initial state = 0 + inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) + enc_in = trellis.encoder_ss(fi,0) # initial state = 0 + mod = gr.chunks_to_symbols_sf(constellation,dimensionality) + + # CHANNEL + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + metrics_in = trellis.metrics_f(fi.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner Viterbi + gnd = gr.vector_source_f([0],True); + siso_in = trellis.siso_f(fi,K,0,-1,True,False,trellis.TRELLIS_MIN_SUM) # Put -1 if the Initial/Final states are not set. + deinter = trellis.permutation(interleaver.K(),interleaver.DEINTER(),fi.I(),gr.sizeof_float) + va_out = trellis.viterbi_s(fo,K,0,-1) # Put -1 if the Initial/Final states are not set. + fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts + dst = gr.check_lfsr_32k_s() + + tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) + tb.connect (mod,(add,0)) + tb.connect (noise,(add,1)) + tb.connect (add,metrics_in) + tb.connect (gnd,(siso_in,0)) + tb.connect (metrics_in,(siso_in,1)) + tb.connect (siso_in,deinter,va_out,fsmi2s,dst) + + tb.run() + + ntotal = dst.ntotal () + nright = dst.nright () + runlength = dst.runlength () + return (ntotal,ntotal-nright) + + +def main(args): + nargs = len (args) + if nargs == 4: + fname_out=args[0] + fname_in=args[1] + esn0_db=float(args[2]) # Es/No in dB + rep=int(args[3]) # number of times the experiment is run to collect enough errors + else: + sys.stderr.write ('usage: test_tcm.py fsm_name_out fsm_fname_in Es/No_db repetitions\n') + sys.exit (1) + + # system parameters + Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) + fo=trellis.fsm(fname_out) # get the outer FSM specification from a file + fi=trellis.fsm(fname_in) # get the innner FSM specification from a file + bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol + if fo.O() != fi.I(): + sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') + sys.exit (1) + K=Kb/bitspersymbol # packet size in trellis steps + interleaver=trellis.interleaver(K,666) # construct a random interleaver + modulation = fsm_utils.psk8 # see fsm_utlis.py for available predefined modulations + dimensionality = modulation[0] + constellation = modulation[1] + if len(constellation)/dimensionality != fi.O(): + sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') + sys.exit (1) + # calculate average symbol energy + Es = 0 + for i in range(len(constellation)): + Es = Es + constellation[i]**2 + Es = Es / (len(constellation)/dimensionality) + N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance + + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + for i in range(rep): + (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%100==0) : # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + + +if __name__ == '__main__': + main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/python/test_sccc_turbo.py b/gr-trellis/src/examples/python/test_sccc_turbo.py new file mode 100755 index 000000000..b1007a864 --- /dev/null +++ b/gr-trellis/src/examples/python/test_sccc_turbo.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import random +import fsm_utils + + + +def make_rx(tb,fo,fi,dimensionality,constellation,K,interleaver,IT,Es,N0,type): + metrics_in = trellis.metrics_f(fi.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner Viterbi + scale = gr.multiply_const_ff(1.0/N0) + gnd = gr.vector_source_f([0],True); + + inter=[] + deinter=[] + siso_in=[] + siso_out=[] + + # generate all blocks + for it in range(IT): + inter.append( trellis.permutation(interleaver.K(),interleaver.INTER(),fi.I(),gr.sizeof_float) ) + siso_in.append( trellis.siso_f(fi,K,0,-1,True,False,type) ) + deinter.append( trellis.permutation(interleaver.K(),interleaver.DEINTER(),fi.I(),gr.sizeof_float) ) + if it < IT-1: + siso_out.append( trellis.siso_f(fo,K,0,-1,False,True,type) ) + else: + siso_out.append( trellis.viterbi_s(fo,K,0,-1) ) # no soft outputs needed + + # connect first stage + tb.connect (gnd,inter[0]) + tb.connect (metrics_in,scale) + tb.connect (scale,(siso_in[0],1)) + + # connect the rest + for it in range(IT): + if it < IT-1: + tb.connect (metrics_in,(siso_in[it+1],1)) + tb.connect (siso_in[it],deinter[it],(siso_out[it],1)) + tb.connect (gnd,(siso_out[it],0)) + tb.connect (siso_out[it],inter[it+1]) + tb.connect (inter[it],(siso_in[it],0)) + else: + tb.connect (siso_in[it],deinter[it],siso_out[it]) + tb.connect (inter[it],(siso_in[it],0)) + + return (metrics_in,siso_out[IT-1]) + + +def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,seed): + tb = gr.top_block () + + + # TX + src = gr.lfsr_32k_source_s() + src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality + enc_out = trellis.encoder_ss(fo,0) # initial state = 0 + inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) + enc_in = trellis.encoder_ss(fi,0) # initial state = 0 + mod = gr.chunks_to_symbols_sf(constellation,dimensionality) + + # CHANNEL + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + (head,tail) = make_rx(tb,fo,fi,dimensionality,constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_MIN_SUM) + #(head,tail) = make_rx(tb,fo,fi,dimensionality,constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_SUM_PRODUCT) + fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts + dst = gr.check_lfsr_32k_s() + + tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) + tb.connect (mod,(add,0)) + tb.connect (noise,(add,1)) + tb.connect (add,head) + tb.connect (tail,fsmi2s,dst) + + tb.run() + + #print enc_out.ST(), enc_in.ST() + + ntotal = dst.ntotal () + nright = dst.nright () + runlength = dst.runlength () + return (ntotal,ntotal-nright) + + +def main(args): + nargs = len (args) + if nargs == 5: + fname_out=args[0] + fname_in=args[1] + esn0_db=float(args[2]) # Es/No in dB + IT=int(args[3]) + rep=int(args[4]) # number of times the experiment is run to collect enough errors + else: + sys.stderr.write ('usage: test_sccc_turbo.py fsm_name_out fsm_fname_in Es/No_db iterations repetitions\n') + sys.exit (1) + + # system parameters + Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) + fo=trellis.fsm(fname_out) # get the outer FSM specification from a file + fi=trellis.fsm(fname_in) # get the innner FSM specification from a file + bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol + if fo.O() != fi.I(): + sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') + sys.exit (1) + K=Kb/bitspersymbol # packet size in trellis steps + interleaver=trellis.interleaver(K,666) # construct a random interleaver + modulation = fsm_utils.psk8 # see fsm_utlis.py for available predefined modulations + dimensionality = modulation[0] + constellation = modulation[1] + if len(constellation)/dimensionality != fi.O(): + sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') + sys.exit (1) + # calculate average symbol energy + Es = 0 + for i in range(len(constellation)): + Es = Es + constellation[i]**2 + Es = Es / (len(constellation)/dimensionality) + N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + for i in range(rep): + (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%10==0): # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + +if __name__ == '__main__': + main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/python/test_sccc_turbo1.py b/gr-trellis/src/examples/python/test_sccc_turbo1.py new file mode 100755 index 000000000..ad2ed6bf9 --- /dev/null +++ b/gr-trellis/src/examples/python/test_sccc_turbo1.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import random +import fsm_utils + + +def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,seed): + tb = gr.top_block () + + # TX + src = gr.lfsr_32k_source_s() + src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality + enc = trellis.sccc_encoder_ss(fo,0,fi,0,interleaver,K) + mod = gr.chunks_to_symbols_sf(constellation,dimensionality) + + # CHANNEL + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + dec = trellis.sccc_decoder_combined_fs(fo,0,-1,fi,0,-1,interleaver,K,IT,trellis.TRELLIS_MIN_SUM,dimensionality,constellation,digital.TRELLIS_EUCLIDEAN,1.0) + fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts + dst = gr.check_lfsr_32k_s() + + #tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) + tb.connect (src,src_head,s2fsmi,enc,mod) + tb.connect (mod,(add,0)) + tb.connect (noise,(add,1)) + #tb.connect (add,head) + #tb.connect (tail,fsmi2s,dst) + tb.connect (add,dec,fsmi2s,dst) + + tb.run() + + #print enc_out.ST(), enc_in.ST() + + ntotal = dst.ntotal () + nright = dst.nright () + runlength = dst.runlength () + return (ntotal,ntotal-nright) + + +def main(args): + nargs = len (args) + if nargs == 5: + fname_out=args[0] + fname_in=args[1] + esn0_db=float(args[2]) # Es/No in dB + IT=int(args[3]) + rep=int(args[4]) # number of times the experiment is run to collect enough errors + else: + sys.stderr.write ('usage: test_tcm.py fsm_name_out fsm_fname_in Es/No_db iterations repetitions\n') + sys.exit (1) + + # system parameters + Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) + fo=trellis.fsm(fname_out) # get the outer FSM specification from a file + fi=trellis.fsm(fname_in) # get the innner FSM specification from a file + bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol + if fo.O() != fi.I(): + sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') + sys.exit (1) + K=Kb/bitspersymbol # packet size in trellis steps + interleaver=trellis.interleaver(K,666) # construct a random interleaver + modulation = fsm_utils.psk8 # see fsm_utlis.py for available predefined modulations + dimensionality = modulation[0] + constellation = modulation[1] + if len(constellation)/dimensionality != fi.O(): + sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') + sys.exit (1) + # calculate average symbol energy + Es = 0 + for i in range(len(constellation)): + Es = Es + constellation[i]**2 + Es = Es / (len(constellation)/dimensionality) + N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + for i in range(rep): + (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%10==0): # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + +if __name__ == '__main__': + main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/python/test_sccc_turbo2.py b/gr-trellis/src/examples/python/test_sccc_turbo2.py new file mode 100755 index 000000000..fdb92adc8 --- /dev/null +++ b/gr-trellis/src/examples/python/test_sccc_turbo2.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import random +import fsm_utils + + +def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,seed): + tb = gr.top_block () + + # TX + src = gr.lfsr_32k_source_s() + src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality + enc = trellis.sccc_encoder_ss(fo,0,fi,0,interleaver,K) + mod = gr.chunks_to_symbols_sf(constellation,dimensionality) + + # CHANNEL + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + metrics_in = trellis.metrics_f(fi.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO + scale = gr.multiply_const_ff(1.0/N0) + dec = trellis.sccc_decoder_s(fo,0,-1,fi,0,-1,interleaver,K,IT,trellis.TRELLIS_MIN_SUM) + fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts + dst = gr.check_lfsr_32k_s() + + #tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) + tb.connect (src,src_head,s2fsmi,enc,mod) + tb.connect (mod,(add,0)) + tb.connect (noise,(add,1)) + #tb.connect (add,head) + #tb.connect (tail,fsmi2s,dst) + tb.connect (add,metrics_in,scale,dec,fsmi2s,dst) + + tb.run() + + #print enc_out.ST(), enc_in.ST() + + ntotal = dst.ntotal () + nright = dst.nright () + runlength = dst.runlength () + return (ntotal,ntotal-nright) + + +def main(args): + nargs = len (args) + if nargs == 5: + fname_out=args[0] + fname_in=args[1] + esn0_db=float(args[2]) # Es/No in dB + IT=int(args[3]) + rep=int(args[4]) # number of times the experiment is run to collect enough errors + else: + sys.stderr.write ('usage: test_tcm.py fsm_name_out fsm_fname_in Es/No_db iterations repetitions\n') + sys.exit (1) + + # system parameters + Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) + fo=trellis.fsm(fname_out) # get the outer FSM specification from a file + fi=trellis.fsm(fname_in) # get the innner FSM specification from a file + bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol + if fo.O() != fi.I(): + sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') + sys.exit (1) + K=Kb/bitspersymbol # packet size in trellis steps + interleaver=trellis.interleaver(K,666) # construct a random interleaver + modulation = fsm_utils.psk8 # see fsm_utlis.py for available predefined modulations + dimensionality = modulation[0] + constellation = modulation[1] + if len(constellation)/dimensionality != fi.O(): + sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') + sys.exit (1) + # calculate average symbol energy + Es = 0 + for i in range(len(constellation)): + Es = Es + constellation[i]**2 + Es = Es / (len(constellation)/dimensionality) + N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + for i in range(rep): + (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%10==0): # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + +if __name__ == '__main__': + main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/python/test_tcm.py b/gr-trellis/src/examples/python/test_tcm.py new file mode 100755 index 000000000..62fd5135e --- /dev/null +++ b/gr-trellis/src/examples/python/test_tcm.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import random +import fsm_utils +from gnuradio.eng_option import eng_option +from optparse import OptionParser + +def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): + tb = gr.top_block () + + + # TX + #packet = [0]*Kb + #for i in range(Kb-1*16): # last 16 bits = 0 to drive the final state to 0 + #packet[i] = random.randint(0, 1) # random 0s and 1s + #src = gr.vector_source_s(packet,False) + src = gr.lfsr_32k_source_s() + src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + #b2s = gr.unpacked_to_packed_ss(1,gr.GR_MSB_FIRST) # pack bits in shorts + s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality + enc = trellis.encoder_ss(f,0) # initial state = 0 + mod = gr.chunks_to_symbols_sf(constellation,dimensionality) + + # CHANNEL + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + metrics = trellis.metrics_f(f.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi + va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. + fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts + #s2b = gr.packed_to_unpacked_ss(1,gr.GR_MSB_FIRST) # unpack shorts to bits + #dst = gr.vector_sink_s(); + dst = gr.check_lfsr_32k_s() + + + tb.connect (src,src_head,s2fsmi,enc,mod) + #tb.connect (src,b2s,s2fsmi,enc,mod) + tb.connect (mod,(add,0)) + tb.connect (noise,(add,1)) + tb.connect (add,metrics) + tb.connect (metrics,va,fsmi2s,dst) + #tb.connect (metrics,va,fsmi2s,s2b,dst) + + + tb.run() + + # A bit of cheating: run the program once and print the + # final encoder state.. + # Then put it as the last argument in the viterbi block + #print "final state = " , enc.ST() + + ntotal = dst.ntotal () + nright = dst.nright () + runlength = dst.runlength () + #ntotal = len(packet) + #if len(dst.data()) != ntotal: + #print "Error: not enough data\n" + #nright = 0; + #for i in range(ntotal): + #if packet[i]==dst.data()[i]: + #nright=nright+1 + #else: + #print "Error in ", i + return (ntotal,ntotal-nright) + + + + +def main(): + parser = OptionParser(option_class=eng_option) + parser.add_option("-f", "--fsm_file", type="string", default="fsm_files/awgn1o2_4.fsm", help="Filename containing the fsm specification, e.g. -f fsm_files/awgn1o2_4.fsm (default=fsm_files/awgn1o2_4.fsm)") + parser.add_option("-e", "--esn0", type="eng_float", default=10.0, help="Symbol energy to noise PSD level ratio in dB, e.g., -e 10.0 (default=10.0)") + parser.add_option("-r", "--repetitions", type="int", default=100, help="Number of packets to be generated for the simulation, e.g., -r 100 (default=100)") + + (options, args) = parser.parse_args () + if len(args) != 0: + parser.print_help() + raise SystemExit, 1 + + fname=options.fsm_file + esn0_db=float(options.esn0) + rep=int(options.repetitions) + + # system parameters + f=trellis.fsm(fname) # get the FSM specification from a file + # alternatively you can specify the fsm from its generator matrix + #f=trellis.fsm(1,2,[5,7]) + Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) + bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol + K=Kb/bitspersymbol # packet size in trellis steps + modulation = fsm_utils.psk4 # see fsm_utlis.py for available predefined modulations + dimensionality = modulation[0] + constellation = modulation[1] + if len(constellation)/dimensionality != f.O(): + sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') + sys.exit (1) + # calculate average symbol energy + Es = 0 + for i in range(len(constellation)): + Es = Es + constellation[i]**2 + Es = Es / (len(constellation)/dimensionality) + N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + for i in range(rep): + (s,e)=run_test(f,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%100==0) : # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + + +if __name__ == '__main__': + main() diff --git a/gr-trellis/src/examples/python/test_tcm_bit.py b/gr-trellis/src/examples/python/test_tcm_bit.py new file mode 100755 index 000000000..cc5caefbc --- /dev/null +++ b/gr-trellis/src/examples/python/test_tcm_bit.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import random +import fsm_utils +from gnuradio.eng_option import eng_option +from optparse import OptionParser + + +def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): + tb = gr.top_block () + + # TX + packet = [0]*Kb + # this for loop is TOO slow!!! + for i in range(Kb-1*16): # last 16 bits = 0 to drive the final state to 0 + packet[i] = random.randint(0, 1) # random 0s and 1s + src = gr.vector_source_s(packet,False) + #src = gr.lfsr_32k_source_s() + #src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + b2s = gr.unpacked_to_packed_ss(1,gr.GR_MSB_FIRST) # pack bits in shorts + s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality + enc = trellis.encoder_ss(f,0) # initial state = 0 + mod = gr.chunks_to_symbols_sf(constellation,dimensionality) + + + # CHANNEL + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + + # RX + metrics = trellis.metrics_f(f.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi + va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. + fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts + s2b = gr.packed_to_unpacked_ss(1,gr.GR_MSB_FIRST) # unpack shorts to bits + dst = gr.vector_sink_s(); + #dst = gr.check_lfsr_32k_s(); + + + #tb.connect (src,src_head,s2fsmi,enc,mod) + tb.connect (src,b2s,s2fsmi,enc,mod) + tb.connect (mod,(add,0)) + tb.connect (noise,(add,1)) + tb.connect (add,metrics) + #tb.connect (metrics,va,fsmi2s,dst) + tb.connect (metrics,va,fsmi2s,s2b,dst) + + + tb.run() + + # A bit of cheating: run the program once and print the + # final encoder state.. + # Then put it as the last argument in the viterbi block + #print "final state = " , enc.ST() + + #ntotal = dst.ntotal () + #nright = dst.nright () + #runlength = dst.runlength () + ntotal = len(packet) + if len(dst.data()) != ntotal: + print "Error: not enough data\n" + nright = 0; + # this for loop is TOO slow!!! + for i in range(ntotal): + if packet[i]==dst.data()[i]: + nright=nright+1 + #else: + #print "Error in ", i + return (ntotal,ntotal-nright) + + + + +def main(): + parser = OptionParser(option_class=eng_option) + parser.add_option("-f", "--fsm_file", type="string", default="fsm_files/awgn1o2_4.fsm", help="Filename containing the fsm specification, e.g. -f fsm_files/awgn1o2_4.fsm (default=fsm_files/awgn1o2_4.fsm)") + parser.add_option("-e", "--esn0", type="eng_float", default=10.0, help="Symbol energy to noise PSD level ratio in dB, e.g., -e 10.0 (default=10.0)") + parser.add_option("-r", "--repetitions", type="int", default=100, help="Number of packets to be generated for the simulation, e.g., -r 100 (default=100)") + + (options, args) = parser.parse_args () + if len(args) != 0: + parser.print_help() + raise SystemExit, 1 + + fname=options.fsm_file + esn0_db=float(options.esn0) + rep=int(options.repetitions) + + + # system parameters + f=trellis.fsm(fname) # get the FSM specification from a file + Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) + bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol + K=Kb/bitspersymbol # packet size in trellis steps + modulation = fsm_utils.psk4 # see fsm_utlis.py for available predefined modulations + dimensionality = modulation[0] + constellation = modulation[1] + if len(constellation)/dimensionality != f.O(): + sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') + sys.exit (1) + # calculate average symbol energy + Es = 0 + for i in range(len(constellation)): + Es = Es + constellation[i]**2 + Es = Es / (len(constellation)/dimensionality) + N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + for i in range(rep): + (s,e)=run_test(f,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%1==0) : # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + + +if __name__ == '__main__': + main() diff --git a/gr-trellis/src/examples/python/test_tcm_combined.py b/gr-trellis/src/examples/python/test_tcm_combined.py new file mode 100755 index 000000000..55a3043b8 --- /dev/null +++ b/gr-trellis/src/examples/python/test_tcm_combined.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import fsm_utils +from gnuradio.eng_option import eng_option +from optparse import OptionParser + + +def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): + tb = gr.top_block () + + # TX + src = gr.lfsr_32k_source_s() + src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality + enc = trellis.encoder_ss(f,0) # initial state = 0 + mod = gr.chunks_to_symbols_sf(constellation,dimensionality) + + + # CHANNEL + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + + # RX + va = trellis.viterbi_combined_fs(f,K,0,-1,dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # Put -1 if the Initial/Final states are not set. + fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts + dst = gr.check_lfsr_32k_s(); + + + tb.connect (src,src_head,s2fsmi,enc,mod) + tb.connect (mod,(add,0)) + tb.connect (noise,(add,1)) + tb.connect (add,va,fsmi2s,dst) + + + tb.run() + + # A bit of cheating: run the program once and print the + # final encoder state.. + # Then put it as the last argument in the viterbi block + #print "final state = " , enc.ST() + + ntotal = dst.ntotal () + nright = dst.nright () + runlength = dst.runlength () + + return (ntotal,ntotal-nright) + + + + +def main(): + parser = OptionParser(option_class=eng_option) + parser.add_option("-f", "--fsm_file", type="string", default="fsm_files/awgn1o2_4.fsm", help="Filename containing the fsm specification, e.g. -f fsm_files/awgn1o2_4.fsm (default=fsm_files/awgn1o2_4.fsm)") + parser.add_option("-e", "--esn0", type="eng_float", default=10.0, help="Symbol energy to noise PSD level ratio in dB, e.g., -e 10.0 (default=10.0)") + parser.add_option("-r", "--repetitions", type="int", default=100, help="Number of packets to be generated for the simulation, e.g., -r 100 (default=100)") + + (options, args) = parser.parse_args () + if len(args) != 0: + parser.print_help() + raise SystemExit, 1 + + fname=options.fsm_file + esn0_db=float(options.esn0) + rep=int(options.repetitions) + + # system parameters + f=trellis.fsm(fname) # get the FSM specification from a file (will hopefully be automated in the future...) + Kb=1024*16 # packet size in bits (make it multiple of 16) + bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol + K=Kb/bitspersymbol # packet size in trellis steps + modulation = fsm_utils.psk4 # see fsm_utils.py for available predefined modulations + dimensionality = modulation[0] + constellation = modulation[1] + if len(constellation)/dimensionality != f.O(): + sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') + sys.exit (1) + # calculate average symbol energy + Es = 0 + for i in range(len(constellation)): + Es = Es + constellation[i]**2 + Es = Es / (len(constellation)/dimensionality) + N0=Es/pow(10.0,esn0_db/10.0); # noise variance + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + for i in range(rep): + (s,e)=run_test(f,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%100==0) : # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + + +if __name__ == '__main__': + main() + diff --git a/gr-trellis/src/examples/python/test_tcm_parallel.py b/gr-trellis/src/examples/python/test_tcm_parallel.py new file mode 100755 index 000000000..2b722c09e --- /dev/null +++ b/gr-trellis/src/examples/python/test_tcm_parallel.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import fsm_utils +from gnuradio.eng_option import eng_option +from optparse import OptionParser + + +def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed,P): + tb = gr.top_block () + + # TX + src = gr.lfsr_32k_source_s() + src_head = gr.head (gr.sizeof_short,Kb/16*P) # packet size in shorts + s2fsmi=gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality + s2p = gr.stream_to_streams(gr.sizeof_short,P) # serial to parallel + enc = trellis.encoder_ss(f,0) # initiali state = 0 + mod = gr.chunks_to_symbols_sf(constellation,dimensionality) + + # CHANNEL + add=[] + noise=[] + for i in range(P): + add.append(gr.add_ff()) + noise.append(gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed)) + + # RX + metrics = trellis.metrics_f(f.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi + va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. + p2s = gr.streams_to_stream(gr.sizeof_short,P) # parallel to serial + fsmi2s=gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts + dst = gr.check_lfsr_32k_s() + + tb.connect (src,src_head,s2fsmi,s2p) + for i in range(P): + tb.connect ((s2p,i),(enc,i),(mod,i)) + tb.connect ((mod,i),(add[i],0)) + tb.connect (noise[i],(add[i],1)) + tb.connect (add[i],(metrics,i)) + tb.connect ((metrics,i),(va,i),(p2s,i)) + tb.connect (p2s,fsmi2s,dst) + + + tb.run() + + # A bit of cheating: run the program once and print the + # final encoder state. + # Then put it as the last argument in the viterbi block + #print "final state = " , enc.ST() + + ntotal = dst.ntotal () + nright = dst.nright () + runlength = dst.runlength () + + return (ntotal,ntotal-nright) + + + +def main(): + parser = OptionParser(option_class=eng_option) + parser.add_option("-f", "--fsm_file", type="string", default="fsm_files/awgn1o2_4.fsm", help="Filename containing the fsm specification, e.g. -f fsm_files/awgn1o2_4.fsm (default=fsm_files/awgn1o2_4.fsm)") + parser.add_option("-e", "--esn0", type="eng_float", default=10.0, help="Symbol energy to noise PSD level ratio in dB, e.g., -e 10.0 (default=10.0)") + parser.add_option("-r", "--repetitions", type="int", default=100, help="Number of packets to be generated for the simulation, e.g., -r 100 (default=100)") + + (options, args) = parser.parse_args () + if len(args) != 0: + parser.print_help() + raise SystemExit, 1 + + fname=options.fsm_file + esn0_db=float(options.esn0) + rep=int(options.repetitions) + + # system parameters + f=trellis.fsm(fname) # get the FSM specification from a file + P=4 # how many parallel streams? + Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) + bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol + K=Kb/bitspersymbol # packet size in trellis steps + modulation = fsm_utils.psk4 # see fsm_utlis.py for available predefined modulations + dimensionality = modulation[0] + constellation = modulation[1] + if len(constellation)/dimensionality != f.O(): + sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') + sys.exit (1) + # calculate average symbol energy + Es = 0 + for i in range(len(constellation)): + Es = Es + constellation[i]**2 + Es = Es / (len(constellation)/dimensionality) + N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + for i in range(rep): + (s,e)=run_test(f,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i),P) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%100==0) : # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + +if __name__ == '__main__': + main() + diff --git a/gr-trellis/src/examples/python/test_turbo_equalization.py b/gr-trellis/src/examples/python/test_turbo_equalization.py new file mode 100755 index 000000000..6fa6749f0 --- /dev/null +++ b/gr-trellis/src/examples/python/test_turbo_equalization.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import fsm_utils + + +def make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,type): + metrics_in = trellis.metrics_f(fi.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO + scale = gr.multiply_const_ff(1.0/N0) + gnd = gr.vector_source_f([0],True); + + inter=[] + deinter=[] + siso_in=[] + siso_out=[] + + # generate all blocks + for it in range(IT): + inter.append( trellis.permutation(interleaver.K(),interleaver.INTER(),fi.I(),gr.sizeof_float) ) + siso_in.append( trellis.siso_f(fi,K,0,-1,True,False,type) ) + deinter.append( trellis.permutation(interleaver.K(),interleaver.DEINTER(),fi.I(),gr.sizeof_float) ) + if it < IT-1: + siso_out.append( trellis.siso_f(fo,K,0,-1,False,True,type) ) + else: + siso_out.append( trellis.viterbi_s(fo,K,0,-1) ) # no soft outputs needed + + # connect first stage + tb.connect (gnd,inter[0]) + tb.connect (metrics_in,scale) + tb.connect (scale,(siso_in[0],1)) + + # connect the rest + for it in range(IT): + if it < IT-1: + tb.connect (metrics_in,(siso_in[it+1],1)) + tb.connect (siso_in[it],deinter[it],(siso_out[it],1)) + tb.connect (gnd,(siso_out[it],0)) + tb.connect (siso_out[it],inter[it+1]) + tb.connect (inter[it],(siso_in[it],0)) + else: + tb.connect (siso_in[it],deinter[it],siso_out[it]) + tb.connect (inter[it],(siso_in[it],0)) + + return (metrics_in,siso_out[IT-1]) + + +def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,tot_constellation,Es,N0,IT,seed): + tb = gr.top_block () + + # TX + src = gr.lfsr_32k_source_s() + src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the iouter FSM input cardinality + enc_out = trellis.encoder_ss(fo,0) # initial state = 0 + inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) + enc_in = trellis.encoder_ss(fi,0) # initial state = 0 + # essentially here we implement the combination of modulation and channel as a memoryless modulation (the memory induced by the channel is hidden in the innner FSM) + mod = gr.chunks_to_symbols_sf(tot_constellation,dimensionality) + + # CHANNEL + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + (head,tail) = make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_MIN_SUM) + fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts + dst = gr.check_lfsr_32k_s(); + + tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) + tb.connect (mod,(add,0)) + tb.connect (noise,(add,1)) + tb.connect (add,head) + tb.connect (tail,fsmi2s,dst) + + tb.run() + + ntotal = dst.ntotal () + nright = dst.nright () + runlength = dst.runlength () + #print ntotal,nright,runlength + + return (ntotal,ntotal-nright) + + + + +def main(args): + nargs = len (args) + if nargs == 3: + fname_out=args[0] + esn0_db=float(args[1]) + rep=int(args[2]) + else: + sys.stderr.write ('usage: test_turbo_equalization.py fsm_name_out Es/No_db repetitions\n') + sys.exit (1) + + # system parameters + Kb=64*16 # packet size in bits (multiple of 16) + modulation = fsm_utils.pam4 # see fsm_utlis.py for available predefined modulations + channel = fsm_utils.c_channel # see fsm_utlis.py for available predefined test channels + fo=trellis.fsm(fname_out) # get the outer FSM specification from a file + fi=trellis.fsm(len(modulation[1]),len(channel)) # generate the FSM automatically + if fo.O() != fi.I(): + sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') + sys.exit (1) + bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol + K=Kb/bitspersymbol # packet size in trellis steps + print 'size = ',K + interleaver=trellis.interleaver(K,666) # construct a random interleaver + tot_channel = fsm_utils.make_isi_lookup(modulation,channel,True) # generate the lookup table (normalize energy to 1) + dimensionality = tot_channel[0] + tot_constellation = tot_channel[1] + if len(tot_constellation)/dimensionality != fi.O(): + sys.stderr.write ('Incompatible FSM output cardinality and lookup table size.\n') + sys.exit (1) + N0=pow(10.0,-esn0_db/10.0); # noise variance + IT = 3 # number of turbo iterations + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + + for i in range(rep): + (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,tot_constellation,1,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations + print s + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%10==0) : # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + + +if __name__ == '__main__': + main (sys.argv[1:]) + diff --git a/gr-trellis/src/examples/python/test_turbo_equalization1.py b/gr-trellis/src/examples/python/test_turbo_equalization1.py new file mode 100755 index 000000000..15a8f6809 --- /dev/null +++ b/gr-trellis/src/examples/python/test_turbo_equalization1.py @@ -0,0 +1,146 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import random +import fsm_utils + +def make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,type): + metrics_in = trellis.metrics_f(fi.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO + scale = gr.multiply_const_ff(1.0/N0) + gnd = gr.vector_source_f([0],True); + + inter=[] + deinter=[] + siso_in=[] + siso_out=[] + + # generate all blocks + for it in range(IT): + inter.append( trellis.permutation(interleaver.K(),interleaver.INTER(),fi.I(),gr.sizeof_float) ) + siso_in.append( trellis.siso_f(fi,K,0,-1,True,False,type) ) + deinter.append( trellis.permutation(interleaver.K(),interleaver.DEINTER(),fi.I(),gr.sizeof_float) ) + if it < IT-1: + siso_out.append( trellis.siso_f(fo,K,0,-1,False,True,type) ) + else: + siso_out.append( trellis.viterbi_s(fo,K,0,-1) ) # no soft outputs needed + + # connect first stage + tb.connect (gnd,inter[0]) + tb.connect (metrics_in,scale) + tb.connect (scale,(siso_in[0],1)) + + # connect the rest + for it in range(IT): + if it < IT-1: + tb.connect (scale,(siso_in[it+1],1)) + tb.connect (siso_in[it],deinter[it],(siso_out[it],1)) + tb.connect (gnd,(siso_out[it],0)) + tb.connect (siso_out[it],inter[it+1]) + tb.connect (inter[it],(siso_in[it],0)) + else: + tb.connect (siso_in[it],deinter[it],siso_out[it]) + tb.connect (inter[it],(siso_in[it],0)) + + return (metrics_in,siso_out[IT-1]) + + +def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,Es,N0,IT,seed): + tb = gr.top_block () + L = len(channel) + + # TX + # this for loop is TOO slow in python!!! + packet = [0]*(K) + random.seed(seed) + for i in range(len(packet)): + packet[i] = random.randint(0, 2**bitspersymbol - 1) # random symbols + src = gr.vector_source_s(packet,False) + enc_out = trellis.encoder_ss(fo,0) # initial state = 0 + inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) + mod = gr.chunks_to_symbols_sf(modulation[1],modulation[0]) + + # CHANNEL + isi = gr.fir_filter_fff(1,channel) + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + (head,tail) = make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_MIN_SUM) + dst = gr.vector_sink_s(); + + tb.connect (src,enc_out,inter,mod) + tb.connect (mod,isi,(add,0)) + tb.connect (noise,(add,1)) + tb.connect (add,head) + tb.connect (tail,dst) + + tb.run() + + data = dst.data() + ntotal = len(data) + nright=0 + for i in range(ntotal): + if packet[i]==data[i]: + nright=nright+1 + #else: + #print "Error in ", i + + return (ntotal,ntotal-nright) + + + + +def main(args): + nargs = len (args) + if nargs == 3: + fname_out=args[0] + esn0_db=float(args[1]) + rep=int(args[2]) + else: + sys.stderr.write ('usage: test_turbo_equalization.py fsm_name_out Es/No_db repetitions\n') + sys.exit (1) + + # system parameters + Kb=64*16 # packet size in bits (multiple of 16) + modulation = fsm_utils.pam4 # see fsm_utlis.py for available predefined modulations + channel = fsm_utils.c_channel # see fsm_utlis.py for available predefined test channels + fo=trellis.fsm(fname_out) # get the outer FSM specification from a file + fi=trellis.fsm(len(modulation[1]),len(channel)) # generate the FSM automatically + if fo.O() != fi.I(): + sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') + sys.exit (1) + bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol + K=Kb/bitspersymbol # packet size in trellis steps + interleaver=trellis.interleaver(K,666) # construct a random interleaver + tot_channel = fsm_utils.make_isi_lookup(modulation,channel,True) # generate the lookup table (normalize energy to 1) + dimensionality = tot_channel[0] + tot_constellation = tot_channel[1] + if len(tot_constellation)/dimensionality != fi.O(): + sys.stderr.write ('Incompatible FSM output cardinality and lookup table size.\n') + sys.exit (1) + N0=pow(10.0,-esn0_db/10.0); # noise variance + IT = 3 # number of turbo iterations + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + + for i in range(rep): + (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,1,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%10==0) : # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + + +if __name__ == '__main__': + main (sys.argv[1:]) + diff --git a/gr-trellis/src/examples/python/test_turbo_equalization2.py b/gr-trellis/src/examples/python/test_turbo_equalization2.py new file mode 100755 index 000000000..7e4341cba --- /dev/null +++ b/gr-trellis/src/examples/python/test_turbo_equalization2.py @@ -0,0 +1,146 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import random +import fsm_utils + +def make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,type): + scale = gr.multiply_const_ff(math.sqrt(1.0/N0)) + gnd = gr.vector_source_f([0],True); + + inter=[] + deinter=[] + siso_in=[] + siso_out=[] + + # generate all blocks + for it in range(IT): + inter.append( trellis.permutation(interleaver.K(),interleaver.INTER(),fi.I(),gr.sizeof_float) ) + siso_in.append( trellis.siso_combined_f(fi,K,0,-1,True,False,type,dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) ) + deinter.append( trellis.permutation(interleaver.K(),interleaver.DEINTER(),fi.I(),gr.sizeof_float) ) + if it < IT-1: + siso_out.append( trellis.siso_f(fo,K,0,-1,False,True,type) ) + else: + siso_out.append( trellis.viterbi_s(fo,K,0,-1) ) # no soft outputs needed + + # connect first stage + tb.connect (gnd,inter[0]) + tb.connect (scale,(siso_in[0],1)) + + # connect the rest + for it in range(IT): + if it < IT-1: + tb.connect (scale,(siso_in[it+1],1)) + tb.connect (siso_in[it],deinter[it],(siso_out[it],1)) + tb.connect (gnd,(siso_out[it],0)) + tb.connect (siso_out[it],inter[it+1]) + tb.connect (inter[it],(siso_in[it],0)) + else: + tb.connect (siso_in[it],deinter[it],siso_out[it]) + tb.connect (inter[it],(siso_in[it],0)) + + return (scale,siso_out[IT-1]) + + +def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,Es,N0,IT,seed): + tb = gr.top_block () + L = len(channel) + + # TX + # this for loop is TOO slow in python!!! + packet = [0]*(K) + random.seed(seed) + for i in range(len(packet)): + packet[i] = random.randint(0, 2**bitspersymbol - 1) # random symbols + src = gr.vector_source_s(packet,False) + enc_out = trellis.encoder_ss(fo,0) # initial state = 0 + inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) + mod = gr.chunks_to_symbols_sf(modulation[1],modulation[0]) + + # CHANNEL + isi = gr.fir_filter_fff(1,channel) + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + (head,tail) = make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_MIN_SUM) + dst = gr.vector_sink_s(); + + tb.connect (src,enc_out,inter,mod) + tb.connect (mod,isi,(add,0)) + tb.connect (noise,(add,1)) + tb.connect (add,head) + tb.connect (tail,dst) + + tb.run() + + data = dst.data() + ntotal = len(data) + nright=0 + for i in range(ntotal): + if packet[i]==data[i]: + nright=nright+1 + #else: + #print "Error in ", i + + return (ntotal,ntotal-nright) + + + + +def main(args): + nargs = len (args) + if nargs == 3: + fname_out=args[0] + esn0_db=float(args[1]) + rep=int(args[2]) + else: + sys.stderr.write ('usage: test_turbo_equalization.py fsm_name_out Es/No_db repetitions\n') + sys.exit (1) + + # system parameters + Kb=64*16 # packet size in bits (multiple of 16) + modulation = fsm_utils.pam4 # see fsm_utlis.py for available predefined modulations + channel = fsm_utils.c_channel # see fsm_utlis.py for available predefined test channels + fo=trellis.fsm(fname_out) # get the outer FSM specification from a file + fi=trellis.fsm(len(modulation[1]),len(channel)) # generate the FSM automatically + if fo.O() != fi.I(): + sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') + sys.exit (1) + bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol + K=Kb/bitspersymbol # packet size in trellis steps + interleaver=trellis.interleaver(K,666) # construct a random interleaver + tot_channel = fsm_utils.make_isi_lookup(modulation,channel,True) # generate the lookup table (normalize energy to 1) + dimensionality = tot_channel[0] + N0=pow(10.0,-esn0_db/10.0); # noise variance + tot_constellation =[0]*len(tot_channel[1]) + for i in range(len(tot_channel[1])): + tot_constellation[i] = tot_channel[1][i] * math.sqrt(1.0/N0) + if len(tot_constellation)/dimensionality != fi.O(): + sys.stderr.write ('Incompatible FSM output cardinality and lookup table size.\n') + sys.exit (1) + IT = 3 # number of turbo iterations + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + + for i in range(rep): + (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,1,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%10==0) : # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + + +if __name__ == '__main__': + main (sys.argv[1:]) + diff --git a/gr-trellis/src/examples/python/test_viterbi_equalization.py b/gr-trellis/src/examples/python/test_viterbi_equalization.py new file mode 100755 index 000000000..d290a0d0a --- /dev/null +++ b/gr-trellis/src/examples/python/test_viterbi_equalization.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import fsm_utils + +def run_test (f,Kb,bitspersymbol,K,dimensionality,tot_constellation,N0,seed): + tb = gr.top_block () + + # TX + src = gr.lfsr_32k_source_s() + src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality + enc = trellis.encoder_ss(f,0) # initial state = 0 + # essentially here we implement the combination of modulation and channel as a memoryless modulation (the memory induced by the channel is hidden in the FSM) + mod = gr.chunks_to_symbols_sf(tot_constellation,dimensionality) + + # CHANNEL + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi + va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. + fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts + dst = gr.check_lfsr_32k_s(); + + tb.connect (src,src_head,s2fsmi,enc,mod) + tb.connect (mod,(add,0)) + tb.connect (noise,(add,1)) + tb.connect (add,metrics) + tb.connect (metrics,va,fsmi2s,dst) + + tb.run() + + ntotal = dst.ntotal () + nright = dst.nright () + runlength = dst.runlength () + #print ntotal,nright,runlength + + return (ntotal,ntotal-nright) + + + + +def main(args): + nargs = len (args) + if nargs == 2: + esn0_db=float(args[0]) + rep=int(args[1]) + else: + sys.stderr.write ('usage: test_viterbi_equalization.py Es/No_db repetitions\n') + sys.exit (1) + + # system parameters + Kb=128*16 # packet size in bits (multiple of 16) + modulation = fsm_utils.pam4 # see fsm_utlis.py for available predefined modulations + channel = fsm_utils.c_channel # see fsm_utlis.py for available predefined test channels + f=trellis.fsm(len(modulation[1]),len(channel)) # generate the FSM automatically + bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol + K=Kb/bitspersymbol # packet size in trellis steps + + tot_channel = fsm_utils.make_isi_lookup(modulation,channel,True) # generate the lookup table (normalize energy to 1) + dimensionality = tot_channel[0] + tot_constellation = tot_channel[1] + N0=pow(10.0,-esn0_db/10.0); # noise variance + if len(tot_constellation)/dimensionality != f.O(): + sys.stderr.write ('Incompatible FSM output cardinality and lookup table size.\n') + sys.exit (1) + + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + + for i in range(rep): + (s,e)=run_test(f,Kb,bitspersymbol,K,dimensionality,tot_constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%100==0) : # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or bit) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + + +if __name__ == '__main__': + main (sys.argv[1:]) + diff --git a/gr-trellis/src/examples/python/test_viterbi_equalization1.py b/gr-trellis/src/examples/python/test_viterbi_equalization1.py new file mode 100755 index 000000000..41f777551 --- /dev/null +++ b/gr-trellis/src/examples/python/test_viterbi_equalization1.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import trellis, digital +from gnuradio import eng_notation +import math +import sys +import random +import fsm_utils + +def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,N0,seed): + tb = gr.top_block () + L = len(channel) + + # TX + # this for loop is TOO slow in python!!! + packet = [0]*(K+2*L) + random.seed(seed) + for i in range(len(packet)): + packet[i] = random.randint(0, 2**bitspersymbol - 1) # random symbols + for i in range(L): # first/last L symbols set to 0 + packet[i] = 0 + packet[len(packet)-i-1] = 0 + src = gr.vector_source_s(packet,False) + mod = gr.chunks_to_symbols_sf(modulation[1],modulation[0]) + + # CHANNEL + isi = gr.fir_filter_fff(1,channel) + add = gr.add_ff() + noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) + + # RX + skip = gr.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols + #metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi + #va = trellis.viterbi_s(f,K+L,-1,0) # Put -1 if the Initial/Final states are not set. + va = trellis.viterbi_combined_fs(f,K+L,0,0,dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # using viterbi_combined_fs instead of metrics_f/viterbi_s allows larger packet lengths because metrics_f is complaining for not being able to allocate large buffers. This is due to the large f.O() in this application... + dst = gr.vector_sink_s() + + tb.connect (src,mod) + tb.connect (mod,isi,(add,0)) + tb.connect (noise,(add,1)) + #tb.connect (add,metrics) + #tb.connect (metrics,va,dst) + tb.connect (add,skip,va,dst) + + tb.run() + + data = dst.data() + ntotal = len(data) - L + nright=0 + for i in range(ntotal): + if packet[i+L]==data[i]: + nright=nright+1 + #else: + #print "Error in ", i + + return (ntotal,ntotal-nright) + + +def main(args): + nargs = len (args) + if nargs == 2: + esn0_db=float(args[0]) + rep=int(args[1]) + else: + sys.stderr.write ('usage: test_viterbi_equalization1.py Es/No_db repetitions\n') + sys.exit (1) + + # system parameters + Kb=128*16 # packet size in bits (multiple of 16) + modulation = fsm_utils.pam4 # see fsm_utlis.py for available predefined modulations + channel = fsm_utils.c_channel # see fsm_utlis.py for available predefined test channels + f=trellis.fsm(len(modulation[1]),len(channel)) # generate the FSM automatically + bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol + K=Kb/bitspersymbol # packet size in trellis steps + + tot_channel = fsm_utils.make_isi_lookup(modulation,channel,True) # generate the lookup table (normalize energy to 1) + dimensionality = tot_channel[0] + tot_constellation = tot_channel[1] + N0=pow(10.0,-esn0_db/10.0); # noise variance + if len(tot_constellation)/dimensionality != f.O(): + sys.stderr.write ('Incompatible FSM output cardinality and lookup table size.\n') + sys.exit (1) + + tot_s=0 # total number of transmitted shorts + terr_s=0 # total number of shorts in error + terr_p=0 # total number of packets in error + + for i in range(rep): + (s,e)=run_test(f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations + tot_s=tot_s+s + terr_s=terr_s+e + terr_p=terr_p+(terr_s!=0) + if ((i+1)%100==0) : # display progress + print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + # estimate of the (short or symbol) error rate + print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + + + +if __name__ == '__main__': + main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/test_cpm.py b/gr-trellis/src/examples/test_cpm.py deleted file mode 100755 index 06d54b1a6..000000000 --- a/gr-trellis/src/examples/test_cpm.py +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/env python -################################################## -# Gnuradio Python Flow Graph -# Title: CPM test -# Author: Achilleas Anastasopoulos -# Description: gnuradio flow graph -# Generated: Thu Feb 19 23:16:23 2009 -################################################## - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio.gr import firdes -from grc_gnuradio import blks2 as grc_blks2 -import math -import numpy -import fsm_utils -from gnuradio import trellis - -try: - import scipy.stats -except ImportError: - print "Error: Program requires scipy (see: www.scipy.org)." - sys.exit(1) - -def run_test(seed,blocksize): - tb = gr.top_block() - - ################################################## - # Variables - ################################################## - M = 2 - K = 1 - P = 2 - h = (1.0*K)/P - L = 3 - Q = 4 - frac = 0.99 - f = trellis.fsm(P,M,L) - - # CPFSK signals - #p = numpy.ones(Q)/(2.0) - #q = numpy.cumsum(p)/(1.0*Q) - - # GMSK signals - BT=0.3; - tt=numpy.arange(0,L*Q)/(1.0*Q)-L/2.0; - #print tt - p=(0.5*scipy.stats.erfc(2*math.pi*BT*(tt-0.5)/math.sqrt(math.log(2.0))/math.sqrt(2.0))-0.5*scipy.stats.erfc(2*math.pi*BT*(tt+0.5)/math.sqrt(math.log(2.0))/math.sqrt(2.0)))/2.0; - p=p/sum(p)*Q/2.0; - #print p - q=numpy.cumsum(p)/Q; - q=q/q[-1]/2.0; - #print q - - (f0T,SS,S,F,Sf,Ff,N) = fsm_utils.make_cpm_signals(K,P,M,L,q,frac) - #print N - #print Ff - Ffa = numpy.insert(Ff,Q,numpy.zeros(N),axis=0) - #print Ffa - MF = numpy.fliplr(numpy.transpose(Ffa)) - #print MF - E = numpy.sum(numpy.abs(Sf)**2,axis=0) - Es = numpy.sum(E)/f.O() - #print Es - - constellation = numpy.reshape(numpy.transpose(Sf),N*f.O()) - #print Ff - #print Sf - #print constellation - #print numpy.max(numpy.abs(SS - numpy.dot(Ff , Sf))) - - EsN0_db = 10.0 - N0 = Es * 10.0**(-(1.0*EsN0_db)/10.0) - #N0 = 0.0 - #print N0 - head = 4 - tail = 4 - numpy.random.seed(seed*666) - data = numpy.random.randint(0, M, head+blocksize+tail+1) - #data = numpy.zeros(blocksize+1+head+tail,'int') - for i in range(head): - data[i]=0 - for i in range(tail+1): - data[-i]=0 - - - - ################################################## - # Blocks - ################################################## - random_source_x_0 = gr.vector_source_b(data.tolist(), False) - gr_chunks_to_symbols_xx_0 = gr.chunks_to_symbols_bf((-1, 1), 1) - gr_interp_fir_filter_xxx_0 = gr.interp_fir_filter_fff(Q, p) - gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc(2*math.pi*h*(1.0/Q)) - - gr_add_vxx_0 = gr.add_vcc(1) - gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, (N0/2.0)**0.5, -long(seed)) - - gr_multiply_vxx_0 = gr.multiply_vcc(1) - gr_sig_source_x_0 = gr.sig_source_c(Q, gr.GR_COS_WAVE, -f0T, 1, 0) - # only works for N=2, do it manually for N>2... - gr_fir_filter_xxx_0_0 = gr.fir_filter_ccc(Q, MF[0].conjugate()) - gr_fir_filter_xxx_0_0_0 = gr.fir_filter_ccc(Q, MF[1].conjugate()) - gr_streams_to_stream_0 = gr.streams_to_stream(gr.sizeof_gr_complex*1, int(N)) - gr_skiphead_0 = gr.skiphead(gr.sizeof_gr_complex*1, int(N*(1+0))) - viterbi = trellis.viterbi_combined_cb(f, head+blocksize+tail, 0, -1, int(N), - constellation, digital.TRELLIS_EUCLIDEAN) - - gr_vector_sink_x_0 = gr.vector_sink_b() - - ################################################## - # Connections - ################################################## - tb.connect((random_source_x_0, 0), (gr_chunks_to_symbols_xx_0, 0)) - tb.connect((gr_chunks_to_symbols_xx_0, 0), (gr_interp_fir_filter_xxx_0, 0)) - tb.connect((gr_interp_fir_filter_xxx_0, 0), (gr_frequency_modulator_fc_0, 0)) - tb.connect((gr_frequency_modulator_fc_0, 0), (gr_add_vxx_0, 0)) - tb.connect((gr_noise_source_x_0, 0), (gr_add_vxx_0, 1)) - tb.connect((gr_add_vxx_0, 0), (gr_multiply_vxx_0, 0)) - tb.connect((gr_sig_source_x_0, 0), (gr_multiply_vxx_0, 1)) - tb.connect((gr_multiply_vxx_0, 0), (gr_fir_filter_xxx_0_0, 0)) - tb.connect((gr_multiply_vxx_0, 0), (gr_fir_filter_xxx_0_0_0, 0)) - tb.connect((gr_fir_filter_xxx_0_0, 0), (gr_streams_to_stream_0, 0)) - tb.connect((gr_fir_filter_xxx_0_0_0, 0), (gr_streams_to_stream_0, 1)) - tb.connect((gr_streams_to_stream_0, 0), (gr_skiphead_0, 0)) - tb.connect((gr_skiphead_0, 0), (viterbi, 0)) - tb.connect((viterbi, 0), (gr_vector_sink_x_0, 0)) - - - tb.run() - dataest = gr_vector_sink_x_0.data() - #print data - #print numpy.array(dataest) - perr = 0 - err = 0 - for i in range(blocksize): - if data[head+i] != dataest[head+i]: - #print i - err += 1 - if err != 0 : - perr = 1 - return (err,perr) - -if __name__ == '__main__': - blocksize = 1000 - ss=0 - ee=0 - for i in range(10000): - (s,e) = run_test(i,blocksize) - ss += s - ee += e - if (i+1) % 100 == 0: - print i+1,ss,ee,(1.0*ss)/(i+1)/(1.0*blocksize),(1.0*ee)/(i+1) - print i+1,ss,ee,(1.0*ss)/(i+1)/(1.0*blocksize),(1.0*ee)/(i+1) diff --git a/gr-trellis/src/examples/test_pccc_turbo1.py b/gr-trellis/src/examples/test_pccc_turbo1.py deleted file mode 100755 index 7f1ea26ae..000000000 --- a/gr-trellis/src/examples/test_pccc_turbo1.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import random -import fsm_utils - - -def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,seed): - tb = gr.top_block () - - - # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts - s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality - #src = gr.vector_source_s([0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1],False) - enc = trellis.pccc_encoder_ss(fo,0,fi,0,interleaver,K) - code = gr.vector_sink_s() - mod = gr.chunks_to_symbols_sf(constellation,dimensionality) - - # CHANNEL - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - # RX - metrics_in = trellis.metrics_f(fi.O()*fo.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO - scale = gr.multiply_const_ff(1.0/N0) - dec = trellis.pccc_decoder_s(fo,0,-1,fi,0,-1,interleaver,K,IT,trellis.TRELLIS_MIN_SUM) - - fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() - - tb.connect (src,src_head,s2fsmi,enc,mod) - #tb.connect (src,enc,mod) - #tb.connect(enc,code) - tb.connect (mod,(add,0)) - tb.connect (noise,(add,1)) - tb.connect (add,metrics_in,scale,dec,fsmi2s,dst) - - tb.run() - - #print code.data() - - ntotal = dst.ntotal () - nright = dst.nright () - runlength = dst.runlength () - return (ntotal,ntotal-nright) - - -def main(args): - nargs = len (args) - if nargs == 5: - fname_out=args[0] - fname_in=args[1] - esn0_db=float(args[2]) # Es/No in dB - IT=int(args[3]) - rep=int(args[4]) # number of times the experiment is run to collect enough errors - else: - sys.stderr.write ('usage: test_pccc_turbo.py fsm_name_1 fsm_fname_2 Es/No_db iterations repetitions\n') - sys.exit (1) - - # system parameters - Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) - fo=trellis.fsm(fname_out) # get the outer FSM specification from a file - fi=trellis.fsm(fname_in) # get the innner FSM specification from a file - bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol - if fo.I() != fi.I(): - sys.stderr.write ('Incompatible input cardinality between two FSMs.\n') - sys.exit (1) - K=Kb/bitspersymbol # packet size in trellis steps - interleaver=trellis.interleaver(K,666) # construct a random interleaver - #modulation = fsm_utils.psk8 # see fsm_utlis.py for available predefined modulations - dimensionality = 4 - constellation = [ 1, 0, 1, 0,\ - 1, 0,-1, 0,\ - 1, 0, 0, 1,\ - 1, 0, 0,-1,\ - -1, 0, 1, 0,\ - -1, 0,-1, 0,\ - -1, 0, 0, 1,\ - -1, 0, 0,-1,\ - 0, 1, 1, 0,\ - 0, 1,-1, 0,\ - 0, 1, 0, 1,\ - 0, 1, 0,-1,\ - 0,-1, 1, 0,\ - 0,-1,-1, 0,\ - 0,-1, 0, 1,\ - 0,-1, 0,-1,] # equivalent to 2 QPSK symbols - if len(constellation)/dimensionality != fi.O()*fo.O(): - sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') - sys.exit (1) - # calculate average symbol energy - Es = 0 - for i in range(len(constellation)): - Es = Es + constellation[i]**2 - Es = Es / (len(constellation)/dimensionality) - N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - for i in range(rep): - (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%10==0): # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - -if __name__ == '__main__': - main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/test_sccc_hard.py b/gr-trellis/src/examples/test_sccc_hard.py deleted file mode 100755 index e732ac2c0..000000000 --- a/gr-trellis/src/examples/test_sccc_hard.py +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import random -import fsm_utils - -def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): - tb = gr.top_block () - - - # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts - s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality - enc_out = trellis.encoder_ss(fo,0) # initial state = 0 - inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) - enc_in = trellis.encoder_ss(fi,0) # initial state = 0 - mod = gr.chunks_to_symbols_sf(constellation,dimensionality) - - # CHANNEL - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - # RX - metrics_in = trellis.metrics_f(fi.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner Viterbi - va_in = trellis.viterbi_s(fi,K,0,-1) # Put -1 if the Initial/Final states are not set. - deinter = trellis.permutation(interleaver.K(),interleaver.DEINTER(),1,gr.sizeof_short) - metrics_out = trellis.metrics_s(fo.O(),1,[0,1,2,3],digital.TRELLIS_HARD_SYMBOL) # data preprocessing to generate metrics for outer Viterbi (hard decisions) - va_out = trellis.viterbi_s(fo,K,0,-1) # Put -1 if the Initial/Final states are not set. - fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() - - tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) - tb.connect (mod,(add,0)) - tb.connect (noise,(add,1)) - tb.connect (add,metrics_in) - tb.connect (metrics_in,va_in,deinter,metrics_out,va_out,fsmi2s,dst) - - tb.run() - - ntotal = dst.ntotal () - nright = dst.nright () - runlength = dst.runlength () - return (ntotal,ntotal-nright) - - -def main(args): - nargs = len (args) - if nargs == 4: - fname_out=args[0] - fname_in=args[1] - esn0_db=float(args[2]) # Es/No in dB - rep=int(args[3]) # number of times the experiment is run to collect enough errors - else: - sys.stderr.write ('usage: test_tcm.py fsm_name_out fsm_fname_in Es/No_db repetitions\n') - sys.exit (1) - - # system parameters - Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) - fo=trellis.fsm(fname_out) # get the outer FSM specification from a file - fi=trellis.fsm(fname_in) # get the innner FSM specification from a file - bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol - if fo.O() != fi.I(): - sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') - sys.exit (1) - K=Kb/bitspersymbol # packet size in trellis steps - interleaver=trellis.interleaver(K,666) # construct a random interleaver - modulation = fsm_utils.psk8 # see fsm_utlis.py for available predefined modulations - dimensionality = modulation[0] - constellation = modulation[1] - if len(constellation)/dimensionality != fi.O(): - sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') - sys.exit (1) - # calculate average symbol energy - Es = 0 - for i in range(len(constellation)): - Es = Es + constellation[i]**2 - Es = Es / (len(constellation)/dimensionality) - N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - for i in range(rep): - (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%100==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - -if __name__ == '__main__': - main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/test_sccc_soft.py b/gr-trellis/src/examples/test_sccc_soft.py deleted file mode 100755 index 1c71e4ca7..000000000 --- a/gr-trellis/src/examples/test_sccc_soft.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import random -import fsm_utils - - - - -def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): - tb = gr.top_block () - - - # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts - s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality - enc_out = trellis.encoder_ss(fo,0) # initial state = 0 - inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) - enc_in = trellis.encoder_ss(fi,0) # initial state = 0 - mod = gr.chunks_to_symbols_sf(constellation,dimensionality) - - # CHANNEL - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - # RX - metrics_in = trellis.metrics_f(fi.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner Viterbi - gnd = gr.vector_source_f([0],True); - siso_in = trellis.siso_f(fi,K,0,-1,True,False,trellis.TRELLIS_MIN_SUM) # Put -1 if the Initial/Final states are not set. - deinter = trellis.permutation(interleaver.K(),interleaver.DEINTER(),fi.I(),gr.sizeof_float) - va_out = trellis.viterbi_s(fo,K,0,-1) # Put -1 if the Initial/Final states are not set. - fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() - - tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) - tb.connect (mod,(add,0)) - tb.connect (noise,(add,1)) - tb.connect (add,metrics_in) - tb.connect (gnd,(siso_in,0)) - tb.connect (metrics_in,(siso_in,1)) - tb.connect (siso_in,deinter,va_out,fsmi2s,dst) - - tb.run() - - ntotal = dst.ntotal () - nright = dst.nright () - runlength = dst.runlength () - return (ntotal,ntotal-nright) - - -def main(args): - nargs = len (args) - if nargs == 4: - fname_out=args[0] - fname_in=args[1] - esn0_db=float(args[2]) # Es/No in dB - rep=int(args[3]) # number of times the experiment is run to collect enough errors - else: - sys.stderr.write ('usage: test_tcm.py fsm_name_out fsm_fname_in Es/No_db repetitions\n') - sys.exit (1) - - # system parameters - Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) - fo=trellis.fsm(fname_out) # get the outer FSM specification from a file - fi=trellis.fsm(fname_in) # get the innner FSM specification from a file - bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol - if fo.O() != fi.I(): - sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') - sys.exit (1) - K=Kb/bitspersymbol # packet size in trellis steps - interleaver=trellis.interleaver(K,666) # construct a random interleaver - modulation = fsm_utils.psk8 # see fsm_utlis.py for available predefined modulations - dimensionality = modulation[0] - constellation = modulation[1] - if len(constellation)/dimensionality != fi.O(): - sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') - sys.exit (1) - # calculate average symbol energy - Es = 0 - for i in range(len(constellation)): - Es = Es + constellation[i]**2 - Es = Es / (len(constellation)/dimensionality) - N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance - - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - for i in range(rep): - (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%100==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - - -if __name__ == '__main__': - main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/test_sccc_turbo.py b/gr-trellis/src/examples/test_sccc_turbo.py deleted file mode 100755 index b1007a864..000000000 --- a/gr-trellis/src/examples/test_sccc_turbo.py +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import random -import fsm_utils - - - -def make_rx(tb,fo,fi,dimensionality,constellation,K,interleaver,IT,Es,N0,type): - metrics_in = trellis.metrics_f(fi.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner Viterbi - scale = gr.multiply_const_ff(1.0/N0) - gnd = gr.vector_source_f([0],True); - - inter=[] - deinter=[] - siso_in=[] - siso_out=[] - - # generate all blocks - for it in range(IT): - inter.append( trellis.permutation(interleaver.K(),interleaver.INTER(),fi.I(),gr.sizeof_float) ) - siso_in.append( trellis.siso_f(fi,K,0,-1,True,False,type) ) - deinter.append( trellis.permutation(interleaver.K(),interleaver.DEINTER(),fi.I(),gr.sizeof_float) ) - if it < IT-1: - siso_out.append( trellis.siso_f(fo,K,0,-1,False,True,type) ) - else: - siso_out.append( trellis.viterbi_s(fo,K,0,-1) ) # no soft outputs needed - - # connect first stage - tb.connect (gnd,inter[0]) - tb.connect (metrics_in,scale) - tb.connect (scale,(siso_in[0],1)) - - # connect the rest - for it in range(IT): - if it < IT-1: - tb.connect (metrics_in,(siso_in[it+1],1)) - tb.connect (siso_in[it],deinter[it],(siso_out[it],1)) - tb.connect (gnd,(siso_out[it],0)) - tb.connect (siso_out[it],inter[it+1]) - tb.connect (inter[it],(siso_in[it],0)) - else: - tb.connect (siso_in[it],deinter[it],siso_out[it]) - tb.connect (inter[it],(siso_in[it],0)) - - return (metrics_in,siso_out[IT-1]) - - -def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,seed): - tb = gr.top_block () - - - # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts - s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality - enc_out = trellis.encoder_ss(fo,0) # initial state = 0 - inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) - enc_in = trellis.encoder_ss(fi,0) # initial state = 0 - mod = gr.chunks_to_symbols_sf(constellation,dimensionality) - - # CHANNEL - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - # RX - (head,tail) = make_rx(tb,fo,fi,dimensionality,constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_MIN_SUM) - #(head,tail) = make_rx(tb,fo,fi,dimensionality,constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_SUM_PRODUCT) - fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() - - tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) - tb.connect (mod,(add,0)) - tb.connect (noise,(add,1)) - tb.connect (add,head) - tb.connect (tail,fsmi2s,dst) - - tb.run() - - #print enc_out.ST(), enc_in.ST() - - ntotal = dst.ntotal () - nright = dst.nright () - runlength = dst.runlength () - return (ntotal,ntotal-nright) - - -def main(args): - nargs = len (args) - if nargs == 5: - fname_out=args[0] - fname_in=args[1] - esn0_db=float(args[2]) # Es/No in dB - IT=int(args[3]) - rep=int(args[4]) # number of times the experiment is run to collect enough errors - else: - sys.stderr.write ('usage: test_sccc_turbo.py fsm_name_out fsm_fname_in Es/No_db iterations repetitions\n') - sys.exit (1) - - # system parameters - Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) - fo=trellis.fsm(fname_out) # get the outer FSM specification from a file - fi=trellis.fsm(fname_in) # get the innner FSM specification from a file - bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol - if fo.O() != fi.I(): - sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') - sys.exit (1) - K=Kb/bitspersymbol # packet size in trellis steps - interleaver=trellis.interleaver(K,666) # construct a random interleaver - modulation = fsm_utils.psk8 # see fsm_utlis.py for available predefined modulations - dimensionality = modulation[0] - constellation = modulation[1] - if len(constellation)/dimensionality != fi.O(): - sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') - sys.exit (1) - # calculate average symbol energy - Es = 0 - for i in range(len(constellation)): - Es = Es + constellation[i]**2 - Es = Es / (len(constellation)/dimensionality) - N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - for i in range(rep): - (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%10==0): # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - -if __name__ == '__main__': - main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/test_sccc_turbo1.py b/gr-trellis/src/examples/test_sccc_turbo1.py deleted file mode 100755 index ad2ed6bf9..000000000 --- a/gr-trellis/src/examples/test_sccc_turbo1.py +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import random -import fsm_utils - - -def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,seed): - tb = gr.top_block () - - # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts - s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality - enc = trellis.sccc_encoder_ss(fo,0,fi,0,interleaver,K) - mod = gr.chunks_to_symbols_sf(constellation,dimensionality) - - # CHANNEL - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - # RX - dec = trellis.sccc_decoder_combined_fs(fo,0,-1,fi,0,-1,interleaver,K,IT,trellis.TRELLIS_MIN_SUM,dimensionality,constellation,digital.TRELLIS_EUCLIDEAN,1.0) - fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() - - #tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) - tb.connect (src,src_head,s2fsmi,enc,mod) - tb.connect (mod,(add,0)) - tb.connect (noise,(add,1)) - #tb.connect (add,head) - #tb.connect (tail,fsmi2s,dst) - tb.connect (add,dec,fsmi2s,dst) - - tb.run() - - #print enc_out.ST(), enc_in.ST() - - ntotal = dst.ntotal () - nright = dst.nright () - runlength = dst.runlength () - return (ntotal,ntotal-nright) - - -def main(args): - nargs = len (args) - if nargs == 5: - fname_out=args[0] - fname_in=args[1] - esn0_db=float(args[2]) # Es/No in dB - IT=int(args[3]) - rep=int(args[4]) # number of times the experiment is run to collect enough errors - else: - sys.stderr.write ('usage: test_tcm.py fsm_name_out fsm_fname_in Es/No_db iterations repetitions\n') - sys.exit (1) - - # system parameters - Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) - fo=trellis.fsm(fname_out) # get the outer FSM specification from a file - fi=trellis.fsm(fname_in) # get the innner FSM specification from a file - bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol - if fo.O() != fi.I(): - sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') - sys.exit (1) - K=Kb/bitspersymbol # packet size in trellis steps - interleaver=trellis.interleaver(K,666) # construct a random interleaver - modulation = fsm_utils.psk8 # see fsm_utlis.py for available predefined modulations - dimensionality = modulation[0] - constellation = modulation[1] - if len(constellation)/dimensionality != fi.O(): - sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') - sys.exit (1) - # calculate average symbol energy - Es = 0 - for i in range(len(constellation)): - Es = Es + constellation[i]**2 - Es = Es / (len(constellation)/dimensionality) - N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - for i in range(rep): - (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%10==0): # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - -if __name__ == '__main__': - main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/test_sccc_turbo2.py b/gr-trellis/src/examples/test_sccc_turbo2.py deleted file mode 100755 index fdb92adc8..000000000 --- a/gr-trellis/src/examples/test_sccc_turbo2.py +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import random -import fsm_utils - - -def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,seed): - tb = gr.top_block () - - # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts - s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality - enc = trellis.sccc_encoder_ss(fo,0,fi,0,interleaver,K) - mod = gr.chunks_to_symbols_sf(constellation,dimensionality) - - # CHANNEL - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - # RX - metrics_in = trellis.metrics_f(fi.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO - scale = gr.multiply_const_ff(1.0/N0) - dec = trellis.sccc_decoder_s(fo,0,-1,fi,0,-1,interleaver,K,IT,trellis.TRELLIS_MIN_SUM) - fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() - - #tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) - tb.connect (src,src_head,s2fsmi,enc,mod) - tb.connect (mod,(add,0)) - tb.connect (noise,(add,1)) - #tb.connect (add,head) - #tb.connect (tail,fsmi2s,dst) - tb.connect (add,metrics_in,scale,dec,fsmi2s,dst) - - tb.run() - - #print enc_out.ST(), enc_in.ST() - - ntotal = dst.ntotal () - nright = dst.nright () - runlength = dst.runlength () - return (ntotal,ntotal-nright) - - -def main(args): - nargs = len (args) - if nargs == 5: - fname_out=args[0] - fname_in=args[1] - esn0_db=float(args[2]) # Es/No in dB - IT=int(args[3]) - rep=int(args[4]) # number of times the experiment is run to collect enough errors - else: - sys.stderr.write ('usage: test_tcm.py fsm_name_out fsm_fname_in Es/No_db iterations repetitions\n') - sys.exit (1) - - # system parameters - Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) - fo=trellis.fsm(fname_out) # get the outer FSM specification from a file - fi=trellis.fsm(fname_in) # get the innner FSM specification from a file - bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol - if fo.O() != fi.I(): - sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') - sys.exit (1) - K=Kb/bitspersymbol # packet size in trellis steps - interleaver=trellis.interleaver(K,666) # construct a random interleaver - modulation = fsm_utils.psk8 # see fsm_utlis.py for available predefined modulations - dimensionality = modulation[0] - constellation = modulation[1] - if len(constellation)/dimensionality != fi.O(): - sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') - sys.exit (1) - # calculate average symbol energy - Es = 0 - for i in range(len(constellation)): - Es = Es + constellation[i]**2 - Es = Es / (len(constellation)/dimensionality) - N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - for i in range(rep): - (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%10==0): # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - -if __name__ == '__main__': - main (sys.argv[1:]) diff --git a/gr-trellis/src/examples/test_tcm.py b/gr-trellis/src/examples/test_tcm.py deleted file mode 100755 index 62fd5135e..000000000 --- a/gr-trellis/src/examples/test_tcm.py +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import random -import fsm_utils -from gnuradio.eng_option import eng_option -from optparse import OptionParser - -def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): - tb = gr.top_block () - - - # TX - #packet = [0]*Kb - #for i in range(Kb-1*16): # last 16 bits = 0 to drive the final state to 0 - #packet[i] = random.randint(0, 1) # random 0s and 1s - #src = gr.vector_source_s(packet,False) - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts - #b2s = gr.unpacked_to_packed_ss(1,gr.GR_MSB_FIRST) # pack bits in shorts - s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality - enc = trellis.encoder_ss(f,0) # initial state = 0 - mod = gr.chunks_to_symbols_sf(constellation,dimensionality) - - # CHANNEL - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - # RX - metrics = trellis.metrics_f(f.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi - va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. - fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - #s2b = gr.packed_to_unpacked_ss(1,gr.GR_MSB_FIRST) # unpack shorts to bits - #dst = gr.vector_sink_s(); - dst = gr.check_lfsr_32k_s() - - - tb.connect (src,src_head,s2fsmi,enc,mod) - #tb.connect (src,b2s,s2fsmi,enc,mod) - tb.connect (mod,(add,0)) - tb.connect (noise,(add,1)) - tb.connect (add,metrics) - tb.connect (metrics,va,fsmi2s,dst) - #tb.connect (metrics,va,fsmi2s,s2b,dst) - - - tb.run() - - # A bit of cheating: run the program once and print the - # final encoder state.. - # Then put it as the last argument in the viterbi block - #print "final state = " , enc.ST() - - ntotal = dst.ntotal () - nright = dst.nright () - runlength = dst.runlength () - #ntotal = len(packet) - #if len(dst.data()) != ntotal: - #print "Error: not enough data\n" - #nright = 0; - #for i in range(ntotal): - #if packet[i]==dst.data()[i]: - #nright=nright+1 - #else: - #print "Error in ", i - return (ntotal,ntotal-nright) - - - - -def main(): - parser = OptionParser(option_class=eng_option) - parser.add_option("-f", "--fsm_file", type="string", default="fsm_files/awgn1o2_4.fsm", help="Filename containing the fsm specification, e.g. -f fsm_files/awgn1o2_4.fsm (default=fsm_files/awgn1o2_4.fsm)") - parser.add_option("-e", "--esn0", type="eng_float", default=10.0, help="Symbol energy to noise PSD level ratio in dB, e.g., -e 10.0 (default=10.0)") - parser.add_option("-r", "--repetitions", type="int", default=100, help="Number of packets to be generated for the simulation, e.g., -r 100 (default=100)") - - (options, args) = parser.parse_args () - if len(args) != 0: - parser.print_help() - raise SystemExit, 1 - - fname=options.fsm_file - esn0_db=float(options.esn0) - rep=int(options.repetitions) - - # system parameters - f=trellis.fsm(fname) # get the FSM specification from a file - # alternatively you can specify the fsm from its generator matrix - #f=trellis.fsm(1,2,[5,7]) - Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) - bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol - K=Kb/bitspersymbol # packet size in trellis steps - modulation = fsm_utils.psk4 # see fsm_utlis.py for available predefined modulations - dimensionality = modulation[0] - constellation = modulation[1] - if len(constellation)/dimensionality != f.O(): - sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') - sys.exit (1) - # calculate average symbol energy - Es = 0 - for i in range(len(constellation)): - Es = Es + constellation[i]**2 - Es = Es / (len(constellation)/dimensionality) - N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - for i in range(rep): - (s,e)=run_test(f,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%100==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - - -if __name__ == '__main__': - main() diff --git a/gr-trellis/src/examples/test_tcm_bit.py b/gr-trellis/src/examples/test_tcm_bit.py deleted file mode 100755 index cc5caefbc..000000000 --- a/gr-trellis/src/examples/test_tcm_bit.py +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import random -import fsm_utils -from gnuradio.eng_option import eng_option -from optparse import OptionParser - - -def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): - tb = gr.top_block () - - # TX - packet = [0]*Kb - # this for loop is TOO slow!!! - for i in range(Kb-1*16): # last 16 bits = 0 to drive the final state to 0 - packet[i] = random.randint(0, 1) # random 0s and 1s - src = gr.vector_source_s(packet,False) - #src = gr.lfsr_32k_source_s() - #src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts - b2s = gr.unpacked_to_packed_ss(1,gr.GR_MSB_FIRST) # pack bits in shorts - s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality - enc = trellis.encoder_ss(f,0) # initial state = 0 - mod = gr.chunks_to_symbols_sf(constellation,dimensionality) - - - # CHANNEL - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - - # RX - metrics = trellis.metrics_f(f.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi - va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. - fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - s2b = gr.packed_to_unpacked_ss(1,gr.GR_MSB_FIRST) # unpack shorts to bits - dst = gr.vector_sink_s(); - #dst = gr.check_lfsr_32k_s(); - - - #tb.connect (src,src_head,s2fsmi,enc,mod) - tb.connect (src,b2s,s2fsmi,enc,mod) - tb.connect (mod,(add,0)) - tb.connect (noise,(add,1)) - tb.connect (add,metrics) - #tb.connect (metrics,va,fsmi2s,dst) - tb.connect (metrics,va,fsmi2s,s2b,dst) - - - tb.run() - - # A bit of cheating: run the program once and print the - # final encoder state.. - # Then put it as the last argument in the viterbi block - #print "final state = " , enc.ST() - - #ntotal = dst.ntotal () - #nright = dst.nright () - #runlength = dst.runlength () - ntotal = len(packet) - if len(dst.data()) != ntotal: - print "Error: not enough data\n" - nright = 0; - # this for loop is TOO slow!!! - for i in range(ntotal): - if packet[i]==dst.data()[i]: - nright=nright+1 - #else: - #print "Error in ", i - return (ntotal,ntotal-nright) - - - - -def main(): - parser = OptionParser(option_class=eng_option) - parser.add_option("-f", "--fsm_file", type="string", default="fsm_files/awgn1o2_4.fsm", help="Filename containing the fsm specification, e.g. -f fsm_files/awgn1o2_4.fsm (default=fsm_files/awgn1o2_4.fsm)") - parser.add_option("-e", "--esn0", type="eng_float", default=10.0, help="Symbol energy to noise PSD level ratio in dB, e.g., -e 10.0 (default=10.0)") - parser.add_option("-r", "--repetitions", type="int", default=100, help="Number of packets to be generated for the simulation, e.g., -r 100 (default=100)") - - (options, args) = parser.parse_args () - if len(args) != 0: - parser.print_help() - raise SystemExit, 1 - - fname=options.fsm_file - esn0_db=float(options.esn0) - rep=int(options.repetitions) - - - # system parameters - f=trellis.fsm(fname) # get the FSM specification from a file - Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) - bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol - K=Kb/bitspersymbol # packet size in trellis steps - modulation = fsm_utils.psk4 # see fsm_utlis.py for available predefined modulations - dimensionality = modulation[0] - constellation = modulation[1] - if len(constellation)/dimensionality != f.O(): - sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') - sys.exit (1) - # calculate average symbol energy - Es = 0 - for i in range(len(constellation)): - Es = Es + constellation[i]**2 - Es = Es / (len(constellation)/dimensionality) - N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - for i in range(rep): - (s,e)=run_test(f,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%1==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - - -if __name__ == '__main__': - main() diff --git a/gr-trellis/src/examples/test_tcm_combined.py b/gr-trellis/src/examples/test_tcm_combined.py deleted file mode 100755 index 55a3043b8..000000000 --- a/gr-trellis/src/examples/test_tcm_combined.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import fsm_utils -from gnuradio.eng_option import eng_option -from optparse import OptionParser - - -def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): - tb = gr.top_block () - - # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts - s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality - enc = trellis.encoder_ss(f,0) # initial state = 0 - mod = gr.chunks_to_symbols_sf(constellation,dimensionality) - - - # CHANNEL - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - - # RX - va = trellis.viterbi_combined_fs(f,K,0,-1,dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # Put -1 if the Initial/Final states are not set. - fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s(); - - - tb.connect (src,src_head,s2fsmi,enc,mod) - tb.connect (mod,(add,0)) - tb.connect (noise,(add,1)) - tb.connect (add,va,fsmi2s,dst) - - - tb.run() - - # A bit of cheating: run the program once and print the - # final encoder state.. - # Then put it as the last argument in the viterbi block - #print "final state = " , enc.ST() - - ntotal = dst.ntotal () - nright = dst.nright () - runlength = dst.runlength () - - return (ntotal,ntotal-nright) - - - - -def main(): - parser = OptionParser(option_class=eng_option) - parser.add_option("-f", "--fsm_file", type="string", default="fsm_files/awgn1o2_4.fsm", help="Filename containing the fsm specification, e.g. -f fsm_files/awgn1o2_4.fsm (default=fsm_files/awgn1o2_4.fsm)") - parser.add_option("-e", "--esn0", type="eng_float", default=10.0, help="Symbol energy to noise PSD level ratio in dB, e.g., -e 10.0 (default=10.0)") - parser.add_option("-r", "--repetitions", type="int", default=100, help="Number of packets to be generated for the simulation, e.g., -r 100 (default=100)") - - (options, args) = parser.parse_args () - if len(args) != 0: - parser.print_help() - raise SystemExit, 1 - - fname=options.fsm_file - esn0_db=float(options.esn0) - rep=int(options.repetitions) - - # system parameters - f=trellis.fsm(fname) # get the FSM specification from a file (will hopefully be automated in the future...) - Kb=1024*16 # packet size in bits (make it multiple of 16) - bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol - K=Kb/bitspersymbol # packet size in trellis steps - modulation = fsm_utils.psk4 # see fsm_utils.py for available predefined modulations - dimensionality = modulation[0] - constellation = modulation[1] - if len(constellation)/dimensionality != f.O(): - sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') - sys.exit (1) - # calculate average symbol energy - Es = 0 - for i in range(len(constellation)): - Es = Es + constellation[i]**2 - Es = Es / (len(constellation)/dimensionality) - N0=Es/pow(10.0,esn0_db/10.0); # noise variance - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - for i in range(rep): - (s,e)=run_test(f,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%100==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - - -if __name__ == '__main__': - main() - diff --git a/gr-trellis/src/examples/test_tcm_parallel.py b/gr-trellis/src/examples/test_tcm_parallel.py deleted file mode 100755 index 2b722c09e..000000000 --- a/gr-trellis/src/examples/test_tcm_parallel.py +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import fsm_utils -from gnuradio.eng_option import eng_option -from optparse import OptionParser - - -def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed,P): - tb = gr.top_block () - - # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16*P) # packet size in shorts - s2fsmi=gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality - s2p = gr.stream_to_streams(gr.sizeof_short,P) # serial to parallel - enc = trellis.encoder_ss(f,0) # initiali state = 0 - mod = gr.chunks_to_symbols_sf(constellation,dimensionality) - - # CHANNEL - add=[] - noise=[] - for i in range(P): - add.append(gr.add_ff()) - noise.append(gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed)) - - # RX - metrics = trellis.metrics_f(f.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi - va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. - p2s = gr.streams_to_stream(gr.sizeof_short,P) # parallel to serial - fsmi2s=gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() - - tb.connect (src,src_head,s2fsmi,s2p) - for i in range(P): - tb.connect ((s2p,i),(enc,i),(mod,i)) - tb.connect ((mod,i),(add[i],0)) - tb.connect (noise[i],(add[i],1)) - tb.connect (add[i],(metrics,i)) - tb.connect ((metrics,i),(va,i),(p2s,i)) - tb.connect (p2s,fsmi2s,dst) - - - tb.run() - - # A bit of cheating: run the program once and print the - # final encoder state. - # Then put it as the last argument in the viterbi block - #print "final state = " , enc.ST() - - ntotal = dst.ntotal () - nright = dst.nright () - runlength = dst.runlength () - - return (ntotal,ntotal-nright) - - - -def main(): - parser = OptionParser(option_class=eng_option) - parser.add_option("-f", "--fsm_file", type="string", default="fsm_files/awgn1o2_4.fsm", help="Filename containing the fsm specification, e.g. -f fsm_files/awgn1o2_4.fsm (default=fsm_files/awgn1o2_4.fsm)") - parser.add_option("-e", "--esn0", type="eng_float", default=10.0, help="Symbol energy to noise PSD level ratio in dB, e.g., -e 10.0 (default=10.0)") - parser.add_option("-r", "--repetitions", type="int", default=100, help="Number of packets to be generated for the simulation, e.g., -r 100 (default=100)") - - (options, args) = parser.parse_args () - if len(args) != 0: - parser.print_help() - raise SystemExit, 1 - - fname=options.fsm_file - esn0_db=float(options.esn0) - rep=int(options.repetitions) - - # system parameters - f=trellis.fsm(fname) # get the FSM specification from a file - P=4 # how many parallel streams? - Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) - bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol - K=Kb/bitspersymbol # packet size in trellis steps - modulation = fsm_utils.psk4 # see fsm_utlis.py for available predefined modulations - dimensionality = modulation[0] - constellation = modulation[1] - if len(constellation)/dimensionality != f.O(): - sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') - sys.exit (1) - # calculate average symbol energy - Es = 0 - for i in range(len(constellation)): - Es = Es + constellation[i]**2 - Es = Es / (len(constellation)/dimensionality) - N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - for i in range(rep): - (s,e)=run_test(f,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i),P) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%100==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - -if __name__ == '__main__': - main() - diff --git a/gr-trellis/src/examples/test_turbo_equalization.py b/gr-trellis/src/examples/test_turbo_equalization.py deleted file mode 100755 index 6fa6749f0..000000000 --- a/gr-trellis/src/examples/test_turbo_equalization.py +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import fsm_utils - - -def make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,type): - metrics_in = trellis.metrics_f(fi.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO - scale = gr.multiply_const_ff(1.0/N0) - gnd = gr.vector_source_f([0],True); - - inter=[] - deinter=[] - siso_in=[] - siso_out=[] - - # generate all blocks - for it in range(IT): - inter.append( trellis.permutation(interleaver.K(),interleaver.INTER(),fi.I(),gr.sizeof_float) ) - siso_in.append( trellis.siso_f(fi,K,0,-1,True,False,type) ) - deinter.append( trellis.permutation(interleaver.K(),interleaver.DEINTER(),fi.I(),gr.sizeof_float) ) - if it < IT-1: - siso_out.append( trellis.siso_f(fo,K,0,-1,False,True,type) ) - else: - siso_out.append( trellis.viterbi_s(fo,K,0,-1) ) # no soft outputs needed - - # connect first stage - tb.connect (gnd,inter[0]) - tb.connect (metrics_in,scale) - tb.connect (scale,(siso_in[0],1)) - - # connect the rest - for it in range(IT): - if it < IT-1: - tb.connect (metrics_in,(siso_in[it+1],1)) - tb.connect (siso_in[it],deinter[it],(siso_out[it],1)) - tb.connect (gnd,(siso_out[it],0)) - tb.connect (siso_out[it],inter[it+1]) - tb.connect (inter[it],(siso_in[it],0)) - else: - tb.connect (siso_in[it],deinter[it],siso_out[it]) - tb.connect (inter[it],(siso_in[it],0)) - - return (metrics_in,siso_out[IT-1]) - - -def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,tot_constellation,Es,N0,IT,seed): - tb = gr.top_block () - - # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts - s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the iouter FSM input cardinality - enc_out = trellis.encoder_ss(fo,0) # initial state = 0 - inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) - enc_in = trellis.encoder_ss(fi,0) # initial state = 0 - # essentially here we implement the combination of modulation and channel as a memoryless modulation (the memory induced by the channel is hidden in the innner FSM) - mod = gr.chunks_to_symbols_sf(tot_constellation,dimensionality) - - # CHANNEL - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - # RX - (head,tail) = make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_MIN_SUM) - fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s(); - - tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) - tb.connect (mod,(add,0)) - tb.connect (noise,(add,1)) - tb.connect (add,head) - tb.connect (tail,fsmi2s,dst) - - tb.run() - - ntotal = dst.ntotal () - nright = dst.nright () - runlength = dst.runlength () - #print ntotal,nright,runlength - - return (ntotal,ntotal-nright) - - - - -def main(args): - nargs = len (args) - if nargs == 3: - fname_out=args[0] - esn0_db=float(args[1]) - rep=int(args[2]) - else: - sys.stderr.write ('usage: test_turbo_equalization.py fsm_name_out Es/No_db repetitions\n') - sys.exit (1) - - # system parameters - Kb=64*16 # packet size in bits (multiple of 16) - modulation = fsm_utils.pam4 # see fsm_utlis.py for available predefined modulations - channel = fsm_utils.c_channel # see fsm_utlis.py for available predefined test channels - fo=trellis.fsm(fname_out) # get the outer FSM specification from a file - fi=trellis.fsm(len(modulation[1]),len(channel)) # generate the FSM automatically - if fo.O() != fi.I(): - sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') - sys.exit (1) - bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol - K=Kb/bitspersymbol # packet size in trellis steps - print 'size = ',K - interleaver=trellis.interleaver(K,666) # construct a random interleaver - tot_channel = fsm_utils.make_isi_lookup(modulation,channel,True) # generate the lookup table (normalize energy to 1) - dimensionality = tot_channel[0] - tot_constellation = tot_channel[1] - if len(tot_constellation)/dimensionality != fi.O(): - sys.stderr.write ('Incompatible FSM output cardinality and lookup table size.\n') - sys.exit (1) - N0=pow(10.0,-esn0_db/10.0); # noise variance - IT = 3 # number of turbo iterations - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - - for i in range(rep): - (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,tot_constellation,1,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations - print s - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%10==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - - -if __name__ == '__main__': - main (sys.argv[1:]) - diff --git a/gr-trellis/src/examples/test_turbo_equalization1.py b/gr-trellis/src/examples/test_turbo_equalization1.py deleted file mode 100755 index 15a8f6809..000000000 --- a/gr-trellis/src/examples/test_turbo_equalization1.py +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import random -import fsm_utils - -def make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,type): - metrics_in = trellis.metrics_f(fi.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO - scale = gr.multiply_const_ff(1.0/N0) - gnd = gr.vector_source_f([0],True); - - inter=[] - deinter=[] - siso_in=[] - siso_out=[] - - # generate all blocks - for it in range(IT): - inter.append( trellis.permutation(interleaver.K(),interleaver.INTER(),fi.I(),gr.sizeof_float) ) - siso_in.append( trellis.siso_f(fi,K,0,-1,True,False,type) ) - deinter.append( trellis.permutation(interleaver.K(),interleaver.DEINTER(),fi.I(),gr.sizeof_float) ) - if it < IT-1: - siso_out.append( trellis.siso_f(fo,K,0,-1,False,True,type) ) - else: - siso_out.append( trellis.viterbi_s(fo,K,0,-1) ) # no soft outputs needed - - # connect first stage - tb.connect (gnd,inter[0]) - tb.connect (metrics_in,scale) - tb.connect (scale,(siso_in[0],1)) - - # connect the rest - for it in range(IT): - if it < IT-1: - tb.connect (scale,(siso_in[it+1],1)) - tb.connect (siso_in[it],deinter[it],(siso_out[it],1)) - tb.connect (gnd,(siso_out[it],0)) - tb.connect (siso_out[it],inter[it+1]) - tb.connect (inter[it],(siso_in[it],0)) - else: - tb.connect (siso_in[it],deinter[it],siso_out[it]) - tb.connect (inter[it],(siso_in[it],0)) - - return (metrics_in,siso_out[IT-1]) - - -def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,Es,N0,IT,seed): - tb = gr.top_block () - L = len(channel) - - # TX - # this for loop is TOO slow in python!!! - packet = [0]*(K) - random.seed(seed) - for i in range(len(packet)): - packet[i] = random.randint(0, 2**bitspersymbol - 1) # random symbols - src = gr.vector_source_s(packet,False) - enc_out = trellis.encoder_ss(fo,0) # initial state = 0 - inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) - mod = gr.chunks_to_symbols_sf(modulation[1],modulation[0]) - - # CHANNEL - isi = gr.fir_filter_fff(1,channel) - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - # RX - (head,tail) = make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_MIN_SUM) - dst = gr.vector_sink_s(); - - tb.connect (src,enc_out,inter,mod) - tb.connect (mod,isi,(add,0)) - tb.connect (noise,(add,1)) - tb.connect (add,head) - tb.connect (tail,dst) - - tb.run() - - data = dst.data() - ntotal = len(data) - nright=0 - for i in range(ntotal): - if packet[i]==data[i]: - nright=nright+1 - #else: - #print "Error in ", i - - return (ntotal,ntotal-nright) - - - - -def main(args): - nargs = len (args) - if nargs == 3: - fname_out=args[0] - esn0_db=float(args[1]) - rep=int(args[2]) - else: - sys.stderr.write ('usage: test_turbo_equalization.py fsm_name_out Es/No_db repetitions\n') - sys.exit (1) - - # system parameters - Kb=64*16 # packet size in bits (multiple of 16) - modulation = fsm_utils.pam4 # see fsm_utlis.py for available predefined modulations - channel = fsm_utils.c_channel # see fsm_utlis.py for available predefined test channels - fo=trellis.fsm(fname_out) # get the outer FSM specification from a file - fi=trellis.fsm(len(modulation[1]),len(channel)) # generate the FSM automatically - if fo.O() != fi.I(): - sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') - sys.exit (1) - bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol - K=Kb/bitspersymbol # packet size in trellis steps - interleaver=trellis.interleaver(K,666) # construct a random interleaver - tot_channel = fsm_utils.make_isi_lookup(modulation,channel,True) # generate the lookup table (normalize energy to 1) - dimensionality = tot_channel[0] - tot_constellation = tot_channel[1] - if len(tot_constellation)/dimensionality != fi.O(): - sys.stderr.write ('Incompatible FSM output cardinality and lookup table size.\n') - sys.exit (1) - N0=pow(10.0,-esn0_db/10.0); # noise variance - IT = 3 # number of turbo iterations - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - - for i in range(rep): - (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,1,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%10==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - - -if __name__ == '__main__': - main (sys.argv[1:]) - diff --git a/gr-trellis/src/examples/test_turbo_equalization2.py b/gr-trellis/src/examples/test_turbo_equalization2.py deleted file mode 100755 index 7e4341cba..000000000 --- a/gr-trellis/src/examples/test_turbo_equalization2.py +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import random -import fsm_utils - -def make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,type): - scale = gr.multiply_const_ff(math.sqrt(1.0/N0)) - gnd = gr.vector_source_f([0],True); - - inter=[] - deinter=[] - siso_in=[] - siso_out=[] - - # generate all blocks - for it in range(IT): - inter.append( trellis.permutation(interleaver.K(),interleaver.INTER(),fi.I(),gr.sizeof_float) ) - siso_in.append( trellis.siso_combined_f(fi,K,0,-1,True,False,type,dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) ) - deinter.append( trellis.permutation(interleaver.K(),interleaver.DEINTER(),fi.I(),gr.sizeof_float) ) - if it < IT-1: - siso_out.append( trellis.siso_f(fo,K,0,-1,False,True,type) ) - else: - siso_out.append( trellis.viterbi_s(fo,K,0,-1) ) # no soft outputs needed - - # connect first stage - tb.connect (gnd,inter[0]) - tb.connect (scale,(siso_in[0],1)) - - # connect the rest - for it in range(IT): - if it < IT-1: - tb.connect (scale,(siso_in[it+1],1)) - tb.connect (siso_in[it],deinter[it],(siso_out[it],1)) - tb.connect (gnd,(siso_out[it],0)) - tb.connect (siso_out[it],inter[it+1]) - tb.connect (inter[it],(siso_in[it],0)) - else: - tb.connect (siso_in[it],deinter[it],siso_out[it]) - tb.connect (inter[it],(siso_in[it],0)) - - return (scale,siso_out[IT-1]) - - -def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,Es,N0,IT,seed): - tb = gr.top_block () - L = len(channel) - - # TX - # this for loop is TOO slow in python!!! - packet = [0]*(K) - random.seed(seed) - for i in range(len(packet)): - packet[i] = random.randint(0, 2**bitspersymbol - 1) # random symbols - src = gr.vector_source_s(packet,False) - enc_out = trellis.encoder_ss(fo,0) # initial state = 0 - inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) - mod = gr.chunks_to_symbols_sf(modulation[1],modulation[0]) - - # CHANNEL - isi = gr.fir_filter_fff(1,channel) - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - # RX - (head,tail) = make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_MIN_SUM) - dst = gr.vector_sink_s(); - - tb.connect (src,enc_out,inter,mod) - tb.connect (mod,isi,(add,0)) - tb.connect (noise,(add,1)) - tb.connect (add,head) - tb.connect (tail,dst) - - tb.run() - - data = dst.data() - ntotal = len(data) - nright=0 - for i in range(ntotal): - if packet[i]==data[i]: - nright=nright+1 - #else: - #print "Error in ", i - - return (ntotal,ntotal-nright) - - - - -def main(args): - nargs = len (args) - if nargs == 3: - fname_out=args[0] - esn0_db=float(args[1]) - rep=int(args[2]) - else: - sys.stderr.write ('usage: test_turbo_equalization.py fsm_name_out Es/No_db repetitions\n') - sys.exit (1) - - # system parameters - Kb=64*16 # packet size in bits (multiple of 16) - modulation = fsm_utils.pam4 # see fsm_utlis.py for available predefined modulations - channel = fsm_utils.c_channel # see fsm_utlis.py for available predefined test channels - fo=trellis.fsm(fname_out) # get the outer FSM specification from a file - fi=trellis.fsm(len(modulation[1]),len(channel)) # generate the FSM automatically - if fo.O() != fi.I(): - sys.stderr.write ('Incompatible cardinality between outer and inner FSM.\n') - sys.exit (1) - bitspersymbol = int(round(math.log(fo.I())/math.log(2))) # bits per FSM input symbol - K=Kb/bitspersymbol # packet size in trellis steps - interleaver=trellis.interleaver(K,666) # construct a random interleaver - tot_channel = fsm_utils.make_isi_lookup(modulation,channel,True) # generate the lookup table (normalize energy to 1) - dimensionality = tot_channel[0] - N0=pow(10.0,-esn0_db/10.0); # noise variance - tot_constellation =[0]*len(tot_channel[1]) - for i in range(len(tot_channel[1])): - tot_constellation[i] = tot_channel[1][i] * math.sqrt(1.0/N0) - if len(tot_constellation)/dimensionality != fi.O(): - sys.stderr.write ('Incompatible FSM output cardinality and lookup table size.\n') - sys.exit (1) - IT = 3 # number of turbo iterations - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - - for i in range(rep): - (s,e)=run_test(fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,1,N0,IT,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%10==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - - -if __name__ == '__main__': - main (sys.argv[1:]) - diff --git a/gr-trellis/src/examples/test_viterbi_equalization.py b/gr-trellis/src/examples/test_viterbi_equalization.py deleted file mode 100755 index d290a0d0a..000000000 --- a/gr-trellis/src/examples/test_viterbi_equalization.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import fsm_utils - -def run_test (f,Kb,bitspersymbol,K,dimensionality,tot_constellation,N0,seed): - tb = gr.top_block () - - # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts - s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality - enc = trellis.encoder_ss(f,0) # initial state = 0 - # essentially here we implement the combination of modulation and channel as a memoryless modulation (the memory induced by the channel is hidden in the FSM) - mod = gr.chunks_to_symbols_sf(tot_constellation,dimensionality) - - # CHANNEL - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - # RX - metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi - va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. - fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s(); - - tb.connect (src,src_head,s2fsmi,enc,mod) - tb.connect (mod,(add,0)) - tb.connect (noise,(add,1)) - tb.connect (add,metrics) - tb.connect (metrics,va,fsmi2s,dst) - - tb.run() - - ntotal = dst.ntotal () - nright = dst.nright () - runlength = dst.runlength () - #print ntotal,nright,runlength - - return (ntotal,ntotal-nright) - - - - -def main(args): - nargs = len (args) - if nargs == 2: - esn0_db=float(args[0]) - rep=int(args[1]) - else: - sys.stderr.write ('usage: test_viterbi_equalization.py Es/No_db repetitions\n') - sys.exit (1) - - # system parameters - Kb=128*16 # packet size in bits (multiple of 16) - modulation = fsm_utils.pam4 # see fsm_utlis.py for available predefined modulations - channel = fsm_utils.c_channel # see fsm_utlis.py for available predefined test channels - f=trellis.fsm(len(modulation[1]),len(channel)) # generate the FSM automatically - bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol - K=Kb/bitspersymbol # packet size in trellis steps - - tot_channel = fsm_utils.make_isi_lookup(modulation,channel,True) # generate the lookup table (normalize energy to 1) - dimensionality = tot_channel[0] - tot_constellation = tot_channel[1] - N0=pow(10.0,-esn0_db/10.0); # noise variance - if len(tot_constellation)/dimensionality != f.O(): - sys.stderr.write ('Incompatible FSM output cardinality and lookup table size.\n') - sys.exit (1) - - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - - for i in range(rep): - (s,e)=run_test(f,Kb,bitspersymbol,K,dimensionality,tot_constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%100==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or bit) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - - -if __name__ == '__main__': - main (sys.argv[1:]) - diff --git a/gr-trellis/src/examples/test_viterbi_equalization1.py b/gr-trellis/src/examples/test_viterbi_equalization1.py deleted file mode 100755 index 41f777551..000000000 --- a/gr-trellis/src/examples/test_viterbi_equalization1.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import trellis, digital -from gnuradio import eng_notation -import math -import sys -import random -import fsm_utils - -def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,N0,seed): - tb = gr.top_block () - L = len(channel) - - # TX - # this for loop is TOO slow in python!!! - packet = [0]*(K+2*L) - random.seed(seed) - for i in range(len(packet)): - packet[i] = random.randint(0, 2**bitspersymbol - 1) # random symbols - for i in range(L): # first/last L symbols set to 0 - packet[i] = 0 - packet[len(packet)-i-1] = 0 - src = gr.vector_source_s(packet,False) - mod = gr.chunks_to_symbols_sf(modulation[1],modulation[0]) - - # CHANNEL - isi = gr.fir_filter_fff(1,channel) - add = gr.add_ff() - noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) - - # RX - skip = gr.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols - #metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi - #va = trellis.viterbi_s(f,K+L,-1,0) # Put -1 if the Initial/Final states are not set. - va = trellis.viterbi_combined_fs(f,K+L,0,0,dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # using viterbi_combined_fs instead of metrics_f/viterbi_s allows larger packet lengths because metrics_f is complaining for not being able to allocate large buffers. This is due to the large f.O() in this application... - dst = gr.vector_sink_s() - - tb.connect (src,mod) - tb.connect (mod,isi,(add,0)) - tb.connect (noise,(add,1)) - #tb.connect (add,metrics) - #tb.connect (metrics,va,dst) - tb.connect (add,skip,va,dst) - - tb.run() - - data = dst.data() - ntotal = len(data) - L - nright=0 - for i in range(ntotal): - if packet[i+L]==data[i]: - nright=nright+1 - #else: - #print "Error in ", i - - return (ntotal,ntotal-nright) - - -def main(args): - nargs = len (args) - if nargs == 2: - esn0_db=float(args[0]) - rep=int(args[1]) - else: - sys.stderr.write ('usage: test_viterbi_equalization1.py Es/No_db repetitions\n') - sys.exit (1) - - # system parameters - Kb=128*16 # packet size in bits (multiple of 16) - modulation = fsm_utils.pam4 # see fsm_utlis.py for available predefined modulations - channel = fsm_utils.c_channel # see fsm_utlis.py for available predefined test channels - f=trellis.fsm(len(modulation[1]),len(channel)) # generate the FSM automatically - bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol - K=Kb/bitspersymbol # packet size in trellis steps - - tot_channel = fsm_utils.make_isi_lookup(modulation,channel,True) # generate the lookup table (normalize energy to 1) - dimensionality = tot_channel[0] - tot_constellation = tot_channel[1] - N0=pow(10.0,-esn0_db/10.0); # noise variance - if len(tot_constellation)/dimensionality != f.O(): - sys.stderr.write ('Incompatible FSM output cardinality and lookup table size.\n') - sys.exit (1) - - tot_s=0 # total number of transmitted shorts - terr_s=0 # total number of shorts in error - terr_p=0 # total number of packets in error - - for i in range(rep): - (s,e)=run_test(f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations - tot_s=tot_s+s - terr_s=terr_s+e - terr_p=terr_p+(terr_s!=0) - if ((i+1)%100==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - # estimate of the (short or symbol) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) - - - -if __name__ == '__main__': - main (sys.argv[1:]) diff --git a/gr-uhd/CMakeLists.txt b/gr-uhd/CMakeLists.txt index 4f4503234..3ba4f5342 100644 --- a/gr-uhd/CMakeLists.txt +++ b/gr-uhd/CMakeLists.txt @@ -39,6 +39,8 @@ GR_SET_GLOBAL(GR_UHD_INCLUDE_DIRS ${UHD_INCLUDE_DIRS} ) +SET(GR_PKG_UHD_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/uhd) + ######################################################################## # Begin conditional configuration ######################################################################## @@ -71,6 +73,13 @@ CPACK_COMPONENT("uhd_python" DEPENDS "core_python;uhd_runtime" ) +CPACK_COMPONENT("uhd_examples" + GROUP "UHD" + DISPLAY_NAME "Examples" + DESCRIPTION "Example programs" + DEPENDS "uhd_runtime" +) + CPACK_COMPONENT("uhd_swig" GROUP "UHD" DISPLAY_NAME "SWIG" @@ -83,12 +92,14 @@ CPACK_COMPONENT("uhd_swig" ######################################################################## add_subdirectory(include) add_subdirectory(lib) -add_subdirectory(examples) add_subdirectory(doc) +add_subdirectory(examples/c++) if(ENABLE_PYTHON) add_subdirectory(swig) add_subdirectory(grc) add_subdirectory(apps) + add_subdirectory(examples/python) + add_subdirectory(examples/grc) endif(ENABLE_PYTHON) ######################################################################## diff --git a/gr-uhd/examples/CMakeLists.txt b/gr-uhd/examples/CMakeLists.txt deleted file mode 100644 index 91e2dfdaf..000000000 --- a/gr-uhd/examples/CMakeLists.txt +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright 2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -######################################################################## -# Setup the include and linker paths -######################################################################## -include_directories( - ${GNURADIO_CORE_INCLUDE_DIRS} - ${GR_UHD_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR} -) - -include_directories(${UHD_INCLUDE_DIRS}) -link_directories(${UHD_LIBRARY_DIRS}) - -include_directories(${Boost_INCLUDE_DIRS}) -link_directories(${Boost_LIBRARY_DIRS}) - -######################################################################## -# Build executable -######################################################################## -add_executable(tags_demo tags_demo.cc) -target_link_libraries(tags_demo gnuradio-uhd) - -######################################################################## -# Python examples -######################################################################## -if(ENABLE_PYTHON) -GR_PYTHON_INSTALL( - PROGRAMS - fm_tx4.py - fm_tx_2_daughterboards.py - max_power.py - usrp_am_mw_rcv.py - usrp_nbfm_ptt.py - usrp_nbfm_rcv.py - usrp_spectrum_sense.py - usrp_tv_rcv_nogui.py - usrp_tv_rcv.py - usrp_wfm_rcv2_nogui.py - usrp_wfm_rcv_fmdet.py - usrp_wfm_rcv_nogui.py - usrp_wfm_rcv_pll.py - usrp_wfm_rcv.py - usrp_wfm_rcv_sca.py - usrp_wxapt_rcv.py - DESTINATION ${GR_PKG_DATA_DIR}/examples/uhd - COMPONENT "uhd_python" -) - -endif(ENABLE_PYTHON) diff --git a/gr-uhd/examples/c++/CMakeLists.txt b/gr-uhd/examples/c++/CMakeLists.txt new file mode 100644 index 000000000..25645117c --- /dev/null +++ b/gr-uhd/examples/c++/CMakeLists.txt @@ -0,0 +1,45 @@ +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories( + ${GNURADIO_CORE_INCLUDE_DIRS} + ${GR_UHD_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} +) + +include_directories(${UHD_INCLUDE_DIRS}) +link_directories(${UHD_LIBRARY_DIRS}) + +include_directories(${Boost_INCLUDE_DIRS}) +link_directories(${Boost_LIBRARY_DIRS}) + +######################################################################## +# Build executable +######################################################################## +add_executable(tags_demo tags_demo.cc) +target_link_libraries(tags_demo gnuradio-uhd) + +INSTALL(TARGETS + tags_demo + DESTINATION ${GR_PKG_UHD_EXAMPLES_DIR} + COMPONENT "uhd_examples" +) diff --git a/gr-uhd/examples/c++/tag_sink_demo.h b/gr-uhd/examples/c++/tag_sink_demo.h new file mode 100644 index 000000000..7d49bd971 --- /dev/null +++ b/gr-uhd/examples/c++/tag_sink_demo.h @@ -0,0 +1,66 @@ +/* + * Copyright 2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include + +class tag_sink_demo : public gr_sync_block{ +public: + + tag_sink_demo(void): + gr_sync_block( + "uhd tag sink demo", + gr_make_io_signature(1, 1, sizeof(std::complex)), + gr_make_io_signature(0, 0, 0) + ) + { + //NOP + } + + int work( + int ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ){ + //grab all "rx time" tags in this work call + const uint64_t samp0_count = this->nitems_read(0); + std::vector rx_time_tags; + get_tags_in_range(rx_time_tags, 0, samp0_count, samp0_count + ninput_items, pmt::pmt_string_to_symbol("rx_time")); + + //print all tags + BOOST_FOREACH(const gr_tag_t &rx_time_tag, rx_time_tags){ + const uint64_t offset = rx_time_tag.offset; + const pmt::pmt_t &value = rx_time_tag.value; + + std::cout << boost::format("Full seconds %u, Frac seconds %f, abs sample offset %u") + % pmt::pmt_to_uint64(pmt_tuple_ref(value, 0)) + % pmt::pmt_to_double(pmt_tuple_ref(value, 1)) + % offset + << std::endl; + } + + return ninput_items; + } +}; diff --git a/gr-uhd/examples/c++/tag_source_demo.h b/gr-uhd/examples/c++/tag_source_demo.h new file mode 100644 index 000000000..9743c3407 --- /dev/null +++ b/gr-uhd/examples/c++/tag_source_demo.h @@ -0,0 +1,128 @@ +/* + * Copyright 2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include + +class tag_source_demo : public gr_sync_block{ +public: + + tag_source_demo( + const uint64_t start_secs, + const double start_fracs, + const double samp_rate, + const double idle_duration, + const double burst_duration + ): + gr_sync_block( + "uhd tag source demo", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, sizeof(std::complex)) + ), + _time_secs(start_secs), + _time_fracs(start_fracs), + _samp_rate(samp_rate), + _samps_per_burst(samp_rate*burst_duration), + _cycle_duration(idle_duration + burst_duration), + _samps_left_in_burst(1), //immediate EOB + _do_new_burst(false) + { + //NOP + } + + void make_time_tag(const uint64_t tag_count){; + const pmt::pmt_t key = pmt::pmt_string_to_symbol("tx_time"); + const pmt::pmt_t value = pmt::pmt_make_tuple( + pmt::pmt_from_uint64(_time_secs), + pmt::pmt_from_double(_time_fracs) + ); + const pmt::pmt_t srcid = pmt::pmt_string_to_symbol(this->name()); + this->add_item_tag(0/*chan0*/, tag_count, key, value, srcid); + } + + void make_sob_tag(const uint64_t tag_count){ + const pmt::pmt_t key = pmt::pmt_string_to_symbol("tx_sob"); + const pmt::pmt_t value = pmt::PMT_T; + const pmt::pmt_t srcid = pmt::pmt_string_to_symbol(this->name()); + this->add_item_tag(0/*chan0*/, tag_count, key, value, srcid); + } + + void make_eob_tag(const uint64_t tag_count){; + const pmt::pmt_t key = pmt::pmt_string_to_symbol("tx_eob"); + const pmt::pmt_t value = pmt::PMT_T; + const pmt::pmt_t srcid = pmt::pmt_string_to_symbol(this->name()); + this->add_item_tag(0/*chan0*/, tag_count, key, value, srcid); + } + + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ){ + //load the output with a constant + std::complex *output = reinterpret_cast *>(output_items[0]); + for (size_t i = 0; i < size_t(noutput_items); i++){ + output[i] = std::complex(0.7, 0.7); + } + + //Handle the start of burst condition. + //Tag a start of burst and timestamp. + //Increment the time for the next burst. + if (_do_new_burst){ + _do_new_burst = false; + _samps_left_in_burst = _samps_per_burst; + + this->make_sob_tag(this->nitems_written(0)); + this->make_time_tag(this->nitems_written(0)); + + _time_fracs += _cycle_duration; + double intpart; //normalize + _time_fracs = std::modf(_time_fracs, &intpart); + _time_secs += uint64_t(intpart); + } + + //Handle the end of burst condition. + //Tag an end of burst and return early. + //the next work call will be a start of burst. + if (_samps_left_in_burst < size_t(noutput_items)){ + this->make_eob_tag(this->nitems_written(0) + _samps_left_in_burst - 1); + _do_new_burst = true; + noutput_items = _samps_left_in_burst; + } + + _samps_left_in_burst -= noutput_items; + return noutput_items; + } + +private: + uint64_t _time_secs; + double _time_fracs; + const double _samp_rate; + const uint64_t _samps_per_burst; + const double _cycle_duration; + uint64_t _samps_left_in_burst; + bool _do_new_burst; + +}; diff --git a/gr-uhd/examples/c++/tags_demo.cc b/gr-uhd/examples/c++/tags_demo.cc new file mode 100644 index 000000000..f7442f098 --- /dev/null +++ b/gr-uhd/examples/c++/tags_demo.cc @@ -0,0 +1,139 @@ +/* + * Copyright 2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include +#include //sleep +#include +#include +#include + +namespace po = boost::program_options; + +/*********************************************************************** + * Signal handlers + **********************************************************************/ +static bool stop_signal_called = false; +void sig_int_handler(int){stop_signal_called = true;} + +/*********************************************************************** + * Main w/ program options + **********************************************************************/ +int main(int argc, char *argv[]){ + + std::string device_addr; + double center_freq, samp_rate, burst_dur, idle_dur; + + //setup the program options + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "help message") + ("addr", po::value(&device_addr)->default_value(""), "the device address in string format") + ("rate", po::value(&samp_rate)->default_value(1e6), "the sample rate in samples per second") + ("freq", po::value(¢er_freq)->default_value(10e6), "the center frequency in Hz") + ("burst", po::value(&burst_dur)->default_value(0.1), "the duration of each burst in seconds") + ("idle", po::value(&idle_dur)->default_value(0.05), "idle time between bursts in seconds") + ; + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + //print the help message + if (vm.count("help")){ + std::cout + << boost::format("UHD Tags Demo %s") % desc << std::endl + << "The tags sink demo block will print USRP source time stamps." << std::endl + << "The tags source demo block will send bursts to the USRP sink." << std::endl + << "Look at the USRP output on a scope to see the timed bursts." << std::endl + << std::endl; + return ~0; + } + + //------------------------------------------------------------------ + //-- make a top block + //------------------------------------------------------------------ + gr_top_block_sptr tb = gr_make_top_block("tags_demo"); + + //------------------------------------------------------------------ + //-- make the usrp source test blocks + //------------------------------------------------------------------ + boost::shared_ptr usrp_source = uhd_make_usrp_source( + device_addr, uhd::stream_args_t("fc32") + ); + usrp_source->set_samp_rate(samp_rate); + usrp_source->set_center_freq(center_freq); + + boost::shared_ptr tag_sink = boost::make_shared(); + + //------------------------------------------------------------------ + //-- connect the usrp source test blocks + //------------------------------------------------------------------ + tb->connect(usrp_source, 0, tag_sink, 0); + + //------------------------------------------------------------------ + //-- make the usrp sink test blocks + //------------------------------------------------------------------ + boost::shared_ptr usrp_sink = uhd_make_usrp_sink( + device_addr, uhd::stream_args_t("fc32") + ); + usrp_sink->set_samp_rate(samp_rate); + usrp_sink->set_center_freq(center_freq); + const uhd::time_spec_t time_now = usrp_sink->get_time_now(); + + boost::shared_ptr tag_source = boost::make_shared( + time_now.get_full_secs() + 1, time_now.get_frac_secs(), //time now + 1 second + samp_rate, idle_dur, burst_dur + ); + + //------------------------------------------------------------------ + //-- connect the usrp sink test blocks + //------------------------------------------------------------------ + tb->connect(tag_source, 0, usrp_sink, 0); + + //------------------------------------------------------------------ + //-- start flow graph execution + //------------------------------------------------------------------ + std::cout << "starting flow graph" << std::endl; + tb->start(); + + //------------------------------------------------------------------ + //-- poll the exit signal while running + //------------------------------------------------------------------ + std::signal(SIGINT, &sig_int_handler); + std::cout << "press ctrl + c to exit" << std::endl; + while (not stop_signal_called){ + boost::this_thread::sleep(boost::posix_time::milliseconds(100)); + } + + //------------------------------------------------------------------ + //-- stop flow graph execution + //------------------------------------------------------------------ + std::cout << "stopping flow graph" << std::endl; + tb->stop(); + tb->wait(); + + std::cout << "done!" << std::endl; + return 0; +} diff --git a/gr-uhd/examples/fm_tx4.py b/gr-uhd/examples/fm_tx4.py deleted file mode 100755 index aecb35b54..000000000 --- a/gr-uhd/examples/fm_tx4.py +++ /dev/null @@ -1,208 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005-2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -""" -Transmit N simultaneous narrow band FM signals. - -They will be centered at the frequency specified on the command line, -and will spaced at 25kHz steps from there. - -The program opens N files with names audio-N.dat where N is in [0,7]. -These files should contain floating point audio samples in the range [-1,1] -sampled at 32kS/sec. You can create files like this using -audio_to_file.py -""" - -from gnuradio import gr, eng_notation -from gnuradio import uhd -from gnuradio import blks2 -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import math -import sys - -from gnuradio.wxgui import stdgui2, fftsink2 -import wx - - -######################################################## -# instantiate one transmit chain for each call - -class pipeline(gr.hier_block2): - def __init__(self, filename, lo_freq, audio_rate, if_rate): - - gr.hier_block2.__init__(self, "pipeline", - gr.io_signature(0, 0, 0), - gr.io_signature(1, 1, gr.sizeof_gr_complex)) - - try: - src = gr.file_source (gr.sizeof_float, filename, True) - except RuntimeError: - sys.stderr.write(("\nError: Could not open file '%s'\n\n" % \ - filename)) - sys.exit(1) - - print audio_rate, if_rate - fmtx = blks2.nbfm_tx (audio_rate, if_rate, max_dev=5e3, tau=75e-6) - - # Local oscillator - lo = gr.sig_source_c (if_rate, # sample rate - gr.GR_SIN_WAVE, # waveform type - lo_freq, #frequency - 1.0, # amplitude - 0) # DC Offset - mixer = gr.multiply_cc () - - self.connect (src, fmtx, (mixer, 0)) - self.connect (lo, (mixer, 1)) - self.connect (mixer, self) - -class fm_tx_block(stdgui2.std_top_block): - def __init__(self, frame, panel, vbox, argv): - MAX_CHANNELS = 7 - stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) - - parser = OptionParser (option_class=eng_option) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-s", "--samp-rate", type="eng_float", default=400e3, - help="set sample rate (bandwidth) [default=%default]") - parser.add_option("-f", "--freq", type="eng_float", default=None, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("-n", "--nchannels", type="int", default=4, - help="number of Tx channels [1,4]") - #parser.add_option("","--debug", action="store_true", default=False, - # help="Launch Tx debugger") - (options, args) = parser.parse_args () - - if len(args) != 0: - parser.print_help() - sys.exit(1) - - if options.nchannels < 1 or options.nchannels > MAX_CHANNELS: - sys.stderr.write ("fm_tx4: nchannels out of range. Must be in [1,%d]\n" % MAX_CHANNELS) - sys.exit(1) - - if options.freq is None: - sys.stderr.write("fm_tx4: must specify frequency with -f FREQ\n") - parser.print_help() - sys.exit(1) - - # ---------------------------------------------------------------- - # Set up constants and parameters - - self.u = uhd.usrp_sink(device_addr=options.args, stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(options.spec): - self.u.set_subdev_spec(options.spec, 0) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, 0) - - self.usrp_rate = options.samp_rate - self.u.set_samp_rate(self.usrp_rate) - self.usrp_rate = self.u.get_samp_rate() - - self.sw_interp = 10 - self.audio_rate = self.usrp_rate / self.sw_interp # 32 kS/s - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - options.gain = float(g.start()+g.stop())/2 - - self.set_gain(options.gain) - self.set_freq(options.freq) - - self.sum = gr.add_cc () - - # Instantiate N NBFM channels - step = 25e3 - offset = (0 * step, 1 * step, -1 * step, - 2 * step, -2 * step, 3 * step, -3 * step) - - for i in range (options.nchannels): - t = pipeline("audio-%d.dat" % (i % 4), offset[i], - self.audio_rate, self.usrp_rate) - self.connect(t, (self.sum, i)) - - self.gain = gr.multiply_const_cc (1.0 / options.nchannels) - - # connect it all - self.connect (self.sum, self.gain) - self.connect (self.gain, self.u) - - # plot an FFT to verify we are sending what we want - if 1: - post_mod = fftsink2.fft_sink_c(panel, title="Post Modulation", - fft_size=512, - sample_rate=self.usrp_rate, - y_per_div=20, - ref_level=40) - self.connect (self.gain, post_mod) - vbox.Add (post_mod.win, 1, wx.EXPAND) - - - #if options.debug: - # self.debugger = tx_debug_gui.tx_debug_gui(self.subdev) - # self.debugger.Show(True) - - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital up converter. Finally, we feed - any residual_freq to the s/w freq translater. - """ - - r = self.u.set_center_freq(target_freq, 0) - if r: - print "Frequency =", eng_notation.num_to_str(self.u.get_center_freq()) - return True - - return False - - def set_gain(self, gain): - self.u.set_gain(gain, 0) - - -def main (): - app = stdgui2.stdapp(fm_tx_block, "Multichannel FM Tx", nstatus=1) - app.MainLoop () - -if __name__ == '__main__': - main () diff --git a/gr-uhd/examples/fm_tx_2_daughterboards.py b/gr-uhd/examples/fm_tx_2_daughterboards.py deleted file mode 100755 index c0a7112de..000000000 --- a/gr-uhd/examples/fm_tx_2_daughterboards.py +++ /dev/null @@ -1,212 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005-2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -""" -Transmit 2 signals, one out each daughterboard. - -Outputs SSB (USB) signals on side A and side B at frequencies -specified on command line. - -Side A is 600 Hz tone. -Side B is 350 + 440 Hz tones. -""" - -from gnuradio import gr, uhd, blks2 -from gnuradio.eng_notation import num_to_str, str_to_num -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import math -import sys - - -class example_signal_0(gr.hier_block2): - """ - Sinusoid at 600 Hz. - """ - def __init__(self, sample_rate): - gr.hier_block2.__init__(self, "example_signal_0", - gr.io_signature(0, 0, 0), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - src = gr.sig_source_c (sample_rate, # sample rate - gr.GR_SIN_WAVE, # waveform type - 600, # frequency - 1.0, # amplitude - 0) # DC Offset - - self.connect(src, self) - - -class example_signal_1(gr.hier_block2): - """ - North American dial tone (350 + 440 Hz). - """ - def __init__(self, sample_rate): - gr.hier_block2.__init__(self, "example_signal_1", - gr.io_signature(0, 0, 0), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - src0 = gr.sig_source_c (sample_rate, # sample rate - gr.GR_SIN_WAVE, # waveform type - 350, # frequency - 1.0, # amplitude - 0) # DC Offset - - src1 = gr.sig_source_c (sample_rate, # sample rate - gr.GR_SIN_WAVE, # waveform type - 440, # frequency - 1.0, # amplitude - 0) # DC Offset - sum = gr.add_cc() - self.connect(src0, (sum, 0)) - self.connect(src1, (sum, 1)) - self.connect(sum, self) - -class my_top_block(gr.top_block): - - def __init__(self): - gr.top_block.__init__(self) - - usage="%prog: [options] tx-freq0 tx-freq1" - parser = OptionParser (option_class=eng_option, usage=usage) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-s", "--samp-rate", type="eng_float", default=320e3, - help="set sample rate [default=%default]") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - (options, args) = parser.parse_args () - - if len(args) != 2: - parser.print_help() - raise SystemExit - else: - freq0 = str_to_num(args[0]) - freq1 = str_to_num(args[1]) - - # ---------------------------------------------------------------- - # Set up USRP to transmit on both daughterboards - - d = uhd.find_devices(uhd.device_addr(options.args)) - uhd_type = d[0].get('type') - - stream_args = uhd.stream_args('fc32', channels=range(2)) - self.u = uhd.usrp_sink(device_addr=options.args, stream_args=stream_args) - - # Set up USRP system based on type - if(uhd_type == "usrp"): - self.u.set_subdev_spec("A:0 B:0") - tr0 = uhd.tune_request(freq0) - tr1 = uhd.tune_request(freq1) - - else: - if abs(freq0 - freq1) > 5.5e6: - sys.stderr.write("\nError: When not using two separate d'boards, frequencies must bewithin 5.5MHz of each other.\n") - raise SystemExit - - self.u.set_subdev_spec("A:0 A:0") - - mid_freq = (freq0 + freq1)/2.0 - tr0 = uhd.tune_request(freq0, rf_freq=mid_freq, - rf_freq_policy=uhd.tune_request.POLICY_MANUAL) - - tr1 = uhd.tune_request(freq1, rf_freq=mid_freq, - rf_freq_policy=uhd.tune_request.POLICY_MANUAL) - - # Use the tune requests to tune each channel - self.set_freq(tr0, 0) - self.set_freq(tr1, 1) - - self.usrp_rate = options.samp_rate - - self.u.set_samp_rate(self.usrp_rate) - dev_rate = self.u.get_samp_rate() - - # ---------------------------------------------------------------- - # build two signal sources, interleave them, amplify and - # connect them to usrp - - sig0 = example_signal_0(self.usrp_rate) - sig1 = example_signal_1(self.usrp_rate) - - intl = gr.interleave(gr.sizeof_gr_complex) - self.connect(sig0, (intl, 0)) - self.connect(sig1, (intl, 1)) - - # Correct for any difference in requested and actual rates - rrate = self.usrp_rate / dev_rate - resamp = blks2.pfb_arb_resampler_ccf(rrate) - - # and wire them up - self.connect(intl, resamp, self.u) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - options.gain = float(g.start()+g.stop())/2.0 - - self.set_gain(options.gain, 0) - self.set_gain(options.gain, 1) - - # Set the subdevice spec - if(options.spec): - self.u.set_subdev_spec(options.spec, 0) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, 0) - self.u.set_antenna(options.antenna, 1) - - def set_freq(self, target_freq, chan): - """ - Set the center frequency we're interested in. - - @param side: 0 = side A, 1 = side B - @param target_freq: frequency in Hz - @rtype: bool - """ - - print "Tuning channel %s to %sHz" % \ - (chan, num_to_str(target_freq)) - - r = self.u.set_center_freq(target_freq, chan) - - if r: - return True - - else: - print " Set Frequency Failed!" - - return False - - def set_gain(self, gain, chan): - self.u.set_gain(gain, chan) - -if __name__ == '__main__': - try: - my_top_block().run() - except KeyboardInterrupt: - pass diff --git a/gr-uhd/examples/grc/CMakeLists.txt b/gr-uhd/examples/grc/CMakeLists.txt new file mode 100644 index 000000000..06c233d45 --- /dev/null +++ b/gr-uhd/examples/grc/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +install( + FILES + uhd_const_wave.grc + uhd_dpsk_mod.grc + uhd_fft.grc + uhd_rx_dpsk.grc + uhd_two_tone_loopback.grc + uhd_tx_dpsk.grc + uhd_wbfm_receive.grc + DESTINATION ${GR_PKG_UHD_EXAMPLES_DIR} + COMPONENT "uhd_python" +) diff --git a/gr-uhd/examples/grc/uhd_const_wave.grc b/gr-uhd/examples/grc/uhd_const_wave.grc new file mode 100644 index 000000000..c64721c83 --- /dev/null +++ b/gr-uhd/examples/grc/uhd_const_wave.grc @@ -0,0 +1,1020 @@ + + + Sat Oct 8 10:24:27 2011 + + const_source_x + + id + const_source_x_0 + + + _enabled + True + + + type + complex + + + const + ampl + + + _coordinate + (102, 193) + + + _rotation + 0 + + + + variable_slider + + id + ampl + + + _enabled + True + + + label + Amplitude + + + value + .1 + + + min + 0 + + + max + 1 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (174, 313) + + + _rotation + 0 + + + + variable_slider + + id + tun_gain + + + _enabled + True + + + label + UHD Gain + + + value + gain + + + min + 0 + + + max + 20 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (318, 314) + + + _rotation + 0 + + + + variable_slider + + id + tun_freq + + + _enabled + True + + + label + UHD Freq (Hz) + + + value + freq + + + min + 2.4e9 + + + max + 2.5e9 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (24, 315) + + + _rotation + 0 + + + + options + + id + uhd_const_wave + + + _enabled + True + + + title + UHD Constant Wave + + + author + Example + + + description + Tune UHD Device + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + parameter + + id + address + + + _enabled + True + + + label + IP Address + + + value + addr=192.168.11.2 + + + type + string + + + short_id + a + + + _coordinate + (188, 12) + + + _rotation + 0 + + + + parameter + + id + samp_rate + + + _enabled + True + + + label + Sample Rate + + + value + 1e6 + + + type + eng_float + + + short_id + s + + + _coordinate + (342, 14) + + + _rotation + 0 + + + + uhd_usrp_sink + + id + uhd_usrp_sink_0 + + + _enabled + True + + + type + complex + + + dev_addr + address + + + sync + + + + clock_rate + 0.0 + + + num_mboards + 1 + + + ref_source0 + + + + sd_spec0 + + + + ref_source1 + + + + sd_spec1 + + + + ref_source2 + + + + sd_spec2 + + + + ref_source3 + + + + sd_spec3 + + + + ref_source4 + + + + sd_spec4 + + + + ref_source5 + + + + sd_spec5 + + + + ref_source6 + + + + sd_spec6 + + + + ref_source7 + + + + sd_spec7 + + + + nchan + 1 + + + samp_rate + samp_rate + + + center_freq0 + tun_freq + + + gain0 + tun_gain + + + ant0 + + + + bw0 + 0 + + + center_freq1 + 0 + + + gain1 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq2 + 0 + + + gain2 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq3 + 0 + + + gain3 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq4 + 0 + + + gain4 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq5 + 0 + + + gain5 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq6 + 0 + + + gain6 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq7 + 0 + + + gain7 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq8 + 0 + + + gain8 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq9 + 0 + + + gain9 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq10 + 0 + + + gain10 + 0 + + + ant10 + + + + bw10 + 0 + + + center_freq11 + 0 + + + gain11 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq12 + 0 + + + gain12 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq13 + 0 + + + gain13 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq14 + 0 + + + gain14 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq15 + 0 + + + gain15 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq16 + 0 + + + gain16 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq17 + 0 + + + gain17 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq18 + 0 + + + gain18 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq19 + 0 + + + gain19 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq20 + 0 + + + gain20 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq21 + 0 + + + gain21 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq22 + 0 + + + gain22 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq23 + 0 + + + gain23 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq24 + 0 + + + gain24 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq25 + 0 + + + gain25 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq26 + 0 + + + gain26 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq27 + 0 + + + gain27 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq28 + 0 + + + gain28 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq29 + 0 + + + gain29 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq30 + 0 + + + gain30 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq31 + 0 + + + gain31 + 0 + + + ant31 + + + + bw31 + 0 + + + _coordinate + (308, 169) + + + _rotation + 0 + + + + parameter + + id + freq + + + _enabled + True + + + label + Default Frequency + + + value + 2.45e9 + + + type + eng_float + + + short_id + f + + + _coordinate + (468, 14) + + + _rotation + 0 + + + + parameter + + id + gain + + + _enabled + True + + + label + Default Gain + + + value + 0 + + + type + eng_float + + + short_id + g + + + _coordinate + (616, 13) + + + _rotation + 0 + + + + const_source_x_0 + uhd_usrp_sink_0 + 0 + 0 + + diff --git a/gr-uhd/examples/grc/uhd_dpsk_mod.grc b/gr-uhd/examples/grc/uhd_dpsk_mod.grc new file mode 100644 index 000000000..18ae9c3db --- /dev/null +++ b/gr-uhd/examples/grc/uhd_dpsk_mod.grc @@ -0,0 +1,2238 @@ + + + Sat Oct 8 14:44:48 2011 + + options + + id + uhd_dpsk_mod + + + _enabled + True + + + title + UHD DPSK Modulation + + + author + Example + + + description + Generate a DPSK signal + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + samps_per_sym + + + _enabled + True + + + value + 8 + + + _coordinate + (33, 280) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + wxgui_fftsink2_0 + + + _enabled + True + + + type + complex + + + title + FFT Plot + + + samp_rate + samp_rate + + + baseband_freq + tun_freq + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 10 + + + ref_scale + 2.0 + + + fft_size + 1024 + + + fft_rate + 30 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + win + None + + + win_size + + + + grid_pos + + + + notebook + + + + _coordinate + (697, 248) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + wxgui_scopesink2_0 + + + _enabled + False + + + type + complex + + + title + Scope Plot + + + samp_rate + samp_rate + + + v_scale + 0 + + + v_offset + 0 + + + t_scale + 1e-6 + + + ac_couple + False + + + xy_mode + True + + + num_inputs + 1 + + + win_size + + + + grid_pos + + + + notebook + + + + trig_mode + gr.gr_TRIG_MODE_AUTO + + + y_axis_label + Counts + + + _coordinate + (469, 355) + + + _rotation + 0 + + + + random_source_x + + id + random_source_x_0 + + + _enabled + True + + + type + byte + + + min + 0 + + + max + 256 + + + num_samps + 1000 + + + repeat + True + + + _coordinate + (245, 139) + + + _rotation + 0 + + + + gr_multiply_const_vxx + + id + gr_multiply_const_vxx_0 + + + _enabled + True + + + type + complex + + + const + ampl + + + vlen + 1 + + + _coordinate + (647, 163) + + + _rotation + 0 + + + + variable_slider + + id + tun_rx_gain + + + _enabled + True + + + label + UHD RX Gain + + + value + rx_gain + + + min + 0 + + + max + 20 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (477, 509) + + + _rotation + 0 + + + + variable_slider + + id + rx_freq_off + + + _enabled + True + + + label + RX Freq Offset (Hz) + + + value + freq_offset + + + min + -50e3 + + + max + +50e3 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (190, 507) + + + _rotation + 0 + + + + parameter + + id + rx_gain + + + _enabled + True + + + label + Default RX Gain + + + value + 0 + + + type + eng_float + + + short_id + + + + _coordinate + (1137, 8) + + + _rotation + 0 + + + + parameter + + id + freq_offset + + + _enabled + True + + + label + Rx Frequency Offset + + + value + 0 + + + type + eng_float + + + short_id + o + + + _coordinate + (824, 8) + + + _rotation + 0 + + + + uhd_usrp_source + + id + uhd_usrp_source_0 + + + _enabled + True + + + type + complex + + + dev_addr + address1 + + + sync + + + + clock_rate + 0.0 + + + num_mboards + 1 + + + ref_source0 + + + + sd_spec0 + + + + ref_source1 + + + + sd_spec1 + + + + ref_source2 + + + + sd_spec2 + + + + ref_source3 + + + + sd_spec3 + + + + ref_source4 + + + + sd_spec4 + + + + ref_source5 + + + + sd_spec5 + + + + ref_source6 + + + + sd_spec6 + + + + ref_source7 + + + + sd_spec7 + + + + nchan + 1 + + + samp_rate + samp_rate + + + center_freq0 + tun_freq+rx_freq_off + + + gain0 + tun_rx_gain + + + ant0 + + + + bw0 + 0 + + + center_freq1 + 0 + + + gain1 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq2 + 0 + + + gain2 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq3 + 0 + + + gain3 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq4 + 0 + + + gain4 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq5 + 0 + + + gain5 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq6 + 0 + + + gain6 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq7 + 0 + + + gain7 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq8 + 0 + + + gain8 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq9 + 0 + + + gain9 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq10 + 0 + + + gain10 + 0 + + + ant10 + + + + bw10 + 0 + + + center_freq11 + 0 + + + gain11 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq12 + 0 + + + gain12 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq13 + 0 + + + gain13 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq14 + 0 + + + gain14 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq15 + 0 + + + gain15 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq16 + 0 + + + gain16 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq17 + 0 + + + gain17 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq18 + 0 + + + gain18 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq19 + 0 + + + gain19 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq20 + 0 + + + gain20 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq21 + 0 + + + gain21 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq22 + 0 + + + gain22 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq23 + 0 + + + gain23 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq24 + 0 + + + gain24 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq25 + 0 + + + gain25 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq26 + 0 + + + gain26 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq27 + 0 + + + gain27 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq28 + 0 + + + gain28 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq29 + 0 + + + gain29 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq30 + 0 + + + gain30 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq31 + 0 + + + gain31 + 0 + + + ant31 + + + + bw31 + 0 + + + _coordinate + (216, 288) + + + _rotation + 0 + + + + wxgui_constellationsink2 + + id + wxgui_constellationsink2_0 + + + _enabled + True + + + title + Constellation Plot + + + samp_rate + samp_rate + + + frame_rate + 5 + + + const_size + 2048 + + + M + 4 + + + theta + 0 + + + loop_bw + 6.28/100.0 + + + fmax + 0.06 + + + mu + 0.5 + + + gain_mu + 0.005 + + + symbol_rate + samp_rate/samps_per_sym + + + omega_limit + 0.005 + + + win_size + + + + grid_pos + + + + notebook + + + + _coordinate + (862, 336) + + + _rotation + 0 + + + + digital_dxpsk_mod + + id + digital_dxpsk_mod_0 + + + _enabled + True + + + type + dqpsk + + + samples_per_symbol + samps_per_sym + + + excess_bw + 0.35 + + + gray_coded + True + + + verbose + False + + + log + False + + + _coordinate + (426, 139) + + + _rotation + 0 + + + + variable_slider + + id + ampl + + + _enabled + True + + + label + Amplitude + + + value + .1 + + + min + 0 + + + max + 1 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (33, 353) + + + _rotation + 0 + + + + uhd_usrp_sink + + id + uhd_usrp_sink_0 + + + _enabled + True + + + type + complex + + + dev_addr + address0 + + + sync + + + + clock_rate + 0.0 + + + num_mboards + 1 + + + ref_source0 + + + + sd_spec0 + + + + ref_source1 + + + + sd_spec1 + + + + ref_source2 + + + + sd_spec2 + + + + ref_source3 + + + + sd_spec3 + + + + ref_source4 + + + + sd_spec4 + + + + ref_source5 + + + + sd_spec5 + + + + ref_source6 + + + + sd_spec6 + + + + ref_source7 + + + + sd_spec7 + + + + nchan + 1 + + + samp_rate + samp_rate + + + center_freq0 + tun_freq + + + gain0 + tun_rx_gain + + + ant0 + + + + bw0 + 0 + + + center_freq1 + 0 + + + gain1 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq2 + 0 + + + gain2 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq3 + 0 + + + gain3 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq4 + 0 + + + gain4 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq5 + 0 + + + gain5 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq6 + 0 + + + gain6 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq7 + 0 + + + gain7 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq8 + 0 + + + gain8 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq9 + 0 + + + gain9 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq10 + 0 + + + gain10 + 0 + + + ant10 + + + + bw10 + 0 + + + center_freq11 + 0 + + + gain11 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq12 + 0 + + + gain12 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq13 + 0 + + + gain13 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq14 + 0 + + + gain14 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq15 + 0 + + + gain15 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq16 + 0 + + + gain16 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq17 + 0 + + + gain17 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq18 + 0 + + + gain18 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq19 + 0 + + + gain19 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq20 + 0 + + + gain20 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq21 + 0 + + + gain21 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq22 + 0 + + + gain22 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq23 + 0 + + + gain23 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq24 + 0 + + + gain24 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq25 + 0 + + + gain25 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq26 + 0 + + + gain26 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq27 + 0 + + + gain27 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq28 + 0 + + + gain28 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq29 + 0 + + + gain29 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq30 + 0 + + + gain30 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq31 + 0 + + + gain31 + 0 + + + ant31 + + + + bw31 + 0 + + + _coordinate + (838, 139) + + + _rotation + 0 + + + + variable_slider + + id + tun_tx_gain + + + _enabled + True + + + label + UHD TX Gain + + + value + tx_gain + + + min + 0 + + + max + 20 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (351, 508) + + + _rotation + 0 + + + + parameter + + id + address0 + + + _enabled + True + + + label + IP Address, Dev 0 + + + value + addr=192.168.10.2 + + + type + string + + + short_id + + + + _coordinate + (197, 11) + + + _rotation + 0 + + + + parameter + + id + address1 + + + _enabled + True + + + label + IP Address, Dev 1 + + + value + addr=192.168.11.2 + + + type + string + + + short_id + + + + _coordinate + (357, 11) + + + _rotation + 0 + + + + parameter + + id + samp_rate + + + _enabled + True + + + label + Sample Rate + + + value + 1e6 + + + type + eng_float + + + short_id + s + + + _coordinate + (543, 8) + + + _rotation + 0 + + + + parameter + + id + freq + + + _enabled + True + + + label + Default Frequency + + + value + 2.45e9 + + + type + eng_float + + + short_id + f + + + _coordinate + (669, 8) + + + _rotation + 0 + + + + parameter + + id + tx_gain + + + _enabled + True + + + label + Default TX Gain + + + value + 0 + + + type + eng_float + + + short_id + + + + _coordinate + (1003, 8) + + + _rotation + 0 + + + + variable_slider + + id + tun_freq + + + _enabled + True + + + label + Freq (Hz) + + + value + freq + + + min + 2.4e9 + + + max + 2.5e9 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (35, 506) + + + _rotation + 0 + + + + uhd_usrp_source_0 + wxgui_fftsink2_0 + 0 + 0 + + + uhd_usrp_source_0 + wxgui_constellationsink2_0 + 0 + 0 + + + uhd_usrp_source_0 + wxgui_scopesink2_0 + 0 + 0 + + + gr_multiply_const_vxx_0 + uhd_usrp_sink_0 + 0 + 0 + + + random_source_x_0 + digital_dxpsk_mod_0 + 0 + 0 + + + digital_dxpsk_mod_0 + gr_multiply_const_vxx_0 + 0 + 0 + + diff --git a/gr-uhd/examples/grc/uhd_fft.grc b/gr-uhd/examples/grc/uhd_fft.grc new file mode 100644 index 000000000..29c375065 --- /dev/null +++ b/gr-uhd/examples/grc/uhd_fft.grc @@ -0,0 +1,1025 @@ + + + Sat Oct 8 10:26:30 2011 + + options + + id + uhd_fft + + + _enabled + True + + + title + UHD FFT Plotter + + + author + Example + + + description + FFT waveform plot + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + parameter + + id + gain + + + _enabled + True + + + label + Default Gain + + + value + 0 + + + type + eng_float + + + short_id + g + + + _coordinate + (633, 17) + + + _rotation + 0 + + + + parameter + + id + freq + + + _enabled + True + + + label + Default Frequency + + + value + 2.45e9 + + + type + eng_float + + + short_id + f + + + _coordinate + (485, 18) + + + _rotation + 0 + + + + parameter + + id + address + + + _enabled + True + + + label + IP Address + + + value + addr=192.168.11.2 + + + type + string + + + short_id + a + + + _coordinate + (205, 16) + + + _rotation + 0 + + + + parameter + + id + samp_rate + + + _enabled + True + + + label + Sample Rate + + + value + 1e6 + + + type + eng_float + + + short_id + s + + + _coordinate + (359, 18) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + wxgui_fftsink2_0 + + + _enabled + True + + + type + complex + + + title + FFT Plot + + + samp_rate + samp_rate + + + baseband_freq + tun_freq + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 10 + + + ref_scale + 2.0 + + + fft_size + 1024 + + + fft_rate + 30 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + win + None + + + win_size + + + + grid_pos + + + + notebook + + + + _coordinate + (479, 176) + + + _rotation + 0 + + + + uhd_usrp_source + + id + uhd_usrp_source_0 + + + _enabled + True + + + type + complex + + + dev_addr + address + + + sync + + + + clock_rate + 0.0 + + + num_mboards + 1 + + + ref_source0 + + + + sd_spec0 + + + + ref_source1 + + + + sd_spec1 + + + + ref_source2 + + + + sd_spec2 + + + + ref_source3 + + + + sd_spec3 + + + + ref_source4 + + + + sd_spec4 + + + + ref_source5 + + + + sd_spec5 + + + + ref_source6 + + + + sd_spec6 + + + + ref_source7 + + + + sd_spec7 + + + + nchan + 1 + + + samp_rate + samp_rate + + + center_freq0 + tun_freq + + + gain0 + tun_gain + + + ant0 + + + + bw0 + 0 + + + center_freq1 + 0 + + + gain1 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq2 + 0 + + + gain2 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq3 + 0 + + + gain3 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq4 + 0 + + + gain4 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq5 + 0 + + + gain5 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq6 + 0 + + + gain6 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq7 + 0 + + + gain7 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq8 + 0 + + + gain8 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq9 + 0 + + + gain9 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq10 + 0 + + + gain10 + 0 + + + ant10 + + + + bw10 + 0 + + + center_freq11 + 0 + + + gain11 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq12 + 0 + + + gain12 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq13 + 0 + + + gain13 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq14 + 0 + + + gain14 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq15 + 0 + + + gain15 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq16 + 0 + + + gain16 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq17 + 0 + + + gain17 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq18 + 0 + + + gain18 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq19 + 0 + + + gain19 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq20 + 0 + + + gain20 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq21 + 0 + + + gain21 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq22 + 0 + + + gain22 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq23 + 0 + + + gain23 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq24 + 0 + + + gain24 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq25 + 0 + + + gain25 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq26 + 0 + + + gain26 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq27 + 0 + + + gain27 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq28 + 0 + + + gain28 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq29 + 0 + + + gain29 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq30 + 0 + + + gain30 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq31 + 0 + + + gain31 + 0 + + + ant31 + + + + bw31 + 0 + + + _coordinate + (212, 216) + + + _rotation + 0 + + + + variable_slider + + id + tun_freq + + + _enabled + True + + + label + UHD Freq (Hz) + + + value + freq + + + min + 2.4e9 + + + max + 2.5e9 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (36, 376) + + + _rotation + 0 + + + + variable_slider + + id + tun_gain + + + _enabled + True + + + label + UHD Gain + + + value + gain + + + min + 0 + + + max + 20 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (177, 377) + + + _rotation + 0 + + + + uhd_usrp_source_0 + wxgui_fftsink2_0 + 0 + 0 + + diff --git a/gr-uhd/examples/grc/uhd_rx_dpsk.grc b/gr-uhd/examples/grc/uhd_rx_dpsk.grc new file mode 100644 index 000000000..73848ff3c --- /dev/null +++ b/gr-uhd/examples/grc/uhd_rx_dpsk.grc @@ -0,0 +1,1431 @@ + + + Sat Oct 8 15:08:55 2011 + + options + + id + uhd_rx_dpsk + + + _enabled + True + + + title + UHD RX DPSK + + + author + + + + description + + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (12, 9) + + + _rotation + 0 + + + + variable + + id + samps_per_sym + + + _enabled + True + + + value + 4 + + + _coordinate + (12, 88) + + + _rotation + 0 + + + + parameter + + id + samp_rate + + + _enabled + True + + + label + Sample Rate + + + value + 1e6 + + + type + eng_float + + + short_id + s + + + _coordinate + (339, 11) + + + _rotation + 0 + + + + parameter + + id + freq + + + _enabled + True + + + label + Default Frequency + + + value + 2.45e9 + + + type + eng_float + + + short_id + f + + + _coordinate + (466, 11) + + + _rotation + 0 + + + + parameter + + id + gain + + + _enabled + True + + + label + Default Gain + + + value + 0 + + + type + eng_float + + + short_id + g + + + _coordinate + (624, 14) + + + _rotation + 0 + + + + parameter + + id + address + + + _enabled + True + + + label + IP Address + + + value + addr=192.168.10.2 + + + type + string + + + short_id + a + + + _coordinate + (186, 10) + + + _rotation + 0 + + + + parameter + + id + freq_offset + + + _enabled + True + + + label + Rx Frequency Offset + + + value + 0 + + + type + eng_float + + + short_id + o + + + _coordinate + (748, 15) + + + _rotation + 0 + + + + variable_slider + + id + tun_freq + + + _enabled + True + + + label + Freq (Hz) + + + value + freq + + + min + 2.4e9 + + + max + 2.5e9 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (12, 436) + + + _rotation + 0 + + + + gr_null_sink + + id + gr_null_sink_0 + + + _enabled + True + + + type + byte + + + vlen + 1 + + + _coordinate + (615, 144) + + + _rotation + 0 + + + + variable_slider + + id + timing_bw + + + _enabled + True + + + label + Timing Loop BW + + + value + 6.28/100.0 + + + min + 0 + + + max + 1 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (604, 436) + + + _rotation + 0 + + + + variable_slider + + id + phase_bw + + + _enabled + True + + + label + Phase Loop BW + + + value + 6.28/100.0 + + + min + 0 + + + max + 1.0 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (461, 436) + + + _rotation + 0 + + + + wxgui_constellationsink2 + + id + wxgui_constellationsink2_0 + + + _enabled + True + + + title + Constellation Plot + + + samp_rate + samp_rate + + + frame_rate + 5 + + + const_size + 2048 + + + M + 4 + + + theta + 0 + + + loop_bw + 6.28/100.0 + + + fmax + 0.06 + + + mu + 0.5 + + + gain_mu + 0.005 + + + symbol_rate + samp_rate/samps_per_sym + + + omega_limit + 0.005 + + + win_size + + + + grid_pos + + + + notebook + + + + _coordinate + (931, 313) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + wxgui_fftsink2_0 + + + _enabled + True + + + type + complex + + + title + FFT Plot + + + samp_rate + samp_rate + + + baseband_freq + tun_freq + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 10 + + + ref_scale + 2.0 + + + fft_size + 1024 + + + fft_rate + 30 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + win + None + + + win_size + + + + grid_pos + + + + notebook + + + + _coordinate + (710, 236) + + + _rotation + 0 + + + + digital_dxpsk_demod + + id + digital_dxpsk_demod_0 + + + _enabled + True + + + type + dqpsk + + + samples_per_symbol + samps_per_sym + + + excess_bw + 0.35 + + + phase_bw + 6.28/100.0 + + + timing_bw + 6.28/100.0 + + + omega_relative_limit + 0.005 + + + gray_coded + True + + + verbose + False + + + log + False + + + sync_out + False + + + _coordinate + (303, 154) + + + _rotation + 0 + + + + variable_slider + + id + rx_freq_off + + + _enabled + True + + + label + RX Freq Offset (Hz) + + + value + freq_offset + + + min + -100e3 + + + max + +100e3 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (149, 437) + + + _rotation + 0 + + + + variable_slider + + id + tun_gain + + + _enabled + True + + + label + UHD Gain + + + value + gain + + + min + 0 + + + max + 20 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (306, 438) + + + _rotation + 0 + + + + uhd_usrp_source + + id + uhd_usrp_source_0 + + + _enabled + True + + + type + complex + + + dev_addr + address + + + sync + + + + clock_rate + 0.0 + + + num_mboards + 1 + + + ref_source0 + + + + sd_spec0 + + + + ref_source1 + + + + sd_spec1 + + + + ref_source2 + + + + sd_spec2 + + + + ref_source3 + + + + sd_spec3 + + + + ref_source4 + + + + sd_spec4 + + + + ref_source5 + + + + sd_spec5 + + + + ref_source6 + + + + sd_spec6 + + + + ref_source7 + + + + sd_spec7 + + + + nchan + 1 + + + samp_rate + samp_rate + + + center_freq0 + tun_freq+rx_freq_off + + + gain0 + tun_gain + + + ant0 + + + + bw0 + 0 + + + center_freq1 + 0 + + + gain1 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq2 + 0 + + + gain2 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq3 + 0 + + + gain3 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq4 + 0 + + + gain4 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq5 + 0 + + + gain5 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq6 + 0 + + + gain6 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq7 + 0 + + + gain7 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq8 + 0 + + + gain8 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq9 + 0 + + + gain9 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq10 + 0 + + + gain10 + 0 + + + ant10 + + + + bw10 + 0 + + + center_freq11 + 0 + + + gain11 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq12 + 0 + + + gain12 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq13 + 0 + + + gain13 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq14 + 0 + + + gain14 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq15 + 0 + + + gain15 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq16 + 0 + + + gain16 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq17 + 0 + + + gain17 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq18 + 0 + + + gain18 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq19 + 0 + + + gain19 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq20 + 0 + + + gain20 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq21 + 0 + + + gain21 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq22 + 0 + + + gain22 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq23 + 0 + + + gain23 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq24 + 0 + + + gain24 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq25 + 0 + + + gain25 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq26 + 0 + + + gain26 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq27 + 0 + + + gain27 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq28 + 0 + + + gain28 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq29 + 0 + + + gain29 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq30 + 0 + + + gain30 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq31 + 0 + + + gain31 + 0 + + + ant31 + + + + bw31 + 0 + + + _coordinate + (18, 276) + + + _rotation + 0 + + + + digital_dxpsk_demod_0 + gr_null_sink_0 + 0 + 0 + + + uhd_usrp_source_0 + digital_dxpsk_demod_0 + 0 + 0 + + + uhd_usrp_source_0 + wxgui_constellationsink2_0 + 0 + 0 + + + uhd_usrp_source_0 + wxgui_fftsink2_0 + 0 + 0 + + diff --git a/gr-uhd/examples/grc/uhd_two_tone_loopback.grc b/gr-uhd/examples/grc/uhd_two_tone_loopback.grc new file mode 100644 index 000000000..8bcbc0792 --- /dev/null +++ b/gr-uhd/examples/grc/uhd_two_tone_loopback.grc @@ -0,0 +1,2204 @@ + + + Sat Oct 8 15:27:04 2011 + + parameter + + id + tx_gain + + + _enabled + True + + + label + Default TX Gain + + + value + 0 + + + type + eng_float + + + short_id + + + + _coordinate + (999, 11) + + + _rotation + 0 + + + + parameter + + id + freq + + + _enabled + True + + + label + Default Frequency + + + value + 2.45e9 + + + type + eng_float + + + short_id + f + + + _coordinate + (665, 11) + + + _rotation + 0 + + + + parameter + + id + freq_offset + + + _enabled + True + + + label + Rx Frequency Offset + + + value + 0 + + + type + eng_float + + + short_id + o + + + _coordinate + (820, 11) + + + _rotation + 0 + + + + parameter + + id + address1 + + + _enabled + True + + + label + IP Address, Dev 1 + + + value + addr=192.168.11.2 + + + type + string + + + short_id + + + + _coordinate + (353, 14) + + + _rotation + 0 + + + + parameter + + id + address0 + + + _enabled + True + + + label + IP Address, Dev 0 + + + value + addr=192.168.10.2 + + + type + string + + + short_id + + + + _coordinate + (193, 14) + + + _rotation + 0 + + + + gr_sig_source_x + + id + gr_sig_source_x + + + _enabled + True + + + type + complex + + + samp_rate + samp_rate + + + waveform + gr.GR_COS_WAVE + + + freq + tone1 + + + amp + tone_ampl + + + offset + 0 + + + _coordinate + (258, 136) + + + _rotation + 0 + + + + gr_sig_source_x + + id + gr_sig_source_x0 + + + _enabled + True + + + type + complex + + + samp_rate + samp_rate + + + waveform + gr.GR_COS_WAVE + + + freq + tone2 + + + amp + tone_ampl + + + offset + 0 + + + _coordinate + (259, 248) + + + _rotation + 0 + + + + gr_noise_source_x + + id + gr_noise_source_x + + + _enabled + True + + + type + complex + + + noise_type + gr.GR_GAUSSIAN + + + amp + noise_ampl + + + seed + 42 + + + _coordinate + (279, 364) + + + _rotation + 0 + + + + uhd_usrp_sink + + id + uhd_usrp_sink_0 + + + _enabled + True + + + type + complex + + + dev_addr + address0 + + + sync + + + + clock_rate + 0.0 + + + num_mboards + 1 + + + ref_source0 + + + + sd_spec0 + + + + ref_source1 + + + + sd_spec1 + + + + ref_source2 + + + + sd_spec2 + + + + ref_source3 + + + + sd_spec3 + + + + ref_source4 + + + + sd_spec4 + + + + ref_source5 + + + + sd_spec5 + + + + ref_source6 + + + + sd_spec6 + + + + ref_source7 + + + + sd_spec7 + + + + nchan + 1 + + + samp_rate + samp_rate + + + center_freq0 + tun_freq + + + gain0 + tun_rx_gain + + + ant0 + + + + bw0 + 0 + + + center_freq1 + 0 + + + gain1 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq2 + 0 + + + gain2 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq3 + 0 + + + gain3 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq4 + 0 + + + gain4 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq5 + 0 + + + gain5 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq6 + 0 + + + gain6 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq7 + 0 + + + gain7 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq8 + 0 + + + gain8 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq9 + 0 + + + gain9 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq10 + 0 + + + gain10 + 0 + + + ant10 + + + + bw10 + 0 + + + center_freq11 + 0 + + + gain11 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq12 + 0 + + + gain12 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq13 + 0 + + + gain13 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq14 + 0 + + + gain14 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq15 + 0 + + + gain15 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq16 + 0 + + + gain16 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq17 + 0 + + + gain17 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq18 + 0 + + + gain18 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq19 + 0 + + + gain19 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq20 + 0 + + + gain20 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq21 + 0 + + + gain21 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq22 + 0 + + + gain22 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq23 + 0 + + + gain23 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq24 + 0 + + + gain24 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq25 + 0 + + + gain25 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq26 + 0 + + + gain26 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq27 + 0 + + + gain27 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq28 + 0 + + + gain28 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq29 + 0 + + + gain29 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq30 + 0 + + + gain30 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq31 + 0 + + + gain31 + 0 + + + ant31 + + + + bw31 + 0 + + + _coordinate + (669, 178) + + + _rotation + 0 + + + + parameter + + id + rx_gain + + + _enabled + True + + + label + Default RX Gain + + + value + 0 + + + type + eng_float + + + short_id + + + + _coordinate + (1139, 12) + + + _rotation + 0 + + + + variable_slider + + id + tone1 + + + _enabled + True + + + label + Tone 1 + + + value + 50e3 + + + min + -samp_rate/2 + + + max + samp_rate/2 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 0, 0, 1, 4 + + + notebook + + + + _coordinate + (161, 484) + + + _rotation + 0 + + + + variable_slider + + id + tone2 + + + _enabled + True + + + label + Tone 2 + + + value + 75e3 + + + min + -samp_rate/2 + + + max + samp_rate/2 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 0, 4, 1, 4 + + + notebook + + + + _coordinate + (308, 483) + + + _rotation + 0 + + + + variable_slider + + id + tun_tx_gain + + + _enabled + True + + + label + UHD TX Gain + + + value + tx_gain + + + min + 0 + + + max + 20 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (655, 486) + + + _rotation + 0 + + + + variable_slider + + id + tun_freq + + + _enabled + True + + + label + Freq (Hz) + + + value + freq + + + min + 2.4e9 + + + max + 2.5e9 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (514, 487) + + + _rotation + 0 + + + + variable_slider + + id + tun_rx_gain + + + _enabled + True + + + label + UHD RX Gain + + + value + rx_gain + + + min + 0 + + + max + 20 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (781, 487) + + + _rotation + 0 + + + + uhd_usrp_source + + id + uhd_usrp_source_0 + + + _enabled + True + + + type + complex + + + dev_addr + address1 + + + sync + + + + clock_rate + 0.0 + + + num_mboards + 1 + + + ref_source0 + + + + sd_spec0 + + + + ref_source1 + + + + sd_spec1 + + + + ref_source2 + + + + sd_spec2 + + + + ref_source3 + + + + sd_spec3 + + + + ref_source4 + + + + sd_spec4 + + + + ref_source5 + + + + sd_spec5 + + + + ref_source6 + + + + sd_spec6 + + + + ref_source7 + + + + sd_spec7 + + + + nchan + 1 + + + samp_rate + samp_rate + + + center_freq0 + tun_freq + + + gain0 + tun_rx_gain + + + ant0 + + + + bw0 + 0 + + + center_freq1 + 0 + + + gain1 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq2 + 0 + + + gain2 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq3 + 0 + + + gain3 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq4 + 0 + + + gain4 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq5 + 0 + + + gain5 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq6 + 0 + + + gain6 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq7 + 0 + + + gain7 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq8 + 0 + + + gain8 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq9 + 0 + + + gain9 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq10 + 0 + + + gain10 + 0 + + + ant10 + + + + bw10 + 0 + + + center_freq11 + 0 + + + gain11 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq12 + 0 + + + gain12 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq13 + 0 + + + gain13 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq14 + 0 + + + gain14 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq15 + 0 + + + gain15 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq16 + 0 + + + gain16 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq17 + 0 + + + gain17 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq18 + 0 + + + gain18 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq19 + 0 + + + gain19 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq20 + 0 + + + gain20 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq21 + 0 + + + gain21 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq22 + 0 + + + gain22 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq23 + 0 + + + gain23 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq24 + 0 + + + gain24 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq25 + 0 + + + gain25 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq26 + 0 + + + gain26 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq27 + 0 + + + gain27 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq28 + 0 + + + gain28 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq29 + 0 + + + gain29 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq30 + 0 + + + gain30 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq31 + 0 + + + gain31 + 0 + + + ant31 + + + + bw31 + 0 + + + _coordinate + (672, 320) + + + _rotation + 0 + + + + variable_slider + + id + tone_ampl + + + _enabled + True + + + label + Tone Ampl + + + value + 0.15 + + + min + 0 + + + max + 1 + + + num_steps + 100 + + + style + wx.SL_VERTICAL + + + converver + float_converter + + + grid_pos + 1, 0, 2, 1 + + + notebook + + + + _coordinate + (14, 485) + + + _rotation + 0 + + + + variable_slider + + id + noise_ampl + + + _enabled + True + + + label + Noise Ampl + + + value + 0.1 + + + min + 0 + + + max + 1 + + + num_steps + 100 + + + style + wx.SL_VERTICAL + + + converver + float_converter + + + grid_pos + 1, 1, 2, 1 + + + notebook + + + + _coordinate + (15, 335) + + + _rotation + 0 + + + + gr_add_xx + + id + gr_add_xx + + + _enabled + True + + + type + complex + + + num_inputs + 3 + + + vlen + 1 + + + _coordinate + (529, 172) + + + _rotation + 0 + + + + options + + id + uhd_two_tone_loopback + + + _enabled + True + + + title + UHD Loopback - 2 Tone + + + author + Example + + + description + Loopback test + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + wxgui_fftsink2 + + + _enabled + True + + + type + complex + + + title + FFT Plot + + + samp_rate + samp_rate + + + baseband_freq + 0 + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 0 + + + ref_scale + 2.0 + + + fft_size + 512*2 + + + fft_rate + 15 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + win + window.blackmanharris + + + win_size + + + + grid_pos + 1, 2, 2, 4 + + + notebook + + + + _coordinate + (1114, 264) + + + _rotation + 0 + + + + parameter + + id + samp_rate + + + _enabled + True + + + label + Sample Rate + + + value + 500e3 + + + type + eng_float + + + short_id + s + + + _coordinate + (539, 11) + + + _rotation + 0 + + + + gr_noise_source_x + gr_add_xx + 0 + 2 + + + gr_sig_source_x0 + gr_add_xx + 0 + 1 + + + gr_sig_source_x + gr_add_xx + 0 + 0 + + + gr_add_xx + uhd_usrp_sink_0 + 0 + 0 + + + uhd_usrp_source_0 + wxgui_fftsink2 + 0 + 0 + + diff --git a/gr-uhd/examples/grc/uhd_tx_dpsk.grc b/gr-uhd/examples/grc/uhd_tx_dpsk.grc new file mode 100644 index 000000000..281ba8429 --- /dev/null +++ b/gr-uhd/examples/grc/uhd_tx_dpsk.grc @@ -0,0 +1,1234 @@ + + + Sat Oct 8 14:55:39 2011 + + variable + + id + samps_per_sym + + + _enabled + True + + + value + 4 + + + _coordinate + (10, 100) + + + _rotation + 0 + + + + variable_slider + + id + ampl + + + _enabled + True + + + label + Amplitude + + + value + .1 + + + min + 0 + + + max + 1 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (7, 299) + + + _rotation + 0 + + + + parameter + + id + samp_rate + + + _enabled + True + + + label + Sample Rate + + + value + 1e6 + + + type + eng_float + + + short_id + s + + + _coordinate + (334, 15) + + + _rotation + 0 + + + + parameter + + id + freq + + + _enabled + True + + + label + Default Frequency + + + value + 2.45e9 + + + type + eng_float + + + short_id + f + + + _coordinate + (463, 17) + + + _rotation + 0 + + + + variable_slider + + id + tun_gain + + + _enabled + True + + + label + UHD Gain + + + value + gain + + + min + 0 + + + max + 20 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (151, 441) + + + _rotation + 0 + + + + variable_slider + + id + tun_freq + + + _enabled + True + + + label + Freq (Hz) + + + value + freq + + + min + 2.4e9 + + + max + 2.5e9 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (7, 441) + + + _rotation + 0 + + + + random_source_x + + id + random_source_x_0 + + + _enabled + True + + + type + byte + + + min + 0 + + + max + 2**8 + + + num_samps + 1000 + + + repeat + True + + + _coordinate + (177, 162) + + + _rotation + 0 + + + + digital_dxpsk_mod + + id + digital_dxpsk_mod_0 + + + _enabled + True + + + type + dqpsk + + + samples_per_symbol + samps_per_sym + + + excess_bw + 0.35 + + + gray_coded + True + + + verbose + False + + + log + False + + + _coordinate + (366, 162) + + + _rotation + 0 + + + + parameter + + id + gain + + + _enabled + True + + + label + Default Gain + + + value + 0 + + + type + eng_float + + + short_id + g + + + _coordinate + (619, 15) + + + _rotation + 0 + + + + parameter + + id + address + + + _enabled + True + + + label + IP Address + + + value + addr=192.168.10.2 + + + type + string + + + short_id + a + + + _coordinate + (177, 14) + + + _rotation + 0 + + + + uhd_usrp_sink + + id + uhd_usrp_sink_0 + + + _enabled + True + + + type + complex + + + dev_addr + address + + + sync + + + + clock_rate + 0.0 + + + num_mboards + 1 + + + ref_source0 + + + + sd_spec0 + + + + ref_source1 + + + + sd_spec1 + + + + ref_source2 + + + + sd_spec2 + + + + ref_source3 + + + + sd_spec3 + + + + ref_source4 + + + + sd_spec4 + + + + ref_source5 + + + + sd_spec5 + + + + ref_source6 + + + + sd_spec6 + + + + ref_source7 + + + + sd_spec7 + + + + nchan + 1 + + + samp_rate + samp_rate + + + center_freq0 + tun_freq + + + gain0 + tun_gain + + + ant0 + + + + bw0 + 0 + + + center_freq1 + 0 + + + gain1 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq2 + 0 + + + gain2 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq3 + 0 + + + gain3 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq4 + 0 + + + gain4 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq5 + 0 + + + gain5 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq6 + 0 + + + gain6 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq7 + 0 + + + gain7 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq8 + 0 + + + gain8 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq9 + 0 + + + gain9 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq10 + 0 + + + gain10 + 0 + + + ant10 + + + + bw10 + 0 + + + center_freq11 + 0 + + + gain11 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq12 + 0 + + + gain12 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq13 + 0 + + + gain13 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq14 + 0 + + + gain14 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq15 + 0 + + + gain15 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq16 + 0 + + + gain16 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq17 + 0 + + + gain17 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq18 + 0 + + + gain18 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq19 + 0 + + + gain19 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq20 + 0 + + + gain20 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq21 + 0 + + + gain21 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq22 + 0 + + + gain22 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq23 + 0 + + + gain23 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq24 + 0 + + + gain24 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq25 + 0 + + + gain25 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq26 + 0 + + + gain26 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq27 + 0 + + + gain27 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq28 + 0 + + + gain28 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq29 + 0 + + + gain29 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq30 + 0 + + + gain30 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq31 + 0 + + + gain31 + 0 + + + ant31 + + + + bw31 + 0 + + + _coordinate + (783, 162) + + + _rotation + 0 + + + + gr_multiply_const_vxx + + id + gr_multiply_const_vxx_0 + + + _enabled + True + + + type + complex + + + const + ampl + + + vlen + 1 + + + _coordinate + (566, 186) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + wxgui_fftsink2_0 + + + _enabled + True + + + type + complex + + + title + Transmit Spectrum + + + samp_rate + samp_rate + + + baseband_freq + tun_freq + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 0 + + + ref_scale + 2 + + + fft_size + 1024 + + + fft_rate + 20 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + win + None + + + win_size + + + + grid_pos + + + + notebook + + + + _coordinate + (827, 299) + + + _rotation + 0 + + + + options + + id + uhd_tx_dpsk + + + _enabled + True + + + title + UHD TX DPSK + + + author + + + + description + + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + random_source_x_0 + digital_dxpsk_mod_0 + 0 + 0 + + + gr_multiply_const_vxx_0 + wxgui_fftsink2_0 + 0 + 0 + + + gr_multiply_const_vxx_0 + uhd_usrp_sink_0 + 0 + 0 + + + digital_dxpsk_mod_0 + gr_multiply_const_vxx_0 + 0 + 0 + + diff --git a/gr-uhd/examples/grc/uhd_wbfm_receive.grc b/gr-uhd/examples/grc/uhd_wbfm_receive.grc new file mode 100644 index 000000000..62658a2eb --- /dev/null +++ b/gr-uhd/examples/grc/uhd_wbfm_receive.grc @@ -0,0 +1,1365 @@ + + + Sat Oct 8 15:18:49 2011 + + options + + id + uhd_wbfm_receive + + + _enabled + True + + + title + UHD WBFM Receive + + + author + Example + + + description + WBFM Receive + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + parameter + + id + gain + + + _enabled + True + + + label + Default Gain + + + value + 0 + + + type + eng_float + + + short_id + g + + + _coordinate + (631, 15) + + + _rotation + 0 + + + + parameter + + id + freq + + + _enabled + True + + + label + Default Frequency + + + value + 93.3e6 + + + type + eng_float + + + short_id + f + + + _coordinate + (479, 15) + + + _rotation + 0 + + + + variable_slider + + id + tun_freq + + + _enabled + True + + + label + Freq (Hz) + + + value + freq + + + min + 87.9e6 + + + max + 108.1e6 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (15, 441) + + + _rotation + 0 + + + + variable_slider + + id + fine + + + _enabled + True + + + label + Fine Freq (MHz) + + + value + 0 + + + min + -.1 + + + max + .1 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 0, 2, 1, 2 + + + notebook + + + + _coordinate + (277, 444) + + + _rotation + 0 + + + + variable_slider + + id + tun_gain + + + _enabled + True + + + label + UHD Gain + + + value + gain + + + min + 0 + + + max + 20 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (158, 440) + + + _rotation + 0 + + + + variable_slider + + id + volume + + + _enabled + True + + + label + Volume + + + value + 1 + + + min + 0 + + + max + 10 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 1, 0, 1, 4 + + + notebook + + + + _coordinate + (436, 446) + + + _rotation + 0 + + + + gr_multiply_const_vxx + + id + gr_multiply_const_vxx + + + _enabled + True + + + type + float + + + const + volume + + + vlen + 1 + + + _coordinate + (836, 161) + + + _rotation + 0 + + + + uhd_usrp_source + + id + uhd_usrp_source_0 + + + _enabled + True + + + type + complex + + + dev_addr + address + + + sync + + + + clock_rate + 0.0 + + + num_mboards + 1 + + + ref_source0 + + + + sd_spec0 + + + + ref_source1 + + + + sd_spec1 + + + + ref_source2 + + + + sd_spec2 + + + + ref_source3 + + + + sd_spec3 + + + + ref_source4 + + + + sd_spec4 + + + + ref_source5 + + + + sd_spec5 + + + + ref_source6 + + + + sd_spec6 + + + + ref_source7 + + + + sd_spec7 + + + + nchan + 1 + + + samp_rate + samp_rate + + + center_freq0 + tun_freq+fine + + + gain0 + tun_gain + + + ant0 + + + + bw0 + 0 + + + center_freq1 + 0 + + + gain1 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq2 + 0 + + + gain2 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq3 + 0 + + + gain3 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq4 + 0 + + + gain4 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq5 + 0 + + + gain5 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq6 + 0 + + + gain6 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq7 + 0 + + + gain7 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq8 + 0 + + + gain8 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq9 + 0 + + + gain9 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq10 + 0 + + + gain10 + 0 + + + ant10 + + + + bw10 + 0 + + + center_freq11 + 0 + + + gain11 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq12 + 0 + + + gain12 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq13 + 0 + + + gain13 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq14 + 0 + + + gain14 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq15 + 0 + + + gain15 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq16 + 0 + + + gain16 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq17 + 0 + + + gain17 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq18 + 0 + + + gain18 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq19 + 0 + + + gain19 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq20 + 0 + + + gain20 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq21 + 0 + + + gain21 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq22 + 0 + + + gain22 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq23 + 0 + + + gain23 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq24 + 0 + + + gain24 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq25 + 0 + + + gain25 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq26 + 0 + + + gain26 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq27 + 0 + + + gain27 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq28 + 0 + + + gain28 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq29 + 0 + + + gain29 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq30 + 0 + + + gain30 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq31 + 0 + + + gain31 + 0 + + + ant31 + + + + bw31 + 0 + + + _coordinate + (14, 165) + + + _rotation + 0 + + + + parameter + + id + address + + + _enabled + True + + + label + IP Address + + + value + addr=192.168.10.2 + + + type + string + + + short_id + a + + + _coordinate + (199, 14) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + wxgui_fftsink2 + + + _enabled + True + + + type + complex + + + title + FFT Plot + + + samp_rate + samp_rate + + + baseband_freq + (freq+fine)*1e6 + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 0 + + + ref_scale + 2.0 + + + fft_size + 512 + + + fft_rate + 15 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + win + None + + + win_size + + + + grid_pos + 2, 0, 2, 4 + + + notebook + + + + _coordinate + (624, 278) + + + _rotation + 0 + + + + parameter + + id + samp_rate + + + _enabled + True + + + label + Sample Rate + + + value + 400e3 + + + type + eng_float + + + short_id + s + + + _coordinate + (352, 15) + + + _rotation + 0 + + + + parameter + + id + audio_output + + + _enabled + True + + + label + Audio Output Device + + + value + + + + type + string + + + short_id + O + + + _coordinate + (769, 13) + + + _rotation + 0 + + + + audio_sink + + id + audio_sink + + + _enabled + True + + + samp_rate + int(samp_rate/audio_decim) + + + device_name + audio_output + + + ok_to_block + True + + + num_inputs + 1 + + + _coordinate + (1023, 161) + + + _rotation + 0 + + + + blks2_wfm_rcv + + id + blks2_wfm_rcv + + + _enabled + True + + + quad_rate + samp_rate + + + audio_decimation + audio_decim + + + _coordinate + (626, 153) + + + _rotation + 0 + + + + low_pass_filter + + id + low_pass_filter_0 + + + _enabled + True + + + type + fir_filter_ccf + + + decim + 1 + + + interp + 1 + + + gain + 1 + + + samp_rate + samp_rate + + + cutoff_freq + 115e3 + + + width + 30e3 + + + win + firdes.WIN_HANN + + + beta + 6.76 + + + _coordinate + (326, 141) + + + _rotation + 0 + + + + variable + + id + audio_decim + + + _enabled + True + + + value + 10 + + + _coordinate + (19, 351) + + + _rotation + 0 + + + + gr_multiply_const_vxx + audio_sink + 0 + 0 + + + blks2_wfm_rcv + gr_multiply_const_vxx + 0 + 0 + + + low_pass_filter_0 + blks2_wfm_rcv + 0 + 0 + + + uhd_usrp_source_0 + low_pass_filter_0 + 0 + 0 + + + low_pass_filter_0 + wxgui_fftsink2 + 0 + 0 + + diff --git a/gr-uhd/examples/max_power.py b/gr-uhd/examples/max_power.py deleted file mode 100755 index a849432ee..000000000 --- a/gr-uhd/examples/max_power.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -""" -Setup USRP for maximum power consumption. -""" - - -from gnuradio import gr -from gnuradio import uhd -from gnuradio.eng_option import eng_option -from optparse import OptionParser - -from gnuradio import eng_notation - -n2s = eng_notation.num_to_str - -# Set this to a huge number; UHD will adjust to the -# maximum the USRP xxxx device can handle -MAX_RATE = 1000e6 - -class build_block(gr.top_block): - def __init__(self, args, tx_enable, rx_enable): - gr.top_block.__init__(self) - - d = uhd.find_devices(uhd.device_addr(args)) - uhd_type = d[0].get('type') - - print "\nFound '%s' at args '%s'" % \ - (uhd_type, args) - - # Test the type of USRP; if it's a USRP (v1), it has - # 2 channels; otherwise, it has 1 channel - if uhd_type == "usrp": - tx_nchan = 2 - rx_nchan = 2 - else: - tx_nchan = 1 - rx_nchan = 1 - - if tx_enable: - print "\nTRANSMIT CHAIN" - stream_args = uhd.stream_args('fc32', channels=range(tx_nchan)) - self.u_tx = uhd.usrp_sink(device_addr=args, stream_args=stream_args) - self.u_tx.set_samp_rate(MAX_RATE) - - self.tx_src0 = gr.sig_source_c(self.u_tx.get_samp_rate(), - gr.GR_CONST_WAVE, - 0, 1.0, 0) - - # Get dboard gain range and select maximum - tx_gain_range = self.u_tx.get_gain_range() - tx_gain = tx_gain_range.stop() - - # Get dboard freq range and select midpoint - tx_freq_range = self.u_tx.get_freq_range() - tx_freq_mid = (tx_freq_range.start() + tx_freq_range.stop())/2.0 - - for i in xrange(tx_nchan): - self.u_tx.set_center_freq (tx_freq_mid + i*1e6, i) - self.u_tx.set_gain(tx_gain, i) - - print "\nTx Sample Rate: %ssps" % (n2s(self.u_tx.get_samp_rate())) - for i in xrange(tx_nchan): - print "Tx Channel %d: " % (i) - print "\tFrequency = %sHz" % \ - (n2s(self.u_tx.get_center_freq(i))) - print "\tGain = %f dB" % (self.u_tx.get_gain(i)) - print "" - - self.connect (self.tx_src0, self.u_tx) - - if rx_enable: - print "\nRECEIVE CHAIN" - self.u_rx = uhd.usrp_source(device_addr=args, - io_type=uhd.io_type.COMPLEX_FLOAT32, - num_channels=rx_nchan) - self.rx_dst0 = gr.null_sink (gr.sizeof_gr_complex) - - self.u_rx.set_samp_rate(MAX_RATE) - - # Get dboard gain range and select maximum - rx_gain_range = self.u_rx.get_gain_range() - rx_gain = rx_gain_range.stop() - - # Get dboard freq range and select midpoint - rx_freq_range = self.u_rx.get_freq_range() - rx_freq_mid = (rx_freq_range.start() + rx_freq_range.stop())/2.0 - - for i in xrange(tx_nchan): - self.u_rx.set_center_freq (rx_freq_mid + i*1e6, i) - self.u_rx.set_gain(rx_gain, i) - - print "\nRx Sample Rate: %ssps" % (n2s(self.u_rx.get_samp_rate())) - for i in xrange(rx_nchan): - print "Rx Channel %d: " % (i) - print "\tFrequency = %sHz" % \ - (n2s(self.u_rx.get_center_freq(i))) - print "\tGain = %f dB" % (self.u_rx.get_gain(i)) - print "" - - self.connect (self.u_rx, self.rx_dst0) - -def main (): - parser = OptionParser (option_class=eng_option) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("-t", action="store_true", dest="tx_enable", - default=False, help="enable Tx path") - parser.add_option("-r", action="store_true", dest="rx_enable", - default=False, help="enable Rx path") - (options, args) = parser.parse_args () - - tb = build_block (options.args, options.tx_enable, options.rx_enable) - - tb.start () - raw_input ('Press Enter to quit: ') - tb.stop () - -if __name__ == '__main__': - main () diff --git a/gr-uhd/examples/python/CMakeLists.txt b/gr-uhd/examples/python/CMakeLists.txt new file mode 100644 index 000000000..7642b536b --- /dev/null +++ b/gr-uhd/examples/python/CMakeLists.txt @@ -0,0 +1,42 @@ +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +include(GrPython) + +GR_PYTHON_INSTALL( + PROGRAMS + fm_tx4.py + fm_tx_2_daughterboards.py + max_power.py + usrp_am_mw_rcv.py + usrp_nbfm_ptt.py + usrp_nbfm_rcv.py + usrp_spectrum_sense.py + usrp_tv_rcv_nogui.py + usrp_tv_rcv.py + usrp_wfm_rcv2_nogui.py + usrp_wfm_rcv_fmdet.py + usrp_wfm_rcv_nogui.py + usrp_wfm_rcv_pll.py + usrp_wfm_rcv.py + usrp_wfm_rcv_sca.py + usrp_wxapt_rcv.py + DESTINATION ${GR_PKG_UHD_EXAMPLES_DIR} + COMPONENT "uhd_python" +) diff --git a/gr-uhd/examples/python/fm_tx4.py b/gr-uhd/examples/python/fm_tx4.py new file mode 100755 index 000000000..aecb35b54 --- /dev/null +++ b/gr-uhd/examples/python/fm_tx4.py @@ -0,0 +1,208 @@ +#!/usr/bin/env python +# +# Copyright 2005-2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +""" +Transmit N simultaneous narrow band FM signals. + +They will be centered at the frequency specified on the command line, +and will spaced at 25kHz steps from there. + +The program opens N files with names audio-N.dat where N is in [0,7]. +These files should contain floating point audio samples in the range [-1,1] +sampled at 32kS/sec. You can create files like this using +audio_to_file.py +""" + +from gnuradio import gr, eng_notation +from gnuradio import uhd +from gnuradio import blks2 +from gnuradio.eng_option import eng_option +from optparse import OptionParser +import math +import sys + +from gnuradio.wxgui import stdgui2, fftsink2 +import wx + + +######################################################## +# instantiate one transmit chain for each call + +class pipeline(gr.hier_block2): + def __init__(self, filename, lo_freq, audio_rate, if_rate): + + gr.hier_block2.__init__(self, "pipeline", + gr.io_signature(0, 0, 0), + gr.io_signature(1, 1, gr.sizeof_gr_complex)) + + try: + src = gr.file_source (gr.sizeof_float, filename, True) + except RuntimeError: + sys.stderr.write(("\nError: Could not open file '%s'\n\n" % \ + filename)) + sys.exit(1) + + print audio_rate, if_rate + fmtx = blks2.nbfm_tx (audio_rate, if_rate, max_dev=5e3, tau=75e-6) + + # Local oscillator + lo = gr.sig_source_c (if_rate, # sample rate + gr.GR_SIN_WAVE, # waveform type + lo_freq, #frequency + 1.0, # amplitude + 0) # DC Offset + mixer = gr.multiply_cc () + + self.connect (src, fmtx, (mixer, 0)) + self.connect (lo, (mixer, 1)) + self.connect (mixer, self) + +class fm_tx_block(stdgui2.std_top_block): + def __init__(self, frame, panel, vbox, argv): + MAX_CHANNELS = 7 + stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) + + parser = OptionParser (option_class=eng_option) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-s", "--samp-rate", type="eng_float", default=400e3, + help="set sample rate (bandwidth) [default=%default]") + parser.add_option("-f", "--freq", type="eng_float", default=None, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is midpoint)") + parser.add_option("-n", "--nchannels", type="int", default=4, + help="number of Tx channels [1,4]") + #parser.add_option("","--debug", action="store_true", default=False, + # help="Launch Tx debugger") + (options, args) = parser.parse_args () + + if len(args) != 0: + parser.print_help() + sys.exit(1) + + if options.nchannels < 1 or options.nchannels > MAX_CHANNELS: + sys.stderr.write ("fm_tx4: nchannels out of range. Must be in [1,%d]\n" % MAX_CHANNELS) + sys.exit(1) + + if options.freq is None: + sys.stderr.write("fm_tx4: must specify frequency with -f FREQ\n") + parser.print_help() + sys.exit(1) + + # ---------------------------------------------------------------- + # Set up constants and parameters + + self.u = uhd.usrp_sink(device_addr=options.args, stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + + self.usrp_rate = options.samp_rate + self.u.set_samp_rate(self.usrp_rate) + self.usrp_rate = self.u.get_samp_rate() + + self.sw_interp = 10 + self.audio_rate = self.usrp_rate / self.sw_interp # 32 kS/s + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2 + + self.set_gain(options.gain) + self.set_freq(options.freq) + + self.sum = gr.add_cc () + + # Instantiate N NBFM channels + step = 25e3 + offset = (0 * step, 1 * step, -1 * step, + 2 * step, -2 * step, 3 * step, -3 * step) + + for i in range (options.nchannels): + t = pipeline("audio-%d.dat" % (i % 4), offset[i], + self.audio_rate, self.usrp_rate) + self.connect(t, (self.sum, i)) + + self.gain = gr.multiply_const_cc (1.0 / options.nchannels) + + # connect it all + self.connect (self.sum, self.gain) + self.connect (self.gain, self.u) + + # plot an FFT to verify we are sending what we want + if 1: + post_mod = fftsink2.fft_sink_c(panel, title="Post Modulation", + fft_size=512, + sample_rate=self.usrp_rate, + y_per_div=20, + ref_level=40) + self.connect (self.gain, post_mod) + vbox.Add (post_mod.win, 1, wx.EXPAND) + + + #if options.debug: + # self.debugger = tx_debug_gui.tx_debug_gui(self.subdev) + # self.debugger.Show(True) + + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + + Tuning is a two step process. First we ask the front-end to + tune as close to the desired frequency as it can. Then we use + the result of that operation and our target_frequency to + determine the value for the digital up converter. Finally, we feed + any residual_freq to the s/w freq translater. + """ + + r = self.u.set_center_freq(target_freq, 0) + if r: + print "Frequency =", eng_notation.num_to_str(self.u.get_center_freq()) + return True + + return False + + def set_gain(self, gain): + self.u.set_gain(gain, 0) + + +def main (): + app = stdgui2.stdapp(fm_tx_block, "Multichannel FM Tx", nstatus=1) + app.MainLoop () + +if __name__ == '__main__': + main () diff --git a/gr-uhd/examples/python/fm_tx_2_daughterboards.py b/gr-uhd/examples/python/fm_tx_2_daughterboards.py new file mode 100755 index 000000000..c0a7112de --- /dev/null +++ b/gr-uhd/examples/python/fm_tx_2_daughterboards.py @@ -0,0 +1,212 @@ +#!/usr/bin/env python +# +# Copyright 2005-2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +""" +Transmit 2 signals, one out each daughterboard. + +Outputs SSB (USB) signals on side A and side B at frequencies +specified on command line. + +Side A is 600 Hz tone. +Side B is 350 + 440 Hz tones. +""" + +from gnuradio import gr, uhd, blks2 +from gnuradio.eng_notation import num_to_str, str_to_num +from gnuradio.eng_option import eng_option +from optparse import OptionParser +import math +import sys + + +class example_signal_0(gr.hier_block2): + """ + Sinusoid at 600 Hz. + """ + def __init__(self, sample_rate): + gr.hier_block2.__init__(self, "example_signal_0", + gr.io_signature(0, 0, 0), # Input signature + gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature + + src = gr.sig_source_c (sample_rate, # sample rate + gr.GR_SIN_WAVE, # waveform type + 600, # frequency + 1.0, # amplitude + 0) # DC Offset + + self.connect(src, self) + + +class example_signal_1(gr.hier_block2): + """ + North American dial tone (350 + 440 Hz). + """ + def __init__(self, sample_rate): + gr.hier_block2.__init__(self, "example_signal_1", + gr.io_signature(0, 0, 0), # Input signature + gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature + + src0 = gr.sig_source_c (sample_rate, # sample rate + gr.GR_SIN_WAVE, # waveform type + 350, # frequency + 1.0, # amplitude + 0) # DC Offset + + src1 = gr.sig_source_c (sample_rate, # sample rate + gr.GR_SIN_WAVE, # waveform type + 440, # frequency + 1.0, # amplitude + 0) # DC Offset + sum = gr.add_cc() + self.connect(src0, (sum, 0)) + self.connect(src1, (sum, 1)) + self.connect(sum, self) + +class my_top_block(gr.top_block): + + def __init__(self): + gr.top_block.__init__(self) + + usage="%prog: [options] tx-freq0 tx-freq1" + parser = OptionParser (option_class=eng_option, usage=usage) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-s", "--samp-rate", type="eng_float", default=320e3, + help="set sample rate [default=%default]") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is midpoint)") + (options, args) = parser.parse_args () + + if len(args) != 2: + parser.print_help() + raise SystemExit + else: + freq0 = str_to_num(args[0]) + freq1 = str_to_num(args[1]) + + # ---------------------------------------------------------------- + # Set up USRP to transmit on both daughterboards + + d = uhd.find_devices(uhd.device_addr(options.args)) + uhd_type = d[0].get('type') + + stream_args = uhd.stream_args('fc32', channels=range(2)) + self.u = uhd.usrp_sink(device_addr=options.args, stream_args=stream_args) + + # Set up USRP system based on type + if(uhd_type == "usrp"): + self.u.set_subdev_spec("A:0 B:0") + tr0 = uhd.tune_request(freq0) + tr1 = uhd.tune_request(freq1) + + else: + if abs(freq0 - freq1) > 5.5e6: + sys.stderr.write("\nError: When not using two separate d'boards, frequencies must bewithin 5.5MHz of each other.\n") + raise SystemExit + + self.u.set_subdev_spec("A:0 A:0") + + mid_freq = (freq0 + freq1)/2.0 + tr0 = uhd.tune_request(freq0, rf_freq=mid_freq, + rf_freq_policy=uhd.tune_request.POLICY_MANUAL) + + tr1 = uhd.tune_request(freq1, rf_freq=mid_freq, + rf_freq_policy=uhd.tune_request.POLICY_MANUAL) + + # Use the tune requests to tune each channel + self.set_freq(tr0, 0) + self.set_freq(tr1, 1) + + self.usrp_rate = options.samp_rate + + self.u.set_samp_rate(self.usrp_rate) + dev_rate = self.u.get_samp_rate() + + # ---------------------------------------------------------------- + # build two signal sources, interleave them, amplify and + # connect them to usrp + + sig0 = example_signal_0(self.usrp_rate) + sig1 = example_signal_1(self.usrp_rate) + + intl = gr.interleave(gr.sizeof_gr_complex) + self.connect(sig0, (intl, 0)) + self.connect(sig1, (intl, 1)) + + # Correct for any difference in requested and actual rates + rrate = self.usrp_rate / dev_rate + resamp = blks2.pfb_arb_resampler_ccf(rrate) + + # and wire them up + self.connect(intl, resamp, self.u) + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2.0 + + self.set_gain(options.gain, 0) + self.set_gain(options.gain, 1) + + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + self.u.set_antenna(options.antenna, 1) + + def set_freq(self, target_freq, chan): + """ + Set the center frequency we're interested in. + + @param side: 0 = side A, 1 = side B + @param target_freq: frequency in Hz + @rtype: bool + """ + + print "Tuning channel %s to %sHz" % \ + (chan, num_to_str(target_freq)) + + r = self.u.set_center_freq(target_freq, chan) + + if r: + return True + + else: + print " Set Frequency Failed!" + + return False + + def set_gain(self, gain, chan): + self.u.set_gain(gain, chan) + +if __name__ == '__main__': + try: + my_top_block().run() + except KeyboardInterrupt: + pass diff --git a/gr-uhd/examples/python/max_power.py b/gr-uhd/examples/python/max_power.py new file mode 100755 index 000000000..a849432ee --- /dev/null +++ b/gr-uhd/examples/python/max_power.py @@ -0,0 +1,140 @@ +#!/usr/bin/env python +# +# Copyright 2004,2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +""" +Setup USRP for maximum power consumption. +""" + + +from gnuradio import gr +from gnuradio import uhd +from gnuradio.eng_option import eng_option +from optparse import OptionParser + +from gnuradio import eng_notation + +n2s = eng_notation.num_to_str + +# Set this to a huge number; UHD will adjust to the +# maximum the USRP xxxx device can handle +MAX_RATE = 1000e6 + +class build_block(gr.top_block): + def __init__(self, args, tx_enable, rx_enable): + gr.top_block.__init__(self) + + d = uhd.find_devices(uhd.device_addr(args)) + uhd_type = d[0].get('type') + + print "\nFound '%s' at args '%s'" % \ + (uhd_type, args) + + # Test the type of USRP; if it's a USRP (v1), it has + # 2 channels; otherwise, it has 1 channel + if uhd_type == "usrp": + tx_nchan = 2 + rx_nchan = 2 + else: + tx_nchan = 1 + rx_nchan = 1 + + if tx_enable: + print "\nTRANSMIT CHAIN" + stream_args = uhd.stream_args('fc32', channels=range(tx_nchan)) + self.u_tx = uhd.usrp_sink(device_addr=args, stream_args=stream_args) + self.u_tx.set_samp_rate(MAX_RATE) + + self.tx_src0 = gr.sig_source_c(self.u_tx.get_samp_rate(), + gr.GR_CONST_WAVE, + 0, 1.0, 0) + + # Get dboard gain range and select maximum + tx_gain_range = self.u_tx.get_gain_range() + tx_gain = tx_gain_range.stop() + + # Get dboard freq range and select midpoint + tx_freq_range = self.u_tx.get_freq_range() + tx_freq_mid = (tx_freq_range.start() + tx_freq_range.stop())/2.0 + + for i in xrange(tx_nchan): + self.u_tx.set_center_freq (tx_freq_mid + i*1e6, i) + self.u_tx.set_gain(tx_gain, i) + + print "\nTx Sample Rate: %ssps" % (n2s(self.u_tx.get_samp_rate())) + for i in xrange(tx_nchan): + print "Tx Channel %d: " % (i) + print "\tFrequency = %sHz" % \ + (n2s(self.u_tx.get_center_freq(i))) + print "\tGain = %f dB" % (self.u_tx.get_gain(i)) + print "" + + self.connect (self.tx_src0, self.u_tx) + + if rx_enable: + print "\nRECEIVE CHAIN" + self.u_rx = uhd.usrp_source(device_addr=args, + io_type=uhd.io_type.COMPLEX_FLOAT32, + num_channels=rx_nchan) + self.rx_dst0 = gr.null_sink (gr.sizeof_gr_complex) + + self.u_rx.set_samp_rate(MAX_RATE) + + # Get dboard gain range and select maximum + rx_gain_range = self.u_rx.get_gain_range() + rx_gain = rx_gain_range.stop() + + # Get dboard freq range and select midpoint + rx_freq_range = self.u_rx.get_freq_range() + rx_freq_mid = (rx_freq_range.start() + rx_freq_range.stop())/2.0 + + for i in xrange(tx_nchan): + self.u_rx.set_center_freq (rx_freq_mid + i*1e6, i) + self.u_rx.set_gain(rx_gain, i) + + print "\nRx Sample Rate: %ssps" % (n2s(self.u_rx.get_samp_rate())) + for i in xrange(rx_nchan): + print "Rx Channel %d: " % (i) + print "\tFrequency = %sHz" % \ + (n2s(self.u_rx.get_center_freq(i))) + print "\tGain = %f dB" % (self.u_rx.get_gain(i)) + print "" + + self.connect (self.u_rx, self.rx_dst0) + +def main (): + parser = OptionParser (option_class=eng_option) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("-t", action="store_true", dest="tx_enable", + default=False, help="enable Tx path") + parser.add_option("-r", action="store_true", dest="rx_enable", + default=False, help="enable Rx path") + (options, args) = parser.parse_args () + + tb = build_block (options.args, options.tx_enable, options.rx_enable) + + tb.start () + raw_input ('Press Enter to quit: ') + tb.stop () + +if __name__ == '__main__': + main () diff --git a/gr-uhd/examples/python/usrp_am_mw_rcv.py b/gr-uhd/examples/python/usrp_am_mw_rcv.py new file mode 100755 index 000000000..85ffd7632 --- /dev/null +++ b/gr-uhd/examples/python/usrp_am_mw_rcv.py @@ -0,0 +1,315 @@ +#!/usr/bin/env python +# +# Copyright 2005-2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, eng_notation, optfir +from gnuradio import audio +from gnuradio import uhd +from gnuradio import blks2 +from gnuradio.eng_option import eng_option +from gnuradio.wxgui import slider, powermate +from gnuradio.wxgui import stdgui2, fftsink2, form +from optparse import OptionParser +import sys +import math +import wx + +class wfm_rx_block (stdgui2.std_top_block): + def __init__(self, frame, panel, vbox, argv): + stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) + + parser=OptionParser(option_class=eng_option) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, + help="set sample rate (bandwidth) [default=%default]") + parser.add_option("-f", "--freq", type="eng_float", default=1008.0e3, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-I", "--use-if-freq", action="store_true", default=False, + help="use intermediate freq (compensates DC problems in quadrature boards)" ) + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is maximum)") + parser.add_option("-V", "--volume", type="eng_float", default=None, + help="set volume (default is midpoint)") + parser.add_option("-O", "--audio-output", type="string", default="", + help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") + + (options, args) = parser.parse_args() + if len(args) != 0: + parser.print_help() + sys.exit(1) + + self.frame = frame + self.panel = panel + self.use_IF=options.use_if_freq + if self.use_IF: + self.IF_freq=64000.0 + else: + self.IF_freq=0.0 + + self.vol = 0 + self.state = "FREQ" + self.freq = 0 + + # build graph + self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + + usrp_rate = 256e3 + demod_rate = 64e3 + audio_rate = 32e3 + chanfilt_decim = int(usrp_rate // demod_rate) + audio_decim = int(demod_rate // audio_rate) + + self.u.set_samp_rate(usrp_rate) + dev_rate = self.u.get_samp_rate() + + # Resample signal to exactly self.usrp_rate + # FIXME: make one of the follow-on filters an arb resampler + rrate = usrp_rate / dev_rate + self.resamp = blks2.pfb_arb_resampler_ccf(rrate) + + chan_filt_coeffs = gr.firdes.low_pass_2 (1, # gain + usrp_rate, # sampling rate + 8e3, # passband cutoff + 4e3, # transition bw + 60) # stopband attenuation + + if self.use_IF: + # Turn If to baseband and filter. + self.chan_filt = gr.freq_xlating_fir_filter_ccf (chanfilt_decim, + chan_filt_coeffs, + self.IF_freq, + usrp_rate) + else: + self.chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) + + self.agc = gr.agc_cc(0.1, 1, 1, 100000) + self.am_demod = gr.complex_to_mag() + self.volume_control = gr.multiply_const_ff(self.vol) + + audio_filt_coeffs = gr.firdes.low_pass_2 (1, # gain + demod_rate, # sampling rate + 8e3, # passband cutoff + 2e3, # transition bw + 60) # stopband attenuation + self.audio_filt=gr.fir_filter_fff(audio_decim, audio_filt_coeffs) + + # sound card as final sink + self.audio_sink = audio.sink (int (audio_rate), + options.audio_output, + False) # ok_to_block + + # now wire it all together + self.connect (self.u, self.resamp, self.chan_filt, self.agc, + self.am_demod, self.audio_filt, + self.volume_control, self.audio_sink) + + self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) + + if options.gain is None: + g = self.u.get_gain_range() + if True: + # if no gain was specified, use the mid gain + options.gain = (g.start() + g.stop())/2.0 + options.gain = g.stop() + + if options.volume is None: + v = self.volume_range() + options.volume = float(v[0]*3+v[1])/4.0 + + if abs(options.freq) < 1e3: + options.freq *= 1e3 + + # set initial values + + self.set_gain(options.gain) + self.set_vol(options.volume) + if not(self.set_freq(options.freq)): + self._set_status_msg("Failed to set initial frequency") + + def _set_status_msg(self, msg, which=0): + self.frame.GetStatusBar().SetStatusText(msg, which) + + + def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): + + def _form_set_freq(kv): + return self.set_freq(kv['freq']) + + + if 0: + self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", + fft_size=512, sample_rate=usrp_rate, + ref_scale=32768.0, ref_level=0.0, y_divs=12) + self.connect (self.u, self.src_fft) + vbox.Add (self.src_fft.win, 4, wx.EXPAND) + + if 0: + self.post_filt_fft = fftsink2.fft_sink_c(self.panel, title="Post Channel filter", + fft_size=512, sample_rate=demod_rate) + self.connect (self.chan_filt, self.post_filt_fft) + vbox.Add (self.post_filt_fft.win, 4, wx.EXPAND) + + if 0: + post_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post Demod", + fft_size=1024, sample_rate=demod_rate, + y_per_div=10, ref_level=0) + self.connect (self.am_demod, post_demod_fft) + vbox.Add (post_demod_fft.win, 4, wx.EXPAND) + + if 1: + audio_fft = fftsink2.fft_sink_f(self.panel, title="Audio", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=20) + self.connect (self.audio_filt, audio_fft) + vbox.Add (audio_fft.win, 4, wx.EXPAND) + + + # control area form at bottom + self.myform = myform = form.form() + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + myform['freq'] = form.float_field( + parent=self.panel, sizer=hbox, label="Freq", weight=1, + callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) + + hbox.Add((5,0), 0) + myform['freq_slider'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, + range=(520.0e3, 1611.0e3, 1.0e3), + callback=self.set_freq) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + + myform['volume'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", + weight=3, range=self.volume_range(), + callback=self.set_vol) + hbox.Add((5,0), 1) + + g = self.u.get_gain_range() + myform['gain'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", + weight=3, range=(g.start(), g.stop(), g.step()), + callback=self.set_gain) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + try: + self.knob = powermate.powermate(self.frame) + self.rot = 0 + powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) + powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) + except: + print "FYI: No Powermate or Contour Knob found" + + + def on_rotate (self, event): + self.rot += event.delta + if (self.state == "FREQ"): + if self.rot >= 3: + self.set_freq(self.freq + .1e6) + self.rot -= 3 + elif self.rot <=-3: + self.set_freq(self.freq - .1e6) + self.rot += 3 + else: + step = self.volume_range()[2] + if self.rot >= 3: + self.set_vol(self.vol + step) + self.rot -= 3 + elif self.rot <=-3: + self.set_vol(self.vol - step) + self.rot += 3 + + def on_button (self, event): + if event.value == 0: # button up + return + self.rot = 0 + if self.state == "FREQ": + self.state = "VOL" + else: + self.state = "FREQ" + self.update_status_bar () + + + def set_vol (self, vol): + g = self.volume_range() + self.vol = max(g[0], min(g[1], vol)) + self.volume_control.set_k(10**(self.vol/10)) + self.myform['volume'].set_value(self.vol) + self.update_status_bar () + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + """ + r = self.u.set_center_freq(target_freq + self.IF_freq, 0) + + if r: + self.freq = target_freq + self.myform['freq'].set_value(target_freq) # update displayed value + self.myform['freq_slider'].set_value(target_freq) # update displayed value + self.update_status_bar() + self._set_status_msg("OK", 0) + return True + + self._set_status_msg("Failed", 0) + return False + + def set_gain(self, gain): + self.myform['gain'].set_value(gain) # update displayed value + self.u.set_gain(gain) + + def update_status_bar (self): + msg = "Volume:%r Setting:%s" % (self.vol, self.state) + self._set_status_msg(msg, 1) + try: + self.src_fft.set_baseband_freq(self.freq) + except: + None + + def volume_range(self): + return (-40.0, 0.0, 0.5) + + +if __name__ == '__main__': + app = stdgui2.stdapp (wfm_rx_block, "USRP Broadcast AM MW RX") + app.MainLoop () diff --git a/gr-uhd/examples/python/usrp_nbfm_ptt.py b/gr-uhd/examples/python/usrp_nbfm_ptt.py new file mode 100755 index 000000000..075604af3 --- /dev/null +++ b/gr-uhd/examples/python/usrp_nbfm_ptt.py @@ -0,0 +1,489 @@ +#!/usr/bin/env python +# +# Copyright 2005,2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +import math +import sys +import wx +from optparse import OptionParser + +from gnuradio import gr, audio, blks2, uhd +from gnuradio.eng_option import eng_option +from gnuradio.wxgui import stdgui2, fftsink2, scopesink2, slider, form + +from numpy import convolve, array + +#import os +#print "pid =", os.getpid() +#raw_input('Press Enter to continue: ') + +# //////////////////////////////////////////////////////////////////////// +# Control Stuff +# //////////////////////////////////////////////////////////////////////// + +class ptt_block(stdgui2.std_top_block): + def __init__(self, frame, panel, vbox, argv): + stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) + + self.frame = frame + self.space_bar_pressed = False + + parser = OptionParser (option_class=eng_option) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option ("-f", "--freq", type="eng_float", default=442.1e6, + help="set Tx and Rx frequency to FREQ", metavar="FREQ") + parser.add_option ("-g", "--rx-gain", type="eng_float", default=None, + help="set rx gain [default=midpoint in dB]") + parser.add_option ("", "--tx-gain", type="eng_float", default=None, + help="set tx gain [default=midpoint in dB]") + parser.add_option("-I", "--audio-input", type="string", default="", + help="pcm input device name. E.g., hw:0,0 or /dev/dsp") + parser.add_option("-O", "--audio-output", type="string", default="", + help="pcm output device name. E.g., hw:0,0 or /dev/dsp") + parser.add_option ("-N", "--no-gui", action="store_true", default=False) + (options, args) = parser.parse_args () + + if len(args) != 0: + parser.print_help() + sys.exit(1) + + if options.freq < 1e6: + options.freq *= 1e6 + + self.txpath = transmit_path(options.args, options.spec, + options.antenna, options.tx_gain, + options.audio_input) + self.rxpath = receive_path(options.args, options.spec, + options.antenna, options.rx_gain, + options.audio_output) + self.connect(self.txpath) + self.connect(self.rxpath) + + self._build_gui(frame, panel, vbox, argv, options.no_gui) + + self.set_transmit(False) + self.set_freq(options.freq) + self.set_rx_gain(self.rxpath.gain) # update gui + self.set_volume(self.rxpath.volume) # update gui + self.set_squelch(self.rxpath.threshold()) # update gui + + + def set_transmit(self, enabled): + self.txpath.set_enable(enabled) + self.rxpath.set_enable(not(enabled)) + if enabled: + self.frame.SetStatusText ("Transmitter ON", 1) + else: + self.frame.SetStatusText ("Receiver ON", 1) + + + def set_rx_gain(self, gain): + self.myform['rx_gain'].set_value(gain) # update displayed value + self.rxpath.set_gain(gain) + + def set_tx_gain(self, gain): + self.txpath.set_gain(gain) + + def set_squelch(self, threshold): + self.rxpath.set_squelch(threshold) + self.myform['squelch'].set_value(self.rxpath.threshold()) + + def set_volume (self, vol): + self.rxpath.set_volume(vol) + self.myform['volume'].set_value(self.rxpath.volume) + #self.update_status_bar () + + def set_freq(self, freq): + r1 = self.txpath.set_freq(freq) + r2 = self.rxpath.set_freq(freq) + #print "txpath.set_freq =", r1 + #print "rxpath.set_freq =", r2 + if r1 and r2: + self.myform['freq'].set_value(freq) # update displayed value + return r1 and r2 + + def _build_gui(self, frame, panel, vbox, argv, no_gui): + + def _form_set_freq(kv): + return self.set_freq(kv['freq']) + + self.panel = panel + + # FIXME This REALLY needs to be replaced with a hand-crafted button + # that sends both button down and button up events + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((10,0), 1) + self.status_msg = wx.StaticText(panel, -1, "Press Space Bar to Transmit") + of = self.status_msg.GetFont() + self.status_msg.SetFont(wx.Font(15, of.GetFamily(), of.GetStyle(), of.GetWeight())) + hbox.Add(self.status_msg, 0, wx.ALIGN_CENTER) + hbox.Add((10,0), 1) + vbox.Add(hbox, 0, wx.EXPAND | wx.ALIGN_CENTER) + + panel.Bind(wx.EVT_KEY_DOWN, self._on_key_down) + panel.Bind(wx.EVT_KEY_UP, self._on_key_up) + panel.Bind(wx.EVT_KILL_FOCUS, self._on_kill_focus) + panel.SetFocus() + + if 1 and not(no_gui): + rx_fft = fftsink2.fft_sink_c(panel, title="Rx Input", fft_size=512, + sample_rate=self.rxpath.if_rate, + ref_level=80, y_per_div=20) + self.connect (self.rxpath.u, rx_fft) + vbox.Add (rx_fft.win, 1, wx.EXPAND) + + if 1 and not(no_gui): + rx_fft = fftsink2.fft_sink_c(panel, title="Post s/w Resampler", + fft_size=512, sample_rate=self.rxpath.quad_rate, + ref_level=80, y_per_div=20) + self.connect (self.rxpath.resamp, rx_fft) + vbox.Add (rx_fft.win, 1, wx.EXPAND) + + if 0 and not(no_gui): + foo = scopesink2.scope_sink_f(panel, title="Squelch", + sample_rate=32000) + self.connect (self.rxpath.fmrx.div, (foo,0)) + self.connect (self.rxpath.fmrx.gate, (foo,1)) + self.connect (self.rxpath.fmrx.squelch_lpf, (foo,2)) + vbox.Add (foo.win, 1, wx.EXPAND) + + if 0 and not(no_gui): + tx_fft = fftsink2.fft_sink_c(panel, title="Tx Output", + fft_size=512, sample_rate=self.txpath.usrp_rate) + self.connect (self.txpath.amp, tx_fft) + vbox.Add (tx_fft.win, 1, wx.EXPAND) + + + # add control area at the bottom + + self.myform = myform = form.form() + + # first row + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0, 0) + myform['freq'] = form.float_field( + parent=panel, sizer=hbox, label="Freq", weight=1, + callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) + + hbox.Add((5,0), 0, 0) + vbox.Add(hbox, 0, wx.EXPAND) + + + # second row + hbox = wx.BoxSizer(wx.HORIZONTAL) + myform['volume'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", + weight=3, range=self.rxpath.volume_range(), + callback=self.set_volume) + hbox.Add((5,0), 0) + myform['squelch'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Squelch", + weight=3, range=self.rxpath.squelch_range(), + callback=self.set_squelch) + + g = self.rxpath.u.get_gain_range() + hbox.Add((5,0), 0) + myform['rx_gain'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Rx Gain", + weight=3, range=(g.start(), g.stop(), g.step()), + callback=self.set_rx_gain) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + + self._build_subpanel(vbox) + + def _build_subpanel(self, vbox_arg): + # build a secondary information panel (sometimes hidden) + + # FIXME figure out how to have this be a subpanel that is always + # created, but has its visibility controlled by foo.Show(True/False) + + #if not(self.show_debug_info): + # return + + panel = self.panel + vbox = vbox_arg + myform = self.myform + + #panel = wx.Panel(self.panel, -1) + #vbox = wx.BoxSizer(wx.VERTICAL) + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + #myform['decim'] = form.static_float_field( + # parent=panel, sizer=hbox, label="Decim") + + #hbox.Add((5,0), 1) + #myform['fs@usb'] = form.static_float_field( + # parent=panel, sizer=hbox, label="Fs@USB") + + #hbox.Add((5,0), 1) + #myform['dbname'] = form.static_text_field( + # parent=panel, sizer=hbox) + + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + + def _set_status_msg(self, msg, which=0): + self.frame.GetStatusBar().SetStatusText(msg, which) + + def _on_key_down(self, evt): + # print "key_down:", evt.m_keyCode + if evt.m_keyCode == wx.WXK_SPACE and not(self.space_bar_pressed): + self.space_bar_pressed = True + self.set_transmit(True) + + def _on_key_up(self, evt): + # print "key_up", evt.m_keyCode + if evt.m_keyCode == wx.WXK_SPACE: + self.space_bar_pressed = False + self.set_transmit(False) + + def _on_kill_focus(self, evt): + # if we lose the keyboard focus, turn off the transmitter + self.space_bar_pressed = False + self.set_transmit(False) + + +# //////////////////////////////////////////////////////////////////////// +# Transmit Path +# //////////////////////////////////////////////////////////////////////// + +class transmit_path(gr.hier_block2): + def __init__(self, args, spec, antenna, gain, audio_input): + gr.hier_block2.__init__(self, "transmit_path", + gr.io_signature(0, 0, 0), # Input signature + gr.io_signature(0, 0, 0)) # Output signature + + self.u = uhd.usrp_sink(device_addr=args, stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(spec): + self.u.set_subdev_spec(spec, 0) + + # Set the antenna + if(antenna): + self.u.set_antenna(antenna, 0) + + self.if_rate = 320e3 + self.audio_rate = 32e3 + + self.u.set_samp_rate(self.if_rate) + dev_rate = self.u.get_samp_rate() + + self.audio_gain = 10 + self.normal_gain = 32000 + + self.audio = audio.source(int(self.audio_rate), audio_input) + self.audio_amp = gr.multiply_const_ff(self.audio_gain) + + lpf = gr.firdes.low_pass (1, # gain + self.audio_rate, # sampling rate + 3800, # low pass cutoff freq + 300, # width of trans. band + gr.firdes.WIN_HANN) # filter type + + hpf = gr.firdes.high_pass (1, # gain + self.audio_rate, # sampling rate + 325, # low pass cutoff freq + 50, # width of trans. band + gr.firdes.WIN_HANN) # filter type + + audio_taps = convolve(array(lpf),array(hpf)) + self.audio_filt = gr.fir_filter_fff(1,audio_taps) + + self.pl = blks2.ctcss_gen_f(self.audio_rate,123.0) + self.add_pl = gr.add_ff() + self.connect(self.pl,(self.add_pl,1)) + + self.fmtx = blks2.nbfm_tx(self.audio_rate, self.if_rate) + self.amp = gr.multiply_const_cc (self.normal_gain) + + rrate = dev_rate / self.if_rate + self.resamp = blks2.pfb_arb_resampler_ccf(rrate) + + self.connect(self.audio, self.audio_amp, self.audio_filt, + (self.add_pl,0), self.fmtx, self.amp, + self.resamp, self.u) + + if gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + gain = float(g.start() + g.stop())/2.0 + + self.set_gain(gain) + + self.set_enable(False) + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + """ + r = self.u.set_center_freq(target_freq) + if r: + return True + return False + + def set_gain(self, gain): + self.gain = gain + self.u.set_gain(gain) + + def set_enable(self, enable): + if enable: + self.amp.set_k (self.normal_gain) + else: + self.amp.set_k (0) + + + +# //////////////////////////////////////////////////////////////////////// +# Receive Path +# //////////////////////////////////////////////////////////////////////// + +class receive_path(gr.hier_block2): + def __init__(self, args, gain, audio_output): + gr.hier_block2.__init__(self, "receive_path", + gr.io_signature(0, 0, 0), # Input signature + gr.io_signature(0, 0, 0)) # Output signature + + self.u = uhd.usrp_source(device_addr=args, + io_type=uhd.io_type.COMPLEX_FLOAT32, + num_channels=1) + + self.if_rate = 256e3 + self.quad_rate = 64e3 + self.audio_rate = 32e3 + + self.u.set_samp_rate(self.if_rate) + dev_rate = self.u.get_samp_rate() + + # Create filter to get actual channel we want + nfilts = 32 + chan_coeffs = gr.firdes.low_pass (nfilts, # gain + nfilts*dev_rate, # sampling rate + 13e3, # low pass cutoff freq + 4e3, # width of trans. band + gr.firdes.WIN_HANN) # filter type + + rrate = self.quad_rate / dev_rate + self.resamp = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) + + # instantiate the guts of the single channel receiver + self.fmrx = blks2.nbfm_rx(self.audio_rate, self.quad_rate) + + # standard squelch block + self.squelch = blks2.standard_squelch(self.audio_rate) + + # audio gain / mute block + self._audio_gain = gr.multiply_const_ff(1.0) + + # sound card as final sink + audio_sink = audio.sink (int(self.audio_rate), audio_output) + + # now wire it all together + self.connect (self.u, self.resamp, self.fmrx, self.squelch, + self._audio_gain, audio_sink) + + if gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + gain = float(g.start() + g.stop())/2.0 + + self.enabled = True + self.set_gain(gain) + v = self.volume_range() + self.set_volume((v[0]+v[1])/2) + s = self.squelch_range() + self.set_squelch((s[0]+s[1])/2) + + # Set the subdevice spec + if(spec): + self.u.set_subdev_spec(spec, 0) + + # Set the antenna + if(antenna): + self.u.set_antenna(antenna, 0) + + def volume_range(self): + return (-20.0, 0.0, 0.5) + + def set_volume (self, vol): + g = self.volume_range() + self.volume = max(g[0], min(g[1], vol)) + self._update_audio_gain() + + def set_enable(self, enable): + self.enabled = enable + self._update_audio_gain() + + def _update_audio_gain(self): + if self.enabled: + self._audio_gain.set_k(10**(self.volume/10)) + else: + self._audio_gain.set_k(0) + + def squelch_range(self): + return self.squelch.squelch_range() + + def set_squelch(self, threshold): + print "SQL =", threshold + self.squelch.set_threshold(threshold) + + def threshold(self): + return self.squelch.threshold() + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + """ + r = self.u.set_center_freq(target_freq) + if r: + return True + return False + + def set_gain(self, gain): + self.gain = gain + self.u.set_gain(gain) + + +# //////////////////////////////////////////////////////////////////////// +# Main +# //////////////////////////////////////////////////////////////////////// + +def main(): + app = stdgui2.stdapp(ptt_block, "NBFM Push to Talk") + app.MainLoop() + +if __name__ == '__main__': + main() diff --git a/gr-uhd/examples/python/usrp_nbfm_rcv.py b/gr-uhd/examples/python/usrp_nbfm_rcv.py new file mode 100755 index 000000000..6fdf95a30 --- /dev/null +++ b/gr-uhd/examples/python/usrp_nbfm_rcv.py @@ -0,0 +1,380 @@ +#!/usr/bin/env python +# +# Copyright 2005,2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, audio, blks2, uhd +from gnuradio.eng_option import eng_option +from gnuradio.wxgui import slider, powermate +from gnuradio.wxgui import stdgui2, fftsink2, form +from optparse import OptionParser +import sys +import math +import wx + +#//////////////////////////////////////////////////////////////////////// +# Control Stuff +#//////////////////////////////////////////////////////////////////////// + +class my_top_block (stdgui2.std_top_block): + def __init__(self,frame,panel,vbox,argv): + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) + + parser=OptionParser(option_class=eng_option) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-f", "--freq", type="eng_float", default=146.585e6, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is midpoint)") + parser.add_option("-V", "--volume", type="eng_float", default=None, + help="set volume (default is midpoint)") + parser.add_option("-O", "--audio-output", type="string", default="", + help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") + parser.add_option("-N", "--no-gui", action="store_true", default=False) + + (options, args) = parser.parse_args() + if len(args) != 0: + parser.print_help() + sys.exit(1) + + if options.freq < 1e6: + options.freq *= 1e6 + + self.frame = frame + self.panel = panel + + self.state = "FREQ" + self.freq = 0 + self.freq_step = 25e3 + + self.rxpath = receive_path(options.args, options.spec, options.antenna, + options.gain, options.audio_output) + self.connect(self.rxpath) + + self._build_gui(vbox, options.no_gui) + + # set initial values + + if options.volume is not None: + self.set_volume(options.volume) + + if not(self.set_freq(options.freq)): + self._set_status_msg("Failed to set initial frequency") + + self.set_gain(self.rxpath.gain) # update gui + self.set_volume(self.rxpath.volume) # update gui + self.set_squelch(self.rxpath.threshold()) # update gui + + + def _set_status_msg(self, msg, which=0): + self.frame.GetStatusBar().SetStatusText(msg, which) + + + def _build_gui(self, vbox, no_gui): + + def _form_set_freq(kv): + return self.set_freq(kv['freq']) + + + self.src_fft = None + if 0 and not(no_gui): + self.src_fft = fftsink2.fft_sink_c(self.panel, + title="Data from USRP", + fft_size=512, + sample_rate=self.rxpath.if_rate, + ref_scale=32768.0, + ref_level=0, + y_per_div=10, + y_divs=12) + self.connect (self.rxpath.u, self.src_fft) + vbox.Add (self.src_fft.win, 4, wx.EXPAND) + if 1 and not(no_gui): + rx_fft = fftsink2.fft_sink_c(self.panel, + title="Post s/w Resampling", + fft_size=512, + sample_rate=self.rxpath.quad_rate, + ref_level=80, + y_per_div=20) + self.connect (self.rxpath.resamp, rx_fft) + vbox.Add (rx_fft.win, 4, wx.EXPAND) + + if 1 and not(no_gui): + post_deemph_fft = fftsink2.fft_sink_f(self.panel, + title="Post Deemph", + fft_size=512, + sample_rate=self.rxpath.audio_rate, + y_per_div=10, + ref_level=-40) + self.connect (self.rxpath.fmrx.deemph, post_deemph_fft) + vbox.Add (post_deemph_fft.win, 4, wx.EXPAND) + + if 0: + post_filt_fft = fftsink2.fft_sink_f(self.panel, + title="Post Filter", + fft_size=512, + sample_rate=audio_rate, + y_per_div=10, + ref_level=-40) + self.connect (self.guts.audio_filter, post_filt) + vbox.Add (fft_win4, 4, wx.EXPAND) + + # control area form at bottom + self.myform = myform = form.form() + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + myform['freq'] = form.float_field( + parent=self.panel, sizer=hbox, label="Freq", weight=1, + callback=myform.check_input_and_call(_form_set_freq, + self._set_status_msg)) + + #hbox.Add((5,0), 0) + #myform['freq_slider'] = \ + # form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, + # range=(87.9e6, 108.1e6, 0.1e6), + # callback=self.set_freq) + + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + + myform['volume'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", + weight=3, range=self.volume_range(), + callback=self.set_volume) + hbox.Add((5,0), 0) + myform['squelch'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Squelch", + weight=3, range=self.rxpath.squelch_range(), + callback=self.set_squelch) + g = self.rxpath.u.get_gain_range() + hbox.Add((5,0), 0) + myform['gain'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", + weight=3, range=(g.start(), g.stop(), g.step()), + callback=self.set_gain) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + try: + self.knob = powermate.powermate(self.frame) + self.rot = 0 + powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) + powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) + except: + print "FYI: No Powermate or Contour Knob found" + + + def on_rotate (self, event): + self.rot += event.delta + if (self.state == "FREQ"): + if self.rot >= 3: + self.set_freq(self.freq + self.freq_step) + self.rot -= 3 + elif self.rot <=-3: + self.set_freq(self.freq - self.freq_step) + self.rot += 3 + else: + step = self.volume_range()[2] + if self.rot >= 3: + self.set_volume(self.rxpath.volume + step) + self.rot -= 3 + elif self.rot <=-3: + self.set_volume(self.rxpath.volume - step) + self.rot += 3 + + def on_button (self, event): + if event.value == 0: # button up + return + self.rot = 0 + if self.state == "FREQ": + self.state = "VOL" + else: + self.state = "FREQ" + self.update_status_bar () + + + def set_squelch(self, threshold_in_db): + self.rxpath.set_squelch(threshold_in_db) + self.myform['squelch'].set_value(self.rxpath.threshold()) + + def set_volume (self, vol): + self.rxpath.set_volume(vol) + self.myform['volume'].set_value(self.rxpath.volume) + self.update_status_bar () + + def set_freq(self, target_freq): + r = self.rxpath.set_freq(target_freq) + if r: + self.freq = target_freq + self.myform['freq'].set_value(target_freq) # update displayed value + #self.myform['freq_slider'].set_value(target_freq) # update displayed value + self.update_status_bar() + self._set_status_msg("OK", 0) + return True + + self._set_status_msg("Failed", 0) + return False + + def set_gain(self, gain): + self.myform['gain'].set_value(gain) # update displayed value + self.rxpath.set_gain(gain) + + def update_status_bar (self): + msg = "Volume:%r Setting:%s" % (self.rxpath.volume, self.state) + self._set_status_msg(msg, 1) + if self.src_fft: + self.src_fft.set_baseband_freq(self.freq) + + def volume_range(self): + return (-20.0, 0.0, 0.5) + + +#//////////////////////////////////////////////////////////////////////// +# Receive Path +#//////////////////////////////////////////////////////////////////////// + +USE_SIMPLE_SQUELCH = False + +class receive_path(gr.hier_block2): + def __init__(self, args, spec, antenna, gain, audio_output): + gr.hier_block2.__init__(self, "receive_path", + gr.io_signature(0, 0, 0), # Input signature + gr.io_signature(0, 0, 0)) # Output signature + + self.u = uhd.usrp_source(device_addr=args, stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(spec): + self.u.set_subdev_spec(spec, 0) + + # Set the antenna + if(antenna): + self.u.set_antenna(antenna, 0) + + self.if_rate = 256e3 + self.quad_rate = 64e3 + self.audio_rate = 32e3 + + self.u.set_samp_rate(self.if_rate) + dev_rate = self.u.get_samp_rate() + + # Create filter to get actual channel we want + nfilts = 32 + chan_coeffs = gr.firdes.low_pass (nfilts, # gain + nfilts*dev_rate, # sampling rate + 8e3, # low pass cutoff freq + 2e3, # width of trans. band + gr.firdes.WIN_HANN) # filter type + rrate = self.quad_rate / dev_rate + self.resamp = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) + + if USE_SIMPLE_SQUELCH: + self.squelch = gr.simple_squelch_cc(20) + else: + self.squelch = blks2.standard_squelch(self.audio_rate) + + # instantiate the guts of the single channel receiver + self.fmrx = blks2.nbfm_rx(self.audio_rate, self.quad_rate) + + # audio gain / mute block + self._audio_gain = gr.multiply_const_ff(1.0) + + # sound card as final sink + audio_sink = audio.sink (int(self.audio_rate), audio_output) + + # now wire it all together + if USE_SIMPLE_SQUELCH: + self.connect (self.u, self.resamp, self.squelch, self.fmrx, + self._audio_gain, audio_sink) + else: + self.connect (self.u, self.resamp, self.fmrx, self.squelch, + self._audio_gain, audio_sink) + + if gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + gain = float(g.start()+g.stop())/2 + + self.set_gain(gain) + + v = self.volume_range() + self.set_volume((v[0]+v[1])/2) + + s = self.squelch_range() + self.set_squelch((s[0]+s[1])/2) + + def volume_range(self): + return (-20.0, 0.0, 0.5) + + def set_volume (self, vol): + g = self.volume_range() + self.volume = max(g[0], min(g[1], vol)) + self._update_audio_gain() + + def _update_audio_gain(self): + self._audio_gain.set_k(10**(self.volume/10)) + + def squelch_range(self): + r = self.squelch.squelch_range() + #print "squelch_range: ", r + return r + + def set_squelch(self, threshold): + #print "SQL =", threshold + self.squelch.set_threshold(threshold) + + def threshold(self): + t = self.squelch.threshold() + #print "t =", t + return t + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + """ + + r = self.u.set_center_freq(target_freq) + if r: + return True + return False + + def set_gain(self, gain): + self.gain = gain + self.u.set_gain(gain) + + +# //////////////////////////////////////////////////////////////////////// +# Main +# //////////////////////////////////////////////////////////////////////// + +if __name__ == '__main__': + app = stdgui2.stdapp (my_top_block, "USRP NBFM RX") + app.MainLoop () diff --git a/gr-uhd/examples/python/usrp_spectrum_sense.py b/gr-uhd/examples/python/usrp_spectrum_sense.py new file mode 100755 index 000000000..355a55a98 --- /dev/null +++ b/gr-uhd/examples/python/usrp_spectrum_sense.py @@ -0,0 +1,258 @@ +#!/usr/bin/env python +# +# Copyright 2005,2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, eng_notation, window +from gnuradio import audio +from gnuradio import uhd +from gnuradio.eng_option import eng_option +from optparse import OptionParser +import sys +import math +import struct +import threading + +sys.stderr.write("Warning: this may have issues on some machines+Python version combinations to seg fault due to the callback in bin_statitics.\n\n") + +class ThreadClass(threading.Thread): + def run(self): + return + +class tune(gr.feval_dd): + """ + This class allows C++ code to callback into python. + """ + def __init__(self, tb): + gr.feval_dd.__init__(self) + self.tb = tb + + def eval(self, ignore): + """ + This method is called from gr.bin_statistics_f when it wants + to change the center frequency. This method tunes the front + end to the new center frequency, and returns the new frequency + as its result. + """ + + try: + # We use this try block so that if something goes wrong + # from here down, at least we'll have a prayer of knowing + # what went wrong. Without this, you get a very + # mysterious: + # + # terminate called after throwing an instance of + # 'Swig::DirectorMethodException' Aborted + # + # message on stderr. Not exactly helpful ;) + + new_freq = self.tb.set_next_freq() + return new_freq + + except Exception, e: + print "tune: Exception: ", e + + +class parse_msg(object): + def __init__(self, msg): + self.center_freq = msg.arg1() + self.vlen = int(msg.arg2()) + assert(msg.length() == self.vlen * gr.sizeof_float) + + # FIXME consider using NumPy array + t = msg.to_string() + self.raw_data = t + self.data = struct.unpack('%df' % (self.vlen,), t) + + +class my_top_block(gr.top_block): + + def __init__(self): + gr.top_block.__init__(self) + + usage = "usage: %prog [options] min_freq max_freq" + parser = OptionParser(option_class=eng_option, usage=usage) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, + help="set sample rate [default=%default]") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is midpoint)") + parser.add_option("", "--tune-delay", type="eng_float", + default=1e-3, metavar="SECS", + help="time to delay (in seconds) after changing frequency [default=%default]") + parser.add_option("", "--dwell-delay", type="eng_float", + default=10e-3, metavar="SECS", + help="time to dwell (in seconds) at a given frequncy [default=%default]") + parser.add_option("-F", "--fft-size", type="int", default=256, + help="specify number of FFT bins [default=%default]") + parser.add_option("", "--real-time", action="store_true", default=False, + help="Attempt to enable real-time scheduling") + + (options, args) = parser.parse_args() + if len(args) != 2: + parser.print_help() + sys.exit(1) + + self.min_freq = eng_notation.str_to_num(args[0]) + self.max_freq = eng_notation.str_to_num(args[1]) + + if self.min_freq > self.max_freq: + # swap them + self.min_freq, self.max_freq = self.max_freq, self.min_freq + + self.fft_size = options.fft_size + + if not options.real_time: + realtime = False + else: + # Attempt to enable realtime scheduling + r = gr.enable_realtime_scheduling() + if r == gr.RT_OK: + realtime = True + else: + realtime = False + print "Note: failed to enable realtime scheduling" + + # build graph + self.u = uhd.usrp_source(device_addr=options.args, + stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + + usrp_rate = options.samp_rate + self.u.set_samp_rate(usrp_rate) + dev_rate = self.u.get_samp_rate() + + s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) + + mywindow = window.blackmanharris(self.fft_size) + fft = gr.fft_vcc(self.fft_size, True, mywindow) + power = 0 + for tap in mywindow: + power += tap*tap + + c2mag = gr.complex_to_mag_squared(self.fft_size) + + # FIXME the log10 primitive is dog slow + log = gr.nlog10_ff(10, self.fft_size, + -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)) + + # Set the freq_step to 75% of the actual data throughput. + # This allows us to discard the bins on both ends of the spectrum. + + self.freq_step = 0.75 * usrp_rate + self.min_center_freq = self.min_freq + self.freq_step/2 + nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step) + self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step) + + self.next_freq = self.min_center_freq + + tune_delay = max(0, int(round(options.tune_delay * usrp_rate / self.fft_size))) # in fft_frames + dwell_delay = max(1, int(round(options.dwell_delay * usrp_rate / self.fft_size))) # in fft_frames + + self.msgq = gr.msg_queue(16) + self._tune_callback = tune(self) # hang on to this to keep it from being GC'd + stats = gr.bin_statistics_f(self.fft_size, self.msgq, + self._tune_callback, tune_delay, + dwell_delay) + + # FIXME leave out the log10 until we speed it up + #self.connect(self.u, s2v, fft, c2mag, log, stats) + self.connect(self.u, s2v, fft, c2mag, stats) + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2.0 + + self.set_gain(options.gain) + print "gain =", options.gain + + def set_next_freq(self): + target_freq = self.next_freq + self.next_freq = self.next_freq + self.freq_step + if self.next_freq >= self.max_center_freq: + self.next_freq = self.min_center_freq + + if not self.set_freq(target_freq): + print "Failed to set frequency to", target_freq + sys.exit(1) + + return target_freq + + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + """ + r = self.u.set_center_freq(target_freq) + if r: + return True + + return False + + def set_gain(self, gain): + self.u.set_gain(gain) + + +def main_loop(tb): + while 1: + + # Get the next message sent from the C++ code (blocking call). + # It contains the center frequency and the mag squared of the fft + m = parse_msg(tb.msgq.delete_head()) + + # Print center freq so we know that something is happening... + print m.center_freq + + # FIXME do something useful with the data... + + # m.data are the mag_squared of the fft output (they are in the + # standard order. I.e., bin 0 == DC.) + # You'll probably want to do the equivalent of "fftshift" on them + # m.raw_data is a string that contains the binary floats. + # You could write this as binary to a file. + + +if __name__ == '__main__': + t = ThreadClass() + t.start() + + tb = my_top_block() + try: + tb.start() + main_loop(tb) + + except KeyboardInterrupt: + pass diff --git a/gr-uhd/examples/python/usrp_tv_rcv.py b/gr-uhd/examples/python/usrp_tv_rcv.py new file mode 100755 index 000000000..700915bf8 --- /dev/null +++ b/gr-uhd/examples/python/usrp_tv_rcv.py @@ -0,0 +1,443 @@ +#!/usr/bin/env python +# +# Copyright 2005-2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +""" +Realtime capture and display of analog Tv stations. + +Can also use a file as source or sink + +When you use an output file you can show the results frame-by-frame +using ImageMagick + +When you want to use the realtime sdl display window you must first +install gr-video-sdl. + +When you use a file source, instead of the usrp, make sure you +capture interleaved shorts. (Use usrp_rx_file.py, or use +usrp_rx_cfile.py --output-shorts if you have a recent enough +usrp_rx_cfile.py) + +There is no synchronisation yet. The sync blocks are in development +but not yet in cvs. +""" + +from gnuradio import gr +try: + from gnuradio import video_sdl +except: + print "FYI: gr-video-sdl is not installed" + print "realtime SDL video output window will not be available" +from gnuradio import uhd +from gnuradio.eng_option import eng_option +from gnuradio.wxgui import slider, powermate +from gnuradio.wxgui import stdgui2, fftsink2, form +from optparse import OptionParser +import sys +import wx + + +class tv_rx_block (stdgui2.std_top_block): + def __init__(self,frame,panel,vbox,argv): + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) + + usage="%prog: [options] [input_filename]. \n If you don't specify an input filename the usrp will be used as source\n " \ + "Make sure your input capture file containes interleaved shorts not complex floats" + parser=OptionParser(option_class=eng_option, usage=usage) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, + help="set sample rate") + parser.add_option("-f", "--freq", type="eng_float", default=519.25e6, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is midpoint)") + parser.add_option("-c", "--contrast", type="eng_float", default=1.0, + help="set contrast (default is 1.0)") + parser.add_option("-b", "--brightness", type="eng_float", default=0.0, + help="set brightness (default is 0)") + parser.add_option("-p", "--pal", action="store_true", default=False, + help="PAL video format (this is the default)") + parser.add_option("-n", "--ntsc", action="store_true", default=False, + help="NTSC video format") + parser.add_option("-o", "--out-filename", type="string", default="sdl", + help="For example out_raw_uchar.gray. If you don't specify an output filename you will get a video_sink_sdl realtime output window. You then need to have gr-video-sdl installed)") + parser.add_option("-r", "--repeat", action="store_false", default=True, + help="repeat file in a loop") + parser.add_option("", "--freq-min", type="eng_float", default=50.25e6, + help="Set a minimum frequency [default=%default]") + parser.add_option("", "--freq-max", type="eng_float", default=900.25e6, + help="Set a maximum frequency [default=%default]") + + (options, args) = parser.parse_args() + if not ((len(args) == 1) or (len(args) == 0)): + parser.print_help() + sys.exit(1) + + if len(args) == 1: + filename = args[0] + else: + filename = None + + self.frame = frame + self.panel = panel + + self.contrast = options.contrast + self.brightness = options.brightness + self.state = "FREQ" + self.freq = 0 + + self.tv_freq_min = options.freq_min + self.tv_freq_max = options.freq_max + + # build graph + self.u=None + + if not (options.out_filename=="sdl"): + options.repeat=False + + usrp_rate = options.samp_rate + + if not ((filename is None) or (filename=="usrp")): + # file is data source + self.filesource = gr.file_source(gr.sizeof_short,filename,options.repeat) + self.istoc = gr.interleaved_short_to_complex() + self.connect(self.filesource,self.istoc) + self.src=self.istoc + + options.gain=0.0 + self.gain=0.0 + + else: # use a UHD device + self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + + self.u.set_samp_rate(usrp_rate) + dev_rate = self.u.get_samp_rate() + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2.0 + + self.src=self.u + + self.gain = options.gain + + f2uc=gr.float_to_uchar() + + # sdl window as final sink + if not (options.pal or options.ntsc): + options.pal=True #set default to PAL + + if options.pal: + lines_per_frame=625.0 + frames_per_sec=25.0 + show_width=768 + + elif options.ntsc: + lines_per_frame=525.0 + frames_per_sec=29.97002997 + show_width=640 + + width=int(usrp_rate/(lines_per_frame*frames_per_sec)) + height=int(lines_per_frame) + + if (options.out_filename=="sdl"): + #Here comes the tv screen, you have to build and install + #gr-video-sdl for this (subproject of gnuradio, only in cvs + #for now) + try: + video_sink = video_sdl.sink_uc ( frames_per_sec, width, height, 0, + show_width, height) + except: + print "gr-video-sdl is not installed" + print "realtime \"sdl\" video output window is not available" + raise SystemExit, 1 + self.dst=video_sink + else: + print "You can use the imagemagick display tool to show the resulting imagesequence" + print "use the following line to show the demodulated TV-signal:" + print "display -depth 8 -size " +str(width)+ "x" + str(height) \ + + " gray:" + options.out_filename + print "(Use the spacebar to advance to next frames)" + options.repeat=False + file_sink=gr.file_sink(gr.sizeof_char, options.out_filename) + self.dst =file_sink + + self.agc=gr.agc_cc(1e-7,1.0,1.0) #1e-7 + self.am_demod = gr.complex_to_mag () + self.set_blacklevel=gr.add_const_ff(0.0) + self.invert_and_scale = gr.multiply_const_ff (0.0) #-self.contrast *128.0*255.0/(200.0) + + # now wire it all together + #sample_rate=options.width*options.height*options.framerate + + process_type='do_no_sync' + if process_type=='do_no_sync': + self.connect (self.src, self.agc,self.am_demod, + self.invert_and_scale, self.set_blacklevel, + f2uc,self.dst) + elif process_type=='do_tv_sync_adv': + #defaults: gr.tv_sync_adv (double sampling_freq, unsigned + #int tv_format,bool output_active_video_only=false, bool + #do_invert=false, double wanted_black_level=0.0, double + #wanted_white_level=255.0, double avg_alpha=0.1, double + #initial_gain=1.0, double initial_offset=0.0,bool + #debug=false) + + #note, this block is not yet in cvs + self.tv_sync_adv=gr.tv_sync_adv(usrp_rate, 0, False, False, + 0.0, 255.0, 0.01, 1.0, 0.0, False) + self.connect (self.src, self.am_demod, self.invert_and_scale, + self.tv_sync_adv, s2f, f2uc, self.dst) + + elif process_type=='do_nullsink': + #self.connect (self.src, self.am_demod,self.invert_and_scale,f2uc,video_sink) + c2r=gr.complex_to_real() + nullsink=gr.null_sink(gr.sizeof_float) + self.connect (self.src, c2r,nullsink) #video_sink) + elif process_type=='do_tv_sync_corr': + frame_size=width*height #int(usrp_rate/25.0) + nframes=10# 32 + search_window=20*nframes + debug=False + video_alpha=0.3 #0.1 + corr_alpha=0.3 + + #Note: this block is not yet in cvs + tv_corr=gr.tv_correlator_ff(frame_size,nframes, search_window, + video_alpha, corr_alpha,debug) + shift=gr.add_const_ff(-0.7) + + self.connect (self.src, self.agc, self.am_demod, tv_corr, + self.invert_and_scale, self.set_blacklevel, + f2uc, self.dst) + else: # process_type=='do_test_image': + src_vertical_bars = gr.sig_source_f (usrp_rate, gr.GR_SIN_WAVE, + 10.0 *usrp_rate/320, 255,128) + self.connect(src_vertical_bars, f2uc, self.dst) + + self._build_gui(vbox, usrp_rate, usrp_rate, usrp_rate) + + + frange = self.u.get_freq_range() + if(frange.start() > self.tv_freq_max or frange.stop() < self.tv_freq_min): + sys.stderr.write("Radio does not support required frequency range.\n") + sys.exit(1) + if(options.freq < self.tv_freq_min or options.freq > self.tv_freq_max): + sys.stderr.write("Requested frequency is outside of required frequency range.\n") + sys.exit(1) + + # set initial values + self.set_gain(options.gain) + self.set_contrast(self.contrast) + self.set_brightness(options.brightness) + if not(self.set_freq(options.freq)): + self._set_status_msg("Failed to set initial frequency") + + + def _set_status_msg(self, msg, which=0): + self.frame.GetStatusBar().SetStatusText(msg, which) + + + def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): + + def _form_set_freq(kv): + return self.set_freq(kv['freq']) + + + if 0: + self.src_fft = fftsink.fft_sink_c (self, self.panel, title="Data from USRP", + fft_size=512, sample_rate=usrp_rate) + self.connect (self.src, self.src_fft) + vbox.Add (self.src_fft.win, 4, wx.EXPAND) + + if 0: + post_demod_fft = fftsink.fft_sink_f (self, self.panel, title="Post Demod", + fft_size=512, sample_rate=demod_rate, + y_per_div=10, ref_level=-40) + self.connect (self.am_demod, post_demod_fft) + vbox.Add (post_demod_fft.win, 4, wx.EXPAND) + + if 0: + post_filt_fft = fftsink.fft_sink_f (self, self.panel, title="Post Filter", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=-40) + self.connect (self.set_blacklevel, post_filt) + vbox.Add (fft_win4, 4, wx.EXPAND) + + + # control area form at bottom + self.myform = myform = form.form() + + if not (self.u is None): + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + myform['freq'] = form.float_field( + parent=self.panel, sizer=hbox, label="Freq", weight=1, + callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) + + hbox.Add((5,0), 0) + myform['freq_slider'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, + range=(self.tv_freq_min, self.tv_freq_max, 0.25e6), + callback=self.set_freq) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + + myform['contrast'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Contrast", + weight=3, range=(-2.0, 2.0, 0.1), + callback=self.set_contrast) + hbox.Add((5,0), 1) + + myform['brightness'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Brightness", + weight=3, range=(-255.0, 255.0, 1.0), + callback=self.set_brightness) + hbox.Add((5,0), 0) + + if not (self.u is None): + g = self.u.get_gain_range() + myform['gain'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", + weight=3, range=(g.start(), g.stop(), g.step()), + callback=self.set_gain) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + try: + self.knob = powermate.powermate(self.frame) + self.rot = 0 + powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) + powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) + except: + print "FYI: No Powermate or Contour Knob found" + + + def on_rotate (self, event): + self.rot += event.delta + if (self.state == "FREQ"): + if self.rot >= 3: + self.set_freq(self.freq + .1e6) + self.rot -= 3 + elif self.rot <=-3: + self.set_freq(self.freq - .1e6) + self.rot += 3 + elif (self.state == "CONTRAST"): + step = 0.1 + if self.rot >= 3: + self.set_contrast(self.contrast + step) + self.rot -= 3 + elif self.rot <=-3: + self.set_contrast(self.contrast - step) + self.rot += 3 + else: + step = 1 + if self.rot >= 3: + self.set_brightness(self.brightness + step) + self.rot -= 3 + elif self.rot <=-3: + self.set_brightness(self.brightness - step) + self.rot += 3 + + def on_button (self, event): + if event.value == 0: # button up + return + self.rot = 0 + if self.state == "FREQ": + self.state = "CONTRAST" + elif self.state == "CONTRAST": + self.state = "BRIGHTNESS" + else: + self.state = "FREQ" + self.update_status_bar () + + + def set_contrast (self, contrast): + self.contrast = contrast + self.invert_and_scale.set_k(-self.contrast *128.0*255.0/(200.0)) + self.myform['contrast'].set_value(self.contrast) + self.update_status_bar () + + def set_brightness (self, brightness): + self.brightness = brightness + self.set_blacklevel.set_k(self.brightness +255.0) + self.myform['brightness'].set_value(self.brightness) + self.update_status_bar () + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + + Tuning is a two step process. First we ask the front-end to + tune as close to the desired frequency as it can. Then we use + the result of that operation and our target_frequency to + determine the value for the digital down converter. + """ + if not (self.u is None): + r = self.u.set_center_freq(target_freq) + if r: + self.freq = target_freq + self.myform['freq'].set_value(target_freq) # update displayed value + self.myform['freq_slider'].set_value(target_freq) # update displayed value + self.update_status_bar() + self._set_status_msg("OK", 0) + return True + + self._set_status_msg("Failed", 0) + return False + + def set_gain(self, gain): + if not (self.u is None): + self.gain=gain + self.myform['gain'].set_value(gain) # update displayed value + self.u.set_gain(gain) + self.update_status_bar() + + def update_status_bar (self): + msg = "Setting:%s Contrast:%r Brightness:%r Gain: %r" % \ + (self.state, self.contrast,self.brightness,self.gain) + self._set_status_msg(msg, 1) + #self.src_fft.set_baseband_freq(self.freq) + + +if __name__ == '__main__': + app = stdgui2.stdapp (tv_rx_block, "USRP TV RX black-and-white") + app.MainLoop () diff --git a/gr-uhd/examples/python/usrp_tv_rcv_nogui.py b/gr-uhd/examples/python/usrp_tv_rcv_nogui.py new file mode 100755 index 000000000..870e65b27 --- /dev/null +++ b/gr-uhd/examples/python/usrp_tv_rcv_nogui.py @@ -0,0 +1,214 @@ +#!/usr/bin/env python +# +# Copyright 2005-2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +""" +Reads from a file and generates PAL TV pictures in black and white +which can be displayed using ImageMagick or realtime using +gr-video-sdl (To capture the input file Use usrp_rx_file.py, or use +usrp_rx_cfile.py --output-shorts if you have a recent enough +usrp_rx_cfile.py) + +Can also use usrp directly as capture source, but then you need a +higher decimation factor (64) and thus get a lower horizontal +resulution. There is no synchronisation yet. The sync blocks are in +development but not yet in cvs. + +""" + +from gnuradio import gr, eng_notation +from gnuradio import audio +from gnuradio import uhd +from gnuradio.eng_option import eng_option +from optparse import OptionParser +import sys + +try: + from gnuradio import video_sdl +except: + print "FYI: gr-video-sdl is not installed" + print "realtime \"sdl\" video output window will not be available" + + +class my_top_block(gr.top_block): + + def __init__(self): + gr.top_block.__init__(self) + + usage=("%prog: [options] output_filename.\nSpecial output_filename" + \ + "\"sdl\" will use video_sink_sdl as realtime output window. " + \ + "You then need to have gr-video-sdl installed.\n" +\ + "Make sure your input capture file containes interleaved " + \ + "shorts not complex floats") + parser = OptionParser(option_class=eng_option, usage=usage) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, + help="set sample rate") + parser.add_option("-c", "--contrast", type="eng_float", default=1.0, + help="set contrast (default is 1.0)") + parser.add_option("-b", "--brightness", type="eng_float", default=0.0, + help="set brightness (default is 0)") + parser.add_option("-i", "--in-filename", type="string", default=None, + help="Use input file as source. samples must be " + \ + "interleaved shorts \n Use usrp_rx_file.py or " + \ + "usrp_rx_cfile.py --output-shorts.\n Special " + \ + "name \"usrp\" results in realtime capturing " + \ + "and processing using usrp.\n" + \ + "You then probably need a decimation factor of 64 or higher.") + parser.add_option("-f", "--freq", type="eng_float", default=519.25e6, + help="set frequency to FREQ.\nNote that the frequency of the video carrier is not at the middle of the TV channel", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is midpoint)") + parser.add_option("-p", "--pal", action="store_true", default=False, + help="PAL video format (this is the default)") + parser.add_option("-n", "--ntsc", action="store_true", default=False, + help="NTSC video format") + parser.add_option("-r", "--repeat", action="store_false", default=True, + help="repeat in_file in a loop") + parser.add_option("-N", "--nframes", type="eng_float", default=None, + help="number of frames to collect [default=+inf]") + parser.add_option("", "--freq-min", type="eng_float", default=50.25e6, + help="Set a minimum frequency [default=%default]") + parser.add_option("", "--freq-max", type="eng_float", default=900.25e6, + help="Set a maximum frequency [default=%default]") + (options, args) = parser.parse_args () + if not (len(args) == 1): + parser.print_help() + sys.stderr.write('You must specify the output. FILENAME or sdl \n'); + sys.exit(1) + + filename = args[0] + + self.tv_freq_min = options.freq_min + self.tv_freq_max = options.freq_max + + if options.in_filename is None: + parser.print_help() + sys.stderr.write('You must specify the input -i FILENAME or -i usrp\n'); + raise SystemExit, 1 + + if not (filename=="sdl"): + options.repeat=False + + input_rate = options.samp_rate + print "video sample rate %s" % (eng_notation.num_to_str(input_rate)) + + if not (options.in_filename=="usrp"): + # file is data source, capture with usr_rx_csfile.py + self.filesource = gr.file_source(gr.sizeof_short, + options.in_filename, + options.repeat) + self.istoc = gr.interleaved_short_to_complex() + self.connect(self.filesource,self.istoc) + self.src=self.istoc + else: + if options.freq is None: + parser.print_help() + sys.stderr.write('You must specify the frequency with -f FREQ\n'); + raise SystemExit, 1 + + # build the graph + self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + + self.u.set_samp_rate(input_rate) + dev_rate = self.u.get_samp_rate() + + self.src=self.u + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2.0 + self.u.set_gain(options.gain) + + r = self.u.set_center_freq(options.freq) + if not r: + sys.stderr.write('Failed to set frequency\n') + raise SystemExit, 1 + + + self.agc = gr.agc_cc(1e-7,1.0,1.0) #1e-7 + self.am_demod = gr.complex_to_mag () + self.set_blacklevel = gr.add_const_ff(options.brightness +255.0) + self.invert_and_scale = gr.multiply_const_ff (-options.contrast *128.0*255.0/(200.0)) + self.f2uc = gr.float_to_uchar() + + # sdl window as final sink + if not (options.pal or options.ntsc): + options.pal=True #set default to PAL + if options.pal: + lines_per_frame=625.0 + frames_per_sec=25.0 + show_width=768 + elif options.ntsc: + lines_per_frame=525.0 + frames_per_sec=29.97002997 + show_width=640 + width=int(input_rate/(lines_per_frame*frames_per_sec)) + height=int(lines_per_frame) + + if filename=="sdl": + #Here comes the tv screen, you have to build and install + #gr-video-sdl for this (subproject of gnuradio, only in cvs + #for now) + try: + video_sink = video_sdl.sink_uc(frames_per_sec, width, height, 0, + show_width,height) + except: + print "gr-video-sdl is not installed" + print "realtime \"sdl\" video output window is not available" + raise SystemExit, 1 + self.dst=video_sink + else: + print "You can use the imagemagick display tool to show the resulting imagesequence" + print "use the following line to show the demodulated TV-signal:" + print "display -depth 8 -size " +str(width)+ "x" + str(height) + " gray:" +filename + print "(Use the spacebar to advance to next frames)" + file_sink=gr.file_sink(gr.sizeof_char, filename) + self.dst =file_sink + + if options.nframes is None: + self.connect(self.src, self.agc) + else: + self.head = gr.head(gr.sizeof_gr_complex, int(options.nframes*width*height)) + self.connect(self.src, self.head, self.agc) + + self.connect (self.agc, self.am_demod, self.invert_and_scale, + self.set_blacklevel, self.f2uc, self.dst) + +if __name__ == '__main__': + try: + my_top_block().run() + except KeyboardInterrupt: + pass diff --git a/gr-uhd/examples/python/usrp_wfm_rcv.py b/gr-uhd/examples/python/usrp_wfm_rcv.py new file mode 100755 index 000000000..f6c5cf853 --- /dev/null +++ b/gr-uhd/examples/python/usrp_wfm_rcv.py @@ -0,0 +1,286 @@ +#!/usr/bin/env python +# +# Copyright 2005-2007,2009,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, optfir, audio, blks2, uhd +from gnuradio.eng_option import eng_option +from gnuradio.wxgui import slider, powermate +from gnuradio.wxgui import stdgui2, fftsink2, form +from optparse import OptionParser +import sys +import wx + + +class wfm_rx_block (stdgui2.std_top_block): + def __init__(self,frame,panel,vbox,argv): + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) + + parser=OptionParser(option_class=eng_option) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=40, + help="set gain in dB (default is midpoint)") + parser.add_option("-V", "--volume", type="eng_float", default=None, + help="set volume (default is midpoint)") + parser.add_option("-O", "--audio-output", type="string", default="", + help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") + parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, + help="Set a minimum frequency [default=%default]") + parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, + help="Set a maximum frequency [default=%default]") + + (options, args) = parser.parse_args() + if len(args) != 0: + parser.print_help() + sys.exit(1) + + self.frame = frame + self.panel = panel + + self.vol = 0 + self.state = "FREQ" + self.freq = 0 + + self.fm_freq_min = options.freq_min + self.fm_freq_max = options.freq_max + + # build graph + self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + + usrp_rate = 320e3 + demod_rate = 320e3 + audio_rate = 32e3 + audio_decim = int(demod_rate / audio_rate) + + self.u.set_samp_rate(usrp_rate) + dev_rate = self.u.get_samp_rate() + + nfilts = 32 + chan_coeffs = optfir.low_pass (nfilts, # gain + nfilts*usrp_rate, # sampling rate + 80e3, # passband cutoff + 115e3, # stopband cutoff + 0.1, # passband ripple + 60) # stopband attenuation + rrate = usrp_rate / dev_rate + self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) + + self.guts = blks2.wfm_rcv (demod_rate, audio_decim) + + self.volume_control = gr.multiply_const_ff(self.vol) + + # sound card as final sink + self.audio_sink = audio.sink (int (audio_rate), + options.audio_output, + False) # ok_to_block + + # now wire it all together + self.connect (self.u, self.chan_filt, self.guts, + self.volume_control, self.audio_sink) + + self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2 + + if options.volume is None: + g = self.volume_range() + options.volume = float(g[0]+g[1])/2 + + frange = self.u.get_freq_range() + if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): + sys.stderr.write("Radio does not support required frequency range.\n") + sys.exit(1) + if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max): + sys.stderr.write("Requested frequency is outside of required frequency range.\n") + sys.exit(1) + + + # set initial values + + self.set_gain(options.gain) + self.set_vol(options.volume) + if not(self.set_freq(options.freq)): + self._set_status_msg("Failed to set initial frequency") + + def _set_status_msg(self, msg, which=0): + self.frame.GetStatusBar().SetStatusText(msg, which) + + + def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): + + def _form_set_freq(kv): + return self.set_freq(kv['freq']) + + + if 1: + self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", + fft_size=512, sample_rate=usrp_rate, + ref_scale=32768.0, ref_level=0, y_divs=12) + self.connect (self.u, self.src_fft) + vbox.Add (self.src_fft.win, 4, wx.EXPAND) + + if 1: + post_filt_fft = fftsink2.fft_sink_f(self.panel, title="Post Demod", + fft_size=1024, sample_rate=usrp_rate, + y_per_div=10, ref_level=0) + self.connect (self.guts.fm_demod, post_filt_fft) + vbox.Add (post_filt_fft.win, 4, wx.EXPAND) + + if 0: + post_deemph_fft = fftsink2.fft_sink_f(self.panel, title="Post Deemph", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=-20) + self.connect (self.guts.deemph, post_deemph_fft) + vbox.Add (post_deemph_fft.win, 4, wx.EXPAND) + + + # control area form at bottom + self.myform = myform = form.form() + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + myform['freq'] = form.float_field( + parent=self.panel, sizer=hbox, label="Freq", weight=1, + callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) + + hbox.Add((5,0), 0) + myform['freq_slider'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, + range=(self.fm_freq_min, self.fm_freq_max, 0.1e6), + callback=self.set_freq) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + + myform['volume'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", + weight=3, range=self.volume_range(), + callback=self.set_vol) + hbox.Add((5,0), 1) + + g = self.u.get_gain_range() + myform['gain'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", + weight=3, range=(g.start(), g.stop(), g.step()), + callback=self.set_gain) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + try: + self.knob = powermate.powermate(self.frame) + self.rot = 0 + powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) + powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) + except: + print "FYI: No Powermate or Contour Knob found" + + + def on_rotate (self, event): + self.rot += event.delta + if (self.state == "FREQ"): + if self.rot >= 3: + self.set_freq(self.freq + .1e6) + self.rot -= 3 + elif self.rot <=-3: + self.set_freq(self.freq - .1e6) + self.rot += 3 + else: + step = self.volume_range()[2] + if self.rot >= 3: + self.set_vol(self.vol + step) + self.rot -= 3 + elif self.rot <=-3: + self.set_vol(self.vol - step) + self.rot += 3 + + def on_button (self, event): + if event.value == 0: # button up + return + self.rot = 0 + if self.state == "FREQ": + self.state = "VOL" + else: + self.state = "FREQ" + self.update_status_bar () + + + def set_vol (self, vol): + g = self.volume_range() + self.vol = max(g[0], min(g[1], vol)) + self.volume_control.set_k(10**(self.vol/10)) + self.myform['volume'].set_value(self.vol) + self.update_status_bar () + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + """ + + r = self.u.set_center_freq(target_freq) + if r: + self.freq = target_freq + self.myform['freq'].set_value(target_freq) # update displayed value + self.myform['freq_slider'].set_value(target_freq) # update displayed value + self.update_status_bar() + self._set_status_msg("OK", 0) + return True + + self._set_status_msg("Failed", 0) + return False + + def set_gain(self, gain): + self.myform['gain'].set_value(gain) # update displayed value + self.u.set_gain(gain) + + def update_status_bar (self): + msg = "Volume:%r Setting:%s" % (self.vol, self.state) + self._set_status_msg(msg, 1) + self.src_fft.set_baseband_freq(self.freq) + + def volume_range(self): + return (-20.0, 0.0, 0.5) + + +if __name__ == '__main__': + app = stdgui2.stdapp (wfm_rx_block, "USRP WFM RX") + app.MainLoop () diff --git a/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py b/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py new file mode 100755 index 000000000..b70334f30 --- /dev/null +++ b/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py @@ -0,0 +1,154 @@ +#!/usr/bin/env python +# +# Copyright 2005-2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, optfir, audio, blks2, uhd +from gnuradio.eng_option import eng_option +from optparse import OptionParser +import sys +import math + +class wfm_rx_block (gr.top_block): + + def __init__(self): + gr.top_block.__init__(self) + + parser=OptionParser(option_class=eng_option) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default="A:0 A:0", + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("", "--f1", type="eng_float", default=100.7e6, + help="set 1st station frequency to FREQ", metavar="FREQ") + parser.add_option("", "--f2", type="eng_float", default=102.5e6, + help="set 2nd station freq to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=40, + help="set gain in dB (default is midpoint)") + parser.add_option("-O", "--audio-output", type="string", default="", + help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") + parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, + help="Set a minimum frequency [default=%default]") + parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, + help="Set a maximum frequency [default=%default]") + + (options, args) = parser.parse_args() + if len(args) != 0: + parser.print_help() + sys.exit(1) + + if abs(options.f1 - options.f2) > 5.5e6: + print "Sorry, two stations must be within 5.5MHz of each other" + raise SystemExit + + f = (options.f1, options.f2) + + self.vol = .1 + self.state = "FREQ" + + self.fm_freq_min = options.freq_min + self.fm_freq_max = options.freq_max + + # build graph + stream_args = uhd.stream_args('fc32', channels=range(2)) + self.u = uhd.usrp_source(device_addr=options.args, stream_args=stream_args) + + # Set front end channel mapping + self.u.set_subdev_spec(options.spec) + + usrp_rate = 320e3 + demod_rate = 320e3 + audio_rate = 32e3 + audio_decim = int(demod_rate / audio_rate) + + self.u.set_samp_rate(usrp_rate) + dev_rate = self.u.get_samp_rate() + + # Make sure dboard can suppor the required frequencies + frange = self.u.get_freq_range() + if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): + sys.stderr.write("Radio does not support required frequency range.\n") + sys.exit(1) + + # sound card as final sink + self.audio_sink = audio.sink(int(audio_rate), options.audio_output) + + # taps for channel filter + nfilts = 32 + chan_coeffs = optfir.low_pass (nfilts, # gain + nfilts*usrp_rate, # sampling rate + 80e3, # passband cutoff + 115e3, # stopband cutoff + 0.1, # passband ripple + 60) # stopband attenuation + rrate = usrp_rate / dev_rate + + # set front end PLL to middle frequency + mid_freq = (f[0] + f[1]) / 2.0 + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2.0 + + for n in range(2): + chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) + guts = blks2.wfm_rcv (demod_rate, audio_decim) + volume_control = gr.multiply_const_ff(self.vol) + + #self.connect((self.di, n), chan_filt) + self.connect((self.u, n), chan_filt) + self.connect(chan_filt, guts, volume_control) + self.connect(volume_control, (self.audio_sink, n)) + + # Test the the requested frequencies are in range + if(f[n] < self.fm_freq_min or f[n] > self.fm_freq_max): + sys.stderr.write("Requested frequency is outside of required frequency range.\n") + sys.exit(1) + + # Tune each channel by setting the RF freq to mid_freq and the + # DDC freq to f[n]. + tr = uhd.tune_request(f[n], rf_freq=mid_freq, + rf_freq_policy=uhd.tune_request.POLICY_MANUAL) + self.u.set_center_freq(tr, n) + + # Set gain for each channel + self.set_gain(options.gain, n) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, n) + + def set_vol (self, vol): + self.vol = vol + self.volume_control.set_k(self.vol) + + + def set_gain(self, gain, n): + self.u.set_gain(gain, n) + +if __name__ == '__main__': + tb = wfm_rx_block() + try: + tb.run() + except KeyboardInterrupt: + pass diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py b/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py new file mode 100755 index 000000000..9649857c0 --- /dev/null +++ b/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py @@ -0,0 +1,349 @@ +#!/usr/bin/env python +# +# Copyright 2005-2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, optfir, audio, blks2, uhd +from gnuradio.eng_option import eng_option +from gnuradio.wxgui import slider, powermate +from gnuradio.wxgui import stdgui2, fftsink2, form, scopesink2 +from optparse import OptionParser +import sys +import wx + +class wfm_rx_block (stdgui2.std_top_block): + def __init__(self,frame,panel,vbox,argv): + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) + + parser=OptionParser(option_class=eng_option) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=65, + help="set gain in dB (default is midpoint)") + parser.add_option("-s", "--squelch", type="eng_float", default=0, + help="set squelch level (default is 0)") + parser.add_option("-V", "--volume", type="eng_float", default=None, + help="set volume (default is midpoint)") + parser.add_option("-O", "--audio-output", type="string", default="", + help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") + parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, + help="Set a minimum frequency [default=%default]") + parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, + help="Set a maximum frequency [default=%default]") + + + (options, args) = parser.parse_args() + if len(args) != 0: + parser.print_help() + sys.exit(1) + + self.frame = frame + self.panel = panel + + self.vol = 0 + self.state = "FREQ" + self.freq = 0 + + self.fm_freq_min = options.freq_min + self.fm_freq_max = options.freq_max + + # build graph + self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + + usrp_rate = 320e3 + demod_rate = 320e3 + audio_rate = 48e3 + audio_decim = 10 + + self.u.set_samp_rate(usrp_rate) + dev_rate = self.u.get_samp_rate() + + nfilts = 32 + chan_coeffs = gr.firdes.low_pass_2(10*nfilts, # gain + nfilts*usrp_rate, # sampling rate + 90e3, # passband cutoff + 30e3, # transition bw + 70) # stopband attenuation + rrate = usrp_rate / dev_rate + self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) + + self.guts = blks2.wfm_rcv_fmdet (demod_rate, audio_decim) + + chan_rate = audio_rate / (demod_rate/audio_decim) + self.rchan_filt = blks2.pfb_arb_resampler_fff(chan_rate) + self.lchan_filt = blks2.pfb_arb_resampler_fff(chan_rate) + + # FIXME rework {add,multiply}_const_* to handle multiple streams + self.volume_control_l = gr.multiply_const_ff(self.vol) + self.volume_control_r = gr.multiply_const_ff(self.vol) + + # sound card as final sink + self.audio_sink = audio.sink (int (audio_rate), + options.audio_output, + False) # ok_to_block + + # now wire it all together + self.connect (self.u, self.chan_filt, self.guts) + self.connect((self.guts, 0), self.lchan_filt, + self.volume_control_l, (self.audio_sink,0)) + self.connect((self.guts, 1), self.rchan_filt, + self.volume_control_r, (self.audio_sink,1)) + + try: + self.guts.stereo_carrier_pll_recovery.squelch_enable(True) + except: + print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" + + + self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2.0 + + if options.volume is None: + g = self.volume_range() + options.volume = float(g[0]+g[1])/2 + + if abs(options.freq) < 1e6: + options.freq *= 1e6 + + frange = self.u.get_freq_range() + if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): + sys.stderr.write("Radio does not support required frequency range.\n") + sys.exit(1) + if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max): + sys.stderr.write("Requested frequency is outside of required frequency range.\n") + sys.exit(1) + + # set initial values + self.set_gain(options.gain) + self.set_vol(options.volume) + try: + self.guts.stereo_carrier_pll_recovery.set_lock_threshold(options.squelch) + except: + print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" + + if not(self.set_freq(options.freq)): + self._set_status_msg("Failed to set initial frequency") + + def _set_status_msg(self, msg, which=0): + self.frame.GetStatusBar().SetStatusText(msg, which) + + + def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): + + def _form_set_freq(kv): + return self.set_freq(kv['freq']) + + + if 1: + self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", + fft_size=512, sample_rate=usrp_rate, + ref_scale=32768.0, ref_level=0, y_divs=12) + self.connect (self.u, self.src_fft) + vbox.Add (self.src_fft.win, 4, wx.EXPAND) + + if 1: + post_fm_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post FM Demod", + fft_size=512, sample_rate=demod_rate, + y_per_div=10, ref_level=0) + self.connect (self.guts.fm_demod, post_fm_demod_fft) + vbox.Add (post_fm_demod_fft.win, 4, wx.EXPAND) + + if 0: + post_stereo_carrier_generator_fft = fftsink2.fft_sink_c (self.panel, title="Post Stereo_carrier_generator", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=0) + self.connect (self.guts.stereo_carrier_generator, post_stereo_carrier_generator_fft) + vbox.Add (post_stereo_carrier_generator_fft.win, 4, wx.EXPAND) + + if 0: + post_deemphasis_left = fftsink2.fft_sink_f (self.panel, title="Post_Deemphasis_Left", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=0) + self.connect (self.guts.deemph_Left, post_deemphasis_left) + vbox.Add (post_deemphasis_left.win, 4, wx.EXPAND) + + if 0: + post_deemphasis_right = fftsink2.fft_sink_f(self.panel, title="Post_Deemphasis_Right", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=-20) + self.connect (self.guts.deemph_Left, post_deemphasis_right) + vbox.Add (post_deemphasis_right.win, 4, wx.EXPAND) + + + if 0: + LmR_fft = fftsink2.fft_sink_f(self.panel, title="LmR", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=-20) + self.connect (self.guts.LmR_real,LmR_fft) + vbox.Add (LmR_fft.win, 4, wx.EXPAND) + + if 0: + self.scope = scopesink2.scope_sink_f(self.panel, sample_rate=demod_rate) + self.connect (self.guts.fm_demod,self.scope) + vbox.Add (self.scope.win,4,wx.EXPAND) + + # control area form at bottom + self.myform = myform = form.form() + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + myform['freq'] = form.float_field( + parent=self.panel, sizer=hbox, label="Freq", weight=1, + callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) + + hbox.Add((5,0), 0) + myform['freq_slider'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, + range=(self.fm_freq_min, self.fm_freq_max, 0.1e6), + callback=self.set_freq) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + + myform['volume'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", + weight=3, range=self.volume_range(), + callback=self.set_vol) + hbox.Add((5,0), 1) + + g = self.u.get_gain_range() + myform['gain'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", + weight=3, range=(g.start(), g.stop(), g.step()), + callback=self.set_gain) + hbox.Add((5,0), 0) + + myform['sqlch_thrsh'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Stereo Squelch Threshold", + weight=3, range=(0.0,1.0,0.01), + callback=self.set_squelch) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + try: + self.knob = powermate.powermate(self.frame) + self.rot = 0 + powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) + powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) + except: + print "FYI: No Powermate or Contour Knob found" + + + def on_rotate (self, event): + self.rot += event.delta + if (self.state == "FREQ"): + if self.rot >= 3: + self.set_freq(self.freq + .1e6) + self.rot -= 3 + elif self.rot <=-3: + self.set_freq(self.freq - .1e6) + self.rot += 3 + else: + step = self.volume_range()[2] + if self.rot >= 3: + self.set_vol(self.vol + step) + self.rot -= 3 + elif self.rot <=-3: + self.set_vol(self.vol - step) + self.rot += 3 + + def on_button (self, event): + if event.value == 0: # button up + return + self.rot = 0 + if self.state == "FREQ": + self.state = "VOL" + else: + self.state = "FREQ" + self.update_status_bar () + + + def set_vol (self, vol): + g = self.volume_range() + self.vol = max(g[0], min(g[1], vol)) + self.volume_control_l.set_k(10**(self.vol/10)) + self.volume_control_r.set_k(10**(self.vol/10)) + self.myform['volume'].set_value(self.vol) + self.update_status_bar () + + def set_squelch(self,squelch_threshold): + try: + self.guts.stereo_carrier_pll_recovery.set_lock_threshold(squelch_threshold); + except: + print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" + + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + """ + + r = self.u.set_center_freq(target_freq) + + if r: + self.freq = target_freq + self.myform['freq'].set_value(target_freq) # update displayed value + self.myform['freq_slider'].set_value(target_freq) # update displayed value + self.update_status_bar() + self._set_status_msg("OK", 0) + return True + + self._set_status_msg("Failed", 0) + return False + + def set_gain(self, gain): + self.myform['gain'].set_value(gain) # update displayed value + self.u.set_gain(gain) + + def update_status_bar (self): + msg = "Volume:%r Setting:%s" % (self.vol, self.state) + self._set_status_msg(msg, 1) + self.src_fft.set_baseband_freq(self.freq) + + def volume_range(self): + return (-20.0, 0.0, 0.5) + + +if __name__ == '__main__': + app = stdgui2.stdapp (wfm_rx_block, "USRP WFM RX") + app.MainLoop () diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py b/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py new file mode 100755 index 000000000..f0195bcb5 --- /dev/null +++ b/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py @@ -0,0 +1,175 @@ +#!/usr/bin/env python +# +# Copyright 2005-2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, optfir, audio, blks2, uhd +from gnuradio import eng_notation +from gnuradio.eng_option import eng_option +from optparse import OptionParser +import sys + +class wfm_rx_block (gr.top_block): + + def __init__(self): + gr.top_block.__init__(self) + + parser=OptionParser(option_class=eng_option) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is midpoint)") + parser.add_option("-V", "--volume", type="eng_float", default=None, + help="set volume (default is midpoint)") + parser.add_option("-O", "--audio-output", type="string", default="", + help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") + parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, + help="Set a minimum frequency [default=%default]") + parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, + help="Set a maximum frequency [default=%default]") + + (options, args) = parser.parse_args() + if len(args) != 0: + parser.print_help() + sys.exit(1) + + self.state = "FREQ" + self.freq = 0 + + self.fm_freq_min = options.freq_min + self.fm_freq_max = options.freq_max + + # build graph + self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + + usrp_rate = 320e3 + demod_rate = 320e3 + audio_rate = 32e3 + audio_decim = int(demod_rate / audio_rate) + + self.u.set_samp_rate(usrp_rate) + dev_rate = self.u.get_samp_rate() + + nfilts = 32 + chan_coeffs = optfir.low_pass (nfilts, # gain + nfilts*usrp_rate, # sampling rate + 80e3, # passband cutoff + 115e3, # stopband cutoff + 0.1, # passband ripple + 60) # stopband attenuation + rrate = usrp_rate / dev_rate + self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) + + self.guts = blks2.wfm_rcv (demod_rate, audio_decim) + + self.volume_control = gr.multiply_const_ff(1) + + # sound card as final sink + self.audio_sink = audio.sink(int(audio_rate), + options.audio_output, + False) # ok_to_block + + # now wire it all together + self.connect (self.u, self.chan_filt, self.guts, + self.volume_control, self.audio_sink) + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2.0 + + if options.volume is None: + g = self.volume_range() + options.volume = float(g[0]+g[1])/2 + + frange = self.u.get_freq_range() + if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): + sys.stderr.write("Radio does not support required frequency range.\n") + sys.exit(1) + if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max): + sys.stderr.write("Requested frequency is outside of required frequency range.\n") + sys.exit(1) + + # set initial values + self.set_gain(options.gain) + self.set_vol(options.volume) + if not(self.set_freq(options.freq)): + self._set_status_msg("Failed to set initial frequency") + + def set_vol (self, vol): + g = self.volume_range() + self.vol = max(g[0], min(g[1], vol)) + self.volume_control.set_k(10**(self.vol/10)) + self.update_status_bar () + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + """ + + r = self.u.set_center_freq(target_freq) + + if r: + self.freq = target_freq + self.update_status_bar() + self._set_status_msg("OK", 0) + return True + + self._set_status_msg("Failed", 0) + return False + + def set_gain(self, gain): + self.u.set_gain(gain) + + def update_status_bar (self): + msg = "Freq: %s Volume:%f Setting:%s" % ( + eng_notation.num_to_str(self.freq), self.vol, self.state) + self._set_status_msg(msg, 1) + + def _set_status_msg(self, msg, which=0): + print msg + + def volume_range(self): + return (-20.0, 0.0, 0.5) + + +if __name__ == '__main__': + tb = wfm_rx_block() + try: + tb.run() + except KeyboardInterrupt: + pass diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_pll.py b/gr-uhd/examples/python/usrp_wfm_rcv_pll.py new file mode 100755 index 000000000..b0744b00b --- /dev/null +++ b/gr-uhd/examples/python/usrp_wfm_rcv_pll.py @@ -0,0 +1,346 @@ +#!/usr/bin/env python +# +# Copyright 2005-2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, optfir, audio, blks2, uhd +from gnuradio import eng_notation +from gnuradio.eng_option import eng_option +from gnuradio.wxgui import slider, powermate +from gnuradio.wxgui import stdgui2, fftsink2, form, scopesink2 +from optparse import OptionParser +import sys +import wx + +class wfm_rx_block (stdgui2.std_top_block): + def __init__(self,frame,panel,vbox,argv): + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) + + parser=OptionParser(option_class=eng_option) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=65, + help="set gain in dB (default is midpoint)") + parser.add_option("-s", "--squelch", type="eng_float", default=0, + help="set squelch level (default is 0)") + parser.add_option("-V", "--volume", type="eng_float", default=None, + help="set volume (default is midpoint)") + parser.add_option("-O", "--audio-output", type="string", default="", + help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") + parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, + help="Set a minimum frequency [default=%default]") + parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, + help="Set a maximum frequency [default=%default]") + + (options, args) = parser.parse_args() + if len(args) != 0: + parser.print_help() + sys.exit(1) + + self.frame = frame + self.panel = panel + + self.vol = 0 + self.state = "FREQ" + self.freq = 0 + + self.fm_freq_min = options.freq_min + self.fm_freq_max = options.freq_max + + # build graph + self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + + usrp_rate = 320e3 + demod_rate = 320e3 + audio_rate = 48e3 + audio_decim = 10 + + self.u.set_samp_rate(usrp_rate) + dev_rate = self.u.get_samp_rate() + + nfilts = 32 + chan_coeffs = gr.firdes.low_pass_2 (nfilts, # gain + nfilts*usrp_rate, # sampling rate + 90e3, # passband cutoff + 30e3, # stopband cutoff + 70) # stopband attenuation + rrate = usrp_rate / dev_rate + self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) + + + self.guts = blks2.wfm_rcv_pll (demod_rate, audio_decim) + + chan_rate = audio_rate / (demod_rate/audio_decim) + self.rchan_filt = blks2.pfb_arb_resampler_fff(chan_rate) + self.lchan_filt = blks2.pfb_arb_resampler_fff(chan_rate) + + # FIXME rework {add,multiply}_const_* to handle multiple streams + self.volume_control_l = gr.multiply_const_ff(self.vol) + self.volume_control_r = gr.multiply_const_ff(self.vol) + + # sound card as final sink + self.audio_sink = audio.sink (int (audio_rate), + options.audio_output, + False) # ok_to_block + + # now wire it all together + self.connect (self.u, self.chan_filt, self.guts) + self.connect((self.guts, 0), self.lchan_filt, + self.volume_control_l, (self.audio_sink,0)) + self.connect((self.guts, 1), self.rchan_filt, + self.volume_control_r, (self.audio_sink,1)) + + try: + self.guts.stereo_carrier_pll_recovery.squelch_enable(True) + except: + print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" + + + self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2.0 + + if options.volume is None: + g = self.volume_range() + options.volume = float(g[0]+g[1])/2 + + frange = self.u.get_freq_range() + if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): + sys.stderr.write("Radio does not support required frequency range.\n") + sys.exit(1) + if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max): + sys.stderr.write("Requested frequency is outside of required frequency range.\n") + sys.exit(1) + + # set initial values + self.set_gain(options.gain) + self.set_vol(options.volume) + try: + self.guts.stereo_carrier_pll_recovery.set_lock_threshold(options.squelch) + except: + print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" + + if not(self.set_freq(options.freq)): + self._set_status_msg("Failed to set initial frequency") + + def _set_status_msg(self, msg, which=0): + self.frame.GetStatusBar().SetStatusText(msg, which) + + + def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): + + def _form_set_freq(kv): + return self.set_freq(kv['freq']) + + + if 1: + self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", + fft_size=512, sample_rate=usrp_rate, + ref_scale=32768.0, ref_level=0, y_divs=12) + self.connect (self.u, self.src_fft) + vbox.Add (self.src_fft.win, 4, wx.EXPAND) + + if 1: + post_fm_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post FM Demod", + fft_size=512, sample_rate=demod_rate, + y_per_div=10, ref_level=0) + self.connect (self.guts.fm_demod, post_fm_demod_fft) + vbox.Add (post_fm_demod_fft.win, 4, wx.EXPAND) + + if 0: + post_stereo_carrier_generator_fft = fftsink2.fft_sink_c (self.panel, title="Post Stereo_carrier_generator", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=0) + self.connect (self.guts.stereo_carrier_generator, post_stereo_carrier_generator_fft) + vbox.Add (post_stereo_carrier_generator_fft.win, 4, wx.EXPAND) + + if 0: + post_deemphasis_left = fftsink2.fft_sink_f (self.panel, title="Post_Deemphasis_Left", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=0) + self.connect (self.guts.deemph_Left, post_deemphasis_left) + vbox.Add (post_deemphasis_left.win, 4, wx.EXPAND) + + if 0: + post_deemphasis_right = fftsink2.fft_sink_f(self.panel, title="Post_Deemphasis_Right", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=-20) + self.connect (self.guts.deemph_Left, post_deemphasis_right) + vbox.Add (post_deemphasis_right.win, 4, wx.EXPAND) + + + if 0: + LmR_fft = fftsink2.fft_sink_f(self.panel, title="LmR", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=-20) + self.connect (self.guts.LmR_real,LmR_fft) + vbox.Add (LmR_fft.win, 4, wx.EXPAND) + + if 0: + self.scope = scopesink2.scope_sink_f(self.panel, sample_rate=demod_rate) + self.connect (self.guts.fm_demod,self.scope) + vbox.Add (self.scope.win,4,wx.EXPAND) + + # control area form at bottom + self.myform = myform = form.form() + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + myform['freq'] = form.float_field( + parent=self.panel, sizer=hbox, label="Freq", weight=1, + callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) + + hbox.Add((5,0), 0) + myform['freq_slider'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, + range=(self.fm_freq_min, self.fm_freq_max, 0.1e6), + callback=self.set_freq) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + + myform['volume'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", + weight=3, range=self.volume_range(), + callback=self.set_vol) + hbox.Add((5,0), 1) + + g = self.u.get_gain_range() + myform['gain'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", + weight=3, range=(g.start(), g.stop(), g.step()), + callback=self.set_gain) + hbox.Add((5,0), 0) + + myform['sqlch_thrsh'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Stereo Squelch Threshold", + weight=3, range=(0.0,1.0,0.01), + callback=self.set_squelch) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + try: + self.knob = powermate.powermate(self.frame) + self.rot = 0 + powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) + powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) + except: + print "FYI: No Powermate or Contour Knob found" + + + def on_rotate (self, event): + self.rot += event.delta + if (self.state == "FREQ"): + if self.rot >= 3: + self.set_freq(self.freq + .1e6) + self.rot -= 3 + elif self.rot <=-3: + self.set_freq(self.freq - .1e6) + self.rot += 3 + else: + step = self.volume_range()[2] + if self.rot >= 3: + self.set_vol(self.vol + step) + self.rot -= 3 + elif self.rot <=-3: + self.set_vol(self.vol - step) + self.rot += 3 + + def on_button (self, event): + if event.value == 0: # button up + return + self.rot = 0 + if self.state == "FREQ": + self.state = "VOL" + else: + self.state = "FREQ" + self.update_status_bar () + + + def set_vol (self, vol): + g = self.volume_range() + self.vol = max(g[0], min(g[1], vol)) + self.volume_control_l.set_k(10**(self.vol/10)) + self.volume_control_r.set_k(10**(self.vol/10)) + self.myform['volume'].set_value(self.vol) + self.update_status_bar () + + def set_squelch(self,squelch_threshold): + try: + self.guts.stereo_carrier_pll_recovery.set_lock_threshold(squelch_threshold); + except: + print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + """ + + r = self.u.set_center_freq(target_freq) + + if r: + self.freq = target_freq + self.myform['freq'].set_value(target_freq) # update displayed value + self.myform['freq_slider'].set_value(target_freq) # update displayed value + self.update_status_bar() + self._set_status_msg("OK", 0) + return True + + self._set_status_msg("Failed", 0) + return False + + def set_gain(self, gain): + self.myform['gain'].set_value(gain) # update displayed value + self.u.set_gain(gain) + + def update_status_bar (self): + msg = "Volume:%r Setting:%s" % (self.vol, self.state) + self._set_status_msg(msg, 1) + self.src_fft.set_baseband_freq(self.freq) + + def volume_range(self): + return (-20.0, 0.0, 0.5) + + +if __name__ == '__main__': + app = stdgui2.stdapp (wfm_rx_block, "USRP WFM RX") + app.MainLoop () diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_sca.py b/gr-uhd/examples/python/usrp_wfm_rcv_sca.py new file mode 100755 index 000000000..224f30cf8 --- /dev/null +++ b/gr-uhd/examples/python/usrp_wfm_rcv_sca.py @@ -0,0 +1,403 @@ +#!/usr/bin/env python +# +# Copyright 2006,2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +""" +Here is a bit of code that will receive SCA analog subcarriers of FM +Broadcast Stations using the USRP. It is a modified version of +usrp_wfm_rcv.py. + +Common SCA frequencies are 67 kHz and 92 kHz. SCA is used for Reading +Services for the Blind, Background Music, Foreign Language Services, and +other services. Remember you may hear static when tuned to a FM station +because this code only outputs SCA audio. + +The USRP gain is critical for good decoding. Adjust for minimum noise. + I use the Post FM Demod FFT to check for SCA subcarriers and to adjust +the USRP gain for the lowest noise floor. The stereo pilot at 19 KHz, +the stereo difference signal around 38 KHz, and RDS at 57 KHz are also +displayed on the Post FM Demod FFT if present. + +The range below 67 kHz is used for SCA only when Stereo is not used. + +The SCA recieve range is not as far as the main FM carrier receive range +so tune in strong local stations first. + +I tried to comment the code with the various parameters. There seems to +be several choices for a couple of them. I coded the common ones I see +here. + +In the local area there are a couple of stations using digital SCA. +These look similar to narrow DRM signals and I wonder if they are using +OFDM. +""" + + +from gnuradio import gr, optfir, audio, blks2, uhd +from gnuradio.eng_option import eng_option +from gnuradio.wxgui import slider, powermate +from gnuradio.wxgui import stdgui2, fftsink2, form +from optparse import OptionParser +import sys +import math +import wx + +class wfm_rx_sca_block (stdgui2.std_top_block): + def __init__(self,frame,panel,vbox,argv): + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) + + parser=OptionParser(option_class=eng_option) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=40, + help="set gain in dB (default is midpoint)") + parser.add_option("-V", "--volume", type="eng_float", default=None, + help="set volume (default is midpoint)") + parser.add_option("-O", "--audio-output", type="string", default="", + help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") + parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, + help="Set a minimum frequency [default=%default]") + parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, + help="Set a maximum frequency [default=%default]") + + (options, args) = parser.parse_args() + if len(args) != 0: + parser.print_help() + sys.exit(1) + + self.frame = frame + self.panel = panel + + self.vol = 0 + self.state = "FREQ" + self.freq = 0 + + self.fm_freq_min = options.freq_min + self.fm_freq_max = options.freq_max + + # build graph + + self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + + usrp_rate = 320e3 + demod_rate = 320e3 + audio_rate = 32e3 + sca_demod_rate = 64e3 + audio_decim = int(demod_rate / audio_rate) + sca_chanfilt_decim = int(demod_rate / sca_demod_rate) + + self.u.set_samp_rate(usrp_rate) + dev_rate = self.u.get_samp_rate() + + nfilts = 32 + chan_coeffs = optfir.low_pass (nfilts, # gain + nfilts*usrp_rate, # sampling rate + 100e3, # passband cutoff + 140e3, # stopband cutoff + 0.1, # passband ripple + 60) # stopband attenuation + rrate = usrp_rate / dev_rate + self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) + + #Create demodulator block for Main FM Channel + max_dev = 75e3 + fm_demod_gain = demod_rate/(2*math.pi*max_dev) + self.fm_demod = gr.quadrature_demod_cf (fm_demod_gain) + + # Note - deemphasis is not applied to the Main FM Channel as + # main audio is not decoded + + # SCA Devation is 10% of carrier but some references say 20% + # if mono with one SCA (6 KHz seems typical) + max_sca_dev = 6e3 + + # Create filter to get SCA channel we want + sca_chan_coeffs = gr.firdes.low_pass (1.0, # gain + demod_rate, # sampling rate + max_sca_dev, # cutoff freq + max_sca_dev/3, # trans. band + gr.firdes.WIN_HANN) # filter type + + self.ddc = gr.freq_xlating_fir_filter_fcf(sca_chanfilt_decim, # decim rate + sca_chan_coeffs, # taps + 0, # freq translation amount (Gets set by the UI) + demod_rate) # input sample rate + + #Create demodulator block for SCA Channel + sca_demod_gain = sca_demod_rate/(2*math.pi*max_sca_dev) + self.fm_demod_sca = gr.quadrature_demod_cf (sca_demod_gain) + + + # SCA analog audio is bandwidth limited to 5 KHz + max_sca_audio_freq = 5.0e3 + + # SCA analog deephasis is 150 uS (75 uS may be used) + sca_tau = 150e-6 + + # compute FIR filter taps for SCA audio filter + audio_coeffs = gr.firdes.low_pass (1.0, # gain + sca_demod_rate, # sampling rate + max_sca_audio_freq, # cutoff freq + max_sca_audio_freq/2.5, # trans. band + gr.firdes.WIN_HAMMING) + + # input: float; output: float + self.audio_filter = gr.fir_filter_fff (audio_decim, audio_coeffs) + + # Create deemphasis block that is applied after SCA demodulation + self.deemph = blks2.fm_deemph (audio_rate, sca_tau) + + self.volume_control = gr.multiply_const_ff(self.vol) + + # sound card as final sink + self.audio_sink = audio.sink (int (audio_rate), + options.audio_output, + False) # ok_to_block + + # now wire it all together + self.connect (self.u, self.chan_filt, self.fm_demod, + self.ddc, self.fm_demod_sca) + self.connect (self.fm_demod_sca, self.audio_filter, + self.deemph, self.volume_control, + self.audio_sink) + + self._build_gui(vbox, usrp_rate, demod_rate, sca_demod_rate, audio_rate) + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2 + + if options.volume is None: + g = self.volume_range() + options.volume = float(g[0]+g[1])/2 + + frange = self.u.get_freq_range() + if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): + sys.stderr.write("Radio does not support required frequency range.\n") + sys.exit(1) + if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max): + sys.stderr.write("Requested frequency is outside of required frequency range.\n") + sys.exit(1) + + # set initial values + + self.set_gain(options.gain) + self.set_vol(options.volume) + if not(self.set_freq(options.freq)): + self._set_status_msg("Failed to set initial frequency") + self.set_sca_freq(67000) # A common SCA Frequency + + def _set_status_msg(self, msg, which=0): + self.frame.GetStatusBar().SetStatusText(msg, which) + + + def _build_gui(self, vbox, usrp_rate, demod_rate, sca_demod_rate, audio_rate): + + def _form_set_freq(kv): + return self.set_freq(kv['freq']) + + def _form_set_sca_freq(kv): + return self.set_sca_freq(kv['sca_freq']) + + if 1: + self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", + fft_size=512, sample_rate=usrp_rate, + ref_scale=32768.0, ref_level=0, y_divs=12) + self.connect (self.u, self.src_fft) + vbox.Add (self.src_fft.win, 4, wx.EXPAND) + + if 1: + post_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post FM Demod", + fft_size=2048, sample_rate=demod_rate, + y_per_div=10, ref_level=0) + self.connect (self.fm_demod, post_demod_fft) + vbox.Add (post_demod_fft.win, 4, wx.EXPAND) + + if 0: + post_demod_sca_fft = fftsink2.fft_sink_f(self.panel, title="Post SCA Demod", + fft_size=1024, sample_rate=sca_demod_rate, + y_per_div=10, ref_level=0) + self.connect (self.fm_demod_sca, post_demod_sca_fft) + vbox.Add (post_demod_sca_fft.win, 4, wx.EXPAND) + + if 0: + post_deemph_fft = fftsink2.fft_sink_f (self.panel, title="Post SCA Deemph", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=-20) + self.connect (self.deemph, post_deemph_fft) + vbox.Add (post_deemph_fft.win, 4, wx.EXPAND) + + + # control area form at bottom + self.myform = myform = form.form() + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + myform['freq'] = form.float_field( + parent=self.panel, sizer=hbox, label="Freq", weight=1, + callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) + + hbox.Add((5,0), 0) + myform['freq_slider'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, + range=(self.fm_freq_min, self.fm_freq_max, 0.1e6), + callback=self.set_freq) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + myform['sca_freq'] = form.float_field( + parent=self.panel, sizer=hbox, label="SCA", weight=1, + callback=myform.check_input_and_call(_form_set_sca_freq, self._set_status_msg)) + + hbox.Add((5,0), 0) + myform['sca_freq_slider'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, + range=(38e3, 100e3, 1.0e3), + callback=self.set_sca_freq) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + + myform['volume'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", + weight=3, range=self.volume_range(), + callback=self.set_vol) + hbox.Add((5,0), 1) + + g = self.u.get_gain_range() + myform['gain'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", + weight=3, range=(g.start(), g.stop(), g.step()), + callback=self.set_gain) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + try: + self.knob = powermate.powermate(self.frame) + self.rot = 0 + powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) + powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) + except: + print "FYI: No Powermate or Contour Knob found" + + + def on_rotate (self, event): + self.rot += event.delta + if (self.state == "FREQ"): + if self.rot >= 3: + self.set_freq(self.freq + .1e6) + self.rot -= 3 + elif self.rot <=-3: + self.set_freq(self.freq - .1e6) + self.rot += 3 + else: + step = self.volume_range()[2] + if self.rot >= 3: + self.set_vol(self.vol + step) + self.rot -= 3 + elif self.rot <=-3: + self.set_vol(self.vol - step) + self.rot += 3 + + def on_button (self, event): + if event.value == 0: # button up + return + self.rot = 0 + if self.state == "FREQ": + self.state = "VOL" + else: + self.state = "FREQ" + self.update_status_bar () + + + def set_vol (self, vol): + g = self.volume_range() + self.vol = max(g[0], min(g[1], vol)) + self.volume_control.set_k(10**(self.vol/10)) + self.myform['volume'].set_value(self.vol) + self.update_status_bar () + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + + Tuning is a two step process. First we ask the front-end to + tune as close to the desired frequency as it can. Then we use + the result of that operation and our target_frequency to + determine the value for the digital down converter. + """ + r = self.u.set_center_freq(target_freq) + if r: + self.freq = target_freq + self.myform['freq'].set_value(target_freq) # update displayed value + self.myform['freq_slider'].set_value(target_freq) # update displayed value + self.update_status_bar() + self._set_status_msg("OK", 0) + return True + self._set_status_msg("Failed", 0) + return False + + def set_sca_freq(self, target_sca_freq): + + self.ddc.set_center_freq(-target_sca_freq) + self.myform['sca_freq'].set_value(target_sca_freq) # update displayed value + self.myform['sca_freq_slider'].set_value(target_sca_freq) # update displayed value + self.update_status_bar() + self._set_status_msg("OK", 0) + return True + + def set_gain(self, gain): + self.myform['gain'].set_value(gain) # update displayed value + self.u.set_gain(gain) + + def update_status_bar (self): + msg = "Volume:%r Setting:%s" % (self.vol, self.state) + self._set_status_msg(msg, 1) + self.src_fft.set_baseband_freq(self.freq) + + def volume_range(self): + return (-20.0, 0.0, 0.5) + + +if __name__ == '__main__': + app = stdgui2.stdapp (wfm_rx_sca_block, "USRP WFM SCA RX") + app.MainLoop () diff --git a/gr-uhd/examples/python/usrp_wxapt_rcv.py b/gr-uhd/examples/python/usrp_wxapt_rcv.py new file mode 100755 index 000000000..d9b1a0188 --- /dev/null +++ b/gr-uhd/examples/python/usrp_wxapt_rcv.py @@ -0,0 +1,282 @@ +#!/usr/bin/env python +# +# Copyright 2005-2007,2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, audio, blks2, uhd +from gnuradio.eng_option import eng_option +from gnuradio.wxgui import slider, powermate +from gnuradio.wxgui import stdgui2, fftsink2, form +from optparse import OptionParser +import sys +import wx + + +class wxapt_rx_block (stdgui2.std_top_block): + def __init__(self,frame,panel,vbox,argv): + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) + + parser=OptionParser(option_class=eng_option) + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args, [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("-f", "--freq", type="eng_float", default=137.5e6, + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is midpoint)") + parser.add_option("-V", "--volume", type="eng_float", default=None, + help="set volume (default is midpoint)") + parser.add_option("-O", "--audio-output", type="string", default="", + help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") + parser.add_option("", "--freq-min", type="eng_float", default=137e6, + help="Set a minimum frequency [default=%default]") + parser.add_option("", "--freq-max", type="eng_float", default=138e6, + help="Set a maximum frequency [default=%default]") + + (options, args) = parser.parse_args() + if len(args) != 0: + parser.print_help() + sys.exit(1) + + self.frame = frame + self.panel = panel + + self.vol = 0 + self.state = "FREQ" + self.freq = 0 + + self.freq_min = options.freq_min + self.freq_max = options.freq_max + + # build graph + self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) + + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna + if(options.antenna): + self.u.set_antenna(options.antenna, 0) + + usrp_rate = 320e3 + demod_rate = 320e3 + audio_rate = 32e3 + audio_decim = int(demod_rate / audio_rate) + + self.u.set_samp_rate(usrp_rate) + dev_rate = self.u.get_samp_rate() + + nfilts = 32 + chan_coeffs = gr.firdes.low_pass_2 (nfilts, # gain + nfilts*usrp_rate, # sampling rate + 40e3, # passband cutoff + 20e3, # transition bw + 60) # stopband attenuation + rrate = usrp_rate / dev_rate + self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) + + self.guts = blks2.wfm_rcv (demod_rate, audio_decim) + + self.volume_control = gr.multiply_const_ff(self.vol) + + # sound card as final sink + self.audio_sink = audio.sink (int (audio_rate), options.audio_output) + + # now wire it all together + self.connect (self.u, self.chan_filt, self.guts, + self.volume_control, self.audio_sink) + + self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) + + if options.gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + options.gain = float(g.start()+g.stop())/2.0 + + if options.volume is None: + g = self.volume_range() + options.volume = float(g[0]+g[1])/2 + + frange = self.u.get_freq_range() + if(frange.start() > self.freq_max or frange.stop() < self.freq_min): + sys.stderr.write("Radio does not support required frequency range.\n") + sys.exit(1) + if(options.freq < self.freq_min or options.freq > self.freq_max): + sys.stderr.write("Requested frequency is outside of required frequency range.\n") + sys.exit(1) + + # set initial values + self.set_gain(options.gain) + self.set_vol(options.volume) + if not(self.set_freq(options.freq)): + self._set_status_msg("Failed to set initial frequency") + + def _set_status_msg(self, msg, which=0): + self.frame.GetStatusBar().SetStatusText(msg, which) + + + def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): + + def _form_set_freq(kv): + return self.set_freq(kv['freq']) + + + if 1: + self.src_fft = fftsink2.fft_sink_c (self.panel, title="Data from USRP", + fft_size=512, sample_rate=usrp_rate, + ref_scale=32768.0, ref_level=0, y_divs=12) + self.connect (self.u, self.src_fft) + vbox.Add (self.src_fft.win, 4, wx.EXPAND) + + if 1: + post_deemph_fft = fftsink2.fft_sink_f (self.panel, title="Post Deemph", + fft_size=512, sample_rate=demod_rate, + y_per_div=10, ref_level=-20) + self.connect (self.guts.deemph, post_deemph_fft) + vbox.Add (post_deemph_fft.win, 4, wx.EXPAND) + + if 1: + post_filt_fft = fftsink2.fft_sink_f (self.panel, title="Post Filter", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=0) + self.connect (self.guts.audio_filter, post_filt_fft) + vbox.Add (post_filt_fft.win, 4, wx.EXPAND) + + + # control area form at bottom + self.myform = myform = form.form() + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + myform['freq'] = form.float_field( + parent=self.panel, sizer=hbox, label="Freq", weight=1, + callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) + + hbox.Add((5,0), 0) + myform['freq_slider'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, + range=(self.freq_min, self.freq_max, 0.0005e6), + callback=self.set_freq) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((5,0), 0) + + myform['volume'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", + weight=3, range=self.volume_range(), + callback=self.set_vol) + hbox.Add((5,0), 1) + + g = self.u.get_gain_range() + myform['gain'] = \ + form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", + weight=3, range=(g.start(), g.start(), g.step()), + callback=self.set_gain) + hbox.Add((5,0), 0) + vbox.Add(hbox, 0, wx.EXPAND) + + try: + self.knob = powermate.powermate(self.frame) + self.rot = 0 + powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) + powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) + except: + print "FYI: No Powermate or Contour Knob found" + + + def on_rotate (self, event): + self.rot += event.delta + if (self.state == "FREQ"): + if self.rot >= 3: + self.set_freq(self.freq + .1e6) + self.rot -= 3 + elif self.rot <=-3: + self.set_freq(self.freq - .1e6) + self.rot += 3 + else: + step = self.volume_range()[2] + if self.rot >= 3: + self.set_vol(self.vol + step) + self.rot -= 3 + elif self.rot <=-3: + self.set_vol(self.vol - step) + self.rot += 3 + + def on_button (self, event): + if event.value == 0: # button up + return + self.rot = 0 + if self.state == "FREQ": + self.state = "VOL" + else: + self.state = "FREQ" + self.update_status_bar () + + + def set_vol (self, vol): + g = self.volume_range() + self.vol = max(g[0], min(g[1], vol)) + self.volume_control.set_k(10**(self.vol/10)) + self.myform['volume'].set_value(self.vol) + self.update_status_bar () + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + + @param target_freq: frequency in Hz + @rypte: bool + """ + + r = self.u.set_center_freq(target_freq) + + if r: + self.freq = target_freq + self.myform['freq'].set_value(target_freq) # update displayed value + self.myform['freq_slider'].set_value(target_freq) # update displayed value + self.update_status_bar() + self._set_status_msg("OK", 0) + return True + + self._set_status_msg("Failed", 0) + return False + + def set_gain(self, gain): + self.myform['gain'].set_value(gain) # update displayed value + self.u.set_gain(gain) + + def update_status_bar (self): + msg = "Volume:%r Setting:%s" % (self.vol, self.state) + self._set_status_msg(msg, 1) + self.src_fft.set_baseband_freq(self.freq) + + def volume_range(self): + return (-20.0, 0.0, 0.5) + + +if __name__ == '__main__': + app = stdgui2.stdapp (wxapt_rx_block, "USRP WXAPT RX") + app.MainLoop () diff --git a/gr-uhd/examples/tag_sink_demo.h b/gr-uhd/examples/tag_sink_demo.h deleted file mode 100644 index 7d49bd971..000000000 --- a/gr-uhd/examples/tag_sink_demo.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include - -class tag_sink_demo : public gr_sync_block{ -public: - - tag_sink_demo(void): - gr_sync_block( - "uhd tag sink demo", - gr_make_io_signature(1, 1, sizeof(std::complex)), - gr_make_io_signature(0, 0, 0) - ) - { - //NOP - } - - int work( - int ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items - ){ - //grab all "rx time" tags in this work call - const uint64_t samp0_count = this->nitems_read(0); - std::vector rx_time_tags; - get_tags_in_range(rx_time_tags, 0, samp0_count, samp0_count + ninput_items, pmt::pmt_string_to_symbol("rx_time")); - - //print all tags - BOOST_FOREACH(const gr_tag_t &rx_time_tag, rx_time_tags){ - const uint64_t offset = rx_time_tag.offset; - const pmt::pmt_t &value = rx_time_tag.value; - - std::cout << boost::format("Full seconds %u, Frac seconds %f, abs sample offset %u") - % pmt::pmt_to_uint64(pmt_tuple_ref(value, 0)) - % pmt::pmt_to_double(pmt_tuple_ref(value, 1)) - % offset - << std::endl; - } - - return ninput_items; - } -}; diff --git a/gr-uhd/examples/tag_source_demo.h b/gr-uhd/examples/tag_source_demo.h deleted file mode 100644 index 9743c3407..000000000 --- a/gr-uhd/examples/tag_source_demo.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include - -class tag_source_demo : public gr_sync_block{ -public: - - tag_source_demo( - const uint64_t start_secs, - const double start_fracs, - const double samp_rate, - const double idle_duration, - const double burst_duration - ): - gr_sync_block( - "uhd tag source demo", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(1, 1, sizeof(std::complex)) - ), - _time_secs(start_secs), - _time_fracs(start_fracs), - _samp_rate(samp_rate), - _samps_per_burst(samp_rate*burst_duration), - _cycle_duration(idle_duration + burst_duration), - _samps_left_in_burst(1), //immediate EOB - _do_new_burst(false) - { - //NOP - } - - void make_time_tag(const uint64_t tag_count){; - const pmt::pmt_t key = pmt::pmt_string_to_symbol("tx_time"); - const pmt::pmt_t value = pmt::pmt_make_tuple( - pmt::pmt_from_uint64(_time_secs), - pmt::pmt_from_double(_time_fracs) - ); - const pmt::pmt_t srcid = pmt::pmt_string_to_symbol(this->name()); - this->add_item_tag(0/*chan0*/, tag_count, key, value, srcid); - } - - void make_sob_tag(const uint64_t tag_count){ - const pmt::pmt_t key = pmt::pmt_string_to_symbol("tx_sob"); - const pmt::pmt_t value = pmt::PMT_T; - const pmt::pmt_t srcid = pmt::pmt_string_to_symbol(this->name()); - this->add_item_tag(0/*chan0*/, tag_count, key, value, srcid); - } - - void make_eob_tag(const uint64_t tag_count){; - const pmt::pmt_t key = pmt::pmt_string_to_symbol("tx_eob"); - const pmt::pmt_t value = pmt::PMT_T; - const pmt::pmt_t srcid = pmt::pmt_string_to_symbol(this->name()); - this->add_item_tag(0/*chan0*/, tag_count, key, value, srcid); - } - - int work( - int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items - ){ - //load the output with a constant - std::complex *output = reinterpret_cast *>(output_items[0]); - for (size_t i = 0; i < size_t(noutput_items); i++){ - output[i] = std::complex(0.7, 0.7); - } - - //Handle the start of burst condition. - //Tag a start of burst and timestamp. - //Increment the time for the next burst. - if (_do_new_burst){ - _do_new_burst = false; - _samps_left_in_burst = _samps_per_burst; - - this->make_sob_tag(this->nitems_written(0)); - this->make_time_tag(this->nitems_written(0)); - - _time_fracs += _cycle_duration; - double intpart; //normalize - _time_fracs = std::modf(_time_fracs, &intpart); - _time_secs += uint64_t(intpart); - } - - //Handle the end of burst condition. - //Tag an end of burst and return early. - //the next work call will be a start of burst. - if (_samps_left_in_burst < size_t(noutput_items)){ - this->make_eob_tag(this->nitems_written(0) + _samps_left_in_burst - 1); - _do_new_burst = true; - noutput_items = _samps_left_in_burst; - } - - _samps_left_in_burst -= noutput_items; - return noutput_items; - } - -private: - uint64_t _time_secs; - double _time_fracs; - const double _samp_rate; - const uint64_t _samps_per_burst; - const double _cycle_duration; - uint64_t _samps_left_in_burst; - bool _do_new_burst; - -}; diff --git a/gr-uhd/examples/tags_demo.cc b/gr-uhd/examples/tags_demo.cc deleted file mode 100644 index f7442f098..000000000 --- a/gr-uhd/examples/tags_demo.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include -#include //sleep -#include -#include -#include - -namespace po = boost::program_options; - -/*********************************************************************** - * Signal handlers - **********************************************************************/ -static bool stop_signal_called = false; -void sig_int_handler(int){stop_signal_called = true;} - -/*********************************************************************** - * Main w/ program options - **********************************************************************/ -int main(int argc, char *argv[]){ - - std::string device_addr; - double center_freq, samp_rate, burst_dur, idle_dur; - - //setup the program options - po::options_description desc("Allowed options"); - desc.add_options() - ("help", "help message") - ("addr", po::value(&device_addr)->default_value(""), "the device address in string format") - ("rate", po::value(&samp_rate)->default_value(1e6), "the sample rate in samples per second") - ("freq", po::value(¢er_freq)->default_value(10e6), "the center frequency in Hz") - ("burst", po::value(&burst_dur)->default_value(0.1), "the duration of each burst in seconds") - ("idle", po::value(&idle_dur)->default_value(0.05), "idle time between bursts in seconds") - ; - po::variables_map vm; - po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); - - //print the help message - if (vm.count("help")){ - std::cout - << boost::format("UHD Tags Demo %s") % desc << std::endl - << "The tags sink demo block will print USRP source time stamps." << std::endl - << "The tags source demo block will send bursts to the USRP sink." << std::endl - << "Look at the USRP output on a scope to see the timed bursts." << std::endl - << std::endl; - return ~0; - } - - //------------------------------------------------------------------ - //-- make a top block - //------------------------------------------------------------------ - gr_top_block_sptr tb = gr_make_top_block("tags_demo"); - - //------------------------------------------------------------------ - //-- make the usrp source test blocks - //------------------------------------------------------------------ - boost::shared_ptr usrp_source = uhd_make_usrp_source( - device_addr, uhd::stream_args_t("fc32") - ); - usrp_source->set_samp_rate(samp_rate); - usrp_source->set_center_freq(center_freq); - - boost::shared_ptr tag_sink = boost::make_shared(); - - //------------------------------------------------------------------ - //-- connect the usrp source test blocks - //------------------------------------------------------------------ - tb->connect(usrp_source, 0, tag_sink, 0); - - //------------------------------------------------------------------ - //-- make the usrp sink test blocks - //------------------------------------------------------------------ - boost::shared_ptr usrp_sink = uhd_make_usrp_sink( - device_addr, uhd::stream_args_t("fc32") - ); - usrp_sink->set_samp_rate(samp_rate); - usrp_sink->set_center_freq(center_freq); - const uhd::time_spec_t time_now = usrp_sink->get_time_now(); - - boost::shared_ptr tag_source = boost::make_shared( - time_now.get_full_secs() + 1, time_now.get_frac_secs(), //time now + 1 second - samp_rate, idle_dur, burst_dur - ); - - //------------------------------------------------------------------ - //-- connect the usrp sink test blocks - //------------------------------------------------------------------ - tb->connect(tag_source, 0, usrp_sink, 0); - - //------------------------------------------------------------------ - //-- start flow graph execution - //------------------------------------------------------------------ - std::cout << "starting flow graph" << std::endl; - tb->start(); - - //------------------------------------------------------------------ - //-- poll the exit signal while running - //------------------------------------------------------------------ - std::signal(SIGINT, &sig_int_handler); - std::cout << "press ctrl + c to exit" << std::endl; - while (not stop_signal_called){ - boost::this_thread::sleep(boost::posix_time::milliseconds(100)); - } - - //------------------------------------------------------------------ - //-- stop flow graph execution - //------------------------------------------------------------------ - std::cout << "stopping flow graph" << std::endl; - tb->stop(); - tb->wait(); - - std::cout << "done!" << std::endl; - return 0; -} diff --git a/gr-uhd/examples/usrp_am_mw_rcv.py b/gr-uhd/examples/usrp_am_mw_rcv.py deleted file mode 100755 index 85ffd7632..000000000 --- a/gr-uhd/examples/usrp_am_mw_rcv.py +++ /dev/null @@ -1,315 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005-2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, eng_notation, optfir -from gnuradio import audio -from gnuradio import uhd -from gnuradio import blks2 -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui2, fftsink2, form -from optparse import OptionParser -import sys -import math -import wx - -class wfm_rx_block (stdgui2.std_top_block): - def __init__(self, frame, panel, vbox, argv): - stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) - - parser=OptionParser(option_class=eng_option) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, - help="set sample rate (bandwidth) [default=%default]") - parser.add_option("-f", "--freq", type="eng_float", default=1008.0e3, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-I", "--use-if-freq", action="store_true", default=False, - help="use intermediate freq (compensates DC problems in quadrature boards)" ) - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is maximum)") - parser.add_option("-V", "--volume", type="eng_float", default=None, - help="set volume (default is midpoint)") - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - self.frame = frame - self.panel = panel - self.use_IF=options.use_if_freq - if self.use_IF: - self.IF_freq=64000.0 - else: - self.IF_freq=0.0 - - self.vol = 0 - self.state = "FREQ" - self.freq = 0 - - # build graph - self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(options.spec): - self.u.set_subdev_spec(options.spec, 0) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, 0) - - usrp_rate = 256e3 - demod_rate = 64e3 - audio_rate = 32e3 - chanfilt_decim = int(usrp_rate // demod_rate) - audio_decim = int(demod_rate // audio_rate) - - self.u.set_samp_rate(usrp_rate) - dev_rate = self.u.get_samp_rate() - - # Resample signal to exactly self.usrp_rate - # FIXME: make one of the follow-on filters an arb resampler - rrate = usrp_rate / dev_rate - self.resamp = blks2.pfb_arb_resampler_ccf(rrate) - - chan_filt_coeffs = gr.firdes.low_pass_2 (1, # gain - usrp_rate, # sampling rate - 8e3, # passband cutoff - 4e3, # transition bw - 60) # stopband attenuation - - if self.use_IF: - # Turn If to baseband and filter. - self.chan_filt = gr.freq_xlating_fir_filter_ccf (chanfilt_decim, - chan_filt_coeffs, - self.IF_freq, - usrp_rate) - else: - self.chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) - - self.agc = gr.agc_cc(0.1, 1, 1, 100000) - self.am_demod = gr.complex_to_mag() - self.volume_control = gr.multiply_const_ff(self.vol) - - audio_filt_coeffs = gr.firdes.low_pass_2 (1, # gain - demod_rate, # sampling rate - 8e3, # passband cutoff - 2e3, # transition bw - 60) # stopband attenuation - self.audio_filt=gr.fir_filter_fff(audio_decim, audio_filt_coeffs) - - # sound card as final sink - self.audio_sink = audio.sink (int (audio_rate), - options.audio_output, - False) # ok_to_block - - # now wire it all together - self.connect (self.u, self.resamp, self.chan_filt, self.agc, - self.am_demod, self.audio_filt, - self.volume_control, self.audio_sink) - - self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) - - if options.gain is None: - g = self.u.get_gain_range() - if True: - # if no gain was specified, use the mid gain - options.gain = (g.start() + g.stop())/2.0 - options.gain = g.stop() - - if options.volume is None: - v = self.volume_range() - options.volume = float(v[0]*3+v[1])/4.0 - - if abs(options.freq) < 1e3: - options.freq *= 1e3 - - # set initial values - - self.set_gain(options.gain) - self.set_vol(options.volume) - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - - def _set_status_msg(self, msg, which=0): - self.frame.GetStatusBar().SetStatusText(msg, which) - - - def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - - if 0: - self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", - fft_size=512, sample_rate=usrp_rate, - ref_scale=32768.0, ref_level=0.0, y_divs=12) - self.connect (self.u, self.src_fft) - vbox.Add (self.src_fft.win, 4, wx.EXPAND) - - if 0: - self.post_filt_fft = fftsink2.fft_sink_c(self.panel, title="Post Channel filter", - fft_size=512, sample_rate=demod_rate) - self.connect (self.chan_filt, self.post_filt_fft) - vbox.Add (self.post_filt_fft.win, 4, wx.EXPAND) - - if 0: - post_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post Demod", - fft_size=1024, sample_rate=demod_rate, - y_per_div=10, ref_level=0) - self.connect (self.am_demod, post_demod_fft) - vbox.Add (post_demod_fft.win, 4, wx.EXPAND) - - if 1: - audio_fft = fftsink2.fft_sink_f(self.panel, title="Audio", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=20) - self.connect (self.audio_filt, audio_fft) - vbox.Add (audio_fft.win, 4, wx.EXPAND) - - - # control area form at bottom - self.myform = myform = form.form() - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - myform['freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="Freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) - - hbox.Add((5,0), 0) - myform['freq_slider'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, - range=(520.0e3, 1611.0e3, 1.0e3), - callback=self.set_freq) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - - myform['volume'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", - weight=3, range=self.volume_range(), - callback=self.set_vol) - hbox.Add((5,0), 1) - - g = self.u.get_gain_range() - myform['gain'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", - weight=3, range=(g.start(), g.stop(), g.step()), - callback=self.set_gain) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - try: - self.knob = powermate.powermate(self.frame) - self.rot = 0 - powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) - powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) - except: - print "FYI: No Powermate or Contour Knob found" - - - def on_rotate (self, event): - self.rot += event.delta - if (self.state == "FREQ"): - if self.rot >= 3: - self.set_freq(self.freq + .1e6) - self.rot -= 3 - elif self.rot <=-3: - self.set_freq(self.freq - .1e6) - self.rot += 3 - else: - step = self.volume_range()[2] - if self.rot >= 3: - self.set_vol(self.vol + step) - self.rot -= 3 - elif self.rot <=-3: - self.set_vol(self.vol - step) - self.rot += 3 - - def on_button (self, event): - if event.value == 0: # button up - return - self.rot = 0 - if self.state == "FREQ": - self.state = "VOL" - else: - self.state = "FREQ" - self.update_status_bar () - - - def set_vol (self, vol): - g = self.volume_range() - self.vol = max(g[0], min(g[1], vol)) - self.volume_control.set_k(10**(self.vol/10)) - self.myform['volume'].set_value(self.vol) - self.update_status_bar () - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - """ - r = self.u.set_center_freq(target_freq + self.IF_freq, 0) - - if r: - self.freq = target_freq - self.myform['freq'].set_value(target_freq) # update displayed value - self.myform['freq_slider'].set_value(target_freq) # update displayed value - self.update_status_bar() - self._set_status_msg("OK", 0) - return True - - self._set_status_msg("Failed", 0) - return False - - def set_gain(self, gain): - self.myform['gain'].set_value(gain) # update displayed value - self.u.set_gain(gain) - - def update_status_bar (self): - msg = "Volume:%r Setting:%s" % (self.vol, self.state) - self._set_status_msg(msg, 1) - try: - self.src_fft.set_baseband_freq(self.freq) - except: - None - - def volume_range(self): - return (-40.0, 0.0, 0.5) - - -if __name__ == '__main__': - app = stdgui2.stdapp (wfm_rx_block, "USRP Broadcast AM MW RX") - app.MainLoop () diff --git a/gr-uhd/examples/usrp_nbfm_ptt.py b/gr-uhd/examples/usrp_nbfm_ptt.py deleted file mode 100755 index 075604af3..000000000 --- a/gr-uhd/examples/usrp_nbfm_ptt.py +++ /dev/null @@ -1,489 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import math -import sys -import wx -from optparse import OptionParser - -from gnuradio import gr, audio, blks2, uhd -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import stdgui2, fftsink2, scopesink2, slider, form - -from numpy import convolve, array - -#import os -#print "pid =", os.getpid() -#raw_input('Press Enter to continue: ') - -# //////////////////////////////////////////////////////////////////////// -# Control Stuff -# //////////////////////////////////////////////////////////////////////// - -class ptt_block(stdgui2.std_top_block): - def __init__(self, frame, panel, vbox, argv): - stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) - - self.frame = frame - self.space_bar_pressed = False - - parser = OptionParser (option_class=eng_option) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option ("-f", "--freq", type="eng_float", default=442.1e6, - help="set Tx and Rx frequency to FREQ", metavar="FREQ") - parser.add_option ("-g", "--rx-gain", type="eng_float", default=None, - help="set rx gain [default=midpoint in dB]") - parser.add_option ("", "--tx-gain", type="eng_float", default=None, - help="set tx gain [default=midpoint in dB]") - parser.add_option("-I", "--audio-input", type="string", default="", - help="pcm input device name. E.g., hw:0,0 or /dev/dsp") - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm output device name. E.g., hw:0,0 or /dev/dsp") - parser.add_option ("-N", "--no-gui", action="store_true", default=False) - (options, args) = parser.parse_args () - - if len(args) != 0: - parser.print_help() - sys.exit(1) - - if options.freq < 1e6: - options.freq *= 1e6 - - self.txpath = transmit_path(options.args, options.spec, - options.antenna, options.tx_gain, - options.audio_input) - self.rxpath = receive_path(options.args, options.spec, - options.antenna, options.rx_gain, - options.audio_output) - self.connect(self.txpath) - self.connect(self.rxpath) - - self._build_gui(frame, panel, vbox, argv, options.no_gui) - - self.set_transmit(False) - self.set_freq(options.freq) - self.set_rx_gain(self.rxpath.gain) # update gui - self.set_volume(self.rxpath.volume) # update gui - self.set_squelch(self.rxpath.threshold()) # update gui - - - def set_transmit(self, enabled): - self.txpath.set_enable(enabled) - self.rxpath.set_enable(not(enabled)) - if enabled: - self.frame.SetStatusText ("Transmitter ON", 1) - else: - self.frame.SetStatusText ("Receiver ON", 1) - - - def set_rx_gain(self, gain): - self.myform['rx_gain'].set_value(gain) # update displayed value - self.rxpath.set_gain(gain) - - def set_tx_gain(self, gain): - self.txpath.set_gain(gain) - - def set_squelch(self, threshold): - self.rxpath.set_squelch(threshold) - self.myform['squelch'].set_value(self.rxpath.threshold()) - - def set_volume (self, vol): - self.rxpath.set_volume(vol) - self.myform['volume'].set_value(self.rxpath.volume) - #self.update_status_bar () - - def set_freq(self, freq): - r1 = self.txpath.set_freq(freq) - r2 = self.rxpath.set_freq(freq) - #print "txpath.set_freq =", r1 - #print "rxpath.set_freq =", r2 - if r1 and r2: - self.myform['freq'].set_value(freq) # update displayed value - return r1 and r2 - - def _build_gui(self, frame, panel, vbox, argv, no_gui): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - self.panel = panel - - # FIXME This REALLY needs to be replaced with a hand-crafted button - # that sends both button down and button up events - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((10,0), 1) - self.status_msg = wx.StaticText(panel, -1, "Press Space Bar to Transmit") - of = self.status_msg.GetFont() - self.status_msg.SetFont(wx.Font(15, of.GetFamily(), of.GetStyle(), of.GetWeight())) - hbox.Add(self.status_msg, 0, wx.ALIGN_CENTER) - hbox.Add((10,0), 1) - vbox.Add(hbox, 0, wx.EXPAND | wx.ALIGN_CENTER) - - panel.Bind(wx.EVT_KEY_DOWN, self._on_key_down) - panel.Bind(wx.EVT_KEY_UP, self._on_key_up) - panel.Bind(wx.EVT_KILL_FOCUS, self._on_kill_focus) - panel.SetFocus() - - if 1 and not(no_gui): - rx_fft = fftsink2.fft_sink_c(panel, title="Rx Input", fft_size=512, - sample_rate=self.rxpath.if_rate, - ref_level=80, y_per_div=20) - self.connect (self.rxpath.u, rx_fft) - vbox.Add (rx_fft.win, 1, wx.EXPAND) - - if 1 and not(no_gui): - rx_fft = fftsink2.fft_sink_c(panel, title="Post s/w Resampler", - fft_size=512, sample_rate=self.rxpath.quad_rate, - ref_level=80, y_per_div=20) - self.connect (self.rxpath.resamp, rx_fft) - vbox.Add (rx_fft.win, 1, wx.EXPAND) - - if 0 and not(no_gui): - foo = scopesink2.scope_sink_f(panel, title="Squelch", - sample_rate=32000) - self.connect (self.rxpath.fmrx.div, (foo,0)) - self.connect (self.rxpath.fmrx.gate, (foo,1)) - self.connect (self.rxpath.fmrx.squelch_lpf, (foo,2)) - vbox.Add (foo.win, 1, wx.EXPAND) - - if 0 and not(no_gui): - tx_fft = fftsink2.fft_sink_c(panel, title="Tx Output", - fft_size=512, sample_rate=self.txpath.usrp_rate) - self.connect (self.txpath.amp, tx_fft) - vbox.Add (tx_fft.win, 1, wx.EXPAND) - - - # add control area at the bottom - - self.myform = myform = form.form() - - # first row - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0, 0) - myform['freq'] = form.float_field( - parent=panel, sizer=hbox, label="Freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) - - hbox.Add((5,0), 0, 0) - vbox.Add(hbox, 0, wx.EXPAND) - - - # second row - hbox = wx.BoxSizer(wx.HORIZONTAL) - myform['volume'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", - weight=3, range=self.rxpath.volume_range(), - callback=self.set_volume) - hbox.Add((5,0), 0) - myform['squelch'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Squelch", - weight=3, range=self.rxpath.squelch_range(), - callback=self.set_squelch) - - g = self.rxpath.u.get_gain_range() - hbox.Add((5,0), 0) - myform['rx_gain'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Rx Gain", - weight=3, range=(g.start(), g.stop(), g.step()), - callback=self.set_rx_gain) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - - self._build_subpanel(vbox) - - def _build_subpanel(self, vbox_arg): - # build a secondary information panel (sometimes hidden) - - # FIXME figure out how to have this be a subpanel that is always - # created, but has its visibility controlled by foo.Show(True/False) - - #if not(self.show_debug_info): - # return - - panel = self.panel - vbox = vbox_arg - myform = self.myform - - #panel = wx.Panel(self.panel, -1) - #vbox = wx.BoxSizer(wx.VERTICAL) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - #myform['decim'] = form.static_float_field( - # parent=panel, sizer=hbox, label="Decim") - - #hbox.Add((5,0), 1) - #myform['fs@usb'] = form.static_float_field( - # parent=panel, sizer=hbox, label="Fs@USB") - - #hbox.Add((5,0), 1) - #myform['dbname'] = form.static_text_field( - # parent=panel, sizer=hbox) - - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - - def _set_status_msg(self, msg, which=0): - self.frame.GetStatusBar().SetStatusText(msg, which) - - def _on_key_down(self, evt): - # print "key_down:", evt.m_keyCode - if evt.m_keyCode == wx.WXK_SPACE and not(self.space_bar_pressed): - self.space_bar_pressed = True - self.set_transmit(True) - - def _on_key_up(self, evt): - # print "key_up", evt.m_keyCode - if evt.m_keyCode == wx.WXK_SPACE: - self.space_bar_pressed = False - self.set_transmit(False) - - def _on_kill_focus(self, evt): - # if we lose the keyboard focus, turn off the transmitter - self.space_bar_pressed = False - self.set_transmit(False) - - -# //////////////////////////////////////////////////////////////////////// -# Transmit Path -# //////////////////////////////////////////////////////////////////////// - -class transmit_path(gr.hier_block2): - def __init__(self, args, spec, antenna, gain, audio_input): - gr.hier_block2.__init__(self, "transmit_path", - gr.io_signature(0, 0, 0), # Input signature - gr.io_signature(0, 0, 0)) # Output signature - - self.u = uhd.usrp_sink(device_addr=args, stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(spec): - self.u.set_subdev_spec(spec, 0) - - # Set the antenna - if(antenna): - self.u.set_antenna(antenna, 0) - - self.if_rate = 320e3 - self.audio_rate = 32e3 - - self.u.set_samp_rate(self.if_rate) - dev_rate = self.u.get_samp_rate() - - self.audio_gain = 10 - self.normal_gain = 32000 - - self.audio = audio.source(int(self.audio_rate), audio_input) - self.audio_amp = gr.multiply_const_ff(self.audio_gain) - - lpf = gr.firdes.low_pass (1, # gain - self.audio_rate, # sampling rate - 3800, # low pass cutoff freq - 300, # width of trans. band - gr.firdes.WIN_HANN) # filter type - - hpf = gr.firdes.high_pass (1, # gain - self.audio_rate, # sampling rate - 325, # low pass cutoff freq - 50, # width of trans. band - gr.firdes.WIN_HANN) # filter type - - audio_taps = convolve(array(lpf),array(hpf)) - self.audio_filt = gr.fir_filter_fff(1,audio_taps) - - self.pl = blks2.ctcss_gen_f(self.audio_rate,123.0) - self.add_pl = gr.add_ff() - self.connect(self.pl,(self.add_pl,1)) - - self.fmtx = blks2.nbfm_tx(self.audio_rate, self.if_rate) - self.amp = gr.multiply_const_cc (self.normal_gain) - - rrate = dev_rate / self.if_rate - self.resamp = blks2.pfb_arb_resampler_ccf(rrate) - - self.connect(self.audio, self.audio_amp, self.audio_filt, - (self.add_pl,0), self.fmtx, self.amp, - self.resamp, self.u) - - if gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - gain = float(g.start() + g.stop())/2.0 - - self.set_gain(gain) - - self.set_enable(False) - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - """ - r = self.u.set_center_freq(target_freq) - if r: - return True - return False - - def set_gain(self, gain): - self.gain = gain - self.u.set_gain(gain) - - def set_enable(self, enable): - if enable: - self.amp.set_k (self.normal_gain) - else: - self.amp.set_k (0) - - - -# //////////////////////////////////////////////////////////////////////// -# Receive Path -# //////////////////////////////////////////////////////////////////////// - -class receive_path(gr.hier_block2): - def __init__(self, args, gain, audio_output): - gr.hier_block2.__init__(self, "receive_path", - gr.io_signature(0, 0, 0), # Input signature - gr.io_signature(0, 0, 0)) # Output signature - - self.u = uhd.usrp_source(device_addr=args, - io_type=uhd.io_type.COMPLEX_FLOAT32, - num_channels=1) - - self.if_rate = 256e3 - self.quad_rate = 64e3 - self.audio_rate = 32e3 - - self.u.set_samp_rate(self.if_rate) - dev_rate = self.u.get_samp_rate() - - # Create filter to get actual channel we want - nfilts = 32 - chan_coeffs = gr.firdes.low_pass (nfilts, # gain - nfilts*dev_rate, # sampling rate - 13e3, # low pass cutoff freq - 4e3, # width of trans. band - gr.firdes.WIN_HANN) # filter type - - rrate = self.quad_rate / dev_rate - self.resamp = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) - - # instantiate the guts of the single channel receiver - self.fmrx = blks2.nbfm_rx(self.audio_rate, self.quad_rate) - - # standard squelch block - self.squelch = blks2.standard_squelch(self.audio_rate) - - # audio gain / mute block - self._audio_gain = gr.multiply_const_ff(1.0) - - # sound card as final sink - audio_sink = audio.sink (int(self.audio_rate), audio_output) - - # now wire it all together - self.connect (self.u, self.resamp, self.fmrx, self.squelch, - self._audio_gain, audio_sink) - - if gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - gain = float(g.start() + g.stop())/2.0 - - self.enabled = True - self.set_gain(gain) - v = self.volume_range() - self.set_volume((v[0]+v[1])/2) - s = self.squelch_range() - self.set_squelch((s[0]+s[1])/2) - - # Set the subdevice spec - if(spec): - self.u.set_subdev_spec(spec, 0) - - # Set the antenna - if(antenna): - self.u.set_antenna(antenna, 0) - - def volume_range(self): - return (-20.0, 0.0, 0.5) - - def set_volume (self, vol): - g = self.volume_range() - self.volume = max(g[0], min(g[1], vol)) - self._update_audio_gain() - - def set_enable(self, enable): - self.enabled = enable - self._update_audio_gain() - - def _update_audio_gain(self): - if self.enabled: - self._audio_gain.set_k(10**(self.volume/10)) - else: - self._audio_gain.set_k(0) - - def squelch_range(self): - return self.squelch.squelch_range() - - def set_squelch(self, threshold): - print "SQL =", threshold - self.squelch.set_threshold(threshold) - - def threshold(self): - return self.squelch.threshold() - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - """ - r = self.u.set_center_freq(target_freq) - if r: - return True - return False - - def set_gain(self, gain): - self.gain = gain - self.u.set_gain(gain) - - -# //////////////////////////////////////////////////////////////////////// -# Main -# //////////////////////////////////////////////////////////////////////// - -def main(): - app = stdgui2.stdapp(ptt_block, "NBFM Push to Talk") - app.MainLoop() - -if __name__ == '__main__': - main() diff --git a/gr-uhd/examples/usrp_nbfm_rcv.py b/gr-uhd/examples/usrp_nbfm_rcv.py deleted file mode 100755 index 6fdf95a30..000000000 --- a/gr-uhd/examples/usrp_nbfm_rcv.py +++ /dev/null @@ -1,380 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, audio, blks2, uhd -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui2, fftsink2, form -from optparse import OptionParser -import sys -import math -import wx - -#//////////////////////////////////////////////////////////////////////// -# Control Stuff -#//////////////////////////////////////////////////////////////////////// - -class my_top_block (stdgui2.std_top_block): - def __init__(self,frame,panel,vbox,argv): - stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) - - parser=OptionParser(option_class=eng_option) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-f", "--freq", type="eng_float", default=146.585e6, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("-V", "--volume", type="eng_float", default=None, - help="set volume (default is midpoint)") - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") - parser.add_option("-N", "--no-gui", action="store_true", default=False) - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - if options.freq < 1e6: - options.freq *= 1e6 - - self.frame = frame - self.panel = panel - - self.state = "FREQ" - self.freq = 0 - self.freq_step = 25e3 - - self.rxpath = receive_path(options.args, options.spec, options.antenna, - options.gain, options.audio_output) - self.connect(self.rxpath) - - self._build_gui(vbox, options.no_gui) - - # set initial values - - if options.volume is not None: - self.set_volume(options.volume) - - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - - self.set_gain(self.rxpath.gain) # update gui - self.set_volume(self.rxpath.volume) # update gui - self.set_squelch(self.rxpath.threshold()) # update gui - - - def _set_status_msg(self, msg, which=0): - self.frame.GetStatusBar().SetStatusText(msg, which) - - - def _build_gui(self, vbox, no_gui): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - - self.src_fft = None - if 0 and not(no_gui): - self.src_fft = fftsink2.fft_sink_c(self.panel, - title="Data from USRP", - fft_size=512, - sample_rate=self.rxpath.if_rate, - ref_scale=32768.0, - ref_level=0, - y_per_div=10, - y_divs=12) - self.connect (self.rxpath.u, self.src_fft) - vbox.Add (self.src_fft.win, 4, wx.EXPAND) - if 1 and not(no_gui): - rx_fft = fftsink2.fft_sink_c(self.panel, - title="Post s/w Resampling", - fft_size=512, - sample_rate=self.rxpath.quad_rate, - ref_level=80, - y_per_div=20) - self.connect (self.rxpath.resamp, rx_fft) - vbox.Add (rx_fft.win, 4, wx.EXPAND) - - if 1 and not(no_gui): - post_deemph_fft = fftsink2.fft_sink_f(self.panel, - title="Post Deemph", - fft_size=512, - sample_rate=self.rxpath.audio_rate, - y_per_div=10, - ref_level=-40) - self.connect (self.rxpath.fmrx.deemph, post_deemph_fft) - vbox.Add (post_deemph_fft.win, 4, wx.EXPAND) - - if 0: - post_filt_fft = fftsink2.fft_sink_f(self.panel, - title="Post Filter", - fft_size=512, - sample_rate=audio_rate, - y_per_div=10, - ref_level=-40) - self.connect (self.guts.audio_filter, post_filt) - vbox.Add (fft_win4, 4, wx.EXPAND) - - # control area form at bottom - self.myform = myform = form.form() - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - myform['freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="Freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, - self._set_status_msg)) - - #hbox.Add((5,0), 0) - #myform['freq_slider'] = \ - # form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, - # range=(87.9e6, 108.1e6, 0.1e6), - # callback=self.set_freq) - - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - - myform['volume'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", - weight=3, range=self.volume_range(), - callback=self.set_volume) - hbox.Add((5,0), 0) - myform['squelch'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Squelch", - weight=3, range=self.rxpath.squelch_range(), - callback=self.set_squelch) - g = self.rxpath.u.get_gain_range() - hbox.Add((5,0), 0) - myform['gain'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", - weight=3, range=(g.start(), g.stop(), g.step()), - callback=self.set_gain) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - try: - self.knob = powermate.powermate(self.frame) - self.rot = 0 - powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) - powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) - except: - print "FYI: No Powermate or Contour Knob found" - - - def on_rotate (self, event): - self.rot += event.delta - if (self.state == "FREQ"): - if self.rot >= 3: - self.set_freq(self.freq + self.freq_step) - self.rot -= 3 - elif self.rot <=-3: - self.set_freq(self.freq - self.freq_step) - self.rot += 3 - else: - step = self.volume_range()[2] - if self.rot >= 3: - self.set_volume(self.rxpath.volume + step) - self.rot -= 3 - elif self.rot <=-3: - self.set_volume(self.rxpath.volume - step) - self.rot += 3 - - def on_button (self, event): - if event.value == 0: # button up - return - self.rot = 0 - if self.state == "FREQ": - self.state = "VOL" - else: - self.state = "FREQ" - self.update_status_bar () - - - def set_squelch(self, threshold_in_db): - self.rxpath.set_squelch(threshold_in_db) - self.myform['squelch'].set_value(self.rxpath.threshold()) - - def set_volume (self, vol): - self.rxpath.set_volume(vol) - self.myform['volume'].set_value(self.rxpath.volume) - self.update_status_bar () - - def set_freq(self, target_freq): - r = self.rxpath.set_freq(target_freq) - if r: - self.freq = target_freq - self.myform['freq'].set_value(target_freq) # update displayed value - #self.myform['freq_slider'].set_value(target_freq) # update displayed value - self.update_status_bar() - self._set_status_msg("OK", 0) - return True - - self._set_status_msg("Failed", 0) - return False - - def set_gain(self, gain): - self.myform['gain'].set_value(gain) # update displayed value - self.rxpath.set_gain(gain) - - def update_status_bar (self): - msg = "Volume:%r Setting:%s" % (self.rxpath.volume, self.state) - self._set_status_msg(msg, 1) - if self.src_fft: - self.src_fft.set_baseband_freq(self.freq) - - def volume_range(self): - return (-20.0, 0.0, 0.5) - - -#//////////////////////////////////////////////////////////////////////// -# Receive Path -#//////////////////////////////////////////////////////////////////////// - -USE_SIMPLE_SQUELCH = False - -class receive_path(gr.hier_block2): - def __init__(self, args, spec, antenna, gain, audio_output): - gr.hier_block2.__init__(self, "receive_path", - gr.io_signature(0, 0, 0), # Input signature - gr.io_signature(0, 0, 0)) # Output signature - - self.u = uhd.usrp_source(device_addr=args, stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(spec): - self.u.set_subdev_spec(spec, 0) - - # Set the antenna - if(antenna): - self.u.set_antenna(antenna, 0) - - self.if_rate = 256e3 - self.quad_rate = 64e3 - self.audio_rate = 32e3 - - self.u.set_samp_rate(self.if_rate) - dev_rate = self.u.get_samp_rate() - - # Create filter to get actual channel we want - nfilts = 32 - chan_coeffs = gr.firdes.low_pass (nfilts, # gain - nfilts*dev_rate, # sampling rate - 8e3, # low pass cutoff freq - 2e3, # width of trans. band - gr.firdes.WIN_HANN) # filter type - rrate = self.quad_rate / dev_rate - self.resamp = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) - - if USE_SIMPLE_SQUELCH: - self.squelch = gr.simple_squelch_cc(20) - else: - self.squelch = blks2.standard_squelch(self.audio_rate) - - # instantiate the guts of the single channel receiver - self.fmrx = blks2.nbfm_rx(self.audio_rate, self.quad_rate) - - # audio gain / mute block - self._audio_gain = gr.multiply_const_ff(1.0) - - # sound card as final sink - audio_sink = audio.sink (int(self.audio_rate), audio_output) - - # now wire it all together - if USE_SIMPLE_SQUELCH: - self.connect (self.u, self.resamp, self.squelch, self.fmrx, - self._audio_gain, audio_sink) - else: - self.connect (self.u, self.resamp, self.fmrx, self.squelch, - self._audio_gain, audio_sink) - - if gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - gain = float(g.start()+g.stop())/2 - - self.set_gain(gain) - - v = self.volume_range() - self.set_volume((v[0]+v[1])/2) - - s = self.squelch_range() - self.set_squelch((s[0]+s[1])/2) - - def volume_range(self): - return (-20.0, 0.0, 0.5) - - def set_volume (self, vol): - g = self.volume_range() - self.volume = max(g[0], min(g[1], vol)) - self._update_audio_gain() - - def _update_audio_gain(self): - self._audio_gain.set_k(10**(self.volume/10)) - - def squelch_range(self): - r = self.squelch.squelch_range() - #print "squelch_range: ", r - return r - - def set_squelch(self, threshold): - #print "SQL =", threshold - self.squelch.set_threshold(threshold) - - def threshold(self): - t = self.squelch.threshold() - #print "t =", t - return t - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - """ - - r = self.u.set_center_freq(target_freq) - if r: - return True - return False - - def set_gain(self, gain): - self.gain = gain - self.u.set_gain(gain) - - -# //////////////////////////////////////////////////////////////////////// -# Main -# //////////////////////////////////////////////////////////////////////// - -if __name__ == '__main__': - app = stdgui2.stdapp (my_top_block, "USRP NBFM RX") - app.MainLoop () diff --git a/gr-uhd/examples/usrp_spectrum_sense.py b/gr-uhd/examples/usrp_spectrum_sense.py deleted file mode 100755 index 355a55a98..000000000 --- a/gr-uhd/examples/usrp_spectrum_sense.py +++ /dev/null @@ -1,258 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, eng_notation, window -from gnuradio import audio -from gnuradio import uhd -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import sys -import math -import struct -import threading - -sys.stderr.write("Warning: this may have issues on some machines+Python version combinations to seg fault due to the callback in bin_statitics.\n\n") - -class ThreadClass(threading.Thread): - def run(self): - return - -class tune(gr.feval_dd): - """ - This class allows C++ code to callback into python. - """ - def __init__(self, tb): - gr.feval_dd.__init__(self) - self.tb = tb - - def eval(self, ignore): - """ - This method is called from gr.bin_statistics_f when it wants - to change the center frequency. This method tunes the front - end to the new center frequency, and returns the new frequency - as its result. - """ - - try: - # We use this try block so that if something goes wrong - # from here down, at least we'll have a prayer of knowing - # what went wrong. Without this, you get a very - # mysterious: - # - # terminate called after throwing an instance of - # 'Swig::DirectorMethodException' Aborted - # - # message on stderr. Not exactly helpful ;) - - new_freq = self.tb.set_next_freq() - return new_freq - - except Exception, e: - print "tune: Exception: ", e - - -class parse_msg(object): - def __init__(self, msg): - self.center_freq = msg.arg1() - self.vlen = int(msg.arg2()) - assert(msg.length() == self.vlen * gr.sizeof_float) - - # FIXME consider using NumPy array - t = msg.to_string() - self.raw_data = t - self.data = struct.unpack('%df' % (self.vlen,), t) - - -class my_top_block(gr.top_block): - - def __init__(self): - gr.top_block.__init__(self) - - usage = "usage: %prog [options] min_freq max_freq" - parser = OptionParser(option_class=eng_option, usage=usage) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, - help="set sample rate [default=%default]") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("", "--tune-delay", type="eng_float", - default=1e-3, metavar="SECS", - help="time to delay (in seconds) after changing frequency [default=%default]") - parser.add_option("", "--dwell-delay", type="eng_float", - default=10e-3, metavar="SECS", - help="time to dwell (in seconds) at a given frequncy [default=%default]") - parser.add_option("-F", "--fft-size", type="int", default=256, - help="specify number of FFT bins [default=%default]") - parser.add_option("", "--real-time", action="store_true", default=False, - help="Attempt to enable real-time scheduling") - - (options, args) = parser.parse_args() - if len(args) != 2: - parser.print_help() - sys.exit(1) - - self.min_freq = eng_notation.str_to_num(args[0]) - self.max_freq = eng_notation.str_to_num(args[1]) - - if self.min_freq > self.max_freq: - # swap them - self.min_freq, self.max_freq = self.max_freq, self.min_freq - - self.fft_size = options.fft_size - - if not options.real_time: - realtime = False - else: - # Attempt to enable realtime scheduling - r = gr.enable_realtime_scheduling() - if r == gr.RT_OK: - realtime = True - else: - realtime = False - print "Note: failed to enable realtime scheduling" - - # build graph - self.u = uhd.usrp_source(device_addr=options.args, - stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(options.spec): - self.u.set_subdev_spec(options.spec, 0) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, 0) - - usrp_rate = options.samp_rate - self.u.set_samp_rate(usrp_rate) - dev_rate = self.u.get_samp_rate() - - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) - - mywindow = window.blackmanharris(self.fft_size) - fft = gr.fft_vcc(self.fft_size, True, mywindow) - power = 0 - for tap in mywindow: - power += tap*tap - - c2mag = gr.complex_to_mag_squared(self.fft_size) - - # FIXME the log10 primitive is dog slow - log = gr.nlog10_ff(10, self.fft_size, - -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)) - - # Set the freq_step to 75% of the actual data throughput. - # This allows us to discard the bins on both ends of the spectrum. - - self.freq_step = 0.75 * usrp_rate - self.min_center_freq = self.min_freq + self.freq_step/2 - nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step) - self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step) - - self.next_freq = self.min_center_freq - - tune_delay = max(0, int(round(options.tune_delay * usrp_rate / self.fft_size))) # in fft_frames - dwell_delay = max(1, int(round(options.dwell_delay * usrp_rate / self.fft_size))) # in fft_frames - - self.msgq = gr.msg_queue(16) - self._tune_callback = tune(self) # hang on to this to keep it from being GC'd - stats = gr.bin_statistics_f(self.fft_size, self.msgq, - self._tune_callback, tune_delay, - dwell_delay) - - # FIXME leave out the log10 until we speed it up - #self.connect(self.u, s2v, fft, c2mag, log, stats) - self.connect(self.u, s2v, fft, c2mag, stats) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - options.gain = float(g.start()+g.stop())/2.0 - - self.set_gain(options.gain) - print "gain =", options.gain - - def set_next_freq(self): - target_freq = self.next_freq - self.next_freq = self.next_freq + self.freq_step - if self.next_freq >= self.max_center_freq: - self.next_freq = self.min_center_freq - - if not self.set_freq(target_freq): - print "Failed to set frequency to", target_freq - sys.exit(1) - - return target_freq - - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - """ - r = self.u.set_center_freq(target_freq) - if r: - return True - - return False - - def set_gain(self, gain): - self.u.set_gain(gain) - - -def main_loop(tb): - while 1: - - # Get the next message sent from the C++ code (blocking call). - # It contains the center frequency and the mag squared of the fft - m = parse_msg(tb.msgq.delete_head()) - - # Print center freq so we know that something is happening... - print m.center_freq - - # FIXME do something useful with the data... - - # m.data are the mag_squared of the fft output (they are in the - # standard order. I.e., bin 0 == DC.) - # You'll probably want to do the equivalent of "fftshift" on them - # m.raw_data is a string that contains the binary floats. - # You could write this as binary to a file. - - -if __name__ == '__main__': - t = ThreadClass() - t.start() - - tb = my_top_block() - try: - tb.start() - main_loop(tb) - - except KeyboardInterrupt: - pass diff --git a/gr-uhd/examples/usrp_tv_rcv.py b/gr-uhd/examples/usrp_tv_rcv.py deleted file mode 100755 index 700915bf8..000000000 --- a/gr-uhd/examples/usrp_tv_rcv.py +++ /dev/null @@ -1,443 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005-2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -""" -Realtime capture and display of analog Tv stations. - -Can also use a file as source or sink - -When you use an output file you can show the results frame-by-frame -using ImageMagick - -When you want to use the realtime sdl display window you must first -install gr-video-sdl. - -When you use a file source, instead of the usrp, make sure you -capture interleaved shorts. (Use usrp_rx_file.py, or use -usrp_rx_cfile.py --output-shorts if you have a recent enough -usrp_rx_cfile.py) - -There is no synchronisation yet. The sync blocks are in development -but not yet in cvs. -""" - -from gnuradio import gr -try: - from gnuradio import video_sdl -except: - print "FYI: gr-video-sdl is not installed" - print "realtime SDL video output window will not be available" -from gnuradio import uhd -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui2, fftsink2, form -from optparse import OptionParser -import sys -import wx - - -class tv_rx_block (stdgui2.std_top_block): - def __init__(self,frame,panel,vbox,argv): - stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) - - usage="%prog: [options] [input_filename]. \n If you don't specify an input filename the usrp will be used as source\n " \ - "Make sure your input capture file containes interleaved shorts not complex floats" - parser=OptionParser(option_class=eng_option, usage=usage) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, - help="set sample rate") - parser.add_option("-f", "--freq", type="eng_float", default=519.25e6, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("-c", "--contrast", type="eng_float", default=1.0, - help="set contrast (default is 1.0)") - parser.add_option("-b", "--brightness", type="eng_float", default=0.0, - help="set brightness (default is 0)") - parser.add_option("-p", "--pal", action="store_true", default=False, - help="PAL video format (this is the default)") - parser.add_option("-n", "--ntsc", action="store_true", default=False, - help="NTSC video format") - parser.add_option("-o", "--out-filename", type="string", default="sdl", - help="For example out_raw_uchar.gray. If you don't specify an output filename you will get a video_sink_sdl realtime output window. You then need to have gr-video-sdl installed)") - parser.add_option("-r", "--repeat", action="store_false", default=True, - help="repeat file in a loop") - parser.add_option("", "--freq-min", type="eng_float", default=50.25e6, - help="Set a minimum frequency [default=%default]") - parser.add_option("", "--freq-max", type="eng_float", default=900.25e6, - help="Set a maximum frequency [default=%default]") - - (options, args) = parser.parse_args() - if not ((len(args) == 1) or (len(args) == 0)): - parser.print_help() - sys.exit(1) - - if len(args) == 1: - filename = args[0] - else: - filename = None - - self.frame = frame - self.panel = panel - - self.contrast = options.contrast - self.brightness = options.brightness - self.state = "FREQ" - self.freq = 0 - - self.tv_freq_min = options.freq_min - self.tv_freq_max = options.freq_max - - # build graph - self.u=None - - if not (options.out_filename=="sdl"): - options.repeat=False - - usrp_rate = options.samp_rate - - if not ((filename is None) or (filename=="usrp")): - # file is data source - self.filesource = gr.file_source(gr.sizeof_short,filename,options.repeat) - self.istoc = gr.interleaved_short_to_complex() - self.connect(self.filesource,self.istoc) - self.src=self.istoc - - options.gain=0.0 - self.gain=0.0 - - else: # use a UHD device - self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(options.spec): - self.u.set_subdev_spec(options.spec, 0) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, 0) - - self.u.set_samp_rate(usrp_rate) - dev_rate = self.u.get_samp_rate() - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - options.gain = float(g.start()+g.stop())/2.0 - - self.src=self.u - - self.gain = options.gain - - f2uc=gr.float_to_uchar() - - # sdl window as final sink - if not (options.pal or options.ntsc): - options.pal=True #set default to PAL - - if options.pal: - lines_per_frame=625.0 - frames_per_sec=25.0 - show_width=768 - - elif options.ntsc: - lines_per_frame=525.0 - frames_per_sec=29.97002997 - show_width=640 - - width=int(usrp_rate/(lines_per_frame*frames_per_sec)) - height=int(lines_per_frame) - - if (options.out_filename=="sdl"): - #Here comes the tv screen, you have to build and install - #gr-video-sdl for this (subproject of gnuradio, only in cvs - #for now) - try: - video_sink = video_sdl.sink_uc ( frames_per_sec, width, height, 0, - show_width, height) - except: - print "gr-video-sdl is not installed" - print "realtime \"sdl\" video output window is not available" - raise SystemExit, 1 - self.dst=video_sink - else: - print "You can use the imagemagick display tool to show the resulting imagesequence" - print "use the following line to show the demodulated TV-signal:" - print "display -depth 8 -size " +str(width)+ "x" + str(height) \ - + " gray:" + options.out_filename - print "(Use the spacebar to advance to next frames)" - options.repeat=False - file_sink=gr.file_sink(gr.sizeof_char, options.out_filename) - self.dst =file_sink - - self.agc=gr.agc_cc(1e-7,1.0,1.0) #1e-7 - self.am_demod = gr.complex_to_mag () - self.set_blacklevel=gr.add_const_ff(0.0) - self.invert_and_scale = gr.multiply_const_ff (0.0) #-self.contrast *128.0*255.0/(200.0) - - # now wire it all together - #sample_rate=options.width*options.height*options.framerate - - process_type='do_no_sync' - if process_type=='do_no_sync': - self.connect (self.src, self.agc,self.am_demod, - self.invert_and_scale, self.set_blacklevel, - f2uc,self.dst) - elif process_type=='do_tv_sync_adv': - #defaults: gr.tv_sync_adv (double sampling_freq, unsigned - #int tv_format,bool output_active_video_only=false, bool - #do_invert=false, double wanted_black_level=0.0, double - #wanted_white_level=255.0, double avg_alpha=0.1, double - #initial_gain=1.0, double initial_offset=0.0,bool - #debug=false) - - #note, this block is not yet in cvs - self.tv_sync_adv=gr.tv_sync_adv(usrp_rate, 0, False, False, - 0.0, 255.0, 0.01, 1.0, 0.0, False) - self.connect (self.src, self.am_demod, self.invert_and_scale, - self.tv_sync_adv, s2f, f2uc, self.dst) - - elif process_type=='do_nullsink': - #self.connect (self.src, self.am_demod,self.invert_and_scale,f2uc,video_sink) - c2r=gr.complex_to_real() - nullsink=gr.null_sink(gr.sizeof_float) - self.connect (self.src, c2r,nullsink) #video_sink) - elif process_type=='do_tv_sync_corr': - frame_size=width*height #int(usrp_rate/25.0) - nframes=10# 32 - search_window=20*nframes - debug=False - video_alpha=0.3 #0.1 - corr_alpha=0.3 - - #Note: this block is not yet in cvs - tv_corr=gr.tv_correlator_ff(frame_size,nframes, search_window, - video_alpha, corr_alpha,debug) - shift=gr.add_const_ff(-0.7) - - self.connect (self.src, self.agc, self.am_demod, tv_corr, - self.invert_and_scale, self.set_blacklevel, - f2uc, self.dst) - else: # process_type=='do_test_image': - src_vertical_bars = gr.sig_source_f (usrp_rate, gr.GR_SIN_WAVE, - 10.0 *usrp_rate/320, 255,128) - self.connect(src_vertical_bars, f2uc, self.dst) - - self._build_gui(vbox, usrp_rate, usrp_rate, usrp_rate) - - - frange = self.u.get_freq_range() - if(frange.start() > self.tv_freq_max or frange.stop() < self.tv_freq_min): - sys.stderr.write("Radio does not support required frequency range.\n") - sys.exit(1) - if(options.freq < self.tv_freq_min or options.freq > self.tv_freq_max): - sys.stderr.write("Requested frequency is outside of required frequency range.\n") - sys.exit(1) - - # set initial values - self.set_gain(options.gain) - self.set_contrast(self.contrast) - self.set_brightness(options.brightness) - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - - - def _set_status_msg(self, msg, which=0): - self.frame.GetStatusBar().SetStatusText(msg, which) - - - def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - - if 0: - self.src_fft = fftsink.fft_sink_c (self, self.panel, title="Data from USRP", - fft_size=512, sample_rate=usrp_rate) - self.connect (self.src, self.src_fft) - vbox.Add (self.src_fft.win, 4, wx.EXPAND) - - if 0: - post_demod_fft = fftsink.fft_sink_f (self, self.panel, title="Post Demod", - fft_size=512, sample_rate=demod_rate, - y_per_div=10, ref_level=-40) - self.connect (self.am_demod, post_demod_fft) - vbox.Add (post_demod_fft.win, 4, wx.EXPAND) - - if 0: - post_filt_fft = fftsink.fft_sink_f (self, self.panel, title="Post Filter", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=-40) - self.connect (self.set_blacklevel, post_filt) - vbox.Add (fft_win4, 4, wx.EXPAND) - - - # control area form at bottom - self.myform = myform = form.form() - - if not (self.u is None): - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - myform['freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="Freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) - - hbox.Add((5,0), 0) - myform['freq_slider'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, - range=(self.tv_freq_min, self.tv_freq_max, 0.25e6), - callback=self.set_freq) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - - myform['contrast'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Contrast", - weight=3, range=(-2.0, 2.0, 0.1), - callback=self.set_contrast) - hbox.Add((5,0), 1) - - myform['brightness'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Brightness", - weight=3, range=(-255.0, 255.0, 1.0), - callback=self.set_brightness) - hbox.Add((5,0), 0) - - if not (self.u is None): - g = self.u.get_gain_range() - myform['gain'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", - weight=3, range=(g.start(), g.stop(), g.step()), - callback=self.set_gain) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - try: - self.knob = powermate.powermate(self.frame) - self.rot = 0 - powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) - powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) - except: - print "FYI: No Powermate or Contour Knob found" - - - def on_rotate (self, event): - self.rot += event.delta - if (self.state == "FREQ"): - if self.rot >= 3: - self.set_freq(self.freq + .1e6) - self.rot -= 3 - elif self.rot <=-3: - self.set_freq(self.freq - .1e6) - self.rot += 3 - elif (self.state == "CONTRAST"): - step = 0.1 - if self.rot >= 3: - self.set_contrast(self.contrast + step) - self.rot -= 3 - elif self.rot <=-3: - self.set_contrast(self.contrast - step) - self.rot += 3 - else: - step = 1 - if self.rot >= 3: - self.set_brightness(self.brightness + step) - self.rot -= 3 - elif self.rot <=-3: - self.set_brightness(self.brightness - step) - self.rot += 3 - - def on_button (self, event): - if event.value == 0: # button up - return - self.rot = 0 - if self.state == "FREQ": - self.state = "CONTRAST" - elif self.state == "CONTRAST": - self.state = "BRIGHTNESS" - else: - self.state = "FREQ" - self.update_status_bar () - - - def set_contrast (self, contrast): - self.contrast = contrast - self.invert_and_scale.set_k(-self.contrast *128.0*255.0/(200.0)) - self.myform['contrast'].set_value(self.contrast) - self.update_status_bar () - - def set_brightness (self, brightness): - self.brightness = brightness - self.set_blacklevel.set_k(self.brightness +255.0) - self.myform['brightness'].set_value(self.brightness) - self.update_status_bar () - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital down converter. - """ - if not (self.u is None): - r = self.u.set_center_freq(target_freq) - if r: - self.freq = target_freq - self.myform['freq'].set_value(target_freq) # update displayed value - self.myform['freq_slider'].set_value(target_freq) # update displayed value - self.update_status_bar() - self._set_status_msg("OK", 0) - return True - - self._set_status_msg("Failed", 0) - return False - - def set_gain(self, gain): - if not (self.u is None): - self.gain=gain - self.myform['gain'].set_value(gain) # update displayed value - self.u.set_gain(gain) - self.update_status_bar() - - def update_status_bar (self): - msg = "Setting:%s Contrast:%r Brightness:%r Gain: %r" % \ - (self.state, self.contrast,self.brightness,self.gain) - self._set_status_msg(msg, 1) - #self.src_fft.set_baseband_freq(self.freq) - - -if __name__ == '__main__': - app = stdgui2.stdapp (tv_rx_block, "USRP TV RX black-and-white") - app.MainLoop () diff --git a/gr-uhd/examples/usrp_tv_rcv_nogui.py b/gr-uhd/examples/usrp_tv_rcv_nogui.py deleted file mode 100755 index 870e65b27..000000000 --- a/gr-uhd/examples/usrp_tv_rcv_nogui.py +++ /dev/null @@ -1,214 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005-2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -""" -Reads from a file and generates PAL TV pictures in black and white -which can be displayed using ImageMagick or realtime using -gr-video-sdl (To capture the input file Use usrp_rx_file.py, or use -usrp_rx_cfile.py --output-shorts if you have a recent enough -usrp_rx_cfile.py) - -Can also use usrp directly as capture source, but then you need a -higher decimation factor (64) and thus get a lower horizontal -resulution. There is no synchronisation yet. The sync blocks are in -development but not yet in cvs. - -""" - -from gnuradio import gr, eng_notation -from gnuradio import audio -from gnuradio import uhd -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import sys - -try: - from gnuradio import video_sdl -except: - print "FYI: gr-video-sdl is not installed" - print "realtime \"sdl\" video output window will not be available" - - -class my_top_block(gr.top_block): - - def __init__(self): - gr.top_block.__init__(self) - - usage=("%prog: [options] output_filename.\nSpecial output_filename" + \ - "\"sdl\" will use video_sink_sdl as realtime output window. " + \ - "You then need to have gr-video-sdl installed.\n" +\ - "Make sure your input capture file containes interleaved " + \ - "shorts not complex floats") - parser = OptionParser(option_class=eng_option, usage=usage) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, - help="set sample rate") - parser.add_option("-c", "--contrast", type="eng_float", default=1.0, - help="set contrast (default is 1.0)") - parser.add_option("-b", "--brightness", type="eng_float", default=0.0, - help="set brightness (default is 0)") - parser.add_option("-i", "--in-filename", type="string", default=None, - help="Use input file as source. samples must be " + \ - "interleaved shorts \n Use usrp_rx_file.py or " + \ - "usrp_rx_cfile.py --output-shorts.\n Special " + \ - "name \"usrp\" results in realtime capturing " + \ - "and processing using usrp.\n" + \ - "You then probably need a decimation factor of 64 or higher.") - parser.add_option("-f", "--freq", type="eng_float", default=519.25e6, - help="set frequency to FREQ.\nNote that the frequency of the video carrier is not at the middle of the TV channel", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("-p", "--pal", action="store_true", default=False, - help="PAL video format (this is the default)") - parser.add_option("-n", "--ntsc", action="store_true", default=False, - help="NTSC video format") - parser.add_option("-r", "--repeat", action="store_false", default=True, - help="repeat in_file in a loop") - parser.add_option("-N", "--nframes", type="eng_float", default=None, - help="number of frames to collect [default=+inf]") - parser.add_option("", "--freq-min", type="eng_float", default=50.25e6, - help="Set a minimum frequency [default=%default]") - parser.add_option("", "--freq-max", type="eng_float", default=900.25e6, - help="Set a maximum frequency [default=%default]") - (options, args) = parser.parse_args () - if not (len(args) == 1): - parser.print_help() - sys.stderr.write('You must specify the output. FILENAME or sdl \n'); - sys.exit(1) - - filename = args[0] - - self.tv_freq_min = options.freq_min - self.tv_freq_max = options.freq_max - - if options.in_filename is None: - parser.print_help() - sys.stderr.write('You must specify the input -i FILENAME or -i usrp\n'); - raise SystemExit, 1 - - if not (filename=="sdl"): - options.repeat=False - - input_rate = options.samp_rate - print "video sample rate %s" % (eng_notation.num_to_str(input_rate)) - - if not (options.in_filename=="usrp"): - # file is data source, capture with usr_rx_csfile.py - self.filesource = gr.file_source(gr.sizeof_short, - options.in_filename, - options.repeat) - self.istoc = gr.interleaved_short_to_complex() - self.connect(self.filesource,self.istoc) - self.src=self.istoc - else: - if options.freq is None: - parser.print_help() - sys.stderr.write('You must specify the frequency with -f FREQ\n'); - raise SystemExit, 1 - - # build the graph - self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(options.spec): - self.u.set_subdev_spec(options.spec, 0) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, 0) - - self.u.set_samp_rate(input_rate) - dev_rate = self.u.get_samp_rate() - - self.src=self.u - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - options.gain = float(g.start()+g.stop())/2.0 - self.u.set_gain(options.gain) - - r = self.u.set_center_freq(options.freq) - if not r: - sys.stderr.write('Failed to set frequency\n') - raise SystemExit, 1 - - - self.agc = gr.agc_cc(1e-7,1.0,1.0) #1e-7 - self.am_demod = gr.complex_to_mag () - self.set_blacklevel = gr.add_const_ff(options.brightness +255.0) - self.invert_and_scale = gr.multiply_const_ff (-options.contrast *128.0*255.0/(200.0)) - self.f2uc = gr.float_to_uchar() - - # sdl window as final sink - if not (options.pal or options.ntsc): - options.pal=True #set default to PAL - if options.pal: - lines_per_frame=625.0 - frames_per_sec=25.0 - show_width=768 - elif options.ntsc: - lines_per_frame=525.0 - frames_per_sec=29.97002997 - show_width=640 - width=int(input_rate/(lines_per_frame*frames_per_sec)) - height=int(lines_per_frame) - - if filename=="sdl": - #Here comes the tv screen, you have to build and install - #gr-video-sdl for this (subproject of gnuradio, only in cvs - #for now) - try: - video_sink = video_sdl.sink_uc(frames_per_sec, width, height, 0, - show_width,height) - except: - print "gr-video-sdl is not installed" - print "realtime \"sdl\" video output window is not available" - raise SystemExit, 1 - self.dst=video_sink - else: - print "You can use the imagemagick display tool to show the resulting imagesequence" - print "use the following line to show the demodulated TV-signal:" - print "display -depth 8 -size " +str(width)+ "x" + str(height) + " gray:" +filename - print "(Use the spacebar to advance to next frames)" - file_sink=gr.file_sink(gr.sizeof_char, filename) - self.dst =file_sink - - if options.nframes is None: - self.connect(self.src, self.agc) - else: - self.head = gr.head(gr.sizeof_gr_complex, int(options.nframes*width*height)) - self.connect(self.src, self.head, self.agc) - - self.connect (self.agc, self.am_demod, self.invert_and_scale, - self.set_blacklevel, self.f2uc, self.dst) - -if __name__ == '__main__': - try: - my_top_block().run() - except KeyboardInterrupt: - pass diff --git a/gr-uhd/examples/usrp_wfm_rcv.py b/gr-uhd/examples/usrp_wfm_rcv.py deleted file mode 100755 index f6c5cf853..000000000 --- a/gr-uhd/examples/usrp_wfm_rcv.py +++ /dev/null @@ -1,286 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005-2007,2009,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, optfir, audio, blks2, uhd -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui2, fftsink2, form -from optparse import OptionParser -import sys -import wx - - -class wfm_rx_block (stdgui2.std_top_block): - def __init__(self,frame,panel,vbox,argv): - stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) - - parser=OptionParser(option_class=eng_option) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=40, - help="set gain in dB (default is midpoint)") - parser.add_option("-V", "--volume", type="eng_float", default=None, - help="set volume (default is midpoint)") - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") - parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, - help="Set a minimum frequency [default=%default]") - parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, - help="Set a maximum frequency [default=%default]") - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - self.frame = frame - self.panel = panel - - self.vol = 0 - self.state = "FREQ" - self.freq = 0 - - self.fm_freq_min = options.freq_min - self.fm_freq_max = options.freq_max - - # build graph - self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(options.spec): - self.u.set_subdev_spec(options.spec, 0) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, 0) - - usrp_rate = 320e3 - demod_rate = 320e3 - audio_rate = 32e3 - audio_decim = int(demod_rate / audio_rate) - - self.u.set_samp_rate(usrp_rate) - dev_rate = self.u.get_samp_rate() - - nfilts = 32 - chan_coeffs = optfir.low_pass (nfilts, # gain - nfilts*usrp_rate, # sampling rate - 80e3, # passband cutoff - 115e3, # stopband cutoff - 0.1, # passband ripple - 60) # stopband attenuation - rrate = usrp_rate / dev_rate - self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) - - self.guts = blks2.wfm_rcv (demod_rate, audio_decim) - - self.volume_control = gr.multiply_const_ff(self.vol) - - # sound card as final sink - self.audio_sink = audio.sink (int (audio_rate), - options.audio_output, - False) # ok_to_block - - # now wire it all together - self.connect (self.u, self.chan_filt, self.guts, - self.volume_control, self.audio_sink) - - self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - options.gain = float(g.start()+g.stop())/2 - - if options.volume is None: - g = self.volume_range() - options.volume = float(g[0]+g[1])/2 - - frange = self.u.get_freq_range() - if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): - sys.stderr.write("Radio does not support required frequency range.\n") - sys.exit(1) - if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max): - sys.stderr.write("Requested frequency is outside of required frequency range.\n") - sys.exit(1) - - - # set initial values - - self.set_gain(options.gain) - self.set_vol(options.volume) - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - - def _set_status_msg(self, msg, which=0): - self.frame.GetStatusBar().SetStatusText(msg, which) - - - def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - - if 1: - self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", - fft_size=512, sample_rate=usrp_rate, - ref_scale=32768.0, ref_level=0, y_divs=12) - self.connect (self.u, self.src_fft) - vbox.Add (self.src_fft.win, 4, wx.EXPAND) - - if 1: - post_filt_fft = fftsink2.fft_sink_f(self.panel, title="Post Demod", - fft_size=1024, sample_rate=usrp_rate, - y_per_div=10, ref_level=0) - self.connect (self.guts.fm_demod, post_filt_fft) - vbox.Add (post_filt_fft.win, 4, wx.EXPAND) - - if 0: - post_deemph_fft = fftsink2.fft_sink_f(self.panel, title="Post Deemph", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=-20) - self.connect (self.guts.deemph, post_deemph_fft) - vbox.Add (post_deemph_fft.win, 4, wx.EXPAND) - - - # control area form at bottom - self.myform = myform = form.form() - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - myform['freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="Freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) - - hbox.Add((5,0), 0) - myform['freq_slider'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, - range=(self.fm_freq_min, self.fm_freq_max, 0.1e6), - callback=self.set_freq) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - - myform['volume'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", - weight=3, range=self.volume_range(), - callback=self.set_vol) - hbox.Add((5,0), 1) - - g = self.u.get_gain_range() - myform['gain'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", - weight=3, range=(g.start(), g.stop(), g.step()), - callback=self.set_gain) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - try: - self.knob = powermate.powermate(self.frame) - self.rot = 0 - powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) - powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) - except: - print "FYI: No Powermate or Contour Knob found" - - - def on_rotate (self, event): - self.rot += event.delta - if (self.state == "FREQ"): - if self.rot >= 3: - self.set_freq(self.freq + .1e6) - self.rot -= 3 - elif self.rot <=-3: - self.set_freq(self.freq - .1e6) - self.rot += 3 - else: - step = self.volume_range()[2] - if self.rot >= 3: - self.set_vol(self.vol + step) - self.rot -= 3 - elif self.rot <=-3: - self.set_vol(self.vol - step) - self.rot += 3 - - def on_button (self, event): - if event.value == 0: # button up - return - self.rot = 0 - if self.state == "FREQ": - self.state = "VOL" - else: - self.state = "FREQ" - self.update_status_bar () - - - def set_vol (self, vol): - g = self.volume_range() - self.vol = max(g[0], min(g[1], vol)) - self.volume_control.set_k(10**(self.vol/10)) - self.myform['volume'].set_value(self.vol) - self.update_status_bar () - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - """ - - r = self.u.set_center_freq(target_freq) - if r: - self.freq = target_freq - self.myform['freq'].set_value(target_freq) # update displayed value - self.myform['freq_slider'].set_value(target_freq) # update displayed value - self.update_status_bar() - self._set_status_msg("OK", 0) - return True - - self._set_status_msg("Failed", 0) - return False - - def set_gain(self, gain): - self.myform['gain'].set_value(gain) # update displayed value - self.u.set_gain(gain) - - def update_status_bar (self): - msg = "Volume:%r Setting:%s" % (self.vol, self.state) - self._set_status_msg(msg, 1) - self.src_fft.set_baseband_freq(self.freq) - - def volume_range(self): - return (-20.0, 0.0, 0.5) - - -if __name__ == '__main__': - app = stdgui2.stdapp (wfm_rx_block, "USRP WFM RX") - app.MainLoop () diff --git a/gr-uhd/examples/usrp_wfm_rcv2_nogui.py b/gr-uhd/examples/usrp_wfm_rcv2_nogui.py deleted file mode 100755 index b70334f30..000000000 --- a/gr-uhd/examples/usrp_wfm_rcv2_nogui.py +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005-2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, optfir, audio, blks2, uhd -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import sys -import math - -class wfm_rx_block (gr.top_block): - - def __init__(self): - gr.top_block.__init__(self) - - parser=OptionParser(option_class=eng_option) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default="A:0 A:0", - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("", "--f1", type="eng_float", default=100.7e6, - help="set 1st station frequency to FREQ", metavar="FREQ") - parser.add_option("", "--f2", type="eng_float", default=102.5e6, - help="set 2nd station freq to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=40, - help="set gain in dB (default is midpoint)") - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") - parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, - help="Set a minimum frequency [default=%default]") - parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, - help="Set a maximum frequency [default=%default]") - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - if abs(options.f1 - options.f2) > 5.5e6: - print "Sorry, two stations must be within 5.5MHz of each other" - raise SystemExit - - f = (options.f1, options.f2) - - self.vol = .1 - self.state = "FREQ" - - self.fm_freq_min = options.freq_min - self.fm_freq_max = options.freq_max - - # build graph - stream_args = uhd.stream_args('fc32', channels=range(2)) - self.u = uhd.usrp_source(device_addr=options.args, stream_args=stream_args) - - # Set front end channel mapping - self.u.set_subdev_spec(options.spec) - - usrp_rate = 320e3 - demod_rate = 320e3 - audio_rate = 32e3 - audio_decim = int(demod_rate / audio_rate) - - self.u.set_samp_rate(usrp_rate) - dev_rate = self.u.get_samp_rate() - - # Make sure dboard can suppor the required frequencies - frange = self.u.get_freq_range() - if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): - sys.stderr.write("Radio does not support required frequency range.\n") - sys.exit(1) - - # sound card as final sink - self.audio_sink = audio.sink(int(audio_rate), options.audio_output) - - # taps for channel filter - nfilts = 32 - chan_coeffs = optfir.low_pass (nfilts, # gain - nfilts*usrp_rate, # sampling rate - 80e3, # passband cutoff - 115e3, # stopband cutoff - 0.1, # passband ripple - 60) # stopband attenuation - rrate = usrp_rate / dev_rate - - # set front end PLL to middle frequency - mid_freq = (f[0] + f[1]) / 2.0 - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - options.gain = float(g.start()+g.stop())/2.0 - - for n in range(2): - chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) - guts = blks2.wfm_rcv (demod_rate, audio_decim) - volume_control = gr.multiply_const_ff(self.vol) - - #self.connect((self.di, n), chan_filt) - self.connect((self.u, n), chan_filt) - self.connect(chan_filt, guts, volume_control) - self.connect(volume_control, (self.audio_sink, n)) - - # Test the the requested frequencies are in range - if(f[n] < self.fm_freq_min or f[n] > self.fm_freq_max): - sys.stderr.write("Requested frequency is outside of required frequency range.\n") - sys.exit(1) - - # Tune each channel by setting the RF freq to mid_freq and the - # DDC freq to f[n]. - tr = uhd.tune_request(f[n], rf_freq=mid_freq, - rf_freq_policy=uhd.tune_request.POLICY_MANUAL) - self.u.set_center_freq(tr, n) - - # Set gain for each channel - self.set_gain(options.gain, n) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, n) - - def set_vol (self, vol): - self.vol = vol - self.volume_control.set_k(self.vol) - - - def set_gain(self, gain, n): - self.u.set_gain(gain, n) - -if __name__ == '__main__': - tb = wfm_rx_block() - try: - tb.run() - except KeyboardInterrupt: - pass diff --git a/gr-uhd/examples/usrp_wfm_rcv_fmdet.py b/gr-uhd/examples/usrp_wfm_rcv_fmdet.py deleted file mode 100755 index 9649857c0..000000000 --- a/gr-uhd/examples/usrp_wfm_rcv_fmdet.py +++ /dev/null @@ -1,349 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005-2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, optfir, audio, blks2, uhd -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui2, fftsink2, form, scopesink2 -from optparse import OptionParser -import sys -import wx - -class wfm_rx_block (stdgui2.std_top_block): - def __init__(self,frame,panel,vbox,argv): - stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) - - parser=OptionParser(option_class=eng_option) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=65, - help="set gain in dB (default is midpoint)") - parser.add_option("-s", "--squelch", type="eng_float", default=0, - help="set squelch level (default is 0)") - parser.add_option("-V", "--volume", type="eng_float", default=None, - help="set volume (default is midpoint)") - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") - parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, - help="Set a minimum frequency [default=%default]") - parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, - help="Set a maximum frequency [default=%default]") - - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - self.frame = frame - self.panel = panel - - self.vol = 0 - self.state = "FREQ" - self.freq = 0 - - self.fm_freq_min = options.freq_min - self.fm_freq_max = options.freq_max - - # build graph - self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(options.spec): - self.u.set_subdev_spec(options.spec, 0) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, 0) - - usrp_rate = 320e3 - demod_rate = 320e3 - audio_rate = 48e3 - audio_decim = 10 - - self.u.set_samp_rate(usrp_rate) - dev_rate = self.u.get_samp_rate() - - nfilts = 32 - chan_coeffs = gr.firdes.low_pass_2(10*nfilts, # gain - nfilts*usrp_rate, # sampling rate - 90e3, # passband cutoff - 30e3, # transition bw - 70) # stopband attenuation - rrate = usrp_rate / dev_rate - self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) - - self.guts = blks2.wfm_rcv_fmdet (demod_rate, audio_decim) - - chan_rate = audio_rate / (demod_rate/audio_decim) - self.rchan_filt = blks2.pfb_arb_resampler_fff(chan_rate) - self.lchan_filt = blks2.pfb_arb_resampler_fff(chan_rate) - - # FIXME rework {add,multiply}_const_* to handle multiple streams - self.volume_control_l = gr.multiply_const_ff(self.vol) - self.volume_control_r = gr.multiply_const_ff(self.vol) - - # sound card as final sink - self.audio_sink = audio.sink (int (audio_rate), - options.audio_output, - False) # ok_to_block - - # now wire it all together - self.connect (self.u, self.chan_filt, self.guts) - self.connect((self.guts, 0), self.lchan_filt, - self.volume_control_l, (self.audio_sink,0)) - self.connect((self.guts, 1), self.rchan_filt, - self.volume_control_r, (self.audio_sink,1)) - - try: - self.guts.stereo_carrier_pll_recovery.squelch_enable(True) - except: - print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" - - - self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - options.gain = float(g.start()+g.stop())/2.0 - - if options.volume is None: - g = self.volume_range() - options.volume = float(g[0]+g[1])/2 - - if abs(options.freq) < 1e6: - options.freq *= 1e6 - - frange = self.u.get_freq_range() - if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): - sys.stderr.write("Radio does not support required frequency range.\n") - sys.exit(1) - if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max): - sys.stderr.write("Requested frequency is outside of required frequency range.\n") - sys.exit(1) - - # set initial values - self.set_gain(options.gain) - self.set_vol(options.volume) - try: - self.guts.stereo_carrier_pll_recovery.set_lock_threshold(options.squelch) - except: - print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" - - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - - def _set_status_msg(self, msg, which=0): - self.frame.GetStatusBar().SetStatusText(msg, which) - - - def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - - if 1: - self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", - fft_size=512, sample_rate=usrp_rate, - ref_scale=32768.0, ref_level=0, y_divs=12) - self.connect (self.u, self.src_fft) - vbox.Add (self.src_fft.win, 4, wx.EXPAND) - - if 1: - post_fm_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post FM Demod", - fft_size=512, sample_rate=demod_rate, - y_per_div=10, ref_level=0) - self.connect (self.guts.fm_demod, post_fm_demod_fft) - vbox.Add (post_fm_demod_fft.win, 4, wx.EXPAND) - - if 0: - post_stereo_carrier_generator_fft = fftsink2.fft_sink_c (self.panel, title="Post Stereo_carrier_generator", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=0) - self.connect (self.guts.stereo_carrier_generator, post_stereo_carrier_generator_fft) - vbox.Add (post_stereo_carrier_generator_fft.win, 4, wx.EXPAND) - - if 0: - post_deemphasis_left = fftsink2.fft_sink_f (self.panel, title="Post_Deemphasis_Left", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=0) - self.connect (self.guts.deemph_Left, post_deemphasis_left) - vbox.Add (post_deemphasis_left.win, 4, wx.EXPAND) - - if 0: - post_deemphasis_right = fftsink2.fft_sink_f(self.panel, title="Post_Deemphasis_Right", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=-20) - self.connect (self.guts.deemph_Left, post_deemphasis_right) - vbox.Add (post_deemphasis_right.win, 4, wx.EXPAND) - - - if 0: - LmR_fft = fftsink2.fft_sink_f(self.panel, title="LmR", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=-20) - self.connect (self.guts.LmR_real,LmR_fft) - vbox.Add (LmR_fft.win, 4, wx.EXPAND) - - if 0: - self.scope = scopesink2.scope_sink_f(self.panel, sample_rate=demod_rate) - self.connect (self.guts.fm_demod,self.scope) - vbox.Add (self.scope.win,4,wx.EXPAND) - - # control area form at bottom - self.myform = myform = form.form() - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - myform['freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="Freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) - - hbox.Add((5,0), 0) - myform['freq_slider'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, - range=(self.fm_freq_min, self.fm_freq_max, 0.1e6), - callback=self.set_freq) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - - myform['volume'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", - weight=3, range=self.volume_range(), - callback=self.set_vol) - hbox.Add((5,0), 1) - - g = self.u.get_gain_range() - myform['gain'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", - weight=3, range=(g.start(), g.stop(), g.step()), - callback=self.set_gain) - hbox.Add((5,0), 0) - - myform['sqlch_thrsh'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Stereo Squelch Threshold", - weight=3, range=(0.0,1.0,0.01), - callback=self.set_squelch) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - try: - self.knob = powermate.powermate(self.frame) - self.rot = 0 - powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) - powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) - except: - print "FYI: No Powermate or Contour Knob found" - - - def on_rotate (self, event): - self.rot += event.delta - if (self.state == "FREQ"): - if self.rot >= 3: - self.set_freq(self.freq + .1e6) - self.rot -= 3 - elif self.rot <=-3: - self.set_freq(self.freq - .1e6) - self.rot += 3 - else: - step = self.volume_range()[2] - if self.rot >= 3: - self.set_vol(self.vol + step) - self.rot -= 3 - elif self.rot <=-3: - self.set_vol(self.vol - step) - self.rot += 3 - - def on_button (self, event): - if event.value == 0: # button up - return - self.rot = 0 - if self.state == "FREQ": - self.state = "VOL" - else: - self.state = "FREQ" - self.update_status_bar () - - - def set_vol (self, vol): - g = self.volume_range() - self.vol = max(g[0], min(g[1], vol)) - self.volume_control_l.set_k(10**(self.vol/10)) - self.volume_control_r.set_k(10**(self.vol/10)) - self.myform['volume'].set_value(self.vol) - self.update_status_bar () - - def set_squelch(self,squelch_threshold): - try: - self.guts.stereo_carrier_pll_recovery.set_lock_threshold(squelch_threshold); - except: - print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" - - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - """ - - r = self.u.set_center_freq(target_freq) - - if r: - self.freq = target_freq - self.myform['freq'].set_value(target_freq) # update displayed value - self.myform['freq_slider'].set_value(target_freq) # update displayed value - self.update_status_bar() - self._set_status_msg("OK", 0) - return True - - self._set_status_msg("Failed", 0) - return False - - def set_gain(self, gain): - self.myform['gain'].set_value(gain) # update displayed value - self.u.set_gain(gain) - - def update_status_bar (self): - msg = "Volume:%r Setting:%s" % (self.vol, self.state) - self._set_status_msg(msg, 1) - self.src_fft.set_baseband_freq(self.freq) - - def volume_range(self): - return (-20.0, 0.0, 0.5) - - -if __name__ == '__main__': - app = stdgui2.stdapp (wfm_rx_block, "USRP WFM RX") - app.MainLoop () diff --git a/gr-uhd/examples/usrp_wfm_rcv_nogui.py b/gr-uhd/examples/usrp_wfm_rcv_nogui.py deleted file mode 100755 index f0195bcb5..000000000 --- a/gr-uhd/examples/usrp_wfm_rcv_nogui.py +++ /dev/null @@ -1,175 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005-2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, optfir, audio, blks2, uhd -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import sys - -class wfm_rx_block (gr.top_block): - - def __init__(self): - gr.top_block.__init__(self) - - parser=OptionParser(option_class=eng_option) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("-V", "--volume", type="eng_float", default=None, - help="set volume (default is midpoint)") - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") - parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, - help="Set a minimum frequency [default=%default]") - parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, - help="Set a maximum frequency [default=%default]") - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - self.state = "FREQ" - self.freq = 0 - - self.fm_freq_min = options.freq_min - self.fm_freq_max = options.freq_max - - # build graph - self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(options.spec): - self.u.set_subdev_spec(options.spec, 0) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, 0) - - usrp_rate = 320e3 - demod_rate = 320e3 - audio_rate = 32e3 - audio_decim = int(demod_rate / audio_rate) - - self.u.set_samp_rate(usrp_rate) - dev_rate = self.u.get_samp_rate() - - nfilts = 32 - chan_coeffs = optfir.low_pass (nfilts, # gain - nfilts*usrp_rate, # sampling rate - 80e3, # passband cutoff - 115e3, # stopband cutoff - 0.1, # passband ripple - 60) # stopband attenuation - rrate = usrp_rate / dev_rate - self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) - - self.guts = blks2.wfm_rcv (demod_rate, audio_decim) - - self.volume_control = gr.multiply_const_ff(1) - - # sound card as final sink - self.audio_sink = audio.sink(int(audio_rate), - options.audio_output, - False) # ok_to_block - - # now wire it all together - self.connect (self.u, self.chan_filt, self.guts, - self.volume_control, self.audio_sink) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - options.gain = float(g.start()+g.stop())/2.0 - - if options.volume is None: - g = self.volume_range() - options.volume = float(g[0]+g[1])/2 - - frange = self.u.get_freq_range() - if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): - sys.stderr.write("Radio does not support required frequency range.\n") - sys.exit(1) - if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max): - sys.stderr.write("Requested frequency is outside of required frequency range.\n") - sys.exit(1) - - # set initial values - self.set_gain(options.gain) - self.set_vol(options.volume) - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - - def set_vol (self, vol): - g = self.volume_range() - self.vol = max(g[0], min(g[1], vol)) - self.volume_control.set_k(10**(self.vol/10)) - self.update_status_bar () - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - """ - - r = self.u.set_center_freq(target_freq) - - if r: - self.freq = target_freq - self.update_status_bar() - self._set_status_msg("OK", 0) - return True - - self._set_status_msg("Failed", 0) - return False - - def set_gain(self, gain): - self.u.set_gain(gain) - - def update_status_bar (self): - msg = "Freq: %s Volume:%f Setting:%s" % ( - eng_notation.num_to_str(self.freq), self.vol, self.state) - self._set_status_msg(msg, 1) - - def _set_status_msg(self, msg, which=0): - print msg - - def volume_range(self): - return (-20.0, 0.0, 0.5) - - -if __name__ == '__main__': - tb = wfm_rx_block() - try: - tb.run() - except KeyboardInterrupt: - pass diff --git a/gr-uhd/examples/usrp_wfm_rcv_pll.py b/gr-uhd/examples/usrp_wfm_rcv_pll.py deleted file mode 100755 index b0744b00b..000000000 --- a/gr-uhd/examples/usrp_wfm_rcv_pll.py +++ /dev/null @@ -1,346 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005-2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, optfir, audio, blks2, uhd -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui2, fftsink2, form, scopesink2 -from optparse import OptionParser -import sys -import wx - -class wfm_rx_block (stdgui2.std_top_block): - def __init__(self,frame,panel,vbox,argv): - stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) - - parser=OptionParser(option_class=eng_option) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=65, - help="set gain in dB (default is midpoint)") - parser.add_option("-s", "--squelch", type="eng_float", default=0, - help="set squelch level (default is 0)") - parser.add_option("-V", "--volume", type="eng_float", default=None, - help="set volume (default is midpoint)") - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") - parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, - help="Set a minimum frequency [default=%default]") - parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, - help="Set a maximum frequency [default=%default]") - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - self.frame = frame - self.panel = panel - - self.vol = 0 - self.state = "FREQ" - self.freq = 0 - - self.fm_freq_min = options.freq_min - self.fm_freq_max = options.freq_max - - # build graph - self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(options.spec): - self.u.set_subdev_spec(options.spec, 0) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, 0) - - usrp_rate = 320e3 - demod_rate = 320e3 - audio_rate = 48e3 - audio_decim = 10 - - self.u.set_samp_rate(usrp_rate) - dev_rate = self.u.get_samp_rate() - - nfilts = 32 - chan_coeffs = gr.firdes.low_pass_2 (nfilts, # gain - nfilts*usrp_rate, # sampling rate - 90e3, # passband cutoff - 30e3, # stopband cutoff - 70) # stopband attenuation - rrate = usrp_rate / dev_rate - self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) - - - self.guts = blks2.wfm_rcv_pll (demod_rate, audio_decim) - - chan_rate = audio_rate / (demod_rate/audio_decim) - self.rchan_filt = blks2.pfb_arb_resampler_fff(chan_rate) - self.lchan_filt = blks2.pfb_arb_resampler_fff(chan_rate) - - # FIXME rework {add,multiply}_const_* to handle multiple streams - self.volume_control_l = gr.multiply_const_ff(self.vol) - self.volume_control_r = gr.multiply_const_ff(self.vol) - - # sound card as final sink - self.audio_sink = audio.sink (int (audio_rate), - options.audio_output, - False) # ok_to_block - - # now wire it all together - self.connect (self.u, self.chan_filt, self.guts) - self.connect((self.guts, 0), self.lchan_filt, - self.volume_control_l, (self.audio_sink,0)) - self.connect((self.guts, 1), self.rchan_filt, - self.volume_control_r, (self.audio_sink,1)) - - try: - self.guts.stereo_carrier_pll_recovery.squelch_enable(True) - except: - print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" - - - self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - options.gain = float(g.start()+g.stop())/2.0 - - if options.volume is None: - g = self.volume_range() - options.volume = float(g[0]+g[1])/2 - - frange = self.u.get_freq_range() - if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): - sys.stderr.write("Radio does not support required frequency range.\n") - sys.exit(1) - if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max): - sys.stderr.write("Requested frequency is outside of required frequency range.\n") - sys.exit(1) - - # set initial values - self.set_gain(options.gain) - self.set_vol(options.volume) - try: - self.guts.stereo_carrier_pll_recovery.set_lock_threshold(options.squelch) - except: - print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" - - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - - def _set_status_msg(self, msg, which=0): - self.frame.GetStatusBar().SetStatusText(msg, which) - - - def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - - if 1: - self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", - fft_size=512, sample_rate=usrp_rate, - ref_scale=32768.0, ref_level=0, y_divs=12) - self.connect (self.u, self.src_fft) - vbox.Add (self.src_fft.win, 4, wx.EXPAND) - - if 1: - post_fm_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post FM Demod", - fft_size=512, sample_rate=demod_rate, - y_per_div=10, ref_level=0) - self.connect (self.guts.fm_demod, post_fm_demod_fft) - vbox.Add (post_fm_demod_fft.win, 4, wx.EXPAND) - - if 0: - post_stereo_carrier_generator_fft = fftsink2.fft_sink_c (self.panel, title="Post Stereo_carrier_generator", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=0) - self.connect (self.guts.stereo_carrier_generator, post_stereo_carrier_generator_fft) - vbox.Add (post_stereo_carrier_generator_fft.win, 4, wx.EXPAND) - - if 0: - post_deemphasis_left = fftsink2.fft_sink_f (self.panel, title="Post_Deemphasis_Left", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=0) - self.connect (self.guts.deemph_Left, post_deemphasis_left) - vbox.Add (post_deemphasis_left.win, 4, wx.EXPAND) - - if 0: - post_deemphasis_right = fftsink2.fft_sink_f(self.panel, title="Post_Deemphasis_Right", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=-20) - self.connect (self.guts.deemph_Left, post_deemphasis_right) - vbox.Add (post_deemphasis_right.win, 4, wx.EXPAND) - - - if 0: - LmR_fft = fftsink2.fft_sink_f(self.panel, title="LmR", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=-20) - self.connect (self.guts.LmR_real,LmR_fft) - vbox.Add (LmR_fft.win, 4, wx.EXPAND) - - if 0: - self.scope = scopesink2.scope_sink_f(self.panel, sample_rate=demod_rate) - self.connect (self.guts.fm_demod,self.scope) - vbox.Add (self.scope.win,4,wx.EXPAND) - - # control area form at bottom - self.myform = myform = form.form() - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - myform['freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="Freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) - - hbox.Add((5,0), 0) - myform['freq_slider'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, - range=(self.fm_freq_min, self.fm_freq_max, 0.1e6), - callback=self.set_freq) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - - myform['volume'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", - weight=3, range=self.volume_range(), - callback=self.set_vol) - hbox.Add((5,0), 1) - - g = self.u.get_gain_range() - myform['gain'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", - weight=3, range=(g.start(), g.stop(), g.step()), - callback=self.set_gain) - hbox.Add((5,0), 0) - - myform['sqlch_thrsh'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Stereo Squelch Threshold", - weight=3, range=(0.0,1.0,0.01), - callback=self.set_squelch) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - try: - self.knob = powermate.powermate(self.frame) - self.rot = 0 - powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) - powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) - except: - print "FYI: No Powermate or Contour Knob found" - - - def on_rotate (self, event): - self.rot += event.delta - if (self.state == "FREQ"): - if self.rot >= 3: - self.set_freq(self.freq + .1e6) - self.rot -= 3 - elif self.rot <=-3: - self.set_freq(self.freq - .1e6) - self.rot += 3 - else: - step = self.volume_range()[2] - if self.rot >= 3: - self.set_vol(self.vol + step) - self.rot -= 3 - elif self.rot <=-3: - self.set_vol(self.vol - step) - self.rot += 3 - - def on_button (self, event): - if event.value == 0: # button up - return - self.rot = 0 - if self.state == "FREQ": - self.state = "VOL" - else: - self.state = "FREQ" - self.update_status_bar () - - - def set_vol (self, vol): - g = self.volume_range() - self.vol = max(g[0], min(g[1], vol)) - self.volume_control_l.set_k(10**(self.vol/10)) - self.volume_control_r.set_k(10**(self.vol/10)) - self.myform['volume'].set_value(self.vol) - self.update_status_bar () - - def set_squelch(self,squelch_threshold): - try: - self.guts.stereo_carrier_pll_recovery.set_lock_threshold(squelch_threshold); - except: - print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - """ - - r = self.u.set_center_freq(target_freq) - - if r: - self.freq = target_freq - self.myform['freq'].set_value(target_freq) # update displayed value - self.myform['freq_slider'].set_value(target_freq) # update displayed value - self.update_status_bar() - self._set_status_msg("OK", 0) - return True - - self._set_status_msg("Failed", 0) - return False - - def set_gain(self, gain): - self.myform['gain'].set_value(gain) # update displayed value - self.u.set_gain(gain) - - def update_status_bar (self): - msg = "Volume:%r Setting:%s" % (self.vol, self.state) - self._set_status_msg(msg, 1) - self.src_fft.set_baseband_freq(self.freq) - - def volume_range(self): - return (-20.0, 0.0, 0.5) - - -if __name__ == '__main__': - app = stdgui2.stdapp (wfm_rx_block, "USRP WFM RX") - app.MainLoop () diff --git a/gr-uhd/examples/usrp_wfm_rcv_sca.py b/gr-uhd/examples/usrp_wfm_rcv_sca.py deleted file mode 100755 index 224f30cf8..000000000 --- a/gr-uhd/examples/usrp_wfm_rcv_sca.py +++ /dev/null @@ -1,403 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -""" -Here is a bit of code that will receive SCA analog subcarriers of FM -Broadcast Stations using the USRP. It is a modified version of -usrp_wfm_rcv.py. - -Common SCA frequencies are 67 kHz and 92 kHz. SCA is used for Reading -Services for the Blind, Background Music, Foreign Language Services, and -other services. Remember you may hear static when tuned to a FM station -because this code only outputs SCA audio. - -The USRP gain is critical for good decoding. Adjust for minimum noise. - I use the Post FM Demod FFT to check for SCA subcarriers and to adjust -the USRP gain for the lowest noise floor. The stereo pilot at 19 KHz, -the stereo difference signal around 38 KHz, and RDS at 57 KHz are also -displayed on the Post FM Demod FFT if present. - -The range below 67 kHz is used for SCA only when Stereo is not used. - -The SCA recieve range is not as far as the main FM carrier receive range -so tune in strong local stations first. - -I tried to comment the code with the various parameters. There seems to -be several choices for a couple of them. I coded the common ones I see -here. - -In the local area there are a couple of stations using digital SCA. -These look similar to narrow DRM signals and I wonder if they are using -OFDM. -""" - - -from gnuradio import gr, optfir, audio, blks2, uhd -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui2, fftsink2, form -from optparse import OptionParser -import sys -import math -import wx - -class wfm_rx_sca_block (stdgui2.std_top_block): - def __init__(self,frame,panel,vbox,argv): - stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) - - parser=OptionParser(option_class=eng_option) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=40, - help="set gain in dB (default is midpoint)") - parser.add_option("-V", "--volume", type="eng_float", default=None, - help="set volume (default is midpoint)") - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") - parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, - help="Set a minimum frequency [default=%default]") - parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, - help="Set a maximum frequency [default=%default]") - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - self.frame = frame - self.panel = panel - - self.vol = 0 - self.state = "FREQ" - self.freq = 0 - - self.fm_freq_min = options.freq_min - self.fm_freq_max = options.freq_max - - # build graph - - self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(options.spec): - self.u.set_subdev_spec(options.spec, 0) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, 0) - - usrp_rate = 320e3 - demod_rate = 320e3 - audio_rate = 32e3 - sca_demod_rate = 64e3 - audio_decim = int(demod_rate / audio_rate) - sca_chanfilt_decim = int(demod_rate / sca_demod_rate) - - self.u.set_samp_rate(usrp_rate) - dev_rate = self.u.get_samp_rate() - - nfilts = 32 - chan_coeffs = optfir.low_pass (nfilts, # gain - nfilts*usrp_rate, # sampling rate - 100e3, # passband cutoff - 140e3, # stopband cutoff - 0.1, # passband ripple - 60) # stopband attenuation - rrate = usrp_rate / dev_rate - self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) - - #Create demodulator block for Main FM Channel - max_dev = 75e3 - fm_demod_gain = demod_rate/(2*math.pi*max_dev) - self.fm_demod = gr.quadrature_demod_cf (fm_demod_gain) - - # Note - deemphasis is not applied to the Main FM Channel as - # main audio is not decoded - - # SCA Devation is 10% of carrier but some references say 20% - # if mono with one SCA (6 KHz seems typical) - max_sca_dev = 6e3 - - # Create filter to get SCA channel we want - sca_chan_coeffs = gr.firdes.low_pass (1.0, # gain - demod_rate, # sampling rate - max_sca_dev, # cutoff freq - max_sca_dev/3, # trans. band - gr.firdes.WIN_HANN) # filter type - - self.ddc = gr.freq_xlating_fir_filter_fcf(sca_chanfilt_decim, # decim rate - sca_chan_coeffs, # taps - 0, # freq translation amount (Gets set by the UI) - demod_rate) # input sample rate - - #Create demodulator block for SCA Channel - sca_demod_gain = sca_demod_rate/(2*math.pi*max_sca_dev) - self.fm_demod_sca = gr.quadrature_demod_cf (sca_demod_gain) - - - # SCA analog audio is bandwidth limited to 5 KHz - max_sca_audio_freq = 5.0e3 - - # SCA analog deephasis is 150 uS (75 uS may be used) - sca_tau = 150e-6 - - # compute FIR filter taps for SCA audio filter - audio_coeffs = gr.firdes.low_pass (1.0, # gain - sca_demod_rate, # sampling rate - max_sca_audio_freq, # cutoff freq - max_sca_audio_freq/2.5, # trans. band - gr.firdes.WIN_HAMMING) - - # input: float; output: float - self.audio_filter = gr.fir_filter_fff (audio_decim, audio_coeffs) - - # Create deemphasis block that is applied after SCA demodulation - self.deemph = blks2.fm_deemph (audio_rate, sca_tau) - - self.volume_control = gr.multiply_const_ff(self.vol) - - # sound card as final sink - self.audio_sink = audio.sink (int (audio_rate), - options.audio_output, - False) # ok_to_block - - # now wire it all together - self.connect (self.u, self.chan_filt, self.fm_demod, - self.ddc, self.fm_demod_sca) - self.connect (self.fm_demod_sca, self.audio_filter, - self.deemph, self.volume_control, - self.audio_sink) - - self._build_gui(vbox, usrp_rate, demod_rate, sca_demod_rate, audio_rate) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - options.gain = float(g.start()+g.stop())/2 - - if options.volume is None: - g = self.volume_range() - options.volume = float(g[0]+g[1])/2 - - frange = self.u.get_freq_range() - if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): - sys.stderr.write("Radio does not support required frequency range.\n") - sys.exit(1) - if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max): - sys.stderr.write("Requested frequency is outside of required frequency range.\n") - sys.exit(1) - - # set initial values - - self.set_gain(options.gain) - self.set_vol(options.volume) - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - self.set_sca_freq(67000) # A common SCA Frequency - - def _set_status_msg(self, msg, which=0): - self.frame.GetStatusBar().SetStatusText(msg, which) - - - def _build_gui(self, vbox, usrp_rate, demod_rate, sca_demod_rate, audio_rate): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - def _form_set_sca_freq(kv): - return self.set_sca_freq(kv['sca_freq']) - - if 1: - self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", - fft_size=512, sample_rate=usrp_rate, - ref_scale=32768.0, ref_level=0, y_divs=12) - self.connect (self.u, self.src_fft) - vbox.Add (self.src_fft.win, 4, wx.EXPAND) - - if 1: - post_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post FM Demod", - fft_size=2048, sample_rate=demod_rate, - y_per_div=10, ref_level=0) - self.connect (self.fm_demod, post_demod_fft) - vbox.Add (post_demod_fft.win, 4, wx.EXPAND) - - if 0: - post_demod_sca_fft = fftsink2.fft_sink_f(self.panel, title="Post SCA Demod", - fft_size=1024, sample_rate=sca_demod_rate, - y_per_div=10, ref_level=0) - self.connect (self.fm_demod_sca, post_demod_sca_fft) - vbox.Add (post_demod_sca_fft.win, 4, wx.EXPAND) - - if 0: - post_deemph_fft = fftsink2.fft_sink_f (self.panel, title="Post SCA Deemph", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=-20) - self.connect (self.deemph, post_deemph_fft) - vbox.Add (post_deemph_fft.win, 4, wx.EXPAND) - - - # control area form at bottom - self.myform = myform = form.form() - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - myform['freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="Freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) - - hbox.Add((5,0), 0) - myform['freq_slider'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, - range=(self.fm_freq_min, self.fm_freq_max, 0.1e6), - callback=self.set_freq) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - myform['sca_freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="SCA", weight=1, - callback=myform.check_input_and_call(_form_set_sca_freq, self._set_status_msg)) - - hbox.Add((5,0), 0) - myform['sca_freq_slider'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, - range=(38e3, 100e3, 1.0e3), - callback=self.set_sca_freq) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - - myform['volume'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", - weight=3, range=self.volume_range(), - callback=self.set_vol) - hbox.Add((5,0), 1) - - g = self.u.get_gain_range() - myform['gain'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", - weight=3, range=(g.start(), g.stop(), g.step()), - callback=self.set_gain) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - try: - self.knob = powermate.powermate(self.frame) - self.rot = 0 - powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) - powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) - except: - print "FYI: No Powermate or Contour Knob found" - - - def on_rotate (self, event): - self.rot += event.delta - if (self.state == "FREQ"): - if self.rot >= 3: - self.set_freq(self.freq + .1e6) - self.rot -= 3 - elif self.rot <=-3: - self.set_freq(self.freq - .1e6) - self.rot += 3 - else: - step = self.volume_range()[2] - if self.rot >= 3: - self.set_vol(self.vol + step) - self.rot -= 3 - elif self.rot <=-3: - self.set_vol(self.vol - step) - self.rot += 3 - - def on_button (self, event): - if event.value == 0: # button up - return - self.rot = 0 - if self.state == "FREQ": - self.state = "VOL" - else: - self.state = "FREQ" - self.update_status_bar () - - - def set_vol (self, vol): - g = self.volume_range() - self.vol = max(g[0], min(g[1], vol)) - self.volume_control.set_k(10**(self.vol/10)) - self.myform['volume'].set_value(self.vol) - self.update_status_bar () - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital down converter. - """ - r = self.u.set_center_freq(target_freq) - if r: - self.freq = target_freq - self.myform['freq'].set_value(target_freq) # update displayed value - self.myform['freq_slider'].set_value(target_freq) # update displayed value - self.update_status_bar() - self._set_status_msg("OK", 0) - return True - self._set_status_msg("Failed", 0) - return False - - def set_sca_freq(self, target_sca_freq): - - self.ddc.set_center_freq(-target_sca_freq) - self.myform['sca_freq'].set_value(target_sca_freq) # update displayed value - self.myform['sca_freq_slider'].set_value(target_sca_freq) # update displayed value - self.update_status_bar() - self._set_status_msg("OK", 0) - return True - - def set_gain(self, gain): - self.myform['gain'].set_value(gain) # update displayed value - self.u.set_gain(gain) - - def update_status_bar (self): - msg = "Volume:%r Setting:%s" % (self.vol, self.state) - self._set_status_msg(msg, 1) - self.src_fft.set_baseband_freq(self.freq) - - def volume_range(self): - return (-20.0, 0.0, 0.5) - - -if __name__ == '__main__': - app = stdgui2.stdapp (wfm_rx_sca_block, "USRP WFM SCA RX") - app.MainLoop () diff --git a/gr-uhd/examples/usrp_wxapt_rcv.py b/gr-uhd/examples/usrp_wxapt_rcv.py deleted file mode 100755 index d9b1a0188..000000000 --- a/gr-uhd/examples/usrp_wxapt_rcv.py +++ /dev/null @@ -1,282 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005-2007,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, audio, blks2, uhd -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui2, fftsink2, form -from optparse import OptionParser -import sys -import wx - - -class wxapt_rx_block (stdgui2.std_top_block): - def __init__(self,frame,panel,vbox,argv): - stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) - - parser=OptionParser(option_class=eng_option) - parser.add_option("-a", "--args", type="string", default="", - help="UHD device address args, [default=%default]") - parser.add_option("", "--spec", type="string", default=None, - help="Subdevice of UHD device where appropriate") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("-f", "--freq", type="eng_float", default=137.5e6, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("-V", "--volume", type="eng_float", default=None, - help="set volume (default is midpoint)") - parser.add_option("-O", "--audio-output", type="string", default="", - help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") - parser.add_option("", "--freq-min", type="eng_float", default=137e6, - help="Set a minimum frequency [default=%default]") - parser.add_option("", "--freq-max", type="eng_float", default=138e6, - help="Set a maximum frequency [default=%default]") - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - self.frame = frame - self.panel = panel - - self.vol = 0 - self.state = "FREQ" - self.freq = 0 - - self.freq_min = options.freq_min - self.freq_max = options.freq_max - - # build graph - self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) - - # Set the subdevice spec - if(options.spec): - self.u.set_subdev_spec(options.spec, 0) - - # Set the antenna - if(options.antenna): - self.u.set_antenna(options.antenna, 0) - - usrp_rate = 320e3 - demod_rate = 320e3 - audio_rate = 32e3 - audio_decim = int(demod_rate / audio_rate) - - self.u.set_samp_rate(usrp_rate) - dev_rate = self.u.get_samp_rate() - - nfilts = 32 - chan_coeffs = gr.firdes.low_pass_2 (nfilts, # gain - nfilts*usrp_rate, # sampling rate - 40e3, # passband cutoff - 20e3, # transition bw - 60) # stopband attenuation - rrate = usrp_rate / dev_rate - self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) - - self.guts = blks2.wfm_rcv (demod_rate, audio_decim) - - self.volume_control = gr.multiply_const_ff(self.vol) - - # sound card as final sink - self.audio_sink = audio.sink (int (audio_rate), options.audio_output) - - # now wire it all together - self.connect (self.u, self.chan_filt, self.guts, - self.volume_control, self.audio_sink) - - self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - g = self.u.get_gain_range() - options.gain = float(g.start()+g.stop())/2.0 - - if options.volume is None: - g = self.volume_range() - options.volume = float(g[0]+g[1])/2 - - frange = self.u.get_freq_range() - if(frange.start() > self.freq_max or frange.stop() < self.freq_min): - sys.stderr.write("Radio does not support required frequency range.\n") - sys.exit(1) - if(options.freq < self.freq_min or options.freq > self.freq_max): - sys.stderr.write("Requested frequency is outside of required frequency range.\n") - sys.exit(1) - - # set initial values - self.set_gain(options.gain) - self.set_vol(options.volume) - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - - def _set_status_msg(self, msg, which=0): - self.frame.GetStatusBar().SetStatusText(msg, which) - - - def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - - if 1: - self.src_fft = fftsink2.fft_sink_c (self.panel, title="Data from USRP", - fft_size=512, sample_rate=usrp_rate, - ref_scale=32768.0, ref_level=0, y_divs=12) - self.connect (self.u, self.src_fft) - vbox.Add (self.src_fft.win, 4, wx.EXPAND) - - if 1: - post_deemph_fft = fftsink2.fft_sink_f (self.panel, title="Post Deemph", - fft_size=512, sample_rate=demod_rate, - y_per_div=10, ref_level=-20) - self.connect (self.guts.deemph, post_deemph_fft) - vbox.Add (post_deemph_fft.win, 4, wx.EXPAND) - - if 1: - post_filt_fft = fftsink2.fft_sink_f (self.panel, title="Post Filter", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=0) - self.connect (self.guts.audio_filter, post_filt_fft) - vbox.Add (post_filt_fft.win, 4, wx.EXPAND) - - - # control area form at bottom - self.myform = myform = form.form() - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - myform['freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="Freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) - - hbox.Add((5,0), 0) - myform['freq_slider'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, - range=(self.freq_min, self.freq_max, 0.0005e6), - callback=self.set_freq) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - - myform['volume'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", - weight=3, range=self.volume_range(), - callback=self.set_vol) - hbox.Add((5,0), 1) - - g = self.u.get_gain_range() - myform['gain'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", - weight=3, range=(g.start(), g.start(), g.step()), - callback=self.set_gain) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - try: - self.knob = powermate.powermate(self.frame) - self.rot = 0 - powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) - powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) - except: - print "FYI: No Powermate or Contour Knob found" - - - def on_rotate (self, event): - self.rot += event.delta - if (self.state == "FREQ"): - if self.rot >= 3: - self.set_freq(self.freq + .1e6) - self.rot -= 3 - elif self.rot <=-3: - self.set_freq(self.freq - .1e6) - self.rot += 3 - else: - step = self.volume_range()[2] - if self.rot >= 3: - self.set_vol(self.vol + step) - self.rot -= 3 - elif self.rot <=-3: - self.set_vol(self.vol - step) - self.rot += 3 - - def on_button (self, event): - if event.value == 0: # button up - return - self.rot = 0 - if self.state == "FREQ": - self.state = "VOL" - else: - self.state = "FREQ" - self.update_status_bar () - - - def set_vol (self, vol): - g = self.volume_range() - self.vol = max(g[0], min(g[1], vol)) - self.volume_control.set_k(10**(self.vol/10)) - self.myform['volume'].set_value(self.vol) - self.update_status_bar () - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - """ - - r = self.u.set_center_freq(target_freq) - - if r: - self.freq = target_freq - self.myform['freq'].set_value(target_freq) # update displayed value - self.myform['freq_slider'].set_value(target_freq) # update displayed value - self.update_status_bar() - self._set_status_msg("OK", 0) - return True - - self._set_status_msg("Failed", 0) - return False - - def set_gain(self, gain): - self.myform['gain'].set_value(gain) # update displayed value - self.u.set_gain(gain) - - def update_status_bar (self): - msg = "Volume:%r Setting:%s" % (self.vol, self.state) - self._set_status_msg(msg, 1) - self.src_fft.set_baseband_freq(self.freq) - - def volume_range(self): - return (-20.0, 0.0, 0.5) - - -if __name__ == '__main__': - app = stdgui2.stdapp (wxapt_rx_block, "USRP WXAPT RX") - app.MainLoop () diff --git a/gr-vocoder/CMakeLists.txt b/gr-vocoder/CMakeLists.txt index e800cff00..19f0dbec9 100644 --- a/gr-vocoder/CMakeLists.txt +++ b/gr-vocoder/CMakeLists.txt @@ -35,6 +35,8 @@ GR_SET_GLOBAL(GR_VOCODER_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include ) +SET(GR_PKG_VOCODER_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/vocoder) + ######################################################################## # Begin conditional configuration ######################################################################## diff --git a/gr-vocoder/examples/CMakeLists.txt b/gr-vocoder/examples/CMakeLists.txt index 76a757826..769ddf602 100644 --- a/gr-vocoder/examples/CMakeLists.txt +++ b/gr-vocoder/examples/CMakeLists.txt @@ -32,6 +32,6 @@ GR_PYTHON_INSTALL( g723_40_audio_loopback.py gsm_audio_loopback.py ulaw_audio_loopback.py - DESTINATION ${GR_PKG_DATA_DIR}/examples/vocoder + DESTINATION ${GR_PKG_VOCODER_EXAMPLES_DIR} COMPONENT "vocoder_examples" ) -- cgit