Ejemplo n.º 1
0
  def __init__(self,delay_num,delay_denom):
    gr.hier_block2.__init__(self,"moms",
      gr.io_signature(1,1,gr.sizeof_gr_complex),
      gr.io_signature(1,1,gr.sizeof_gr_complex))

    cmplx_to_real  = blocks.complex_to_real()
    cmplx_to_img   = blocks.complex_to_imag()

    iirf_real = filter.iir_filter_ffd([1.5],[1, -0.5])
    self.moms_real = moms_ff()
    self.moms_real.set_init_ip_fraction(delay_num,delay_denom)

    iirf_imag = filter.iir_filter_ffd([1.5],[1, -0.5])
    self.moms_imag = moms_ff()
    self.moms_imag.set_init_ip_fraction(delay_num,delay_denom)

    float_to_cmplx = blocks.float_to_complex()

    self.connect((self,0),            (cmplx_to_real,0))
    self.connect((self,0),            (cmplx_to_img,0))
    self.connect((cmplx_to_real,0),   (iirf_real,0))
    self.connect((cmplx_to_img,0),    (iirf_imag,0))
    self.connect((iirf_real,0),       (self.moms_real,0))
    self.connect((iirf_imag,0),       (self.moms_imag,0))
    self.connect((self.moms_real,0),  (float_to_cmplx,0))
    self.connect((self.moms_imag,0),  (float_to_cmplx,1))
    self.connect((float_to_cmplx,0),  (self,0))
Ejemplo n.º 2
0
    def __init__(self, delay_num, delay_denom):
        gr.hier_block2.__init__(self, "moms",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        cmplx_to_real = blocks.complex_to_real()
        cmplx_to_img = blocks.complex_to_imag()

        iirf_real = filter.iir_filter_ffd([1.5], [1, -0.5])
        self.moms_real = moms_ff()
        self.moms_real.set_init_ip_fraction(delay_num, delay_denom)

        iirf_imag = filter.iir_filter_ffd([1.5], [1, -0.5])
        self.moms_imag = moms_ff()
        self.moms_imag.set_init_ip_fraction(delay_num, delay_denom)

        float_to_cmplx = blocks.float_to_complex()

        self.connect((self, 0), (cmplx_to_real, 0))
        self.connect((self, 0), (cmplx_to_img, 0))
        self.connect((cmplx_to_real, 0), (iirf_real, 0))
        self.connect((cmplx_to_img, 0), (iirf_imag, 0))
        self.connect((iirf_real, 0), (self.moms_real, 0))
        self.connect((iirf_imag, 0), (self.moms_imag, 0))
        self.connect((self.moms_real, 0), (float_to_cmplx, 0))
        self.connect((self.moms_imag, 0), (float_to_cmplx, 1))
        self.connect((float_to_cmplx, 0), (self, 0))
Ejemplo n.º 3
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-I", "--audio-input", type="string", default="",
                          help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-O", "--audio-output", type="string", default="",
                          help="pcm output device name")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=192000,
                          help="set sample rate to RATE (192000)")
        parser.add_option("-f", "--frequency", type="eng_float", default=45000)
        parser.add_option("-a", "--amplitude", type="eng_float", default=0.5)

        (options, args) = parser.parse_args ()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        ampl = float(options.amplitude)
        if ampl > 1.0: ampl = 1.0

        to_real = blocks.complex_to_real()
        to_imag = blocks.complex_to_imag()

        src = audio.source (sample_rate, options.audio_input)
        firdes_taps = filter.firdes.low_pass_2(1, 1, 0.2, 0.1, 60)
        converter = filter.freq_xlating_fir_filter_fcf ( 1, firdes_taps, 0, sample_rate )
        converter.set_center_freq(0 - options.frequency)
        dst = audio.sink (sample_rate, options.audio_output, True)

        #self.connect(src, converter, to_real, dst)
        self.connect(src, converter)
        self.connect(converter, to_real, (dst,0))
        self.connect(converter, to_imag, (dst,1))
Ejemplo n.º 4
0
def test_complex_to_imag():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    complextoimag = blocks.complex_to_imag()
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, complextoimag, probe)

    return top, probe
Ejemplo n.º 5
0
def test_complex_to_imag():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    complextoimag = blocks.complex_to_imag()
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, complextoimag, probe)

    return top, probe
Ejemplo n.º 6
0
 def test_complex_to_imag(self):
     src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j)
     expected_data = (2.0, 4.0, 6.0, 8.0, 10.0)
     src = blocks.vector_source_c(src_data)
     op = blocks.complex_to_imag()
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
Ejemplo n.º 7
0
 def test_complex_to_imag(self):
     src_data = (1 + 2j, 3 + 4j, 5 + 6j, 7 + 8j, 9 + 10j)
     expected_data = (2.0, 4.0, 6.0, 8.0, 10.0)
     src = blocks.vector_source_c(src_data)
     op = blocks.complex_to_imag()
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
Ejemplo n.º 8
0
    def connect_audio_stage(self, input_port):
        stereo_rate = self.demod_rate
        normalizer = TWO_PI / stereo_rate
        pilot_tone = 19000
        pilot_low = pilot_tone * 0.9
        pilot_high = pilot_tone * 1.1

        def make_audio_filter():
            return grfilter.fir_filter_fff(
                stereo_rate // self.__audio_int_rate,  # decimation
                firdes.low_pass(1.0, stereo_rate, 15000, 5000,
                                firdes.WIN_HAMMING))

        stereo_pilot_filter = grfilter.fir_filter_fcc(
            1,  # decimation
            firdes.complex_band_pass(1.0, stereo_rate, pilot_low, pilot_high,
                                     300))  # TODO magic number from gqrx
        stereo_pilot_pll = analog.pll_refout_cc(
            0.001,  # TODO magic number from gqrx
            normalizer * pilot_high,
            normalizer * pilot_low)
        stereo_pilot_doubler = blocks.multiply_cc()
        stereo_pilot_out = blocks.complex_to_imag()
        difference_channel_mixer = blocks.multiply_ff()
        difference_channel_filter = make_audio_filter()
        mono_channel_filter = make_audio_filter()
        mixL = blocks.add_ff(1)
        mixR = blocks.sub_ff(1)

        # connections
        self.connect(input_port, mono_channel_filter)
        if self.stereo:
            # stereo pilot tone tracker
            self.connect(input_port, stereo_pilot_filter, stereo_pilot_pll)
            self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 0))
            self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 1))
            self.connect(stereo_pilot_doubler, stereo_pilot_out)

            # pick out stereo left-right difference channel (at stereo_rate)
            self.connect(input_port, (difference_channel_mixer, 0))
            self.connect(stereo_pilot_out, (difference_channel_mixer, 1))
            self.connect(difference_channel_mixer, difference_channel_filter)

            # recover left/right channels (at self.__audio_int_rate)
            self.connect(difference_channel_filter, (mixL, 1))
            self.connect(difference_channel_filter, (mixR, 1))
            resamplerL = self._make_resampler((mixL, 0), self.__audio_int_rate)
            resamplerR = self._make_resampler((mixR, 0), self.__audio_int_rate)
            self.connect(mono_channel_filter, (mixL, 0))
            self.connect(mono_channel_filter, (mixR, 0))
            self.connect_audio_output(resamplerL, resamplerR)
        else:
            resampler = self._make_resampler(mono_channel_filter,
                                             self.__audio_int_rate)
            self.connect_audio_output(resampler, resampler)
Ejemplo n.º 9
0
    def connect_audio_stage(self, input_port):
        stereo_rate = self.demod_rate
        normalizer = TWO_PI / stereo_rate
        pilot_tone = 19000
        pilot_low = pilot_tone * 0.9
        pilot_high = pilot_tone * 1.1

        def make_audio_filter():
            return grfilter.fir_filter_fff(
                stereo_rate // self.__audio_int_rate,  # decimation
                firdes.low_pass(1.0, stereo_rate, 15000, 5000, firdes.WIN_HAMMING),
            )

        stereo_pilot_filter = grfilter.fir_filter_fcc(
            1, firdes.complex_band_pass(1.0, stereo_rate, pilot_low, pilot_high, 300)  # decimation
        )  # TODO magic number from gqrx
        stereo_pilot_pll = analog.pll_refout_cc(
            0.001, normalizer * pilot_high, normalizer * pilot_low  # TODO magic number from gqrx
        )
        stereo_pilot_doubler = blocks.multiply_cc()
        stereo_pilot_out = blocks.complex_to_imag()
        difference_channel_mixer = blocks.multiply_ff()
        difference_channel_filter = make_audio_filter()
        mono_channel_filter = make_audio_filter()
        mixL = blocks.add_ff(1)
        mixR = blocks.sub_ff(1)

        # connections
        self.connect(input_port, mono_channel_filter)
        if self.stereo:
            # stereo pilot tone tracker
            self.connect(input_port, stereo_pilot_filter, stereo_pilot_pll)
            self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 0))
            self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 1))
            self.connect(stereo_pilot_doubler, stereo_pilot_out)

            # pick out stereo left-right difference channel (at stereo_rate)
            self.connect(input_port, (difference_channel_mixer, 0))
            self.connect(stereo_pilot_out, (difference_channel_mixer, 1))
            self.connect(difference_channel_mixer, difference_channel_filter)

            # recover left/right channels (at self.__audio_int_rate)
            self.connect(difference_channel_filter, (mixL, 1))
            self.connect(difference_channel_filter, (mixR, 1))
            resamplerL = self._make_resampler((mixL, 0), self.__audio_int_rate)
            resamplerR = self._make_resampler((mixR, 0), self.__audio_int_rate)
            self.connect(mono_channel_filter, (mixL, 0))
            self.connect(mono_channel_filter, (mixR, 0))
            self.connect_audio_output(resamplerL, resamplerR)
        else:
            resampler = self._make_resampler(mono_channel_filter, self.__audio_int_rate)
            self.connect_audio_output(resampler, resampler)
Ejemplo n.º 10
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.taps = taps = [1.0, 0.25 - 0.25j, 0.50 + 0.10j, -0.3 + 0.2j]
        self.sps = sps = 4
        self.samp_rate = samp_rate = 44100
        self.qpsk = qpsk = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base()
        self.excess_bw = excess_bw = 0.35

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

        self.blocks_wavfile_sink = blocks.wavfile_sink('/tmp/challenge.wav', 2,
                                                       samp_rate, 16)
        self.blocks_file_source = blocks.file_source(gr.sizeof_char * 1,
                                                     '/tmp/input.txt', False)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)

        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=qpsk,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=excess_bw,
            verbose=False,
            log=False,
        )

        ##################################################
        # Connections
        ##################################################

        self.connect((self.blocks_file_source, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_wavfile_sink, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_wavfile_sink, 1))
Ejemplo n.º 11
0
    def __init__(self, mode="MODE-S", input_rate=0, audio_rate=0, context=None):
        assert input_rate > 0
        gr.hier_block2.__init__(
            self,
            "Mode S/ADS-B/1090 demodulator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            # TODO: Add generic support for demodulators with no audio output
            gr.io_signature(2, 2, gr.sizeof_float * 1),
        )
        self.mode = mode
        self.input_rate = input_rate

        # Subprocess
        self.dump1090 = SubprocessSink(args=["dump1090", "--ifile", "-"], itemsize=gr.sizeof_char)

        # Output
        self.band_filter_block = filter = MultistageChannelFilter(
            input_rate=input_rate,
            output_rate=pipe_rate,  # expected by dump1090
            cutoff_freq=pipe_rate / 2,
            transition_width=transition_width,
        )  # TODO optimize filter band
        interleaver = blocks.interleave(gr.sizeof_char)
        self.connect(
            self,
            filter,
            blocks.complex_to_real(1),
            blocks.multiply_const_ff(255.0 / 2),
            blocks.add_const_ff(255.0 / 2),
            blocks.float_to_uchar(),
            (interleaver, 0),
            self.dump1090,
        )

        self.connect(
            filter,
            blocks.complex_to_imag(1),
            blocks.multiply_const_ff(255.0 / 2),
            blocks.add_const_ff(255.0 / 2),
            blocks.float_to_uchar(),
            (interleaver, 1),
        )
        # Dummy audio
        zero = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.throttle = blocks.throttle(gr.sizeof_float, audio_rate)
        self.connect(zero, self.throttle)
        self.connect(self.throttle, (self, 0))
        self.connect(self.throttle, (self, 1))
Ejemplo n.º 12
0
    def __init__(self, sr, fr, bw):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = sr
        self.freq = freq = fr
        self.bandwidth = bandwidth = bw
        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_1 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "bladerf=179")
        self.osmosdr_source_1.set_sample_rate(samp_rate)
        self.osmosdr_source_1.set_center_freq(freq, 0)
        self.osmosdr_source_1.set_freq_corr(0, 0)
        self.osmosdr_source_1.set_dc_offset_mode(0, 0)
        self.osmosdr_source_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_1.set_gain_mode(False, 0)
        self.osmosdr_source_1.set_gain(2, 0)
        self.osmosdr_source_1.set_if_gain(0, 0)
        self.osmosdr_source_1.set_bb_gain(0, 0)
        self.osmosdr_source_1.set_antenna('RX', 0)
        self.osmosdr_source_1.set_bandwidth(bandwidth, 0)

        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                       '/dev/shm/dataI.dat',
                                                       False)
        self.blocks_file_sink_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                     '/dev/shm/dataR.dat',
                                                     False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.osmosdr_source_1, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.osmosdr_source_1, 0),
                     (self.blocks_complex_to_real_0, 0))
Ejemplo n.º 13
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################

        ##################################################
        # Blocks
        ##################################################
        self.correctiq_correctiq_0 = correctiq.correctiq()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_float * 1, '/dev/shm/dataI.dat', False)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float * 1,
                                                       '/dev/shm/dataR.dat',
                                                       False)
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                       '/dev/shm/fdataI.dat',
                                                       False)
        self.blocks_file_sink_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                     '/dev/shm/fdataR.dat',
                                                     False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.correctiq_correctiq_0, 0))
        self.connect((self.correctiq_correctiq_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.correctiq_correctiq_0, 0),
                     (self.blocks_complex_to_real_0, 0))
