Esempio n. 1
0
    def __init__(self, input_rate, sps):
        gr.hier_block2.__init__(
            self,
            "atsc_rx",
            # Input signature
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_char))  # Output signature

        # ATSC receiver filter/interpolator
        rx_filt = atsc_rx_filter(input_rate, sps)

        # Lock on to pilot tone, shift to DC, then discard Q channel
        output_rate = ATSC_SYMBOL_RATE * sps
        pll = dtv.atsc_fpll(output_rate)

        # Remove pilot tone now at DC
        dcr = filter.dc_blocker_ff(4096)

        # Normalize signal to proper constellation amplitude
        agc = analog.agc_ff(1e-5, 4.0)

        # Synchronize bit and segment timing
        btl = dtv.atsc_sync(output_rate)

        # Check for correct field sync
        fsc = dtv.atsc_fs_checker()

        # Equalize channel using training sequences
        equ = dtv.atsc_equalizer()

        # Remove convolutional trellis coding
        vit = dtv.atsc_viterbi_decoder()

        # Remove convolutional interleaving
        dei = dtv.atsc_deinterleaver()

        # Reed-Solomon decode
        rsd = dtv.atsc_rs_decoder()

        # Derandomize MPEG2-TS packet
        der = dtv.atsc_derandomizer()

        # Remove padding from packet
        dep = dtv.atsc_depad()

        # Connect pipeline
        self.connect(self, rx_filt, pll, dcr, agc, btl, fsc)
        self.connect((fsc, 0), (equ, 0))
        self.connect((fsc, 1), (equ, 1))
        self.connect((equ, 0), (vit, 0))
        self.connect((equ, 1), (vit, 1))
        self.connect((vit, 0), (dei, 0))
        self.connect((vit, 1), (dei, 1))
        self.connect((dei, 0), (rsd, 0))
        self.connect((dei, 1), (rsd, 1))
        self.connect((rsd, 0), (der, 0))
        self.connect((rsd, 1), (der, 1))
        self.connect((der, 0), (dep, 0))
        self.connect((dep, 0), (self, 0))
Esempio n. 2
0
    def test_002_sets(self):
        agc = analog.agc_ff(1e-3, 1, 1)

        agc.set_rate(1)
        agc.set_reference(1.1)
        agc.set_gain(1.1)
        agc.set_max_gain(100)

        self.assertAlmostEqual(agc.rate(), 1)
        self.assertAlmostEqual(agc.reference(), 1.1)
        self.assertAlmostEqual(agc.gain(), 1.1)
        self.assertAlmostEqual(agc.max_gain(), 100)
Esempio n. 3
0
    def test_002_sets(self):
        agc = analog.agc_ff(1e-3, 1, 1)

        agc.set_rate(1)
        agc.set_reference(1.1)
        agc.set_gain(1.1)
        agc.set_max_gain(100)

        self.assertAlmostEqual(agc.rate(), 1)
        self.assertAlmostEqual(agc.reference(), 1.1)
        self.assertAlmostEqual(agc.gain(), 1.1)
        self.assertAlmostEqual(agc.max_gain(), 100)
Esempio n. 4
0
    def __init__(self, chan_rate, target_dir, freq, holdoff, file_header,
                 file_cb, start_cb, stop_cb):
        gr.hier_block2.__init__(self, "indri_voice_channel",
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(0, 0, 0))

        self.connect(self, blocks.null_sink(gr.sizeof_float))

        self.target_dir = target_dir
        self.freq = freq
        self.holdoff = holdoff

        bpf_taps = firdes.band_pass(1, chan_rate, 300.0, 2000.0, 100,
                                    firdes.WIN_HAMMING, 6.76)

        bpf = gr_filter.fir_filter_fff(1, bpf_taps)

        agc = analog.agc_ff(1e-5, 0.6, 1.0)

        rational_resampler = gr_filter.rational_resampler_fff(
            interpolation=16,
            decimation=25,
            taps=None,
            fractional_bw=0.49,
        )

        f_bias = blocks.add_const_ff(1.0)
        f_scale = blocks.multiply_const_ff(125.0)
        f_to_char = blocks.float_to_uchar()

        self.connect(
            self,
            #bpf,
            #agc,
            rational_resampler,
            f_bias,
            f_scale,
            f_to_char)

        pattern = "%s/audio_%d_%%s.wav" % (self.target_dir, self.freq)
        ttrig = time_trigger(self.holdoff, start_cb, stop_cb, self.freq)
        self.time_trigger = ttrig

        afile_sink = timestamp_file_sink(pattern,
                                         self.holdoff,
                                         header=file_header,
                                         final_cb=file_cb)

        self.connect(f_to_char, afile_sink)
        self.connect(f_to_char, ttrig)
Esempio n. 5
0
    def __init__(self, input_rate, sps):
        gr.hier_block2.__init__(self, "atsc_rx",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                                gr.io_signature(1, 1, gr.sizeof_char))       # Output signature

        # ATSC receiver filter/interpolator
        rx_filt = atsc_rx_filter(input_rate, sps)

        # Lock on to pilot tone, shift to DC, then discard Q channel
        output_rate = ATSC_SYMBOL_RATE*sps
        pll = dtv.atsc_fpll(output_rate)

        # Remove pilot tone now at DC
        dcr = filter.dc_blocker_ff(4096)

        # Normalize signal to proper constellation amplitude
        agc = analog.agc_ff(1e-5, 4.0)

        # Synchronize bit and segment timing
        btl = dtv.atsc_sync(output_rate)

        # Check for correct field sync
        fsc = dtv.atsc_fs_checker()

        # Equalize channel using training sequences
        equ = dtv.atsc_equalizer()

        # Remove convolutional trellis coding
        vit = dtv.atsc_viterbi_decoder()

        # Remove convolutional interleaving
        dei = dtv.atsc_deinterleaver()

        # Reed-Solomon decode
        rsd = dtv.atsc_rs_decoder()

        # Derandomize MPEG2-TS packet
        der = dtv.atsc_derandomizer()

        # Remove padding from packet
        dep = dtv.atsc_depad()

        # Connect pipeline
        self.connect(self, rx_filt, pll, dcr, agc, btl, fsc, equ)
        self.connect(equ, vit, dei, rsd, der, dep, self)
Esempio n. 6
0
    def test_002(self):
        ''' Test the floating point AGC loop (single rate input) '''
        tb = self.tb

        expected_result = (
            7.2191943445432116e-07, 58.837181091308594, 89.700050354003906,
            81.264183044433594, 45.506141662597656, 4.269894304798072e-07,
            -42.948936462402344, -65.50335693359375, -59.368724822998047,
            -33.261005401611328, -4.683740257860336e-07, 31.423542022705078,
            47.950984954833984, 43.485683441162109, 24.378345489501953,
            5.7254135299444897e-07, -23.062990188598633, -35.218441009521484,
            -31.964075088500977, -17.934831619262695, -5.0591745548445033e-07,
            16.998210906982422, 25.982204437255859, 23.606258392333984,
            13.260685920715332, 4.9936483037527069e-07, -12.59880542755127,
            -19.28221321105957, -17.54347038269043, -9.8700437545776367,
            -4.188150626305287e-07, 9.4074573516845703, 14.422011375427246,
            13.145503044128418, 7.41046142578125, 3.8512698097292741e-07,
            -7.0924453735351562, -10.896408081054688, -9.9552040100097656,
            -5.6262712478637695, -3.1982864356905338e-07, 5.4131259918212891,
            8.3389215469360352, 7.6409502029418945, 4.3320145606994629,
            2.882407841298118e-07, -4.194943904876709, -6.4837145805358887,
            -5.9621825218200684, -3.3931560516357422)

        sampling_freq = 100
        src1 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE,
                                   sampling_freq * 0.10, 100.0)
        dst1 = blocks.vector_sink_f()
        head = blocks.head(gr.sizeof_float, int(5 * sampling_freq * 0.10))

        agc = analog.agc_ff(1e-3, 1, 1)

        tb.connect(src1, head)
        tb.connect(head, agc)
        tb.connect(agc, dst1)

        tb.run()
        dst_data = dst1.data()
        self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4)
Esempio n. 7
0
    def test_002(self):
        ''' Test the floating point AGC loop (single rate input) '''
        tb = self.tb

        expected_result = (
            0.0, 58.83704376220703, 89.69985961914062, 81.26403045654297,
            45.50606918334961, -3.3625440210016677e-06, -42.9488639831543,
            -65.50326538085938, -59.368656158447266, -33.26097869873047,
            4.995997642254224e-06, 31.423521041870117, 47.950958251953125,
            43.48566436767578, 24.37834358215332, -5.4677821026416495e-06,
            -23.06298828125, -35.21844482421875, -31.964082717895508,
            -17.93484115600586, 5.396469077822985e-06, 16.998228073120117,
            25.982229232788086, 23.60628318786621, 13.260700225830078,
            -4.97806149724056e-06, -12.598825454711914, -19.282241821289062,
            -17.543500900268555, -9.870061874389648, 4.467380676942412e-06,
            9.407480239868164, 14.422045707702637, 13.14553451538086,
            7.410478591918945, -3.91256025977782e-06, -7.092466354370117,
            -10.896439552307129, -9.955231666564941, -5.62628698348999,
            3.411524403418298e-06, 5.413146018981934, 8.338950157165527,
            7.640974521636963, 4.332027435302734, -2.95963241114805e-06,
            -4.19495964050293, -6.483736991882324, -5.962202072143555,
            -3.3931667804718018)

        sampling_freq = 100
        src1 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE,
                                   sampling_freq * 0.10, 100.0)
        dst1 = blocks.vector_sink_f()
        head = blocks.head(gr.sizeof_float, int(5 * sampling_freq * 0.10))

        agc = analog.agc_ff(1e-3, 1, 1)

        tb.connect(src1, head)
        tb.connect(head, agc)
        tb.connect(agc, dst1)

        tb.run()
        dst_data = dst1.data()
        self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4)
