Beispiel #1
0
 def toggle_fft(self):
     if (self.fft_sink is None):
         self.fft_sink = fft_sink_c()
         self.add_plot_sink(self.fft_sink)
         if self.options.decim_amt > 1:
             self.spectrum_decim = filter.rational_resampler_ccf(
                 1, self.options.decim_amt)
         else:
             self.spectrum_decim = None
         self.fft_sink.set_offset(self.options.offset)
         self.fft_sink.set_center_freq(self.target_freq)
         self.fft_sink.set_width(self.options.sample_rate)
         self.lock()
         if self.spectrum_decim is not None:
             self.connect(self.spectrum_decim, self.fft_sink)
             self.demod.connect_complex('src', self.spectrum_decim)
         else:
             self.demod.connect_complex('src', self.fft_sink)
         self.unlock()
     elif (self.fft_sink is not None):
         self.lock()
         if self.spectrum_decim is not None:
             self.disconnect(self.spectrum_decim, self.fft_sink)
         self.demod.disconnect_complex(self.fft_sink)
         self.unlock()
         self.fft_sink.kill()
         self.remove_plot_sink(self.fft_sink)
         self.spectrum_decim = None
         self.fft_sink = None
Beispiel #2
0
    def __init__(self, sign_freq, audio_freq):

        ##################################################
        # Variables
        ##################################################
        self.sign_freq = sign_freq
        self.audio_freq = audio_freq

        # hyperparameter
        self.low_pass_cut_off = 75000
        self.low_pass_trans_width = 5000
        self.low_pass_ampl_bound = 0.5
        self.low_pass_window = firdes.WIN_HAMMING
        self.low_pass_beta = 6.76

        ##################################################
        # Submodule
        ##################################################

        # we always resample the signal frequency into 2MHz
        self.input_resample = filter.rational_resampler_ccf(
            interpolation=2000000,
            decimation=sign_freq,
            taps=None,
            fractional_bw=None)

        self.low_pass_filter = eewls.auto_gain_low_pass_filter(
            filter.fir_filter_ccf, 8, self.low_pass_ampl_bound, 2000000,
            self.low_pass_cut_off, self.low_pass_trans_width,
            self.low_pass_window, self.low_pass_beta, str(complex))

        self.analog_wfm_rcv = analog.wfm_rcv(quad_rate=500000,
                                             audio_decimation=5)

        self.rational_resampler = filter.rational_resampler_fff(
            interpolation=48, decimation=50, taps=None, fractional_bw=None)

        gr.hier_block2.__init__(
            self, "fm_audio_decoder",
            gr.io_signature(
                1, 1,
                self.input_resample.input_signature().sizeof_stream_item(0)),
            gr.io_signature(
                1, 1,
                self.rational_resampler.output_signature().sizeof_stream_item(
                    0)))

        ##################################################
        # Connections
        ##################################################
        self.connect((self, 0), (self.input_resample, 0))
        self.connect((self.input_resample, 0), (self.low_pass_filter, 0))
        self.connect((self.low_pass_filter, 0), (self.analog_wfm_rcv, 0))
        self.connect((self.analog_wfm_rcv, 0), (self.rational_resampler, 0))
        self.connect((self.rational_resampler, 0), (self, 0))