Ejemplo n.º 14
0
    def __init__(self, audio_input, input_rate, audio_output, output_rate, frequency=55000, ampl=1.0):
        gr.top_block.__init__(self)

        if ampl > 1.0: ampl = 1.0

        to_real = blocks.complex_to_real()
        to_imag = blocks.complex_to_imag()
        float_to_complex = blocks.float_to_complex()

        src = audio.source (input_rate, audio_input)
        firdes_taps = filter.firdes.low_pass_2(1, 1, 0.2, 0.1, 60)
        self._converter = filter.freq_xlating_fir_filter_ccf ( 1, firdes_taps, 0, input_rate )
        self._converter.set_center_freq(frequency)
        dst = audio.sink (output_rate, audio_output, True)

        #self.connect(src, converter, to_real, dst)
        self.connect((src, 1), (float_to_complex, 0))
        self.connect((src, 0), (float_to_complex, 1))
        self.connect(float_to_complex, self._converter)
        self.connect(self._converter, to_real, (dst,0))
        self.connect(self._converter, to_imag, (dst,1))
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        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())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.samp_rate = samp_rate = 100000
        self.fo = fo = 800000
        self.N0 = N0 = 1

        ##################################################
        # Blocks
        ##################################################
        self._fo_range = Range(800000, 1000000, 1000, 800000, 200)
        self._fo_win = RangeWidget(self._fo_range, self.set_fo, 'Frequency',
                                   "counter_slider", float)
        self.top_grid_layout.addWidget(self._fo_win, 0, 0, 1, 1)
        self._N0_range = Range(0.0001, 10, 0.0001, 1, 200)
        self._N0_win = RangeWidget(self._N0_range, self.set_N0,
                                   'Noise voltage', "counter_slider", float)
        self.top_grid_layout.addWidget(self._N0_win, 0, 1, 1, 1)
        self.qtgui_time_sink_x_0_2 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_2.set_update_time(0.10)
        self.qtgui_time_sink_x_0_2.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_2.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_2.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_2.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_2.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_2.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_2.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_2.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_2.set_line_alpha(i, alphas[i])

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

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

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

        if not True:
            self.qtgui_time_sink_x_0_1_0_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_1_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1_0_0.set_line_alpha(i, alphas[i])

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

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

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

        if not True:
            self.qtgui_time_sink_x_0_1_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_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win, 2, 0,
                                       1, 1)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #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(-1, 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(False)
        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)

        if not True:
            self.qtgui_time_sink_x_0_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_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, 1, 1,
                                       1, 1)
        self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0_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_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win, 4, 0,
                                       1, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #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(-1, 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(False)
        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)

        if not True:
            self.qtgui_time_sink_x_0_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_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, 5, 0,
                                       1, 1)
        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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 3, 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(True)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 2, 1,
                                       1)
        self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_1_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_1_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_1_0.enable_grid(False)
        self.qtgui_freq_sink_x_1_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_1_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_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 6, 1,
                                       1, 1)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f(
            1024,  #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(1.0)
        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 "float" == "float" or "float" == "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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 6, 0, 1,
                                       1)
        self.qtgui_freq_sink_x_0_1_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_1_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_1_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_1_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      0.0, 0, "")
        self.qtgui_freq_sink_x_0_1_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_1_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_1_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_1_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_1_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_1_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_0_1_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_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_1_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_1_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_1_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_1_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_1_0_win, 2, 3,
                                       1, 1)
        self.qtgui_freq_sink_x_0_1 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_1.enable_grid(False)
        self.qtgui_freq_sink_x_0_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_1.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_0_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_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_1_win, 2, 1,
                                       1, 1)
        self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      0.0, 0, "")
        self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_0_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_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 4, 1,
                                       1, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_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(-140, 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(False)
        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 "float" == "float" or "float" == "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, 5, 1,
                                       1, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            1024,  #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(1.0)
        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 "float" == "float" or "float" == "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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 3, 1, 1,
                                       1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_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.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 0, 1,
                                       1)
        self.digital_qam_mod_0 = digital.qam.qam_mod(
            constellation_points=4,
            mod_code="gray",
            differential=False,
            samples_per_symbol=2,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = 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_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_sig_source_x_0_1 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, fo, 1, 0)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SIN_WAVE, fo, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SIN_WAVE, fo, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, fo, 1, 0)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 256, 1000)), True)
        self.analog_noise_source_x_0 = analog.noise_source_f(
            analog.GR_GAUSSIAN, N0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.qtgui_freq_sink_x_0_0_0, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.qtgui_time_sink_x_0_0_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        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.qtgui_time_sink_x_0_2, 0))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.analog_sig_source_x_0_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_xx_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_0_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.qtgui_time_sink_x_0_1_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.qtgui_freq_sink_x_0_1_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.qtgui_time_sink_x_0_1_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.qtgui_freq_sink_x_1_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.digital_qam_mod_0, 0))
        self.connect((self.digital_qam_mod_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.digital_qam_mod_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_qam_mod_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
Ejemplo n.º 16
0
    def __init__(self, options):
        gr.hier_block2.__init__(
            self, "fbmc_transmit_path", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex)
        )

        common_options.defaults(options)

        config = self.config = station_configuration()

        config.data_subcarriers = options.subcarriers
        config.cp_length = 0
        config.frame_data_blocks = options.data_blocks
        config._verbose = options.verbose
        config.fft_length = options.fft_length
        config.dc_null = options.dc_null
        config.training_data = default_block_header(config.data_subcarriers, config.fft_length, config.dc_null, options)
        config.coding = options.coding
        config.fbmc = options.fbmc
        config.adaptive_fbmc = options.adaptive_fbmc

        config.frame_id_blocks = 1  # FIXME

        # digital rms amplitude sent to USRP
        rms_amp = options.rms_amplitude
        self._options = copy.copy(options)

        config.block_length = config.fft_length + config.cp_length
        config.frame_data_part = config.frame_data_blocks + config.frame_id_blocks
        config.frame_length = config.training_data.fbmc_no_preambles + 2 * config.frame_data_part
        config.subcarriers = config.data_subcarriers + config.training_data.pilot_subcarriers
        config.virtual_subcarriers = config.fft_length - config.subcarriers - config.dc_null

        # default values if parameters not set
        if rms_amp is None:
            rms_amp = math.sqrt(config.subcarriers)
        config.rms_amplitude = rms_amp

        # check some bounds
        if config.fft_length < config.subcarriers:
            raise SystemError, "Subcarrier number must be less than FFT length"
        if config.fft_length < config.cp_length:
            raise SystemError, "Cyclic prefix length must be less than FFT length"

        ## shortcuts
        blen = config.block_length
        flen = config.frame_length
        dsubc = config.data_subcarriers
        vsubc = config.virtual_subcarriers

        # Adaptive Transmitter Concept

        used_id_bits = config.used_id_bits = 8  # TODO: no constant in source code
        rep_id_bits = config.rep_id_bits = config.data_subcarriers / used_id_bits  # BPSK
        if config.data_subcarriers % used_id_bits <> 0:
            raise SystemError, "Data subcarriers need to be multiple of %d" % (used_id_bits)

        ## Allocation Control
        self.allocation_src = allocation_src(
            config.data_subcarriers,
            config.frame_data_blocks,
            config.coding,
            "tcp://*:3333",
            "tcp://" + options.rx_hostname + ":3322",
        )
        if options.static_allocation:  # DEBUG
            # how many bits per subcarrier

            if options.coding:
                mode = 1  # Coding mode 1-9
                bitspermode = [0.5, 1, 1.5, 2, 3, 4, 4.5, 5, 6]  # Information bits per mode
                modulbitspermode = [1, 2, 2, 4, 4, 6, 6, 6, 8]  # Coding bits per mode
                bitcount_vec = [(int)(config.data_subcarriers * config.frame_data_blocks * bitspermode[mode - 1])]
                modul_bitcount_vec = [config.data_subcarriers * config.frame_data_blocks * modulbitspermode[mode - 1]]
                bitcount_src = blocks.vector_source_i(bitcount_vec, True, 1)
                modul_bitcount_src = blocks.vector_source_i(modul_bitcount_vec, True, 1)
                bitloading = mode
            else:
                bitloading = 1
                bitcount_vec = [config.data_subcarriers * config.frame_data_blocks * bitloading]
                bitcount_src = blocks.vector_source_i(bitcount_vec, True, 1)
                modul_bitcount_src = bitcount_src
            # id's for frames
            id_vec = range(0, 256)
            id_src = blocks.vector_source_s(id_vec, True, 1)
            # bitloading for ID symbol and then once for data symbols
            # bitloading_vec = [1]*dsubc+[0]*(dsubc/2)+[2]*(dsubc/2)

            test_allocation = (
                [bitloading] * (int)(config.data_subcarriers / 8)
                + [0] * (int)(config.data_subcarriers / 4 * 3)
                + [bitloading] * (int)(config.data_subcarriers / 8)
            )
            # bitloading_vec = [1]*dsubc+[bitloading]*dsubc
            bitloading_vec = [1] * dsubc + test_allocation
            bitloading_src = blocks.vector_source_b(bitloading_vec, True, dsubc)
            # bitcount for frames
            # bitcount_vec = [config.data_subcarriers*config.frame_data_blocks*bitloading]
            bitcount_vec = [config.frame_data_blocks * sum(test_allocation)]
            bitcount_src = blocks.vector_source_i(bitcount_vec, True, 1)
            # power loading, here same for all symbols
            power_vec = (
                [1] * (int)(config.data_subcarriers / 8)
                + [0] * (int)(config.data_subcarriers / 4 * 3)
                + [1] * (int)(config.data_subcarriers / 8)
            )
            power_src = blocks.vector_source_f(power_vec, True, dsubc)
            # mux control stream to mux id and data bits
            mux_vec = [0] * dsubc + [1] * bitcount_vec[0]
            mux_ctrl = blocks.vector_source_b(mux_vec, True, 1)
        else:
            id_src = (self.allocation_src, 0)
            bitcount_src = (self.allocation_src, 4)
            bitloading_src = (self.allocation_src, 2)
            power_src = (self.allocation_src, 1)
            if options.coding:
                modul_bitcount_src = (self.allocation_src, 5)
            else:
                modul_bitcount_src = bitcount_src
            mux_ctrl = ofdm.tx_mux_ctrl(dsubc)
            self.connect(modul_bitcount_src, mux_ctrl)
            # Initial allocation
            self.allocation_src.set_allocation([4] * config.data_subcarriers, [1] * config.data_subcarriers)
            if options.benchmarking:
                self.allocation_src.set_allocation([4] * config.data_subcarriers, [1] * config.data_subcarriers)

        if options.lab_special_case:
            self.allocation_src.set_allocation(
                [0] * (config.data_subcarriers / 4)
                + [2] * (config.data_subcarriers / 2)
                + [0] * (config.data_subcarriers / 4),
                [1] * config.data_subcarriers,
            )

        if options.log:
            log_to_file(self, id_src, "data/id_src.short")
            log_to_file(self, bitcount_src, "data/bitcount_src.int")
            log_to_file(self, bitloading_src, "data/bitloading_src.char")
            log_to_file(self, power_src, "data/power_src.cmplx")

        ## GUI probe output
        zmq_probe_bitloading = zeromq.pub_sink(gr.sizeof_char, dsubc, "tcp://*:4445")
        # also skip ID symbol bitloading with keep_one_in_n (side effect)
        # factor 2 for bitloading because we have two vectors per frame, one for id symbol and one for all payload/data symbols
        # factor config.frame_data_part for power because there is one vector per ofdm symbol per frame
        self.connect(bitloading_src, blocks.keep_one_in_n(gr.sizeof_char * dsubc, 2 * 40), zmq_probe_bitloading)
        zmq_probe_power = zeromq.pub_sink(gr.sizeof_float, dsubc, "tcp://*:4444")
        # self.connect(power_src, blocks.keep_one_in_n(gr.sizeof_gr_complex*dsubc,40), blocks.complex_to_real(dsubc), zmq_probe_power)
        self.connect(power_src, blocks.keep_one_in_n(gr.sizeof_float * dsubc, 40), zmq_probe_power)

        ## Workaround to avoid periodic structure
        seed(1)
        whitener_pn = [randint(0, 1) for i in range(used_id_bits * rep_id_bits)]

        ## ID Encoder
        id_enc = self._id_encoder = repetition_encoder_sb(used_id_bits, rep_id_bits, whitener_pn)
        self.connect(id_src, id_enc)

        if options.log:
            id_enc_f = gr.char_to_float()
            self.connect(id_enc, id_enc_f)
            log_to_file(self, id_enc_f, "data/id_enc_out.float")

        ## Reference Data Source
        ber_ref_src = ber_reference_source(self._options)
        self.connect(id_src, (ber_ref_src, 0))
        self.connect(bitcount_src, (ber_ref_src, 1))

        if options.log:
            log_to_file(self, ber_ref_src, "data/ber_rec_src_tx.char")

        if options.log:
            log_to_file(self, btrig, "data/bitmap_trig.char")

        ## Frame Trigger
        ftrig_stream = [1] + [0] * (config.frame_data_part - 1)
        ftrig = self._frame_trigger = blocks.vector_source_b(ftrig_stream, True)

        ## Data Multiplexer
        # Input 0: control stream
        # Input 1: encoded ID stream
        # Inputs 2..n: data streams
        dmux = self._data_multiplexer = stream_controlled_mux_b()
        self.connect(mux_ctrl, (dmux, 0))
        self.connect(id_enc, (dmux, 1))

        if options.coding:
            fo = trellis.fsm(1, 2, [91, 121])
            encoder = self._encoder = trellis.encoder_bb(fo, 0)
            unpack = self._unpack = blocks.unpack_k_bits_bb(2)
            self.connect(ber_ref_src, encoder, unpack)

            if options.interleave:
                int_object = trellis.interleaver(2000, 666)
                interlv = trellis.permutation(int_object.K(), int_object.INTER(), 1, gr.sizeof_char)

            if not options.nopunct:
                bmaptrig_stream_puncturing = [1] + [0] * (config.frame_data_blocks / 2 - 1)
                btrig_puncturing = self._bitmap_trigger_puncturing = blocks.vector_source_b(
                    bmaptrig_stream_puncturing, True
                )
                puncturing = self._puncturing = puncture_bb(config.data_subcarriers)
                self.connect(bitloading_src, (puncturing, 1))
                self.connect(self._bitmap_trigger_puncturing, (puncturing, 2))
                self.connect(unpack, puncturing)
                last_block = puncturing

                if options.interleave:
                    self.connect(last_block, interlv)
                    last_block = interlv

                if options.benchmarking:
                    self.connect(last_block, blocks.head(gr.sizeof_char, options.N), (dmux, 2))
                else:
                    self.connect(last_block, (dmux, 2))
            else:
                if options.benchmarking:
                    self.connect(unpack, blocks.head(gr.sizeof_char, options.N), (dmux, 2))
                else:
                    self.connect(unpack, (dmux, 2))

        else:
            if options.benchmarking:
                self.connect(ber_ref_src, blocks.head(gr.sizeof_char, options.N), (dmux, 2))
            else:
                self.connect(ber_ref_src, (dmux, 2))

        if options.log:
            dmux_f = gr.char_to_float()
            self.connect(dmux, dmux_f)
            log_to_file(self, dmux_f, "data/dmux_out.float")

        ## Modulator
        mod = self._modulator = generic_mapper_bcv(config.data_subcarriers, config.coding, config.frame_data_part)
        self.connect(dmux, (mod, 0))
        self.connect(bitloading_src, (mod, 1))

        if options.log:
            log_to_file(self, mod, "data/mod_out.compl")
            modi = blocks.complex_to_imag(config.data_subcarriers)
            modr = blocks.complex_to_real(config.data_subcarriers)
            self.connect(mod, modi)
            self.connect(mod, modr)
            log_to_file(self, modi, "data/mod_imag_out.float")
            log_to_file(self, modr, "data/mod_real_out.float")

        ## Power allocator
        pa = self._power_allocator = multiply_frame_fc(config.frame_data_part, config.data_subcarriers)
        self.connect(mod, (pa, 0))
        self.connect(power_src, (pa, 1))

        if options.log:
            log_to_file(self, pa, "data/pa_out.compl")

        if options.fbmc:
            psubc = pa
        else:
            psubc = self._pilot_subcarrier_inserter = pilot_subcarrier_inserter()
            self.connect(pa, psubc)

            if options.log:
                log_to_file(self, psubc, "data/psubc_out.compl")

        subcarriers = config.subcarriers

        # fbmc_pblocks_timing = self._fbmc_timing_pilot_block_inserter = fbmc_timing_pilot_block_inserter(5,False)

        oqam_prep = self._oqam_prep = fbmc_oqam_preprocessing_vcvc(config.subcarriers, 0, 0)
        self.connect(psubc, oqam_prep)

        fbmc_pblocks = self._fbmc_pilot_block_inserter = fbmc_pilot_block_inserter(5, False)
        self.connect(oqam_prep, fbmc_pblocks)
        # log_to_file(self, fbmc_pblocks, "data/fbmc_pblocks_out.compl")
        # fbmc_insert_pream = self._fbmc_insert_pream = fbmc_insert_preamble_vcvc(M, syms_per_frame, preamble)
        # log_to_file(self, oqam_prep, "data/oqam_prep.compl")
        # log_to_file(self, psubc, "data/psubc_out.compl")
        # fbmc_pblocks = fbmc_pblocks_timing
        # log_to_file(self, fbmc_pblocks, "data/fbmc_pblocks_out.compl")

        beta_mult = self._beta_mult = fbmc_beta_multiplier_vcvc(config.subcarriers, 4, 4 * config.fft_length - 1, 0)
        self.connect(fbmc_pblocks, beta_mult)
        log_to_file(self, beta_mult, "data/beta_mult.compl")

        ## Add virtual subcarriers
        if config.fft_length > subcarriers:
            vsubc = self._virtual_subcarrier_extender = vector_padding_dc_null(
                config.subcarriers, config.fft_length, config.dc_null
            )
            self.connect(beta_mult, vsubc)
        else:
            vsubc = self._virtual_subcarrier_extender = beta_mult

        if options.log:
            log_to_file(self, vsubc, "data/vsubc_out.compl")

        ## IFFT, no window, block shift
        ifft = self._ifft = fft_blocks.fft_vcc(config.fft_length, False, [], True)
        self.connect(vsubc, ifft)

        if options.log:
            log_to_file(self, ifft, "data/ifft_out.compl")

        # FBMC separate stream + filterbanks
        separate_oqam = self._separate_oqam = fbmc_separate_vcvc(config.fft_length, 2)
        poly_netw_1 = self._poly_netw_1 = fbmc_polyphase_network_vcvc(
            config.fft_length, 4, 4 * config.fft_length - 1, False
        )
        poly_netw_2 = self._poly_netw_2 = fbmc_polyphase_network_vcvc(
            config.fft_length, 4, 4 * config.fft_length - 1, False
        )
        overlap_p2s = self._overlap_p2s = fbmc_overlapping_parallel_to_serial_vcc(config.fft_length)

        self.connect(ifft, (separate_oqam, 0), poly_netw_1)
        self.connect((separate_oqam, 1), poly_netw_2)
        self.connect(poly_netw_1, (overlap_p2s, 0))
        self.connect(poly_netw_2, (overlap_p2s, 1))

        ## Pilot blocks (preambles)
        # pblocks = self._pilot_block_inserter = pilot_block_inserter2(5,False)
        # self.connect( overlap_p2s, blocks.stream_to_vector(gr.sizeof_gr_complex,config.fft_length/2),  pblocks )

        # log_to_file(self, pblocks, "data/fbmc_pilot_block_ins_out.compl")

        if options.log:
            log_to_file(self, pblocks, "data/pilot_block_ins_out.compl")

        ## Cyclic Prefix
        # cp = self._cyclic_prefixer = cyclic_prefixer(config.fft_length,
        # config.block_length)

        # cp= blocks.vector_to_stream(gr.sizeof_gr_complex, config.fft_length/2)
        # self.connect(pblocks, cp )
        # self.connect( overlap_p2s,blocks.stream_to_vector(gr.sizeof_gr_complex,config.fft_length/2), cp )

        lastblock = overlap_p2s

        if options.log:
            log_to_file(self, overlap_p2s, "data/overlap_p2s_out.compl")

        # Digital Amplifier for resource allocation
        if config.adaptive_fbmc:
            rep = blocks.repeat(gr.sizeof_gr_complex, config.frame_length * config.block_length)
            amp = blocks.multiply_cc()
            self.connect(lastblock, (amp, 0))
            self.connect((self.allocation_src, 3), rep, (amp, 1))
            lastblock = amp
        else:
            self.connect((self.allocation_src, 3), blocks.null_sink(gr.sizeof_gr_complex))

        ## Digital Amplifier
        # amp = self._amplifier = gr.multiply_const_cc(1)
        amp = self._amplifier = ofdm.multiply_const_ccf(1.0)
        self.connect(lastblock, amp)
        self.set_rms_amplitude(rms_amp)
        # log_to_file(self, amp, "data/amp_tx_out.compl")

        if options.log:
            log_to_file(self, amp, "data/amp_tx_out.compl")

        ## Tx parameters
        bandwidth = options.bandwidth or 2e6
        bits = 8 * config.data_subcarriers * config.frame_data_blocks  # max. QAM256
        samples_per_frame = config.frame_length * config.block_length
        tb = samples_per_frame / bandwidth
        # set dummy carrier frequency if none available due to baseband mode
        if options.tx_freq is None:
            options.tx_freq = 0.0
        self.tx_parameters = {
            "carrier_frequency": options.tx_freq / 1e9,
            "fft_size": config.fft_length,
            "cp_size": config.cp_length,
            "subcarrier_spacing": options.bandwidth / config.fft_length / 1e3,
            "data_subcarriers": config.data_subcarriers,
            "bandwidth": options.bandwidth / 1e6,
            "frame_length": config.frame_length,
            "symbol_time": (config.cp_length + config.fft_length) / options.bandwidth * 1e6,
            "max_data_rate": (bits / tb) / 1e6,
        }

        ## Setup Output
        self.connect(amp, self)

        # Display some information about the setup
        if config._verbose:
            self._print_verbage()
Ejemplo n.º 17
0
    def __init__(self, options):
        gr.hier_block2.__init__(self, "transmit_path",
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        common_options.defaults(options)

        config = self.config = station_configuration()

        config.data_subcarriers = options.subcarriers
        config.cp_length = options.cp_length
        config.frame_data_blocks = options.data_blocks
        config._verbose = options.verbose
        config.fft_length = options.fft_length
        config.dc_null = options.dc_null
        config.training_data = default_block_header(config.data_subcarriers,
                                                    config.fft_length,
                                                    config.dc_null, options)
        config.coding = options.coding
        config.bandwidth = options.bandwidth
        config.gui_frame_rate = options.gui_frame_rate
        config.fbmc = options.fbmc

        config.frame_id_blocks = 1  # FIXME

        # digital rms amplitude sent to USRP
        rms_amp = options.rms_amplitude
        self._options = copy.copy(options)

        config.block_length = config.fft_length + config.cp_length
        config.frame_data_part = config.frame_data_blocks + config.frame_id_blocks
        config.frame_length = config.frame_data_part + \
                              config.training_data.no_pilotsyms
        config.subcarriers = config.data_subcarriers + \
                             config.training_data.pilot_subcarriers
        config.virtual_subcarriers = config.fft_length - config.subcarriers - config.dc_null

        # default values if parameters not set
        if rms_amp is None:
            rms_amp = math.sqrt(config.subcarriers)
        config.rms_amplitude = rms_amp

        # check some bounds
        if config.fft_length < config.subcarriers:
            raise SystemError, "Subcarrier number must be less than FFT length"
        if config.fft_length < config.cp_length:
            raise SystemError, "Cyclic prefix length must be less than FFT length"

        ## shortcuts
        blen = config.block_length
        flen = config.frame_length
        dsubc = config.data_subcarriers
        vsubc = config.virtual_subcarriers

        # Adaptive Transmitter Concept
        used_id_bits = config.used_id_bits = 8  #TODO: no constant in source code
        rep_id_bits = config.rep_id_bits = config.data_subcarriers / used_id_bits  #BPSK
        if config.data_subcarriers % used_id_bits <> 0:
            raise SystemError, "Data subcarriers need to be multiple of %d" % (
                used_id_bits)

        # adapt OFDM frame rate and GUI display frame rate
        self.keep_frame_n = int(
            1.0 / (config.frame_length *
                   (config.cp_length + config.fft_length) / config.bandwidth) /
            config.gui_frame_rate)

        ## Allocation Control
        self.allocation_src = allocation_src(
            config.data_subcarriers, config.frame_data_blocks, config.coding,
            "tcp://*:3333", "tcp://" + options.rx_hostname + ":3322")
        if options.static_allocation:  #DEBUG
            # how many bits per subcarrier

            if options.coding:
                mode = 1  # Coding mode 1-9
                bitspermode = [0.5, 1, 1.5, 2, 3, 4, 4.5, 5,
                               6]  # Information bits per mode
                modulbitspermode = [1, 2, 2, 4, 4, 6, 6, 6,
                                    8]  # Coding bits per mode
                bitcount_vec = [
                    (int)(config.data_subcarriers * config.frame_data_blocks *
                          bitspermode[mode - 1])
                ]
                modul_bitcount_vec = [
                    config.data_subcarriers * config.frame_data_blocks *
                    modulbitspermode[mode - 1]
                ]
                bitcount_src = blocks.vector_source_i(bitcount_vec, True, 1)
                modul_bitcount_src = blocks.vector_source_i(
                    modul_bitcount_vec, True, 1)
                bitloading = mode
            else:
                bitloading = 1
                bitcount_vec = [
                    config.data_subcarriers * config.frame_data_blocks *
                    bitloading
                ]
                bitcount_src = blocks.vector_source_i(bitcount_vec, True, 1)
                modul_bitcount_src = bitcount_src

            # id's for frames
            id_vec = range(0, 256)
            id_src = blocks.vector_source_s(id_vec, True, 1)
            # bitloading for ID symbol and then once for data symbols
            #bitloading_vec = [1]*dsubc+[0]*(dsubc/2)+[2]*(dsubc/2)

            #test_allocation = [bitloading]*(int)(config.data_subcarriers/8)+ [0]*(int)(config.data_subcarriers/4*3) + [bitloading]*(int)(config.data_subcarriers/8)
            #bitloading_vec = [1]*dsubc+[bitloading]*dsubc
            test_allocation = [bitloading] * dsubc
            bitloading_vec = [bitloading] * dsubc + test_allocation
            bitloading_src = blocks.vector_source_b(bitloading_vec, True,
                                                    dsubc)
            # bitcount for frames
            #bitcount_vec = [config.data_subcarriers*config.frame_data_blocks*bitloading]
            bitcount_vec = [config.frame_data_blocks * sum(test_allocation)]
            bitcount_src = blocks.vector_source_i(bitcount_vec, True, 1)
            # power loading, here same for all symbols
            #power_vec = [1]*(int)(config.data_subcarriers/8)+ [0]*(int)(config.data_subcarriers/4*3) + [1]*(int)(config.data_subcarriers/8)
            power_vec = [1] * config.data_subcarriers
            power_src = blocks.vector_source_f(power_vec, True, dsubc)
            # mux control stream to mux id and data bits
            mux_vec = [0] * dsubc + [1] * bitcount_vec[0]
            mux_ctrl = blocks.vector_source_b(mux_vec, True, 1)
        else:
            id_src = (self.allocation_src, 0)
            bitcount_src = (self.allocation_src, 4)
            bitloading_src = (self.allocation_src, 2)
            power_src = (self.allocation_src, 1)
            if options.coding:
                modul_bitcount_src = (self.allocation_src, 5)
            else:
                modul_bitcount_src = bitcount_src
            mux_ctrl = ofdm.tx_mux_ctrl(dsubc)
            self.connect(modul_bitcount_src, mux_ctrl)

            #Initial allocation
            self.allocation_src.set_allocation([2] * config.data_subcarriers,
                                               [1] * config.data_subcarriers)
            self.allocation_src.set_allocation_scheme(0)
            if options.benchmarking:
                self.allocation_src.set_allocation(
                    [4] * config.data_subcarriers,
                    [1] * config.data_subcarriers)

        if options.lab_special_case:
            self.allocation_src.set_allocation(
                [0] * (config.data_subcarriers / 4) + [2] *
                (config.data_subcarriers / 2) + [0] *
                (config.data_subcarriers / 4), [1] * config.data_subcarriers)

        if options.log:
            log_to_file(self, id_src, "data/id_src.short")
            log_to_file(self, bitcount_src, "data/bitcount_src.int")
            log_to_file(self, bitloading_src, "data/bitloading_src.char")
            log_to_file(self, power_src, "data/power_src.cmplx")

        ## GUI probe output
        zmq_probe_bitloading = zeromq.pub_sink(gr.sizeof_char, dsubc,
                                               "tcp://*:4445")
        # also skip ID symbol bitloading with keep_one_in_n (side effect)
        # factor 2 for bitloading because we have two vectors per frame, one for id symbol and one for all payload/data symbols
        # factor config.frame_data_part for power because there is one vector per ofdm symbol per frame
        self.connect(bitloading_src,
                     blocks.keep_one_in_n(gr.sizeof_char * dsubc, 2 * 40),
                     zmq_probe_bitloading)
        zmq_probe_power = zeromq.pub_sink(gr.sizeof_float, dsubc,
                                          "tcp://*:4444")
        #self.connect(power_src, blocks.keep_one_in_n(gr.sizeof_gr_complex*dsubc,40), blocks.complex_to_real(dsubc), zmq_probe_power)
        self.connect(power_src,
                     blocks.keep_one_in_n(gr.sizeof_float * dsubc, 40),
                     zmq_probe_power)

        ## Workaround to avoid periodic structure
        seed(1)
        whitener_pn = [
            randint(0, 1) for i in range(used_id_bits * rep_id_bits)
        ]

        ## ID Encoder
        id_enc = self._id_encoder = repetition_encoder_sb(
            used_id_bits, rep_id_bits, whitener_pn)
        self.connect(id_src, id_enc)

        if options.log:
            id_enc_f = gr.char_to_float()
            self.connect(id_enc, id_enc_f)
            log_to_file(self, id_enc_f, "data/id_enc_out.float")

        ## Reference Data Source
        ber_ref_src = ber_reference_source(self._options)
        self.connect(id_src, (ber_ref_src, 0))
        self.connect(bitcount_src, (ber_ref_src, 1))

        if options.log:
            log_to_file(self, ber_ref_src, "data/ber_rec_src_tx.char")

        if options.log:
            log_to_file(self, btrig, "data/bitmap_trig.char")

        ## Bitmap Update Trigger for puncturing
        if not options.nopunct:
            bmaptrig_stream_puncturing = [
                1
            ] + [0] * (config.frame_data_blocks / 2 - 1)

            btrig_puncturing = self._bitmap_trigger_puncturing = blocks.vector_source_b(
                bmaptrig_stream_puncturing, True)
            bmapsrc_stream_puncturing = [1] * dsubc + [2] * dsubc
            bsrc_puncturing = self._bitmap_src_puncturing = blocks.vector_source_b(
                bmapsrc_stream_puncturing, True, dsubc)

        if options.log and options.coding and not options.nopunct:
            log_to_file(self, btrig_puncturing,
                        "data/bitmap_trig_puncturing.char")

        ## Frame Trigger
        ftrig_stream = [1] + [0] * (config.frame_data_part - 1)
        ftrig = self._frame_trigger = blocks.vector_source_b(
            ftrig_stream, True)

        ## Data Multiplexer
        # Input 0: control stream
        # Input 1: encoded ID stream
        # Inputs 2..n: data streams
        dmux = self._data_multiplexer = stream_controlled_mux_b()
        self.connect(mux_ctrl, (dmux, 0))
        self.connect(id_enc, (dmux, 1))

        if options.coding:
            fo = trellis.fsm(1, 2, [91, 121])
            encoder = self._encoder = trellis.encoder_bb(fo, 0)
            unpack = self._unpack = blocks.unpack_k_bits_bb(2)
            self.connect(ber_ref_src, encoder, unpack)

            if options.interleave:
                int_object = trellis.interleaver(2000, 666)
                interlv = trellis.permutation(int_object.K(),
                                              int_object.INTER(), 1,
                                              gr.sizeof_char)

            if not options.nopunct:
                bmaptrig_stream_puncturing = [
                    1
                ] + [0] * (config.frame_data_blocks / 2 - 1)
                btrig_puncturing = self._bitmap_trigger_puncturing = blocks.vector_source_b(
                    bmaptrig_stream_puncturing, True)
                puncturing = self._puncturing = puncture_bb(
                    config.data_subcarriers)
                self.connect(bitloading_src, (puncturing, 1))
                self.connect(self._bitmap_trigger_puncturing, (puncturing, 2))
                self.connect(unpack, puncturing)
                last_block = puncturing

                if options.interleave:
                    self.connect(last_block, interlv)
                    last_block = interlv

                if options.benchmarking:
                    self.connect(last_block,
                                 blocks.head(gr.sizeof_char, options.N),
                                 (dmux, 2))
                else:
                    self.connect(last_block, (dmux, 2))
            else:
                if options.benchmarking:
                    self.connect(unpack, blocks.head(gr.sizeof_char,
                                                     options.N), (dmux, 2))
                else:
                    self.connect(unpack, (dmux, 2))

        else:
            if options.benchmarking:
                self.connect(ber_ref_src, blocks.head(gr.sizeof_char,
                                                      options.N), (dmux, 2))
            else:
                self.connect(ber_ref_src, (dmux, 2))

        if options.log:
            dmux_f = gr.char_to_float()
            self.connect(dmux, dmux_f)
            log_to_file(self, dmux_f, "data/dmux_out.float")

        ## Modulator
        mod = self._modulator = generic_mapper_bcv(config.data_subcarriers,
                                                   config.coding,
                                                   config.frame_data_part)
        self.connect(dmux, (mod, 0))
        self.connect(bitloading_src, (mod, 1))
        #log_to_file(self, mod, "data/mod_out.compl")

        if options.log:
            log_to_file(self, mod, "data/mod_out.compl")
            modi = blocks.complex_to_imag(config.data_subcarriers)
            modr = blocks.complex_to_real(config.data_subcarriers)
            self.connect(mod, modi)
            self.connect(mod, modr)
            log_to_file(self, modi, "data/mod_imag_out.float")
            log_to_file(self, modr, "data/mod_real_out.float")

        ## Power allocator
        pa = self._power_allocator = multiply_frame_fc(config.frame_data_part,
                                                       config.data_subcarriers)
        self.connect(mod, (pa, 0))
        self.connect(power_src, (pa, 1))

        if options.log:
            log_to_file(self, pa, "data/pa_out.compl")

        # Standard Transmitter Parts

        ## Pilot subcarriers
        psubc = self._pilot_subcarrier_inserter = pilot_subcarrier_inserter()
        self.connect(pa, psubc)

        if options.log:
            log_to_file(self, psubc, "data/psubc_out.compl")

        ## Add virtual subcarriers
        if config.fft_length > config.subcarriers:
            vsubc = self._virtual_subcarrier_extender = \
                    vector_padding_dc_null(config.subcarriers, config.fft_length,config.dc_null)
            self.connect(psubc, vsubc)
        else:
            vsubc = self._virtual_subcarrier_extender = psubc

        if options.log:
            log_to_file(self, vsubc, "data/vsubc_out.compl")

        ## IFFT, no window, block shift
        ifft = self._ifft = fft_blocks.fft_vcc(config.fft_length, False, [],
                                               True)
        self.connect(vsubc, ifft)

        if options.log:
            log_to_file(self, ifft, "data/ifft_out.compl")

        ## Pilot blocks (preambles)
        pblocks = self._pilot_block_inserter = pilot_block_inserter(5, False)
        self.connect(ifft, pblocks)

        if options.log:
            log_to_file(self, pblocks, "data/pilot_block_ins_out.compl")

        ## Cyclic Prefix
        cp = self._cyclic_prefixer = cyclic_prefixer(config.fft_length,
                                                     config.block_length)
        self.connect(pblocks, cp)

        lastblock = cp

        if options.log:
            log_to_file(self, cp, "data/cp_out.compl")

        #Digital Amplifier for resource allocation
        #if not options.coding:
        rep = blocks.repeat(gr.sizeof_gr_complex,
                            config.frame_length * config.block_length)
        amp = blocks.multiply_cc()
        self.connect(lastblock, (amp, 0))
        self.connect((self.allocation_src, 3), rep, (amp, 1))
        lastblock = amp

        ## Digital Amplifier
        #amp = self._amplifier = gr.multiply_const_cc(1)
        amp = self._amplifier = ofdm.multiply_const_ccf(1.0)
        self.connect(lastblock, amp)
        self.set_rms_amplitude(rms_amp)

        if options.log:
            log_to_file(self, amp, "data/amp_tx_out.compl")

        ## Tx parameters
        bandwidth = options.bandwidth or 2e6
        bits = 8 * config.data_subcarriers * config.frame_data_blocks  # max. QAM256
        samples_per_frame = config.frame_length * config.block_length
        tb = samples_per_frame / bandwidth
        # set dummy carrier frequency if none available due to baseband mode
        if (options.tx_freq is None):
            options.tx_freq = 0.0
        self.tx_parameters = {'carrier_frequency':options.tx_freq/1e9,'fft_size':config.fft_length, 'cp_size':config.cp_length \
                              , 'subcarrier_spacing':options.bandwidth/config.fft_length/1e3 \
                              , 'data_subcarriers':config.data_subcarriers, 'bandwidth':options.bandwidth/1e6 \
                              , 'frame_length':config.frame_length  \
                              , 'symbol_time':(config.cp_length + config.fft_length)/options.bandwidth*1e6, 'max_data_rate':(bits/tb)/1e6}

        ## Setup Output
        self.connect(amp, self)

        # Display some information about the setup
        if config._verbose:
            self._print_verbage()
Ejemplo n.º 18
0
    def __init__(self):
        gr.top_block.__init__(self, "Demod")

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 20
        self.nfilts = nfilts = 32
        self.samp_rate = samp_rate = 44100
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base()
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1.6e3, .6E3, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_1 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 5000, 100, firdes.WIN_HAMMING, 6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 62.8e-3, (rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_map_bb_0 = digital.map_bb(([0, 1, 3, 2]))
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            62.8e-3, arity, False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            qpsk)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, 10e-3, 2)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            sys.argv[1], False)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   sys.argv[2], False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -8e3, 1, 0)

        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            "/mnt/test.wav", 2, samp_rate, 16)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_1 = blocks.complex_to_imag(1)
        ##################################################
        # Connections
        ##################################################
        # self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1))
        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.blocks_float_to_complex_0, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.low_pass_filter_1, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.digital_map_bb_0, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blocks_file_sink_0, 0))

        #Test wav
        self.connect((self.low_pass_filter_1, 0),
                     (self.blocks_complex_to_imag_1, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.blocks_complex_to_real_1, 0))
        self.connect((self.blocks_complex_to_imag_1, 0),
                     (self.blocks_wavfile_sink_0, 1))
        self.connect((self.blocks_complex_to_real_1, 0),
                     (self.blocks_wavfile_sink_0, 0))