Esempio n. 8
0
    def __init__(self):
        gr.top_block.__init__(self, "Chu")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Chu")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "chu")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1200000
        self.upconverter_lo_freq = upconverter_lo_freq = 0
        self.space_tone = space_tone = 2025
        self.offset = offset = 100000
        self.mark_tone = mark_tone = 2225
        self.gain = gain = 10
        self.decimation = decimation = samp_rate // 48000
        self.chu_freq = chu_freq = 3330000
        self.channel_rate = channel_rate = 4800

        ##################################################
        # Blocks
        ##################################################
        self._gain_range = Range(0, 50, 0.4, 10, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain,
                                     'RX gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_win)
        self.root_raised_cosine_filter_0 = filter.fir_filter_fff(
            1, firdes.root_raised_cosine(1, channel_rate, 300, 0.35, 100))
        self.qtgui_waterfall_sink_x_1 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_1.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_1.enable_grid(False)
        self.qtgui_waterfall_sink_x_1.enable_axis_labels(True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_1.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_1.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_1.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_1_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_1_win)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        labels = [
            'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.osmosdr_source_1 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_1.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_1.set_sample_rate(samp_rate)
        self.osmosdr_source_1.set_center_freq(
            chu_freq - offset + upconverter_lo_freq, 0)
        self.osmosdr_source_1.set_freq_corr(0, 0)
        self.osmosdr_source_1.set_gain(gain, 0)
        self.osmosdr_source_1.set_if_gain(20, 0)
        self.osmosdr_source_1.set_bb_gain(20, 0)
        self.osmosdr_source_1.set_antenna('', 0)
        self.osmosdr_source_1.set_bandwidth(0, 0)
        self.low_pass_filter_1 = filter.fir_filter_ccf(
            10,
            firdes.low_pass(1000, samp_rate / 25, 200, 50, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            decimation,
            firdes.low_pass(1, samp_rate, 20000, 5000, firdes.WIN_HAMMING,
                            6.76))
        self.ham_chu_decode_0 = ham.chu_decode()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5)
        self.blocks_add_const_vxx_0 = blocks.add_const_ff(-1)
        self.band_pass_filter_0 = filter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, samp_rate / decimation, 200, 2800, 200,
                                     firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0_0 = audio.sink(48000, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate / decimation, analog.GR_COS_WAVE,
            -(space_tone + mark_tone) / 2, 1, 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -offset, 1, 0, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            channel_rate / (3.1416 * (mark_tone - space_tone)))
        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(
            3.1416 / 500, 1.8, -1.8)
        self.analog_agc_xx_0 = analog.agc_ff(1e-1, 0.02, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.ham_chu_decode_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.qtgui_waterfall_sink_x_1, 0))
        self.connect((self.osmosdr_source_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
Esempio n. 9
0
    def __init__(self, mon_id, audio_port):
        gr.top_block.__init__(self, "EAS/SAME Monitor")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8000

        ##################################################
        # Blocks
        ##################################################

        # Resampler from input rate (44.1k) to internal rate (8k)
        self.rational_resampler_44k = filter.rational_resampler_fff(
            interpolation=80,
            decimation=441,
        )

        # Resampler from 8000 Hz to 4166 2/3rd Hz to deal with SAME's weird parameters
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=50,
            decimation=96,
            taps=None,
            fractional_bw=None,
        )

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcc(
            1, (firdes.low_pass(1, samp_rate, 600, 100)), 1822.916667,
            samp_rate)
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
            samples_per_symbol=8,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.01,
            freq_error=0.0,
            verbose=True,
            log=False,
        )
        self.src = audio.source(44100, "eas_mon_%s:in" % (mon_id), True)
        self.agc = analog.agc_ff(0.0001, 0.1, 1.0)
        #self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(-50, 0.0001, 0)
        self.msg_queue = gr.msg_queue(10)
        self.same_dec_0 = same.same_dec(self.msg_queue)

        self.tone_det_0 = fft.goertzel_fc(samp_rate, samp_rate / 10, 853)
        self.tone_det_1 = fft.goertzel_fc(samp_rate, samp_rate / 10, 960)
        self.tone_det_2 = fft.goertzel_fc(samp_rate, samp_rate / 10, 1050)
        self.wat_thresh_msg = same.wat_thresh_msg(self.msg_queue, 1, 0.05,
                                                  0.01)

        #self.avg_audio_level = analog.probe_avg_mag_sqrd_ff(-50)
        #self.level_thresh_msg = same.level_thresh_msg(self.msg_queue, 1, 3, db_to_abs(-30), db_to_abs(-40))

        self.audio_sink_converter = blocks.float_to_short(1, 3276)
        self.audio_sink = blocks.udp_sink(2, '127.0.0.1', audio_port)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.src, 0), (self.rational_resampler_44k, 0))
        self.connect((self.rational_resampler_44k, 0), (self.agc, 0))
        #self.connect((self.agc, 0), (self.analog_pwr_squelch_xx_0, 0))

        #self.connect((self.analog_pwr_squelch_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.agc, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.digital_gmsk_demod_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0), (self.same_dec_0, 0))

        self.connect((self.agc, 0), (self.tone_det_0, 0),
                     (self.wat_thresh_msg, 0))
        self.connect((self.agc, 0), (self.tone_det_1, 0),
                     (self.wat_thresh_msg, 1))
        self.connect((self.agc, 0), (self.tone_det_2, 0),
                     (self.wat_thresh_msg, 2))
        #self.connect((self.agc, 0), (self.avg_audio_level, 0), (self.level_thresh_msg, 0))

        self.connect((self.agc, 0), (self.audio_sink_converter, 0),
                     (self.audio_sink, 0))

        self._watcher = _queue_watcher_thread(self.msg_queue, mon_id,
                                              audio_port)
Esempio n. 10
0
    def __init__(self):
        gr.top_block.__init__(self, "PWM")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("PWM")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "PWM")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 192000
        self.out_gain = out_gain = 0.1
        self.in_gain = in_gain = 0.2
        self.carrier_lvl = carrier_lvl = 0.2

        ##################################################
        # Blocks
        ##################################################
        self._out_gain_range = Range(0, 5, 0.05, 0.1, 200)
        self._out_gain_win = RangeWidget(self._out_gain_range,
                                         self.set_out_gain, 'Volumen OUT',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._out_gain_win)
        self._in_gain_range = Range(0, 5, 0.05, 0.2, 200)
        self._in_gain_win = RangeWidget(self._in_gain_range, self.set_in_gain,
                                        'Volumen IN', "counter_slider", float)
        self.top_grid_layout.addWidget(self._in_gain_win)
        self._carrier_lvl_range = Range(0, 1, 0.01, 0.2, 200)
        self._carrier_lvl_win = RangeWidget(self._carrier_lvl_range,
                                            self.set_carrier_lvl,
                                            'Carrier Gain', "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._carrier_lvl_win)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            2048,  #size
            samp_rate,  #samp_rate
            'Original signals',  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_1.enable_tags(True)
        self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_1.enable_autoscale(True)
        self.qtgui_time_sink_x_0_1.enable_grid(False)
        self.qtgui_time_sink_x_0_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_1.enable_control_panel(False)
        self.qtgui_time_sink_x_0_1.enable_stem_plot(False)

        labels = [
            'Original', 'Carrier', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            'Demodulated',  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

        labels = [
            'Demodulated', 'Original Signal', 'Signal 3', 'Signal 4',
            'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9',
            'Signal 10'
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            2048,  #size
            samp_rate,  #samp_rate
            'Modulated',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        labels = [
            'Modulated', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 12000, 10, firdes.WIN_HAMMING, 6.76))
        self.epy_block_0 = epy_block_0.blk()
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/irodrigu/Proyectos/sc-clases/2020-2021/P1/src/songs/Lofi.wav',
            True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(in_gain)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(out_gain)
        self.audio_sink_0 = audio.sink(48000, 'pulse', True)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_TRI_WAVE, 60000, carrier_lvl,
            -(carrier_lvl) / 2, 1.5707)
        self.analog_agc_xx_0 = analog.agc_ff(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.epy_block_0, 1))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.qtgui_time_sink_x_0_1, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.epy_block_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_time_sink_x_0_0, 1))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.epy_block_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.epy_block_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_agc_xx_0, 0))