Beispiel #3
0
    def __init__(self, num_streams, delta_f_in):
        gr.hier_block2.__init__(self, 'final_processing',
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        blk_last = (self, 0)
        if (num_streams % 2) == 0:
            self._mult_conj = blocks.multiply_conjugate_cc(1)
            self._carrier = analog.sig_source_c(sampling_freq=8 * delta_f_in,
                                                waveform=analog.GR_COS_WAVE,
                                                wave_freq=delta_f_in / 2.0,
                                                ampl=1.0,
                                                offset=0.0)
            self.connect(blk_last, (self._mult_conj, 0))
            self.connect((self._carrier), (self._mult_conj, 1))
            blk_last = self._mult_conj

        if num_streams <= 10:
            self._final_resamp = filter.rational_resampler_ccf(1, 2)
            self.connect(blk_last, (self._final_resamp))
            blk_last = self._final_resamp

        self.connect(blk_last, (self, 0))
Beispiel #4
0
 def toggle_fft(self):
     if (self.fft_sink is None) and (self.kill_sink is None):
         self.lock()
         self.fft_sink = fft_sink_c()
         self.spectrum_decim = filter.rational_resampler_ccf(
             1, self.options.decim_amt)
         self.connect(self.spectrum_decim, self.fft_sink)
         self.demod.connect_complex('src', self.spectrum_decim)
         self.kill_sink = self.fft_sink
         self.fft_sink.set_offset(self.options.offset)
         self.fft_sink.set_center_freq(self.target_freq)
         self.fft_sink.set_width(self.options.sample_rate)
         self.unlock()
     elif (self.fft_sink is not None):
         self.lock()
         self.disconnect(self.spectrum_decim, self.fft_sink)
         self.demod.disconnect_complex()
         self.fft_sink.kill()
         self.spectrum_decim = None
         self.fft_sink = None
         self.kill_sink = None
         self.unlock()
     else:
         sys.stderr.write("Only one Plot can be active at a time\n")
Beispiel #5
0
    def __build_graph(self, source, capture_rate):
        global speeds
        global WIRESHARK_PORT

        sps = 5  # samples / symbol
        if_rate = sps * 4800

        self.rx_q = gr.msg_queue(100)
        udp_port = 0

        vocoder = self.options.vocoder
        wireshark = self.options.wireshark
        wireshark_host = self.options.wireshark_host
        if self.options.udp_player:
            vocoder = True
            wireshark = True
            wireshark_host = "127.0.0.1"

        if wireshark or (wireshark_host != "127.0.0.1"):
            udp_port = self.options.wireshark_port

        self.tdma_state = False
        self.xor_cache = {}

        if self.baseband_input:
            self.demod = p25_demodulator.p25_demod_fb(
                input_rate=capture_rate,
                excess_bw=self.options.excess_bw,
                if_rate=if_rate)
        else:  # complex input
            # local osc
            self.lo_freq = self.options.offset
            if self.options.audio_if or self.options.ifile or self.options.input:
                self.lo_freq += self.options.calibration
            self.demod = p25_demodulator.p25_demod_cb(
                input_rate=capture_rate,
                demod_type=self.options.demod_type,
                relative_freq=self.lo_freq,
                offset=self.options.offset,
                if_rate=if_rate,
                gain_mu=self.options.gain_mu,
                costas_alpha=self.options.costas_alpha,
                excess_bw=self.options.excess_bw,
                symbol_rate=self.symbol_rate)

        num_ambe = 0
        if self.options.phase2_tdma:
            num_ambe = 1

        self.decoder = p25_decoder.p25_decoder_sink_b(
            dest='audio',
            do_imbe=vocoder,
            num_ambe=num_ambe,
            wireshark_host=wireshark_host,
            udp_port=udp_port,
            do_msgq=True,
            msgq=self.rx_q,
            audio_output=self.options.audio_output,
            debug=self.options.verbosity)

        # connect it all up
        self.connect(source, self.demod, self.decoder)

        if self.baseband_input:
            sps = if_rate // 4800
        plot_modes = []
        if self.options.plot_mode is not None:
            plot_modes = self.options.plot_mode.split(',')
        for plot_mode in plot_modes:
            if plot_mode == 'constellation':
                assert self.options.demod_type == 'cqpsk'  ## constellation requires cqpsk demod-type
                sink = constellation_sink_c()
                self.plot_sinks.append(sink)
                self.demod.connect_complex('diffdec', sink)
            elif plot_mode == 'symbol':
                sink = symbol_sink_f()
                self.plot_sinks.append(sink)
                self.demod.connect_float(sink)
            elif plot_mode == 'fft':
                sink = fft_sink_c()
                self.plot_sinks.append(sink)
                self.spectrum_decim = filter.rational_resampler_ccf(
                    1, self.options.decim_amt)
                self.connect(self.spectrum_decim, sink)
                self.demod.connect_complex('src', self.spectrum_decim)
            elif plot_mode == 'mixer':
                sink = mixer_sink_c()
                self.plot_sinks.append(sink)
                self.demod.connect_complex('mixer', sink)
            elif plot_mode == 'datascope':
                assert self.options.demod_type == 'fsk4'  ## datascope requires fsk4 demod-type
                sink = eye_sink_f(sps=sps)
                self.plot_sinks.append(sink)
                self.demod.connect_bb('symbol_filter', sink)
            elif plot_mode == 'correlation':
                assert self.options.demod_type == 'fsk4'  ## correlation plot requires fsk4 demod type
                self.plot_sinks += setup_correlation(sps, "",
                                                     self.demod.connect_bb)
            else:
                raise ValueError('unsupported plot type: %s' % plot_mode)
        if self.is_http_term():
            for sink in self.plot_sinks:
                sink.gnuplot.set_interval(_def_interval)
                sink.gnuplot.set_output_dir(_def_file_dir)

        if self.options.raw_symbols:
            self.sink_sf = blocks.file_sink(gr.sizeof_char,
                                            self.options.raw_symbols)
            self.connect(self.demod, self.sink_sf)

        logfile_workers = []
        if self.options.phase2_tdma:
            num_ambe = 2
        if self.options.logfile_workers:
            for i in range(self.options.logfile_workers):
                demod = p25_demodulator.p25_demod_cb(
                    input_rate=capture_rate,
                    demod_type=self.options.demod_type,
                    offset=self.options.offset)
                decoder = p25_decoder.p25_decoder_sink_b(
                    debug=self.options.verbosity,
                    do_imbe=vocoder,
                    num_ambe=num_ambe)
                logfile_workers.append({
                    'demod': demod,
                    'decoder': decoder,
                    'active': False
                })
                self.connect(source, demod, decoder)

        self.trunk_rx = trunking.rx_ctl(frequency_set=self.change_freq,
                                        debug=self.options.verbosity,
                                        conf_file=self.options.trunk_conf_file,
                                        logfile_workers=logfile_workers)

        self.du_watcher = du_queue_watcher(self.rx_q,
                                           self.trunk_rx.process_qmsg)
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Fmrx Without Echo")
        _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 = 10e6
        self.freq = freq = 97.9e6
        self.channel_width = channel_width = 200e3
        self.channel_freq = channel_freq = 96.5e6
        self.center_freq = center_freq = 97.9e6
        self.audio_gain = audio_gain = 1

        ##################################################
        # Blocks
        ##################################################
        _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="Frequency",
        	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=80e6,
        	maximum=120e6,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freq_sizer)
        _audio_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._audio_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_audio_gain_sizer,
        	value=self.audio_gain,
        	callback=self.set_audio_gain,
        	label='audio_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._audio_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_audio_gain_sizer,
        	value=self.audio_gain,
        	callback=self.set_audio_gain,
        	minimum=0,
        	maximum=10,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_audio_gain_sizer)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=freq,
        	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=True,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccf(
                interpolation=12,
                decimation=5,
                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, 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(50, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(int(samp_rate/channel_width), firdes.low_pass(
        	1, samp_rate, 75e3, 25e3, firdes.WIN_HAMMING, 6.76))
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink("/home/ubuntu/audio", 1, int(48e3), 8)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((audio_gain, ))
        self.audio_sink_0 = audio.sink(48000, "", False)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=480e3,
        	audio_decimation=10,
        )
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq - channel_freq, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 0))    
Beispiel #7
0
    def __build_graph(self, source, capture_rate):
        global speeds
        global WIRESHARK_PORT
        # tell the scope the source rate

        self.rx_q = gr.msg_queue(100)
        udp_port = 0

        if self.options.udp_player or self.options.wireshark or (
                self.options.wireshark_host != "127.0.0.1"):
            udp_port = WIRESHARK_PORT

        self.tdma_state = False
        self.xor_cache = {}

        self.fft_state = False
        self.c4fm_state = False
        self.fscope_state = False
        self.corr_state = False
        self.fac_state = False
        self.fsk4_demod_connected = False
        self.psk_demod_connected = False
        self.fsk4_demod_mode = False
        self.corr_i_chan = False

        if self.baseband_input:
            self.demod = p25_demodulator.p25_demod_fb(input_rate=capture_rate)
        else:  # complex input
            # local osc
            self.lo_freq = self.options.offset + self.options.fine_tune
            if self.options.audio_if or self.options.ifile or self.options.input:
                self.lo_freq += self.options.calibration
            self.demod = p25_demodulator.p25_demod_cb(
                input_rate=capture_rate,
                demod_type=self.options.demod_type,
                relative_freq=self.lo_freq,
                offset=self.options.offset,
                if_rate=48000,
                gain_mu=self.options.gain_mu,
                costas_alpha=self.options.costas_alpha,
                symbol_rate=self.symbol_rate)

        num_ambe = 0
        if self.options.phase2_tdma:
            num_ambe = 1

        self.decoder = p25_decoder.p25_decoder_sink_b(
            dest='audio',
            do_imbe=True,
            num_ambe=num_ambe,
            wireshark_host=self.options.wireshark_host,
            udp_port=udp_port,
            do_msgq=True,
            msgq=self.rx_q,
            audio_output=self.options.audio_output,
            debug=self.options.verbosity)

        # connect it all up
        self.connect(source, self.demod, self.decoder)

        if self.options.plot_mode == 'constellation':
            assert self.options.demod_type == 'cqpsk'  ## constellation requires cqpsk demod-type
            self.constellation_sink = constellation_sink_c()
            self.demod.connect_complex('diffdec', self.constellation_sink)
            self.kill_sink = self.constellation_sink
        elif self.options.plot_mode == 'symbol':
            self.symbol_sink = symbol_sink_f()
            self.demod.connect_float(self.symbol_sink)
            self.kill_sink = self.symbol_sink
        elif self.options.plot_mode == 'fft':
            self.fft_sink = fft_sink_c()
            self.spectrum_decim = filter.rational_resampler_ccf(
                1, self.options.decim_amt)
            self.connect(self.spectrum_decim, self.fft_sink)
            self.demod.connect_complex('src', self.spectrum_decim)
            self.kill_sink = self.fft_sink
        elif self.options.plot_mode == 'datascope':
            assert self.options.demod_type == 'fsk4'  ## datascope requires fsk4 demod-type
            self.eye_sink = eye_sink_f(sps=10)
            self.demod.connect_bb('symbol_filter', self.eye_sink)
            self.kill_sink = self.eye_sink

        if self.options.raw_symbols:
            self.sink_sf = blocks.file_sink(gr.sizeof_char,
                                            self.options.raw_symbols)
            self.connect(self.demod, self.sink_sf)

        logfile_workers = []
        if self.options.phase2_tdma:
            num_ambe = 2
        if self.options.logfile_workers:
            for i in range(self.options.logfile_workers):
                demod = p25_demodulator.p25_demod_cb(
                    input_rate=capture_rate,
                    demod_type=self.options.demod_type,
                    offset=self.options.offset)
                decoder = p25_decoder.p25_decoder_sink_b(
                    debug=self.options.verbosity,
                    do_imbe=self.options.vocoder,
                    num_ambe=num_ambe)
                logfile_workers.append({
                    'demod': demod,
                    'decoder': decoder,
                    'active': False
                })
                self.connect(source, demod, decoder)

        self.trunk_rx = trunking.rx_ctl(frequency_set=self.change_freq,
                                        debug=self.options.verbosity,
                                        conf_file=self.options.trunk_conf_file,
                                        logfile_workers=logfile_workers)

        self.du_watcher = du_queue_watcher(self.rx_q,
                                           self.trunk_rx.process_qmsg)
    def __init__(self):
        gr.top_block.__init__(self, "NBFM_transceiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("NBFM_transceiver")
        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", "NBFM_transceiver")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.rx_freq = rx_freq = 141050000
        self.offset = offset = 5000000
        self.tx_gain = tx_gain = 15
        self.tx_freq = tx_freq = rx_freq - offset
        self.sqch = sqch = -60
        self.sdr_samp_rate = sdr_samp_rate = samp_rate * 12
        self.rx_tx = rx_tx = 0
        self.rx_gain = rx_gain = 10
        self.rx_freq_fine = rx_freq_fine = 0
        self.rx_aud = rx_aud = 0.300

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 90, 1, 15, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        'tx_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win, 2, 2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._sqch_range = Range(-110, -50, 1, -60, 200)
        self._sqch_win = RangeWidget(self._sqch_range, self.set_sqch,
                                     'rx_sqlch', "counter_slider", float)
        self.top_grid_layout.addWidget(self._sqch_win, 3, 0, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._sdr_samp_rate_range = Range(520833, 61440000, 100000,
                                          samp_rate * 12, 200)
        self._sdr_samp_rate_win = RangeWidget(self._sdr_samp_rate_range,
                                              self.set_sdr_samp_rate,
                                              'sdr_sample_rate',
                                              "counter_slider", float)
        self.top_grid_layout.addWidget(self._sdr_samp_rate_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_tx_options = (
            0,
            1,
        )
        self._rx_tx_labels = (
            'RX',
            'TX',
        )
        self._rx_tx_group_box = Qt.QGroupBox('rx_tx_pushbutton')
        self._rx_tx_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._rx_tx_button_group = variable_chooser_button_group()
        self._rx_tx_group_box.setLayout(self._rx_tx_box)
        for i, label in enumerate(self._rx_tx_labels):
            radio_button = Qt.QRadioButton(label)
            self._rx_tx_box.addWidget(radio_button)
            self._rx_tx_button_group.addButton(radio_button, i)
        self._rx_tx_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._rx_tx_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._rx_tx_options.index(i)))
        self._rx_tx_callback(self.rx_tx)
        self._rx_tx_button_group.buttonClicked[int].connect(
            lambda i: self.set_rx_tx(self._rx_tx_options[i]))
        self.top_grid_layout.addWidget(self._rx_tx_group_box, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_gain_range = Range(0, 50, 1, 10, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        'rx_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win, 2, 0, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_range = Range(88000000, 174000000, 25000, 141050000, 200)
        self._rx_freq_win = RangeWidget(self._rx_freq_range, self.set_rx_freq,
                                        'rx_freq', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_freq_win, 1, 0, 1, 2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_aud_range = Range(0, 0.5, 0.05, 0.300, 200)
        self._rx_aud_win = RangeWidget(self._rx_aud_range, self.set_rx_aud,
                                       'rx_audio_gain', "counter_slider",
                                       float)
        self.top_grid_layout.addWidget(self._rx_aud_win, 2, 1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._offset_options = (
            5000000,
            600000,
        )
        self._offset_labels = (
            '5Mhz',
            '600kHz',
        )
        self._offset_tool_bar = Qt.QToolBar(self)
        self._offset_tool_bar.addWidget(Qt.QLabel('rx_tx_offset' + ": "))
        self._offset_combo_box = Qt.QComboBox()
        self._offset_tool_bar.addWidget(self._offset_combo_box)
        for label in self._offset_labels:
            self._offset_combo_box.addItem(label)
        self._offset_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._offset_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._offset_options.index(i)))
        self._offset_callback(self.offset)
        self._offset_combo_box.currentIndexChanged.connect(
            lambda i: self.set_offset(self._offset_options[i]))
        self.top_grid_layout.addWidget(self._offset_tool_bar, 0, 2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._tx_freq_tool_bar = Qt.QToolBar(self)

        if None:
            self._tx_freq_formatter = None
        else:
            self._tx_freq_formatter = lambda x: eng_notation.num_to_str(x)

        self._tx_freq_tool_bar.addWidget(Qt.QLabel('tx_freq' + ": "))
        self._tx_freq_label = Qt.QLabel(
            str(self._tx_freq_formatter(self.tx_freq)))
        self._tx_freq_tool_bar.addWidget(self._tx_freq_label)
        self.top_grid_layout.addWidget(self._tx_freq_tool_bar, 1, 2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_fine_range = Range(-10000, 10000, 100, 0, 200)
        self._rx_freq_fine_win = RangeWidget(self._rx_freq_fine_range,
                                             self.set_rx_freq_fine,
                                             'rx_freq_fine', "counter_slider",
                                             float)
        self.top_grid_layout.addWidget(self._rx_freq_fine_win, 3, 1, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rational_resampler_xxx_0_1 = filter.rational_resampler_ccf(
            interpolation=samp_rate,
            decimation=sdr_samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=samp_rate,
            decimation=sdr_samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=sdr_samp_rate,
            decimation=samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0 = qtgui.sink_c(
            256,  #fftsize
            firdes.WIN_HAMMING,  #wintype
            rx_freq,  #fc
            25000,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #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_grid_layout.addWidget(self._qtgui_sink_x_0_win, 4, 0, 6, 3)
        for r in range(4, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 3):
            self.top_grid_layout.setColumnStretch(c, 1)

        self.qtgui_sink_x_0.enable_rf_freq(True)

        self.pluto_source_0 = iio.pluto_source('', rx_freq, sdr_samp_rate,
                                               15000, 0x4000, True, True, True,
                                               "manual",
                                               rx_gain * ((-rx_tx) + 1), '',
                                               True)
        self.pluto_sink_0 = iio.pluto_sink('192.168.2.1', rx_freq - offset,
                                           sdr_samp_rate, 5000, 0x4000, False,
                                           -tx_gain * (rx_tx), '', True)
        self.low_pass_filter_1 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 20000, 500, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 10e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 16000, 200, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (rx_aud * (-(rx_tx) + 1), ))
        self.audio_sink_0 = audio.sink(48000,
                                       "Speakers (Conexant SmartAudio HD)",
                                       True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(sqch, 1)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 0, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            sdr_samp_rate, analog.GR_COS_WAVE, 0, 1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=samp_rate,
            quad_rate=samp_rate,
            tau=75e-6,
            max_dev=5e3,
            fh=-1.0,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=48000,
            quad_rate=48000,
            tau=50e-6,
            max_dev=12.5e3,
        )
        self.Internal_Microphone = audio.source(48000, '', True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Internal_Microphone, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_0_1, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.analog_nbfm_tx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.pluto_source_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.pluto_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_1, 0),
                     (self.qtgui_sink_x_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "FloripaSat-I Simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("FloripaSat-I Simulation")
        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", "fsat_simulation")

        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.symbol_rate = symbol_rate = 1.2e3
        self.samples_per_symbol = samples_per_symbol = 40
        self.sample_rate_tx = sample_rate_tx = symbol_rate * samples_per_symbol * 25 / 6
        self.sample_rate_rx = sample_rate_rx = sample_rate_tx * 6 / 5
        self.sample_rate = sample_rate = symbol_rate * samples_per_symbol
        self.pi = pi = numpy.pi
        self.phase_shift = phase_shift = 0
        self.noise_amp = noise_amp = 1e-6
        self.modulation_sensitivity = modulation_sensitivity = 4e3
        self.freq_shift = freq_shift = 1e3

        ##################################################
        # Blocks
        ##################################################
        self.tabs = Qt.QTabWidget()
        self.tabs_widget_0 = Qt.QWidget()
        self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                           self.tabs_widget_0)
        self.tabs_grid_layout_0 = Qt.QGridLayout()
        self.tabs_layout_0.addLayout(self.tabs_grid_layout_0)
        self.tabs.addTab(self.tabs_widget_0, 'Spectrum')
        self.tabs_widget_1 = Qt.QWidget()
        self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                           self.tabs_widget_1)
        self.tabs_grid_layout_1 = Qt.QGridLayout()
        self.tabs_layout_1.addLayout(self.tabs_grid_layout_1)
        self.tabs.addTab(self.tabs_widget_1, 'Time')
        self.top_layout.addWidget(self.tabs)
        self._phase_shift_range = Range(0, 2 * pi, 0.01, 0, 200)
        self._phase_shift_win = RangeWidget(self._phase_shift_range,
                                            self.set_phase_shift,
                                            "Channel Phase Shift",
                                            "counter_slider", float)
        self.tabs_grid_layout_1.addWidget(self._phase_shift_win, 1, 0, 1, 1)
        [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(1, 2)]
        [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)]
        self._noise_amp_range = Range(1e-6, 0.1, 1e-6, 1e-6, 200)
        self._noise_amp_win = RangeWidget(self._noise_amp_range,
                                          self.set_noise_amp,
                                          "Channel Noise Amplitude",
                                          "counter_slider", float)
        self.tabs_grid_layout_1.addWidget(self._noise_amp_win, 2, 0, 1, 1)
        [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(2, 3)]
        [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)]
        self._freq_shift_range = Range(0, 100e3, 1e3, 1e3, 200)
        self._freq_shift_win = RangeWidget(self._freq_shift_range,
                                           self.set_freq_shift,
                                           "Channel Frequency Shift",
                                           "counter_slider", float)
        self.tabs_grid_layout_1.addWidget(self._freq_shift_win, 0, 0, 1, 1)
        [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)]
        [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)]
        self.simple_channel_0 = simple_channel(
            freq_shift=freq_shift,
            noise_amplitude=noise_amp,
            noise_seed=1,
            phase_shift=phase_shift,
            samp_rate=sample_rate_tx,
        )
        self.rational_resampler_xxx_0_0_0_0_1_0 = filter.rational_resampler_fff(
            interpolation=1,
            decimation=5,
            taps=(firdes.low_pass(1, 1, 0.5 / 5, 0.001)),
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0_0_0_0 = filter.rational_resampler_ccf(
            interpolation=6,
            decimation=5,
            taps=(firdes.low_pass(6, 1, 0.5 / 6, 0.001)),
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccf(
            interpolation=25,
            decimation=6,
            taps=(firdes.low_pass(25, 1, 0.5 / 25, 0.001)),
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_f(
            11200,  #size
            symbol_rate * samples_per_symbol,  #samp_rate
            "Signal",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-1.2, 1.2)

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

        self.qtgui_time_sink_x_0_0_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_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_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0_0_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_0_0_0.disable_legend()

        labels = ["Received", "Received", '', '', '', '', '', '', '', '']
        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_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.tabs_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_0_0_win,
                                          3, 0, 7, 1)
        [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(3, 10)]
        [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)]
        self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f(
            280,  #size
            symbol_rate * samples_per_symbol,  #samp_rate
            "Message",  #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.2, 1.2)

        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)
        self.qtgui_time_sink_x_0_0_0.enable_stem_plot(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 = [0, -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.tabs_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_0_win,
                                          10, 0, 7, 1)
        [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(10, 17)]
        [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)]
        self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c(
            8192,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            sample_rate_rx,  #bw
            "Received Signal",  #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(-180, 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 "complex" == "float" or "complex" == "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.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 1,
                                          0, 1, 1)
        [self.tabs_grid_layout_0.setRowStretch(r, 1) for r in range(1, 2)]
        [self.tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1)]
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            8192,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            sample_rate_tx,  #bw
            "Transmitted Signal",  #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(-180, 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 "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

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

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0,
                                          0, 1, 1)
        [self.tabs_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)]
        [self.tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1)]
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            8192,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            symbol_rate * samples_per_symbol,  #bw
            "Demodulated Signal",  #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(-180, 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.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0,
                                          1, 1)
        [self.tabs_grid_layout_0.setRowStretch(r, 1) for r in range(2, 3)]
        [self.tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1)]
        self.gfsk_modulator_0 = gfsk_modulator(
            BT=0.25,
            filter_taps=100,
            modulation_sensitivity=modulation_sensitivity,
            samples_per_symbol=samples_per_symbol,
            symbol_rate=1.2e3,
        )
        self.fm_demodulator_0 = fm_demodulator(
            modulation_sensitivity=modulation_sensitivity,
            samp_rate=sample_rate_rx,
        )
        self.custom_symbol_sync_gardner_fb_0 = custom.symbol_sync_gardner_fb(
            samples_per_symbol, 1 / sample_rate, 0.01 * sample_rate, 0.707,
            3.22)
        self.custom_frame_sync_bb_0 = custom.frame_sync_bb(([
            0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0,
            1, 0, 0, 1, 1, 1, 1, 1, 1, 0
        ]), 32, 3)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 sample_rate, True)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/rpa/code/FloripaSat-I-SDR-Receiver/Binary-Files/fsat-hello.bin',
            True)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_0_0_0, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.gfsk_modulator_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.custom_frame_sync_bb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.custom_symbol_sync_gardner_fb_0, 0),
                     (self.custom_frame_sync_bb_0, 0))
        self.connect((self.fm_demodulator_0, 0),
                     (self.rational_resampler_xxx_0_0_0_0_1_0, 0))
        self.connect((self.gfsk_modulator_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.simple_channel_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0_0, 0),
                     (self.fm_demodulator_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0_0, 0),
                     (self.qtgui_freq_sink_x_0_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0_1_0, 0),
                     (self.custom_symbol_sync_gardner_fb_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0_1_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0_1_0, 0),
                     (self.qtgui_time_sink_x_0_0_0_0, 0))
        self.connect((self.simple_channel_0, 0),
                     (self.rational_resampler_xxx_0_0_0_0_0, 0))