Ejemplo n.º 19
0
	def connect_audio_stage(self):
		demod_rate = self.demod_rate
		stereo_rate = self.post_demod_rate
		audio_rate = self.audio_rate
		normalizer = 2 * math.pi / stereo_rate
		pilot_tone = 19000
		pilot_low = pilot_tone * 0.9
		pilot_high = pilot_tone * 1.1

		def make_audio_filter():
			return grfilter.fir_filter_fff(
				1,  # decimation
				firdes.low_pass(
					1.0,
					stereo_rate,
					15000,
					5000,
					firdes.WIN_HAMMING))

		stereo_pilot_filter = grfilter.fir_filter_fcc(
			1,  # decimation
			firdes.complex_band_pass(
				1.0,
				stereo_rate,
				pilot_low,
				pilot_high,
				300))  # TODO magic number from gqrx
		stereo_pilot_pll = analog.pll_refout_cc(
			0.001,  # TODO magic number from gqrx
			normalizer * pilot_high,
			normalizer * pilot_low)
		stereo_pilot_doubler = blocks.multiply_cc()
		stereo_pilot_out = blocks.complex_to_imag()
		difference_channel_mixer = blocks.multiply_ff()
		difference_channel_filter = make_audio_filter()
		difference_real = blocks.complex_to_real(1)
		mono_channel_filter = make_audio_filter()
		resamplerL = self._make_resampler()
		resamplerR = self._make_resampler()
		mixL = blocks.add_ff(1)
		mixR = blocks.sub_ff(1)
		
		# connections
		if self.audio_filter:
			self.connect(self.demod_block, mono_channel_filter)
			mono = mono_channel_filter
		else:
			mono = self.demod_block

		if self.stereo:
			# stereo pilot tone tracker
			self.connect(
				self.demod_block,
				stereo_pilot_filter,
				stereo_pilot_pll)
			self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 0))
			self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 1))
			self.connect(stereo_pilot_doubler, stereo_pilot_out)
		
			# pick out stereo left-right difference channel
			self.connect(self.demod_block, (difference_channel_mixer, 0))
			self.connect(stereo_pilot_out, (difference_channel_mixer, 1))
			self.connect(difference_channel_mixer, difference_channel_filter)
		
			# recover left/right channels
			self.connect(difference_channel_filter, (mixL, 1))
			self.connect(difference_channel_filter, (mixR, 1))
			self.connect(mono, (mixL, 0), resamplerL)
			self.connect(mono, (mixR, 0), resamplerR)
			self.connect_audio_output(resamplerL, resamplerR)
		else:
			self.connect(mono, resamplerL)
			self.connect_audio_output(resamplerL, resamplerL)
Ejemplo n.º 20
0
    def __init__(self, infile, infile_fake, outfile):
        gr.top_block.__init__(self, "Mod")

        ##################################################
        # Variables
        ##################################################
        self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j]
        self.sps = sps = 20
        self.samp_rate = samp_rate = 44100
        self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base()
        self.num_repeats = num_repeats = 200
        self.fsk_deviation_hz = fsk_deviation_hz = 100
        self.fake_message = fake_message = "This is not the flag\x00\x00\x00\x00\x00"
        self.excess_bw = excess_bw = 0.35
        self.carrier_freq = carrier_freq = 1000

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

        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=qpsk,
          differential=True,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=excess_bw,
          verbose=False,
          log=False,
          )

        # self.digital_psk_mod_0 = digital.psk.psk_mod(
        #   constellation_points=4,
        #   mod_code="gray",
        #   differential=True,
        #   samples_per_symbol=sps,
        #   excess_bw=0.35,
        #   verbose=False,
        #   log=False,
        #   )
        # self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(((2*3.14*carrier_freq-2*3.14*fsk_deviation_hz,2*3.14*carrier_freq+2*3.14*fsk_deviation_hz)), 1)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=0.35,
        	frequency_offset=0,
        	epsilon=1,
        	taps=(taps),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(outfile, 2, samp_rate, 16)
        self.blocks_vco_f_0 = blocks.vco_f(samp_rate, 1, 1)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, num_repeats)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 1, "", False, gr.GR_LSB_FIRST)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        # self.blocks_file_source_1 = blocks.file_source(gr.sizeof_char*1, infile_fake, True)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, infile, False)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 8000, 1, 0)

        ##################################################
        # Connections
        ##################################################
        # self.connect((self.blocks_file_source_0, 0), (self.digital_psk_mod_0, 0))
        # self.connect((self.digital_psk_mod_0, 0),(self.channels_channel_model_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.digital_constellation_modulator_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),(self.channels_channel_model_0, 0))
            
        self.connect((self.channels_channel_model_0, 0), (self.blocks_add_xx_0, 0))

        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 1))

        # self.connect((self.blocks_file_source_1, 0), (self.blocks_repack_bits_bb_0, 0))
        # self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        # self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0))
        # self.connect((self.blocks_repeat_0, 0), (self.blocks_vco_f_0, 0))
        # self.connect((self.blocks_vco_f_0, 0), (self.blocks_float_to_complex_0, 0))
        # self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0))
        # self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1))

        self.connect((self.blocks_add_xx_0, 0), (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_complex_to_real_0, 0))
        # self.connect((self.channels_channel_model_0, 0), (self.blocks_complex_to_imag_0, 0))
        # self.connect((self.channels_channel_model_0, 0), (self.blocks_complex_to_real_0, 0))

        self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_wavfile_sink_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_wavfile_sink_0, 0))
Ejemplo n.º 21
0
  def build_blocks(self,config):
    if not self.device_found:
      return
      
    self.error = False

    fft_size = self.main.fft_size_control.get_value()
    
    frame_rate = self.main.framerate_control.get_value()
    average = self.main.average_control.get_value()
    ssb_lo = self.ssb_lo
    ssb_hi = self.ssb_hi
    
    USB = self.mode == self.main.MODE_USB or self.mode == self.main.MODE_CW_USB
      
    self.audio_dec_nrw = 1
    
    self.dec_nrw, self.interp_nrw = self.compute_dec_interp(self.sample_rate,self.audio_rate)
    
    self.audio_dec_wid = self.if_sample_rate / self.audio_rate
    
    self.dec_wid, self.interp_wid = self.compute_dec_interp(self.sample_rate,self.if_sample_rate)
          
    volume = .1
    
    self.configure_source_controls()
    
    self.create_update_freq_xlating_fir_filter()
    
    self.analog_agc_cc = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
    self.analog_agc_cc.set_max_gain(1)
    
    self.analog_agc_ff = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0)
    self.analog_agc_ff.set_max_gain(1)
        
    self.rational_resampler_wid = filter.rational_resampler_ccc(
      decimation=int(self.dec_wid),
      interpolation=int(self.interp_wid),
      taps=None,
      fractional_bw=None,
        )
        
    self.rational_resampler_nrw = filter.rational_resampler_ccc(
      decimation=int(self.dec_nrw),
      interpolation=int(self.interp_nrw),
      taps=None,
      fractional_bw=None,
        )
        
    self.analog_pwr_squelch = analog.pwr_squelch_cc(self.squelch_level, 1e-4, 0, True)
    
    self.analog_pwr_squelch_ssb = analog.pwr_squelch_ff(self.squelch_level, 1e-4, 0, True)
        
    self.blocks_multiply = blocks.multiply_vcc(1)
    self.blocks_complex_to_real = blocks.complex_to_real(1)
    
    #self.rebuild_filters(config)
     
    self.blocks_complex_to_mag_am = blocks.complex_to_mag(1)
      
    self.analog_nbfm_rcv = analog.nbfm_rx(
        audio_rate=self.audio_rate,
        quad_rate=self.audio_rate,
        tau=75e-6,
        max_dev=6e3,
        )
      
    self.analog_wfm_rcv = analog.wfm_rcv(
        quad_rate=self.if_sample_rate,
        audio_decimation=self.audio_dec_wid,
      )
      
    self.hilbert_fc_2 = filter.hilbert_fc(self.hilbert_taps_ssb, firdes.WIN_HAMMING, 6.76)
    self.hilbert_fc_1 = filter.hilbert_fc(self.hilbert_taps_ssb, firdes.WIN_HAMMING, 6.76)
    
    self.blocks_multiply_ssb = blocks.multiply_vcc(1)
    
    self.blocks_complex_to_float_ssb = blocks.complex_to_float(1)
    
    self.create_usb_lsb_switch()
    
    self.blocks_add = blocks.add_vff(1)
    
    self.blocks_complex_to_real = blocks.complex_to_real(1)
    self.blocks_complex_to_imag = blocks.complex_to_imag(1)
         
    # this is the source for the FFT display's data  
    self.logpwrfft = logpwrfft.logpwrfft_c(
      sample_rate=self.sample_rate,
      fft_size=fft_size,
      ref_scale=2,
      frame_rate=frame_rate,
      avg_alpha=average,
      average=(average != 1),
        )

    # this is the main FFT display
    self.fft_vector_sink = MyVectorSink(self.main,fft_size)
    
    self.blocks_multiply_const_volume = blocks.multiply_const_vff((volume, ))
        
    # only create this once
    if self.audio_sink == None:
      try:
        self.audio_sink = audio.sink(self.audio_rate, config['audio_device'], True)
      except Exception as e:
        self.main.message_dialog("Audio Error","A problem has come up while accessing the audio system: %s" % e)
        self.error = True
        self.audio_sink = None

    self.main.af_gain_control.set_value()
Ejemplo n.º 22
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.sps = sps = 4
        self.ntaps = ntaps = 1408
        self.nfilts = nfilts = 32
        self.excess_bw = excess_bw = 0.45
        self.timing_bw = timing_bw = 2 * pi / 100
        self.sr2 = sr2 = 300000
        self.samp_rate_0 = samp_rate_0 = 32000
        self.samp_rate = samp_rate = 100000
        self.s = s = 0.01
        self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(nfilts, nfilts * sps, 1.0, excess_bw, ntaps)
        self.freq_bw = freq_bw = 2 * pi / 100
        self.fll_ntaps = fll_ntaps = 55

        ##################################################
        # Blocks
        ##################################################
        self.n = self.n = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.n.AddPage(grc_wxgui.Panel(self.n), "tab1")
        self.n.AddPage(grc_wxgui.Panel(self.n), "tab2")
        self.n.AddPage(grc_wxgui.Panel(self.n), "tab3")
        self.Add(self.n)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_c(
            self.n.GetPage(1).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.n.GetPage(1).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.n.GetPage(0).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.n.GetPage(0).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.n.GetPage(2).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.n.GetPage(2).Add(self.wxgui_scopesink2_0.win)
        _s_sizer = wx.BoxSizer(wx.VERTICAL)
        self._s_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_s_sizer,
            value=self.s,
            callback=self.set_s,
            label="s",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._s_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_s_sizer,
            value=self.s,
            callback=self.set_s,
            minimum=-5,
            maximum=5,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_s_sizer)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            4, taps=(firdes.root_raised_cosine(32, 32, 1.0, 0.45, 1408)), flt_size=32
        )
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.iir_filter_xxx_0_0 = filter.iir_filter_ffd(([1.0001, -1]), ([-1, 1]), True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd((0.01,), ([-1, 0.99]), True)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(4, 2 * pi / 100, (rx_taps), 32, 16, 1.5, 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (((1 + 1j), (1 - 1j), (-1 + 1j), (-1 - 1j))), 1
        )
        self.blocks_vco_c_0 = blocks.vco_c(samp_rate, -5, 1)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_float * 1, "127.0.0.1", 12345, 1472, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1, "127.0.0.1", 12345, 1472, True)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((1,))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((1.413,))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1.413,))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1000)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-0.5,))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5,))
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, 10, 1, 0)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 4, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_multiply_xx_2, 1))
        self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.iir_filter_xxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_udp_source_0, 0), (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_0, 2))
        self.connect((self.blocks_vco_c_0, 0), (self.wxgui_scopesink2_2, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_imag_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.wxgui_scopesink2_1, 0))
        self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_vco_c_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 20e6
        self.freq = freq = 2400e6
        self.bandwidth = bandwidth = 1.5e6

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_1 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "bladerf=179")
        self.osmosdr_source_1.set_sample_rate(samp_rate)
        self.osmosdr_source_1.set_center_freq(freq, 0)
        self.osmosdr_source_1.set_freq_corr(0, 0)
        self.osmosdr_source_1.set_dc_offset_mode(0, 0)
        self.osmosdr_source_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_1.set_gain_mode(True, 0)
        self.osmosdr_source_1.set_gain(15, 0)
        self.osmosdr_source_1.set_if_gain(0, 0)
        self.osmosdr_source_1.set_bb_gain(0, 0)
        self.osmosdr_source_1.set_antenna('RX', 0)
        self.osmosdr_source_1.set_bandwidth(bandwidth, 0)

        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                           "bladerf=32a")
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(25, 0)
        self.osmosdr_sink_0.set_if_gain(0, 0)
        self.osmosdr_sink_0.set_bb_gain(0, 0)
        self.osmosdr_sink_0.set_antenna('TX', 0)
        self.osmosdr_sink_0.set_bandwidth(bandwidth, 0)

        self.correctiq_correctiq_0 = correctiq.correctiq()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_float * 1, '/dev/shm/QPulse.dat', True)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float * 1,
                                                       '/dev/shm/IPulse.dat',
                                                       True)
        self.blocks_file_sink_0_0_0_0_0_0 = blocks.file_sink(
            gr.sizeof_float * 1, '/dev/shm/ruidoR.dat', False)
        self.blocks_file_sink_0_0_0_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0_0_0_0 = blocks.file_sink(
            gr.sizeof_float * 1, '/dev/shm/ruidoI.dat', False)
        self.blocks_file_sink_0_0_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                       '/dev/shm/dataI.dat',
                                                       False)
        self.blocks_file_sink_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                     '/dev/shm/dataR.dat',
                                                     False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_file_sink_0_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_file_sink_0_0_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.osmosdr_sink_0, 0))
        self.connect((self.correctiq_correctiq_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.correctiq_correctiq_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.osmosdr_source_1, 0),
                     (self.correctiq_correctiq_0, 0))