Esempio n. 11
0
    def __init__(self, inputfile='', outputfile='0'):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.inputfile = inputfile
        self.outputfile = outputfile

        ##################################################
        # Variables
        ##################################################
        self.decimation = decimation = 1
        self.symb_rate = symb_rate = 72e3
        self.samp_rate = samp_rate = 0.900001e6 / decimation
        self.ted_gain = ted_gain = 1
        self.sps = sps = (samp_rate) / symb_rate

        self.qpsk = qpsk = digital.constellation_calcdist(
            ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()

        self.loop_bw = loop_bw = 0.002
        self.fft_min = fft_min = -160
        self.fft_max = fft_max = -15

        self.dec_taps = dec_taps = firdes.low_pass(1.0, samp_rate, 141e3, 20e3,
                                                   firdes.WIN_HAMMING, 6.76)

        self.d_factor = d_factor = 2

        ##################################################
        # Blocks
        ##################################################
        self._ted_gain_range = Range(0.1, 2, 0.1, 1, 200)
        self._ted_gain_win = RangeWidget(self._ted_gain_range,
                                         self.set_ted_gain, "ted_gain",
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._ted_gain_win, 0, 2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._loop_bw_range = Range(0.001, 0.1, 0.001, 0.002, 200)
        self._loop_bw_win = RangeWidget(self._loop_bw_range, self.set_loop_bw,
                                        "loop_bw", "counter_slider", float)
        self.top_grid_layout.addWidget(self._loop_bw_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._d_factor_range = Range(0.1, 2, 0.1, 2, 200)
        self._d_factor_win = RangeWidget(self._d_factor_range,
                                         self.set_d_factor, "d_factor",
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._d_factor_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 3, 300))
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            3  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(9, 13)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['error', 't_inst', 't_avg', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(3):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 2, 0, 1,
                                       1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            100e3,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(fft_min, fft_max)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "red", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 2, 1,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5)
        self.qtgui_const_sink_x_0_0.set_x_axis(-1.5, 1.5)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(True)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 2, 2,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.fir_filter_xxx_0 = filter.fir_filter_ccf(decimation, (dec_taps))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.digital_symbol_sync_xx_0 = digital.symbol_sync_cc(
            digital.TED_MUELLER_AND_MULLER, sps, loop_bw, d_factor, ted_gain,
            1, 1,
            digital.constellation_bpsk().base(), digital.IR_MMSE_8TAP, 128,
            ([]))
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            loop_bw, 4, False)
        self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf(
            digital.constellation_calcdist(
                ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4,
                1).base())
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate * 25 * decimation,
                                                 True)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 127)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_float * 1,
            '/home/nacho/Desktop/Proyecto-Final/data/gqrx_20190914_121650_137100000_900001_fc.raw',
            False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/nacho/Desktop/Proyecto-Final/data/2019_09_14.s', False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_deinterleave_0 = blocks.deinterleave(
            gr.sizeof_float * 1, 1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((10, ))
        self.analog_rail_ff_0 = analog.rail_ff(-1, 1)
        self.analog_agc_xx_0_0_0 = analog.agc_ff(1e-5, 1, 0.5)
        self.analog_agc_xx_0_0_0.set_max_gain(4e3)
        self.analog_agc_xx_0_0 = analog.agc_ff(1e-5, 1, 0.5)
        self.analog_agc_xx_0_0.set_max_gain(4e3)
        self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1, 1)
        self.analog_agc_xx_0.set_max_gain(4e3)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.analog_agc_xx_0_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_agc_xx_0_0_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_rail_ff_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_deinterleave_0, 0),
                     (self.analog_agc_xx_0_0, 0))
        self.connect((self.blocks_deinterleave_0, 1),
                     (self.analog_agc_xx_0_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_deinterleave_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.digital_constellation_soft_decoder_cf_1, 0),
                     (self.analog_rail_ff_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_soft_decoder_cf_1, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.digital_symbol_sync_xx_0, 1),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.digital_symbol_sync_xx_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_symbol_sync_xx_0, 3),
                     (self.qtgui_time_sink_x_0, 2))
        self.connect((self.digital_symbol_sync_xx_0, 2),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.fir_filter_xxx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_symbol_sync_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
Esempio n. 12
0
    def __init__(self, args):
        gr.top_block.__init__(self, "File Atsc Rx", catch_exceptions=True)

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 4500000.0 / 286 * 684
        self.sps = sps = 1.1
        self.atsc_sym_rate = atsc_sym_rate = 4.5e6 / 286 * 684
        self.sample_rate = sample_rate = atsc_sym_rate * sps
        self.pilot_freq = pilot_freq = (6000000.0 - (symbol_rate / 2)) / 2
        self.oversampled_rate = oversampled_rate = atsc_sym_rate * sps
        self.center_freq = center_freq = 429e6
        self.capt_sample_rate = capt_sample_rate = 20e6

        ##################################################
        # Blocks
        ##################################################
        self.filter_fft_rrc_filter_0 = filter.fft_filter_ccc(
            1,
            firdes.root_raised_cosine(1, sample_rate, atsc_sym_rate / 2.0,
                                      0.1152, 50), 1)
        self.dtv_atsc_viterbi_decoder_0 = dtv.atsc_viterbi_decoder()
        # self.dtv_atsc_viterbi_decoder_0.set_processor_affinity([2])
        self.dtv_atsc_sync_0 = dtv.atsc_sync(oversampled_rate)
        self.dtv_atsc_rs_decoder_0 = dtv.atsc_rs_decoder()
        self.dtv_atsc_fs_checker_0 = dtv.atsc_fs_checker()
        self.dtv_atsc_fpll_0 = dtv.atsc_fpll(oversampled_rate)
        # self.dtv_atsc_fpll_0.set_processor_affinity([0])
        self.dtv_atsc_equalizer_0 = dtv.atsc_equalizer()
        self.dtv_atsc_derandomizer_0 = dtv.atsc_derandomizer()
        self.dtv_atsc_depad_0 = dtv.atsc_depad()
        self.dtv_atsc_deinterleaver_0 = dtv.atsc_deinterleaver()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(4096, True)
        # self.dc_blocker_xx_0.set_processor_affinity([1])
        self.blocks_interleaved_short_to_complex_0_0 = blocks.interleaved_short_to_complex(
            False, False, 32768)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_short * 1, args.infile, False, 0, 0)
        self.blocks_file_source_0_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                     args.outfile, False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.agc = analog.agc_ff(1e-5, 4.0, 1.0)
        self.agc.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.agc, 0), (self.dtv_atsc_sync_0, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.blocks_interleaved_short_to_complex_0_0, 0))
        self.connect((self.blocks_interleaved_short_to_complex_0_0, 0),
                     (self.filter_fft_rrc_filter_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.agc, 0))
        self.connect((self.dtv_atsc_deinterleaver_0, 0),
                     (self.dtv_atsc_rs_decoder_0, 0))
        self.connect((self.dtv_atsc_depad_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.dtv_atsc_derandomizer_0, 0),
                     (self.dtv_atsc_depad_0, 0))
        self.connect((self.dtv_atsc_equalizer_0, 0),
                     (self.dtv_atsc_viterbi_decoder_0, 0))
        self.connect((self.dtv_atsc_fpll_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.dtv_atsc_fs_checker_0, 0),
                     (self.dtv_atsc_equalizer_0, 0))
        self.connect((self.dtv_atsc_rs_decoder_0, 0),
                     (self.dtv_atsc_derandomizer_0, 0))
        self.connect((self.dtv_atsc_sync_0, 0),
                     (self.dtv_atsc_fs_checker_0, 0))
        self.connect((self.dtv_atsc_viterbi_decoder_0, 0),
                     (self.dtv_atsc_deinterleaver_0, 0))
        self.connect((self.filter_fft_rrc_filter_0, 0),
                     (self.dtv_atsc_fpll_0, 0))
Esempio n. 13
0
File: chu.py Progetto: argilo/gr-ham
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Chu")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1200000
        self.upconverter_lo_freq = upconverter_lo_freq = 125000000
        self.space_tone = space_tone = 2025
        self.offset = offset = 100000
        self.mark_tone = mark_tone = 2225
        self.gain = gain = 10
        self.decimation = decimation = samp_rate / 48000
        self.chu_freq = chu_freq = 3330000
        self.channel_rate = channel_rate = 4800

        ##################################################
        # Blocks
        ##################################################
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "48 kHz")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "4.8 kHz")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Data scope")
        self.GridAdd(self.nb, 2, 0, 1, 1)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label="USB tuner gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=50,
        	num_steps=125,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_gain_sizer, 1, 0, 1, 1)
        self._chu_freq_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.chu_freq,
        	callback=self.set_chu_freq,
        	label="CHU frequency",
        	choices=[3330000, 7850000, 14670000],
        	labels=['3.33 MHz', '7.85 MHz', '14.67 MHz'],
        	style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._chu_freq_chooser, 0, 0, 1, 1)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
        	self.nb.GetPage(1).GetWin(),
        	baseband_freq=(mark_tone + space_tone) / 2,
        	dynamic_range=50,
        	ref_level=-20,
        	ref_scale=2.0,
        	sample_rate=channel_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_1.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.nb.GetPage(0).GetWin(),
        	baseband_freq=chu_freq,
        	dynamic_range=50,
        	ref_level=-60,
        	ref_scale=2.0,
        	sample_rate=samp_rate / decimation,
        	fft_size=2048,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        	win=window.hamming,
        )
        self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.nb.GetPage(2).GetWin(),
        	title="Scope Plot",
        	sample_rate=channel_rate,
        	v_scale=1,
        	v_offset=0,
        	t_scale=0.050,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=2,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nb.GetPage(2).Add(self.wxgui_scopesink2_0.win)
        self.root_raised_cosine_filter_0 = filter.fir_filter_fff(1, firdes.root_raised_cosine(
        	1, channel_rate, 300, 0.35, 100))
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(chu_freq - offset + upconverter_lo_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(0, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_1 = filter.fir_filter_ccf(10, firdes.low_pass(
        	1000, samp_rate / 25, 200, 50, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(decimation, firdes.low_pass(
        	1, samp_rate, 20000, 5000, firdes.WIN_HAMMING, 6.76))
        self.ham_chu_decode_0 = ham.chu_decode()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass(
        	1, samp_rate / decimation, 200, 2800, 200, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0_0 = audio.sink(48000, "", True)
        self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate / decimation, analog.GR_COS_WAVE, -(space_tone + mark_tone) / 2, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -offset, 1, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(channel_rate / (3.1416*(mark_tone - space_tone)))
        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(3.1416 / 500, 1.8, -1.8)
        self.analog_agc_xx_0 = analog.agc_ff(1e-1, 0.02, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_2, 1))
        self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.low_pass_filter_1, 0), (self.wxgui_waterfallsink2_1, 0))
        self.connect((self.low_pass_filter_1, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0), (self.low_pass_filter_1, 0))
        self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_scopesink2_0, 1))
        self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.ham_chu_decode_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.root_raised_cosine_filter_0, 0))
