def __init__(self, sps=8, bt=0.5, mod_idx=0.68): gr.hier_block2.__init__( self, "simple_modulator", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature # message ports self.message_port_register_hier_in("in") self.message_port_register_hier_out("out") # blocks self.pack = pdu_utils.pack_unpack(pdu_utils.MODE_UNPACK_BYTE, pdu_utils.BIT_ORDER_LSB_FIRST) self.preamble = pdu_utils.pdu_preamble([], [], sps, 0) modulation_index = mod_idx sensitivity = (pi * modulation_index) / sps gain = 1.0 taps = firdes.gaussian(gain, sps, bt, 5) self.gmsk = pdu_utils.pdu_gmsk_fc(sensitivity, taps) # connections self.msg_connect(self, "in", self.pack, "pdu_in") self.msg_connect(self.pack, "pdu_out", self.preamble, "pdu_in") self.msg_connect(self.preamble, "pdu_out", self.gmsk, "pdu_in") self.msg_connect(self.gmsk, "pdu_out", self, "out")
def set_baud_rate(self, baud_rate): self.baud_rate = baud_rate self.set_gaussian_taps( firdes.gaussian(1.5, 2 * (self.samp_rate / self.baud_rate), 0.5, 12)) self.digital_clock_recovery_mm_xx_0.set_omega( (self.samp_rate / self.baud_rate) * (1 + 0.0)) self.analog_quadrature_demod_cf_0.set_gain( 2 * (self.samp_rate / self.baud_rate) / (math.pi))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_gaussian_taps( firdes.gaussian(1.5, 2 * (self.samp_rate / self.baud_rate), 0.5, 12)) self.qtgui_waterfall_sink_x_0.set_frequency_range(0, self.samp_rate) self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate) self.digital_clock_recovery_mm_xx_0.set_omega( (self.samp_rate / self.baud_rate) * (1 + 0.0)) self.analog_quadrature_demod_cf_0.set_gain( 2 * (self.samp_rate / self.baud_rate) / (math.pi))
def setUp(self): self.tb = gr.top_block() self.emitter = pdu_utils.message_emitter() self.emitter2 = pdu_utils.message_emitter() self.pre = pdu_utils.pdu_preamble([], [], 8, 20, True) self.gmsk = pdu_utils.pdu_gmsk_fc(0.5, firdes.gaussian(1, 4, 0.35, 9)) self.debug = blocks.message_debug() self.tb.msg_connect((self.emitter, 'msg'), (self.pre, 'pdu_in')) self.tb.msg_connect((self.emitter2, 'msg'), (self.gmsk, 'pdu_in')) self.tb.msg_connect((self.pre, 'pdu_out'), (self.gmsk, 'pdu_in')) self.tb.msg_connect((self.gmsk, 'pdu_out'), (self.debug, 'store'))
def set_samples_per_symbol(self, samples_per_symbol): self.samples_per_symbol = samples_per_symbol self.set_sample_rate(self.symbol_rate * self.samples_per_symbol) self.set_sample_rate_tx(self.symbol_rate * self.samples_per_symbol * 25 / 6) self.qtgui_time_sink_x_0_0_0_0.set_samp_rate(self.symbol_rate * self.samples_per_symbol) self.qtgui_time_sink_x_0_0_0.set_samp_rate(self.symbol_rate * self.samples_per_symbol) self.qtgui_freq_sink_x_0.set_frequency_range( 0, self.symbol_rate * self.samples_per_symbol) self.interp_fir_filter_xxx_0.set_taps( (firdes.gaussian(1, self.samples_per_symbol / 2, 0.25, 100))) self.fm_modulator_0.set_samp_rate(self.symbol_rate * self.samples_per_symbol)
def __init__(self): fsk_source.__init__(self, mod_name="8gfsk", samp_per_sym=8) self.pack = blocks.packed_to_unpacked_bb(3, gr.GR_MSB_FIRST) self.map = digital.chunks_to_symbols_bf(np.linspace(-2, 2, 8), 1) # This design mirrors the internals of the GMSK mod block self.taps = np.convolve( firdes.gaussian(1, self.samp_per_sym, .35, 4 * self.samp_per_sym), (1, ) * self.samp_per_sym) self.filt = \ filter.interp_fir_filter_fff( self.samp_per_sym, self.taps, ) self.filt.declare_sample_delay(0) self.mod = analog.frequency_modulator_fc(1) self.connect(self.random_source, self.pack, self.map, self.filt, self.mod, self)
def __init__(self): gr.top_block.__init__(self, "FloripaSat-I Simulation Test") Qt.QWidget.__init__(self) self.setWindowTitle("FloripaSat-I Simulation Test") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fsat_simulation_test") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 1.2e3 self.samples_per_symbol = samples_per_symbol = 40 self.sample_rate_tx = sample_rate_tx = symbol_rate * samples_per_symbol * 25 / 6 self.nfilts = nfilts = 32 self.sample_rate_rx = sample_rate_rx = sample_rate_tx * 6 / 5 self.sample_rate = sample_rate = symbol_rate * samples_per_symbol self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(40), 0.35, 45 * nfilts) self.pi = pi = numpy.pi self.phase_shift = phase_shift = 0 self.noise_amp = noise_amp = 1e-6 self.modulation_sensitivity = modulation_sensitivity = 4e3 self.freq_shift = freq_shift = 1e3 ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'Spectrum') self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, 'Time') self.top_layout.addWidget(self.tabs) self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_f( 11200, #size symbol_rate * samples_per_symbol, #samp_rate "Signal", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-1.2, 1.2) self.qtgui_time_sink_x_0_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0_0_0.disable_legend() labels = [ "Transmitted", "Received", "Transmitted", '', '', '', '', '', '', '' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_0_0_win, 3, 0, 7, 1) [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(3, 10)] [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 280, #size symbol_rate * samples_per_symbol, #samp_rate "Message", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-1.2, 1.2) self.qtgui_time_sink_x_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_0_win, 10, 0, 7, 1) [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(10, 17)] [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sample_rate, #bw "Received Signal", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0.set_y_axis(-180, 10) self.qtgui_freq_sink_x_0_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 1, 0, 1, 1) [self.tabs_grid_layout_0.setRowStretch(r, 1) for r in range(1, 2)] [self.tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sample_rate, #bw "Transmitted Signal", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-180, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 0, 1, 1) [self.tabs_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [self.tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc symbol_rate * samples_per_symbol, #bw "Demodulated Signal", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-180, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 1, 1) [self.tabs_grid_layout_0.setRowStretch(r, 1) for r in range(2, 3)] [self.tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1)] self._phase_shift_range = Range(0, 2 * pi, 0.01, 0, 200) self._phase_shift_win = RangeWidget(self._phase_shift_range, self.set_phase_shift, "Channel Phase Shift", "counter_slider", float) self.tabs_grid_layout_1.addWidget(self._phase_shift_win, 1, 0, 1, 1) [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(1, 2)] [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)] self._noise_amp_range = Range(1e-6, 0.1, 1e-6, 1e-6, 200) self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, "Channel Noise Amplitude", "counter_slider", float) self.tabs_grid_layout_1.addWidget(self._noise_amp_win, 2, 0, 1, 1) [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(2, 3)] [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)] self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff( 1, (firdes.gaussian(1, samples_per_symbol / 2, 0.25, 100))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self._freq_shift_range = Range(0, 100e3, 1e3, 1e3, 200) self._freq_shift_win = RangeWidget(self._freq_shift_range, self.set_freq_shift, "Channel Frequency Shift", "counter_slider", float) self.tabs_grid_layout_1.addWidget(self._freq_shift_win, 0, 0, 1, 1) [self.tabs_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [self.tabs_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1)] self.fm_modulator_0 = fm_modulator( modulation_sensitivity=modulation_sensitivity, samp_rate=symbol_rate * samples_per_symbol, ) self.fm_demodulator_0 = fm_demodulator( modulation_sensitivity=modulation_sensitivity, samp_rate=sample_rate, ) self.custom_symbol_sync_early_late_fb_0 = custom.symbol_sync_early_late_fb( samples_per_symbol, 1 / sample_rate, 0.01 * sample_rate, 0.707, 3.22) self.custom_rect_encoder_bf_0 = custom.rect_encoder_bf( samples_per_symbol) self.custom_frame_sync_bb_0 = custom.frame_sync_bb(([ 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0 ]), 32, 3) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, sample_rate, True) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_char * 1, '/home/rpa/code/FloripaSat-I-SDR-Receiver/Binary-Files/fsat-hello.bin', True) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fm_demodulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.custom_rect_encoder_bf_0, 0)) self.connect((self.custom_frame_sync_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.custom_rect_encoder_bf_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.custom_symbol_sync_early_late_fb_0, 0), (self.custom_frame_sync_bb_0, 0)) self.connect((self.fm_demodulator_0, 0), (self.custom_symbol_sync_early_late_fb_0, 0)) self.connect((self.fm_demodulator_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.fm_demodulator_0, 0), (self.qtgui_time_sink_x_0_0_0_0, 1)) self.connect((self.fm_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.fm_modulator_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "OPS-SAT UHF demodulator/decoder") Qt.QWidget.__init__(self) self.setWindowTitle("OPS-SAT UHF demodulator/decoder") 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", "os_demod_decode") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 57600 self.baud_rate = baud_rate = 9600 self.gaussian_taps = gaussian_taps = firdes.gaussian( 1.5, 2 * (samp_rate / baud_rate), 0.5, 12) self.gain_mu = gain_mu = 0.175 ################################################## # Blocks ################################################## self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1, 'tcp://127.0.0.1:5555', 100, False, -1) self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1, 'tcp://127.0.0.1:38211', 100, False, -1) self.satellites_strip_ax25_header_0 = satellites.strip_ax25_header() self.satellites_nrzi_decode_0 = satellites.nrzi_decode() self.satellites_hdlc_deframer_0_0 = satellites.hdlc_deframer( check_fcs=True, max_length=1000) self.satellites_decode_rs_0 = satellites.decode_rs(True, 0) self.satellites_check_address_0 = satellites.check_address( 'DP0OPS', "from") self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 512, #size firdes.WIN_HAMMING, #wintype 0, #fc samp_rate, #bw "OPS-SAT UHF BEACON", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.03) 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, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, (gaussian_taps)) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_descrambler_bb_0_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( (samp_rate / baud_rate) * (1 + 0.0), 0.25 * gain_mu * gain_mu, 0.5, gain_mu, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.digital_additive_scrambler_bb_0_0 = digital.additive_scrambler_bb( 0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key="packet_len") self.blocks_unpacked_to_packed_xx_0_0_0_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_tagged_stream_to_pdu_0_0_0_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'packet_len') 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.byte_t, 'packet_len') self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_message_debug_0 = blocks.message_debug() self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( 2 * (samp_rate / baud_rate) / (math.pi)) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 'pdus'), (self.satellites_decode_rs_0, 'in')) self.msg_connect((self.satellites_check_address_0, 'ok'), (self.satellites_strip_ax25_header_0, 'in')) self.msg_connect((self.satellites_decode_rs_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.satellites_decode_rs_0, 'out'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.satellites_hdlc_deframer_0_0, 'out'), (self.satellites_check_address_0, 'in')) self.msg_connect((self.satellites_strip_ax25_header_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_additive_scrambler_bb_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.zeromq_pub_sink_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0_0_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 0)) self.connect((self.digital_additive_scrambler_bb_0_0, 0), (self.blocks_unpacked_to_packed_xx_0_0_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.satellites_nrzi_decode_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0_0, 0), (self.satellites_hdlc_deframer_0_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.satellites_nrzi_decode_0, 0), (self.digital_descrambler_bb_0_0, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.qtgui_waterfall_sink_x_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") 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.Rb = Rb = 32000 self.vueltas_simbolo = vueltas_simbolo = 2 self.Tb = Tb = 1 / Rb self.Sps = Sps = 2 self.Bps = Bps = 1 self.samp_rate = samp_rate = Rb * Sps self.run_stop = run_stop = True self.ntaps = ntaps = 2 self.f1 = f1 = vueltas_simbolo / Tb self.bt = bt = 0.350 self.Tupdate = Tupdate = 1. / Rb self.Rs = Rs = Rb / Bps self.P = P = 0. self.F = F = 0. self.Ar = Ar = 0. self.A = A = 1. ################################################## # Blocks ################################################## self._P_range = Range(-2. * math.pi, 2. * math.pi, (4. * math.pi) / 360., 0., 200) self._P_win = RangeWidget(self._P_range, self.set_P, 'Fase', "counter_slider", float) self.top_grid_layout.addWidget(self._P_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Ar_range = Range(0, 4., (4.) / 50., 0., 200) self._Ar_win = RangeWidget(self._Ar_range, self.set_Ar, 'Ruido', "counter_slider", float) self.top_grid_layout.addWidget(self._Ar_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) _run_stop_check_box = Qt.QCheckBox('Inicial/Parar') self._run_stop_choices = {True: True, False: False} self._run_stop_choices_inv = dict( (v, k) for k, v in self._run_stop_choices.items()) self._run_stop_callback = lambda i: Qt.QMetaObject.invokeMethod( _run_stop_check_box, "setChecked", Qt.Q_ARG("bool", self._run_stop_choices_inv[i])) self._run_stop_callback(self.run_stop) _run_stop_check_box.stateChanged.connect( lambda i: self.set_run_stop(self._run_stop_choices[bool(i)])) self.top_grid_layout.addWidget(_run_stop_check_box, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "compararacion entre mensaje y EC", #name 3 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0_0_0_0.set_y_axis(-1.5, 1.5) self.qtgui_time_sink_x_0_0_0_0_0.set_y_label('Amplitud', 'volts') self.qtgui_time_sink_x_0_0_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_stem_plot(False) labels = ['Mensaje', '', '', '', '', '', '', '', '', ''] widths = [3, 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(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_0_win, 4, 1, 1, 2) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): 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(1.0) 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, 5, 0, 1, 1) for r in range(5, 6): 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( 8, #size '', #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(Tupdate) self.qtgui_const_sink_x_0.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_0.set_x_axis(-1.5, 1.5) 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) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [4, 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 range(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, 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.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc( Sps, firdes.gaussian(1.0, Rs, bt, ntaps)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.epy_block_0 = epy_block_0.blk() self.e_VCO_fase_fc_0 = e_VCO_fase_fc_0.blk() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(f1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_1 = blocks.complex_to_float(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 = blocks.add_vff(1) self.b_binary_bipolar_source_f_0 = b_binary_bipolar_source_f( Am=1., Spb=Sps, ) self.b_PSD_c_0_0 = b_PSD_c( Ensayos=1000000, Fc=0, N=1024, Ymax=6e-6, samp_rate_audio=samp_rate, ) self.top_grid_layout.addWidget(self.b_PSD_c_0_0, 5, 2, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.b_PSD_c_0 = b_PSD_c( Ensayos=1000000, Fc=f1, N=1024, Ymax=6e-6, samp_rate_audio=samp_rate, ) self.top_grid_layout.addWidget(self.b_PSD_c_0, 5, 1, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.analog_noise_source_x_1 = analog.noise_source_c( analog.GR_GAUSSIAN, Ar, 0) self.analog_const_source_x_0_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, P) self.analog_const_source_x_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 1) self._F_range = Range(-2.4, 2.4, (2 * 2.4) / 1000., 0., 200) self._F_win = RangeWidget(self._F_range, self.set_F, 'Frecuencia', "counter_slider", float) self.top_grid_layout.addWidget(self._F_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._A_range = Range(-1.5, 1.5, (1.5) / 100., 1., 200) self._A_win = RangeWidget(self._A_range, self.set_A, 'A', "counter_slider", float) self.top_grid_layout.addWidget(self._A_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) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0_0, 0), (self.e_VCO_fase_fc_0, 1)) self.connect((self.analog_const_source_x_0_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_noise_source_x_1, 0), (self.blocks_add_xx_1, 1)) self.connect((self.b_binary_bipolar_source_f_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.e_VCO_fase_fc_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0_0_0_0_0, 2)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0_0_0_0_0, 1)) self.connect((self.blocks_complex_to_float_1, 0), (self.epy_block_0, 0)) self.connect((self.blocks_complex_to_float_1, 0), (self.qtgui_time_sink_x_0_0_0_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.b_PSD_c_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.b_PSD_c_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.e_VCO_fase_fc_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.epy_block_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_complex_to_float_1, 0))
def set_Rs(self, Rs): self.Rs = Rs self.interp_fir_filter_xxx_0.set_taps( firdes.gaussian(1.0, self.Rs, self.bt, self.ntaps))
def set_bt(self, bt): self.bt = bt self.interp_fir_filter_xxx_0.set_taps( firdes.gaussian(1.0, self.Rs, self.bt, self.ntaps))
def __init__(self, samp_rate, tune_offset, source, sink, sw_gain=0, sym_rate=10e3, deviation=20e3): gr.top_block.__init__(self, "Auto BER Test") self.source = source self.sink = sink ################################################## # Variables ################################################## self.sym_rate = sym_rate self.samp_per_sym = samp_per_sym = int(samp_rate / sym_rate) self.bt = bt = 0.5 self.gaussian_taps = gaussian_taps = firdes.gaussian( 1.0, samp_per_sym, bt, 4 * samp_per_sym) self.tx_taps = tx_taps = numpy.convolve( numpy.array(gaussian_taps), numpy.array((1, ) * samp_per_sym)) self.tx_deviation = tx_deviation = deviation self.sw_gain = sw_gain ################################################## # Blocks ################################################## # Disable CRC generation to make sure we're in the right CRC_ENABLE mode self.var_len_packet_creator = si446x.var_len_packet_creator( 8, 0x2DD4, True, 0x0000) self.pdu_to_tagged_stream = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.uchar_to_float = blocks.uchar_to_float() self.sub_one_half = blocks.add_const_vff((-0.5, )) self.mult_two = blocks.multiply_const_vff((2, )) self.gaussian_filter = filter.interp_fir_filter_fff( samp_per_sym, (tx_taps)) self.gaussian_filter.declare_sample_delay(0) self.freq_xlating_fir_filter = filter.freq_xlating_fir_filter_ccc( 1, ([10**(sw_gain / 20.0)]), tune_offset, samp_rate) self.freq_mod = analog.frequency_modulator_fc(2 * math.pi * tx_deviation / samp_rate) ################################################## # Connections ################################################## self.msg_connect((self.source, 'out'), (self.var_len_packet_creator, 'in')) self.msg_connect((self.var_len_packet_creator, 'out'), (self.pdu_to_tagged_stream, 'pdus')) self.connect((self.pdu_to_tagged_stream, 0), (self.uchar_to_float, 0)) self.connect((self.freq_mod, 0), (self.freq_xlating_fir_filter, 0)) self.connect((self.freq_xlating_fir_filter, 0), (self.sink, 0)) self.connect((self.gaussian_filter, 0), (self.freq_mod, 0)) self.connect((self.mult_two, 0), (self.gaussian_filter, 0)) self.connect((self.sub_one_half, 0), (self.mult_two, 0)) self.connect((self.uchar_to_float, 0), (self.sub_one_half, 0))
def __init__(self): gr.top_block.__init__(self, "Impulse Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("Impulse Receiver") 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", "impulse_receiver") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 200e6 self.bandwidth = bandwidth = 20e6 self.transition = transition = 5e6 self.center_freq = center_freq = -samp_rate / 2.0 + 2 * bandwidth self.rx_taps = rx_taps = firdes.complex_band_pass( 1, samp_rate, center_freq - bandwidth / 2.0, center_freq + bandwidth / 2.0, transition) self.ntaps = ntaps = len(rx_taps) ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.01) self.qtgui_time_sink_x_0.set_y_axis(-0.5, 1.5) 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, 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 = [ 'Re{Tx}', 'Im{Tx}', 'Re{Rx}', 'Im{Rx}', '', '', '', '', '', '' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "cyan", "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(4): 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 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.01) self.qtgui_freq_sink_x_0.set_y_axis(-200, -20) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(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 = ['Tx', 'Rx', '', '', '', '', '', '', '', ''] 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fir_filter_xxx_0 = filter.fir_filter_ccf( 1, (firdes.gaussian(12, 8, 0.25, 51))) self.fir_filter_xxx_0.declare_sample_delay(0) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (rx_taps), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self._center_freq_range = Range(-samp_rate / 2.0 + 2 * bandwidth, samp_rate / 2.0 - 2 * bandwidth, samp_rate / 100.0, -samp_rate / 2.0 + 2 * bandwidth, 200) self._center_freq_win = RangeWidget(self._center_freq_range, self.set_center_freq, 'Center Frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._center_freq_win) self.blocks_vector_source_x_0 = blocks.vector_source_c( 511 * [ 0, ] + [ 1, ] + 512 * [ 0, ], True, 1, []) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate / 100.0, True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, 0.02, 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.fir_filter_xxx_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0))