Ejemplo n.º 24
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.sps = sps = 3
        self.nfilts = nfilts = 32
        self.ntaps = ntaps = 11 * nfilts * sps
        self.excess_bw = excess_bw = 0.4
        self.tx_taps = tx_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.timing_bw = timing_bw = 2 * pi / 100
        self.samp_rate_0 = samp_rate_0 = 20000 * sps
        self.samp_rate = samp_rate = 20000
        self.rx_taps = rx_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.freq_bw = freq_bw = 2 * pi / 100
        self.fll_ntaps = fll_ntaps = 55
        self.const_points = const_points = 4

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccf(
            interpolation=3,
            decimation=25,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=25,
            decimation=3,
            taps=None,
            fractional_bw=None,
        )
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(sps,
                                                             taps=(tx_taps),
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.low_pass_filter_0_0 = filter.fir_filter_fff(
            1, firdes.low_pass(1, 500e3, 50e3, 10e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1, firdes.low_pass(1, 500e3, 50e3, 10e3, firdes.WIN_HAMMING, 6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_bw, (rx_taps), nfilts, 16, 1.5, 1)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(4)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (((-1 - 1j) / sqrt(2), (-1 + 1j) / sqrt(2), (1 - 1j) / sqrt(2),
              (1 + 1j) / sqrt(2))), 1)
        self.blocks_unpack_k_bits_bb_1 = blocks.unpack_k_bits_bb(2)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                   20e3, True)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, 6)
        self.blocks_pack_k_bits_bb_2 = blocks.pack_k_bits_bb(2)
        self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(2)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, ))
        self.blocks_interleave_0 = blocks.interleave(gr.sizeof_float * 1, 1)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/media/aaronjs/New Volume/IITB_Files/Annual_Academic_Files/Year_3/Semester_5/EE340/Labwork/P10/Original_Text.txt',
            False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/media/aaronjs/New Volume/IITB_Files/Annual_Academic_Files/Year_3/Semester_5/EE340/Labwork/P10/P10_3_ModDemod_Text.txt',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        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_imag_0 = blocks.complex_to_imag(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            500e3, analog.GR_COS_WAVE, 100e3, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0),
                     (self.blocks_skiphead_0, 0))
        self.connect((self.blocks_interleave_0, 0),
                     (self.blocks_float_to_uchar_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_xx_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_pack_k_bits_bb_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_1, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_2, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.blocks_skiphead_0, 0),
                     (self.blocks_pack_k_bits_bb_2, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_interleave_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.blocks_interleave_0, 1))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_1, 0))
        self.connect((self.blocks_unpack_k_bits_bb_1, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_unpack_k_bits_bb_1, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_throttle_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, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
Ejemplo n.º 25
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FM Stereo Receiver")

        ##################################################
        # Variables
        ##################################################
        self.smux_filt_samprate = smux_filt_samprate = 256e3
        self.smux_decim = smux_decim = 8
        self.samp_rate = samp_rate = 2.048e6
        self.right_gain = right_gain = 3
        self.left_gain = left_gain = 3
        self.bpf_base = bpf_base = 23e3
        self.RF_Gain = RF_Gain = 45
        self.CF = CF = 99.3e6

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label=
            "Sample Rate: 1.024M, 1.4M, 1.8M, 1.92M, 2.048M, 2.4M & 2. 56M",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._samp_rate_text_box, 1, 0, 1, 1)
        _right_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._right_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_right_gain_sizer,
            value=self.right_gain,
            callback=self.set_right_gain,
            label="R Audio Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._right_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_right_gain_sizer,
            value=self.right_gain,
            callback=self.set_right_gain,
            minimum=0,
            maximum=5,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_right_gain_sizer, 0, 1, 1, 1)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "BB Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Demod Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Stereo Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Stereo Signal")
        self.GridAdd(self.notebook_0, 2, 0, 1, 2)
        _left_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._left_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_left_gain_sizer,
            value=self.left_gain,
            callback=self.set_left_gain,
            label="L Audio Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._left_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_left_gain_sizer,
            value=self.left_gain,
            callback=self.set_left_gain,
            minimum=0,
            maximum=5,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_left_gain_sizer, 0, 0, 1, 1)
        _RF_Gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_Gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_RF_Gain_sizer,
            value=self.RF_Gain,
            callback=self.set_RF_Gain,
            label="RF Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._RF_Gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_RF_Gain_sizer,
            value=self.RF_Gain,
            callback=self.set_RF_Gain,
            minimum=0,
            maximum=100,
            num_steps=45,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_RF_Gain_sizer, 1, 1, 1, 1)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.notebook_0.GetPage(0).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Baseband Waterfall",
            size=(800, 100),
        )
        self.notebook_0.GetPage(0).GridAdd(self.wxgui_waterfallsink2_0.win, 3,
                                           0, 1, 2)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.notebook_0.GetPage(3).GetWin(),
            title="Scope Plot",
            sample_rate=32e3,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=2,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
            size=(800, 500),
        )
        self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_f(
            self.notebook_0.GetPage(2).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=32e3,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Difference FFT ",
            peak_hold=False,
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0_1.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f(
            self.notebook_0.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate / 8,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Demodulated FFT",
            peak_hold=False,
            size=(800, 800),
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0_0_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
            self.notebook_0.GetPage(0).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="Baseband FFT",
            peak_hold=False,
            size=(800, 100),
        )
        self.notebook_0.GetPage(0).GridAdd(self.wxgui_fftsink2_0_0.win, 2, 0,
                                           1, 2)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.notebook_0.GetPage(2).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=32e3,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Sum FFT",
            peak_hold=False,
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0.win)
        self.rfgain = blocks.multiply_const_vcc((RF_Gain, ))
        self.low_pass_filter_1_0 = filter.fir_filter_fff(
            smux_decim,
            firdes.low_pass(1, smux_filt_samprate, 15e3, 500,
                            firdes.WIN_HAMMING, 1))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            2,
            firdes.low_pass(2, samp_rate / 4, 100e3, 500, firdes.WIN_KAISER,
                            6.76))
        self.iir_filter_xxx_0 = filter.iir_filter_ccf(
            (-0.00266, 0.00504, -0.00309, -0.00136, 0.00663, -0.01052, 0.01103,
             -0.00731, 0.00016, 0.00800, -0.01396, 0.01490, -0.00971, -0.00035,
             0.01173, -0.01979, 0.02054, -0.01240, -0.00273, 0.01960, -0.03122,
             0.03124, -0.01669, -0.01017, 0.04137, -0.06448, 0.06476, -0.02634,
             -0.07449, 0.33571, -0.00000, -0.33571, 0.07449, 0.02634, -0.06476,
             0.06448, -0.04137, 0.01017, 0.01669, -0.03124, 0.03122, -0.01960,
             0.00273, 0.01240, -0.02054, 0.01979, -0.01173, 0.00035, 0.00971,
             -0.01490, 0.01396, -0.00800, -0.00016, 0.00731, -0.01103, 0.01052,
             -0.00663, 0.00136, 0.00309, -0.00504, 0.00266), (1, ), False)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccf(4, (1, 1, 1, 1))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        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_multiply_xx_1_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (right_gain, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (left_gain, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            "/Users/bretttt/iCloud_drive/16S/engs110/project/radio_dat/IQ_Data_STEREO1",
            True)
        self.blocks_divide_xx_1 = blocks.divide_cc(1)
        self.blocks_delay_2 = blocks.delay(gr.sizeof_gr_complex * 1, 30)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.1, ))
        self.baseband_LPF = filter.fir_filter_fff(
            smux_decim,
            firdes.low_pass(1, smux_filt_samprate, 15e3, 500,
                            firdes.WIN_KAISER, 6.76))
        self.band_pass_filter_0_0_0 = filter.fir_filter_fcc(
            1,
            firdes.complex_band_pass(1, smux_filt_samprate, 18000, 20000, 1000,
                                     firdes.WIN_KAISER, 1))
        self.band_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, smux_filt_samprate, bpf_base, bpf_base + 30e3,
                             500, firdes.WIN_KAISER, 6.76))
        self.audio_sink_0_0_0_0 = audio.sink(32000, "", True)
        self.analog_pll_refout_cc_0_0 = analog.pll_refout_cc(
            3.14 / 100, 0.152 * 3.14, 0.144 * 3.14)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=samp_rate / 8,
                                                     tau=75e-6)
        self.analog_fm_deemph_0 = analog.fm_deemph(fs=samp_rate / 8, tau=75e-6)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        _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="Center Frequency",
            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=80e6,
            maximum=108e6,
            num_steps=280,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_CF_sizer, 3, 0, 1, 2)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_fm_deemph_0, 0),
                     (self.audio_sink_0_0_0_0, 0))
        self.connect((self.analog_fm_deemph_0_0, 0),
                     (self.audio_sink_0_0_0_0, 1))
        self.connect((self.analog_pll_refout_cc_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.analog_pll_refout_cc_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.band_pass_filter_0_0_0, 0),
                     (self.analog_pll_refout_cc_0_0, 0))
        self.connect((self.baseband_LPF, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.baseband_LPF, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_divide_xx_1, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.band_pass_filter_0_0_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.baseband_LPF, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.wxgui_fftsink2_0_0_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_delay_2, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_divide_xx_1, 0), (self.blocks_delay_2, 0))
        self.connect((self.blocks_divide_xx_1, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_file_source_0_0, 0), (self.rfgain, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.analog_fm_deemph_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.analog_fm_deemph_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.wxgui_fftsink2_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.wxgui_scopesink2_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_1_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.fir_filter_xxx_0_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.iir_filter_xxx_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_divide_xx_1, 0))
        self.connect((self.low_pass_filter_1_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.low_pass_filter_1_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.rfgain, 0), (self.blocks_throttle_0, 0))
Ejemplo n.º 26
0
    def __init__(self):
        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", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 960e3

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccf(
            interpolation=1,
            decimation=30,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0_1_1_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / 30,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_1_1_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_1_1_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_1_1_0_win)

        self.qtgui_sink_x_0_1_1_0.enable_rf_freq(False)

        self.qtgui_sink_x_0_1_1 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / 30,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_1_1.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_1_1_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_1_1_win)

        self.qtgui_sink_x_0_1_1.enable_rf_freq(False)

        self.qtgui_sink_x_0_1_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / 30,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_1_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_1_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_1_0_win)

        self.qtgui_sink_x_0_1_0.enable_rf_freq(False)

        self.qtgui_sink_x_0_1 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / 30,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_1.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_1_win)

        self.qtgui_sink_x_0_1.enable_rf_freq(False)

        self.low_pass_filter_0_0_0_0 = filter.fir_filter_fff(
            1, firdes.low_pass(1, samp_rate, 700, 150, firdes.WIN_HAMMING,
                               6.76))
        self.low_pass_filter_0_0_0 = filter.fir_filter_fff(
            1, firdes.low_pass(1, samp_rate, 700, 150, firdes.WIN_HAMMING,
                               6.76))
        self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_float * 1,
                                                   samp_rate / 30, True)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float * 1,
                                                   samp_rate / 30, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate / 30, True)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_1_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_1 = 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 = blocks.multiply_const_vcc((10, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_float * 1,
            '/media/aaronjs/New Volume/IITB_Files/Annual_Academic_Files/Year_3/Semester_5/EE340/EndSem/Given_Files/q1-file.bin',
            True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.band_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, samp_rate, 300e3 - 900, 300e3 + 900, 50,
                             firdes.WIN_HAMMING, 6.76))
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SIN_WAVE, 300e3, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 300e3, 1, 0)

        ##################################################
        # Connections
        ##################################################
        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_1_0, 1))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_multiply_xx_0_1_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_throttle_0_1, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_multiply_xx_0_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.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0),
                     (self.low_pass_filter_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_1_0, 0),
                     (self.low_pass_filter_0_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_0_1, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.qtgui_sink_x_0_1_1, 0))
        self.connect((self.blocks_throttle_0_1, 0),
                     (self.qtgui_sink_x_0_1_0, 0))
        self.connect((self.low_pass_filter_0_0_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.low_pass_filter_0_0_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.low_pass_filter_0_0_0_0, 0),
                     (self.qtgui_sink_x_0_1_1_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_throttle_0, 0))
Ejemplo n.º 27
0
    def __init__(self, demod_rate, audio_decimation, deemph_tau):
        """
        Hierarchical block for demodulating a broadcast FM signal.

        The input is the downconverted complex baseband signal (gr_complex).
        The output is two streams of the demodulated audio (float) 0=Left, 1=Right.

        Args:
            demod_rate: input sample rate of complex baseband input. (float)
            audio_decimation: how much to decimate demod_rate to get to audio. (integer)
            deemph_tau: deemphasis ime constant in seconds (75us in US, 50us in EUR). (float)
        """
        gr.hier_block2.__init__(self, "wfm_rcv_pll",
                                # Input signature
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(2, 2, gr.sizeof_float))      # Output signature

        if audio_decimation != int(audio_decimation):
            raise ValueError("audio_decimation needs to be an integer")
        audio_decimation = int(audio_decimation)

        ##################################################
        # Variables
        ##################################################
        self.demod_rate = demod_rate
        self.deemph_tau = deemph_tau
        self.stereo_carrier_filter_coeffs = stereo_carrier_filter_coeffs = firdes.band_pass(
            -2.0, demod_rate, 37600, 38400, 400, fft.window.WIN_HAMMING, 6.76)
        self.pilot_carrier_filter_coeffs = pilot_carrier_filter_coeffs = firdes.complex_band_pass(
            1.0, demod_rate, 18980, 19020, 1500, fft.window.WIN_HAMMING, 6.76)
        self.deviation = deviation = 75000
        self.audio_filter_coeffs = audio_filter_coeffs = firdes.low_pass(
            1, demod_rate, 15000, 1500, fft.window.WIN_HAMMING, 6.76)
        self.audio_decim = audio_decim = audio_decimation
        self.audio_rate = audio_rate = demod_rate / audio_decim
        self.samp_delay = samp_delay = (len(
            pilot_carrier_filter_coeffs) - 1) // 2 + (len(stereo_carrier_filter_coeffs) - 1) // 2

        ##################################################
        # Blocks
        ##################################################
        self.pilot_carrier_bpf = filter.fir_filter_fcc(
            1, pilot_carrier_filter_coeffs)
        self.pilot_carrier_bpf.declare_sample_delay(0)
        self.stereo_carrier_bpf = filter.fft_filter_fff(
            1, stereo_carrier_filter_coeffs, 1)
        self.stereo_carrier_bpf.declare_sample_delay(0)
        self.stereo_audio_lpf = filter.fft_filter_fff(
            audio_decim, audio_filter_coeffs, 1)
        self.stereo_audio_lpf.declare_sample_delay(0)
        self.mono_audio_lpf = filter.fft_filter_fff(
            audio_decim, audio_filter_coeffs, 1)
        self.mono_audio_lpf.declare_sample_delay(0)
        self.blocks_stereo_multiply = blocks.multiply_ff(1)
        self.blocks_pilot_multiply = blocks.multiply_cc(1)
        self.blocks_complex_to_imag = blocks.complex_to_imag(1)
        self.blocks_right_sub = blocks.sub_ff(1)
        self.blocks_left_add = blocks.add_ff(1)
        self.analog_quadrature_demod_cf = analog.quadrature_demod_cf(
            demod_rate / (2 * math.pi * deviation))
        self.analog_pll_refout_cc = analog.pll_refout_cc(
            0.001, 2 * math.pi * 19200 / demod_rate, 2 * math.pi * 18800 / demod_rate)
        self.analog_right_fm_deemph = analog.fm_deemph(
            fs=audio_rate, tau=deemph_tau)
        self.analog_left_fm_deemph = analog.fm_deemph(
            fs=audio_rate, tau=deemph_tau)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, samp_delay)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_left_fm_deemph, 0), (self, 0))
        self.connect((self.analog_right_fm_deemph, 0), (self, 1))
        self.connect((self.analog_pll_refout_cc, 0),
                     (self.blocks_pilot_multiply, 1))
        self.connect((self.analog_pll_refout_cc, 0),
                     (self.blocks_pilot_multiply, 0))
        self.connect((self.analog_quadrature_demod_cf, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_stereo_multiply, 0))
        self.connect((self.blocks_delay_0, 0), (self.mono_audio_lpf, 0))
        self.connect((self.analog_quadrature_demod_cf, 0),
                     (self.pilot_carrier_bpf, 0))
        self.connect((self.blocks_left_add, 0),
                     (self.analog_left_fm_deemph, 0))
        self.connect((self.blocks_right_sub, 0),
                     (self.analog_right_fm_deemph, 0))
        self.connect((self.blocks_complex_to_imag, 0),
                     (self.stereo_carrier_bpf, 0))
        self.connect((self.blocks_pilot_multiply, 0),
                     (self.blocks_complex_to_imag, 0))
        self.connect((self.blocks_stereo_multiply, 0),
                     (self.stereo_audio_lpf, 0))  # L - R path
        self.connect((self.mono_audio_lpf, 0), (self.blocks_left_add, 1))
        self.connect((self.mono_audio_lpf, 0), (self.blocks_right_sub, 0))
        self.connect((self.stereo_audio_lpf, 0), (self.blocks_left_add, 0))
        self.connect((self.stereo_audio_lpf, 0), (self.blocks_right_sub, 1))
        self.connect((self.stereo_carrier_bpf, 0),
                     (self.blocks_stereo_multiply, 1))
        self.connect((self.pilot_carrier_bpf, 0),
                     (self.analog_pll_refout_cc, 0))
        self.connect((self, 0), (self.analog_quadrature_demod_cf, 0))
Ejemplo n.º 28
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        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())


        ##################################################
        # Variables
        ##################################################
        self.variable_juanqui = variable_juanqui = 0
        self.variable_cb = variable_cb = False
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        _variable_cb_check_box = Qt.QCheckBox("var_cb")
        self._variable_cb_choices = {True: True, False: False}
        self._variable_cb_choices_inv = dict((v,k) for k,v in self._variable_cb_choices.iteritems())
        self._variable_cb_callback = lambda i: Qt.QMetaObject.invokeMethod(_variable_cb_check_box, "setChecked", Qt.Q_ARG("bool", self._variable_cb_choices_inv[i]))
        self._variable_cb_callback(self.variable_cb)
        _variable_cb_check_box.stateChanged.connect(lambda i: self.set_variable_cb(self._variable_cb_choices[bool(i)]))
        self.top_layout.addWidget(_variable_cb_check_box)
        self.nulo = spectsensing.nulo(0)
        def _variable_juanqui_probe():
        	while True:
        		val = self.nulo.update_variable(self.variable_cb)
        		try: self.set_variable_juanqui(val)
        		except AttributeError, e: pass
        		time.sleep(1.0/(0.1))
        _variable_juanqui_thread = threading.Thread(target=_variable_juanqui_probe)
        _variable_juanqui_thread.daemon = True
        _variable_juanqui_thread.start()
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"QT GUI Plot", #name
        	1 #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.enable_tags(-1, 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_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
        	1024, #size
        	samp_rate, #samp_rate
        	"QT GUI Plot", #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.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_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.3, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_imag_0, 0), (self.nulo, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.nulo, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