Esempio n. 14
0
    def __init__(self, baud, bpf_trans, filter_len, fsk_hi_tone, fsk_lo_tone,
                 gain, gmu, hi, input_rate, low, mu):
        gr.hier_block2.__init__(
            self,
            "merapi_rx",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signaturev(3, 3, [
                gr.sizeof_gr_complex * 1, gr.sizeof_float * 1,
                gr.sizeof_short * 1
            ]),
        )
        self.message_port_register_hier_out("frame_out")
        self.message_port_register_hier_out("afsk")
        self.message_port_register_hier_out("hi_symb")
        self.message_port_register_hier_out("lo_symb")
        self.message_port_register_hier_out("softbits")

        ##################################################
        # Parameters
        ##################################################
        self.baud = baud
        self.bpf_trans = bpf_trans
        self.filter_len = filter_len
        self.fsk_hi_tone = fsk_hi_tone
        self.fsk_lo_tone = fsk_lo_tone
        self.gain = gain
        self.gmu = gmu
        self.hi = hi
        self.input_rate = input_rate
        self.low = low
        self.mu = mu

        ##################################################
        # Variables
        ##################################################
        self.ch_rate = ch_rate = 48e3
        self.sps = sps = int(ch_rate / baud)

        ##################################################
        # Blocks
        ##################################################
        self.root_raised_cosine_filter_1 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, sps * 1.0, 1.0, 0.7, 4 * sps))
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, sps * 1.0, 1.0, 0.7, 4 * sps))
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=2,
            decimation=sps,
            taps=None,
            fractional_bw=None,
        )
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(ch_rate /
                                                             input_rate,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.Merapi_frame_detect_0 = Merapi.frame_detect()
        self.fft_filter_xxx_0 = filter.fft_filter_fff(1, (firdes.band_pass(
            0.1, ch_rate, fsk_lo_tone - (bpf_trans / 2), fsk_hi_tone +
            (bpf_trans / 2), 1e3, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            2 * (1 + 0.0), 0.25 * gmu * gmu, mu, gmu, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_threshold_ff_0 = blocks.threshold_ff(low, hi, 0)
        self.blocks_tagged_stream_to_pdu_1 = blocks.tagged_stream_to_pdu(
            blocks.float_t, 'packet_len')
        self.blocks_tagged_stream_to_pdu_0_0_0 = blocks.tagged_stream_to_pdu(
            blocks.float_t, 'packet_len')
        self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu(
            blocks.float_t, 'packet_len')
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.float_t, 'packet_len')
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream(
            gr.sizeof_float, 1, 512, "packet_len")
        self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_float, 1, 512, "packet_len")
        self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_float, 1, 512, "packet_len")
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_float, 1, 512, "packet_len")
        self.blocks_rotator_cc_1 = blocks.rotator_cc(
            (-1.0 * fsk_hi_tone / ch_rate) * 2 * math.pi)
        self.blocks_rotator_cc_0_0 = blocks.rotator_cc(
            (-1.0 * fsk_lo_tone / ch_rate) * 2 * math.pi)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((gain, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            filter_len, 1.0 / filter_len, 4000)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_short, 2, sps,
                                                       0)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 0)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_burst_tagger_1 = blocks.burst_tagger(gr.sizeof_float)
        self.blocks_burst_tagger_1.set_true_tag('burst_start', True)
        self.blocks_burst_tagger_1.set_false_tag('burst_stop', False)

        self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_float)
        self.blocks_burst_tagger_0.set_true_tag('burst_start', True)
        self.blocks_burst_tagger_0.set_false_tag('burst_stop', False)

        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            ch_rate / (2 * math.pi * (10e3) / 8.0))
        self.analog_agc_xx_0 = analog.agc_ff(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)
        self.analog_agc2_xx_1 = analog.agc2_ff(0.5, 0.00001, 1.0, 1.0)
        self.analog_agc2_xx_1.set_max_gain(65536)
        self.analog_agc2_xx_0 = analog.agc2_ff(0.5, 0.00001, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self, 'softbits'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'),
                         (self, 'hi_symb'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'),
                         (self, 'lo_symb'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_1, 'pdus'),
                         (self, 'afsk'))
        self.msg_connect((self.Merapi_frame_detect_0, 'frame out'),
                         (self, 'frame_out'))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_agc2_xx_1, 0),
                     (self.blocks_stream_to_tagged_stream_0_0_0, 0))
        self.connect((self.analog_agc2_xx_1, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.blocks_burst_tagger_1, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_burst_tagger_0, 0),
                     (self.blocks_stream_to_tagged_stream_1, 0))
        self.connect((self.blocks_burst_tagger_0, 0), (self, 1))
        self.connect((self.blocks_burst_tagger_1, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_1, 0),
                     (self.analog_agc2_xx_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_delay_0, 0), (self, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_rotator_cc_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_rotator_cc_1, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_burst_tagger_0, 1))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.blocks_float_to_short_0, 0), (self, 2))
        self.connect((self.blocks_keep_m_in_n_0, 0),
                     (self.blocks_burst_tagger_1, 1))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_rotator_cc_0_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.blocks_rotator_cc_1, 0),
                     (self.root_raised_cosine_filter_1, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_1, 0),
                     (self.blocks_tagged_stream_to_pdu_1, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.Merapi_frame_detect_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.blocks_burst_tagger_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self, 0), (self.blocks_delay_0, 0))
        self.connect((self, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_agc_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.root_raised_cosine_filter_1, 0),
                     (self.blocks_complex_to_mag_1, 0))
Esempio n. 15
0
    def __init__(self):
        gr.top_block.__init__(self, "Merapi Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Merapi Test")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "merapi_test")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 44100

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=10,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate / 100,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.01)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(False)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.fft_filter_xxx_2 = filter.fft_filter_fff(1, (firdes.band_pass(
            1, samp_rate, 1360 - 300, 1360 + 300, 500, firdes.WIN_HAMMING)), 1)
        self.fft_filter_xxx_2.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_fff(10, (firdes.low_pass(
            1, samp_rate / 10, 20, 20, firdes.WIN_HAMMING)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/handiko/cv.wav', True)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(
            (-1360.0 / samp_rate) * 2 * math.pi)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.audio_sink_0 = audio.sink(samp_rate, '', True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            0.1 * samp_rate / (2 * math.pi * 500 / 8.0))
        self.analog_agc_xx_0 = analog.agc_ff(1e-2, 0.1, 0.1)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_rotator_cc_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.fft_filter_xxx_2, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.fft_filter_xxx_2, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
Esempio n. 16
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sr = sr = 3.5e6
        self.tw = tw = 10000
        self.samp_rate = samp_rate = sr
        self.rl = rl = -20
        self.gain = gain = 1
        self.co = co = 100000
        self.cf = cf = 100.3e6
        self.bw = bw = 2e6

        ##################################################
        # Blocks
        ##################################################
        self._gain_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.gain,
            callback=self.set_gain,
            label='gain',
            choices=[0.2, 0.4, 0.6, 0.8, 1, 1.5, 2, 2.5, 3, 3.5],
            labels=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        )
        self.Add(self._gain_chooser)
        _cf_sizer = wx.BoxSizer(wx.VERTICAL)
        self._cf_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_cf_sizer,
            value=self.cf,
            callback=self.set_cf,
            label='cf',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._cf_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_cf_sizer,
            value=self.cf,
            callback=self.set_cf,
            minimum=88.5e6,
            maximum=108.5e6,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_cf_sizer)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=cf,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Sample_Bandpass',
            peak_hold=False,
            win=window.hamming,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=441,
            decimation=2500,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            int(samp_rate / 250000),
            firdes.low_pass(4, samp_rate, co, tw, firdes.WIN_HAMMING, 6.76))
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            'sample.wav', 1, 44100, 8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((gain, ))
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=250000,
            audio_decimation=1,
        )
        self.analog_agc_xx_0 = analog.agc_ff(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)
        self.TekRSA_iq_stream_0_0 = TekRSA.iq_stream(cf, rl, bw, 1000000, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.TekRSA_iq_stream_0_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.TekRSA_iq_stream_0_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_agc_xx_0, 0))
Esempio n. 17
0
    def __init__(self, antenna=satnogs.not_set_antenna, bb_gain=satnogs.not_set_rx_bb_gain, bfo_freq=1e3, decoded_data_file_path='/tmp/.satnogs/data/data', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=1000, enable_iq_dump=0, file_path='test.txt', if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=100e6, rx_sdr_device='usrpb200', udp_IP='127.0.0.1', udp_port=16887, waterfall_file_path='/tmp/waterfall.dat', wpm=20, samp_rate_rx=satnogs.not_set_samp_rate_rx):
        gr.top_block.__init__(self, "CW Decoder")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.bb_gain = bb_gain
        self.bfo_freq = bfo_freq
        self.decoded_data_file_path = decoded_data_file_path
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.enable_iq_dump = enable_iq_dump
        self.file_path = file_path
        self.if_gain = if_gain
        self.iq_file_path = iq_file_path
        self.lo_offset = lo_offset
        self.ppm = ppm
        self.rf_gain = rf_gain
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.rx_sdr_device = rx_sdr_device
        self.udp_IP = udp_IP
        self.udp_port = udp_port
        self.waterfall_file_path = waterfall_file_path
        self.wpm = wpm
        self.samp_rate_rx = samp_rate_rx

        ##################################################
        # Variables
        ##################################################
        self.audio_samp_rate = audio_samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(audio_samp_rate, 0.0, 10, 1024, waterfall_file_path, 1)
        self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(udp_IP, udp_port, 1500)
        self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", rigctl_port, False, 1000, 1500)
        self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(file_path, audio_samp_rate, 1.0)
        self.satnogs_morse_decoder_0 = satnogs.morse_decoder(ord('#'), 3)
        self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, iq_file_path, False, enable_iq_dump)
        self.satnogs_frame_file_sink_0_0 = satnogs.frame_file_sink(decoded_data_file_path, 0)
        self.satnogs_cw_to_symbol_0 = satnogs.cw_to_symbol(audio_samp_rate/4, 0.4, 0.75, wpm)
        self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx))
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  audio_samp_rate/satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx),
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.handle_rx_dev_args(rx_sdr_device, dev_args) )
        self.osmosdr_source_0.set_sample_rate(satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx))
        self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0)
        self.osmosdr_source_0.set_freq_corr(ppm, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0)
        self.osmosdr_source_0.set_if_gain(satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0)
        self.osmosdr_source_0.set_bb_gain(satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0)
        self.osmosdr_source_0.set_antenna(satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0)
        self.osmosdr_source_0.set_bandwidth(satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), 0)

        self.low_pass_filter_0_0 = filter.fir_filter_fff(4, firdes.low_pass(
        	4, audio_samp_rate, 100, 100, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, audio_samp_rate, 2e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-2.0 * math.pi * (lo_offset / satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx)))
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(audio_samp_rate, analog.GR_COS_WAVE, bfo_freq, 1, 0)
        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(2*math.pi/400.0, 2*math.pi*2e3/audio_samp_rate, -2*math.pi*2e3/audio_samp_rate)
        self.analog_agc_xx_0 = analog.agc_ff(1e-3, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 0.0)
        self.analog_agc2_xx_0_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_cw_to_symbol_0, 'out'), (self.satnogs_morse_decoder_0, 'in'))
        self.msg_connect((self.satnogs_morse_decoder_0, 'out'), (self.satnogs_frame_file_sink_0_0, 'frame'))
        self.msg_connect((self.satnogs_morse_decoder_0, 'out'), (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq'))
        self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_agc_xx_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.satnogs_ogg_encoder_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_agc2_xx_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.satnogs_cw_to_symbol_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_iq_sink_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_waterfall_sink_0, 0))
        self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
