def __init__(self, baudrate, samp_rate, iq, f_offset=None, differential=False, manchester=False, dump_path=None, options=None): gr.hier_block2.__init__( self, "bpsk_demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex if iq else gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float)) options_block.__init__(self, options) if dump_path is not None: dump_path = pathlib.Path(dump_path) if manchester: baudrate *= 2 # prevent problems due to baudrate too high if baudrate >= samp_rate / 4: print( f'Sample rate {samp_rate} sps insufficient for {baudrate} baud BPSK demodulation. Demodulator will not work.', file=sys.stderr) baudrate = samp_rate / 4 sps = samp_rate / baudrate max_sps = 10 if sps > max_sps: decimation = ceil(sps / max_sps) else: decimation = 1 sps /= decimation filter_cutoff = baudrate * 2.0 filter_transition = baudrate * 0.2 if f_offset is None: f_offset = self.options.f_offset if f_offset is None: if iq: f_offset = 0 elif baudrate <= 2400: f_offset = 1500 else: f_offset = 12000 taps = firdes.low_pass(1, samp_rate, filter_cutoff, filter_transition) f = filter.freq_xlating_fir_filter_ccf if iq else filter.freq_xlating_fir_filter_fcf self.xlating = f(decimation, taps, f_offset, samp_rate) agc_constant = 2e-2 / sps # This gives a time constant of 50 symbols self.agc = rms_agc(agc_constant, 1) if dump_path is not None: self.agc_in = blocks.file_sink(gr.sizeof_gr_complex, str(dump_path / 'agc_in.c64'), False) self.agc_out = blocks.file_sink(gr.sizeof_gr_complex, str(dump_path / 'agc_out.c64'), False) self.connect(self.xlating, self.agc_in) self.connect(self.agc, self.agc_out) if not self.options.disable_fll: fll_bw = 2 * pi * decimation / samp_rate * self.options.fll_bw self.fll = digital.fll_band_edge_cc(sps, self.options.rrc_alpha, 100, fll_bw) if dump_path is not None: self.fll_freq = blocks.file_sink( gr.sizeof_float, str(dump_path / 'fll_freq.f32'), False) self.fll_phase = blocks.file_sink( gr.sizeof_float, str(dump_path / 'fll_phase.f32'), False) self.fll_error = blocks.file_sink( gr.sizeof_float, str(dump_path / 'fll_error.f32'), False) self.connect((self.fll, 1), self.fll_freq) self.connect((self.fll, 2), self.fll_phase) self.connect((self.fll, 3), self.fll_error) nfilts = 16 rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0 / float(sps), self.options.rrc_alpha, int(ceil(11 * sps * nfilts))) ted_gain = 0.5 # "empiric" formula for TED gain of a PFB MF TED for complex BPSK 0.5 sample^{-1} damping = 1.0 self.clock_recovery = digital.symbol_sync_cc( digital.TED_SIGNAL_TIMES_SLOPE_ML, sps, self.options.clk_bw, damping, ted_gain, self.options.clk_limit * sps, 1, digital.constellation_bpsk().base(), digital.IR_PFB_MF, nfilts, rrc_taps) if dump_path is not None: self.clock_recovery_out = blocks.file_sink( gr.sizeof_gr_complex, str(dump_path / 'clock_recovery_out.c64'), False) self.clock_recovery_err = blocks.file_sink( gr.sizeof_float, str(dump_path / 'clock_recovery_err.f32'), False) self.clock_recovery_T_inst = blocks.file_sink( gr.sizeof_float, str(dump_path / 'clock_recovery_T_inst.f32'), False) self.clock_recovery_T_avg = blocks.file_sink( gr.sizeof_float, str(dump_path / 'clock_recovery_T_avg.f32'), False) self.connect(self.clock_recovery, self.clock_recovery_out) self.connect((self.clock_recovery, 1), self.clock_recovery_err) self.connect((self.clock_recovery, 2), self.clock_recovery_T_inst) self.connect((self.clock_recovery, 3), self.clock_recovery_T_avg) self.connect(self, self.xlating, self.agc) if self.options.disable_fll: self.connect(self.agc, self.clock_recovery) else: self.connect(self.agc, self.fll, self.clock_recovery) self.complex_to_real = blocks.complex_to_real(1) if manchester: self.manchester = manchester_sync(self.options.manchester_history) self.connect(self.clock_recovery, self.manchester) else: self.manchester = self.clock_recovery if differential: self.delay = blocks.delay(gr.sizeof_gr_complex, 1) self.multiply_conj = blocks.multiply_conjugate_cc(1) sign = -1 if manchester else 1 self.multiply_const = blocks.multiply_const_ff( sign, 1) # take care about inverion in Manchester self.connect(self.manchester, (self.multiply_conj, 0)) self.connect(self.manchester, self.delay, (self.multiply_conj, 1)) self.connect(self.multiply_conj, self.complex_to_real, self.multiply_const, self) else: costas_bw = 2 * pi / baudrate * self.options.costas_bw self.costas = digital.costas_loop_cc(costas_bw, 2, False) if dump_path is not None: self.costas_out = blocks.file_sink( gr.sizeof_gr_complex, str(dump_path / 'costas_out.c64'), False) self.costas_frequency = blocks.file_sink( gr.sizeof_float, str(dump_path / 'costas_frequency.f32'), False) self.costas_phase = blocks.file_sink( gr.sizeof_float, str(dump_path / 'costas_phase.f32'), False) self.costas_error = blocks.file_sink( gr.sizeof_float, str(dump_path / 'costas_error.f32'), False) self.connect(self.costas, self.costas_out) self.connect((self.costas, 1), self.costas_frequency) self.connect((self.costas, 2), self.costas_phase) self.connect((self.costas, 3), self.costas_error) self.connect(self.manchester, self.costas, self.complex_to_real, self)
def __init__(self): gr.hier_block2.__init__( self, "PW-Sat2 Demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(0, 0, 0), ) self.message_port_register_hier_out("frames") 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) ################################################## # Variables ################################################## self.symb_rate = symb_rate = 1200 self.samp_per_sym = samp_per_sym = 10 self.samp_rate = samp_rate = symb_rate * samp_per_sym self.frequency_offset = frequency_offset = -20e3 self.decimation = decimation = 16 self.bpsk = bpsk = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 2, 1).base() self.alpha = alpha = 0.5 ################################################## # Blocks ################################################## self._frequency_offset_range = Range(-40e3, 40e3, 10, -20e3, 200) self._frequency_offset_win = RangeWidget(self._frequency_offset_range, self.set_frequency_offset, 'Frequency Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._frequency_offset_win) self._decimation_options = ( 16, 8, 4, 2, ) self._decimation_labels = ( '1200', '2400', '4800', '9600', ) self._decimation_tool_bar = Qt.QToolBar(self) self._decimation_tool_bar.addWidget(Qt.QLabel('Symbol Rate' + ": ")) self._decimation_combo_box = Qt.QComboBox() self._decimation_tool_bar.addWidget(self._decimation_combo_box) for label in self._decimation_labels: self._decimation_combo_box.addItem(label) self._decimation_callback = lambda i: Qt.QMetaObject.invokeMethod( self._decimation_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._decimation_options.index(i))) self._decimation_callback(self.decimation) self._decimation_combo_box.currentIndexChanged.connect( lambda i: self.set_decimation(self._decimation_options[i])) self.top_grid_layout.addWidget(self._decimation_tool_bar) self._alpha_range = Range(0, 1, 1e-3, 0.5, 200) self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha, "alpha", "counter_slider", float) self.top_grid_layout.addWidget(self._alpha_win) self.satellites_nrzi_decode_0 = satellites.nrzi_decode() self.satellites_hdlc_deframer_0 = satellites.hdlc_deframer( check_fcs=True, max_length=10000) self.root_raised_cosine_filter_0_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symb_rate, alpha, 300)) self.qtgui_waterfall_sink_x_1 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 192000, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_1.set_update_time(0.10) self.qtgui_waterfall_sink_x_1.enable_grid(False) self.qtgui_waterfall_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_1.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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_1.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_1.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_1.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_1.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_1_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 192000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win) 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 128, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (firdes.low_pass(1, 192000, 40000, 1000)), frequency_offset, 192000) self.fractional_resampler_xx_0 = filter.fractional_resampler_cc( 0, decimation) self.digital_symbol_sync_xx_0 = digital.symbol_sync_cc( digital.TED_ZERO_CROSSING, samp_per_sym, 0.045, 1.0, 1, 0.1, 1, digital.constellation_bpsk().base(), digital.IR_MMSE_8TAP, 128, ([])) self.digital_descrambler_bb_0_1 = digital.descrambler_bb( 0x21, 0x00, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(0.1, 2, False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( bpsk) self.analog_agc_xx_0 = analog.agc_cc(1e-3, 1, 1.0) self.analog_agc_xx_0.set_max_gain(30) ################################################## # Connections ################################################## self.msg_connect((self.satellites_hdlc_deframer_0, 'out'), (self, 'frames')) self.connect((self.analog_agc_xx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_descrambler_bb_0_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.root_raised_cosine_filter_0_0, 0)) self.connect((self.digital_descrambler_bb_0_1, 0), (self.satellites_nrzi_decode_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.fractional_resampler_xx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fractional_resampler_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self, 0), (self.qtgui_waterfall_sink_x_1, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.digital_symbol_sync_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.satellites_nrzi_decode_0, 0), (self.satellites_hdlc_deframer_0, 0))
def __init__(self): gr.top_block.__init__(self, "Testbench") Qt.QWidget.__init__(self) self.setWindowTitle("Testbench") 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", "testbench") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.decim = decim = 1 self.audio_samp_rate = audio_samp_rate = 40e3 self.symbol_rate = symbol_rate = 20e3 self.samp_rate = samp_rate = audio_samp_rate / decim self.sps = sps = float(samp_rate) / symbol_rate self.rolloff = rolloff = 0.2 self.ntaps = ntaps = 31 self.tx_taps_hex = tx_taps_hex = [ 119, -19, -111, 129, 21, -277, 199, 446, -619, -616, 1385, 760, -3014, -857, 10233, 17209, 10233, -857, -3014, 760, 1385, -616, -619, 446, 199, -277, 21, 129, -111, -19, 119 ] self.sym_per_arm = sym_per_arm = 8 self.nfilts = nfilts = 16 self.ideal_taps = ideal_taps = firdes.root_raised_cosine( int(sps), samp_rate, symbol_rate, rolloff, ntaps) self.thresh = thresh = 70 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), rolloff, int(sym_per_arm * sps * nfilts)) self.quant_taps = quant_taps = [ round(2**15 * x) / 2**15 for x in ideal_taps ] self.constel = constel = digital.constellation_calcdist([ +0.70711 + +0.70711j, +1.0 + +0.0j, -1.0 + +0.0j, -0.70711 + -0.70711j, +0.0 + +1.0j, +0.70711 + -0.70711j, -0.70711 + +0.70711j, -0.0 + -1.0j ], list(range(0, 8)), 8, 1).base() self.constel.gen_soft_dec_lut(8) self.act_taps = act_taps = [x * 2**-15 for x in tx_taps_hex] ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(0, 50) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, thresh, 512 / samp_rate, 0, "phase_est") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0, 1, 2, 1) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(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 range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 3, 0, 1, 2) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "EVM Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.001) self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_x_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) labels = [ 'Reclocked', 'Reference', 'Filtered', 'Raw', '', '', '', '', '', '' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "cyan", "yellow", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [2, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0, 0, 2, 1) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.kc2qol_ldpc_decoder_fb_0 = kc2qol.ldpc_decoder_fb() self.kc2qol_dvbs2_pl_deframer_0 = kc2qol.dvbs2_pl_deframer( 21600, pmt.intern('corr_est'), 0) self.kc2qol_dvbs2_8psk_demod_0 = kc2qol.dvbs2_8psk_demod(None) self.digital_symbol_sync_xx_0 = digital.symbol_sync_cc( digital.TED_MOD_MUELLER_AND_MULLER, sps, 2 * numpy.pi / 100 * 0.6, 1.0, 1.0, 1.5, 1, constel, digital.IR_MMSE_8TAP, 128, []) self.digital_corr_est_cc_0 = digital.corr_est_cc([ 0.707 + 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, 0.707 + 0.707j, 0.707 - 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, 0.707 - 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, 0.707 - 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, 0.707 + 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j ], 1, 1, thresh / 90, digital.THRESHOLD_ABSOLUTE) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 1, 8, "", False, gr.GR_MSB_FIRST) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(2**-12) self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex( False, False) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_short * 1, '/Users/iracigt/Developer/DVB_hat/hdl/iq_bytes.bin', True, 0 * 21690 * 2, ) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_3 = blocks.file_sink( gr.sizeof_char * 1, '/Users/iracigt/Desktop/packets_ldpc.bin', False) self.blocks_file_sink_3.set_unbuffered(True) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_const_vxx_0 = blocks.add_const_cc(-3.8 * (1 + 1j)) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_interleaved_short_to_complex_0, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_file_sink_3, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_symbol_sync_xx_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.kc2qol_dvbs2_pl_deframer_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.kc2qol_dvbs2_8psk_demod_0, 0), (self.kc2qol_ldpc_decoder_fb_0, 0)) self.connect((self.kc2qol_dvbs2_pl_deframer_0, 0), (self.kc2qol_dvbs2_8psk_demod_0, 0)) self.connect((self.kc2qol_ldpc_decoder_fb_0, 0), (self.blocks_repack_bits_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "Not titled yet") Qt.QWidget.__init__(self) self.setWindowTitle("Not titled yet") 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", "sim_tx") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 500000 self.tx_gain = tx_gain = 50 self.samp_rate = samp_rate = symbol_rate * 2 self.constel = constel = digital.constellation_calcdist([ +0.70711 + +0.70711j, +1.0 + +0.0j, -1.0 + +0.0j, -0.70711 + -0.70711j, +0.0 + +1.0j, +0.70711 + -0.70711j, -0.70711 + +0.70711j, -0.0 + -1.0j ], list(range(0, 8)), 8, 1).base() self.constel.gen_soft_dec_lut(8) self.center_freq = center_freq = 1279e6 ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 60, 1, 50, 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) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name 1) 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(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) 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 range(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) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "EVM Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.001) self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_x_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) labels = [ 'Reclocked', 'Reference', 'Filtered', 'Raw', '', '', '', '', '', '' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "cyan", "yellow", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [2, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0, 0, 2, 1) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.iio_pluto_sink_0 = iio.pluto_sink('', int(center_freq), int(samp_rate), 2000000, 32768, False, 60 - tx_gain, '', True) self.digital_symbol_sync_xx_0 = digital.symbol_sync_cc( digital.TED_MOD_MUELLER_AND_MULLER, 2, 2 * 3.14159 / 100 * 0.6, 1.0, 1.0, 1.5, 1, constel, digital.IR_MMSE_8TAP, 128, []) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(2**-12) self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex( False, False) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_short * 1, '/Users/iracigt/Developer/DVB_hat/hdl/iq_bytes.bin', True, 0 * 21690 * 2, ) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_add_const_vxx_0 = blocks.add_const_cc(-3.8 * (1 + 1j)) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_symbol_sync_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_interleaved_short_to_complex_0, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.qtgui_const_sink_x_0_0, 0))
def __init__(self, inputfile='', outputfile='0'): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.inputfile = inputfile self.outputfile = outputfile ################################################## # Variables ################################################## self.decimation = decimation = 1 self.symb_rate = symb_rate = 72e3 self.samp_rate = samp_rate = 0.900001e6 / decimation self.ted_gain = ted_gain = 1 self.sps = sps = (samp_rate) / symb_rate self.qpsk = qpsk = digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base() self.loop_bw = loop_bw = 0.002 self.fft_min = fft_min = -160 self.fft_max = fft_max = -15 self.dec_taps = dec_taps = firdes.low_pass(1.0, samp_rate, 141e3, 20e3, firdes.WIN_HAMMING, 6.76) self.d_factor = d_factor = 2 ################################################## # Blocks ################################################## self._ted_gain_range = Range(0.1, 2, 0.1, 1, 200) self._ted_gain_win = RangeWidget(self._ted_gain_range, self.set_ted_gain, "ted_gain", "counter_slider", float) self.top_grid_layout.addWidget(self._ted_gain_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._loop_bw_range = Range(0.001, 0.1, 0.001, 0.002, 200) self._loop_bw_win = RangeWidget(self._loop_bw_range, self.set_loop_bw, "loop_bw", "counter_slider", float) self.top_grid_layout.addWidget(self._loop_bw_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._d_factor_range = Range(0.1, 2, 0.1, 2, 200) self._d_factor_win = RangeWidget(self._d_factor_range, self.set_d_factor, "d_factor", "counter_slider", float) self.top_grid_layout.addWidget(self._d_factor_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 3, 300)) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(9, 13) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['error', 't_inst', 't_avg', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 100e3, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(fft_min, fft_max) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "red", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_x_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.fir_filter_xxx_0 = filter.fir_filter_ccf(decimation, (dec_taps)) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_symbol_sync_xx_0 = digital.symbol_sync_cc( digital.TED_MUELLER_AND_MULLER, sps, loop_bw, d_factor, ted_gain, 1, 1, digital.constellation_bpsk().base(), digital.IR_MMSE_8TAP, 128, ([])) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( loop_bw, 4, False) self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf( digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * 25 * decimation, True) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_float * 1, '/home/nacho/Desktop/Proyecto-Final/data/gqrx_20190914_121650_137100000_900001_fc.raw', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/nacho/Desktop/Proyecto-Final/data/2019_09_14.s', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_deinterleave_0 = blocks.deinterleave( gr.sizeof_float * 1, 1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((10, )) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0_0_0 = analog.agc_ff(1e-5, 1, 0.5) self.analog_agc_xx_0_0_0.set_max_gain(4e3) self.analog_agc_xx_0_0 = analog.agc_ff(1e-5, 1, 0.5) self.analog_agc_xx_0_0.set_max_gain(4e3) self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1, 1) self.analog_agc_xx_0.set_max_gain(4e3) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_agc_xx_0_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_agc_xx_0_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_deinterleave_0, 0), (self.analog_agc_xx_0_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.analog_agc_xx_0_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 1), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 3), (self.qtgui_time_sink_x_0, 2)) self.connect((self.digital_symbol_sync_xx_0, 2), (self.qtgui_time_sink_x_0, 1)) self.connect((self.fir_filter_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_symbol_sync_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.qtgui_freq_sink_x_0_0, 0))
def __init__(self, baudrate=9600, costas_loop_bw=2*math.pi/200, excess_bw=0.5, fll_loop_bw=2*math.pi/350, max_cfo=4e3, rf_samp_rate=2.4e6, symbol_Sync_loop_bw=2*math.pi/100): gr.hier_block2.__init__(self, "bpsk_ax25_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signaturev(3, 3, [gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1]) ) # Output signature self.message_port_register_hier_out("out") ################################################## # Parameters ################################################## self.baudrate = baudrate self.costas_loop_bw = costas_loop_bw self.excess_bw = excess_bw self.fll_loop_bw = fll_loop_bw self.max_cfo = max_cfo self.rf_samp_rate = rf_samp_rate self.symbol_Sync_loop_bw = symbol_Sync_loop_bw ################################################## # Variables ################################################## self.samp_rate = samp_rate = 9600*20 self.sps = sps = int(samp_rate/baudrate) self.nfilts = nfilts = 64 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), excess_bw, 11*sps*nfilts) self.bpsk_constellation = bpsk_constellation = digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( samp_rate/rf_samp_rate, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.low_pass_filter_0_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, ((1.0 + excess_bw) * baudrate/2.0) + min(baudrate, abs(1000*1.2)), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, (max_cfo+baudrate/2), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, (max_cfo+baudrate/2), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.hsl_rms_agc_0 = hsl.rms_agc(alpha=1e-2, reference=0.5, ) self.hsl_kiss_encoder_0 = hsl.kiss_encoder() self.digital_symbol_sync_xx_0_0 = digital.symbol_sync_cc(digital.TED_SIGNUM_TIMES_SLOPE_ML, sps, symbol_Sync_loop_bw, 1/math.sqrt(2.0), 1, 2*math.pi/100, 1, digital.constellation_bpsk().base(), digital.IR_PFB_MF, nfilts, (rrc_taps)) self.digital_hdlc_deframer_bp_0_0 = digital.hdlc_deframer_bp(15, 500) self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(15, 500) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, excess_bw, 300, fll_loop_bw) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(costas_loop_bw, 2, False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(bpsk_constellation) self.blocks_not_xx_0_0_0 = blocks.not_bb() self.blocks_message_debug_0 = blocks.message_debug() self.blocks_and_const_xx_0_0_0 = blocks.and_const_bb(1) ################################################## # Connections ################################################## self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.hsl_kiss_encoder_0, 'packet')) self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'), (self.hsl_kiss_encoder_0, 'packet')) self.msg_connect((self.hsl_kiss_encoder_0, 'encoded_packet'), (self, 'out')) self.connect((self.blocks_and_const_xx_0_0_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.blocks_and_const_xx_0_0_0, 0), (self.digital_hdlc_deframer_bp_0_0, 0)) self.connect((self.blocks_not_xx_0_0_0, 0), (self.blocks_and_const_xx_0_0_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_symbol_sync_xx_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self, 1)) self.connect((self.digital_descrambler_bb_0, 0), (self.digital_hdlc_deframer_bp_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_not_xx_0_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.low_pass_filter_0_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self, 2)) self.connect((self.digital_symbol_sync_xx_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_symbol_sync_xx_0_0, 0), (self, 0)) self.connect((self.hsl_rms_agc_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.hsl_rms_agc_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.low_pass_filter_0_0_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))