Ejemplo n.º 29
0
    def __init__(self):
        gr.top_block.__init__(self, "Lab 1")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Lab 1")
        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", "lab1")

        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.freqc = freqc = 900
        self.sps = sps = 8
        self.samp_rate = samp_rate = 1000
        self.phase = phase = 0
        self.mod_M = mod_M = 0
        self.gain_ = gain_ = 0.5
        self.freqc_ = freqc_ = freqc
        self.fps = fps = 30
        self.foffset = foffset = 0
        self.bw = bw = 1
        self.buff_size = buff_size = 32768
        self.analog_gain = analog_gain = 32

        ##################################################
        # Blocks
        ##################################################
        self.tab0 = Qt.QTabWidget()
        self.tab0_widget_0 = Qt.QWidget()
        self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0)
        self.tab0_grid_layout_0 = Qt.QGridLayout()
        self.tab0_layout_0.addLayout(self.tab0_grid_layout_0)
        self.tab0.addTab(self.tab0_widget_0, 'Spectrum/Constellation')
        self.tab0_widget_1 = Qt.QWidget()
        self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1)
        self.tab0_grid_layout_1 = Qt.QGridLayout()
        self.tab0_layout_1.addLayout(self.tab0_grid_layout_1)
        self.tab0.addTab(self.tab0_widget_1, 'Time-Series')
        self.top_grid_layout.addWidget(self.tab0, 0, 0, 10, 2)
        for r in range(0, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._phase_range = Range(-180*2, 180*2, 0.1, 0, 200)
        self._phase_win = RangeWidget(self._phase_range, self.set_phase, 'Phase Offset (Degrees)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._phase_win, 11, 1, 1, 1)
        for r in range(11, 12):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        # Create the options list
        self._mod_M_options = (0, 1, )
        # Create the labels list
        self._mod_M_labels = ('BPSK', 'QPSK', )
        # Create the combo box
        # Create the radio buttons
        self._mod_M_group_box = Qt.QGroupBox('Modulation Select' + ": ")
        self._mod_M_box = Qt.QHBoxLayout()
        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._mod_M_button_group = variable_chooser_button_group()
        self._mod_M_group_box.setLayout(self._mod_M_box)
        for i, _label in enumerate(self._mod_M_labels):
            radio_button = Qt.QRadioButton(_label)
            self._mod_M_box.addWidget(radio_button)
            self._mod_M_button_group.addButton(radio_button, i)
        self._mod_M_callback = lambda i: Qt.QMetaObject.invokeMethod(self._mod_M_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._mod_M_options.index(i)))
        self._mod_M_callback(self.mod_M)
        self._mod_M_button_group.buttonClicked[int].connect(
            lambda i: self.set_mod_M(self._mod_M_options[i]))
        self.top_grid_layout.addWidget(self._mod_M_group_box, 12, 1, 1, 1)
        for r in range(12, 13):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._gain__range = Range(0.1, 1, 0.01, 0.5, 200)
        self._gain__win = RangeWidget(self._gain__range, self.set_gain_, 'Gain (Amp)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain__win, 10, 1, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._freqc__range = Range(70, 6000, .01, freqc, 200)
        self._freqc__win = RangeWidget(self._freqc__range, self.set_freqc_, 'Carrier (MHz)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._freqc__win, 10, 0, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._foffset_range = Range(-10, 10, 1, 0, 10)
        self._foffset_win = RangeWidget(self._foffset_range, self.set_foffset, 'Frequency Offset (Hz)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._foffset_win, 12, 0, 1, 1)
        for r in range(12, 13):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._analog_gain_range = Range(0, 64, 1, 32, 200)
        self._analog_gain_win = RangeWidget(self._analog_gain_range, self.set_analog_gain, 'Gain (Analog)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._analog_gain_win, 11, 0, 1, 1)
        for r in range(11, 12):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            131072, #size
            samp_rate*1000, #samp_rate
            "", #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(1/fps)
        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(True)
        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:
                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.tab0_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 10, 2)
        for r in range(0, 10):
            self.tab0_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 2):
            self.tab0_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024, #size
            firdes.WIN_BLACKMAN_hARRIS, #wintype
            0, #fc
            samp_rate*1e3, #bw
            "", #name
            1
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(1/fps)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 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(0.1)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)



        labels = ['Magnitude', '', '', '', '',
            '', '', '', '', '']
        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 range(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.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 0, 5, 1)
        for r in range(0, 5):
            self.tab0_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.tab0_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0.set_processor_affinity([0])
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            1024, #size
            firdes.WIN_BLACKMAN_hARRIS, #wintype
            0, #fc
            samp_rate*1e3, #bw
            "", #name
            2
        )
        self.qtgui_freq_sink_x_0.set_update_time(1/fps)
        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(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)


        self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['In-Phase', 'Quadrature', '', '', '',
            '', '', '', '', '']
        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 range(2):
            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.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 5, 0, 5, 1)
        for r in range(5, 10):
            self.tab0_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.tab0_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0.set_processor_affinity([0])
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024, #size
            "", #name
            2 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(1/fps)
        self.qtgui_const_sink_x_0.set_y_axis(-3, 3)
        self.qtgui_const_sink_x_0.set_x_axis(-3, 3)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(True)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)


        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, 1, 0, 0, 0,
            0, 0, 0, 0, 0]
        markers = [0, -1, 0, 0, 0,
            0, 0, 0, 0, 0]
        alphas = [1.0, 0.5, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab0_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 10, 1)
        for r in range(0, 10):
            self.tab0_grid_layout_0.setRowStretch(r, 1)
        for c in range(1, 2):
            self.tab0_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0.set_processor_affinity([0])
        self.iio_pluto_source_0 = iio.pluto_source('', int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, True, True, True, 'manual', analog_gain, '', True)
        self.iio_pluto_sink_0 = iio.pluto_sink('', int(freqc_*1e6)+foffset, int(samp_rate*1000), 20000000, buff_size, False, 10.0, '', True)
        self.digital_psk_mod_0_0 = digital.psk.psk_mod(
            constellation_points=4,
            mod_code="gray",
            differential=True,
            samples_per_symbol=sps,
            excess_bw=1,
            verbose=False,
            log=False)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(np.exp(1j*2*pi*phase/360))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(mod_M)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(gain_  * np.exp(1j * pi / 4))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_1 = blocks.complex_to_imag(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 4, 8192))), True)
        self.analog_agc_xx_0 = analog.agc_cc(1e-4,  ( 1.0 + mod_M), 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.blocks_complex_to_imag_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_const_sink_x_0, 1))
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0), (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.blocks_complex_to_imag_1, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_complex_to_real_1, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.iio_pluto_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_imag_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_real_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.digital_psk_mod_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.iio_pluto_source_0, 0), (self.blocks_multiply_const_vxx_1, 0))
Ejemplo n.º 30
0
    def __init__(self):
        gr.top_block.__init__(self, "Audio Tx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Audio Tx")
        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", "audio_tx")

        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 = 1
        self.nfilts = nfilts = 25
        self.samp_rate = samp_rate = 32E3
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.phase_bw = phase_bw = 6.28 / 100.0
        self.excess_bw = excess_bw = 0.35

        self.BPSK = BPSK = digital.constellation_qpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200)
        self._phase_bw_win = RangeWidget(self._phase_bw_range,
                                         self.set_phase_bw, 'Phase: Bandwidth',
                                         "slider", float)
        self.top_layout.addWidget(self._phase_bw_win)
        self.qtgui_time_sink_x_1_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1_1.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_1_win)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #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 = ['', '', '', '', '', '', '', '', '', '']
        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_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
            "",  #name
            1  #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 = ['', '', '', '', '', '', '', '', '', '']
        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)
        self.qtgui_time_sink_x_0.enable_stem_plot(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.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
            1024,  #size
            "demod",  #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(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        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_layout.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "Rx",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(True)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_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.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 1,
                                       1)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)]
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1.6E3, .6E3, firdes.WIN_HAMMING,
                            6.76))
        self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, .063, (rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(
            8, .01, 1, BPSK)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            phase_bw, 4, False)
        self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(
            BPSK, phase_bw, 0, 2 * 3.14)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=BPSK,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=2,
            verbose=False,
            log=False,
        )
        self.blocks_multiply_xx_3_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_3 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_2_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_2_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_2_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        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/test_input.txt', True)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/peter/Desktop/output.txt', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_imag_1 = blocks.complex_to_imag(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_3 = blocks.add_vff(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=sps,
                bits_per_symbol=1,
                preamble='',
                access_code='',
                pad_for_usrp=False,
            ),
            payload_length=1,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code='',
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )
        self.analog_sig_source_x_0_1_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, 4E3, 1, 0)
        self.analog_sig_source_x_0_1_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0)
        self.analog_sig_source_x_0_1 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SIN_WAVE, 4E3, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SIN_WAVE, 4E3, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0)
        self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(
            1024, 1.55)
        self.analog_const_source_x_0_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, -1)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, -1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_multiply_xx_3, 1))
        self.connect((self.analog_const_source_x_0_0, 0),
                     (self.blocks_multiply_xx_3_0, 1))
        self.connect((self.analog_feedforward_agc_cc_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_3_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_3, 0))
        self.connect((self.analog_sig_source_x_0_1, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.analog_sig_source_x_0_1_0, 0),
                     (self.blocks_multiply_xx_2_0, 1))
        self.connect((self.analog_sig_source_x_0_1_0_0, 0),
                     (self.blocks_multiply_xx_2_0_0, 1))
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_xx_2_1, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_add_xx_3, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_complex_to_imag_1, 0),
                     (self.blocks_add_xx_3, 1))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_multiply_xx_2_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_multiply_xx_2_0_0, 0),
                     (self.blocks_complex_to_imag_1, 0))
        self.connect((self.blocks_multiply_xx_2_1, 0),
                     (self.blocks_add_xx_3, 0))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_2_1, 1))
        self.connect((self.blocks_multiply_xx_3_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 4),
                     (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 3),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 1),
                     (self.qtgui_time_sink_x_1_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 2),
                     (self.qtgui_time_sink_x_1_1, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_lms_dd_equalizer_cc_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0, 0),
                     (self.digital_constellation_receiver_cb_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_xx_2_0, 0))
        self.connect((self.hilbert_fc_0, 0),
                     (self.blocks_multiply_xx_2_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_feedforward_agc_cc_0, 0))
Ejemplo n.º 31
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.samp_rate = samp_rate = 500000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
            self.GetWin(),
            title='Constellation Plot',
            sample_rate=samp_rate,
            frame_rate=5,
            const_size=2048,
            M=4,
            theta=0,
            loop_bw=6.28 / 100.0,
            fmax=0.06,
            mu=0.5,
            gain_mu=0.005,
            symbol_rate=samp_rate / 4.,
            omega_limit=0.005,
        )
        self.Add(self.wxgui_constellationsink2_0.win)
        self.digital_qam_mod_0 = digital.qam.qam_mod(
            constellation_points=16,
            mod_code="gray",
            differential=True,
            samples_per_symbol=4,
            excess_bw=0.90,
            verbose=False,
            log=False,
        )
        self.digital_qam_demod_0 = digital.qam.qam_demod(
            constellation_points=16,
            differential=True,
            samples_per_symbol=4,
            excess_bw=0.90,
            freq_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            phase_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_multiply_xx_0_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_1 = 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_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_complex_to_imag_0_0 = blocks.complex_to_imag(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_char_to_float_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 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_COS_WAVE, 25000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_SIN_WAVE, 25000, 1, 0)
        self.analog_random_source_x_0 = blocks.vector_source_s(
            map(int, numpy.random.randint(0, 2, 2000000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_short_to_float_0, 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, 0))
        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_2, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_xx_0_2, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_char_to_float_1, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_imag_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.digital_qam_mod_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.digital_qam_demod_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0_1, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_xx_0_2, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.digital_qam_demod_0, 0),
                     (self.blocks_char_to_float_1, 0))
        self.connect((self.digital_qam_mod_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.digital_qam_mod_0, 0),
                     (self.blocks_complex_to_imag_0_0, 0))
        self.connect((self.digital_qam_mod_0, 0),
                     (self.wxgui_constellationsink2_0, 0))
Ejemplo n.º 32
0
    def __init__(self):
        gr.top_block.__init__(self, "Lab 3 Task 1B")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Lab 3 Task 1B")
        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", "lab3_task1b")

        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 = 3528000
        self.samp_msg = samp_msg = 44100

        ##################################################
        # 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, 'Modulated')
        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, 'Demodulated')
        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, 'Demodulated (only Real)')
        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, 'Demodulated (only Imag)')
        self.top_grid_layout.addWidget(self.tab)
        self.rational_resampler_xxx_0_0_0_0 = filter.rational_resampler_fff(
            interpolation=samp_msg,
            decimation=samp_rate,
            taps=None,
            fractional_bw=None)
        self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff(
            interpolation=samp_msg,
            decimation=samp_rate,
            taps=None,
            fractional_bw=None)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=samp_msg,
            decimation=samp_rate,
            taps=None,
            fractional_bw=None)
        self.qtgui_sink_x_1 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            'Modulated',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True  #plotconst
        )
        self.qtgui_sink_x_1.set_update_time(1.0 / 10)
        self._qtgui_sink_x_1_win = sip.wrapinstance(
            self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_1.enable_rf_freq(False)

        self.tab_layout_0.addWidget(self._qtgui_sink_x_1_win)
        self.qtgui_sink_x_0_0_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_msg,  #bw
            'Demodulated (only Imag)',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True  #plotconst
        )
        self.qtgui_sink_x_0_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_0_0_0.enable_rf_freq(False)

        self.tab_layout_3.addWidget(self._qtgui_sink_x_0_0_0_win)
        self.qtgui_sink_x_0_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_msg,  #bw
            'Demodulated (only Real)',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True  #plotconst
        )
        self.qtgui_sink_x_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_0_0.enable_rf_freq(False)

        self.tab_layout_2.addWidget(self._qtgui_sink_x_0_0_win)
        self.qtgui_sink_x_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_msg,  #bw
            'Demodulated',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True  #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.qtgui_sink_x_0.enable_rf_freq(False)

        self.tab_layout_1.addWidget(self._qtgui_sink_x_0_win)
        self.low_pass_filter_1_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 15000, 1000, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_1 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 15000, 1000, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 15000, 1000, firdes.WIN_KAISER,
                            6.76))
        self.iir_filter_xxx_2_0_0 = filter.iir_filter_ffd([1], [1, -0.95],
                                                          False)
        self.iir_filter_xxx_2_0 = filter.iir_filter_ffd([1], [1, -0.95], False)
        self.iir_filter_xxx_2 = filter.iir_filter_ffd([1], [1, -0.95], False)
        self.iir_filter_xxx_0_0 = filter.iir_filter_ffd([1, -1], [1], False)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd([1, -1], [1], True)
        self.dc_blocker_xx_0_0_0 = filter.dc_blocker_ff(10000, True)
        self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(32000, True)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(10000, True)
        self.blocks_wavfile_sink_0_0_0 = blocks.wavfile_sink(
            '/home/ipsit/Documents/EE 340/Lab 3/task1bi.wav', 1, samp_msg, 8)
        self.blocks_wavfile_sink_0_0 = blocks.wavfile_sink(
            '/home/ipsit/Documents/EE 340/Lab 3/task1br.wav', 1, samp_msg, 8)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            '/home/ipsit/Documents/EE 340/Lab 3/task1b.wav', 1, samp_msg, 8)
        self.blocks_throttle_1_0_0_0 = blocks.throttle(gr.sizeof_float * 1,
                                                       samp_msg, True)
        self.blocks_throttle_1_0_0 = blocks.throttle(gr.sizeof_float * 1,
                                                     samp_msg, True)
        self.blocks_throttle_1_0 = blocks.throttle(gr.sizeof_float * 1,
                                                   samp_msg, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_1_0 = blocks.multiply_const_ff(10)
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_ff(10)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(1 / 6.28)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(100)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/ipsit/Documents/EE 340/Lab 3/task2b.dat', True, 0, 0)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.blocks_abs_xx_0_0 = blocks.abs_ff(1)
        self.blocks_abs_xx_0 = blocks.abs_ff(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_abs_xx_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.blocks_abs_xx_0_0, 0),
                     (self.low_pass_filter_1_0, 0))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.iir_filter_xxx_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_delay_0, 0), (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_throttle_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.blocks_throttle_1_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_1_0, 0),
                     (self.blocks_throttle_1_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_1, 0))
        self.connect((self.blocks_throttle_1_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_throttle_1_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.blocks_throttle_1_0_0, 0),
                     (self.blocks_wavfile_sink_0_0, 0))
        self.connect((self.blocks_throttle_1_0_0, 0),
                     (self.qtgui_sink_x_0_0, 0))
        self.connect((self.blocks_throttle_1_0_0_0, 0),
                     (self.blocks_wavfile_sink_0_0_0, 0))
        self.connect((self.blocks_throttle_1_0_0_0, 0),
                     (self.qtgui_sink_x_0_0_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0),
                     (self.rational_resampler_xxx_0_0_0, 0))
        self.connect((self.dc_blocker_xx_0_0_0, 0),
                     (self.rational_resampler_xxx_0_0_0_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_abs_xx_0, 0))
        self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_abs_xx_0_0, 0))
        self.connect((self.iir_filter_xxx_2, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.iir_filter_xxx_2_0, 0),
                     (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.iir_filter_xxx_2_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_1_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.low_pass_filter_1, 0), (self.dc_blocker_xx_0_0, 0))
        self.connect((self.low_pass_filter_1_0, 0),
                     (self.dc_blocker_xx_0_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.iir_filter_xxx_2, 0))
        self.connect((self.rational_resampler_xxx_0_0_0, 0),
                     (self.iir_filter_xxx_2_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0, 0),
                     (self.iir_filter_xxx_2_0_0, 0))
Ejemplo n.º 33
0
    def __init__(self, input_filename, _samp_rate, bs_format, output_filename):
        gr.top_block.__init__(self, "Noaa Demodulator")

        ##################################################
        # Variables
        ##################################################
        self.decimation = decimation = 1
        self.samp_rate = samp_rate = _samp_rate / decimation
        self.baud = baud = 8320
        self.sps = sps = samp_rate / (baud * 2.0)
        self.nfilts = nfilts = 72
        self.ebw = ebw = 0.25
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), ebw, 64 * nfilts)
        self.lp_taps = lp_taps = firdes.low_pass_2(nfilts, nfilts, 2 / sps,
                                                   0.05, nfilts)
        self.bp_taps = bp_taps = firdes.band_pass_2(nfilts, nfilts,
                                                    0.1 / float(sps),
                                                    1.2 / float(sps), ebw,
                                                    64 * nfilts)

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decimation,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 11000, 6000, firdes.WIN_BLACKMAN,
                            6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, .068 / 1.5, (lp_taps), nfilts, 0, 10, 2)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            6, 1, .0000005, 2)
        self.dc_blocker_xx_0_0 = filter.dc_blocker_cc(16, False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate * 24, True)
        self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)

        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(
            0.068 / 12, 6000 * 2 * 3.14159 / samp_rate,
            -6000 * 2 * 3.14159 / samp_rate)
        self.analog_agc2_xx_0 = analog.agc2_cc(0.5, 1, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/xeratec/Projects/NOAA-DSB/recordings/samples/POES_56k250.raw',
            False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)

        if bs_format == 0:
            self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
            self.blocks_file_sink_3_1 = blocks.file_sink(
                gr.sizeof_float * 1, output_filename, False)
            self.blocks_file_sink_3_1.set_unbuffered(False)
        if bs_format == 1:
            self.blocks_file_sink_0 = blocks.file_sink(
                gr.sizeof_gr_complex * 1, output_filename, False)
            self.blocks_file_sink_0.set_unbuffered(False)

        #################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.dc_blocker_xx_0_0, 0))

        if bs_format == 0:
            self.connect((self.blocks_complex_to_imag_0, 0),
                         (self.blocks_file_sink_3_1, 0))
            self.connect((self.digital_cma_equalizer_cc_0, 0),
                         (self.blocks_complex_to_imag_0, 0))
        if bs_format == 1:
            self.connect((self.digital_cma_equalizer_cc_0, 0),
                         (self.blocks_file_sink_0, 0))

        self.connect((self.blocks_file_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 3),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 1),
                     (self.blocks_null_sink_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 2),
                     (self.blocks_null_sink_0_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_throttle_0, 0))