Esempio n. 18
0
    def __init__(self):
        gr.top_block.__init__(self, "Vor Sim")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Vor Sim")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "vor_sim")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.angle = angle = 0
        self.samp_rate = samp_rate = 48e3
        self.angle_degree = angle_degree = angle * 1.0

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'RF Spectrum')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'VOR Baseband')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'REF/VAR Signal')
        self.tab_widget_3 = Qt.QWidget()
        self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_3)
        self.tab_grid_layout_3 = Qt.QGridLayout()
        self.tab_layout_3.addLayout(self.tab_grid_layout_3)
        self.tab.addTab(self.tab_widget_3, 'Bearing Estimation')
        self.top_layout.addWidget(self.tab)
        self.vor_generator_0 = vor_generator(
            am_carrier=5e3,
            angle_degree=angle_degree,
            samp_rate=samp_rate,
        )
        self.rational_resampler_xxx_2 = filter.rational_resampler_fff(
            interpolation=512,
            decimation=3000,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
            interpolation=512,
            decimation=3000,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=3000,
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=3000,
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            2048,  #size
            3e3,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(True)
        self.qtgui_time_sink_x_1.enable_grid(True)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tab_layout_2.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            2048,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2 * 1):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 1, 0,
                                         1, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = ['', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_3.addWidget(self._qtgui_number_sink_0_win)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            8192,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(0.1)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_1.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_1.addWidget(self._qtgui_freq_sink_x_1_win, 0, 0,
                                         1, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            8192,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(0.1)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0,
                                         1, 1)
        self.fft_vxx_0_0 = fft.fft_vfc(512, True, (window.blackmanharris(512)),
                                       1)
        self.fft_vxx_0 = fft.fft_vfc(512, True, (window.blackmanharris(512)),
                                     1)
        self.fft_filter_xxx_3 = filter.fft_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, 2e3, 1e3, firdes.WIN_BLACKMAN)),
            1)
        self.fft_filter_xxx_3.declare_sample_delay(0)
        self.fft_filter_xxx_2 = filter.fft_filter_ccc(
            1, (firdes.low_pass(-1, samp_rate, 2e3, 1e3, firdes.WIN_BLACKMAN)),
            1)
        self.fft_filter_xxx_2.declare_sample_delay(0)
        self.fft_filter_xxx_0_0 = filter.fft_filter_fff(
            1, (firdes.low_pass(1, 3e3, 60, 10, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0_0.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_fff(
            1, (firdes.low_pass(1, 3e3, 60, 10, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(32, True)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=0.01,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0 + 1.0j, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 512)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 512)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(
            gr.sizeof_float * 1, 512)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_float * 1, 512)
        self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_gr_complex * 1,
                                                   30)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex * 1, 30)
        self.blocks_rotator_cc_1 = blocks.rotator_cc(-(9960.0 / samp_rate) *
                                                     2 * math.pi)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(
            (-5e3 / samp_rate) * 2 * math.pi)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, 1000)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (180.0 / math.pi, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            10000, 1e-4, 4000)
        self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * 1, 512)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * 1, 512)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_arg_0_0 = blocks.complex_to_arg(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((0.0, ))
        self._angle_range = Range(-180, 180, 1, 0, 200)
        self._angle_win = RangeWidget(self._angle_range, self.set_angle,
                                      "angle", "counter_slider", float)
        self.top_layout.addWidget(self._angle_win)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            samp_rate / (2 * math.pi * 500 / 8.0))
        self.analog_agc_xx_0_0 = analog.agc_ff(1e-3, 1.0, 1.0)
        self.analog_agc_xx_0_0.set_max_gain(65536)
        self.analog_agc_xx_0 = analog.agc_ff(1e-3, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.analog_agc_xx_0_0, 0),
                     (self.qtgui_time_sink_x_1, 1))
        self.connect((self.analog_agc_xx_0_0, 0),
                     (self.rational_resampler_xxx_2, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_complex_to_arg_0_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.fft_filter_xxx_2, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_0, 0),
                     (self.blocks_complex_to_arg_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.blocks_rotator_cc_1, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.blocks_rotator_cc_1, 0), (self.fft_filter_xxx_3, 0))
        self.connect((self.blocks_skiphead_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_skiphead_0_0, 0),
                     (self.blocks_keep_one_in_n_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_skiphead_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.blocks_skiphead_0_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.blocks_rotator_cc_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0), (self.fft_filter_xxx_0_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.fft_filter_xxx_0_0, 0), (self.analog_agc_xx_0_0, 0))
        self.connect((self.fft_filter_xxx_2, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.fft_filter_xxx_3, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.fft_vxx_0_0, 0),
                     (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.dc_blocker_xx_0_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.rational_resampler_xxx_2, 0),
                     (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.vor_generator_0, 0), (self.blocks_throttle_0, 0))
