def __init__(self, alpha=1e-2, reference=0.5): gr.hier_block2.__init__( self, "RMS AGC", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Parameters ################################################## self.alpha = alpha self.reference = reference ################################################## # Blocks ################################################## self.blocks_rms_xx_0 = blocks.rms_cf(alpha) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1.0/reference) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_add_const_vxx_0 = blocks.add_const_ff(1e-20) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self, 0), (self.blocks_divide_xx_0, 0)) self.connect((self, 0), (self.blocks_rms_xx_0, 0))
def __init__(self, frequency): gr.top_block.__init__(self) sample_rate = 32000 ampl = 0.1 # Source. addr = '' stream_args = uhd.stream_args('fc32') self.src = uhd.usrp_source(addr, stream_args) #src.set_subdev_spec(options.spec, 0) self.src.set_samp_rate(32000) self.src.set_center_freq(frequency) self.src.set_gain(30) self.src.set_antenna('TX/RX') # SNR snr = digital.mpsk_snr_est_cc(type=0) snr.set_alpha(0.001) snr.set_tag_nsample(1000000) rms = blocks.rms_cf() rms.set_alpha(0.0001) self.msgq = gr.msg_queue(16) sink = blocks.message_sink(4, self.msgq, 'bleh') self.connect(self.src, snr, rms, sink)
def test_001_t (self): """AGC on random noisy QPSK symbols""" # Parameters snr_db = 0.0 const_mult = 1.5 agc_rate = 1e-4 agc_ref = 1.0 agc_gain = 1.0 N_last = 1000 # analyze the last symbols # Constants n_symbols = int(10*(1/agc_rate)) noise_v = 1/sqrt((10**(float(snr_db)/10))) rndm = random.Random() # Input data in_vec = tuple([rndm.randint(0,1) for i in range(0, n_symbols)]) # Flowgraph src = blocks.vector_source_b(in_vec) pack = blocks.repack_bits_bb(1, 2, "", False, gr.GR_MSB_FIRST) const = digital.constellation_qpsk().base() cmap = digital.chunks_to_symbols_bc(const.points()) mult = blocks.multiply_const_cc(const_mult) nadder = blocks.add_cc() noise = analog.noise_source_c(analog.GR_GAUSSIAN, noise_v, 0) agc = blocksat.agc_cc(agc_rate, agc_ref, agc_gain) snk = blocks.vector_sink_c() snk2 = blocks.vector_sink_c() # Reference AGC approach rms_cf = blocks.rms_cf(0.0001) f2c = blocks.float_to_complex() div = blocks.divide_cc() snk3 = blocks.vector_sink_c() self.tb.connect(src, pack, cmap, mult) self.tb.connect(mult, (nadder, 0)) self.tb.connect(noise, (nadder, 1)) self.tb.connect(nadder, agc, snk) self.tb.connect(nadder, snk2) self.tb.connect(nadder, (div, 0)) self.tb.connect(nadder, rms_cf, (f2c, 0), (div, 1)) self.tb.connect(div, snk3) self.tb.run() # Collect results agc_syms = snk.data() pre_agc_syms = snk2.data() ref_agc_syms = snk3.data() rms_agc = self.rms(agc_syms, N_last) rms_pre_agc = self.rms(pre_agc_syms, N_last) rms_agc_ref = self.rms(ref_agc_syms, N_last) print('RMS before AGC: %f' %(rms_pre_agc)) print('RMS after AGC: %f' %(rms_agc)) print('RMS after reference AGC: %f' %(rms_agc_ref)) # Check results self.assertAlmostEqual(rms_agc, 1.0, places=1)
def test_cf(self): amp = 4 src_data = sig_source_c(1, 0.01, amp, 200) N = 750000 expected_data = amp src = blocks.vector_source_c(src_data, True) head = blocks.head(gr.sizeof_gr_complex, N) op = blocks.rms_cf(0.0001) dst = blocks.vector_sink_f() self.tb.connect(src, head, op, dst) self.tb.run() dst_data = dst.data() self.assertAlmostEqual(dst_data[-1], expected_data, 4)
def __init__(self, alpha=0.01): gr.hier_block2.__init__( self, "RMS AGC", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex), ) self.alpha = alpha self.block_rms = blocks.rms_cf(alpha) self.block_divide = blocks.divide_cc(1) self.connect( self, self.block_rms, blocks.add_const_vff((1e-20, )), # to avoid div by 0 blocks.float_to_complex(1), (self.block_divide, 1), ) self.connect(self, (self.block_divide, 0)) self.connect((self.block_divide, 0), self)
def __init__(self): gr.top_block.__init__(self, "FID Sequence") Qt.QWidget.__init__(self) self.setWindowTitle("FID Sequence") 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", "fid_grc_1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.slave_delay = slave_delay = 0 self.samp_rate = samp_rate = 250000 self.readout_delay = readout_delay = 0 self.offset = offset = 0 self.master_delay = master_delay = 0 self.ex_delay = ex_delay = 0 self.TR_clock = TR_clock = 0 self.TR = TR = 1 self.RUN = RUN = 1 self.CF = CF = 21.3e6 ################################################## # Blocks ################################################## self._TR_tool_bar = Qt.QToolBar(self) self._TR_tool_bar.addWidget(Qt.QLabel("TR" + ": ")) self._TR_line_edit = Qt.QLineEdit(str(self.TR)) self._TR_tool_bar.addWidget(self._TR_line_edit) self._TR_line_edit.returnPressed.connect( lambda: self.set_TR(int(str(self._TR_line_edit.text().toAscii())))) self.top_layout.addWidget(self._TR_tool_bar) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("serial = DR31R6U1", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:B A:A", 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(CF + offset, 0) self.uhd_usrp_source_0.set_gain(15, 0) self.uhd_usrp_source_0.set_antenna("A:B", 0) self.uhd_usrp_source_0.set_center_freq(CF + offset, 1) self.uhd_usrp_source_0.set_gain(10, 1) self.uhd_usrp_source_0.set_antenna("A:A", 1) self.signal_out = MRI.gated_vector_sink() self.rf_sink = uhd.usrp_sink( ",".join(("serial = DR31R6U1", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.rf_sink.set_subdev_spec("A:AB B:A", 0) self.rf_sink.set_samp_rate(samp_rate) self.rf_sink.set_center_freq(CF + offset, 0) self.rf_sink.set_gain(0, 0) self.rf_sink.set_antenna("A:A", 0) self.rf_sink.set_center_freq(0, 1) self.rf_sink.set_gain(0, 1) self.rf_sink.set_antenna("A:B", 1) self.readwin = MRI.triggered_vector_source_f([0, 0, 0], 1.0, 0.0, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( int(.00315 * samp_rate), #size samp_rate, #samp_rate "", #name 4 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-.25, .25) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, .01, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = [ "Read Window", "Real Signal", "Imag Signal", "RMS", "", "", "", "", "", "" ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "black", "blue", "red", "green", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [2, 1, 1, 2, 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(4): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.m_delay = blocks.delay(gr.sizeof_gr_complex * 1, int(master_delay)) self.ex_pulse = MRI.triggered_vector_source([0, 0, 0], 1.0, 0.0, 1, 1) self.delay3 = blocks.delay(gr.sizeof_float * 1, readout_delay) self.delay1 = blocks.delay(gr.sizeof_float * 1, ex_delay) self.blocks_threshold_ff_0_2 = blocks.threshold_ff(.000001, .000001, 0) self.blocks_threshold_ff_0_1 = blocks.threshold_ff(.05, .05, 0) self.blocks_rms_xx_1 = blocks.rms_cf(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((RUN, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, 1, 4000) self.blocks_float_to_complex_0_1_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 5) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 5) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SQR_WAVE, 1. / TR, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_float_0_0, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_threshold_ff_0_1, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_complex_to_float_0_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.rf_sink, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_delay_0_0, 0)) self.connect((self.blocks_float_to_complex_0_1_0, 0), (self.m_delay, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0_2, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.signal_out, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.delay1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.delay3, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.qtgui_time_sink_x_0, 3)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.signal_out, 0)) self.connect((self.blocks_threshold_ff_0_2, 0), (self.blocks_float_to_complex_0_1_0, 0)) self.connect((self.delay1, 0), (self.ex_pulse, 0)) self.connect((self.delay3, 0), (self.readwin, 0)) self.connect((self.ex_pulse, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.ex_pulse, 0), (self.blocks_delay_0, 0)) self.connect((self.m_delay, 0), (self.rf_sink, 1)) self.connect((self.readwin, 0), (self.blocks_float_to_complex_0_1, 1)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_divide_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Frontend BBCR 12k") Qt.QWidget.__init__(self) self.setWindowTitle("Frontend BBCR 12k") 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", "send_data_12k") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 5 self.nfilts = nfilts = 16 self.alpha = alpha = 0.35 self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 2, 1).base() self.tx_offset = tx_offset = 0 self.tx_gain = tx_gain = 57 self.timing_loop_bw = timing_loop_bw = 0.05 self.samp_rate = samp_rate = 250000 self.rx_gain = rx_gain = 35 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), alpha, 11 * sps * nfilts) self.phase_bw = phase_bw = 0.1 self.if_rate = if_rate = 48000 self.if_freq = if_freq = 60e3 self.fll_bw = fll_bw = 0.01 self.fc = fc = 401.6e6 self.equalizer_gain = equalizer_gain = 0.05 self.audio_rate = audio_rate = 48000 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Demodulator') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Loop') self.top_grid_layout.addWidget(self.tab, 0, 1, 5, 1) for r in range(0, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._tx_offset_tool_bar = Qt.QToolBar(self) self._tx_offset_tool_bar.addWidget(Qt.QLabel('TX Offset' + ": ")) self._tx_offset_line_edit = Qt.QLineEdit(str(self.tx_offset)) self._tx_offset_tool_bar.addWidget(self._tx_offset_line_edit) self._tx_offset_line_edit.returnPressed.connect( lambda: self.set_tx_offset( int(str(self._tx_offset_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._tx_offset_tool_bar, 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._tx_gain_range = Range(0, 89, 1, 57, 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, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 0.05, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, 'Time: Bandwidth', "counter_slider", float) self.tab_grid_layout_1.addWidget(self._timing_loop_bw_win, 1, 0, 1, 1) for r in range(1, 2): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab_grid_layout_1.setColumnStretch(c, 1) self._rx_gain_range = Range(0, 73, 1, 35, 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, 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._phase_bw_range = Range(0.0, 1.0, 0.01, 0.1, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, 'Phase: Bandwidth', "counter_slider", float) self.tab_grid_layout_1.addWidget(self._phase_bw_win, 2, 0, 1, 1) for r in range(2, 3): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab_grid_layout_1.setColumnStretch(c, 1) self._if_freq_options = ( 20e3, 60e3, -20e3, -40e3, ) self._if_freq_labels = ( '401.58M (30)', '401.54M (31)', '401.62M (32)', '401.66M (33)', ) self._if_freq_tool_bar = Qt.QToolBar(self) self._if_freq_tool_bar.addWidget(Qt.QLabel('RX Frequency' + ": ")) self._if_freq_combo_box = Qt.QComboBox() self._if_freq_tool_bar.addWidget(self._if_freq_combo_box) for label in self._if_freq_labels: self._if_freq_combo_box.addItem(label) self._if_freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._if_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._if_freq_options.index(i))) self._if_freq_callback(self.if_freq) self._if_freq_combo_box.currentIndexChanged.connect( lambda i: self.set_if_freq(self._if_freq_options[i])) self.tab_grid_layout_0.addWidget(self._if_freq_tool_bar, 0, 0, 1, 1) for r in range(0, 1): self.tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab_grid_layout_0.setColumnStretch(c, 1) self._fll_bw_range = Range(0.0, 0.2, 0.001, 0.01, 200) self._fll_bw_win = RangeWidget(self._fll_bw_range, self.set_fll_bw, 'FLL: Bandwidth', "counter_slider", float) self.tab_grid_layout_1.addWidget(self._fll_bw_win, 0, 0, 1, 1) for r in range(0, 1): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab_grid_layout_1.setColumnStretch(c, 1) self._equalizer_gain_range = Range(0.0, 0.2, 0.01, 0.05, 200) self._equalizer_gain_win = RangeWidget(self._equalizer_gain_range, self.set_equalizer_gain, 'Equalizer: Gain', "counter_slider", float) self.tab_grid_layout_1.addWidget(self._equalizer_gain_win, 3, 0, 1, 1) for r in range(3, 4): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab_grid_layout_1.setColumnStretch(c, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_subdev_spec('A:A', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(fc, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_1.set_subdev_spec('A:A', 0) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(259.5e6 + tx_offset, 0) self.uhd_usrp_sink_1.set_gain(tx_gain, 0) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc( interpolation=125, decimation=48, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=24, decimation=125, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-100, 0) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 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.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0.001, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title('') labels = ['RSSI', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_number_sink_0_win, 0, 1, 1, 1) for r in range(0, 1): self.tab_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc if_rate, #bw "", #name 2 #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(-100, 0) 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 False: 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(2): 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.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 3, 0, 1, 2) for r in range(3, 4): self.tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not False: self.qtgui_const_sink_x_0.disable_legend() labels = ['A', 'B', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 2, 0, 1, 2) for r in range(2, 3): self.tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.tab_grid_layout_0.setColumnStretch(c, 1) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, if_rate, 10e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.lilacsat_vitfilt27_fb_0_0 = lilacsat.vitfilt27_fb() self.lilacsat_vitfilt27_fb_0 = lilacsat.vitfilt27_fb() self.lilacsat_two_bit_dpd_precoder_0 = lilacsat.two_bit_dpd_precoder( True) self.lilacsat_plan13_cc_0_2_0 = lilacsat.plan13_cc( True, tle_line1, tle_line2, lon, lat, alt, 259500000, samp_rate, True, True) self.lilacsat_plan13_cc_0 = lilacsat.plan13_cc(True, tle_line1, tle_line2, lon, lat, alt, fc - if_freq, if_rate, False, False) self.lilacsat_kiss_decode_pdu_0_0 = lilacsat.kiss_decode_pdu() self.lilacsat_fec_decode_b_0_0_0 = lilacsat.fec_decode_b( 214, True, False, False) self.lilacsat_fec_decode_b_0_0 = lilacsat.fec_decode_b( 214, True, False, False) self.lilacsat_attach_rs_codeblock_0 = lilacsat.attach_rs_codeblock(1) self.lilacsat_attach_preamble_and_tailer_0 = lilacsat.attach_preamble_and_tailer( 200, 100, True) self.dslwp_ccsds_pseudo_randomizer_0 = dslwp.ccsds_pseudo_randomizer(2) self.dslwp_attach_sync_marker_0 = dslwp.attach_sync_marker( (0x1a, 0xcf, 0xfc, 0x1d), 2) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 0.05, 2) self.digital_lms_dd_equalizer_cc_0_0 = digital.lms_dd_equalizer_cc( 2, equalizer_gain, 2, variable_constellation_0) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=8, bt=0.5, verbose=False, log=False, ) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( sps, alpha, 100, fll_bw) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( phase_bw, 2, False) self.blocks_unpack_k_bits_bb_0_0_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_socket_pdu_1 = blocks.socket_pdu("TCP_CLIENT", 'localhost', '52001', 10000, False) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((10, )) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, if_freq, 1, 0) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_1, 'pdus'), (self.lilacsat_kiss_decode_pdu_0_0, 'in')) self.msg_connect((self.dslwp_attach_sync_marker_0, 'out'), (self.lilacsat_attach_preamble_and_tailer_0, 'in')) self.msg_connect((self.dslwp_ccsds_pseudo_randomizer_0, 'out'), (self.dslwp_attach_sync_marker_0, 'in')) self.msg_connect((self.lilacsat_attach_preamble_and_tailer_0, 'out'), (self.lilacsat_two_bit_dpd_precoder_0, 'in')) self.msg_connect((self.lilacsat_attach_rs_codeblock_0, 'out'), (self.dslwp_ccsds_pseudo_randomizer_0, 'in')) self.msg_connect((self.lilacsat_fec_decode_b_0_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.lilacsat_fec_decode_b_0_0, 'out'), (self.blocks_socket_pdu_1, 'pdus')) self.msg_connect((self.lilacsat_fec_decode_b_0_0_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.lilacsat_fec_decode_b_0_0_0, 'out'), (self.blocks_socket_pdu_1, 'pdus')) self.msg_connect((self.lilacsat_kiss_decode_pdu_0_0, 'out'), (self.lilacsat_attach_rs_codeblock_0, 'in')) self.msg_connect((self.lilacsat_two_bit_dpd_precoder_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.analog_feedforward_agc_cc_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.lilacsat_vitfilt27_fb_0, 0)) self.connect((self.blocks_delay_0, 0), (self.lilacsat_vitfilt27_fb_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.lilacsat_plan13_cc_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0_0, 0), (self.lilacsat_fec_decode_b_0_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0_0_0, 0), (self.lilacsat_fec_decode_b_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_lms_dd_equalizer_cc_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.qtgui_freq_sink_x_0_0, 1)) self.connect((self.digital_gmsk_mod_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.lilacsat_plan13_cc_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.lilacsat_plan13_cc_0_2_0, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.lilacsat_vitfilt27_fb_0, 0), (self.blocks_unpack_k_bits_bb_0_0_0, 0)) self.connect((self.lilacsat_vitfilt27_fb_0_0, 0), (self.blocks_unpack_k_bits_bb_0_0_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_feedforward_agc_cc_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.lilacsat_plan13_cc_0_2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self, rf_params, bb_params): gr.hier_block2.__init__( self, "RX Demod Block", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), # single in gr.io_signature(1, 1, gr.sizeof_char * 1) # single out ) ################################################## # Parameters ################################################## # ADD VALIDITY CHECKS TO EACH OF THESE self.agc_enable = rf_params.agc_enable if self.agc_enable: self.threshold = 0.5 else: self.threshold = rf_params.threshold self.symbol_time = bb_params.symbol_time ################################################## # Variables ################################################## ################################################## # Blocks ################################################## if self.agc_enable: # the following blocks provide the AGC self.blocks_rms_xx_0 = blocks.rms_cf(self.symbol_time / 10) self.connect((self, 0), (self.blocks_rms_xx_0, 0)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.connect((self, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) # demodulation and cleanup self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) if self.agc_enable: # get input from agc output self.connect((self.blocks_divide_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) else: # connect input directly to input self.connect((self, 0), (self.blocks_complex_to_mag_0)) self.blocks_add_const_vxx_0 = blocks.add_const_vff( (-1 * self.threshold, )) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_add_const_vxx_0, 0)) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_binary_slicer_fb_0, 0)) # output from block self.connect((self.digital_binary_slicer_fb_0, 0), (self, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Hackrfone Am Rx 8Msps") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 8e6 self.ppm = ppm = 0 self.freq = freq = 472e3 self.fi = fi = 200e3 self.RF_Gain = RF_Gain = 0 self.FI_Gain = FI_Gain = 10 self.FI_BWD = FI_BWD = 10e3 self.BandWidth = BandWidth = 0 self.BB_Gain = BB_Gain = 20 self.Audio_Gain = Audio_Gain = 5 ################################################## # Blocks ################################################## _ppm_sizer = wx.BoxSizer(wx.VERTICAL) self._ppm_text_box = forms.text_box( parent=self.GetWin(), sizer=_ppm_sizer, value=self.ppm, callback=self.set_ppm, label='Freq. Corr. [ppm]', converter=forms.float_converter(), proportion=0, ) self._ppm_slider = forms.slider( parent=self.GetWin(), sizer=_ppm_sizer, value=self.ppm, callback=self.set_ppm, minimum=-10, maximum=10, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ppm_sizer, 1, 1, 1, 1) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "FI") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "AF") self.Add(self.notebook_0) _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=400e3, maximum=1.2e6, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_freq_sizer, 1, 0, 1, 1) self._RF_Gain_chooser = forms.button( parent=self.GetWin(), value=self.RF_Gain, callback=self.set_RF_Gain, label='RF Amp', choices=[0, 8], labels=['0 dB', '13 dB'], ) self.GridAdd(self._RF_Gain_chooser, 0, 0, 1, 1) _FI_Gain_sizer = wx.BoxSizer(wx.VERTICAL) self._FI_Gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_FI_Gain_sizer, value=self.FI_Gain, callback=self.set_FI_Gain, label='Rx FI Gain', converter=forms.float_converter(), proportion=0, ) self._FI_Gain_slider = forms.slider( parent=self.GetWin(), sizer=_FI_Gain_sizer, value=self.FI_Gain, callback=self.set_FI_Gain, minimum=0, maximum=47, num_steps=47, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_FI_Gain_sizer, 0, 1, 1, 1) _FI_BWD_sizer = wx.BoxSizer(wx.VERTICAL) self._FI_BWD_text_box = forms.text_box( parent=self.GetWin(), sizer=_FI_BWD_sizer, value=self.FI_BWD, callback=self.set_FI_BWD, label='FI Bandwidth', converter=forms.float_converter(), proportion=0, ) self._FI_BWD_slider = forms.slider( parent=self.GetWin(), sizer=_FI_BWD_sizer, value=self.FI_BWD, callback=self.set_FI_BWD, minimum=500, maximum=20e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_FI_BWD_sizer, 1, 3, 1, 1) self._BandWidth_chooser = forms.drop_down( parent=self.GetWin(), value=self.BandWidth, callback=self.set_BandWidth, label='Bandwidth', choices=[0, 1.75e6, 20e6], labels=['Auto', '1.75 MHz', '20 MHz'], ) self.GridAdd(self._BandWidth_chooser, 0, 3, 1, 1) _BB_Gain_sizer = wx.BoxSizer(wx.VERTICAL) self._BB_Gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_BB_Gain_sizer, value=self.BB_Gain, callback=self.set_BB_Gain, label='Base Band Gain', converter=forms.float_converter(), proportion=0, ) self._BB_Gain_slider = forms.slider( parent=self.GetWin(), sizer=_BB_Gain_sizer, value=self.BB_Gain, callback=self.set_BB_Gain, minimum=0, maximum=62, num_steps=31, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_BB_Gain_sizer, 0, 2, 1, 1) _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=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_Audio_Gain_sizer, 1, 2, 1, 1) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit='Unidades', minval=0, maxval=2, factor=1.0, decimal_places=2, ref_level=0, sample_rate=samp_rate, number_rate=2, average=False, avg_alpha=0.5, label='RMS de Entrada', peak_hold=False, show_gauge=True, ) self.GridAdd(self.wxgui_numbersink2_0.win, 2, 0, 1, 4) self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).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=0.5, title='FFT Plot', peak_hold=False, size=(800,400), ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0_1.win) self.wxgui_fftsink2_0_0_0_0 = fftsink2.fft_sink_f( self.notebook_0.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=32000, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.2, title='AF', peak_hold=False, size=(800,500), ) self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0_0_0_0.win) self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(1).GetWin(), baseband_freq=fi, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate/80, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.2, title='FI', peak_hold=False, size=(800,500), ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0_0_0.win) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=8, decimation=25, 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+fi, 0) self.osmosdr_source_0.set_freq_corr(ppm, 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(True, 0) self.osmosdr_source_0.set_gain(RF_Gain, 0) self.osmosdr_source_0.set_if_gain(FI_Gain, 0) self.osmosdr_source_0.set_bb_gain(BB_Gain, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(BandWidth, 0) self.low_pass_filter_0 = filter.fir_filter_ccf(80, firdes.low_pass( 1, samp_rate, FI_BWD/2, samp_rate/2500, firdes.WIN_HAMMING, 6.76)) self.dc_blocker_xx_0 = filter.dc_blocker_ff(160, True) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) 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(32000, '', True) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, fi, 1, 0) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=samp_rate/80, audio_decim=1, audio_pass=5000, audio_stop=7000, ) ################################################## # Connections ################################################## self.connect((self.analog_am_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_0_1, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_fftsink2_0_0_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.dc_blocker_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Modes Uf Rx Sigmf V2") Qt.QWidget.__init__(self) self.setWindowTitle("Modes Uf Rx Sigmf V2") 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", "modes_uf_rx_sigmf_v2") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 2 self.samp_rate = samp_rate = 8000000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( 1, 1, 0.5, 0.4, 32) self.rms_alpha = rms_alpha = 1e-6 self.rf_gain = rf_gain = 45 self.qt_thresh = qt_thresh = 110 self.es_thresh = es_thresh = 110 self.det_mult = det_mult = 2 self.det_avg_len = det_avg_len = 20 self.cons_offset = cons_offset = 5 self.burst_length = burst_length = 600 self.bit_thresh = bit_thresh = 5 self.avg_len = avg_len = 20 ################################################## # Blocks ################################################## self._rms_alpha_tool_bar = Qt.QToolBar(self) self._rms_alpha_tool_bar.addWidget(Qt.QLabel("rms_alpha" + ": ")) self._rms_alpha_line_edit = Qt.QLineEdit(str(self.rms_alpha)) self._rms_alpha_tool_bar.addWidget(self._rms_alpha_line_edit) self._rms_alpha_line_edit.returnPressed.connect( lambda: self.set_rms_alpha( eng_notation.str_to_num( str(self._rms_alpha_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rms_alpha_tool_bar, 6, 3, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self._qt_thresh_tool_bar = Qt.QToolBar(self) self._qt_thresh_tool_bar.addWidget(Qt.QLabel("qt_thresh" + ": ")) self._qt_thresh_line_edit = Qt.QLineEdit(str(self.qt_thresh)) self._qt_thresh_tool_bar.addWidget(self._qt_thresh_line_edit) self._qt_thresh_line_edit.returnPressed.connect( lambda: self.set_qt_thresh( eng_notation.str_to_num( str(self._qt_thresh_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._qt_thresh_tool_bar, 0, 2, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._es_thresh_tool_bar = Qt.QToolBar(self) self._es_thresh_tool_bar.addWidget(Qt.QLabel('ES Thresh' + ": ")) self._es_thresh_line_edit = Qt.QLineEdit(str(self.es_thresh)) self._es_thresh_tool_bar.addWidget(self._es_thresh_line_edit) self._es_thresh_line_edit.returnPressed.connect( lambda: self.set_es_thresh( eng_notation.str_to_num( str(self._es_thresh_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._es_thresh_tool_bar, 0, 5, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._det_mult_tool_bar = Qt.QToolBar(self) self._det_mult_tool_bar.addWidget(Qt.QLabel("det_mult" + ": ")) self._det_mult_line_edit = Qt.QLineEdit(str(self.det_mult)) self._det_mult_tool_bar.addWidget(self._det_mult_line_edit) self._det_mult_line_edit.returnPressed.connect( lambda: self.set_det_mult( eng_notation.str_to_num( str(self._det_mult_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._det_mult_tool_bar, 0, 6, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self._det_avg_len_tool_bar = Qt.QToolBar(self) self._det_avg_len_tool_bar.addWidget(Qt.QLabel("det_avg_len" + ": ")) self._det_avg_len_line_edit = Qt.QLineEdit(str(self.det_avg_len)) self._det_avg_len_tool_bar.addWidget(self._det_avg_len_line_edit) self._det_avg_len_line_edit.returnPressed.connect( lambda: self.set_det_avg_len( int(str(self._det_avg_len_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._det_avg_len_tool_bar, 0, 9, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(9, 10): self.top_grid_layout.setColumnStretch(c, 1) self._cons_offset_tool_bar = Qt.QToolBar(self) self._cons_offset_tool_bar.addWidget(Qt.QLabel("cons_offset" + ": ")) self._cons_offset_line_edit = Qt.QLineEdit(str(self.cons_offset)) self._cons_offset_tool_bar.addWidget(self._cons_offset_line_edit) self._cons_offset_line_edit.returnPressed.connect( lambda: self.set_cons_offset( eng_notation.str_to_num( str(self._cons_offset_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._cons_offset_tool_bar, 0, 8, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(8, 9): self.top_grid_layout.setColumnStretch(c, 1) self._avg_len_tool_bar = Qt.QToolBar(self) self._avg_len_tool_bar.addWidget(Qt.QLabel("avg_len" + ": ")) self._avg_len_line_edit = Qt.QLineEdit(str(self.avg_len)) self._avg_len_tool_bar.addWidget(self._avg_len_line_edit) self._avg_len_line_edit.returnPressed.connect(lambda: self.set_avg_len( eng_notation.str_to_num( str(self._avg_len_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._avg_len_tool_bar, 0, 4, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self.vcc_es_tag_to_utc_0 = vcc.es_tag_to_utc(samp_rate) self.vcc_burst_snr_0 = vcc.burst_snr(25, 2) self.sigmf_source_0 = gr_sigmf.source( '/captures/adsb/20210127/MODE-S_2021-01-27T23:43:24.sigmf-data', "ci16" + ("_le" if sys.byteorder == "little" else "_be"), False) self._rf_gain_tool_bar = Qt.QToolBar(self) self._rf_gain_tool_bar.addWidget(Qt.QLabel("rf_gain" + ": ")) self._rf_gain_line_edit = Qt.QLineEdit(str(self.rf_gain)) self._rf_gain_tool_bar.addWidget(self._rf_gain_line_edit) self._rf_gain_line_edit.returnPressed.connect(lambda: self.set_rf_gain( eng_notation.str_to_num( str(self._rf_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rf_gain_tool_bar, 0, 0, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( burst_length / 2, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.010) self.qtgui_time_sink_x_1.set_y_axis(-5, 20) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, qt_thresh, 1.0 / samp_rate * 100, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(True) self.qtgui_time_sink_x_1.enable_grid(True) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 0, 2, 4) for r in range(1, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( burst_length / 2, #size samp_rate / 2, #samp_rate "soft chips", #name 3 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0, 0, 0, "es::event_type") self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(False) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['re', 'abs', 'mag', 'ph', '', '', '', '', '', ''] 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, 2, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -1, 0, -1, -1, -1, -1, -1, -1, -1] alphas = [1, 0.25, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 3, 0, 3, 5) for r in range(3, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 5): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_b( samp_rate / 2, 20, 56, ([]), ([]), "", 1, ) self.qtgui_time_raster_sink_x_0.set_update_time(0.10) self.qtgui_time_raster_sink_x_0.set_intensity_range(-1, 1) self.qtgui_time_raster_sink_x_0.enable_grid(False) self.qtgui_time_raster_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_raster_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance( self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_raster_sink_x_0_win, 3, 5, 3, 5) for r in range(3, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 10): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( burst_length / 2, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.010) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(True) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 8, 2, 2) for r in range(1, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(8, 10): self.top_grid_layout.setColumnStretch(c, 1) self.pyqt_ctime_plot_0 = pyqt.ctime_plot('') self._pyqt_ctime_plot_0_win = self.pyqt_ctime_plot_0 self.top_grid_layout.addWidget(self._pyqt_ctime_plot_0_win, 1, 4, 2, 2) for r in range(1, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self.pyqt_const_plot_0 = pyqt.const_plot(label='') self._pyqt_const_plot_0_win = self.pyqt_const_plot_0 self.top_grid_layout.addWidget(self._pyqt_const_plot_0_win, 1, 6, 2, 2) for r in range(1, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 4e6, 250e3, firdes.WIN_BLACKMAN, 6.76)) self.fosphor_glfw_sink_c_0 = fosphor.glfw_sink_c() self.fosphor_glfw_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_glfw_sink_c_0.set_frequency_range(0, samp_rate) self.es_trigger_edge_f_0 = es.trigger_edge_f(es_thresh, burst_length, burst_length / 3, gr.sizeof_gr_complex, 300) self.es_sink_0 = es.sink(1 * [gr.sizeof_gr_complex], 4, 64, 0, 2, 0) self.es_handler_pdu_0 = es.es_make_handler_pdu( es.es_handler_print.TYPE_C32) self.epy_block_1 = epy_block_1.uf_frame_sync(tag_name='sync', msg_len=112, samp_rate=samp_rate, sps=2) self.epy_block_0_0 = epy_block_0_0.uf_decode(msg_filter='All Messages', verbose=True) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( 2, math.pi / 200, (rrc_taps), 32, 16, 1.1, 1) self.digital_diff_phasor_cc_0 = digital.diff_phasor_cc() self.digital_costas_loop_cc_0 = digital.costas_loop_cc( math.pi / 50, 2, False) self.digital_correlate_access_code_tag_xx_0_0_1_2_2_0_0_0 = digital.correlate_access_code_tag_bb( '00011111000111000001', 3, 'sync') self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * 2, True) self.blocks_sub_xx_2_0 = blocks.sub_ff(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_float * 1, 1) self.blocks_rms_xx_1 = blocks.rms_cf(rms_alpha) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.complex_t, 'est_len') (self.blocks_pdu_to_tagged_stream_0).set_min_output_buffer(600) self.blocks_pdu_remove_0 = blocks.pdu_remove( pmt.intern("es::event_buffer")) self.blocks_multiply_const_xx_0 = blocks.multiply_const_cc(1.0 / 65536.0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (-1 * det_mult, )) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff( int(det_avg_len), 1.0 / det_avg_len, 4000, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( int(avg_len), 1.0 / avg_len, 4000, 1) self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex( True, False) self.blocks_complex_to_real_1_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1 / 10.0) self.blocks_add_const_vxx_0 = blocks.add_const_vff((cons_offset, )) self.blocks_abs_xx_0 = blocks.abs_ff(1) self._bit_thresh_tool_bar = Qt.QToolBar(self) self._bit_thresh_tool_bar.addWidget(Qt.QLabel("bit_thresh" + ": ")) self._bit_thresh_line_edit = Qt.QLineEdit(str(self.bit_thresh)) self._bit_thresh_tool_bar.addWidget(self._bit_thresh_line_edit) self._bit_thresh_line_edit.returnPressed.connect( lambda: self.set_bit_thresh( eng_notation.str_to_num( str(self._bit_thresh_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._bit_thresh_tool_bar, 6, 4, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) self.ais_invert_0 = ais.invert() ################################################## # Connections ################################################## self.msg_connect((self.blocks_pdu_remove_0, 'pdus'), (self.vcc_burst_snr_0, 'in')) self.msg_connect((self.epy_block_0_0, 'out'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.epy_block_1, 'out'), (self.epy_block_0_0, 'in')) self.msg_connect((self.es_handler_pdu_0, 'pdus_out'), (self.blocks_pdu_remove_0, 'pdus')) self.msg_connect((self.es_trigger_edge_f_0, 'edge_event'), (self.es_handler_pdu_0, 'handle_event')) self.msg_connect((self.es_trigger_edge_f_0, 'which_stream'), (self.es_sink_0, 'schedule_event')) self.msg_connect((self.vcc_burst_snr_0, 'out'), (self.vcc_es_tag_to_utc_0, 'in')) self.msg_connect((self.vcc_es_tag_to_utc_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.vcc_es_tag_to_utc_0, 'out'), (self.pyqt_const_plot_0, 'cpdus')) self.msg_connect((self.vcc_es_tag_to_utc_0, 'out'), (self.pyqt_ctime_plot_0, 'cpdus')) self.connect( (self.ais_invert_0, 0), (self.digital_correlate_access_code_tag_xx_0_0_1_2_2_0_0_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.es_trigger_edge_f_0, 1)) self.connect((self.analog_agc2_xx_0, 0), (self.fosphor_glfw_sink_c_0, 0)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_time_sink_x_1, 2)) self.connect((self.blocks_char_to_float_0_1, 0), (self.qtgui_time_sink_x_0_1, 2)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_complex_to_real_1_0_0, 0), (self.blocks_sub_xx_2_0, 0)) self.connect((self.blocks_complex_to_real_1_0_0, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.blocks_multiply_const_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.es_trigger_edge_f_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.qtgui_time_raster_sink_x_0, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_sub_xx_2_0, 1)) self.connect((self.blocks_rms_xx_1, 0), (self.qtgui_time_sink_x_0_1, 1)) self.connect((self.blocks_skiphead_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_sub_xx_2_0, 0), (self.digital_binary_slicer_fb_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.ais_invert_0, 0)) self.connect( (self.digital_correlate_access_code_tag_xx_0_0_1_2_2_0_0_0, 0), (self.blocks_char_to_float_0_1, 0)) self.connect( (self.digital_correlate_access_code_tag_xx_0_0_1_2_2_0_0_0, 0), (self.epy_block_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_diff_phasor_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_diff_phasor_cc_0, 0), (self.blocks_complex_to_real_1_0_0, 0)) self.connect((self.digital_diff_phasor_cc_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.es_trigger_edge_f_0, 0), (self.es_sink_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.sigmf_source_0, 0), (self.blocks_interleaved_short_to_complex_0, 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").toByteArray()) ################################################## # Variables ################################################## self.down_samprate = down_samprate = 120e3 self.down_bw = down_bw = 20e3 self.up_symbolrate = up_symbolrate = 10e3 self.lpf_taps = lpf_taps = firdes.low_pass(1.0, down_samprate, down_bw / 2, down_bw / 8, firdes.WIN_HAMMING, 6.76) self.vfo = vfo = 30e3 self.up_samprate = up_samprate = down_samprate self.up_mod_index = up_mod_index = 2 self.up_gain = up_gain = 60 self.up_freq = up_freq = 436.5e6 self.up_bw = up_bw = up_symbolrate * 4 self.sc_id = sc_id = 1 self.lpf_ntaps = lpf_ntaps = len(lpf_taps) self.fcorr = fcorr = 0 self.down_symbolrate = down_symbolrate = 20e3 self.down_gain = down_gain = 23 self.down_freq = down_freq = 436.5e6 self.down_decim = down_decim = 3 ################################################## # Blocks ################################################## self._fcorr_range = Range(-15e3, 15e3, 100, 0, 200) self._fcorr_win = RangeWidget(self._fcorr_range, self.set_fcorr, "fcorr", "counter_slider", float) self.top_layout.addWidget(self._fcorr_win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(down_samprate) self.uhd_usrp_source_0.set_center_freq(down_freq - vfo, 0) self.uhd_usrp_source_0.set_gain(down_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_bandwidth(down_samprate / 2, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(up_samprate) self.uhd_usrp_sink_0.set_center_freq(up_freq + fcorr, 0) self.uhd_usrp_sink_0.set_gain(up_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_bandwidth(up_samprate / 2, 0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype down_freq - vfo, #fc down_samprate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.1) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -60) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size down_samprate / 1024, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc down_samprate / down_decim, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, -40) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [0.3, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.kcsa_vitfilt27_bb_0_0 = kcsa.vitfilt27_bb() self.kcsa_vitfilt27_bb_0 = kcsa.vitfilt27_bb() self.kcsa_kiss_server_0 = kcsa.kiss_server('127.0.0.1', 2610, 1024, 25, 10) self.kcsa_halfduplex_tc_0 = kcsa.halfduplex_tc(1, 0, True, 128, 4) self.kcsa_fec_decode_b_0_0_0 = kcsa.fec_decode_b( 223, False, False, True, False) self.kcsa_fec_decode_b_0_0 = kcsa.fec_decode_b(223, False, False, True, False) self.gpredict_doppler_0 = gpredict.doppler(self.set_fcorr, "localhost", 4532, True) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( down_decim, (lpf_taps), vfo + fcorr, down_samprate) self.fir_filter_xxx_0 = filter.fir_filter_fff(1024, (np.ones(1024) / 1024)) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=int(down_samprate / down_decim / down_symbolrate), gain_mu=0.175, mu=0.5, omega_relative_limit=0.02, freq_error=0.01, verbose=False, log=False, ) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=int(up_samprate / up_symbolrate), sensitivity=math.pi * up_mod_index / int(up_samprate / up_symbolrate), bt=0.5, verbose=False, log=False, ) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_gr_complex * 1, '', "") self.blocks_tag_debug_0.set_display(True) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_delay_0 = blocks.delay(gr.sizeof_char * 1, 1) ################################################## # Connections ################################################## self.msg_connect((self.kcsa_fec_decode_b_0_0, 'out'), (self.kcsa_kiss_server_0, 'in')) self.msg_connect((self.kcsa_fec_decode_b_0_0_0, 'out'), (self.kcsa_kiss_server_0, 'in')) self.msg_connect((self.kcsa_kiss_server_0, 'out'), (self.kcsa_halfduplex_tc_0, 'pdu')) self.connect((self.blocks_delay_0, 0), (self.kcsa_vitfilt27_bb_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.kcsa_vitfilt27_bb_0_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.kcsa_halfduplex_tc_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.kcsa_vitfilt27_bb_0, 0), (self.kcsa_fec_decode_b_0_0, 0)) self.connect((self.kcsa_vitfilt27_bb_0_0, 0), (self.kcsa_fec_decode_b_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Bpsk Receiverpoly") ################################################## # Variables ################################################## self.sps = sps = 8 self.probe_var = probe_var = 0 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.SNR = SNR = 500 self.transistion = transistion = 100 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.sideband_rx = sideband_rx = 500 self.sideband = sideband = 500 self.samp_rate = samp_rate = 48000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts/16, nfilts/16, 1.0/float(sps), 0.35, 11*sps*nfilts/16) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.probe_var_n = probe_var_n = 0 self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase_bw = phase_bw = 6.28/100.0 self.noise_amp = noise_amp = probe_var/(10**(SNR/20)) self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.interpolation = interpolation = 2000 self.eq_gain = eq_gain = 0.01 self.delay = delay = 0 self.decimation = decimation = 1 self.constel = constel = digital.constellation_calcdist(([1,- 1]), ([0,1]), 2, 1).base() self.carrier = carrier = 10000 self.arity = arity = 2 ################################################## # Blocks ################################################## self.probe_rms = blocks.probe_signal_f() self.probe_avg_n = blocks.probe_signal_f() self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=decimation, decimation=interpolation, taps=(rrc_taps), fractional_bw=None, ) def _probe_var_n_probe(): while True: val = self.probe_avg_n.level() try: self.set_probe_var_n(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_var_n_thread = threading.Thread(target=_probe_var_n_probe) _probe_var_n_thread.daemon = True _probe_var_n_thread.start() def _probe_var_probe(): while True: val = self.probe_rms.level() try: self.set_probe_var(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_var_thread = threading.Thread(target=_probe_var_probe) _probe_var_thread.daemon = True _probe_var_thread.start() self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, (filter.firdes.low_pass(1, samp_rate*10, sideband_rx,1000)), carrier, samp_rate) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 1) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constel) script, SNRinput, inputwav, outputBinary, delay= argv self.blocks_wavfile_source_0 = blocks.wavfile_source(inputwav, False) self.blocks_throttle_1_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_rms_xx_1 = blocks.rms_cf(0.01) self.blocks_rms_xx_0 = blocks.rms_cf(0.01) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, outputBinary, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_1 = blocks.delay(gr.sizeof_char*1, int(delay)) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, noise_amp, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.probe_rms, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.probe_avg_n, 0)) self.connect((self.blocks_throttle_1_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_throttle_1_0_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_delay_1, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_throttle_1_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10e3 self.center_freq = center_freq = 49.8552e6 ################################################## # Blocks ################################################## self.rtlsdr_source_0_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0_0.set_sample_rate(samp_rate) self.rtlsdr_source_0_0.set_center_freq(center_freq, 0) self.rtlsdr_source_0_0.set_freq_corr(0, 0) self.rtlsdr_source_0_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0_0.set_gain_mode(False, 0) self.rtlsdr_source_0_0.set_gain(50, 0) self.rtlsdr_source_0_0.set_if_gain(0, 0) self.rtlsdr_source_0_0.set_bb_gain(0, 0) self.rtlsdr_source_0_0.set_antenna("", 0) self.rtlsdr_source_0_0.set_bandwidth(0, 0) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024 * 8, #size samp_rate, #samp_rate "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024 * 8, #size samp_rate, #samp_rate "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_threshold_ff_0 = blocks.threshold_ff(0.5, 0.5, 0) self.blocks_rms_xx_0 = blocks.rms_cf(0.01) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_float * 1, addr="127.0.0.1", port=2600, server=True, ) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.rtlsdr_source_0_0, 0), (self.analog_agc_xx_0, 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").toByteArray()) ################################################## # Variables ################################################## self.vector = vector = (88.1e6, 89.1e6, 89.7e6, 90.1e6, 90.5e6, 90.9e6, 91.3e6, 92.1e6, 92.5e6, 92.9e6, 93.7e6, 94.1e6, 94.7e6, 95.3e6, 95.7e6, 96.1e6, 96.5e6, 96.9e6, 97.3e6, 97.7e6, 98.1e6, 98.5e6, 98.9e6, 99.3e6, 100.1e6, 100.9e6, 101.3e6, 101.5e6, 101.7e6, 102.1e6, 102.5e6, 103.3e6, 104.1e6, 104.3e6, 104.7e6, 105.1e6, 105.7e6, 106.3e6, 106.9e6, 107.3e6, 107.9e6) self.indice = indice = 0 self.ajuste = ajuste = 0 self.samp_rate = samp_rate = 2.4e6 self.freq_Passa_Faixa_REAL = freq_Passa_Faixa_REAL = vector[indice] + ( vector[indice + 1] - vector[indice]) + ajuste self.freq_Passa_Faixa = freq_Passa_Faixa = vector[indice + 1] self.freq_Passa_Baixa = freq_Passa_Baixa = vector[indice] self.down_rate = down_rate = 25e4 self.bw = bw = 100e3 self.Update_Interval = Update_Interval = 0.1 self.OutputDir = OutputDir = "/home/iris/Desktop/medidas/" self.FileNameCP = FileNameCP = "CP_" + str(indice) + "_" + str( vector[indice]) + ".bin" self.FileNameCAS = FileNameCAS = "CAS_" + str(indice + 1) + "_" + str( vector[indice + 1]) + ".bin" ################################################## # Blocks ################################################## self._indice_range = Range(0, 40, 1, 0, 2) self._indice_win = RangeWidget(self._indice_range, self.set_indice, "indice", "counter", int) self.top_grid_layout.addWidget(self._indice_win, 2, 3, 1, 3) self._ajuste_range = Range(-600e3, 600e3, 100, 0, 300) self._ajuste_win = RangeWidget(self._ajuste_range, self.set_ajuste, "ajuste", "counter_slider", float) self.top_grid_layout.addWidget(self._ajuste_win, 2, 0, 1, 3) 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(vector[indice], 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(70, 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.qtgui_freq_sink_x_1_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype vector[indice], #fc samp_rate, #bw 'Filtro Passa Baixa', #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_1.set_update_time(0.10) self.qtgui_freq_sink_x_1_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_1.set_y_label('Ganho Relativo', 'dB') self.qtgui_freq_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_1.enable_autoscale(False) self.qtgui_freq_sink_x_1_1.enable_grid(False) self.qtgui_freq_sink_x_1_1.set_fft_average(0.1) self.qtgui_freq_sink_x_1_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_1_win, 6, 0, 1, 3) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype vector[indice] + (vector[indice + 1] - vector[indice]) + ajuste, #fc samp_rate, #bw 'Filtro Passa Faixa', #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(Update_Interval / 10) self.qtgui_freq_sink_x_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Ganho Relativo', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(False) self.qtgui_freq_sink_x_1_0.set_fft_average(0.1) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 6, 4, 1, 3) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype vector[indice], #fc samp_rate, #bw 'antes de filtrar', #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(Update_Interval / 10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(0.05) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 5, 0, 1, 6) self.low_pass_filter_0_1 = filter.fir_filter_ccf( 8, firdes.low_pass(2, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76)) self._freq_Passa_Faixa_REAL_tool_bar = Qt.QToolBar(self) if None: self._freq_Passa_Faixa_REAL_formatter = None else: self._freq_Passa_Faixa_REAL_formatter = lambda x: eng_notation.num_to_str( x) self._freq_Passa_Faixa_REAL_tool_bar.addWidget( Qt.QLabel('Freq (Chanel +1) + ajuste (PF)' + ": ")) self._freq_Passa_Faixa_REAL_label = Qt.QLabel( str( self._freq_Passa_Faixa_REAL_formatter( self.freq_Passa_Faixa_REAL))) self._freq_Passa_Faixa_REAL_tool_bar.addWidget( self._freq_Passa_Faixa_REAL_label) self.top_grid_layout.addWidget(self._freq_Passa_Faixa_REAL_tool_bar, 3, 5, 1, 3) self._freq_Passa_Faixa_tool_bar = Qt.QToolBar(self) if None: self._freq_Passa_Faixa_formatter = None else: self._freq_Passa_Faixa_formatter = lambda x: eng_notation.num_to_str( x) self._freq_Passa_Faixa_tool_bar.addWidget( Qt.QLabel('Freq(chanel + 1)' + ": ")) self._freq_Passa_Faixa_label = Qt.QLabel( str(self._freq_Passa_Faixa_formatter(self.freq_Passa_Faixa))) self._freq_Passa_Faixa_tool_bar.addWidget(self._freq_Passa_Faixa_label) self.top_grid_layout.addWidget(self._freq_Passa_Faixa_tool_bar, 3, 3, 1, 3) self._freq_Passa_Baixa_tool_bar = Qt.QToolBar(self) if None: self._freq_Passa_Baixa_formatter = None else: self._freq_Passa_Baixa_formatter = lambda x: eng_notation.num_to_str( x) self._freq_Passa_Baixa_tool_bar.addWidget( Qt.QLabel('Freq (Chanel)' + ": ")) self._freq_Passa_Baixa_label = Qt.QLabel( str(self._freq_Passa_Baixa_formatter(self.freq_Passa_Baixa))) self._freq_Passa_Baixa_tool_bar.addWidget(self._freq_Passa_Baixa_label) self.top_grid_layout.addWidget(self._freq_Passa_Baixa_tool_bar, 3, 0, 1, 3) self.blocks_rms_xx_1 = blocks.rms_cf(0.0001) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(20, 1, 1) self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(20, 1, 1) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1, OutputDir + FileNameCP, False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 1, OutputDir + FileNameCAS, False) self.blocks_file_sink_0.set_unbuffered(False) self.band_pass_filter = filter.fir_filter_ccf( 8, firdes.band_pass( 2, samp_rate, (vector[indice + 1] - vector[indice]) - bw + ajuste, (vector[indice + 1] - vector[indice]) + bw + ajuste, 10e3, firdes.WIN_HAMMING, 6.76)) self.POTENCIA_PASSA_FAIXA = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.POTENCIA_PASSA_FAIXA.set_update_time(Update_Interval) self.POTENCIA_PASSA_FAIXA.set_title('POT_CAS (dB)') labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.POTENCIA_PASSA_FAIXA.set_min(i, -1) self.POTENCIA_PASSA_FAIXA.set_max(i, 1) self.POTENCIA_PASSA_FAIXA.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.POTENCIA_PASSA_FAIXA.set_label(i, "Data {0}".format(i)) else: self.POTENCIA_PASSA_FAIXA.set_label(i, labels[i]) self.POTENCIA_PASSA_FAIXA.set_unit(i, units[i]) self.POTENCIA_PASSA_FAIXA.set_factor(i, factor[i]) self.POTENCIA_PASSA_FAIXA.enable_autoscale(False) self._POTENCIA_PASSA_FAIXA_win = sip.wrapinstance( self.POTENCIA_PASSA_FAIXA.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._POTENCIA_PASSA_FAIXA_win, 4, 3, 1, 3) self.POTENCIA_PASSA_BAIXA = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.POTENCIA_PASSA_BAIXA.set_update_time(Update_Interval) self.POTENCIA_PASSA_BAIXA.set_title('POT_CP (dB)') labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.POTENCIA_PASSA_BAIXA.set_min(i, -1) self.POTENCIA_PASSA_BAIXA.set_max(i, 1) self.POTENCIA_PASSA_BAIXA.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.POTENCIA_PASSA_BAIXA.set_label(i, "Data {0}".format(i)) else: self.POTENCIA_PASSA_BAIXA.set_label(i, labels[i]) self.POTENCIA_PASSA_BAIXA.set_unit(i, units[i]) self.POTENCIA_PASSA_BAIXA.set_factor(i, factor[i]) self.POTENCIA_PASSA_BAIXA.enable_autoscale(False) self._POTENCIA_PASSA_BAIXA_win = sip.wrapinstance( self.POTENCIA_PASSA_BAIXA.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._POTENCIA_PASSA_BAIXA_win, 4, 0, 1, 3) ################################################## # Connections ################################################## self.connect((self.band_pass_filter, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.band_pass_filter, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.blocks_nlog10_ff_0_0, 0), (self.POTENCIA_PASSA_BAIXA, 0)) self.connect((self.blocks_nlog10_ff_0_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_nlog10_ff_0_1, 0), (self.POTENCIA_PASSA_FAIXA, 0)) self.connect((self.blocks_nlog10_ff_0_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_nlog10_ff_0_1, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_nlog10_ff_0_0, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.qtgui_freq_sink_x_1_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.band_pass_filter, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_1, 0))
def __init__(self): gr.top_block.__init__(self, "Demod Node 1: BPSK 9k6") Qt.QWidget.__init__(self) self.setWindowTitle("Demod Node 1: BPSK 9k6") 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", "demod_node1_bpsk_9k6") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 5 self.nfilts = nfilts = 16 self.alpha = alpha = 0.35 self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 2, 1).base() self.timing_loop_bw = timing_loop_bw = 0.05 self.samp_rate = samp_rate = 48000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), alpha, 11 * sps * nfilts) self.phase_bw = phase_bw = 0.02 self.fll_bw = fll_bw = 0.01 self.equalizer_gain = equalizer_gain = 0.05 self.digigain = digigain = 20 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Spectrum') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Loop') self.top_grid_layout.addWidget(self.tab, 2, 0, 1, 2) self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 0.05, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, 'Time: Bandwidth', "counter_slider", float) self.tab_grid_layout_1.addWidget(self._timing_loop_bw_win, 1, 0) self._phase_bw_range = Range(0.0, 1.0, 0.01, 0.02, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, 'Phase: Bandwidth', "counter_slider", float) self.tab_grid_layout_1.addWidget(self._phase_bw_win, 2, 0) self._fll_bw_range = Range(0.0, 0.2, 0.001, 0.01, 200) self._fll_bw_win = RangeWidget(self._fll_bw_range, self.set_fll_bw, 'FLL: Bandwidth', "counter_slider", float) self.tab_grid_layout_1.addWidget(self._fll_bw_win, 0, 0) self._equalizer_gain_range = Range(0.0, 0.2, 0.01, 0.05, 200) self._equalizer_gain_win = RangeWidget(self._equalizer_gain_range, self.set_equalizer_gain, 'Equalizer: Gain', "counter_slider", float) self.tab_grid_layout_1.addWidget(self._equalizer_gain_win, 3, 0) self._digigain_tool_bar = Qt.QToolBar(self) self._digigain_tool_bar.addWidget(Qt.QLabel("digigain" + ": ")) self._digigain_line_edit = Qt.QLineEdit(str(self.digigain)) self._digigain_tool_bar.addWidget(self._digigain_line_edit) self._digigain_line_edit.returnPressed.connect( lambda: self.set_digigain( eng_notation.str_to_num( str(self._digigain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._digigain_tool_bar, 0, 0) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0.001, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title('') labels = ['RSSI', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 48e3, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-100, 0) 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 "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['A', 'B', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 0, 1, 2) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 10e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.lilacsat_vitfilt27_fb_0_0 = lilacsat.vitfilt27_fb() self.lilacsat_vitfilt27_fb_0 = lilacsat.vitfilt27_fb() self.lilacsat_plan13_cc_0 = lilacsat.plan13_cc(True, tle_line1, tle_line2, lon, lat, alt, 437200000, samp_rate, False, True) self.lilacsat_kiss_decode_pdu_0 = lilacsat.kiss_decode_pdu() self.lilacsat_fec_decode_b_0_0_0 = lilacsat.fec_decode_b( 114, True, False, False) self.lilacsat_fec_decode_b_0_0 = lilacsat.fec_decode_b( 114, True, False, False) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 0.05, 2) self.digital_lms_dd_equalizer_cc_0_0 = digital.lms_dd_equalizer_cc( 2, equalizer_gain, 2, variable_constellation_0) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( sps, alpha, 100, fll_bw) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( phase_bw, 2, False) self.blocks_unpack_k_bits_bb_0_0_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex * 1, '127.0.0.1', 7200, 1472, False) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, 1, 0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (10**(digigain / 20), )) self.blocks_message_debug_1 = blocks.message_debug() self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 2) ################################################## # Connections ################################################## self.msg_connect((self.lilacsat_fec_decode_b_0_0, 'out'), (self.lilacsat_kiss_decode_pdu_0, 'in')) self.msg_connect((self.lilacsat_fec_decode_b_0_0_0, 'out'), (self.lilacsat_kiss_decode_pdu_0, 'in')) self.msg_connect((self.lilacsat_kiss_decode_pdu_0, 'out'), (self.blocks_message_debug_1, 'print_pdu')) self.connect((self.analog_feedforward_agc_cc_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.lilacsat_vitfilt27_fb_0, 0)) self.connect((self.blocks_delay_0, 0), (self.lilacsat_vitfilt27_fb_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.lilacsat_plan13_cc_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0_0, 0), (self.lilacsat_fec_decode_b_0_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0_0_0, 0), (self.lilacsat_fec_decode_b_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_lms_dd_equalizer_cc_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.digital_lms_dd_equalizer_cc_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.lilacsat_plan13_cc_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.lilacsat_vitfilt27_fb_0, 0), (self.blocks_unpack_k_bits_bb_0_0_0, 0)) self.connect((self.lilacsat_vitfilt27_fb_0_0, 0), (self.blocks_unpack_k_bits_bb_0_0_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_feedforward_agc_cc_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_rms_xx_0, 0))
def __init__(self, freq=0, gain=0, loopbw=100, fllbw=0.002): gr.top_block.__init__(self, "Rx") ################################################## # Parameters ################################################## self.freq = freq self.gain = gain self.loopbw = loopbw self.fllbw = fllbw ################################################## # Variables ################################################## self.sps = sps = 8 self.excess_bw = excess_bw = 0.25 self.target_samp_rate = target_samp_rate = sps * (200e3 / (1 + excess_bw)) self.qpsk_const = qpsk_const = digital.constellation_qpsk().base() self.dsp_rate = dsp_rate = 100e6 self.const_choice = const_choice = "qpsk" self.bpsk_const = bpsk_const = digital.constellation_bpsk().base() self.barker_code_two_dim = barker_code_two_dim = [ -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j ] self.barker_code_one_dim = barker_code_one_dim = sqrt(2) * numpy.real([ -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j ]) self.rrc_delay = rrc_delay = int(round(-44 * excess_bw + 33)) self.nfilts = nfilts = 32 self.n_barker_rep = n_barker_rep = 10 self.dec_factor = dec_factor = ceil(dsp_rate / target_samp_rate) self.constellation = constellation = qpsk_const if ( const_choice == "qpsk") else bpsk_const self.barker_code = barker_code = barker_code_two_dim if ( const_choice == "qpsk") else barker_code_one_dim self.preamble_syms = preamble_syms = numpy.matlib.repmat( barker_code, 1, n_barker_rep)[0] self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps * nfilts) self.n_codewords = n_codewords = 1 self.even_dec_factor = even_dec_factor = dec_factor if ( dec_factor % 1 == 1) else (dec_factor + 1) self.const_order = const_order = pow(2, constellation.bits_per_symbol()) self.codeword_len = codeword_len = 18444 self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2" self.samp_rate = samp_rate = dsp_rate / even_dec_factor self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, excess_bw, n_rrc_taps) self.rf_center_freq = rf_center_freq = 1428.4309e6 self.preamble_size = preamble_size = len(preamble_syms) self.pmf_peak_threshold = pmf_peak_threshold = 0.6 self.payload_size = payload_size = codeword_len * n_codewords / int( numpy.log2(const_order)) self.dataword_len = dataword_len = 6144 self.barker_len = barker_len = 13 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len, dataword_len) self.mods_frame_sync_fast_0 = mods.frame_sync_fast( pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1, int(const_order)) self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx') self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff( 1, (numpy.ones(n_barker_rep * barker_len))) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc( 1, (numpy.flipud(numpy.conj(preamble_syms)))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 2 * pi / 50, (rrc_taps), nfilts, nfilts / 2, pi / 8, 1) self.digital_map_bb_0_0_0 = digital.map_bb(([1, -1])) self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc( sps, excess_bw, rrc_delay * int(sps) + 1, fllbw) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( 2 * pi / loopbw, 2**constellation.bits_per_symbol(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( constellation.base()) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb( constellation.bits_per_symbol()) self.blocks_rms_xx_1 = blocks.rms_cf(0.0001) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc( (1.0 / sqrt(2), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc( (1.0 / (preamble_size * sqrt(2)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_1 = blocks.divide_ff(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'), (self.mods_fifo_async_sink_0, 'async_pdu')) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.digital_fll_band_edge_cc_1, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.mods_frame_sync_fast_0, 2)) self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.mods_frame_sync_fast_0, 1)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mods_frame_sync_fast_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.framers_gr_hdlc_deframer_b_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_map_bb_0_0_0, 0), (self.mods_turbo_decoder_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_divide_xx_1, 1)) self.connect((self.mods_frame_sync_fast_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.mods_turbo_decoder_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0))
def __init__(self): gr.top_block.__init__(self, "LRIT Demodulator") Qt.QWidget.__init__(self) self.setWindowTitle("LRIT Demodulator") 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", "demod_tcp_qt") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 293883 self.samp_rate = samp_rate = 10e6 / 10 self.vgagain = vgagain = 15 self.sps = sps = (samp_rate * 1.0) / (symbol_rate * 1.0) self.pll_alpha = pll_alpha = 0.00199 self.mixgain = mixgain = 15 self.lnagain = lnagain = 15 self.clock_alpha = clock_alpha = 3.7e-3 self.center_freq = center_freq = 1691e6 ################################################## # Blocks ################################################## self._vgagain_range = Range(0, 15, 1, 15, 150) self._vgagain_win = RangeWidget(self._vgagain_range, self.set_vgagain, 'VGA Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._vgagain_win, 4, 1, 1, 1) self._pll_alpha_range = Range(0.00100, 0.10000, 0.00001, 0.00199, 150) self._pll_alpha_win = RangeWidget(self._pll_alpha_range, self.set_pll_alpha, 'PLL Alpha', "counter_slider", float) self.top_grid_layout.addWidget(self._pll_alpha_win, 6, 1, 1, 1) self._mixgain_range = Range(0, 15, 1, 15, 150) self._mixgain_win = RangeWidget(self._mixgain_range, self.set_mixgain, 'Mixer Gain', "counter_slider", int) self.top_grid_layout.addWidget(self._mixgain_win, 3, 1, 1, 1) self._lnagain_range = Range(0, 15, 1, 15, 150) self._lnagain_win = RangeWidget(self._lnagain_range, self.set_lnagain, 'LNA Gain', "counter_slider", int) self.top_grid_layout.addWidget(self._lnagain_win, 2, 1, 1, 1) self._clock_alpha_range = Range(1e-3, 10e-3, 1e-5, 3.7e-3, 150) self._clock_alpha_win = RangeWidget(self._clock_alpha_range, self.set_clock_alpha, 'Clock Alpha', "counter_slider", float) self.top_grid_layout.addWidget(self._clock_alpha_win, 5, 1, 1, 1) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symbol_rate, 0.5, 361)) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.05) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(False) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [3, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-50, -40) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 1, 0, 6, 1) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0.3, qtgui.NUM_GRAPH_VERT, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title('SNR') labels = [' ', '', '', '', '', '', '', '', '', ''] units = ['dB', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 10) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 2, 7, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw 'Input Signal', #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.05) self.qtgui_freq_sink_x_0.set_y_axis(-60, -40) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_axis_labels(False) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "dark red", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size 'Output Constellation', #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.05) self.qtgui_const_sink_x_0.set_y_axis(-1, 1) self.qtgui_const_sink_x_0.set_x_axis(-1, 1) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(False) if not False: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "dark green", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 1, 1) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + 'airspy=0') self.osmosdr_source_0.set_sample_rate(samp_rate * 10) self.osmosdr_source_0.set_center_freq(center_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(1, 0) self.osmosdr_source_0.set_iq_balance_mode(1, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(lnagain, 0) self.osmosdr_source_0.set_if_gain(vgagain, 0) self.osmosdr_source_0.set_bb_gain(mixgain, 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( 10, firdes.low_pass(1, samp_rate * 10, samp_rate / 2, 100e3, firdes.WIN_HAMMING, 6.76)) self.high_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.high_pass(1, samp_rate, symbol_rate, 300e3, firdes.WIN_BLACKMAN, 6.76)) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( pll_alpha, 2, False) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc( sps, clock_alpha**2 / 4.0, 0.5, clock_alpha, 0.005) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_char * 1, 64) self.blocks_rms_xx_0_0 = blocks.rms_cf(0.0001) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 64) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, 1, 0) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_agc_xx_0 = analog.agc_cc(100e-4, 0.5, 0.5) self.analog_agc_xx_0.set_max_gain(4000) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.high_pass_filter_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.high_pass_filter_0, 0), (self.blocks_rms_xx_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Osmocom Source") Qt.QWidget.__init__(self) self.setWindowTitle("Osmocom Source") 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", "osmocom_source") 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.zwave_freq = zwave_freq = 908.42e6 self.samp_rate = samp_rate = 3e6 self.antenna_0 = antenna_0 = 2.5 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=12, taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + 'airspy=0') self.osmosdr_source_0.set_time_source('gpsdo', 0) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(zwave_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(0, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(20e4, 0) self.comparison_comparison_py_f_0 = comparison.comparison_py_f(0, 0) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_float * 1, 1250000) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(20, 1, -14) ################################################## # Connections ################################################## self.connect((self.blocks_nlog10_ff_0_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_nlog10_ff_0_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.comparison_comparison_py_f_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_rms_xx_0, 0))
def __init__( self, label="IQ", sampRate=1.0, centerFreq=0.0, fftPlotRange=[-120, 0], fftSizeN=10, rmsGainRange=[0, 11], enableSpectrum=True, enableTimeWaveform=True, enableWaterfall=True, enableRssiDisplay=True, enableRssi=True, fftGainLog=0.0, rssiPollRate=1.0, updatePeriod=0.1, rmsAvgGainExpInit=5, ): gr.hier_block2.__init__( self, "Freq and Time Sink (%s)" % (label, ), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(0, 0, 0), ) self.message_port_register_hier_out("freq") self.message_port_register_hier_in("freq") Qt.QWidget.__init__(self) self.top_layout = Qt.QVBoxLayout() self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.setLayout(self.top_layout) self._lock = threading.RLock() ################################################## # Parameters ################################################## self.centerFreq = centerFreq self.enableRssiDisplay = enableRssiDisplay and enableRssi self.enableRssi = enableRssi self.enableSpectrum = enableSpectrum self.enableTimeWaveform = enableTimeWaveform self.enableWaterfall = enableWaterfall self.fftGainLog = fftGainLog self.fftPlotRange = fftPlotRange self.fftSizeN = fftSizeN self.label = label self.rmsGainRange = rmsGainRange self.rssiPollRate = rssiPollRate self.sampRate = sampRate self.updatePeriod = updatePeriod ################################################## # Variables ################################################## self.rssi = rssi = "n/a" self.rmsAvgGainExp = rmsAvgGainExp = rmsAvgGainExpInit self.fftSize = fftSize = int(2**fftSizeN) self.fftGainLinear = fftGainLinear = 10.0**(float(fftGainLog) / 20) self.N = N = int(sampRate * updatePeriod) ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() if self.enableSpectrum: 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, "%s Spectrum" % (label, )) if self.enableWaterfall: 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, "%s Waterfall" % (label, )) if self.enableTimeWaveform: self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, "%s Time Waveform" % (label, )) self.top_grid_layout.addWidget(self.tabs, 0, 0, 1, 2) if self.enableRssiDisplay: self._rmsAvgGainExp_range = Range(rmsGainRange[0], rmsGainRange[1], 1, rmsAvgGainExp, 200) self._rmsAvgGainExp_win = RangeWidget( self._rmsAvgGainExp_range, self.set_rmsAvgGainExp, "Avg\nGain\n2^-[%s]" % (",".join(str(i) for i in rmsGainRange)), "dial", float) self.top_grid_layout.addWidget(self._rmsAvgGainExp_win, 1, 1, 1, 1) if self.enableWaterfall: self.waterfallSink = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype centerFreq, #fc sampRate, #bw "", #name 1 #number of inputs ) self.waterfallSink.set_update_time(updatePeriod) self.waterfallSink.enable_grid(True) if not True: self.waterfallSink.disable_legend() if complex == type(float()): self.waterfallSink.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [3, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.waterfallSink.set_line_label(i, "Data {0}".format(i)) else: self.waterfallSink.set_line_label(i, labels[i]) self.waterfallSink.set_color_map(i, colors[i]) self.waterfallSink.set_line_alpha(i, alphas[i]) self.waterfallSink.set_intensity_range(fftPlotRange[0] + 20, fftPlotRange[1]) self._waterfallSink_win = sip.wrapinstance( self.waterfallSink.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_1.addWidget(self._waterfallSink_win, 0, 0, 1, 1) if self.enableTimeWaveform: self.timeSink = qtgui.time_sink_c( fftSize, #size sampRate, #samp_rate "", #name 1 #number of inputs ) self.timeSink.set_update_time(updatePeriod) self.timeSink.set_y_axis(-1, 1) self.timeSink.set_y_label("Amplitude", "") self.timeSink.enable_tags(-1, True) self.timeSink.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.timeSink.enable_autoscale(True) self.timeSink.enable_grid(True) self.timeSink.enable_control_panel(False) if not False: self.timeSink.disable_legend() labels = ["I", "Q", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "green", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.timeSink.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.timeSink.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.timeSink.set_line_label(i, labels[i]) self.timeSink.set_line_width(i, widths[i]) self.timeSink.set_line_color(i, colors[i]) self.timeSink.set_line_style(i, styles[i]) self.timeSink.set_line_marker(i, markers[i]) self.timeSink.set_line_alpha(i, alphas[i]) self._timeSink_win = sip.wrapinstance(self.timeSink.pyqwidget(), Qt.QWidget) self.tabs_layout_2.addWidget(self._timeSink_win) if self.enableRssi: self.rmsCalc = blocks.rms_cf(2**-rmsAvgGainExp) self.nLog10 = blocks.nlog10_ff(20, 1, 0) self.keepOneInN = blocks.keep_one_in_n(gr.sizeof_float * 1, N if N > 0 else 1) self.rssiProbe = blocks.probe_signal_f() def _rssi_probe(): while True: val = self.rssiProbe.level() try: self.set_rssi(val) except AttributeError: pass time.sleep(1.0 / (rssiPollRate)) _rssi_thread = threading.Thread(target=_rssi_probe) _rssi_thread.daemon = True _rssi_thread.start() if self.enableRssiDisplay: self.numberSInk = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.numberSInk.set_update_time(updatePeriod) self.numberSInk.set_title("") labels = [ "\n".join((label, "RMS Mag")), "NBDDC", "", "", "", "", "", "", "", "" ] units = ["dBfs", "dBfs", "", "", "", "", "", "", "", ""] colors = [ ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black") ] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.numberSInk.set_min(i, fftPlotRange[0]) self.numberSInk.set_max(i, fftPlotRange[1]) self.numberSInk.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.numberSInk.set_label(i, "Data {0}".format(i)) else: self.numberSInk.set_label(i, labels[i]) self.numberSInk.set_unit(i, units[i]) self.numberSInk.set_factor(i, factor[i]) self.numberSInk.enable_autoscale(False) self._numberSInk_win = sip.wrapinstance( self.numberSInk.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._numberSInk_win, 1, 0, 1, 1) if self.enableSpectrum: self.freqSink = qtgui.freq_sink_c( fftSize, #size firdes.WIN_BLACKMAN_hARRIS, #wintype centerFreq, #fc sampRate, #bw "", #name 1 #number of inputs ) self.freqSink.set_update_time(updatePeriod) self.freqSink.set_y_axis(fftPlotRange[0], fftPlotRange[1]) self.freqSink.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.freqSink.enable_autoscale(False) self.freqSink.enable_grid(True) self.freqSink.set_fft_average(1.0) self.freqSink.enable_control_panel(False) if not False: self.freqSink.disable_legend() if complex == type(float()): self.freqSink.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "dark red", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.freqSink.set_line_label(i, "Data {0}".format(i)) else: self.freqSink.set_line_label(i, labels[i]) self.freqSink.set_line_width(i, widths[i]) self.freqSink.set_line_color(i, colors[i]) self.freqSink.set_line_alpha(i, alphas[i]) self._freqSink_win = sip.wrapinstance(self.freqSink.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._freqSink_win, 0, 0, 1, 2) if self.enableSpectrum or self.enableWaterfall: self.fftGainMultiplier = blocks.multiply_const_vcc( (fftGainLinear, )) _fftsize_probe_thread = threading.Thread(target=self.checkFftScale) _fftsize_probe_thread.daemon = True _fftsize_probe_thread.start() ################################################## # Connections ################################################## if self.enableSpectrum or self.enableWaterfall: self.connect((self, 0), (self.fftGainMultiplier, 0)) if self.enableSpectrum: self.connect((self.fftGainMultiplier, 0), (self.freqSink, 0)) self.msg_connect((self, 'freq'), (self.freqSink, 'freq')) self.msg_connect((self.freqSink, 'freq'), (self, 'freq')) if self.enableWaterfall: self.connect((self.fftGainMultiplier, 0), (self.waterfallSink, 0)) self.msg_connect((self, 'freq'), (self.waterfallSink, 'freq')) if self.enableRssi: self.connect((self, 0), (self.rmsCalc, 0)) self.connect((self.rmsCalc, 0), (self.keepOneInN, 0)) self.connect((self.keepOneInN, 0), (self.nLog10, 0)) self.connect((self.nLog10, 0), (self.rssiProbe, 0)) if self.enableRssiDisplay: self.connect((self.nLog10, 0), (self.numberSInk, 0)) if self.enableTimeWaveform: self.connect((self, 0), (self.timeSink, 0))
def __init__(self): gr.top_block.__init__(self, "FID Sequence") Qt.QWidget.__init__(self) self.setWindowTitle("FID Sequence") 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", "fid_grc_1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.slave_delay = slave_delay = 0 self.samp_rate = samp_rate = 250000 self.readout_delay = readout_delay = 0 self.offset = offset = 0 self.master_delay = master_delay = 0 self.ex_delay = ex_delay = 0 self.TR_clock = TR_clock = 0 self.TR = TR = 1 self.RUN = RUN = 1 self.CF = CF = 21.3e6 #### ADDED FROM GR-MRI ##### f = open('FID_config.txt', 'r') foo = {} for line in f: k, v, bar = [q.strip() for q in line.split(',')] if k == 'serial_ID': self.serial = str("serial = " + v) if k == 'CF': #added by Chris, to read the CF from FID_config.txt file self.CF = float(v) # if k == 'num_proj': # self.num_proj = float(v) # if k == 'angl_inc': # self.angl_inc = float(v) f.close() ############################ ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((self.serial, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:A A:B", 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(CF + offset, 0) self.uhd_usrp_source_0.set_gain(15, 0) self.uhd_usrp_source_0.set_antenna("A:B", 0) self.uhd_usrp_source_0.set_center_freq(CF + offset, 1) self.uhd_usrp_source_0.set_gain(10, 1) self.uhd_usrp_source_0.set_antenna("A:A", 1) self.signal_out = MRI.gated_vector_sink() self.rf_sink = uhd.usrp_sink( ",".join((self.serial, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.rf_sink.set_subdev_spec("A:AB B:A", 0) self.rf_sink.set_samp_rate(samp_rate) self.rf_sink.set_center_freq(CF + offset, 0) self.rf_sink.set_gain(0, 0) self.rf_sink.set_antenna("A:AB", 0) self.rf_sink.set_center_freq(0, 1) self.rf_sink.set_gain(0, 1) self.rf_sink.set_antenna("B:A", 1) self.readwin = MRI.triggered_vector_source_f([0, 0, 0], 1.0, 0.0, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1000, #size samp_rate, #samp_rate "", #name 4 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-.25, .25) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, .01, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = [ "Read Window", "Real Signal", "Imag Signal", "RMS", "", "", "", "", "", "" ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "black", "blue", "red", "green", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [2, 1, 1, 2, 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(4): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.m_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(master_delay)) self.m_delay = blocks.delay(gr.sizeof_gr_complex * 1, int(master_delay)) self.ex_pulse = MRI.triggered_vector_source([0, 0, 0], 1.0, 0.0, 1, 1) self.delay3 = blocks.delay(gr.sizeof_float * 1, readout_delay) self.delay1 = blocks.delay(gr.sizeof_float * 1, ex_delay) self.blocks_threshold_ff_0_2 = blocks.threshold_ff(.000001, .000001, 0) self.blocks_threshold_ff_0_1 = blocks.threshold_ff(.05, .05, 0) self.blocks_rms_xx_1 = blocks.rms_cf(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((RUN, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 100, 1.0, 4000) #define the length of the unblanking pulse for the RF-PA self.blocks_float_to_complex_0_1_0 = blocks.float_to_complex( 1) #--> first parameter times Ta (Ta=1/fa) fa=samplingrate self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_delay_0 = blocks.delay( gr.sizeof_gr_complex * 1, 97 ) #define delay so that RF-Pulse is centered in the unblanking Window self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SQR_WAVE, 1. / TR, 1, 0) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.m_delay_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_threshold_ff_0_1, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_float_to_complex_0_1_0, 0), (self.m_delay, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0_2, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.signal_out, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.delay1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.delay3, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.qtgui_time_sink_x_0, 3)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.signal_out, 0)) self.connect((self.blocks_threshold_ff_0_2, 0), (self.blocks_float_to_complex_0_1_0, 0)) self.connect((self.delay1, 0), (self.ex_pulse, 0)) self.connect((self.delay3, 0), (self.readwin, 0)) self.connect((self.ex_pulse, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.ex_pulse, 0), (self.blocks_delay_0, 0)) self.connect((self.m_delay, 0), (self.rf_sink, 1)) self.connect((self.m_delay_0, 0), (self.rf_sink, 0)) self.connect((self.readwin, 0), (self.blocks_float_to_complex_0_1, 1)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_divide_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) #define the GPIO needed to control gradient stepper motor as output self.rf_sink.set_gpio_attr( "TXA", "DDR", 2, 2, 0 ) #attributes: which daughterboard, directions, value, mask, which motherboard
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sr_rf = sr_rf = 2500000 self.decimate = decimate = 400 self.sr_lo = sr_lo = sr_rf/decimate self.f_rf = f_rf = 434645000 self.f_lo = f_lo = 455.2 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "Tuning") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "IQ Display") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "PSK Output") self.top_layout.addWidget(self.tab) self._f_rf_layout = Qt.QVBoxLayout() self._f_rf_tool_bar = Qt.QToolBar(self) self._f_rf_layout.addWidget(self._f_rf_tool_bar) self._f_rf_tool_bar.addWidget(Qt.QLabel("RF Freq"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._f_rf_counter = qwt_counter_pyslot() self._f_rf_counter.setRange(434644000, 434646000, 1) self._f_rf_counter.setNumButtons(2) self._f_rf_counter.setValue(self.f_rf) self._f_rf_tool_bar.addWidget(self._f_rf_counter) self._f_rf_counter.valueChanged.connect(self.set_f_rf) self._f_rf_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._f_rf_slider.setRange(434644000, 434646000, 1) self._f_rf_slider.setValue(self.f_rf) self._f_rf_slider.setMinimumWidth(200) self._f_rf_slider.valueChanged.connect(self.set_f_rf) self._f_rf_layout.addWidget(self._f_rf_slider) self.tab_layout_0.addLayout(self._f_rf_layout) self._f_lo_layout = Qt.QVBoxLayout() self._f_lo_tool_bar = Qt.QToolBar(self) self._f_lo_layout.addWidget(self._f_lo_tool_bar) self._f_lo_tool_bar.addWidget(Qt.QLabel("LO Freq"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._f_lo_counter = qwt_counter_pyslot() self._f_lo_counter.setRange(0, 2000, .1) self._f_lo_counter.setNumButtons(2) self._f_lo_counter.setValue(self.f_lo) self._f_lo_tool_bar.addWidget(self._f_lo_counter) self._f_lo_counter.valueChanged.connect(self.set_f_lo) self._f_lo_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._f_lo_slider.setRange(0, 2000, .1) self._f_lo_slider.setValue(self.f_lo) self._f_lo_slider.setMinimumWidth(200) self._f_lo_slider.valueChanged.connect(self.set_f_lo) self._f_lo_layout.addWidget(self._f_lo_slider) self.tab_layout_0.addLayout(self._f_lo_layout) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( sr_lo, #size sr_lo, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(.03) self.qtgui_time_sink_x_0.set_y_axis(-.02, .02) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_1 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.set_title("") labels = ["Signal RMS", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_1.set_min(i, -1) self.qtgui_number_sink_1.set_max(i, 1) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance(self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_1_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.03) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-.02, .02) self.qtgui_const_sink_x_1.set_x_axis(-.02, .02) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-.02, .02) self.qtgui_const_sink_x_0.set_x_axis(-.02, .02) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "airspy=0" ) self.osmosdr_source_0.set_sample_rate(sr_rf) self.osmosdr_source_0.set_center_freq(f_rf, 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(3, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(100, (firdes.low_pass(1, sr_rf, 2000, 100)), f_lo, sr_rf) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, cmath.pi/100.0, -0.5, 0.5, 0.25, 0.01, 2, 0.001, 0.001) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((sr_lo / (2 * 3.14159), )) self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(.06, 0.6, -.6) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pll_freqdet_cf_0, 0)) self.connect((self.analog_pll_freqdet_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.qtgui_number_sink_1, 0))
def __init__(self, modScheme, snr): self.rmsValue = rmsValue = 1.0 # RMS value to calculate noise voltage with print "Generating", modScheme, " with ", snr, "SNR" floatSNR = float(snr) self.noiseLevel = noiseLevel = rmsValue / ( 10**(floatSNR / 20.0) ) # Sets noise voltage of channel model based on the SNR parameter gr.top_block.__init__(self, "Ngmodtesting") ################################################## # Variables ################################################## self.randNumLimit = randNumLimit = 256 # 256 to generate 0-255, put as 1 if only want noise self.samp_rate = samp_rate = 300000 # Set sampling rate for throttle blocks, was 90000 before self.modBPSK = modBPSK = digital.constellation_rect( ([-1, 1]), ([0, 1]), 4, 2, 2, 1, 1).base() self.modQPSK = modQPSK = digital.constellation_rect( ([-1 - 1j, -1 + 1j, 1 - 1j, 1 + 1j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() # 00: -1-1j # 01: -1+1j # 10: +1-1j # 11: +1+1j self.mod16QAM = mod16QAM = digital.constellation_rect(([ -1 - 1j, -1 - 2j, -2 - 1j, -2 - 2j, -1 + 1j, -1 + 2j, -2 + 1j, -2 + 2j, 1 - 1j, 1 - 2j, 2 - 1j, 2 - 2j, 1 + 1j, 1 + 2j, 2 + 1j, 2 + 2j ]), ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]), 4, 2, 2, 1, 1).base() symbols32QAM = range(0, 32, 1) self.mod32QAM = mod32QAM = digital.constellation_rect(([ -1 - 1j, 1 - 1j, -1 + 1j, 1 + 1j, -1 - 2j, 1 - 2j, -1 + 2j, 1 + 2j, -1 - 3j, 1 - 3j, -1 + 3j, 1 + 3j, -2 - 1j, 2 - 1j, -2 + 1j, 2 + 1j, -2 - 2j, 2 - 2j, -2 + 2j, 2 + 2j, -2 - 3j, 2 - 3j, -2 + 3j, 2 + 3j, -3 - 1j, 3 - 1j, -3 + 1j, 3 + 1j, -3 - 2j, 3 - 2j, -3 + 2j, 3 + 2j ]), symbols32QAM, 4, 2, 2, 1, 1).base() symbols64QAM = range(0, 64, 1) self.mod64QAM = mod64QAM = digital.constellation_rect(([ -1 - 1j, 1 - 1j, -1 + 1j, 1 + 1j, -1 - 2j, 1 - 2j, -1 + 2j, 1 + 2j, -1 - 3j, 1 - 3j, -1 + 3j, 1 + 3j, -1 - 4j, 1 - 4j, -1 + 4j, 1 + 4j, -2 - 1j, 2 - 1j, -2 + 1j, 2 + 1j, -2 - 2j, 2 - 2j, -2 + 2j, 2 + 2j, -2 - 3j, 2 - 3j, -2 + 3j, 2 + 3j, -2 - 4j, 2 - 4j, -2 + 4j, 2 + 4j, -3 - 1j, 3 - 1j, -3 + 1j, 3 + 1j, -3 - 2j, 3 - 2j, -3 + 2j, 3 + 2j, -3 - 3j, 3 - 3j, -3 + 3j, 3 + 3j, -3 - 4j, 3 - 4j, -3 + 4j, 3 + 4j, -4 - 1j, 4 - 1j, -4 + 1j, 4 + 1j, -4 - 2j, 4 - 2j, -4 + 2j, 4 + 2j, -4 - 3j, 4 - 3j, -4 + 3j, 4 + 3j, -4 - 4j, 4 - 4j, -4 + 4j, 4 + 4j ]), symbols64QAM, 4, 2, 2, 1, 1).base() symbols128QAM = range(0, 128, 1) list = [1, 2, 3, 4, 5, 6] points128QAM = [] counter = 0 for num in list: for num2 in list: if num >= 5 and num2 >= 5: continue else: y = 1 + 1j z = -1 * y.real * num - y.imag * num2 * 1j points128QAM.append(z) z = -1 * y.real * num + y.imag * num2 * 1j points128QAM.append(z) z = y.real * num - y.imag * num2 * 1j points128QAM.append(z) z = y.real * num + y.imag * num2 * 1j points128QAM.append(z) self.mod128QAM = mod128QAM = digital.constellation_rect( points128QAM, symbols128QAM, 4, 2, 2, 1, 1).base() symbols256QAM = range(0, 256, 1) list = range(1, 9, 1) # 0..8 points256QAM = [] counter = 0 for num in list: for num2 in list: y = 1 + 1j z = -1 * y.real * num - y.imag * num2 * 1j points256QAM.insert(counter, z) counter += 1 z = -1 * y.real * num + y.imag * num2 * 1j points256QAM.insert(counter, z) counter += 1 z = y.real * num - y.imag * num2 * 1j points256QAM.insert(counter, z) counter += 1 z = y.real * num + y.imag * num2 * 1j points256QAM.insert(counter, z) counter += 1 self.mod256QAM = mod256QAM = digital.constellation_rect( points256QAM, symbols256QAM, 4, 2, 2, 1, 1).base() self.modNoise = modNoise = digital.constellation_rect( ([0, -1 + 1j, 1 - 1j, 1 + 1j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.sink = None self.constObj = constObj = None if modScheme == "FM": self.sink = self.fmGen(noiseLevel) return elif modScheme == "AM-SSB": self.sink = self.amGen("SSB", noiseLevel) return elif modScheme == "AM-DSBSC": self.sink = self.amGen("DSBSC", noiseLevel) return elif modScheme == "AM-DSBFC": self.sink = self.amGen("DSBFC", noiseLevel) return elif modScheme == "16QAM": self.constObj = constObj = mod16QAM elif modScheme == "32QAM": self.constObj = constObj = mod32QAM elif modScheme == "64QAM": self.constObj = constObj = mod64QAM elif modScheme == "128QAM": self.constObj = constObj = mod128QAM elif modScheme == "256QAM": self.constObj = constObj = mod256QAM elif modScheme == "QPSK": self.constObj = constObj = modQPSK elif modScheme == "BPSK": self.constObj = constObj = modBPSK elif modScheme.upper() == "NOISE": self.constObj = constObj = modNoise randNumLimit = 1 else: print( "Error: Hardcoded schemes does not match accepted schemes. Offending input: {}'" .format(modScheme)) sys.exit(-1) self.channel = channels.channel_model( noise_voltage= noiseLevel, # AWGN noise level as a voltage (edit depending on SNR) frequency_offset=0.0, # No frequency offset epsilon= 1.0, # 1.0 to keep no difference between sampling rates of clocks of transmitter and receiver noise_seed=0, # Normal random number generator for noise block_tags=False # Only needed for multipath ) ################################################## # Blocks ################################################## self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constObj, differential= True, # True for PSK/QAM, allows modulation based on successive symbols samples_per_symbol= 2, # For every symbol, adds (samples_per_symbol)-1 zeroes after the original symbol pre_diff_code=False, excess_bw=0.35, verbose=False, log=False, ) self.sink = blocks.vector_sink_c(1) self.blocks_vector_sink_x_5 = blocks.vector_sink_f(1) self.blocks_vector_sink_x_4 = blocks.vector_sink_c(1) self.blocks_vector_sink_x_1 = blocks.vector_sink_b(1) self.blocks_vector_sink_x_0 = blocks.vector_sink_c(1) self.blocks_throttle_1 = blocks.throttle(gr.sizeof_char * 1, samp_rate) #, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate) #, True) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_char * 1, 1) self.numSamples = numSamples = 10000000 # Number of samples for random number generator self.isRepeat = isRepeat = True # Repeat random number generator? self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, randNumLimit, numSamples)), isRepeat) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) ################################################## # Connections ################################################## self.sink2 = self.blocks_vector_sink_x_1 self.sink5 = self.blocks_vector_sink_x_4 self.rmssink = self.blocks_vector_sink_x_5 # Byte Stream: self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.blocks_throttle_1, 0), (self.sink2, 0)) # Constellation Block Raw Output: self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.sink5, 0)) # Modulated Signal + Noise Path: self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channel, 0)) self.connect((self.channel, 0), (self.sink, 0)) # Get RMS self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.rmssink, 0)) def closeEvent(self, event): self.settings = Qt.QSettings("GNU Radio", "ngModTesting") self.settings.setValue("geometry", self.saveGeometry()) event.accept()
def __init__(self): gr.top_block.__init__(self, "Bpsk Receiverlms") Qt.QWidget.__init__(self) self.setWindowTitle("Bpsk Receiverlms") 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", "BPSK_ReceiverLMS") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 8 self.probe_var_n = probe_var_n = 0 self.probe_var = probe_var = 0 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.SNR = SNR = 500 self.transistion = transistion = 100 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.sideband_rx = sideband_rx = 500 self.sideband = sideband = 500 self.samp_rate = samp_rate = 48000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts/16, nfilts/16, 1.0/float(sps), 0.35, 11*sps*nfilts/16) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase_bw = phase_bw = 6.28/100.0 self.noise_amp = noise_amp = probe_var/(10**(SNR/20)) self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.interpolation = interpolation = 2000 self.eq_gain = eq_gain = 0.01 self.delay = delay = 0 self.decimation = decimation = 1 self.constel = constel = digital.constellation_calcdist(([1,- 1]), ([0,1]), 2, 1).base() self.carrier = carrier = 10000 self.arity = arity = 2 self.Signal_rms = Signal_rms = probe_var self.Signal_Noise_amp = Signal_Noise_amp = probe_var_n ################################################## # Blocks ################################################## self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28/100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, "Time: BW", "counter_slider", float) self.top_grid_layout.addWidget(self._timing_loop_bw_win, 0,0) self.probe_rms = blocks.probe_signal_f() self.probe_avg_n = blocks.probe_signal_f() self._phase_bw_range = Range(0.0, 1.0, 0.001, 6.28/100.0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, "Phase: Bandwidth", "counter_slider", float) self.top_grid_layout.addWidget(self._phase_bw_win, 0,4) self._eq_gain_range = Range(0.0, 0.5, 0.001, 0.01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, "Equalizer: rate", "slider", float) self.top_grid_layout.addWidget(self._eq_gain_win, 1,3) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=decimation, decimation=interpolation, taps=(rrc_taps), fractional_bw=None, ) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) def _probe_var_n_probe(): while True: val = self.probe_avg_n.level() try: self.set_probe_var_n(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_var_n_thread = threading.Thread(target=_probe_var_n_probe) _probe_var_n_thread.daemon = True _probe_var_n_thread.start() def _probe_var_probe(): while True: val = self.probe_rms.level() try: self.set_probe_var(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_var_thread = threading.Thread(target=_probe_var_probe) _probe_var_thread.daemon = True _probe_var_thread.start() self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, (filter.firdes.low_pass(1, samp_rate*10, sideband_rx,1000)), carrier, samp_rate) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 1) self.digital_lms_dd_equalizer_cc_1 = digital.lms_dd_equalizer_cc(8, eq_gain, 1, constel) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity, False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constel) self.blocks_wavfile_source_0 = blocks.wavfile_source("/Users/ahmadtrabousli/Desktop/GnuRadioModems/Impulse Responses/5km_20pc/BPSK_Output/goff_random_20pc_5km_E_no3.wav", False) self.blocks_throttle_1_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_rms_xx_1 = blocks.rms_cf(0.01) self.blocks_rms_xx_0 = blocks.rms_cf(0.01) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0_1 = blocks.file_sink(gr.sizeof_char*1, "/Users/ahmadtrabousli/Desktop/GnuRadioModems/PSK/outputText", False) self.blocks_file_sink_0_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/Users/ahmadtrabousli/Desktop/GnuRadioModems/PSK/outputBinary", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_1 = blocks.delay(gr.sizeof_char*1, int(delay)) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, noise_amp, 0) self._Signal_rms_tool_bar = Qt.QToolBar(self) if None: self._Signal_rms_formatter = None else: self._Signal_rms_formatter = lambda x: x self._Signal_rms_tool_bar.addWidget(Qt.QLabel("Signal_rms"+": ")) self._Signal_rms_label = Qt.QLabel(str(self._Signal_rms_formatter(self.Signal_rms))) self._Signal_rms_tool_bar.addWidget(self._Signal_rms_label) self.top_layout.addWidget(self._Signal_rms_tool_bar) self._Signal_Noise_amp_tool_bar = Qt.QToolBar(self) if None: self._Signal_Noise_amp_formatter = None else: self._Signal_Noise_amp_formatter = lambda x: x self._Signal_Noise_amp_tool_bar.addWidget(Qt.QLabel("Signal_Noise_amp"+": ")) self._Signal_Noise_amp_label = Qt.QLabel(str(self._Signal_Noise_amp_formatter(self.Signal_Noise_amp))) self._Signal_Noise_amp_tool_bar.addWidget(self._Signal_Noise_amp_label) self.top_layout.addWidget(self._Signal_Noise_amp_tool_bar) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_file_sink_0_1, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.probe_rms, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.probe_avg_n, 0)) self.connect((self.blocks_throttle_1_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_throttle_1_0_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_delay_1, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_1, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_1, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_throttle_1_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "HF channel simulation") ################################################## # Variables ################################################## self.snr = snr = 40 self.vol = vol = [1, 1] self.tau_a = tau_a = 1 / 100. self.tau = tau = 0.1 self.snrVecOut = snrVecOut = ([0] * 3) self.samp_rate = samp_rate = 48000 self.outSigRMSVec = outSigRMSVec = ([0] * 2) self.noSpread = noSpread = 0 self.kN = kN = pow(10.0, (-snr / 20.0)) self.freqShift = freqShift = 0.0 self.fd = fd = 1 self.en_noise = en_noise = [0, 0] self.doppler_ir = doppler_ir = [ 0.0016502763167573274, 0.0018854799389366934, 0.002149957633383614, 0.0024466994528029662, 0.002778907461425479, 0.003149998028185868, 0.003563602180973301, 0.00402356375450247, 0.004533935060796761, 0.0050989698117900155, 0.005723113028669535, 0.006410987682800636, 0.007167377828853199, 0.007997208012493867, 0.008905518763040982, 0.00989743801603955, 0.010978148351927763, 0.012152849984840378, 0.013426719489994542, 0.014804864318746317, 0.016292273216847054, 0.01789376273305468, 0.019613920081278834, 0.021457042698902442, 0.023427074925696508, 0.025527542310538734, 0.027761484135525694, 0.030131384827462734, 0.03263910500345486, 0.035285812968654906, 0.03807191754835305, 0.04099700319171279, 0.04405976832879332, 0.04725796799434838, 0.050588361749672524, 0.05404666793605477, 0.057627525278984175, 0.06132446283016882, 0.06512987918400244, 0.0690350318359975, 0.073030037462906, 0.07710388379815894, 0.08124445365265866, 0.08543856149104095, 0.08967200281887802, 0.0939296164688993, 0.09819535969651079, 0.10245239580938088, 0.10668319386560887, 0.1108696397832219, 0.11499315801386097, 0.11903484274903825, 0.12297559745183839, 0.12679628134392928, 0.1304778613306593, 0.13400156771907581, 0.1373490519778611, 0.14050254470705797, 0.14344501193124823, 0.14616030780428022, 0.14863332181791858, 0.15085011864154488, 0.1527980687853246, 0.154465968374505, 0.15584414644656272, 0.15692455833401583, 0.15770086387153975, 0.1581684893637365, 0.15832467246620405, 0.1581684893637365, 0.15770086387153975, 0.15692455833401583, 0.15584414644656272, 0.154465968374505, 0.1527980687853246, 0.15085011864154488, 0.14863332181791858, 0.14616030780428022, 0.14344501193124823, 0.14050254470705797, 0.1373490519778611, 0.13400156771907581, 0.1304778613306593, 0.12679628134392928, 0.12297559745183839, 0.11903484274903825, 0.11499315801386097, 0.1108696397832219, 0.10668319386560887, 0.10245239580938088, 0.09819535969651079, 0.0939296164688993, 0.08967200281887802, 0.08543856149104095, 0.08124445365265866, 0.07710388379815894, 0.073030037462906, 0.0690350318359975, 0.06512987918400244, 0.06132446283016882, 0.057627525278984175, 0.05404666793605477, 0.050588361749672524, 0.04725796799434838, 0.04405976832879332, 0.04099700319171279, 0.03807191754835305, 0.035285812968654906, 0.03263910500345486, 0.030131384827462734, 0.027761484135525694, 0.025527542310538734, 0.023427074925696508, 0.021457042698902442, 0.019613920081278834, 0.01789376273305468, 0.016292273216847054, 0.014804864318746317, 0.013426719489994542, 0.012152849984840378, 0.010978148351927763, 0.00989743801603955, 0.008905518763040982, 0.007997208012493867, 0.007167377828853199, 0.006410987682800636, 0.005723113028669535, 0.0050989698117900155, 0.004533935060796761, 0.00402356375450247, 0.003563602180973301, 0.003149998028185868, 0.002778907461425479, 0.0024466994528029662, 0.002149957633383614, 0.0018854799389366934, 0.0016502763167573274 ] self.ampl = ampl = [[1.0, 1.0], [1.0, 1.0]] ################################################## # Blocks ################################################## self.snrOut = blocks.probe_signal_vf(4) self.outSigRMS = blocks.probe_signal_vf(2) def _snrVecOut_probe(): while True: val = self.snrOut.level() try: self.set_snrVecOut(val) except AttributeError: pass time.sleep(1.0 / (10)) _snrVecOut_thread = threading.Thread(target=_snrVecOut_probe) _snrVecOut_thread.daemon = True _snrVecOut_thread.start() self.single_pole_iir_filter_xx_0_1 = filter.single_pole_iir_filter_ff( 2 * pi * tau_a / samp_rate, 1) self.single_pole_iir_filter_xx_0_0_0 = filter.single_pole_iir_filter_ff( 2 * pi * tau_a / samp_rate, 1) self.single_pole_iir_filter_xx_0_0 = filter.single_pole_iir_filter_ff( 2 * pi * tau_a / samp_rate, 1) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff( 2 * pi * tau_a / samp_rate, 1) def _outSigRMSVec_probe(): while True: val = self.outSigRMS.level() try: self.set_outSigRMSVec(val) except AttributeError: pass time.sleep(1.0 / (10)) _outSigRMSVec_thread = threading.Thread(target=_outSigRMSVec_probe) _outSigRMSVec_thread.daemon = True _outSigRMSVec_thread.start() self.low_pass_filter_2_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1550, 100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1550, 100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1_1 = filter.interp_fir_filter_ccf( int(samp_rate / 100), firdes.low_pass(ampl[1][0] * (samp_rate / 100.0), samp_rate, 50, 25, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1_0_0 = filter.interp_fir_filter_ccf( int(samp_rate / 100), firdes.low_pass(ampl[1][1] * (samp_rate / 100.0), samp_rate, 50, 25, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1_0 = filter.interp_fir_filter_ccf( int(samp_rate / 100), firdes.low_pass(ampl[0][1] * (samp_rate / 100.0), samp_rate, 50, 25, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_ccf( int(samp_rate / 100), firdes.low_pass(ampl[0][0] * (samp_rate / 100.0), samp_rate, 50, 25, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1750 + 100, 600, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1750 + 100, 600, firdes.WIN_HAMMING, 6.76)) self.epy_block_0_0_0_0 = epy_block_0_0_0_0.blk(fd=fd) self.epy_block_0_0_0 = epy_block_0_0_0.blk(fd=fd) self.epy_block_0_0 = epy_block_0_0.blk(fd=fd) self.epy_block_0 = epy_block_0.blk(fd=fd) self.blocks_streams_to_vector_0_0 = blocks.streams_to_vector( gr.sizeof_float * 1, 2) self.blocks_streams_to_vector_0 = blocks.streams_to_vector( gr.sizeof_float * 1, 4) self.blocks_selector_0_1 = blocks.selector(gr.sizeof_gr_complex * 1, noSpread, 0) self.blocks_selector_0_1.set_enabled(True) self.blocks_selector_0_0_0 = blocks.selector(gr.sizeof_gr_complex * 1, noSpread, 0) self.blocks_selector_0_0_0.set_enabled(True) self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex * 1, noSpread, 0) self.blocks_selector_0_0.set_enabled(True) self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex * 1, noSpread, 0) self.blocks_selector_0.set_enabled(True) self.blocks_rms_xx_0_1 = blocks.rms_cf(2 * pi * tau_a * 100 / samp_rate) self.blocks_rms_xx_0_0_0 = blocks.rms_ff(2 * pi * tau_a * 10 / samp_rate) self.blocks_rms_xx_0_0 = blocks.rms_ff(2 * pi * tau_a * 10 / samp_rate) self.blocks_rms_xx_0 = blocks.rms_cf(2 * pi * tau_a * 100 / samp_rate) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_1_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_3_0 = blocks.multiply_const_ff( en_noise[1]) self.blocks_multiply_const_vxx_3 = blocks.multiply_const_ff( en_noise[0]) self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_cc(vol[1]) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_cc(vol[0]) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_ff( 2 * sqrt(ampl[1][0]**2 + ampl[1][1]**2) * 2) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_ff( 2 * sqrt(ampl[0][0]**2 + ampl[0][1]**2) * 2) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(0.5) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(0.5) self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_1_0 = blocks.divide_ff(1) self.blocks_divide_xx_1 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(tau * samp_rate)) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(tau * samp_rate)) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_squared_2_1 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_2_0_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_2_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_2 = blocks.complex_to_mag_squared(1) self.blocks_add_xx_1_0 = blocks.add_vff(1) self.blocks_add_xx_1 = blocks.add_vff(1) self.blocks_add_xx_0_1 = blocks.add_vcc(1) self.blocks_add_xx_0_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.audio_source_0 = audio.source(samp_rate, 'hw:CARD=Rubix44,DEV=0', False) self.audio_sink_0 = audio.sink(samp_rate, 'hw:CARD=Rubix44,DEV=0', False) self.analog_sig_source_x_3 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 1000, 0.3, 0, 0) self.analog_sig_source_x_2_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0) self.analog_sig_source_x_2 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0) self.analog_sig_source_x_1_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freqShift, 1, 0, 0) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freqShift, 1, 0, 0) self.analog_sig_source_x_0_0_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1850, 1, 0, 0) self.analog_sig_source_x_0_0_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0) self.analog_sig_source_x_0_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1850, 1, 0, 0) self.analog_noise_source_x_1_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1e-0 * kN, 13) self.analog_noise_source_x_1 = analog.noise_source_c( analog.GR_GAUSSIAN, 1e-0 * kN, 3) self.analog_noise_source_x_0_1 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, 10) self.analog_noise_source_x_0_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, 11) self.analog_noise_source_x_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, 1) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, 0) self.analog_const_source_x_2_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_const_source_x_2 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_const_source_x_1_1 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, ampl[1][0]) self.analog_const_source_x_1_0_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, ampl[1][1]) self.analog_const_source_x_1_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, ampl[0][1]) self.analog_const_source_x_1 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, ampl[0][0]) self.analog_const_source_x_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_const_source_x_0_0, 0), (self.blocks_float_to_complex_0_0, 1)) self.connect((self.analog_const_source_x_1, 0), (self.blocks_selector_0, 1)) self.connect((self.analog_const_source_x_1_0, 0), (self.blocks_selector_0_0, 1)) self.connect((self.analog_const_source_x_1_0_0, 0), (self.blocks_selector_0_0_0, 1)) self.connect((self.analog_const_source_x_1_1, 0), (self.blocks_selector_0_1, 1)) self.connect((self.analog_const_source_x_2, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.analog_const_source_x_2_0, 0), (self.blocks_float_to_complex_1_0, 1)) self.connect((self.analog_noise_source_x_0, 0), (self.epy_block_0, 0)) self.connect((self.analog_noise_source_x_0_0, 0), (self.epy_block_0_0, 0)) self.connect((self.analog_noise_source_x_0_0_0, 0), (self.epy_block_0_0_0_0, 0)) self.connect((self.analog_noise_source_x_0_1, 0), (self.epy_block_0_0_0, 0)) self.connect((self.analog_noise_source_x_1, 0), (self.low_pass_filter_2, 0)) self.connect((self.analog_noise_source_x_1_0, 0), (self.low_pass_filter_2_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_0_0, 1)) self.connect((self.analog_sig_source_x_0_0_0_0, 0), (self.blocks_multiply_xx_0_0_1, 1)) self.connect((self.analog_sig_source_x_0_0_1, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.analog_sig_source_x_1_0, 0), (self.blocks_multiply_xx_1_0, 0)) self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_0_0_0_0_0, 1)) self.connect((self.analog_sig_source_x_2_0, 0), (self.blocks_multiply_xx_0_0_0_0_0_0, 1)) self.connect((self.analog_sig_source_x_3, 0), (self.blocks_multiply_const_vxx_3, 0)) self.connect((self.analog_sig_source_x_3, 0), (self.blocks_multiply_const_vxx_3_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.audio_source_0, 1), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.audio_source_0, 2), (self.blocks_null_sink_0, 0)) self.connect((self.audio_source_0, 3), (self.blocks_null_sink_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_add_xx_0_0_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.blocks_add_xx_0_1, 0), (self.blocks_multiply_xx_1_0, 1)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_xx_1_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_2, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_2_0, 0), (self.single_pole_iir_filter_xx_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_2_0_0, 0), (self.single_pole_iir_filter_xx_0_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_2_1, 0), (self.single_pole_iir_filter_xx_0_1, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_add_xx_1_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0_0_0_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_multiply_xx_0_0_0_0_1, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_divide_xx_1_0, 0), (self.blocks_nlog10_ff_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_xx_0_0_0_0_0, 2)) self.connect((self.blocks_float_to_complex_1_0, 0), (self.blocks_multiply_xx_0_0_0_0_0_0, 2)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_rms_xx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_rms_xx_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_float_to_complex_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_multiply_const_vxx_3_0, 0), (self.blocks_add_xx_1_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0), (self.blocks_complex_to_mag_squared_2_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0_0_0_0, 0), (self.blocks_add_xx_0_0_0, 1)) self.connect((self.blocks_multiply_xx_0_0_0_0_0_0, 0), (self.blocks_complex_to_mag_squared_2_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0_0_1, 0), (self.blocks_add_xx_0_1, 1)) self.connect((self.blocks_multiply_xx_0_0_0_1, 0), (self.blocks_add_xx_0_1, 0)) self.connect((self.blocks_multiply_xx_0_0_1, 0), (self.blocks_delay_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0_1, 0), (self.blocks_multiply_xx_0_0_0_1, 0)) self.connect((self.blocks_multiply_xx_0_0_1, 0), (self.blocks_rms_xx_0_1, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_complex_to_mag_squared_2, 0)) self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_add_xx_0_0_0, 0)) self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_complex_to_mag_squared_2_1, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_streams_to_vector_0, 2)) self.connect((self.blocks_nlog10_ff_0_0, 0), (self.blocks_streams_to_vector_0, 3)) self.connect((self.blocks_null_source_0, 0), (self.audio_sink_0, 2)) self.connect((self.blocks_null_source_0, 1), (self.audio_sink_0, 3)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_streams_to_vector_0_0, 0)) self.connect((self.blocks_rms_xx_0_0_0, 0), (self.blocks_streams_to_vector_0_0, 1)) self.connect((self.blocks_rms_xx_0_1, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_selector_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.blocks_selector_0_0, 0), (self.blocks_multiply_xx_0_0_0_0, 1)) self.connect((self.blocks_selector_0_0_0, 0), (self.blocks_multiply_xx_0_0_0_0_1, 1)) self.connect((self.blocks_selector_0_1, 0), (self.blocks_multiply_xx_0_0_0_1, 1)) self.connect((self.blocks_streams_to_vector_0, 0), (self.snrOut, 0)) self.connect((self.blocks_streams_to_vector_0_0, 0), (self.outSigRMS, 0)) self.connect((self.epy_block_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.epy_block_0_0, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.epy_block_0_0_0, 0), (self.low_pass_filter_1_1, 0)) self.connect((self.epy_block_0_0_0_0, 0), (self.low_pass_filter_1_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_xx_0_0_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_selector_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.blocks_selector_0_0, 0)) self.connect((self.low_pass_filter_1_0_0, 0), (self.blocks_selector_0_0_0, 0)) self.connect((self.low_pass_filter_1_1, 0), (self.blocks_selector_0_1, 0)) self.connect((self.low_pass_filter_2, 0), (self.blocks_multiply_xx_0_0_0_0_0, 0)) self.connect((self.low_pass_filter_2_0, 0), (self.blocks_multiply_xx_0_0_0_0_0_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_streams_to_vector_0, 0)) self.connect((self.single_pole_iir_filter_xx_0_0, 0), (self.blocks_divide_xx_1, 1)) self.connect((self.single_pole_iir_filter_xx_0_0, 0), (self.blocks_streams_to_vector_0, 1)) self.connect((self.single_pole_iir_filter_xx_0_0_0, 0), (self.blocks_divide_xx_1_0, 1)) self.connect((self.single_pole_iir_filter_xx_0_1, 0), (self.blocks_divide_xx_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "Dronedb") Qt.QWidget.__init__(self) self.setWindowTitle("Dronedb") 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", "DroneDB") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2e6 self.head = head = int(2e6) self.cent_freq = cent_freq = 2.462e9 self.band = band = 2e6 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(cent_freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_source_0.set_center_freq(cent_freq, 1) self.uhd_usrp_source_0.set_gain(0, 1) self.uhd_usrp_source_0.set_antenna("RX2", 1) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=1, decimation=8, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=1, decimation=8, taps=None, fractional_bw=None, ) self.qtgui_number_sink_0_0_1_0 = qtgui.number_sink( gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0_0_1_0.set_update_time(0.10) self.qtgui_number_sink_0_0_1_0.set_title("rightGFSK") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_1_0.set_min(i, -1) self.qtgui_number_sink_0_0_1_0.set_max(i, 1) self.qtgui_number_sink_0_0_1_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_1_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_1_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_1_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_1_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_1_0.enable_autoscale(False) self._qtgui_number_sink_0_0_1_0_win = sip.wrapinstance(self.qtgui_number_sink_0_0_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_0_1_0_win) self.qtgui_number_sink_0_0_1 = qtgui.number_sink( gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0_0_1.set_update_time(0.10) self.qtgui_number_sink_0_0_1.set_title("leftGFSK") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_1.set_min(i, -1) self.qtgui_number_sink_0_0_1.set_max(i, 1) self.qtgui_number_sink_0_0_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_1.set_label(i, labels[i]) self.qtgui_number_sink_0_0_1.set_unit(i, units[i]) self.qtgui_number_sink_0_0_1.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_1.enable_autoscale(False) self._qtgui_number_sink_0_0_1_win = sip.wrapinstance(self.qtgui_number_sink_0_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_0_1_win) self.qtgui_number_sink_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0.set_title("rightFRMS") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0.set_min(i, -1) self.qtgui_number_sink_0_0_0.set_max(i, 1) self.qtgui_number_sink_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_win = sip.wrapinstance(self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_0_0_win) self.qtgui_number_sink_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("leftFRMS") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0.set_min(i, -1) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance(self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_0_win) self.fft_vxx_0_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 1) self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 1) self.digital_gfsk_demod_0_0 = digital.gfsk_demod( samples_per_symbol=2, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=2, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 1024) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 1024) self.blocks_stream_to_vector_0_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024) self.blocks_skiphead_0_1_0 = blocks.skiphead(gr.sizeof_char*1, head/2) self.blocks_skiphead_0_1 = blocks.skiphead(gr.sizeof_char*1, head/2) self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_float*1, head) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_float*1, head) self.blocks_rms_xx_0_0 = blocks.rms_cf(0.0001) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((100, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((100, )) self.blocks_file_sink_0_0_1_0 = blocks.file_sink(gr.sizeof_char*1, "/home/summit/DroneIndicator/rightGFSK.dat", False) self.blocks_file_sink_0_0_1_0.set_unbuffered(False) self.blocks_file_sink_0_0_1 = blocks.file_sink(gr.sizeof_char*1, "/home/summit/DroneIndicator/leftGFSK.dat", False) self.blocks_file_sink_0_0_1.set_unbuffered(False) self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_float*1, "/home/summit/DroneIndicator/rightFRMS.dat", False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float*1, "/home/summit/DroneIndicator/leftFRMS.dat", False) self.blocks_file_sink_0_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_skiphead_0_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_skiphead_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_skiphead_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_skiphead_0_1, 0), (self.blocks_file_sink_0_0_1, 0)) self.connect((self.blocks_skiphead_0_1, 0), (self.qtgui_number_sink_0_0_1, 0)) self.connect((self.blocks_skiphead_0_1_0, 0), (self.blocks_file_sink_0_0_1_0, 0)) self.connect((self.blocks_skiphead_0_1_0, 0), (self.qtgui_number_sink_0_0_1_0, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_0_0_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_rms_xx_0_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.blocks_skiphead_0_1, 0)) self.connect((self.digital_gfsk_demod_0_0, 0), (self.blocks_skiphead_0_1_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_number_sink_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_stream_to_vector_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_gfsk_demod_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.digital_gfsk_demod_0_0, 0))
def __init__(self, cutoffFreq=2**-6, freqUpdateRate=1.0, fs=1.0, isReal=False, notchFreq=0.0, rmsAvgExp=5, transBw=2.0**-8, useFreqEstimate=False): gr.hier_block2.__init__( self, "Sinad Calc Block", gr.io_signaturev(2, 2, [gr.sizeof_gr_complex * 1, gr.sizeof_float * 1]), gr.io_signaturev(5, 5, [ gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_gr_complex * 1 ]), ) ################################################## # Parameters ################################################## self.cutoffFreq = cutoffFreq self.freqUpdateRate = freqUpdateRate self.fs = fs self.isReal = isReal self.notchFreq = notchFreq self.rmsAvgExp = rmsAvgExp self.transBw = transBw self.useFreqEstimate = useFreqEstimate ################################################## # Variables ################################################## self.freqEstQuery = freqEstQuery = 0.0 self.estimatedFrequency = estimatedFrequency = round(fs * freqEstQuery) self.rotationFreq = rotationFreq = estimatedFrequency if useFreqEstimate else notchFreq self.useReal = useReal = bool(isReal) self.sinadLevel = sinadLevel = 0.0 self.signalLevel = signalLevel = 0.0 self.rotation = rotation = -2 * pi * rotationFreq / fs self.rmsAvgGain = rmsAvgGain = 2.0**-rmsAvgExp self.noiseLevel = noiseLevel = 0.0 ################################################## # Blocks ################################################## self.sinadProbe = blocks.probe_signal_f() self.signalProbe = blocks.probe_signal_f() self.noiseProbe = blocks.probe_signal_f() self.freqEstProbe = blocks.probe_signal_f() self.sinadLog10 = blocks.nlog10_ff(20, 1, 0) def _sinadLevel_probe(): while True: val = self.sinadProbe.level() try: self.set_sinadLevel(val) except AttributeError: pass time.sleep(1.0 / (freqUpdateRate)) _sinadLevel_thread = threading.Thread(target=_sinadLevel_probe) _sinadLevel_thread.daemon = True _sinadLevel_thread.start() self.sinadDivider = blocks.divide_ff(1) self.signalLevelRms = blocks.rms_cf(rmsAvgGain) self.signalLevelLog10 = blocks.nlog10_ff(20, 1, 0) def _signalLevel_probe(): while True: val = self.signalProbe.level() try: self.set_signalLevel(val) except AttributeError: pass time.sleep(1.0 / (freqUpdateRate)) _signalLevel_thread = threading.Thread(target=_signalLevel_probe) _signalLevel_thread.daemon = True _signalLevel_thread.start() self.rotatorBlock = blocks.rotator_cc(rotation) self.realOrIqSelector = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=1 if useReal else 0, output_index=0, ) self.realHilbertFilter = filter.hilbert_fc(1025, firdes.WIN_KAISER, 6.76) self.noiseRms = blocks.rms_cf(rmsAvgGain) self.noiseLog10 = blocks.nlog10_ff(20, 1, 0) def _noiseLevel_probe(): while True: val = self.noiseProbe.level() try: self.set_noiseLevel(val) except AttributeError: pass time.sleep(1.0 / (freqUpdateRate)) _noiseLevel_thread = threading.Thread(target=_noiseLevel_probe) _noiseLevel_thread.daemon = True _noiseLevel_thread.start() self.highPassFilter = filter.fir_filter_ccf( 1, firdes.high_pass(1, 1.0, cutoffFreq, transBw, firdes.WIN_KAISER, 6.76)) self.freqEstScale = blocks.multiply_const_vff((fs, )) def _freqEstQuery_probe(): while True: val = self.freqEstProbe.level() try: self.set_freqEstQuery(val) except AttributeError: pass time.sleep(1.0 / (freqUpdateRate)) _freqEstQuery_thread = threading.Thread(target=_freqEstQuery_probe) _freqEstQuery_thread.daemon = True _freqEstQuery_thread.start() self.freqEstNullSink = blocks.null_sink(gr.sizeof_float * 1) self.freqEstFilter = filter.single_pole_iir_filter_ff(2**-10, 1) self.freqEstDemod = analog.quadrature_demod_cf(1.0 / (2 * pi)) self.derotatorBlock = blocks.rotator_cc(-1.0 * rotation) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) ################################################## # Connections ################################################## self.connect((self.derotatorBlock, 0), (self.blocks_null_sink_0, 0)) self.connect((self.derotatorBlock, 0), (self, 4)) self.connect((self.freqEstDemod, 0), (self.freqEstFilter, 0)) self.connect((self.freqEstFilter, 0), (self.freqEstProbe, 0)) self.connect((self.freqEstFilter, 0), (self.freqEstScale, 0)) self.connect((self.freqEstScale, 0), (self.freqEstNullSink, 0)) self.connect((self.freqEstScale, 0), (self, 3)) self.connect((self.highPassFilter, 0), (self.derotatorBlock, 0)) self.connect((self.highPassFilter, 0), (self.noiseRms, 0)) self.connect((self, 0), (self.realOrIqSelector, 0)) self.connect((self.noiseLog10, 0), (self.noiseProbe, 0)) self.connect((self.noiseLog10, 0), (self, 2)) self.connect((self.noiseRms, 0), (self.noiseLog10, 0)) self.connect((self.noiseRms, 0), (self.sinadDivider, 1)) self.connect((self.realHilbertFilter, 0), (self.realOrIqSelector, 1)) self.connect((self, 1), (self.realHilbertFilter, 0)) self.connect((self.realOrIqSelector, 0), (self.freqEstDemod, 0)) self.connect((self.realOrIqSelector, 0), (self.rotatorBlock, 0)) self.connect((self.realOrIqSelector, 0), (self.signalLevelRms, 0)) self.connect((self.rotatorBlock, 0), (self.highPassFilter, 0)) self.connect((self.signalLevelLog10, 0), (self, 1)) self.connect((self.signalLevelLog10, 0), (self.signalProbe, 0)) self.connect((self.signalLevelRms, 0), (self.signalLevelLog10, 0)) self.connect((self.signalLevelRms, 0), (self.sinadDivider, 0)) self.connect((self.sinadDivider, 0), (self.sinadLog10, 0)) self.connect((self.sinadLog10, 0), (self, 0)) self.connect((self.sinadLog10, 0), (self.sinadProbe, 0))
def __init__(self, freq=0, gain=40, loopbw=100, loopbw_0=100, fllbw=0.002): gr.top_block.__init__(self, "Rx Gui") Qt.QWidget.__init__(self) self.setWindowTitle("Rx Gui") 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", "rx_gui") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.freq = freq self.gain = gain self.loopbw = loopbw self.loopbw_0 = loopbw_0 self.fllbw = fllbw ################################################## # Variables ################################################## self.sps = sps = 8 self.excess_bw = excess_bw = 0.25 self.target_samp_rate = target_samp_rate = sps*(200e3/(1 + excess_bw)) self.qpsk_const = qpsk_const = digital.constellation_qpsk().base() self.dsp_rate = dsp_rate = 100e6 self.const_choice = const_choice = "qpsk" self.bpsk_const = bpsk_const = digital.constellation_bpsk().base() self.barker_code_two_dim = barker_code_two_dim = [-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j] self.barker_code_one_dim = barker_code_one_dim = sqrt(2)*numpy.real([-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j]) self.rrc_delay = rrc_delay = int(round(-44*excess_bw + 33)) self.nfilts = nfilts = 32 self.n_barker_rep = n_barker_rep = 10 self.dec_factor = dec_factor = ceil(dsp_rate/target_samp_rate) self.constellation = constellation = qpsk_const if (const_choice=="qpsk") else bpsk_const self.barker_code = barker_code = barker_code_two_dim if (const_choice == "qpsk") else barker_code_one_dim self.preamble_syms = preamble_syms = numpy.matlib.repmat(barker_code, 1, n_barker_rep)[0] self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps*nfilts) self.n_codewords = n_codewords = 1 self.even_dec_factor = even_dec_factor = dec_factor if (dec_factor % 1 == 1) else (dec_factor+1) self.const_order = const_order = pow(2,constellation.bits_per_symbol()) self.codeword_len = codeword_len = 18444 self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2" self.samp_rate = samp_rate = dsp_rate/even_dec_factor self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, excess_bw, n_rrc_taps) self.rf_center_freq = rf_center_freq = 1428.4309e6 self.preamble_size = preamble_size = len(preamble_syms) self.pmf_peak_threshold = pmf_peak_threshold = 0.6 self.payload_size = payload_size = codeword_len*n_codewords/int(numpy.log2(const_order)) self.dataword_len = dataword_len = 6144 self.barker_len = barker_len = 13 ################################################## # 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, 'PMF Out') 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, 'Abs PMF Out') self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, 'FLL In') self.tabs_widget_3 = Qt.QWidget() self.tabs_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_3) self.tabs_grid_layout_3 = Qt.QGridLayout() self.tabs_layout_3.addLayout(self.tabs_grid_layout_3) self.tabs.addTab(self.tabs_widget_3, 'FLL Out') self.tabs_widget_4 = Qt.QWidget() self.tabs_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_4) self.tabs_grid_layout_4 = Qt.QGridLayout() self.tabs_layout_4.addLayout(self.tabs_grid_layout_4) self.tabs.addTab(self.tabs_widget_4, 'FLL State') self.tabs_widget_5 = Qt.QWidget() self.tabs_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_5) self.tabs_grid_layout_5 = Qt.QGridLayout() self.tabs_layout_5.addLayout(self.tabs_grid_layout_5) self.tabs.addTab(self.tabs_widget_5, 'PFB Sync Out') self.tabs_widget_6 = Qt.QWidget() self.tabs_layout_6 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_6) self.tabs_grid_layout_6 = Qt.QGridLayout() self.tabs_layout_6.addLayout(self.tabs_grid_layout_6) self.tabs.addTab(self.tabs_widget_6, 'Costas State') self.tabs_widget_7 = Qt.QWidget() self.tabs_layout_7 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_7) self.tabs_grid_layout_7 = Qt.QGridLayout() self.tabs_layout_7.addLayout(self.tabs_grid_layout_7) self.tabs.addTab(self.tabs_widget_7, 'Demod Bits') self.tabs_widget_8 = Qt.QWidget() self.tabs_layout_8 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_8) self.tabs_grid_layout_8 = Qt.QGridLayout() self.tabs_layout_8.addLayout(self.tabs_grid_layout_8) self.tabs.addTab(self.tabs_widget_8, 'Costas Sym Out') self.tabs_widget_9 = Qt.QWidget() self.tabs_layout_9 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_9) self.tabs_grid_layout_9 = Qt.QGridLayout() self.tabs_layout_9.addLayout(self.tabs_grid_layout_9) self.tabs.addTab(self.tabs_widget_9, 'Payload Symbols') self.top_layout.addWidget(self.tabs) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.qtgui_time_sink_x_2 = qtgui.time_sink_c( preamble_size + payload_size, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(True) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_2.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.tabs_layout_0.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0.set_y_axis(-128, 128) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, False) self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget) self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_0_win) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 8192, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['FLL Freq (PI Output)', 'FLL Phase Accum', 'FLL Error', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_4.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_3 = qtgui.time_sink_f( 1024*4, #size samp_rate, #samp_rate "Error", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_3.set_update_time(0.10) self.qtgui_time_sink_x_0_3.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_3.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_3.enable_tags(-1, True) self.qtgui_time_sink_x_0_3.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_3.enable_autoscale(False) self.qtgui_time_sink_x_0_3.enable_grid(False) self.qtgui_time_sink_x_0_3.enable_axis_labels(True) self.qtgui_time_sink_x_0_3.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_3.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_3.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_3.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_3.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_3.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_3.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_3.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_3.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_3_win = sip.wrapinstance(self.qtgui_time_sink_x_0_3.pyqwidget(), Qt.QWidget) self.tabs_layout_6.addWidget(self._qtgui_time_sink_x_0_3_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( preamble_size + payload_size, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['Mag Sq', 'Mag', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_sink_x_5 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_5.set_update_time(1.0/10) self._qtgui_sink_x_5_win = sip.wrapinstance(self.qtgui_sink_x_5.pyqwidget(), Qt.QWidget) self.tabs_layout_3.addWidget(self._qtgui_sink_x_5_win) self.qtgui_sink_x_5.enable_rf_freq(False) self.qtgui_sink_x_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_1.set_update_time(1.0/10) self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_2.addWidget(self._qtgui_sink_x_1_win) self.qtgui_sink_x_1.enable_rf_freq(False) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name False, #plotfreq False, #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.tabs_layout_5.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_layout_2.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_9.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_layout_8.addWidget(self._qtgui_const_sink_x_0_win) self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len, dataword_len) self.mods_frame_sync_fast_0 = mods.frame_sync_fast(pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1, int(const_order)) self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx') self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff(1, ( numpy.ones(n_barker_rep*barker_len))) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, ( numpy.flipud(numpy.conj(preamble_syms)))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*pi/50, (rrc_taps), nfilts, nfilts/2, pi/8, 1) self.digital_map_bb_0_0_0 = digital.map_bb(([1,- 1])) self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc(sps, excess_bw, rrc_delay * int(sps) + 1, fllbw) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*pi/loopbw, 2**constellation.bits_per_symbol(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation.base()) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(constellation.bits_per_symbol()) self.blocks_rms_xx_1 = blocks.rms_cf(0.0001) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((1.0/sqrt(2), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1.0/(preamble_size*sqrt(2)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_1 = blocks.divide_ff(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'), (self.mods_fifo_async_sink_0, 'async_pdu')) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.blocks_char_to_float_0_1, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.digital_fll_band_edge_cc_1, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.mods_frame_sync_fast_0, 2)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.mods_frame_sync_fast_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_char_to_float_0_1, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mods_frame_sync_fast_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 1), (self.qtgui_time_sink_x_0_3, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.framers_gr_hdlc_deframer_b_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.qtgui_sink_x_5, 0)) self.connect((self.digital_fll_band_edge_cc_1, 3), (self.qtgui_time_sink_x_1, 2)) self.connect((self.digital_fll_band_edge_cc_1, 1), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_fll_band_edge_cc_1, 2), (self.qtgui_time_sink_x_1, 1)) self.connect((self.digital_map_bb_0_0_0, 0), (self.mods_turbo_decoder_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_divide_xx_1, 1)) self.connect((self.mods_frame_sync_fast_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.mods_frame_sync_fast_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.mods_turbo_decoder_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sr_rf = sr_rf = 2500000 self.decimate = decimate = 400 self.sr_lo = sr_lo = sr_rf / decimate self.f_rf = f_rf = 434645000 self.f_lo = f_lo = 455.2 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "Tuning") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "IQ Display") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "PSK Output") self.top_layout.addWidget(self.tab) self._f_rf_layout = Qt.QVBoxLayout() self._f_rf_tool_bar = Qt.QToolBar(self) self._f_rf_layout.addWidget(self._f_rf_tool_bar) self._f_rf_tool_bar.addWidget(Qt.QLabel("RF Freq" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._f_rf_counter = qwt_counter_pyslot() self._f_rf_counter.setRange(434644000, 434646000, 1) self._f_rf_counter.setNumButtons(2) self._f_rf_counter.setValue(self.f_rf) self._f_rf_tool_bar.addWidget(self._f_rf_counter) self._f_rf_counter.valueChanged.connect(self.set_f_rf) self._f_rf_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._f_rf_slider.setRange(434644000, 434646000, 1) self._f_rf_slider.setValue(self.f_rf) self._f_rf_slider.setMinimumWidth(200) self._f_rf_slider.valueChanged.connect(self.set_f_rf) self._f_rf_layout.addWidget(self._f_rf_slider) self.tab_layout_0.addLayout(self._f_rf_layout) self._f_lo_layout = Qt.QVBoxLayout() self._f_lo_tool_bar = Qt.QToolBar(self) self._f_lo_layout.addWidget(self._f_lo_tool_bar) self._f_lo_tool_bar.addWidget(Qt.QLabel("LO Freq" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._f_lo_counter = qwt_counter_pyslot() self._f_lo_counter.setRange(0, 2000, .1) self._f_lo_counter.setNumButtons(2) self._f_lo_counter.setValue(self.f_lo) self._f_lo_tool_bar.addWidget(self._f_lo_counter) self._f_lo_counter.valueChanged.connect(self.set_f_lo) self._f_lo_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._f_lo_slider.setRange(0, 2000, .1) self._f_lo_slider.setValue(self.f_lo) self._f_lo_slider.setMinimumWidth(200) self._f_lo_slider.valueChanged.connect(self.set_f_lo) self._f_lo_layout.addWidget(self._f_lo_slider) self.tab_layout_0.addLayout(self._f_lo_layout) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( sr_lo, #size sr_lo, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(.03) self.qtgui_time_sink_x_0.set_y_axis(-.02, .02) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_1 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.set_title("") labels = ["Signal RMS", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_1.set_min(i, -1) self.qtgui_number_sink_1.set_max(i, 1) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance( self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_1_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.03) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-.02, .02) self.qtgui_const_sink_x_1.set_x_axis(-.02, .02) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance( self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-.02, .02) self.qtgui_const_sink_x_0.set_x_axis(-.02, .02) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "airspy=0") self.osmosdr_source_0.set_sample_rate(sr_rf) self.osmosdr_source_0.set_center_freq(f_rf, 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(3, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 100, (firdes.low_pass(1, sr_rf, 2000, 100)), f_lo, sr_rf) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc( 2, 0, cmath.pi / 100.0, -0.5, 0.5, 0.25, 0.01, 2, 0.001, 0.001) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (sr_lo / (2 * 3.14159), )) self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(.06, 0.6, -.6) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pll_freqdet_cf_0, 0)) self.connect((self.analog_pll_freqdet_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.qtgui_number_sink_1, 0))
def __init__(self): gr.top_block.__init__(self, "Spin Echo") Qt.QWidget.__init__(self) self.setWindowTitle("Spin Echo") 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", "spin_echo") self.restoreGeometry(self.settings.value("geometry").toByteArray()) self._lock = threading.RLock() ################################################## # Variables ################################################## self.slave_delay = slave_delay = 0 self.samp_rate = samp_rate = 250000 self.ref_delay = ref_delay = 0 self.readout_delay = readout_delay = 0 self.power = power = 1 self.offset = offset = 0 self.master_delay = master_delay = 0 self.gz_on = gz_on = 0 self.gy_on = gy_on = 0 self.gx_on = gx_on = 0 self.ex_delay = ex_delay = 0 self.TR_clock = TR_clock = 0 self.TR = TR = 1. self.RUN = RUN = 1 self.Gz_delay = Gz_delay = 0 self.Gy_delay = Gy_delay = 0 self.Gx_delay = Gx_delay = 0 self.CF = CF = 21.3e6 #### ADDED FROM GR-MRI ##### f = open('spin_config.txt', 'r') foo = {} for line in f: k, v, bar = [q.strip() for q in line.split(',')] if k == 'leader_ID': self.leader_ID = str("serial = " + v) elif k == 'follower_ID': self.follower_ID = str("serial = " + v) else: pass f.close() ############################ ################################################## # Blocks ################################################## self.delay = blocks.delay(gr.sizeof_gr_complex * 1, 5) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join((self.follower_ID, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0_0.set_clock_source("external", 0) self.uhd_usrp_source_0_0.set_time_source("external", 0) self.uhd_usrp_source_0_0.set_subdev_spec("B:A B:B", 0) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(0, 0) self.uhd_usrp_source_0_0.set_gain(0, 0) self.uhd_usrp_source_0_0.set_antenna("B:A", 0) self.uhd_usrp_source_0_0.set_center_freq(0, 1) self.uhd_usrp_source_0_0.set_gain(0, 1) self.uhd_usrp_source_0_0.set_antenna("B:B", 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((self.leader_ID, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:A B:B", 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(CF + offset, 0) self.uhd_usrp_source_0.set_gain(15, 0) self.uhd_usrp_source_0.set_antenna("A:A", 0) self.uhd_usrp_source_0.set_bandwidth(25000, 0) self.uhd_usrp_source_0.set_center_freq(CF + offset, 1) self.uhd_usrp_source_0.set_gain(10, 1) self.uhd_usrp_source_0.set_antenna("B:B", 1) self.syncwin = MRI.triggered_vector_source_f( [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 1.0, 0.0, 1, 1) self.sync_data = blocks.vector_sink_c(1) self.signal_out = MRI.gated_vector_sink() self.s_delay_0_0_0 = blocks.delay(gr.sizeof_float * 1, 5) self.s_delay_0_0 = blocks.delay(gr.sizeof_float * 1, 5) self.s_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 5) self.s_delay = blocks.delay(gr.sizeof_gr_complex * 1, int(slave_delay)) self.rf_sink = uhd.usrp_sink( ",".join((self.leader_ID, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.rf_sink.set_subdev_spec("A:AB B:AB", 0) self.rf_sink.set_samp_rate(samp_rate) self.rf_sink.set_center_freq(CF + offset, 0) self.rf_sink.set_gain(0, 0) self.rf_sink.set_antenna("A:AB", 0) self.rf_sink.set_center_freq(0, 1) self.rf_sink.set_gain(0, 1) self.rf_sink.set_antenna("B:AB", 1) self.ref_pulse = MRI.triggered_vector_source([0, 0, 0], 1.0, 0.0, 1, 1) self.readwin = MRI.triggered_vector_source_f([0, 0, 0], 1.0, 0.0, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 3000, #size samp_rate, #samp_rate "", #name 4 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(.1) self.qtgui_time_sink_x_0.set_y_axis(-.25, .25) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, .01, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = [ "Read Window", "Real Signal", "Imag Signal", "RMS", "", "", "", "", "", "" ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "black", "blue", "red", "green", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [2, 1, 1, 2, 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(4): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.m_delay = blocks.delay(gr.sizeof_gr_complex * 1, int(master_delay)) self.ex_pulse = MRI.triggered_vector_source([0, 0, 0], 1.0, 0.0, 1, 1) self.delay6 = blocks.delay(gr.sizeof_float * 1, Gx_delay) self.delay3_0_1_0 = blocks.delay(gr.sizeof_float * 1, Gy_delay) self.delay3_0_1 = blocks.delay(gr.sizeof_float * 1, Gz_delay) self.delay3 = blocks.delay(gr.sizeof_float * 1, readout_delay) self.delay1_0 = blocks.delay(gr.sizeof_float * 1, ref_delay) self.delay1 = blocks.delay(gr.sizeof_float * 1, ex_delay) self.dc_sinc = uhd.usrp_sink( ",".join((self.follower_ID, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.dc_sinc.set_clock_source("external", 0) self.dc_sinc.set_time_source("external", 0) self.dc_sinc.set_subdev_spec("B:AB A:AB", 0) self.dc_sinc.set_samp_rate(samp_rate) self.dc_sinc.set_center_freq(0, 0) self.dc_sinc.set_gain(0, 0) self.dc_sinc.set_antenna("B:AB", 0) self.dc_sinc.set_center_freq(0, 1) self.dc_sinc.set_gain(0, 1) self.dc_sinc.set_antenna("A:AB", 1) self.blocks_threshold_ff_0_2 = blocks.threshold_ff(.000001, .000001, 0) self.blocks_threshold_ff_0_1 = blocks.threshold_ff(.05, .05, 0) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(.01, .01, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff(.01, .01, 0) self.blocks_rms_xx_1 = blocks.rms_cf(1) self.blocks_rms_xx_0_0 = blocks.rms_cf(1) self.blocks_rms_xx_0 = blocks.rms_cf(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff((RUN, )) self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff( (gy_on, )) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff( (gz_on, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((gx_on, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, 1, 4000) self.blocks_float_to_complex_2 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_0_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0_0 = blocks.add_vcc(1) self.analog_sig_source_x_0_0_0 = analog.sig_source_f( samp_rate, analog.GR_SQR_WAVE, 5. / TR, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SQR_WAVE, 1. / TR, 1, 0) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.Gz = MRI.triggered_vector_source_f([0, 0, 0], 1, 0, 1, 1) self.Gy = MRI.triggered_vector_source_f([0, 0, 0], 1, 0, 1, 1) self.Gx = MRI.triggered_vector_source_f([0, 0, 0], 1, 0, 1, 1) ################################################## # Connections ################################################## self.connect((self.Gx, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.Gy, 0), (self.blocks_multiply_const_vxx_1_0_0, 0)) self.connect((self.Gz, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.syncwin, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.delay, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_threshold_ff_0_1, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.s_delay, 0)) self.connect((self.blocks_float_to_complex_0_0_0, 0), (self.s_delay, 1)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_float_to_complex_1, 0), (self.sync_data, 0)) self.connect((self.blocks_float_to_complex_2, 0), (self.m_delay, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0_2, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.signal_out, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.s_delay_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_float_to_complex_0_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.blocks_float_to_complex_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay1, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay1_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay3, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay3_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay3_0_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay6, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.qtgui_time_sink_x_0, 3)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.signal_out, 0)) self.connect((self.blocks_threshold_ff_0_2, 0), (self.blocks_float_to_complex_2, 0)) self.connect((self.delay, 0), (self.m_delay, 0)) self.connect((self.delay1, 0), (self.ex_pulse, 0)) self.connect((self.delay1_0, 0), (self.ref_pulse, 0)) self.connect((self.delay3, 0), (self.readwin, 0)) self.connect((self.delay3_0_1, 0), (self.Gz, 0)) self.connect((self.delay3_0_1_0, 0), (self.Gy, 0)) self.connect((self.delay6, 0), (self.Gx, 0)) self.connect((self.ex_pulse, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.m_delay, 0), (self.rf_sink, 0)) self.connect((self.m_delay, 1), (self.rf_sink, 1)) self.connect((self.readwin, 0), (self.s_delay_0_0_0, 0)) self.connect((self.ref_pulse, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.s_delay, 0), (self.dc_sinc, 0)) self.connect((self.s_delay, 1), (self.s_delay_0, 0)) self.connect((self.s_delay_0, 0), (self.dc_sinc, 1)) self.connect((self.s_delay_0_0, 0), (self.blocks_float_to_complex_0_0, 1)) self.connect((self.s_delay_0_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.syncwin, 0), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.syncwin, 0), (self.blocks_float_to_complex_2, 1)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_divide_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_rms_xx_0_0, 0))
def __init__(self, freq=0, gain=0, loopbw=100, fllbw=0.002): gr.top_block.__init__(self, "Rx") ################################################## # Parameters ################################################## self.freq = freq self.gain = gain self.loopbw = loopbw self.fllbw = fllbw ################################################## # Variables ################################################## self.sps = sps = 8 self.excess_bw = excess_bw = 0.25 self.target_samp_rate = target_samp_rate = sps*(200e3/(1 + excess_bw)) self.qpsk_const = qpsk_const = digital.constellation_qpsk().base() self.dsp_rate = dsp_rate = 100e6 self.const_choice = const_choice = "qpsk" self.bpsk_const = bpsk_const = digital.constellation_bpsk().base() self.barker_code_two_dim = barker_code_two_dim = [-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j] self.barker_code_one_dim = barker_code_one_dim = sqrt(2)*numpy.real([-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j]) self.rrc_delay = rrc_delay = int(round(-44*excess_bw + 33)) self.nfilts = nfilts = 32 self.n_barker_rep = n_barker_rep = 10 self.dec_factor = dec_factor = ceil(dsp_rate/target_samp_rate) self.constellation = constellation = qpsk_const if (const_choice=="qpsk") else bpsk_const self.barker_code = barker_code = barker_code_two_dim if (const_choice == "qpsk") else barker_code_one_dim self.preamble_syms = preamble_syms = numpy.matlib.repmat(barker_code, 1, n_barker_rep)[0] self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps*nfilts) self.n_codewords = n_codewords = 1 self.even_dec_factor = even_dec_factor = dec_factor if (dec_factor % 1 == 1) else (dec_factor+1) self.const_order = const_order = pow(2,constellation.bits_per_symbol()) self.codeword_len = codeword_len = 18444 self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2" self.samp_rate = samp_rate = dsp_rate/even_dec_factor self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, excess_bw, n_rrc_taps) self.rf_center_freq = rf_center_freq = 1428.4309e6 self.preamble_size = preamble_size = len(preamble_syms) self.pmf_peak_threshold = pmf_peak_threshold = 0.6 self.payload_size = payload_size = codeword_len*n_codewords/int(numpy.log2(const_order)) self.dataword_len = dataword_len = 6144 self.barker_len = barker_len = 13 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len, dataword_len) self.mods_frame_sync_fast_0 = mods.frame_sync_fast(pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1, int(const_order)) self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx') self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff(1, ( numpy.ones(n_barker_rep*barker_len))) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, ( numpy.flipud(numpy.conj(preamble_syms)))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*pi/50, (rrc_taps), nfilts, nfilts/2, pi/8, 1) self.digital_map_bb_0_0_0 = digital.map_bb(([1,- 1])) self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc(sps, excess_bw, rrc_delay * int(sps) + 1, fllbw) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*pi/loopbw, 2**constellation.bits_per_symbol(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation.base()) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(constellation.bits_per_symbol()) self.blocks_rms_xx_1 = blocks.rms_cf(0.0001) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((1.0/sqrt(2), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1.0/(preamble_size*sqrt(2)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_1 = blocks.divide_ff(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'), (self.mods_fifo_async_sink_0, 'async_pdu')) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.digital_fll_band_edge_cc_1, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.mods_frame_sync_fast_0, 2)) self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.mods_frame_sync_fast_0, 1)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mods_frame_sync_fast_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.framers_gr_hdlc_deframer_b_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_map_bb_0_0_0, 0), (self.mods_turbo_decoder_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_divide_xx_1, 1)) self.connect((self.mods_frame_sync_fast_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.mods_turbo_decoder_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0))
def __init__(self): gr.top_block.__init__(self, "Bpsk Receiverpoly") ################################################## # Variables ################################################## self.sps = sps = 8 self.probe_var = probe_var = 0 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.SNR = SNR = 500 self.transistion = transistion = 100 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.sideband_rx = sideband_rx = 500 self.sideband = sideband = 500 self.samp_rate = samp_rate = 48000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts/16, nfilts/16, 1.0/float(sps), 0.35, 11*sps*nfilts/16) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.probe_var_n = probe_var_n = 0 self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase_bw = phase_bw = 6.28/100.0 self.noise_amp = noise_amp = probe_var/(10**(SNR/20)) self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.interpolation = interpolation = 60000 self.eq_gain = eq_gain = 0.01 self.delay = delay = 0 self.decimation = decimation = 1 self.constel = constel = digital.constellation_calcdist(([1,- 1]), ([0,1]), 2, 1).base() self.carrier = carrier = 10000 self.arity = arity = 2 ################################################## # Blocks ################################################## self.probe_rms = blocks.probe_signal_f() self.probe_avg_n = blocks.probe_signal_f() self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=decimation, decimation=interpolation, taps=(rrc_taps), fractional_bw=None, ) def _probe_var_n_probe(): while True: val = self.probe_avg_n.level() try: self.set_probe_var_n(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_var_n_thread = threading.Thread(target=_probe_var_n_probe) _probe_var_n_thread.daemon = True _probe_var_n_thread.start() def _probe_var_probe(): while True: val = self.probe_rms.level() try: self.set_probe_var(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_var_thread = threading.Thread(target=_probe_var_probe) _probe_var_thread.daemon = True _probe_var_thread.start() self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, (filter.firdes.low_pass(1, samp_rate*10, sideband_rx,1000)), carrier, samp_rate) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts*2, nfilts/2, 1.5, 1) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constel) script, SNRinput, inputwav, outputBinary, delay= argv self.blocks_wavfile_source_0 = blocks.wavfile_source(inputwav, False) self.blocks_throttle_1_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_rms_xx_1 = blocks.rms_cf(0.01) self.blocks_rms_xx_0 = blocks.rms_cf(0.01) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, outputBinary, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_1 = blocks.delay(gr.sizeof_char*1, int(delay)) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, noise_amp, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.probe_rms, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.probe_avg_n, 0)) self.connect((self.blocks_throttle_1_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_throttle_1_0_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_delay_1, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_throttle_1_0_0, 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").toByteArray()) ################################################## # Variables ################################################## self.vector = vector = (88.1e6, 89.1e6, 89.7e6, 90.1e6, 90.5e6, 90.9e6, 91.3e6, 92.1e6, 92.5e6, 92.9e6, 93.7e6, 94.1e6, 94.7e6, 95.3e6, 95.7e6, 96.1e6, 96.5e6, 96.9e6, 97.3e6, 97.7e6, 98.1e6, 98.5e6, 98.9e6, 99.3e6, 100.1e6, 100.9e6, 101.3e6, 101.5e6, 101.7e6, 102.1e6, 102.5e6, 103.3e6, 104.1e6, 104.3e6, 104.7e6, 105.1e6, 105.7e6, 106.3e6, 106.9e6, 107.3e6, 107.9e6) self.indice = indice = 0 self.ajuste = ajuste = 0 self.samp_rate = samp_rate = 2.4e6 self.rfgain = rfgain = 70 self.freq_Passa_Faixa_REAL = freq_Passa_Faixa_REAL = vector[indice] + ( vector[indice + 1] - vector[indice]) + ajuste self.freq_Passa_Faixa = freq_Passa_Faixa = vector[indice + 1] self.Update_Interval = Update_Interval = 0.1 self.Quadrature = Quadrature = 50e4 self.OutputDir = OutputDir = "/home/iris/Desktop/medidas/" self.FreqChannel = FreqChannel = vector[indice] self.FileNameSND = FileNameSND = "SND_" + str(indice) + "_" + str( vector[indice]) + ".bin" self.BandWidth = BandWidth = 100e3 ################################################## # Blocks ################################################## self._rfgain_range = Range(0, 100, 1, 70, 10) self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain, 'Ganho', "slider", float) self.top_grid_layout.addWidget(self._rfgain_win, 0, 0, 1, 2) self._indice_range = Range(0, 40, 1, 0, 2) self._indice_win = RangeWidget(self._indice_range, self.set_indice, "indice", "counter", int) self.top_grid_layout.addWidget(self._indice_win, 1, 0, 1, 1) self._ajuste_range = Range(-600e3, 600e3, 100, 0, 10) self._ajuste_win = RangeWidget(self._ajuste_range, self.set_ajuste, "ajuste", "counter_slider", float) self.top_grid_layout.addWidget(self._ajuste_win, 0, 6, 1, 2) self._BandWidth_range = Range(0, 100e3, 1, 100e3, 10) self._BandWidth_win = RangeWidget(self._BandWidth_range, self.set_BandWidth, 'Largura de Banda', "slider", float) self.top_grid_layout.addWidget(self._BandWidth_win, 0, 3, 1, 2) 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(vector[indice], 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(rfgain, 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.low_pass_filter_0_1 = filter.fir_filter_ccf( 12, firdes.low_pass(2, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76)) self._freq_Passa_Faixa_REAL_tool_bar = Qt.QToolBar(self) if None: self._freq_Passa_Faixa_REAL_formatter = None else: self._freq_Passa_Faixa_REAL_formatter = lambda x: eng_notation.num_to_str( x) self._freq_Passa_Faixa_REAL_tool_bar.addWidget( Qt.QLabel('Freq (Chanel +1) + ajuste (PF)' + ": ")) self._freq_Passa_Faixa_REAL_label = Qt.QLabel( str( self._freq_Passa_Faixa_REAL_formatter( self.freq_Passa_Faixa_REAL))) self._freq_Passa_Faixa_REAL_tool_bar.addWidget( self._freq_Passa_Faixa_REAL_label) self.top_grid_layout.addWidget(self._freq_Passa_Faixa_REAL_tool_bar, 1, 6, 1, 1) self._freq_Passa_Faixa_tool_bar = Qt.QToolBar(self) if None: self._freq_Passa_Faixa_formatter = None else: self._freq_Passa_Faixa_formatter = lambda x: eng_notation.num_to_str( x) self._freq_Passa_Faixa_tool_bar.addWidget( Qt.QLabel('Freq(channel + 1)' + ": ")) self._freq_Passa_Faixa_label = Qt.QLabel( str(self._freq_Passa_Faixa_formatter(self.freq_Passa_Faixa))) self._freq_Passa_Faixa_tool_bar.addWidget(self._freq_Passa_Faixa_label) self.top_grid_layout.addWidget(self._freq_Passa_Faixa_tool_bar, 1, 4, 1, 1) self.blocks_rms_xx_1 = blocks.rms_cf(0.0001) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_nlog10_ff_0_1_0 = blocks.nlog10_ff(20, 1, 1) self.blocks_file_sink_1_0 = blocks.file_sink(gr.sizeof_float * 1, OutputDir + FileNameSND, False) self.blocks_file_sink_1_0.set_unbuffered(False) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.band_pass_filter = filter.fir_filter_ccf( 12, firdes.band_pass( 2, samp_rate, (vector[indice + 1] - vector[indice]) - BandWidth + ajuste, (vector[indice + 1] - vector[indice]) + BandWidth + ajuste, 10e3, firdes.WIN_HAMMING, 6.76)) self.POTENCIA_PASSA_BAIXA_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.POTENCIA_PASSA_BAIXA_0.set_update_time(Update_Interval) self.POTENCIA_PASSA_BAIXA_0.set_title('SND (dB)') labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.POTENCIA_PASSA_BAIXA_0.set_min(i, -1) self.POTENCIA_PASSA_BAIXA_0.set_max(i, 1) self.POTENCIA_PASSA_BAIXA_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.POTENCIA_PASSA_BAIXA_0.set_label(i, "Data {0}".format(i)) else: self.POTENCIA_PASSA_BAIXA_0.set_label(i, labels[i]) self.POTENCIA_PASSA_BAIXA_0.set_unit(i, units[i]) self.POTENCIA_PASSA_BAIXA_0.set_factor(i, factor[i]) self.POTENCIA_PASSA_BAIXA_0.enable_autoscale(False) self._POTENCIA_PASSA_BAIXA_0_win = sip.wrapinstance( self.POTENCIA_PASSA_BAIXA_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._POTENCIA_PASSA_BAIXA_0_win, 3, 0, 1, 1) self._FreqChannel_tool_bar = Qt.QToolBar(self) if None: self._FreqChannel_formatter = None else: self._FreqChannel_formatter = lambda x: eng_notation.num_to_str(x) self._FreqChannel_tool_bar.addWidget(Qt.QLabel('Freq (Chanel)' + ": ")) self._FreqChannel_label = Qt.QLabel( str(self._FreqChannel_formatter(self.FreqChannel))) self._FreqChannel_tool_bar.addWidget(self._FreqChannel_label) self.top_grid_layout.addWidget(self._FreqChannel_tool_bar, 1, 2, 1, 1) ################################################## # Connections ################################################## self.connect((self.band_pass_filter, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0_1_0, 0)) self.connect((self.blocks_nlog10_ff_0_1_0, 0), (self.POTENCIA_PASSA_BAIXA_0, 0)) self.connect((self.blocks_nlog10_ff_0_1_0, 0), (self.blocks_file_sink_1_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.band_pass_filter, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0_1, 0))