Ejemplo n.º 34
0
    def __init__(self):
        gr.top_block.__init__(self, "Lab 2")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Lab 2")
        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", "lab2")

        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.sps = sps = 8
        self.roll_off = roll_off = 0.5
        self.freqc = freqc = 900
        self.std_dev = std_dev = 0.05
        self.samp_rate = samp_rate = 1024
        self.rrc_filter = rrc_filter = firdes.root_raised_cosine(4, sps, 1, roll_off, 32*sps+1)
        self.phase = phase = 0
        self.lw = lw = 2
        self.gain_ = gain_ = 0.5
        self.freqc_ = freqc_ = freqc
        self.fps = fps = 30
        self.const = const = digital.constellation_calcdist(digital.psk_2()[0], digital.psk_2()[1],
        2, 1).base()
        self.bw = bw = 1
        self.buff_size = buff_size = 32768
        self.bNoise = bNoise = 0
        self.bFilter = bFilter = 0
        self.axis = axis = 2
        self.N = N = 0

        ##################################################
        # Blocks
        ##################################################
        self.tab0 = Qt.QTabWidget()
        self.tab0_widget_0 = Qt.QWidget()
        self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0)
        self.tab0_grid_layout_0 = Qt.QGridLayout()
        self.tab0_layout_0.addLayout(self.tab0_grid_layout_0)
        self.tab0.addTab(self.tab0_widget_0, 'Spectrum/Constellation')
        self.tab0_widget_1 = Qt.QWidget()
        self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1)
        self.tab0_grid_layout_1 = Qt.QGridLayout()
        self.tab0_layout_1.addLayout(self.tab0_grid_layout_1)
        self.tab0.addTab(self.tab0_widget_1, 'Eye Diagram')
        self.top_grid_layout.addWidget(self.tab0, 0, 0, 10, 2)
        for r in range(0, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._std_dev_range = Range(0, 1, 0.01, 0.05, 200)
        self._std_dev_win = RangeWidget(self._std_dev_range, self.set_std_dev, 'Noise Std. Dev', "counter_slider", float)
        self.top_grid_layout.addWidget(self._std_dev_win, 11, 0, 1, 1)
        for r in range(11, 12):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._phase_range = Range(-180*2, 180*2, 0.1, 0, 200)
        self._phase_win = RangeWidget(self._phase_range, self.set_phase, 'Phase Offset (Degrees)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._phase_win, 11, 1, 1, 1)
        for r in range(11, 12):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._gain__range = Range(0.1, 1, 0.01, 0.5, 200)
        self._gain__win = RangeWidget(self._gain__range, self.set_gain_, 'Gain (Amp)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain__win, 10, 1, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._freqc__range = Range(70, 6000, .01, freqc, 200)
        self._freqc__win = RangeWidget(self._freqc__range, self.set_freqc_, 'Carrier (MHz)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._freqc__win, 10, 0, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        # Create the options list
        self._bNoise_options = (0, 1, )
        # Create the labels list
        self._bNoise_labels = ('Noise Only', 'Signal + Noise', )
        # Create the combo box
        # Create the radio buttons
        self._bNoise_group_box = Qt.QGroupBox('Waveform Select' + ": ")
        self._bNoise_box = Qt.QHBoxLayout()
        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._bNoise_button_group = variable_chooser_button_group()
        self._bNoise_group_box.setLayout(self._bNoise_box)
        for i, _label in enumerate(self._bNoise_labels):
            radio_button = Qt.QRadioButton(_label)
            self._bNoise_box.addWidget(radio_button)
            self._bNoise_button_group.addButton(radio_button, i)
        self._bNoise_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bNoise_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._bNoise_options.index(i)))
        self._bNoise_callback(self.bNoise)
        self._bNoise_button_group.buttonClicked[int].connect(
            lambda i: self.set_bNoise(self._bNoise_options[i]))
        self.top_grid_layout.addWidget(self._bNoise_group_box, 12, 1, 1, 1)
        for r in range(12, 13):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        # Create the options list
        self._bFilter_options = (0, 1, )
        # Create the labels list
        self._bFilter_labels = ('Rectangular', 'Raised Cosine', )
        # Create the combo box
        # Create the radio buttons
        self._bFilter_group_box = Qt.QGroupBox('Pulse Shaping Select' + ": ")
        self._bFilter_box = Qt.QHBoxLayout()
        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._bFilter_button_group = variable_chooser_button_group()
        self._bFilter_group_box.setLayout(self._bFilter_box)
        for i, _label in enumerate(self._bFilter_labels):
            radio_button = Qt.QRadioButton(_label)
            self._bFilter_box.addWidget(radio_button)
            self._bFilter_button_group.addButton(radio_button, i)
        self._bFilter_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bFilter_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._bFilter_options.index(i)))
        self._bFilter_callback(self.bFilter)
        self._bFilter_button_group.buttonClicked[int].connect(
            lambda i: self.set_bFilter(self._bFilter_options[i]))
        self.top_grid_layout.addWidget(self._bFilter_group_box, 12, 0, 1, 1)
        for r in range(12, 13):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._N_range = Range(0, 7, 1, 0, 200)
        self._N_win = RangeWidget(self._N_range, self.set_N, 'Nth Sample', "counter_slider", float)
        self.top_grid_layout.addWidget(self._N_win, 13, 1, 1, 1)
        for r in range(13, 14):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._roll_off_range = Range(0.01, 0.99, 0.01, 0.5, 200)
        self._roll_off_win = RangeWidget(self._roll_off_range, self.set_roll_off, 'Beta (Roll-Off-Factor)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._roll_off_win, 13, 0, 1, 1)
        for r in range(13, 14):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            2*sps, #size
            1, #samp_rate
            "", #name
            10 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(1/fps)
        self.qtgui_time_sink_x_0.set_y_axis(-2, 2)

        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, "buffer_start")
        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(True)
        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 = [lw, lw, lw, lw, lw,
            lw, lw, lw, lw, lw]
        colors = ['blue', 'red', 'yellow', '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(10):
            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.tab0_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 5, 1)
        for r in range(0, 5):
            self.tab0_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 1):
            self.tab0_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f(
            int(1e5),
            400,
            -axis,
            axis,
            "",
            1
        )

        self.qtgui_histogram_sink_x_0.set_update_time(1/fps)
        self.qtgui_histogram_sink_x_0.enable_autoscale(True)
        self.qtgui_histogram_sink_x_0.enable_accumulate(False)
        self.qtgui_histogram_sink_x_0.enable_grid(True)
        self.qtgui_histogram_sink_x_0.enable_axis_labels(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"]
        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 range(1):
            if len(labels[i]) == 0:
                self.qtgui_histogram_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab0_grid_layout_0.addWidget(self._qtgui_histogram_sink_x_0_win, 5, 1, 5, 1)
        for r in range(5, 10):
            self.tab0_grid_layout_0.setRowStretch(r, 1)
        for c in range(1, 2):
            self.tab0_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024, #size
            firdes.WIN_BLACKMAN_hARRIS, #wintype
            0, #fc
            samp_rate*1e3, #bw
            "", #name
            1
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(1/fps)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 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(0.05)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)



        labels = ['Magnitude', '', '', '', '',
            '', '', '', '', '']
        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 range(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.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 0, 5, 1)
        for r in range(0, 5):
            self.tab0_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.tab0_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0.set_processor_affinity([0])
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            1024, #size
            firdes.WIN_BLACKMAN_hARRIS, #wintype
            0, #fc
            samp_rate*1e3, #bw
            "", #name
            2
        )
        self.qtgui_freq_sink_x_0.set_update_time(1/fps)
        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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.05)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)


        self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['In-Phase', 'Quadrature', '', '', '',
            '', '', '', '', '']
        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 range(2):
            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.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 5, 0, 5, 1)
        for r in range(5, 10):
            self.tab0_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.tab0_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0.set_processor_affinity([0])
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024, #size
            "", #name
            2 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(1/fps)
        self.qtgui_const_sink_x_0.set_y_axis(-axis, axis)
        self.qtgui_const_sink_x_0.set_x_axis(-axis, axis)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(True)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)


        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, 1, 0, 0, 0,
            0, 0, 0, 0, 0]
        markers = [0, -1, 0, 0, 0,
            0, 0, 0, 0, 0]
        alphas = [1.0, 0.5, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab0_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 5, 1)
        for r in range(0, 5):
            self.tab0_grid_layout_0.setRowStretch(r, 1)
        for c in range(1, 2):
            self.tab0_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0.set_processor_affinity([0])
        self.interp_fir_filter_xxx_1_0 = filter.interp_fir_filter_ccc(sps, (1,1,1,1,1,1,1,1))
        self.interp_fir_filter_xxx_1_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(sps, rrc_filter)
        self.interp_fir_filter_xxx_1.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, rrc_filter)
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.iio_pluto_source_0 = iio.pluto_source('', int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, True, True, True, 'manual', 32, '', True)
        self.iio_pluto_sink_0 = iio.pluto_sink('', int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, False, 10.0, '', True)
        self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc(const.points(), 1)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False)
        self.blocks_tag_gate_0.set_single_key("")
        self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex*1,bFilter,0)
        self.blocks_selector_0_0.set_enabled(True)
        self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex*1,N,0)
        self.blocks_selector_0.set_enabled(True)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(np.exp(1j*2*pi*phase/360))
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_cc(2)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_cc(bNoise)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(gain_ )
        self.blocks_delay_0_2 = blocks.delay(gr.sizeof_float*1, -N+1024)
        self.blocks_delay_0_1 = blocks.delay(gr.sizeof_float*1, sps)
        self.blocks_delay_0_0_1 = blocks.delay(gr.sizeof_float*1, sps)
        self.blocks_delay_0_0_0_1_0 = blocks.delay(gr.sizeof_float*1, sps)
        self.blocks_delay_0_0_0_1 = blocks.delay(gr.sizeof_float*1, sps)
        self.blocks_delay_0_0_0_0_0 = blocks.delay(gr.sizeof_float*1, sps)
        self.blocks_delay_0_0_0_0 = blocks.delay(gr.sizeof_float*1, sps)
        self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_float*1, sps)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float*1, sps)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, sps)
        self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_gr_complex*1, 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_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 2, 8192))), True)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, std_dev, 0)
        self.analog_agc_xx_0 = analog.agc_cc(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_deinterleave_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_1, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0), (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_delay_0_2, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0), (self.qtgui_histogram_sink_x_0, 0))
        self.connect((self.blocks_deinterleave_0, 7), (self.blocks_selector_0, 7))
        self.connect((self.blocks_deinterleave_0, 4), (self.blocks_selector_0, 4))
        self.connect((self.blocks_deinterleave_0, 3), (self.blocks_selector_0, 3))
        self.connect((self.blocks_deinterleave_0, 6), (self.blocks_selector_0, 6))
        self.connect((self.blocks_deinterleave_0, 5), (self.blocks_selector_0, 5))
        self.connect((self.blocks_deinterleave_0, 0), (self.blocks_selector_0, 0))
        self.connect((self.blocks_deinterleave_0, 1), (self.blocks_selector_0, 1))
        self.connect((self.blocks_deinterleave_0, 2), (self.blocks_selector_0, 2))
        self.connect((self.blocks_delay_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_delay_0_0, 0), (self.blocks_delay_0_0_0, 0))
        self.connect((self.blocks_delay_0_0, 0), (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_delay_0_0_0, 0), (self.blocks_delay_0_0_0_0, 0))
        self.connect((self.blocks_delay_0_0_0, 0), (self.qtgui_time_sink_x_0, 3))
        self.connect((self.blocks_delay_0_0_0_0, 0), (self.blocks_delay_0_1, 0))
        self.connect((self.blocks_delay_0_0_0_0, 0), (self.qtgui_time_sink_x_0, 4))
        self.connect((self.blocks_delay_0_0_0_0_0, 0), (self.blocks_delay_0_0_0_1_0, 0))
        self.connect((self.blocks_delay_0_0_0_0_0, 0), (self.qtgui_time_sink_x_0, 8))
        self.connect((self.blocks_delay_0_0_0_1, 0), (self.blocks_delay_0_0_0_0_0, 0))
        self.connect((self.blocks_delay_0_0_0_1, 0), (self.qtgui_time_sink_x_0, 7))
        self.connect((self.blocks_delay_0_0_0_1_0, 0), (self.qtgui_time_sink_x_0, 9))
        self.connect((self.blocks_delay_0_0_1, 0), (self.blocks_delay_0_0_0_1, 0))
        self.connect((self.blocks_delay_0_0_1, 0), (self.qtgui_time_sink_x_0, 6))
        self.connect((self.blocks_delay_0_1, 0), (self.blocks_delay_0_0_1, 0))
        self.connect((self.blocks_delay_0_1, 0), (self.qtgui_time_sink_x_0, 5))
        self.connect((self.blocks_delay_0_2, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_delay_0_2, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.iio_pluto_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_selector_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_selector_0, 0), (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.blocks_selector_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_selector_0, 0), (self.qtgui_const_sink_x_0, 1))
        self.connect((self.blocks_selector_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_1, 0))
        self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_1_0, 0))
        self.connect((self.iio_pluto_source_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_selector_0_0, 1))
        self.connect((self.interp_fir_filter_xxx_1, 0), (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_multiply_const_vxx_0_0_0, 0))
Ejemplo n.º 35
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FM Stereo Receiver")

        ##################################################
        # Variables
        ##################################################
        self.smux_filt_samprate = smux_filt_samprate = 256e3
        self.smux_decim = smux_decim = 8
        self.samp_rate = samp_rate = 2.048e6
        self.right_gain = right_gain = 3
        self.left_gain = left_gain = 3
        self.bpf_base = bpf_base = 23e3
        self.RF_Gain = RF_Gain = 45
        self.CF = CF = 99.3e6

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate: 1.024M, 1.4M, 1.8M, 1.92M, 2.048M, 2.4M & 2. 56M",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._samp_rate_text_box, 1, 0, 1, 1)
        _right_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._right_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_right_gain_sizer,
        	value=self.right_gain,
        	callback=self.set_right_gain,
        	label="R Audio Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._right_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_right_gain_sizer,
        	value=self.right_gain,
        	callback=self.set_right_gain,
        	minimum=0,
        	maximum=5,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_right_gain_sizer, 0, 1, 1, 1)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "BB Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Stereo Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Stereo Signal")
        self.GridAdd(self.notebook_0, 2, 0, 1, 2)
        _left_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._left_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_left_gain_sizer,
        	value=self.left_gain,
        	callback=self.set_left_gain,
        	label="L Audio Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._left_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_left_gain_sizer,
        	value=self.left_gain,
        	callback=self.set_left_gain,
        	minimum=0,
        	maximum=5,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_left_gain_sizer, 0, 0, 1, 1)
        _RF_Gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_Gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_RF_Gain_sizer,
        	value=self.RF_Gain,
        	callback=self.set_RF_Gain,
        	label="RF Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._RF_Gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_RF_Gain_sizer,
        	value=self.RF_Gain,
        	callback=self.set_RF_Gain,
        	minimum=0,
        	maximum=100,
        	num_steps=45,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_RF_Gain_sizer, 1, 1, 1, 1)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Baseband Waterfall",
        	size=(800,100),
        )
        self.notebook_0.GetPage(0).GridAdd(self.wxgui_waterfallsink2_0.win, 3, 0, 1, 2)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.notebook_0.GetPage(3).GetWin(),
        	title="Scope Plot",
        	sample_rate=32e3,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=2,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        	size=(800,500),
        )
        self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_f(
        	self.notebook_0.GetPage(2).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=32e3,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Difference FFT ",
        	peak_hold=False,
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0_1.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f(
        	self.notebook_0.GetPage(1).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate/8,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Demodulated FFT",
        	peak_hold=False,
        	size=(800,800),
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0_0_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
        	self.notebook_0.GetPage(0).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="Baseband FFT",
        	peak_hold=False,
        	size=(800,100),
        )
        self.notebook_0.GetPage(0).GridAdd(self.wxgui_fftsink2_0_0.win, 2, 0, 1, 2)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
        	self.notebook_0.GetPage(2).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=32e3,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Sum FFT",
        	peak_hold=False,
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0.win)
        self.rfgain = blocks.multiply_const_vcc((RF_Gain, ))
        self.low_pass_filter_1_0 = filter.fir_filter_fff(smux_decim, firdes.low_pass(
        	1, smux_filt_samprate, 15e3, 500, firdes.WIN_HAMMING, 1))
        self.low_pass_filter_0 = filter.fir_filter_ccf(2, firdes.low_pass(
        	2, samp_rate/4, 100e3, 500, firdes.WIN_KAISER, 6.76))
        self.iir_filter_xxx_0 = filter.iir_filter_ccf((-0.00266, 0.00504, -0.00309, -0.00136, 0.00663, -0.01052, 0.01103, -0.00731, 0.00016, 0.00800, -0.01396, 0.01490, -0.00971, -0.00035, 0.01173, -0.01979, 0.02054, -0.01240, -0.00273, 0.01960, -0.03122, 0.03124, -0.01669, -0.01017, 0.04137, -0.06448, 0.06476, -0.02634, -0.07449, 0.33571, -0.00000, -0.33571, 0.07449, 0.02634, -0.06476, 0.06448, -0.04137, 0.01017, 0.01669, -0.03124, 0.03122, -0.01960, 0.00273, 0.01240, -0.02054, 0.01979, -0.01173, 0.00035, 0.00971, -0.01490, 0.01396, -0.00800, -0.00016, 0.00731, -0.01103, 0.01052, -0.00663, 0.00136, 0.00309, -0.00504, 0.00266
        ), (1 , ), False)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccf(4, (1,1,1,1))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        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_multiply_xx_1_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((right_gain, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((left_gain, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/Users/bretttt/iCloud_drive/16S/engs110/project/radio_dat/IQ_Data_STEREO1", True)
        self.blocks_divide_xx_1 = blocks.divide_cc(1)
        self.blocks_delay_2 = blocks.delay(gr.sizeof_gr_complex*1, 30)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.1, ))
        self.baseband_LPF = filter.fir_filter_fff(smux_decim, firdes.low_pass(
        	1, smux_filt_samprate, 15e3, 500, firdes.WIN_KAISER, 6.76))
        self.band_pass_filter_0_0_0 = filter.fir_filter_fcc(1, firdes.complex_band_pass(
        	1, smux_filt_samprate, 18000, 20000, 1000, firdes.WIN_KAISER, 1))
        self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass(
        	1, smux_filt_samprate, bpf_base, bpf_base+30e3, 500, firdes.WIN_KAISER, 6.76))
        self.audio_sink_0_0_0_0 = audio.sink(32000, "", True)
        self.analog_pll_refout_cc_0_0 = analog.pll_refout_cc(3.14/100, 0.152*3.14, 0.144*3.14)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=samp_rate/8, tau=75e-6)
        self.analog_fm_deemph_0 = analog.fm_deemph(fs=samp_rate/8, tau=75e-6)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)
        _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="Center Frequency",
        	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=80e6,
        	maximum=108e6,
        	num_steps=280,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_CF_sizer, 3, 0, 1, 2)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.analog_fm_deemph_0, 0), (self.audio_sink_0_0_0_0, 0))    
        self.connect((self.analog_fm_deemph_0_0, 0), (self.audio_sink_0_0_0_0, 1))    
        self.connect((self.analog_pll_refout_cc_0_0, 0), (self.blocks_multiply_xx_1_0, 0))    
        self.connect((self.analog_pll_refout_cc_0_0, 0), (self.blocks_multiply_xx_1_0, 1))    
        self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.band_pass_filter_0_0_0, 0), (self.analog_pll_refout_cc_0_0, 0))    
        self.connect((self.baseband_LPF, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.baseband_LPF, 0), (self.blocks_sub_xx_0, 0))    
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_divide_xx_1, 1))    
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_complex_to_imag_0, 0), (self.band_pass_filter_0, 0))    
        self.connect((self.blocks_complex_to_imag_0, 0), (self.band_pass_filter_0_0_0, 0))    
        self.connect((self.blocks_complex_to_imag_0, 0), (self.baseband_LPF, 0))    
        self.connect((self.blocks_complex_to_imag_0, 0), (self.wxgui_fftsink2_0_0_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_delay_2, 0), (self.blocks_multiply_conjugate_cc_0, 1))    
        self.connect((self.blocks_divide_xx_1, 0), (self.blocks_delay_2, 0))    
        self.connect((self.blocks_divide_xx_1, 0), (self.iir_filter_xxx_0, 0))    
        self.connect((self.blocks_file_source_0_0, 0), (self.rfgain, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_imag_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_fm_deemph_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.analog_fm_deemph_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.wxgui_fftsink2_0_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.wxgui_scopesink2_0, 1))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_1_0, 0))    
        self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.fir_filter_xxx_0_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_divide_xx_1, 0))    
        self.connect((self.low_pass_filter_1_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.low_pass_filter_1_0, 0), (self.blocks_sub_xx_0, 1))    
        self.connect((self.rfgain, 0), (self.blocks_throttle_0, 0))    
Ejemplo n.º 36
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Stereo FM receiver and RDS Decoder")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1000000
        self.bb_decim = bb_decim = 4
        self.freq_offset = freq_offset = 250000
        self.freq = freq = 106.1e6
        self.baseband_rate = baseband_rate = samp_rate/bb_decim
        self.audio_decim = audio_decim = 5
        self.xlate_bandwidth = xlate_bandwidth = 100000
        self.volume = volume = 0
        self.gain = gain = 37.6
        self.freq_tune = freq_tune = freq - freq_offset
        self.audio_rate = audio_rate = 48000
        self.audio_decim_rate = audio_decim_rate = baseband_rate/audio_decim

        ##################################################
        # Blocks
        ##################################################
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_volume_sizer,
        	value=self.volume,
        	callback=self.set_volume,
        	label="Volume",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._volume_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_volume_sizer,
        	value=self.volume,
        	callback=self.set_volume,
        	minimum=-20,
        	maximum=10,
        	num_steps=300,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_volume_sizer, 0, 1, 1, 1)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Pilot")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "DSBSC")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS constellation")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall")
        self.GridAdd(self.nb, 2, 0, 1, 2)
        _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="RF 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=49.6,
        	num_steps=124,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_gain_sizer, 0, 0, 1, 1)
        _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=88.1e6,
        	maximum=107.9e6,
        	num_steps=99,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_freq_sizer, 1, 0, 1, 2)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f(
        	self.nb.GetPage(8).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=baseband_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.nb.GetPage(8).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
        	self.nb.GetPage(7).GetWin(),
        	title="Scope Plot",
        	sample_rate=2375,
        	v_scale=0.4,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nb.GetPage(7).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.nb.GetPage(3).GetWin(),
        	title="Pilot",
        	sample_rate=baseband_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nb.GetPage(3).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_c(
        	self.nb.GetPage(5).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=audio_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="RDS",
        	peak_hold=False,
        )
        self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win)
        self.wxgui_fftsink2_0_0_0_1_0_0 = fftsink2.fft_sink_f(
        	self.nb.GetPage(6).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=-50,
        	ref_scale=2.0,
        	sample_rate=baseband_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="L-R",
        	peak_hold=False,
        )
        self.nb.GetPage(6).Add(self.wxgui_fftsink2_0_0_0_1_0_0.win)
        self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f(
        	self.nb.GetPage(4).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=baseband_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="DSBSC Sub-carrier",
        	peak_hold=False,
        )
        self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f(
        	self.nb.GetPage(2).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=audio_decim_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="L+R",
        	peak_hold=False,
        )
        self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f(
        	self.nb.GetPage(1).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=baseband_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.8,
        	title="FM Demod",
        	peak_hold=False,
        )
        self.nb.GetPage(1).Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.nb.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=-30,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.8,
        	title="Baseband",
        	peak_hold=False,
        )
        self.nb.GetPage(0).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_tune, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 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(gain, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(
        	1, samp_rate/bb_decim/audio_decim, 2375, 1, 100))
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
                interpolation=audio_rate,
                decimation=audio_decim_rate,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=audio_rate,
                decimation=audio_decim_rate,
                taps=None,
                fractional_bw=None,
        )
        self.gr_rds_parser_0 = rds.parser(False, True)
        self.gr_rds_panel_0 = rds.rdsPanel(freq, self.GetWin())
        self.Add(self.gr_rds_panel_0.panel)
        self.gr_rds_decoder_0 = rds.decoder(False, False)
        self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_fcc(audio_decim, (firdes.low_pass(2500.0,baseband_rate,2.4e3,2e3,firdes.WIN_HAMMING)), 57e3, baseband_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, samp_rate, xlate_bandwidth, 100000)), freq_offset, samp_rate)
        self.fir_filter_xxx_5 = filter.fir_filter_fff(audio_decim, (firdes.low_pass(1.0,baseband_rate,20e3,40e3,firdes.WIN_HAMMING)))
        self.fir_filter_xxx_5.declare_sample_delay(0)
        self.fir_filter_xxx_3 = filter.fir_filter_fff(1, (firdes.band_pass(1.0,baseband_rate,38e3-13e3,38e3+13e3,3e3,firdes.WIN_HAMMING)))
        self.fir_filter_xxx_3.declare_sample_delay(0)
        self.fir_filter_xxx_2 = filter.fir_filter_fcc(1, (firdes.complex_band_pass(1.0,baseband_rate,19e3-500,19e3+500,1e3,firdes.WIN_HAMMING)))
        self.fir_filter_xxx_2.declare_sample_delay(0)
        self.fir_filter_xxx_1 = filter.fir_filter_fff(audio_decim, (firdes.low_pass(1.0,baseband_rate,13e3,3e3,firdes.WIN_HAMMING)))
        self.fir_filter_xxx_1.declare_sample_delay(0)
        self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, 1*cmath.pi/100.0, -0.06, 0.06, 0.5, 0.05, samp_rate/bb_decim/audio_decim/ 2375.0, 0.001, 0.005)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((10**(1.*(volume+15)/10), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10**(1.*(volume+15)/10), ))
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 2)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=samp_rate,
        	audio_decimation=bb_decim,
        )
        self.analog_pll_refout_cc_0 = analog.pll_refout_cc(0.001, 2 * math.pi * (19000+200) / baseband_rate, 2 * math.pi * (19000-200) / baseband_rate)
        self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=audio_decim_rate, tau=75e-6)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=audio_decim_rate, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.fir_filter_xxx_3, 0), (self.wxgui_fftsink2_0_0_0_1, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_5, 0))
        self.connect((self.analog_fm_deemph_0_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_fm_deemph_0_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_0_0_0_1_0_0, 0))
        self.connect((self.fir_filter_xxx_5, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.fir_filter_xxx_5, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.fir_filter_xxx_3, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_fm_deemph_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_1, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_3, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_2, 0))
        self.connect((self.fir_filter_xxx_2, 0), (self.analog_pll_refout_cc_0, 0))
        self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_wfm_rcv_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0_1_0_1, 0))
        self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.wxgui_scopesink2_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.root_raised_cosine_filter_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_mpsk_receiver_cc_0, 0))
        self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_decoder_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_null_sink_0, 1))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.gr_rds_decoder_0, "out", self.gr_rds_parser_0, "in")
        self.msg_connect(self.gr_rds_parser_0, "out", self.gr_rds_panel_0, "in")