Esempio n. 19
0
    def __init__(self,
                 antenna=satnogs.not_set_antenna,
                 bb_gain=satnogs.not_set_rx_bb_gain,
                 bfo_freq=1e3,
                 decoded_data_file_path='/tmp/.satnogs/data/data',
                 dev_args=satnogs.not_set_dev_args,
                 doppler_correction_per_sec=1000,
                 enable_iq_dump=0,
                 file_path='test.txt',
                 if_gain=satnogs.not_set_rx_if_gain,
                 iq_file_path='/tmp/iq.dat',
                 lo_offset=100e3,
                 ppm=0,
                 rf_gain=satnogs.not_set_rx_rf_gain,
                 rigctl_port=4532,
                 rx_freq=100e6,
                 rx_sdr_device='usrpb200',
                 samp_rate_rx=satnogs.not_set_samp_rate_rx,
                 udp_IP='127.0.0.1',
                 udp_port=16887,
                 waterfall_file_path='/tmp/waterfall.dat',
                 wpm=20):
        gr.top_block.__init__(self, "CW Decoder")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.bb_gain = bb_gain
        self.bfo_freq = bfo_freq
        self.decoded_data_file_path = decoded_data_file_path
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.enable_iq_dump = enable_iq_dump
        self.file_path = file_path
        self.if_gain = if_gain
        self.iq_file_path = iq_file_path
        self.lo_offset = lo_offset
        self.ppm = ppm
        self.rf_gain = rf_gain
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.rx_sdr_device = rx_sdr_device
        self.samp_rate_rx = samp_rate_rx
        self.udp_IP = udp_IP
        self.udp_port = udp_port
        self.waterfall_file_path = waterfall_file_path
        self.wpm = wpm

        ##################################################
        # Variables
        ##################################################
        self.audio_samp_rate = audio_samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.satnogs_multi_format_msg_sink_0 = satnogs.multi_format_msg_sink(
            1, False, True, '')
        self.satnogs_morse_decoder_0 = satnogs.morse_decoder(ord('#'), 3)
        self.satnogs_cw_to_symbol_0 = satnogs.cw_to_symbol(
            audio_samp_rate / 4, 0.4, 0.75, wpm, 0)
        self.low_pass_filter_0_0 = filter.fir_filter_fff(
            4,
            firdes.low_pass(4, audio_samp_rate, 100, 100, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, audio_samp_rate, 2e3, 1e3, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/mocha/Github/cherry_picking_grc/cw_demod/143229_iq-recording.dat',
            True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(
            2 * math.pi / 400.0, 2 * math.pi * 2e3 / audio_samp_rate,
            -2 * math.pi * 2e3 / audio_samp_rate)
        self.analog_agc_xx_0 = analog.agc_ff(1e-3, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_cw_to_symbol_0, 'out'),
                         (self.satnogs_morse_decoder_0, 'in'))
        self.msg_connect((self.satnogs_morse_decoder_0, 'out'),
                         (self.satnogs_multi_format_msg_sink_0, 'in'))
        self.connect((self.analog_agc_xx_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.satnogs_cw_to_symbol_0, 0))
Esempio n. 20
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.88e6
        self.freq_corr = freq_corr = 0
        self.freq = freq = 433e6
        self.cte = cte = -380e-3

        ##################################################
        # Blocks
        ##################################################
        _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_corr_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_corr_sizer,
            value=self.freq_corr,
            callback=self.set_freq_corr,
            label='freq_corr',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._freq_corr_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_corr_sizer,
            value=self.freq_corr,
            callback=self.set_freq_corr,
            minimum=-100,
            maximum=100,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_corr_sizer)
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_sizer,
            value=self.freq,
            callback=self.set_freq,
            label='freq',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_sizer,
            value=self.freq,
            callback=self.set_freq,
            minimum=420e6,
            maximum=434e6,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_sizer)
        _cte_sizer = wx.BoxSizer(wx.VERTICAL)
        self._cte_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_cte_sizer,
            value=self.cte,
            callback=self.set_cte,
            label='cte',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._cte_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_cte_sizer,
            value=self.cte,
            callback=self.set_cte,
            minimum=-1,
            maximum=1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_cte_sizer)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate,
            v_scale=500e-3,
            v_offset=1,
            t_scale=100e-6,
            ac_couple=False,
            xy_mode=False,
            num_inputs=2,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              '')
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(freq, 0)
        self.rtlsdr_source_0.set_freq_corr(freq_corr, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(10, 0)
        self.rtlsdr_source_0.set_if_gain(30, 0)
        self.rtlsdr_source_0.set_bb_gain(30, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 480e3, 48e3, firdes.WIN_HAMMING,
                            6.76))
        self.channels_quantizer_0 = channels.quantizer(2)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, ))
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 120)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_const_vxx_1 = blocks.add_const_vff((ord('0'), ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((cte, ))
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
            itemsize=gr.sizeof_char * 1,
            addr='127.0.0.1',
            port=3333,
            server=False,
        )
        self.analog_agc_xx_0 = analog.agc_ff(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.channels_quantizer_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.wxgui_scopesink2_0, 1))
        self.connect((self.blocks_add_const_vxx_1, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blks2_tcp_sink_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_const_vxx_1, 0))
        self.connect((self.channels_quantizer_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.channels_quantizer_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
Esempio n. 21
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Chu")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1200000
        self.upconverter_lo_freq = upconverter_lo_freq = 125000000
        self.space_tone = space_tone = 2025
        self.offset = offset = 100000
        self.mark_tone = mark_tone = 2225
        self.gain = gain = 10
        self.decimation = decimation = samp_rate / 48000
        self.chu_freq = chu_freq = 3330000
        self.channel_rate = channel_rate = 4800

        ##################################################
        # Blocks
        ##################################################
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "48 kHz")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "4.8 kHz")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Data scope")
        self.GridAdd(self.nb, 2, 0, 1, 1)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label="USB tuner gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=50,
            num_steps=125,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_gain_sizer, 1, 0, 1, 1)
        self._chu_freq_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.chu_freq,
            callback=self.set_chu_freq,
            label="CHU frequency",
            choices=[3330000, 7850000, 14670000],
            labels=['3.33 MHz', '7.85 MHz', '14.67 MHz'],
            style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._chu_freq_chooser, 0, 0, 1, 1)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
            self.nb.GetPage(1).GetWin(),
            baseband_freq=(mark_tone + space_tone) / 2,
            dynamic_range=50,
            ref_level=-20,
            ref_scale=2.0,
            sample_rate=channel_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
        )
        self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_1.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.nb.GetPage(0).GetWin(),
            baseband_freq=chu_freq,
            dynamic_range=50,
            ref_level=-60,
            ref_scale=2.0,
            sample_rate=samp_rate / decimation,
            fft_size=2048,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
            win=window.hamming,
        )
        self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.nb.GetPage(2).GetWin(),
            title="Scope Plot",
            sample_rate=channel_rate,
            v_scale=1,
            v_offset=0,
            t_scale=0.050,
            ac_couple=False,
            xy_mode=False,
            num_inputs=2,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(2).Add(self.wxgui_scopesink2_0.win)
        self.root_raised_cosine_filter_0 = filter.fir_filter_fff(
            1, firdes.root_raised_cosine(1, channel_rate, 300, 0.35, 100))
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(
            chu_freq - offset + upconverter_lo_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(0, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_1 = filter.fir_filter_ccf(
            10,
            firdes.low_pass(1000, samp_rate / 25, 200, 50, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            decimation,
            firdes.low_pass(1, samp_rate, 20000, 5000, firdes.WIN_HAMMING,
                            6.76))
        self.ham_chu_decode_0 = ham.chu_decode()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.band_pass_filter_0 = filter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, samp_rate / decimation, 200, 2800, 200,
                                     firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0_0 = audio.sink(48000, "", True)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate / decimation, analog.GR_COS_WAVE,
            -(space_tone + mark_tone) / 2, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -offset, 1, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            channel_rate / (3.1416 * (mark_tone - space_tone)))
        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(
            3.1416 / 500, 1.8, -1.8)
        self.analog_agc_xx_0 = analog.agc_ff(1e-1, 0.02, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.wxgui_waterfallsink2_1, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.wxgui_scopesink2_0, 1))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.ham_chu_decode_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
Esempio n. 22
0
    def __init__(self):
        gr.top_block.__init__(self, "HLG Receiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("HLG Receiver")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "cw_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1.024e6
        self.low_cut = low_cut = 500
        self.hi_cut = hi_cut = 1100
        self.freq = freq = 8.5427e6
        self.cfreq = cfreq = 8.5764e6

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'Narrow Band RF Spectrum/Spectrogram')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'AF Processing')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Time Domain Scope')
        self.top_grid_layout.addWidget(self.tab, 0,0,1,1)
        self._low_cut_range = Range(0, 700, 10, 500, 200)
        self._low_cut_win = RangeWidget(self._low_cut_range, self.set_low_cut, 'Low Cut (Hz)', "counter_slider", float)
        self.tab_grid_layout_1.addWidget(self._low_cut_win, 1,0,1,1)
        self._hi_cut_range = Range(900, 2000, 10, 1100, 200)
        self._hi_cut_win = RangeWidget(self._hi_cut_range, self.set_hi_cut, 'Hi Cut (Hz)', "counter_slider", float)
        self.tab_grid_layout_1.addWidget(self._hi_cut_win, 2,0,1,1)
        self._freq_range = Range(cfreq - samp_rate/2, cfreq + samp_rate/2, 1e2, 8.5427e6, 200)
        self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'VFO (Hz)', "counter_slider", float)
        self.top_layout.addWidget(self._freq_win)
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
                interpolation=24,
                decimation=48,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=48,
                decimation=1024,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	4096, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	freq, #fc
        	48e3, #bw
        	'', #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)
        
        if not False:
          self.qtgui_waterfall_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [6, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0.set_intensity_range(-150, -90)
        
        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 1,0,1,1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	8192*4, #size
        	48e3, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_win, 0,0,1,1)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f(
        	4096, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	24e3, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-160, -50)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(True)
        self.qtgui_freq_sink_x_1.set_fft_average(0.2)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)
        
        if not False:
          self.qtgui_freq_sink_x_1.disable_legend()
        
        if "float" == "float" or "float" == "msg_float":
          self.qtgui_freq_sink_x_1.set_plot_pos_half(not False)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_1.addWidget(self._qtgui_freq_sink_x_1_win, 0,0,1,1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	4096, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	freq, #fc
        	48e3, #bw
        	'', #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-150, -40)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,1)
        self.fft_filter_xxx_1 = filter.fft_filter_ccc(1, (firdes.complex_band_pass(50,48e3,low_cut,hi_cut,5e2,firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.blocks_wavfile_source_0 = blocks.wavfile_source('/home/handiko/HDSDR_20140419_185856Z_8500kHz_RF.wav', False)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink('HLG.wav', 1, 48000, 16)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, 48e3,True)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-((freq-cfreq)/samp_rate)*math.pi)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_agc_xx_0 = analog.agc_ff(1e-2, 0.1, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.analog_agc_xx_0, 0), (self.blocks_wavfile_sink_0, 0))    
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.analog_agc_xx_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_rotator_cc_0, 0))    
        self.connect((self.blocks_rotator_cc_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_waterfall_sink_x_0, 0))    
        self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.fft_filter_xxx_1, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.fft_filter_xxx_1, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.qtgui_freq_sink_x_1, 0))    
Esempio n. 23
0
    def __init__(self):
        gr.top_block.__init__(self, "Rtl Airband")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rtl Airband")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "rtl_airband")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.048e6
        self.freq_corr = freq_corr = 0
        self.freq = freq = 131.55e6

        ##################################################
        # Blocks
        ##################################################
        self._freq_corr_range = Range(-10e3, 10e3, 1, 0, 200)
        self._freq_corr_win = RangeWidget(self._freq_corr_range, self.set_freq_corr, "freq_corr", "counter_slider", float)
        self.top_layout.addWidget(self._freq_corr_win)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=24000,
                decimation=192000,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=192000,
                decimation=int(samp_rate),
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	8192, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	freq+freq_corr, #fc
        	192e3, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)
        
        if not False:
          self.qtgui_waterfall_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [6, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0.set_intensity_range(-100, -40)
        
        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	4096, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	192e3, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -20)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq+freq_corr, 0)
        self.osmosdr_source_0.set_freq_corr(70, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(45, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.fft_filter_xxx_0 = filter.fft_filter_fff(1, (firdes.low_pass(7,24e3,3e3,1e2,firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.audio_sink_0 = audio.sink(24000, '', True)
        self.analog_agc_xx_0 = analog.agc_ff(4e-1, 0.01, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.fft_filter_xxx_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.dc_blocker_xx_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.analog_agc_xx_0, 0))    
        self.connect((self.fft_filter_xxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_complex_to_mag_0, 0))    
Esempio n. 24
0
    def __init__(self):
        gr.top_block.__init__(self, "Message Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Message Test")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "message_test")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 16
        self.nfilts = nfilts = 32
        self.timing_loop_bw = timing_loop_bw = 62.8e-3
        self.taps_0 = taps_0 = [1.0, 0.25 - 0.25j, 0.50 + 0.10j, -0.3 + 0.2j]
        self.taps = taps = [
            1.0 + 0.0j,
        ]
        self.samp_rate_0 = samp_rate_0 = 10e3
        self.samp_rate = samp_rate = 32e3
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts)
        self.phase_bw = phase_bw = 62.8e-3
        self.lpf_transition_width = lpf_transition_width = 500
        self.lpf_cutoff_freq = lpf_cutoff_freq = 3e3
        self.excess_bw = excess_bw = 0.35
        self.eq_gain = eq_gain = 10e-3
        self.center_freq = center_freq = 5e3
        self.bpsk = bpsk = digital.constellation_rect(
            ([1 + 1j, -1 + 1j, -1 - 1j, 1 - 1j]), ([0, 1, 2, 3]), 4, 2, 2, 1,
            1).base()
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "Test: Downconersion",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_1_0.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_1_0.enable_control_panel(False)
        self.qtgui_time_sink_x_1_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_1_0.disable_legend()

        labels = [
            'Down_Baseband', 'Bandpass', 'Passband(Real)', 'Passband(Img)', '',
            '', '', '', '', ''
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "Test: Upconersion",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(False)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(False)
        self.qtgui_time_sink_x_1.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

        labels = [
            'Baseband', 'Bandpass', 'Passband(Real)', 'Passband(Img)', '', '',
            '', '', '', ''
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_freq_sink_x_1_1 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Down Conversion and LPF",  #name
            3  #number of inputs
        )
        self.qtgui_freq_sink_x_1_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1_1.set_y_axis(-100, 0)
        self.qtgui_freq_sink_x_1_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_1_1.enable_autoscale(True)
        self.qtgui_freq_sink_x_1_1.enable_grid(False)
        self.qtgui_freq_sink_x_1_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1_1.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_1_1.set_plot_pos_half(not True)

        labels = ['Bandpass', 'IF', 'LPF', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(3):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_1_1_win)
        self.low_pass_filter_0_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, lpf_cutoff_freq,
                            lpf_transition_width, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, lpf_cutoff_freq,
                            lpf_transition_width, firdes.WIN_HAMMING, 6.76))
        self.digital_pfb_clock_sync_xxx_0_0_0 = digital.pfb_clock_sync_ccf(
            sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=bpsk,
            differential=False,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=excess_bw,
            verbose=True,
            log=False,
        )
        self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(
            bpsk)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, 10e3,
                                                 True)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            2, 8, "", False, gr.GR_MSB_FIRST)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((2, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/peter/Desktop/acoustic_radio/Testings/bin_test.txt', True)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/peter/Desktop/acoustic_radio/Testings/bin_test_qpsk_NOpacketEncode_output.txt',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_float_2 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SIN_WAVE, center_freq, -1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, center_freq, 1, 0)
        self.analog_agc_xx_0 = analog.agc_ff(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 0))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_complex_to_float_2, 0),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.qtgui_time_sink_x_1_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.qtgui_freq_sink_x_1_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.qtgui_time_sink_x_1, 1))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0),
                     (self.qtgui_freq_sink_x_1_1, 1))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.blocks_complex_to_float_2, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0_0, 0),
                     (self.digital_constellation_decoder_cb_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_1_1, 2))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_float_to_complex_0, 1))