Beispiel #10
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))
Beispiel #11
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FM receiver")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.down_rate = down_rate = 150e3
        self.VOLUMEN = VOLUMEN = 70
        self.SINTONIZADOR = SINTONIZADOR = 90.1e6
        self.GANANCIA = GANANCIA = 50

        ##################################################
        # Blocks
        ##################################################
        _VOLUMEN_sizer = wx.BoxSizer(wx.VERTICAL)
        self._VOLUMEN_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_VOLUMEN_sizer,
            value=self.VOLUMEN,
            callback=self.set_VOLUMEN,
            label='Ajuste de sonido',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._VOLUMEN_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_VOLUMEN_sizer,
            value=self.VOLUMEN,
            callback=self.set_VOLUMEN,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_VOLUMEN_sizer, 1, 5, 1, 8)
        _SINTONIZADOR_sizer = wx.BoxSizer(wx.VERTICAL)
        self._SINTONIZADOR_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_SINTONIZADOR_sizer,
            value=self.SINTONIZADOR,
            callback=self.set_SINTONIZADOR,
            label='Sintonizador',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._SINTONIZADOR_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_SINTONIZADOR_sizer,
            value=self.SINTONIZADOR,
            callback=self.set_SINTONIZADOR,
            minimum=10e6,
            maximum=142e6,
            num_steps=10,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_SINTONIZADOR_sizer)
        _GANANCIA_sizer = wx.BoxSizer(wx.VERTICAL)
        self._GANANCIA_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_GANANCIA_sizer,
            value=self.GANANCIA,
            callback=self.set_GANANCIA,
            label='Ganancia',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._GANANCIA_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_GANANCIA_sizer,
            value=self.GANANCIA,
            callback=self.set_GANANCIA,
            minimum=10,
            maximum=70,
            num_steps=12,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_GANANCIA_sizer, 1, 0, 1, 4)
        self.wxgui_fftsink2_1 = fftsink2.fft_sink_f(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=1000,
            average=False,
            avg_alpha=None,
            title='Especto de frecuencias',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_1.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(SINTONIZADOR, 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(GANANCIA, 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.rational_resampler_xxx_1 = filter.rational_resampler_fff(
            interpolation=48,
            decimation=50,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccf(
            interpolation=1,
            decimation=4,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 100e3, 1e6, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            'C:\\Users\\camil\\Desktop\\PROYECTO DE PRUEBA\\Decodificador\\DemodulacionFM.wav',
            1, 20800, 16)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (VOLUMEN / 100, ))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=500000,
            audio_decimation=10,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
Beispiel #12
0
    def __init__(self):
        gr.top_block.__init__(self, "Fm Simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fm Simulation")
        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", "fm_simulation")

        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 = 48000
        self.pi = pi = numpy.pi
        self.kf = kf = 30e3
        self.fs_tx = fs_tx = samp_rate * 25 / 6
        self.gain_FM = gain_FM = 2 * pi * kf / fs_tx
        self.fs_rx = fs_rx = samp_rate * 5
        self.freq_shift = freq_shift = 1e3

        ##################################################
        # Blocks
        ##################################################
        self._freq_shift_range = Range(0, 200e3, 200, 1e3, 200)
        self._freq_shift_win = RangeWidget(self._freq_shift_range,
                                           self.set_freq_shift, "freq_shift",
                                           "counter_slider", float)
        self.top_layout.addWidget(self._freq_shift_win)
        self.simple_channel_0 = simple_channel(
            freq_shift=freq_shift,
            noise_amplitude=0,
            noise_seed=0,
            phase_shift=0,
            samp_rate=240e3,
        )
        self.rational_resampler_xxx_0_0_0_0_1_0 = filter.rational_resampler_fff(
            interpolation=1,
            decimation=5,
            taps=(firdes.low_pass(1, 1, 0.5 / 5, 0.001)),
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0_0_0_0 = filter.rational_resampler_ccf(
            interpolation=6,
            decimation=5,
            taps=(firdes.low_pass(6, 1, 0.5 / 6, 0.001)),
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=25,
            decimation=6,
            taps=(firdes.low_pass(25, 1, 0.5 / 25, 0.001)),
            fractional_bw=None,
        )
        self.qtgui_freq_sink_x_0_1_0 = qtgui.freq_sink_f(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Demodulated Signal",  #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(True)
        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_layout.addWidget(self._qtgui_freq_sink_x_0_1_0_win)
        self.fm_modulator_0 = fm_modulator(
            modulation_sensitivity=30e3,
            samp_rate=fs_tx,
        )
        self.fm_demodulator_0 = fm_demodulator(
            modulation_sensitivity=30e3,
            samp_rate=fs_rx,
        )
        self.audio_sink_0 = audio.sink(samp_rate, '', True)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 440, 0.25, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.fm_demodulator_0, 0),
                     (self.rational_resampler_xxx_0_0_0_0_1_0, 0))
        self.connect((self.fm_modulator_0, 0),
                     (self.rational_resampler_xxx_0_0_0_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.fm_modulator_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0_0, 0),
                     (self.simple_channel_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0_1_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0_1_0, 0),
                     (self.qtgui_freq_sink_x_0_1_0, 0))
        self.connect((self.simple_channel_0, 0), (self.fm_demodulator_0, 0))
Beispiel #13
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))
Beispiel #14
0
    def __init__(self,
                 sign_freq,
                 audio_freq,
                 signal_low_pass_cutoff=10000,
                 signal_low_pass_trans=1000,
                 audio_low_pass_cutoff=3000,
                 audio_low_pass_trans=20,
                 use_dc_blocker=True,
                 audio_gain=1):
        ##################################################
        # Variables
        ##################################################
        self.sign_freq = sign_freq
        self.audio_freq = audio_freq
        self.signal_low_pass_cutoff = signal_low_pass_cutoff
        self.signal_low_pass_trans = signal_low_pass_trans
        self.audio_low_pass_cutoff = audio_low_pass_cutoff
        self.audio_low_pass_trans = audio_low_pass_trans
        self.use_dc_blocker = use_dc_blocker
        self.audio_gain = audio_gain

        # hyper parameter
        self.low_pass_ampl_bound = 0.1
        self.low_pass_window = firdes.WIN_HAMMING
        self.low_pass_beta = 6.76

        ##################################################
        # Submodule
        ##################################################
        self.input_resample = filter.rational_resampler_ccf(
            interpolation=2000000,
            decimation=sign_freq,
            taps=None,
            fractional_bw=None)

        self.signal_low_pass_filter = eewls.auto_gain_low_pass_filter(
            filter.fir_filter_ccf, 8, self.low_pass_ampl_bound, 2000000,
            self.signal_low_pass_cutoff, self.signal_low_pass_trans,
            self.low_pass_window, self.low_pass_beta, str(complex))

        self.am_demod = analog.am_demod_cf(channel_rate=50000,
                                           audio_decim=5,
                                           audio_pass=5000,
                                           audio_stop=5500)
        self.resampler = filter.rational_resampler_fff(
            interpolation=48 * self.audio_freq * 2 / 96000,
            decimation=50,
            taps=None,
            fractional_bw=None)
        self.audio_filter = filter.interp_fir_filter_fff(
            1,
            firdes.low_pass(self.audio_gain, self.audio_freq * 2,
                            self.audio_low_pass_cutoff,
                            self.audio_low_pass_trans, self.low_pass_window,
                            self.low_pass_beta))

        gr.hier_block2.__init__(
            self, "fm_audio_decoder",
            gr.io_signature(
                1, 1,
                self.input_resample.input_signature().sizeof_stream_item(0)),
            gr.io_signature(
                1, 1,
                self.audio_filter.output_signature().sizeof_stream_item(0)))

        if self.use_dc_blocker:
            self.dc_blocker = filter.dc_blocker_cc(256, True)
        ##################################################
        # Connections
        ##################################################
        self.connect((self, 0), (self.input_resample, 0))
        self.connect((self.input_resample, 0),
                     (self.signal_low_pass_filter, 0))
        if self.use_dc_blocker:
            self.connect((self.signal_low_pass_filter, 0),
                         (self.dc_blocker, 0))
            self.connect((self.dc_blocker, 0), (self.am_demod, 0))
        else:
            self.connect((self.signal_low_pass_filter, 0), (self.am_demod, 0))
        self.connect((self.am_demod, 0), (self.resampler, 0))
        self.connect((self.resampler, 0), (self.audio_filter, 0))
        self.connect((self.audio_filter, 0), (self, 0))
Beispiel #15
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.sdr_samp_rate = sdr_samp_rate = 2.4e6
        self.samp_rate = samp_rate = 48e3
        self.freq = freq = 88.1e6

        ##################################################
        # Blocks
        ##################################################
        _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=80e6,
        	maximum=110e6,
        	num_steps=600,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freq_sizer)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=sdr_samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title='Waterfall Plot',
        )
        self.Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_fftsink2_1 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=sdr_samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title='FFT Plot',
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_1.win)
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.rtlsdr_source_0.set_sample_rate(sdr_samp_rate)
        self.rtlsdr_source_0.set_center_freq(freq, 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(40, 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.rational_resampler_xxx_0_0 = filter.rational_resampler_ccf(
                interpolation=1,
                decimation=4,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, sdr_samp_rate, 100e3, 1e6, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=500e3,
        	audio_decimation=10,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_1, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_waterfallsink2_0, 0))