Ejemplo n.º 37
0
    def __init__(self, options):
	grc_wxgui.top_block_gui.__init__(self, title="DSSDR")

	self.initialized = False
	self.stopped = False

	self.options = copy.copy(options)
	self._constellation = digital.constellation_bpsk()
	self._excess_bw = options.excess_bw
	self._phase_bw = options.phase_bw
	self._freq_bw = options.freq_bw
	self._timing_bw = options.timing_bw
	self._if_freq = options.if_freq
	self._timing_max_dev= 1.5
	self._demod_class = digital.bpsk_demod  # the demodulator_class we're using
	self._chbw_factor = options.chbw_factor # channel filter bandwidth factor
	self._samples_per_second = 2e6
	self._nav_samples_per_second = 16e6
	self._down_decim = 1
	self._down_samples_per_second = self._scope_sample_rate = self._samples_per_second/self._down_decim
	self._up_samples_per_second = 1e6
	self._asm_threshold = 0
	self._access_code = None
	self._tm_packet_id = 4
	self._timestamp_id = 5
	self._down_bitrate = options.bitrate
	self._up_bitrate = options.up_bitrate
	self._up_samples_per_symbol = self._up_samples_per_second/self._up_bitrate
	self._samples_per_symbol = self._samples_per_second/self._down_decim/self._down_bitrate
	self._down_sub_freq = options.down_sub_freq
	self._up_sub_freq = 25e3
	self._tm_len = 8920
	self._up_tm_len = 8920
	self._coding_method = options.coding_method
	self._up_coding_method = 'None'
	self._up_subcarrier = 'Square'
	self._rs_i = 1
	self._ccsds_channel = 38
	self._uhd_carrier_offset = 10e3
	self._turn_div = 749
	self._turn_mult = 880
	self._modulation_index = 'pi/3'
	self._up_modulation_index = 1.047
	self._max_carrier_offset = 0.1
	self._dssdr_mixer_freq = options.rf_freq
	self._up_coding_rate = '1'
	self._down_coding_rate = '1'
	self._down_conv_en = "False"
	self._down_randomizer_en = options.down_randomizer_en
	self._down_manchester_en = options.down_manchester_en
	self._up_conv_en = "False"
	self._up_idle_sequence = "\\x55"
	self._down_default_gain = 64
	self._up_default_gain = 44
	self._up_en = True

        if self._access_code is None:
            self._access_code = packet_utils.default_access_code

	#Construct the lookup table for parameter-setting functions
	self.param_setters = {
		"DSSDR_CHANNEL": self.setChannel,
		"DSSDR_LO_FREQ": self.setLOFreq,
		"DSSDR_REF_FREQ": self.setRefFreq,
		"DSSDR_TURN_MULT": self.setTurnMult,
		"DSSDR_TURN_DIV": self.setTurnDiv,
		"DSSDR_UP_GAIN": self.setUpGain,
		"DSSDR_DOWN_GAIN": self.setDownGain,
		"DSSDR_UP_BITRATE": self.setUpBitrate,
		"DSSDR_DOWN_BITRATE": self.setDownBitrate,
		"DSSDR_DOWN_SAMPLE_RATE": self.setSampRate,
		"DSSDR_UP_SUB_FREQ": self.setUpSubFreq,
		"DSSDR_DOWN_SUB_FREQ": self.setDownSubFreq,
		"DSSDR_DOPPLER_REPORT": self.dopplerReport,
		"DSSDR_PN_RANGE": self.rangePN,
		"DSSDR_SEQUENTIAL_RANGE": self.rangeSequential,
		"DSSDR_DOWN_CODING_METHOD": self.setDownCodingMethod,
		"DSSDR_UP_CODING_METHOD": self.setUpCodingMethod,
		"DSSDR_DOWN_TM_LEN": self.setTMLen,
		"DSSDR_UP_TM_LEN": self.setUpTMLen,
		"DSSDR_DOWN_MOD_IDX": self.setDownModulationIndex,
		"DSSDR_UP_MOD_IDX": self.setUpModulationIndex,
		"DSSDR_DOWN_CONV_EN": self.setDownConvEn,
		"DSSDR_UP_CONV_EN": self.setUpConvEn,
		"DSSDR_ASM_TOL": self.setASMThreshold,
		"DSSDR_UP_SWEEP": self.freqSweep,
		"DSSDR_UP_IDLE": self.setUpIdleSequence,
		"DSSDR_UP_EN": self.setUpEn,
		"DSSDR_SYNC_TIME": self.syncSDRTime,
		"DSSDR_UP_SWEEP": self.freqSweep,
		"DSSDR_DOWN_ACQUIRE": self.acquireCarrier,
		"DSSDR_INPUT_SELECT": self.setPanelSelect,
		"DSSDR_REF_SELECT": self.setRefSelect,
		"DSSDR_PPS_SELECT": self.setPPSSelect
	}

	#TODO:Add status fields for things like DSSDR_REF_LOCK

	self._dssdr_channels = {
		3: [7149597994, 8400061729],
		4: [7150753857, 8401419752],
		5: [7151909723, 8402777779],
		6: [7153065586, 8404135802],
		7: [7154221449, 8405493825],
		8: [7155377316, 8406851853],
		9: [7156533179, 8408209877],
		10: [7157689045, 8409567903],
		11: [7158844908, 8410925927],
		12: [7160000771, 8412283950],
		13: [7161156637, 8413641977],
		14: [7162312500, 8415000000],
		15: [7163468363, 8416358023],
		16: [7164624229, 8417716050],
		17: [7165780092, 8419074073],
		18: [7166935955, 8420432097],
		19: [7168091821, 8421790123],
		20: [7169247684, 8423148147],
		21: [7170403551, 8424506175],
		22: [7171559414, 8425864198],
		23: [7172715277, 8427222221],
		24: [7173871143, 8428580248],
		25: [7175027006, 8429938271],
		26: [7176182869, 8431296295],
		27: [7177338735, 8432654321],
		28: [7178494598, 8434012345],
		29: [7179650464, 8435370372],
		30: [7180806327, 8436728395],
		31: [7181962190, 8438086418],
		32: [7183118057, 8439444446],
		33: [7184273920, 8440802469],
		34: [7185429783, 8442160493],
		35: [7186585649, 8443518520],
		36: [7187741512, 8444876543],
		37: [7188897378, 8446234570],
		38: [7190000000, 8450000000],
	}

	#FLOWGRAPH STUFF
	if options.test == True:
		self.u = blks2.tcp_source(
			itemsize=gr.sizeof_gr_complex*1,
			addr="",
			port=12905,
			server=True
		)
	elif options.fromfile == True:
		self.u2 = blocks.file_meta_source("iq_in.dat")
		self.u = blocks.throttle(gr.sizeof_gr_complex*1, self._samples_per_second)
	elif options.frombitlog == True:
		self.u3 = blocks.file_source(gr.sizeof_char, "bitstream_recording.in", True)
		self.u2 = blocks.uchar_to_float()
		self.u1 = blocks.throttle(gr.sizeof_float*1, self._down_bitrate)
		self.u = blocks.add_const_ff(-0.5)
	else:
		self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
		self.u.set_clock_source("external")
		self.u.set_time_source("external")
		self.u.set_samp_rate(self._samples_per_second)
		self.u.set_antenna("RX2")
		self.u.set_gain(self._down_default_gain)

		self.frontend = dfi.dssdrFrontendInterface(self.u)

	if options.debug_pps == True:
		self.debug_pps = blocks.tag_debug(gr.sizeof_gr_complex, "debug-pps", "rx_time")

	if options.tofile == True:
		self.u_tx = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_out.dat", self._up_samples_per_second)
	elif options.tonull == True:
		self.u_tx = blocks.null_sink(gr.sizeof_gr_complex)
	else:
		self.u_tx = uhd.usrp_sink(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
		self.u_tx.set_clock_source("external")
		self.u_tx.set_time_source("external")
		self.u_tx.set_samp_rate(self._up_samples_per_second)
		self.u_tx.set_antenna("TX/RX")
		self.u_tx.set_gain(self._up_default_gain)

	#GUI STUFF
	if options.graphics == True:
		self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "RX")
		self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "TX")
		self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Nav")
		self.Add(self.nb0)
		self.constellation_scope = scopesink2.scope_sink_c(
			self.nb0.GetPage(0).GetWin(),
			title="Scope Plot",
			sample_rate=self._scope_sample_rate,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=True,
			num_inputs=1,
			trig_mode=wxgui.TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
	        self.nb0.GetPage(0).Add(self.constellation_scope.win)
		#self.constellation_scope.win.set_marker('plus')
		self._scope_is_fft = False
		self.time_scope = scopesink2.scope_sink_f(
			self.nb0.GetPage(0).GetWin(),
			title="Scope Plot",
			sample_rate=self._scope_sample_rate,
			v_scale=0,
			v_offset=0,
			t_scale=.005,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=wxgui.TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.nb0.GetPage(0).Add(self.time_scope.win)
		self.nb0.GetPage(0).GetWin()._box.Hide(self.time_scope.win)
		self.fft_scope = fftsink2.fft_sink_c(
			self.nb0.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=self._scope_sample_rate,
			fft_size=1024,
		 	fft_rate=15,
			average=False,
			avg_alpha=None,
			title="FFT Plot",
			peak_hold=False,
		)
		self.nb0.GetPage(0).Add(self.fft_scope.win)
		self.nb0.GetPage(0).GetWin()._box.Hide(self.fft_scope.win)
	
		self.row1_sizer = wx.BoxSizer(wx.HORIZONTAL)
		self.recording_onoff_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Off',
			callback=self.setRecording,
			label="IQ Recording",
			choices=['Off','On'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.front_panel_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='RF',
			callback=self.setPanelSelect,
			label="Input Select",
			choices=['RF','IF'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.ref_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Internal',
			callback=self.setRefSelect,
			label="Ref Select",
			choices=['Internal','External'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.pps_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Internal',
			callback=self.setPPSSelect,
			label="PPS Select",
			choices=['Internal','External'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)

		self.sync_button = forms.button(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Sync to PPS',
			callback=self.syncSDRTime,
			choices=['Sync to PPS'],
			style=wx.RA_HORIZONTAL,
		)
		self.ref_locked_text = forms.static_text(
			parent=self.nb0.GetPage(0).GetWin(),
			value="",
			callback=self.setRefLocked,
			label="",
			converter=forms.str_converter(),
		)
		self.row1_sizer.Add(self.recording_onoff_chooser, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.front_panel_chooser, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.ref_chooser, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.pps_chooser, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.sync_button, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.ref_locked_text, flag=wx.ALIGN_CENTER)
		self.nb0.GetPage(0).Add(self.row1_sizer)
		self.complex_scope_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Constellation',
			callback=self.setComplexScopeStyle,
			label="Complex Scope",
			choices=['Constellation','FFT'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self.complex_scope_chooser)
		self.scope_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='USRP',
			callback=self.setScopePoint,
			label="Scope Probe Point",
			choices=['USRP','Carrier Tracking','Sub-Carrier Costas','Sub-Carrier Sync','Data Sync'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self.scope_chooser)
		self._bitrate_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_bitrate,
			callback=self.setDownBitrate,
			label="Symbol Rate",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._bitrate_text_box)
		self._samprate_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._samples_per_second,
			callback=self.setSampRate,
			label="Sampling Rate",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._samprate_text_box)
		self._subcfreq_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_sub_freq,
			callback=self.setDownSubFreq,
			label="Downlink Subcarrier Frequency",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._subcfreq_text_box)
		self._mod_index_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._modulation_index,
			callback=self.setDownModulationIndex,
			label="Modulation Index",
			choices=['pi/2', 'pi/3'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self._mod_index_chooser)
		self._pktlen_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._tm_len,
			callback=self.setTMLen,
			label="Downlink Packet Length (bits)",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._pktlen_text_box)
		self._coding_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._coding_method,
			callback=self.setDownCodingMethod,
			label="Coding",
			choices=['None', 'RS', 'Turbo 1/2', 'Turbo 1/3', 'Turbo 1/4', 'Turbo 1/6'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self._coding_chooser)
		self._down_conv_check_box = forms.check_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_conv_en,
			callback=self.setDownConvEn,
			label="Convolutional Decode",
			true="True",
			false="False",
		)
		self.nb0.GetPage(0).Add(self._down_conv_check_box)
		self._down_randomizer_check_box = forms.check_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_randomizer_en,
			callback=self.setDownRandomizerEn,
			label="De-randomizer",
			true=True,
			false=False,
		)
		self.nb0.GetPage(0).Add(self._down_randomizer_check_box)
		self._down_manchester_check_box = forms.check_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_manchester_en,
			callback=self.setDownManchesterEn,
			label="Manchester Decode",
			true=True,
			false=False,
		)
		self.nb0.GetPage(0).Add(self._down_manchester_check_box)
		self._pktlen_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._asm_threshold,
			callback=self.setASMThreshold,
			label="ASM Error Tolerance (bits)",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._pktlen_text_box)
		self._coding_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._rs_i,
			callback=self.setRSI,
			label="Reed-Solomon Interleaving Depth",
			choices=[1,5],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self._coding_chooser)
		self._ccsds_chan_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._ccsds_channel,
			callback=self.setChannel,
			label="CCSDS Channel",
			converter=forms.int_converter(),
		)
		self.nb0.GetPage(0).Add(self._ccsds_chan_text_box)
		self.setChannel(self._ccsds_channel)
	
		if options.test == True or options.fromfile == True or options.frombitlog == True:
			glow = 0.0
			ghigh = 1.0
			cur_g = 0.5
		else:
			g = self.u.get_gain_range()
			cur_g = self._down_default_gain
		
			# some configurations don't have gain control
			if g.stop() <= g.start():
				glow = 0.0
				ghigh = 1.0
		
			else:
				glow = g.start()
				ghigh = g.stop()
		
		self._uhd_gain_slider = wx.BoxSizer(wx.HORIZONTAL)
		form.slider_field(
			parent=self.nb0.GetPage(0).GetWin(),
			sizer=self._uhd_gain_slider,
			label="USRP RX Gain",
			weight=3,
			min=int(glow), 
			max=int(ghigh),
			value=cur_g,
			callback=self.setDownGain
		)
		self.nb0.GetPage(0).Add(self._uhd_gain_slider)

		#TX chain GUI components
		if options.test == True or options.tofile == True or options.tonull == True:
			gtxlow = 0.0
			gtxhigh = 1.0
			cur_gtx = 0.5
		else:
			gtx = self.u_tx.get_gain_range()
			cur_gtx = self._up_default_gain
		
			# some configurations don't have gain control
			if gtx.stop() <= gtx.start():
				gtxlow = 0.0
				gtxhigh = 1.0
		
			else:
				gtxlow = gtx.start()
				gtxhigh = gtx.stop()

		self._up_en_chooser = forms.check_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value='True',
			callback=self.setUpEn,
			label="TX Enable",
			true='True',
			false='False',
		)
		self.nb0.GetPage(1).Add(self._up_en_chooser)

		self._uhd_tx_gain_slider = wx.BoxSizer(wx.HORIZONTAL)
		form.slider_field(
			parent=self.nb0.GetPage(1).GetWin(),
			sizer=self._uhd_tx_gain_slider,
			label="USRP TX Gain",
			weight=3,
			min=int(gtxlow), 
			max=int(gtxhigh),
			value=cur_gtx,
			callback=self.setUpGain
		)
		self.nb0.GetPage(1).Add(self._uhd_tx_gain_slider)
		self._subcfreq_up_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_sub_freq,
			callback=self.setUpSubFreq,
			label="Uplink Subcarrier Frequency",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._subcfreq_up_text_box)
		self._up_bitrate_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_bitrate,
			callback=self.setUpBitrate,
			label="Uplink Bitrate",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._up_bitrate_text_box)
		self._up_data_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value="1234ABCD",
			callback=self.txData,
			label="TX Data",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(1).Add(self._up_data_text_box)
		self._up_mod_index_chooser = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_modulation_index,
			callback=self.setUpModulationIndex,
			label="Uplink Modulation Index",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._up_mod_index_chooser)
		self._up_coding_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_coding_method,
			callback=self.setUpCodingMethod,
			label="Coding",
			choices=['None', 'RS'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(1).Add(self._up_coding_chooser)
		self._subcarrier_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_subcarrier,
			callback=self.setUpSubcarrier,
			label="Subcarrier Type",
			choices=['Square','Sine'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(1).Add(self._subcarrier_chooser)
		self._up_conv_check_box = forms.check_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_conv_en,
			callback=self.setUpConvEn,
			label="Convolutional Encode",
			true="True",
			false="False",
		)
		self.nb0.GetPage(1).Add(self._up_conv_check_box)
		self._up_pktlen_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_tm_len,
			callback=self.setUpTMLen,
			label="Uplink Packet Length (bits)",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._up_pktlen_text_box)
		self._uhd_offset_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._uhd_carrier_offset,
			callback=self.setUHDCarrierOffset,
			label="USRP Offset Frequency (Hz)",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._uhd_offset_text_box)
		self._sweep_gen_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value="rf2_1",
			callback=self.freqSweep,
			label="Frequency Sweep Profile",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(1).Add(self._sweep_gen_text_box)
		self._idle_sequence_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_idle_sequence,
			callback=self.setUpIdleSequence,
			label="Uplink Idle Sequence",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(1).Add(self._idle_sequence_text_box)
		self._pn_ranging_text_box = forms.text_box(
			parent=self.nb0.GetPage(2).GetWin(),
			value="",
			callback=self.rangePN,
			label="Queue PN Ranging",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(2).Add(self._pn_ranging_text_box)
		self._sequential_ranging_text_box = forms.text_box(
			parent=self.nb0.GetPage(2).GetWin(),
			value="",
			callback=self.rangeSequential,
			label="Queue Sequential Ranging",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(2).Add(self._sequential_ranging_text_box)
		self.row2_sizer = wx.BoxSizer(wx.HORIZONTAL)
		self.freq_acq_button = forms.button(
			parent=self.nb0.GetPage(2).GetWin(),
			value='Acquire Carrier Offset',
			callback=self.acquireCarrier,
			choices=['Acquire Carrier Offset'],
			style=wx.RA_HORIZONTAL,
		)
		self.carrier_offset_text = forms.static_text(
			parent=self.nb0.GetPage(2).GetWin(),
			value="",
			label="",
			converter=forms.str_converter(),
		)
		self.row2_sizer.Add(self.freq_acq_button, flag=wx.ALIGN_CENTER)
		self.row2_sizer.Add(self.carrier_offset_text, flag=wx.ALIGN_CENTER)
		self.nb0.GetPage(2).Add(self.row2_sizer)


	self.file_sink = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_recording.dat", self._samples_per_second)
	self.file_sink.close()
	self.iq_recording_ctr = 0

	# Selection logic to switch between recording and normal flowgraph routes
	# NOTE: u_valve logic is implemented backwards in GNURadio....
	#self.u_valve = blks2.valve(
	#	item_size=gr.sizeof_gr_complex,
	#	open=False
	#)

	# Temporary code used to verify coherent turnaround
	self.turnaround_mixer = blocks.multiply_cc()
	self.turnaround_mixer_source = analog.sig_source_c(self._down_samples_per_second, analog.GR_SIN_WAVE, -25e3, 1.0)
	self.turnaround_iir = filter.single_pole_iir_filter_cc(0.0001)
	self.turnaround_null = blocks.null_sink(gr.sizeof_float)

	# PLL and associated carrier for tracking carrier frequency if residual carrier is used
	self.carrier_tracking = sdrp.pll_freq_acq_cc(math.pi/2000, math.pi, -math.pi, int(options.acq_samples))
	self.imag_to_float = blocks.complex_to_imag()

	#Suppressed carrier requires costas after subcarrier mixer
	self.subcarrier_costas = digital.costas_loop_cc(0.001, 2)
	self.real_to_float = blocks.complex_to_real()

	#Square wave subcarrier sync
	self.subcarrier_sync = sdrp.square_sub_tracker_ff(0.001, 2*self._down_sub_freq/self._down_samples_per_second*1.0001, 2*self._down_sub_freq/self._down_samples_per_second*0.9999)

	#Data sync
	self.data_sync = sdrp.square_data_tracker_ff(0.001, self._down_bitrate/self._down_samples_per_second*1.001, self._down_bitrate/self._down_samples_per_second*0.999)

	#Data framing
	self.soft_correlator = sdrp.correlate_soft_access_tag_ff(conv_packed_binary_string_to_1_0_string('\x1A\xCF\xFC\x1D'), self._asm_threshold, "asm_corr")
	self.conv_decoder = sdrp.ccsds_tm_conv_decoder("asm_corr")
	self.de_randomizer = sdrp.ccsds_tm_derandomizer("asm_corr")
	self.tm_framer = sdrp.ccsds_tm_framer(self._tm_packet_id, self._timestamp_id, "asm_corr", "rx_time", self._down_bitrate)
	self.tm_framer.setFrameLength(self._tm_len)

	self._current_scope_block = None
	self._current_scoped_block = self.u
	self._current_scoped_block_port = 0

	self._recording = 'Off'

	#TX path in flowgraph
	self.pkt_gen_msgq = gr.msg_queue(10)
        self.pkt_gen = sdrp.ccsds_tm_tx(self._tm_packet_id, self._timestamp_id, 1.0, 16, self.pkt_gen_msgq)
	self.conj = blocks.conjugate_cc()

	#Sweep generator for transponder lock
	self.sweep_gen = sdrp.sweep_generator_cc(self._up_samples_per_second)

	# DSSDR subcarrier mixer (either 25 kHz or 0 kHz depending on baud rate)
	self.up_subcarrier_mixer = blocks.multiply_ff()
	self.subcarrier_mixer_source_tx = analog.sig_source_f(self._up_samples_per_second, analog.GR_SQR_WAVE, 25e3, 2.0, -1.0)
	self.phase_mod_tx = analog.phase_modulator_fc(self._up_modulation_index)
	self.tx_attenuator = blocks.multiply_const_cc((0.1+0.0j))

	#Add in bit recorder if needed
	if self.options.bitlog:
		self.bit_slicer = digital.binary_slicer_fb()
		self.bit_recorder = blocks.file_sink(1, "bitstream_recording.out")


	self.setDownCodingMethod(self._coding_method)
	self.setUpCodingMethod("None")
	self.setUpSubcarrier(self._up_subcarrier)
	self.setDownBitrate(self._down_bitrate)
	self.setUpBitrate(self._up_bitrate)
	self.setDownModulationIndex(self._modulation_index)
	self.setUpModulationIndex(self._up_modulation_index)
	self.setDownConvEn(self._down_conv_en)
	self.setUpConvEn(self._up_conv_en)
	self.setUpIdleSequence(self._up_idle_sequence)
	self.setDownRandomizerEn(self._down_randomizer_en)
	self.setDownManchesterEn(self._down_manchester_en)

	#Connection to outside world
	self.socket_pdu = blocks.socket_pdu("TCP_SERVER", "127.0.0.1", "12902", 10000)
	self.sdrp_interpreter = sdrp.sdrp_packet_interpreter()
	self.msg_connect(self.tm_framer, "tm_frame_out", self.sdrp_interpreter, "sdrp_pdu_in")
	self.msg_connect(self.sdrp_interpreter, "socket_pdu_out", self.socket_pdu, "pdus")
	self.msg_connect(self.socket_pdu, "pdus", self.sdrp_interpreter, "socket_pdu_in")
	self.msg_connect(self.sdrp_interpreter,"sdrp_pdu_out", self.pkt_gen, "ccsds_tx_msg_in")

	if options.test == False and options.fromfile == False and options.frombitlog == False:
		_threading.Thread(target=self.watchRef).start()

	self.initialized = True
	print "DS-SDR Initialized"
Ejemplo n.º 38
0
    def __init__(self, demod_rate, audio_decimation):
        """
        Hierarchical block for demodulating a broadcast FM signal.

        The input is the downconverted complex baseband signal (gr_complex).
        The output is two streams of the demodulated audio (float) 0=Left, 1=Right.

        Args:
            demod_rate: input sample rate of complex baseband input. (float)
            audio_decimation: how much to decimate demod_rate to get to audio. (integer) FIXME: Not actually implemented!
        """
        gr.hier_block2.__init__(
            self,
            "wfm_rcv_pll",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature(2, 2, gr.sizeof_float))  # Output signature

        if audio_decimation != int(audio_decimation):
            raise ValueError("audio_decimation needs to be an integer")
        audio_decimation = int(audio_decimation)

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 3840000
        self.rf_decim = rf_decim = 10
        self.demod_rate = demod_rate = (int)(samp_rate / rf_decim)
        self.stereo_carrier_filter_coeffs_0 = stereo_carrier_filter_coeffs_0 = firdes.band_pass(
            1.0, demod_rate, 37600, 38400, 400, fft.window.WIN_HAMMING, 6.76)
        self.stereo_carrier_filter_coeffs = stereo_carrier_filter_coeffs = firdes.complex_band_pass(
            1.0, demod_rate, 18980, 19020, 1500, fft.window.WIN_HAMMING, 6.76)
        self.deviation = deviation = 75000
        self.audio_filter = audio_filter = firdes.low_pass(
            1, demod_rate, 15000, 1500, fft.window.WIN_HAMMING, 6.76)
        self.audio_decim = audio_decim = (int)(demod_rate / 48000)

        ##################################################
        # Blocks
        ##################################################
        self.fir_filter_xxx_1 = filter.fir_filter_fcc(
            1, stereo_carrier_filter_coeffs)
        self.fir_filter_xxx_1.declare_sample_delay(0)
        self.fft_filter_xxx_3 = filter.fft_filter_fff(
            1, stereo_carrier_filter_coeffs_0, 1)
        self.fft_filter_xxx_3.declare_sample_delay(0)
        self.fft_filter_xxx_2 = filter.fft_filter_fff(audio_decim,
                                                      audio_filter, 1)
        self.fft_filter_xxx_2.declare_sample_delay(0)
        self.fft_filter_xxx_1 = filter.fft_filter_fff(audio_decim,
                                                      audio_filter, 1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.blocks_multiply_xx_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_ff(5.5)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(-5.5)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_xx_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            demod_rate / (2 * math.pi * deviation))
        self.analog_pll_refout_cc_0 = analog.pll_refout_cc(
            0.001, 2 * math.pi * 19200 / demod_rate,
            2 * math.pi * 18800 / demod_rate)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=48000, tau=75e-6)
        self.analog_fm_deemph_0 = analog.fm_deemph(fs=48000, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fm_deemph_0, 0), (self, 0))
        self.connect((self.analog_fm_deemph_0_0, 0), (self, 1))
        self.connect((self.analog_pll_refout_cc_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_pll_refout_cc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fft_filter_xxx_1, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fir_filter_xxx_1, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_fm_deemph_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.analog_fm_deemph_0_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.fft_filter_xxx_3, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.fft_filter_xxx_2, 0))
        self.connect((self.fft_filter_xxx_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.fft_filter_xxx_1, 0), (self.blocks_add_xx_0_0, 1))
        self.connect((self.fft_filter_xxx_2, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.fft_filter_xxx_2, 0),
                     (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.fft_filter_xxx_3, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.fir_filter_xxx_1, 0),
                     (self.analog_pll_refout_cc_0, 0))
        self.connect((self, 0), (self.analog_quadrature_demod_cf_0, 0))