Esempio n. 25
0
    def __init__(self, samp_rate=48e3):
        gr.top_block.__init__(self, "Audio Input/Ouput")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Audio Input/Ouput")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "audio_io")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.samp_rate = samp_rate

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.01)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -40)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not False)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "red", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [0.75, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.audio_source_0 = audio.source(int(samp_rate / 2), '', True)
        self.audio_sink_0 = audio.sink(int(samp_rate), '', True)
        self.analog_agc_xx_0 = analog.agc_ff(1e-2, 0.1, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.audio_source_0, 0), (self.analog_agc_xx_0, 0))
Esempio n. 26
0
    def __init__(self):
        gr.top_block.__init__(self, "Atsc2 Receive")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Atsc2 Receive")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "atsc2_receive")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.tuning_offset = tuning_offset = 0
        self.center_freq = center_freq = 195e6
        self.radio_freq = radio_freq = center_freq + tuning_offset
        self.processing_rate = processing_rate = 6.25e6
        self.lna_gain = lna_gain = 14
        self.hw_sample_rate = hw_sample_rate = 10e6
        self.freq_min = freq_min = -90

        ##################################################
        # Blocks
        ##################################################
        self._lna_gain_range = Range(0, 21, 1, 14, 200)
        self._lna_gain_win = RangeWidget(self._lna_gain_range,
                                         self.set_lna_gain, 'LNA Gain',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._lna_gain_win, 0, 3, 1, 1)
        self._freq_min_range = Range(-140, 70, 1, -90, 200)
        self._freq_min_win = RangeWidget(self._freq_min_range,
                                         self.set_freq_min,
                                         'Low dB Display Cutoff',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_min_win, 3, 0, 1, 5)
        self._center_freq_tool_bar = Qt.QToolBar(self)
        self._center_freq_tool_bar.addWidget(
            Qt.QLabel('Center Frequency' + ": "))
        self._center_freq_line_edit = Qt.QLineEdit(str(self.center_freq))
        self._center_freq_tool_bar.addWidget(self._center_freq_line_edit)
        self._center_freq_line_edit.returnPressed.connect(
            lambda: self.set_center_freq(
                eng_notation.str_to_num(
                    str(self._center_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._center_freq_tool_bar, 0, 2, 1, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=625,
            decimation=1000,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            center_freq,  #fc
            hw_sample_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(freq_min, -10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 1, 0,
                                       2, 5)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'airspy')
        self.osmosdr_source_0.set_sample_rate(hw_sample_rate)
        self.osmosdr_source_0.set_center_freq(radio_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(lna_gain, 0)
        self.osmosdr_source_0.set_if_gain(lna_gain, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.dtv_atsc_viterbi_decoder_0 = dtv.atsc_viterbi_decoder()
        self.dtv_atsc_sync_0 = dtv.atsc_sync(11.8385e6)
        self.dtv_atsc_rx_filter_0 = dtv.atsc_rx_filter(processing_rate, 1.1)
        self.dtv_atsc_rs_decoder_0 = dtv.atsc_rs_decoder()
        self.dtv_atsc_fs_checker_0 = dtv.atsc_fs_checker()
        self.dtv_atsc_fpll_0 = dtv.atsc_fpll(11.8385e6)
        self.dtv_atsc_equalizer_0 = dtv.atsc_equalizer()
        self.dtv_atsc_derandomizer_0 = dtv.atsc_derandomizer()
        self.dtv_atsc_depad_0 = dtv.atsc_depad()
        self.dtv_atsc_deinterleaver_0 = dtv.atsc_deinterleaver()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(4096, True)
        self.blocks_probe_rate_0 = blocks.probe_rate(gr.sizeof_char * 1, 500.0,
                                                     0.15)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.analog_agc_xx_0 = analog.agc_ff(1e-5, 4.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_probe_rate_0, 'rate'),
                         (self.blocks_message_debug_0, 'print'))
        self.connect((self.analog_agc_xx_0, 0), (self.dtv_atsc_sync_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.dtv_atsc_deinterleaver_0, 0),
                     (self.dtv_atsc_rs_decoder_0, 0))
        self.connect((self.dtv_atsc_depad_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.dtv_atsc_depad_0, 0), (self.blocks_probe_rate_0, 0))
        self.connect((self.dtv_atsc_derandomizer_0, 0),
                     (self.dtv_atsc_depad_0, 0))
        self.connect((self.dtv_atsc_equalizer_0, 0),
                     (self.dtv_atsc_viterbi_decoder_0, 0))
        self.connect((self.dtv_atsc_fpll_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.dtv_atsc_fs_checker_0, 0),
                     (self.dtv_atsc_equalizer_0, 0))
        self.connect((self.dtv_atsc_rs_decoder_0, 0),
                     (self.dtv_atsc_derandomizer_0, 0))
        self.connect((self.dtv_atsc_rx_filter_0, 0), (self.dtv_atsc_fpll_0, 0))
        self.connect((self.dtv_atsc_sync_0, 0),
                     (self.dtv_atsc_fs_checker_0, 0))
        self.connect((self.dtv_atsc_viterbi_decoder_0, 0),
                     (self.dtv_atsc_deinterleaver_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.dtv_atsc_rx_filter_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
Esempio n. 27
0
    def __init__(self):
        gr.top_block.__init__(self, "COMMUNICATIONS-RECEIVER")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("COMMUNICATIONS-RECEIVER")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "commrx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.upconv = upconv = 0
        self.rit = rit = 0
        self.ften = ften = 50000000
        self.fsel = fsel = 0
        self.fone = fone = 5000000
        self.fhun = fhun = 100000000
        self.squelch = squelch = -70
        self.scanw = scanw = 1000000
        self.samp_rate = samp_rate = 1200000
        self.msel = msel = 1
        self.gain = gain = 35
        self.freq = freq = fhun + ften + fone + fsel + rit - 100000
        self.corr = corr = 3
        self.FREQUENCY = FREQUENCY = (
            (upconv + fhun + ften + fone + fsel + rit) / 1000000)

        ##################################################
        # Blocks
        ##################################################
        self._squelch_range = Range(-80, -20, 1, -70, 50)
        self._squelch_win = RangeWidget(self._squelch_range, self.set_squelch,
                                        "squelch", "dial", float)
        self.top_grid_layout.addWidget(self._squelch_win, 5, 3, 1, 1)
        self._scanw_range = Range(10000, 1000000, 10000, 1000000, 50)
        self._scanw_win = RangeWidget(self._scanw_range, self.set_scanw,
                                      "scanw", "counter", float)
        self.top_grid_layout.addWidget(self._scanw_win, 6, 0, 1, 2)
        self._msel_options = (
            0,
            1,
            2,
            3,
            4,
        )
        self._msel_labels = (
            "AM",
            "NFM",
            "WFM",
            "USB",
            "LSB",
        )
        self._msel_group_box = Qt.QGroupBox("MODE")
        self._msel_box = Qt.QVBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._msel_button_group = variable_chooser_button_group()
        self._msel_group_box.setLayout(self._msel_box)
        for i, label in enumerate(self._msel_labels):
            radio_button = Qt.QRadioButton(label)
            self._msel_box.addWidget(radio_button)
            self._msel_button_group.addButton(radio_button, i)
        self._msel_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._msel_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._msel_options.index(i)))
        self._msel_callback(self.msel)
        self._msel_button_group.buttonClicked[int].connect(
            lambda i: self.set_msel(self._msel_options[i]))
        self.top_grid_layout.addWidget(self._msel_group_box, 1, 3, 1, 1)
        self._gain_range = Range(0, 50, 1, 35, 50)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain",
                                     "dial", float)
        self.top_grid_layout.addWidget(self._gain_win, 4, 3, 1, 1)
        _upconv_check_box = Qt.QCheckBox("UPCONVERTER")
        self._upconv_choices = {True: -125000000, False: 0}
        self._upconv_choices_inv = dict(
            (v, k) for k, v in self._upconv_choices.iteritems())
        self._upconv_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _upconv_check_box, "setChecked",
            Qt.Q_ARG("bool", self._upconv_choices_inv[i]))
        self._upconv_callback(self.upconv)
        _upconv_check_box.stateChanged.connect(
            lambda i: self.set_upconv(self._upconv_choices[bool(i)]))
        self.top_grid_layout.addWidget(_upconv_check_box, 1, 4, 1, 1)
        self._rit_range = Range(-500, 500, 10, 0, 50)
        self._rit_win = RangeWidget(self._rit_range, self.set_rit, "RIT",
                                    "dial", float)
        self.top_grid_layout.addWidget(self._rit_win, 2, 1, 1, 1)
        self.qtgui_sink_x_0 = qtgui.sink_c(
            512,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            (freq + 100000),  #fc
            scanw,  #bw
            "",  #name
            False,  #plotfreq
            True,  #plotwaterfall
            False,  #plottime
            False,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win, 5, 0, 1, 2)

        self.qtgui_sink_x_0.enable_rf_freq(True)

        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq + 100000,  #fc
            scanw,  #bw
            "RF",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_control_panel(True)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "green", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 4, 0, 1,
                                       2)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "RTL2838UHIDIR")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(corr, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(samp_rate, 0)

        (self.osmosdr_source_0).set_min_output_buffer(8)
        (self.osmosdr_source_0).set_max_output_buffer(32)
        self.msel1 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=1,
            num_outputs=5,
            input_index=0,
            output_index=msel,
        )
        self.low_pass_filter_0_1 = filter.fir_filter_ccf(
            5,
            firdes.low_pass(1, samp_rate, 75000, 25000, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            25,
            firdes.low_pass(1, samp_rate, 5000, 5000, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            25,
            firdes.low_pass(1, samp_rate, 7500, 5000, firdes.WIN_HAMMING,
                            6.76))
        self._ften_range = Range(0, 90000000, 10000000, 50000000, 50)
        self._ften_win = RangeWidget(self._ften_range, self.set_ften, "10s",
                                     "dial", float)
        self.top_grid_layout.addWidget(self._ften_win, 1, 0, 1, 1)
        self._fsel_range = Range(0, 999000, 1000, 0, 1000)
        self._fsel_win = RangeWidget(self._fsel_range, self.set_fsel, "fsel",
                                     "counter_slider", float)
        self.top_grid_layout.addWidget(self._fsel_win, 0, 0, 1, 2)
        self._fone_range = Range(0, 9000000, 1000000, 5000000, 50)
        self._fone_win = RangeWidget(self._fone_range, self.set_fone, "1s",
                                     "dial", float)
        self.top_grid_layout.addWidget(self._fone_win, 1, 1, 1, 1)
        self._fhun_range = Range(0, 2000000000, 100000000, 100000000, 50)
        self._fhun_win = RangeWidget(self._fhun_range, self.set_fhun, "100s",
                                     "counter", float)
        self.top_grid_layout.addWidget(self._fhun_win, 2, 0, 1, 1)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.band_pass_filter_0_0 = filter.fir_filter_ccc(
            25,
            firdes.complex_band_pass(1, samp_rate, -2800, 200, 1000,
                                     firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0 = filter.fir_filter_ccc(
            25,
            firdes.complex_band_pass(1, samp_rate, 200, 2800, 1000,
                                     firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.asel = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=5,
            num_outputs=1,
            input_index=msel,
            output_index=0,
        )
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=samp_rate / 5,
            audio_decimation=5,
        )
        self.analog_simple_squelch_cc_4 = analog.simple_squelch_cc(squelch, 1)
        self.analog_simple_squelch_cc_3 = analog.simple_squelch_cc(squelch, 1)
        self.analog_simple_squelch_cc_2 = analog.simple_squelch_cc(squelch, 1)
        self.analog_simple_squelch_cc_1 = analog.simple_squelch_cc(squelch, 1)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -100000, 1, 0)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=48000,
            quad_rate=samp_rate / 25,
            tau=75e-6,
            max_dev=5.0e3,
        )
        self.analog_agc_xx_0_1 = analog.agc_ff(1e-1, 0.02, 1.0)
        self.analog_agc_xx_0_1.set_max_gain(65536)
        self.analog_agc_xx_0_0 = analog.agc_ff(1e-1, 0.02, 1.0)
        self.analog_agc_xx_0_0.set_max_gain(65536)
        self.analog_agc_xx_0 = analog.agc_ff(1e-1, 0.02, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)
        self._FREQUENCY_tool_bar = Qt.QToolBar(self)

        if None:
            self._FREQUENCY_formatter = None
        else:
            self._FREQUENCY_formatter = lambda x: x

        self._FREQUENCY_tool_bar.addWidget(Qt.QLabel("FREQUENCY" + ": "))
        self._FREQUENCY_label = Qt.QLabel(
            str(self._FREQUENCY_formatter(self.FREQUENCY)))
        self._FREQUENCY_tool_bar.addWidget(self._FREQUENCY_label)
        self.top_grid_layout.addWidget(self._FREQUENCY_tool_bar, 3, 0, 1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.asel, 0))
        self.connect((self.analog_agc_xx_0_0, 0), (self.asel, 3))
        self.connect((self.analog_agc_xx_0_1, 0), (self.asel, 4))
        self.connect((self.analog_nbfm_rx_0, 0), (self.asel, 1))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.analog_simple_squelch_cc_1, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.analog_simple_squelch_cc_2, 0),
                     (self.analog_wfm_rcv_0, 0))
        self.connect((self.analog_simple_squelch_cc_3, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.analog_simple_squelch_cc_4, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.asel, 2))
        self.connect((self.asel, 0), (self.audio_sink_0, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.analog_simple_squelch_cc_3, 0))
        self.connect((self.band_pass_filter_0_0, 0),
                     (self.analog_simple_squelch_cc_4, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.analog_agc_xx_0_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.analog_agc_xx_0_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.msel1, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_simple_squelch_cc_1, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.low_pass_filter_0_1, 0),
                     (self.analog_simple_squelch_cc_2, 0))
        self.connect((self.msel1, 3), (self.band_pass_filter_0, 0))
        self.connect((self.msel1, 4), (self.band_pass_filter_0_0, 0))
        self.connect((self.msel1, 1), (self.low_pass_filter_0, 0))
        self.connect((self.msel1, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.msel1, 2), (self.low_pass_filter_0_1, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
Esempio n. 28
0
    def test_002(self):
        ''' Test the floating point AGC loop (single rate input) '''
        tb = self.tb

        expected_result = (
            7.2191943445432116e-07,
            58.837181091308594,
            89.700050354003906,
            81.264183044433594,
            45.506141662597656,
            4.269894304798072e-07,
            -42.948936462402344,
            -65.50335693359375,
            -59.368724822998047,
            -33.261005401611328,
            -4.683740257860336e-07,
            31.423542022705078,
            47.950984954833984,
            43.485683441162109,
            24.378345489501953,
            5.7254135299444897e-07,
            -23.062990188598633,
            -35.218441009521484,
            -31.964075088500977,
            -17.934831619262695,
            -5.0591745548445033e-07,
            16.998210906982422,
            25.982204437255859,
            23.606258392333984,
            13.260685920715332,
            4.9936483037527069e-07,
            -12.59880542755127,
            -19.28221321105957,
            -17.54347038269043,
            -9.8700437545776367,
            -4.188150626305287e-07,
            9.4074573516845703,
            14.422011375427246,
            13.145503044128418,
            7.41046142578125,
            3.8512698097292741e-07,
            -7.0924453735351562,
            -10.896408081054688,
            -9.9552040100097656,
            -5.6262712478637695,
            -3.1982864356905338e-07,
            5.4131259918212891,
            8.3389215469360352,
            7.6409502029418945,
            4.3320145606994629,
            2.882407841298118e-07,
            -4.194943904876709,
            -6.4837145805358887,
            -5.9621825218200684,
            -3.3931560516357422)

        sampling_freq = 100
        src1 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE,
                                   sampling_freq * 0.10, 100.0)
        dst1 = blocks.vector_sink_f ()
        head = blocks.head (gr.sizeof_float, int (5*sampling_freq * 0.10))

        agc = analog.agc_ff(1e-3, 1, 1)

        tb.connect (src1, head)
        tb.connect (head, agc)
        tb.connect (agc, dst1)

        tb.run ()
        dst_data = dst1.data ()
        self.assertFloatTuplesAlmostEqual (expected_result, dst_data, 4)
Esempio n. 29
0
    def __init__(self, mon_id, audio_port):
        gr.top_block.__init__(self, "EAS/SAME Monitor")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8000

        ##################################################
        # Blocks
        ##################################################

        # Resampler from input rate (44.1k) to internal rate (8k)
        self.rational_resampler_44k = filter.rational_resampler_fff(
                interpolation=80,
                decimation=441,
        )

        # Resampler from 8000 Hz to 4166 2/3rd Hz to deal with SAME's weird parameters
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=50,
                decimation=96,
                taps=None,
                fractional_bw=None,
        )

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcc(1, (firdes.low_pass(1, samp_rate, 600, 100)), 1822.916667, samp_rate)
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=8,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.01,
        	freq_error=0.0,
        	verbose=True,
        	log=False,
        )
        self.src = audio.source(44100, "eas_mon_%s:in" % (mon_id), True)
        self.agc = analog.agc_ff(0.0001, 0.1, 1.0)
        #self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(-50, 0.0001, 0)
        self.msg_queue = gr.msg_queue(10)
        self.same_dec_0 = same.same_dec(self.msg_queue)

        self.tone_det_0 = fft.goertzel_fc(samp_rate, samp_rate / 10, 853)
        self.tone_det_1 = fft.goertzel_fc(samp_rate, samp_rate / 10, 960)
        self.tone_det_2 = fft.goertzel_fc(samp_rate, samp_rate / 10, 1050)
        self.wat_thresh_msg = same.wat_thresh_msg(self.msg_queue, 1, 0.05, 0.01)

        #self.avg_audio_level = analog.probe_avg_mag_sqrd_ff(-50)
        #self.level_thresh_msg = same.level_thresh_msg(self.msg_queue, 1, 3, db_to_abs(-30), db_to_abs(-40))

        self.audio_sink_converter = blocks.float_to_short(1, 3276)
        self.audio_sink = blocks.udp_sink(2, '127.0.0.1', audio_port)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.src, 0), (self.rational_resampler_44k, 0))
        self.connect((self.rational_resampler_44k, 0), (self.agc, 0))
        #self.connect((self.agc, 0), (self.analog_pwr_squelch_xx_0, 0))

        #self.connect((self.analog_pwr_squelch_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.agc, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.digital_gmsk_demod_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0), (self.same_dec_0, 0))

        self.connect((self.agc, 0), (self.tone_det_0, 0), (self.wat_thresh_msg, 0))
        self.connect((self.agc, 0), (self.tone_det_1, 0), (self.wat_thresh_msg, 1))
        self.connect((self.agc, 0), (self.tone_det_2, 0), (self.wat_thresh_msg, 2))
        #self.connect((self.agc, 0), (self.avg_audio_level, 0), (self.level_thresh_msg, 0))

        self.connect((self.agc, 0), (self.audio_sink_converter, 0), (self.audio_sink, 0))

        self._watcher = _queue_watcher_thread(self.msg_queue, mon_id, audio_port)