Ejemplo n.º 39
0
    def __init__(self):
        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")

        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.samp_rate = samp_rate = 20e6
        self.freq = freq = 2400e6
        self.bandwidth = bandwidth = 1.5e6

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_sink_x_0 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #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_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)



        self.osmosdr_source_1 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=179" )
        self.osmosdr_source_1.set_sample_rate(samp_rate)
        self.osmosdr_source_1.set_center_freq(freq, 0)
        self.osmosdr_source_1.set_freq_corr(0, 0)
        self.osmosdr_source_1.set_dc_offset_mode(0, 0)
        self.osmosdr_source_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_1.set_gain_mode(True, 0)
        self.osmosdr_source_1.set_gain(15, 0)
        self.osmosdr_source_1.set_if_gain(0, 0)
        self.osmosdr_source_1.set_bb_gain(0, 0)
        self.osmosdr_source_1.set_antenna('RX', 0)
        self.osmosdr_source_1.set_bandwidth(bandwidth, 0)

        self.correctiq_correctiq_0 = correctiq.correctiq()
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_float*1, '/dev/shm/dataI.dat', False)
        self.blocks_file_sink_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float*1, '/dev/shm/dataR.dat', False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.correctiq_correctiq_0, 0), (self.blocks_complex_to_imag_0, 0))
        self.connect((self.correctiq_correctiq_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.correctiq_correctiq_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.osmosdr_source_1, 0), (self.correctiq_correctiq_0, 0))
Ejemplo n.º 40
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="Stereo FM receiver and RDS Decoder")
        _icon_path = "/usr/share/icons/hicolor/24x24/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1000000
        self.bb_decim = bb_decim = 4
        self.freq_offset = freq_offset = 250000
        self.freq = freq = 97e6
        self.baseband_rate = baseband_rate = samp_rate / bb_decim
        self.audio_decim = audio_decim = 5
        self.xlate_bandwidth = xlate_bandwidth = 100000
        self.volume = volume = 0
        self.gain = gain = 20
        self.freq_tune = freq_tune = freq - freq_offset
        self.audio_rate = audio_rate = 48000
        self.audio_decim_rate = audio_decim_rate = baseband_rate / audio_decim

        ##################################################
        # Blocks
        ##################################################
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            label='Volume',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            minimum=-20,
            maximum=10,
            num_steps=300,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_volume_sizer, 0, 1, 1, 1)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Pilot")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "DSBSC")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS constellation")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall")
        self.GridAdd(self.nb, 2, 0, 1, 2)
        _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='RF 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=49.6,
            num_steps=124,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_gain_sizer, 0, 0, 1, 1)
        _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=88.1e6,
            maximum=107.9e6,
            num_steps=99,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_freq_sizer, 1, 0, 1, 2)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f(
            self.nb.GetPage(8).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=baseband_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Waterfall Plot',
        )
        self.nb.GetPage(8).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
            self.nb.GetPage(7).GetWin(),
            title='Scope Plot',
            sample_rate=2375,
            v_scale=0.4,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.nb.GetPage(7).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.nb.GetPage(3).GetWin(),
            title='Pilot',
            sample_rate=baseband_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.nb.GetPage(3).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_c(
            self.nb.GetPage(5).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=audio_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='RDS',
            peak_hold=False,
        )
        self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win)
        self.wxgui_fftsink2_0_0_0_1_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(6).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=-50,
            ref_scale=2.0,
            sample_rate=baseband_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='L-R',
            peak_hold=False,
        )
        self.nb.GetPage(6).Add(self.wxgui_fftsink2_0_0_0_1_0_0.win)
        self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f(
            self.nb.GetPage(4).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=baseband_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='DSBSC Sub-carrier',
            peak_hold=False,
        )
        self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(2).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=audio_decim_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='L+R',
            peak_hold=False,
        )
        self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=baseband_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.8,
            title='FM Demod',
            peak_hold=False,
        )
        self.nb.GetPage(1).Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.nb.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=-30,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.8,
            title='Baseband',
            peak_hold=False,
        )
        self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.root_raised_cosine(1, samp_rate / bb_decim / audio_decim,
                                      2375, 1, 100))
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=audio_rate,
            decimation=audio_decim_rate,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=audio_rate,
            decimation=audio_decim_rate,
            taps=None,
            fractional_bw=None,
        )
        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_tune, 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(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.gr_rds_parser_0 = rds.parser(True, False, 0)
        self.gr_rds_panel_0 = rds.rdsPanel(freq, self.GetWin())
        self.Add(self.gr_rds_panel_0.panel)
        self.gr_rds_decoder_0 = rds.decoder(False, False)
        self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_fcc(
            audio_decim, (firdes.low_pass(2500.0, baseband_rate, 2.4e3, 2e3,
                                          firdes.WIN_HAMMING)), 57e3,
            baseband_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, xlate_bandwidth, 100000)),
            freq_offset, samp_rate)
        self.fir_filter_xxx_5 = filter.fir_filter_fff(
            audio_decim, (firdes.low_pass(1.0, baseband_rate, 20e3, 40e3,
                                          firdes.WIN_HAMMING)))
        self.fir_filter_xxx_5.declare_sample_delay(0)
        self.fir_filter_xxx_3 = filter.fir_filter_fff(
            1, (firdes.band_pass(1.0, baseband_rate, 38e3 - 13e3, 38e3 + 13e3,
                                 3e3, firdes.WIN_HAMMING)))
        self.fir_filter_xxx_3.declare_sample_delay(0)
        self.fir_filter_xxx_2 = filter.fir_filter_fcc(
            1, (firdes.complex_band_pass(1.0, baseband_rate, 19e3 - 500,
                                         19e3 + 500, 1e3, firdes.WIN_HAMMING)))
        self.fir_filter_xxx_2.declare_sample_delay(0)
        self.fir_filter_xxx_1 = filter.fir_filter_fff(
            audio_decim, (firdes.low_pass(1.0, baseband_rate, 13e3, 3e3,
                                          firdes.WIN_HAMMING)))
        self.fir_filter_xxx_1.declare_sample_delay(0)
        self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(
            2, 0, 1 * cmath.pi / 100.0, -0.06, 0.06, 0.5, 0.05,
            samp_rate / bb_decim / audio_decim / 2375.0, 0.001, 0.005)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (10**(1. * (volume + 15) / 10), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (10**(1. * (volume + 15) / 10), ))
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_char * 1, 2)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(audio_rate, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=samp_rate,
            audio_decimation=bb_decim,
        )
        self.analog_pll_refout_cc_0 = analog.pll_refout_cc(
            0.001, 2 * math.pi * (19000 + 200) / baseband_rate,
            2 * math.pi * (19000 - 200) / baseband_rate)
        self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=audio_decim_rate,
                                                       tau=75e-6)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=audio_decim_rate,
                                                     tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.gr_rds_decoder_0, 'out'),
                         (self.gr_rds_parser_0, 'in'))
        self.msg_connect((self.gr_rds_parser_0, 'out'),
                         (self.gr_rds_panel_0, 'in'))
        self.connect((self.analog_fm_deemph_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.analog_fm_deemph_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_pll_refout_cc_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.analog_pll_refout_cc_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_1, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_2, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_3, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.freq_xlating_fir_filter_xxx_1, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.analog_fm_deemph_0_0_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.fir_filter_xxx_5, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.wxgui_fftsink2_0_0_0_1_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.gr_rds_decoder_0, 0))
        self.connect((self.digital_mpsk_receiver_cc_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_mpsk_receiver_cc_0, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.fir_filter_xxx_1, 0),
                     (self.wxgui_fftsink2_0_0_0, 0))
        self.connect((self.fir_filter_xxx_2, 0),
                     (self.analog_pll_refout_cc_0, 0))
        self.connect((self.fir_filter_xxx_3, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.fir_filter_xxx_3, 0),
                     (self.wxgui_fftsink2_0_0_0_1, 0))
        self.connect((self.fir_filter_xxx_5, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.fir_filter_xxx_5, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_wfm_rcv_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_1, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_1, 0),
                     (self.wxgui_fftsink2_0_0_0_1_0_1, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.audio_sink_0, 1))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_mpsk_receiver_cc_0, 0))
Ejemplo n.º 41
0
def complex_to_imag(N):
    op = blocks.complex_to_imag()
    tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_float, 1, 1)
    return tb
Ejemplo n.º 42
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="General I/Q Receiver")
        _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 = 2500000
        self.rf_gain = rf_gain = 7
        self.if_gain = if_gain = 7
        self.f_c = f_c = 1000
        self.bb_gain = bb_gain = 7
        self.ReceiverGain = ReceiverGain = 30

        ##################################################
        # Blocks
        ##################################################
        _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            label='RF',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rf_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            minimum=0,
            maximum=90,
            num_steps=90,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rf_gain_sizer, 9, 2, 1, 1)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Scope Plot")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Magnitude")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Phase")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Real")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Imaginary")
        self.Add(self.notebook_0)
        _if_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._if_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_if_gain_sizer,
            value=self.if_gain,
            callback=self.set_if_gain,
            label='IF',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._if_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_if_gain_sizer,
            value=self.if_gain,
            callback=self.set_if_gain,
            minimum=0,
            maximum=60,
            num_steps=60,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_if_gain_sizer, 9, 1, 1, 1)
        _bb_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._bb_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_bb_gain_sizer,
            value=self.bb_gain,
            callback=self.set_bb_gain,
            label='BB',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._bb_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_bb_gain_sizer,
            value=self.bb_gain,
            callback=self.set_bb_gain,
            minimum=0,
            maximum=90,
            num_steps=90,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_bb_gain_sizer, 9, 3, 1, 1)
        self.wxgui_scopesink3 = scopesink2.scope_sink_c(
            self.notebook_0.GetPage(0).GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate,
            v_scale=.05,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_scopesink3.win)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_f(
            self.notebook_0.GetPage(4).GetWin(),
            title='Imaginary',
            sample_rate=samp_rate,
            v_scale=0.05,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.notebook_0.GetPage(4).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.notebook_0.GetPage(3).GetWin(),
            title='Real',
            sample_rate=samp_rate,
            v_scale=.05,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_scopesink2 = scopesink2.scope_sink_f(
            self.notebook_0.GetPage(2).GetWin(),
            title='Phase',
            sample_rate=samp_rate,
            v_scale=1,
            v_offset=0,
            t_scale=0.002,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_scopesink2.win)
        self.wxgui_scopesink1 = scopesink2.scope_sink_f(
            self.notebook_0.GetPage(1).GetWin(),
            title='Magnitude',
            sample_rate=samp_rate,
            v_scale=.05,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_scopesink1.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=4,
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_source_1 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'airspy')
        self.osmosdr_source_1.set_sample_rate(samp_rate)
        self.osmosdr_source_1.set_center_freq(200000000, 0)
        self.osmosdr_source_1.set_freq_corr(0, 0)
        self.osmosdr_source_1.set_dc_offset_mode(0, 0)
        self.osmosdr_source_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_1.set_gain_mode(False, 0)
        self.osmosdr_source_1.set_gain(rf_gain, 0)
        self.osmosdr_source_1.set_if_gain(if_gain, 0)
        self.osmosdr_source_1.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_1.set_antenna('', 0)
        self.osmosdr_source_1.set_bandwidth(0, 0)

        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        _ReceiverGain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ReceiverGain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_ReceiverGain_sizer,
            value=self.ReceiverGain,
            callback=self.set_ReceiverGain,
            label='ReceiverGain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._ReceiverGain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_ReceiverGain_sizer,
            value=self.ReceiverGain,
            callback=self.set_ReceiverGain,
            minimum=0,
            maximum=38,
            num_steps=38,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_ReceiverGain_sizer)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.wxgui_scopesink2, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.wxgui_scopesink2_2, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.wxgui_scopesink1, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.osmosdr_source_1, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.wxgui_scopesink3, 0))
Ejemplo n.º 43
0
def complex_to_imag(N):
    op = blocks.complex_to_imag()
    tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_float, 1, 1)
    return tb
Ejemplo n.º 44
0
    def __init__(self):
        gr.top_block.__init__(self, "Fhss Tx")

        ##################################################
        # Variables
        ##################################################
        self.samp_sym = samp_sym = 12000
        self.transistion = transistion = 50
        self.tone_freq = tone_freq = 0
        self.sideband_rx = sideband_rx = 6000
        self.sideband = sideband = 6000
        self.samp_rate = samp_rate = 12000
        self.interpolation = interpolation = 4
        self.init = init = 1, 1, 1, 1
        self.generator = generator = 1, 1, 0, 0, 1
        self.code_rate = code_rate = int(samp_sym * 1)
        self.carrier = carrier = 10000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=interpolation,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.band_pass(0.5, samp_rate * 4, 10000 - sideband,
                                 10000 + sideband, transistion)), -carrier,
            samp_rate * 4)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            "FHSS_output1.wav", 2, 48000, 16)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                   samp_rate * 4, True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.9, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1,
                                                       "TestData2", False)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "inputBinary", False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.Spread_synthesizer_0 = Spread.synthesizer(code_rate, 100,
                                                       samp_rate, (generator),
                                                       (init))
        self.Spread_cpfsk_mod_0 = Spread.cpfsk_mod(samp_sym)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Spread_cpfsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.Spread_synthesizer_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_wavfile_sink_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.Spread_synthesizer_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.Spread_cpfsk_mod_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.blocks_throttle_0_0, 0))