def setup_bpsk0(self): self.tb = gr.top_block() # Build the constellation object arity = 2 bps = 1 pts, code = digital.psk_2_0x0() constellation = digital.constellation_psk(pts, code, 2) # Create BPSK data to pass to the demodulator src = blocks.vector_source_b(self.src_data_bpsk) p2u = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) mod = digital.generic_mod(constellation, True, self.sps, True, self.eb) snk = blocks.vector_sink_c() tb = gr.top_block() tb.connect(src, p2u, mod, snk) tb.run() self.src = blocks.vector_source_c(snk.data()) self.freq_recov = digital.fll_band_edge_cc(self.sps, self.eb, self.fll_ntaps, self.freq_bw) self.time_recov = digital.pfb_clock_sync_ccf(self.sps, self.timing_bw, self.taps, self.nfilts, self.nfilts//2, self.timing_max_dev) self.receiver = digital.constellation_receiver_cb( constellation.base(), self.phase_bw, self.fmin, self.fmax) self.diffdec = digital.diff_decoder_bb(arity) self.symbol_mapper = digital.map_bb( mod_codes.invert_code(constellation.pre_diff_code())) self.unpack = blocks.unpack_k_bits_bb(bps) self.snk = blocks.null_sink(gr.sizeof_char) self.tb.connect(self.src, self.freq_recov, self.time_recov, self.receiver) self.tb.connect(self.receiver, self.diffdec, self.symbol_mapper, self.unpack) self.tb.connect(self.unpack, self.snk)
def setup_8psk0(self): self.tb = gr.top_block() constellation = digital.psk_constellation(8) self.src = blocks.vector_source_b(self.src_data_8psk) self.p2u = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.mod = digital.generic_mod(constellation, True, self.sps, True, self.eb) self.snk = blocks.null_sink(gr.sizeof_gr_complex) self.tb.connect(self.src, self.p2u, self.mod, self.snk)
def __init__(self, constellation, samples_per_symbol, differential, excess_bw, gray_coded, verbose, log): gr.hier_block2.__init__(self, "bert_transmit", gr.io_signature(0, 0, 0), # Output signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Input signature # Create BERT data bit stream self._bits = gr.vector_source_b([1,], True) # Infinite stream of ones self._scrambler = gr.scrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit scrambler self._mod = digital.generic_mod(constellation, samples_per_symbol, differential, excess_bw, gray_coded, verbose, log) self._pack = gr.unpacked_to_packed_bb(self._mod.bits_per_symbol(), gr.GR_MSB_FIRST) self.connect(self._bits, self._scrambler, self._pack, self._mod, self)
def __init__(self): gr.top_block.__init__(self, "Test Corr And Sync") Qt.QWidget.__init__(self) self.setWindowTitle("Test Corr And Sync") 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", "test_corr_and_sync") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.time_offset = time_offset = 1 self.samp_rate = samp_rate = 100000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), eb, 5*sps*nfilts) self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase = phase = 0 self.payload_size = payload_size = 992 self.noise = noise = 0 self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.gap = gap = 20000 self.freq_offset = freq_offset = 0 self.constel = constel = digital.constellation_calcdist(([1,- 1]), ([0,1]), 2, 1).base() self.bb_filter = bb_filter = firdes.root_raised_cosine(sps, sps, 1, eb, 101) ################################################## # Blocks ################################################## self._time_offset_layout = Qt.QVBoxLayout() self._time_offset_label = Qt.QLabel("Timing Offset") self._time_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._time_offset_slider.setRange(0.995, 1.005, 0.00001) self._time_offset_slider.setValue(self.time_offset) self._time_offset_slider.setMinimumWidth(200) self._time_offset_slider.valueChanged.connect(self.set_time_offset) self._time_offset_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._time_offset_layout.addWidget(self._time_offset_label) self._time_offset_layout.addWidget(self._time_offset_slider) self.top_grid_layout.addLayout(self._time_offset_layout, 4,1,1,1) self._noise_layout = Qt.QVBoxLayout() self._noise_label = Qt.QLabel("Noise") self._noise_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_slider.setRange(0, 1, 0.005) self._noise_slider.setValue(self.noise) self._noise_slider.setMinimumWidth(200) self._noise_slider.valueChanged.connect(self.set_noise) self._noise_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._noise_layout.addWidget(self._noise_label) self._noise_layout.addWidget(self._noise_slider) self.top_grid_layout.addLayout(self._noise_layout, 3,0,1,1) self._freq_offset_layout = Qt.QVBoxLayout() self._freq_offset_label = Qt.QLabel("Frequency Offset") self._freq_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_offset_slider.setRange(-0.001, 0.001, 0.00002) self._freq_offset_slider.setValue(self.freq_offset) self._freq_offset_slider.setMinimumWidth(200) self._freq_offset_slider.valueChanged.connect(self.set_freq_offset) self._freq_offset_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._freq_offset_layout.addWidget(self._freq_offset_label) self._freq_offset_layout.addWidget(self._freq_offset_slider) self.top_grid_layout.addLayout(self._freq_offset_layout, 4,0,1,1) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 80000, #size samp_rate, #samp_rate "QT GUI Plot", #name 3 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-200, 400) self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 200, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) labels = ["|corr|^2", "Re{corr}", "Im{corr}", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1,0,1,2) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 50000, #size samp_rate, #samp_rate "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 1, 0.1, 0, "time_est") self.qtgui_time_sink_x_0.enable_autoscale(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", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0,0,1,1) (self.qtgui_time_sink_x_0).set_processor_affinity([0]) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1000, #size "QT GUI Plot", #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_TAG, qtgui.TRIG_SLOPE_POS, 0, 0, "time_est") self.qtgui_const_sink_x_0.enable_autoscale(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0,1,1,1) self._phase_layout = Qt.QVBoxLayout() self._phase_label = Qt.QLabel("Phase offset") self._phase_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_slider.setRange(-2*scipy.pi, 2*scipy.pi, 0.1) self._phase_slider.setValue(self.phase) self._phase_slider.setMinimumWidth(200) self._phase_slider.valueChanged.connect(self.set_phase) self._phase_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._phase_layout.addWidget(self._phase_label) self._phase_layout.addWidget(self._phase_slider) self.top_grid_layout.addLayout(self._phase_layout, 3,1,1,1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*3.14/100.0, (rrc_taps), nfilts, 0, 0.5, 1) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(1*3.14/50.0, 2) self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble), (matched_filter), sps) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constel, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=eb, verbose=False, log=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq_offset, epsilon=time_offset, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b(map(lambda x: (-x+1)/2, preamble), True, 1, []) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)/8,payload_size)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, ((len(preamble)+8*payload_size)*sps, gap)) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_source_0_0 = blocks.null_source(gr.sizeof_gr_complex*1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 100000)), True) ################################################## # Connections ################################################## self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_null_source_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_1, 2)) self.connect((self.channels_channel_model_0, 0), (self.digital_correlate_and_sync_cc_0, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_stream_mux_0_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_mux_0_0_0, 1)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "WDA Channel Simulator v2") Qt.QWidget.__init__(self) self.setWindowTitle("WDA Channel Simulator v2") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 200 self.excess_bw = excess_bw = 0.35 self.QAM = QAM = digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base() self.symbol_reflection_offset = symbol_reflection_offset = 0 self.symbol_reflection_ampl = symbol_reflection_ampl = 0 self.samp_rate = samp_rate = 1e6 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( 1, sps, 1, excess_bw, 45) self.refl_delay = refl_delay = 0 self.refl_amplitude = refl_amplitude = 0 self.noise_level = noise_level = 0 self.max_phase_offset_ratio = max_phase_offset_ratio = 1 self.direct_amplitude = direct_amplitude = 1 self.constellation = constellation = QAM self.carrier_frequency = carrier_frequency = 10e3 self.bits_per_symbol = bits_per_symbol = 2 self.PSK = PSK = digital.constellation_calcdist(([1 + 0j, -1 + 0j]), ([0, 1]), 2, 1).base() ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "Time") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "Frequency") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "Windowed Constellation") self.top_grid_layout.addWidget(self.tab, 0, 0, 1, 7) self._symbol_reflection_offset_range = Range(0, 1, 0.01, 0, 100) self._symbol_reflection_offset_win = RangeWidget( self._symbol_reflection_offset_range, self.set_symbol_reflection_offset, "Offset (% of Symbol)", "counter_slider", float) self.top_grid_layout.addWidget(self._symbol_reflection_offset_win, 3, 5, 1, 3) self._symbol_reflection_ampl_range = Range(0, 1, 0.001, 0, 100) self._symbol_reflection_ampl_win = RangeWidget( self._symbol_reflection_ampl_range, self.set_symbol_reflection_ampl, "Distant Reflection Amplitude", "counter_slider", float) self.top_grid_layout.addWidget(self._symbol_reflection_ampl_win, 3, 0, 1, 5) self._refl_delay_range = Range(0, 360, 1, 0, 100) self._refl_delay_win = RangeWidget(self._refl_delay_range, self.set_refl_delay, "Phase Offset (Degrees)", "counter_slider", float) self.top_grid_layout.addWidget(self._refl_delay_win, 2, 5, 1, 3) self._refl_amplitude_range = Range(0, 1, 0.001, 0, 100) self._refl_amplitude_win = RangeWidget(self._refl_amplitude_range, self.set_refl_amplitude, "Nearby Reflection Amplitude", "counter_slider", float) self.top_grid_layout.addWidget(self._refl_amplitude_win, 2, 0, 1, 5) self._noise_level_range = Range(0, 160, 1, 0, 100) self._noise_level_win = RangeWidget(self._noise_level_range, self.set_noise_level, "Noise Level (dB)", "counter_slider", float) self.top_grid_layout.addWidget(self._noise_level_win, 4, 0, 1, 8) self._direct_amplitude_range = Range(0, 1, 0.01, 1, 1000) self._direct_amplitude_win = RangeWidget( self._direct_amplitude_range, self.set_direct_amplitude, "Transmitted Signal Amplitude", "counter_slider", float) self.top_grid_layout.addWidget(self._direct_amplitude_win, 1, 0, 1, 8) self.up_convert = blocks.multiply_vcc(1) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=sps, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=sps, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Transmitted and Received Signals", #name 5 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-3, 3) self.qtgui_time_sink_x_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_control_panel(True) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = [ "Transmitted Signal", "Nearby Reflection", "Distant Reflection", "Noise", "Channel Total", "", "", "", "", "" ] 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(5): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Transmitted and Received Signals", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-200, 0) 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_control_panel(True) 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 = [ "Received Signal", "Transmitted Signal", "", "", "", "", "", "", "", "" ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 512, #size "Windowed Constellation", #name 2 #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.75, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = [ "Decoded Data", "Expected Data", "", "", "", "", "", "", "", "" ] 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, 2, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [0.5, 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_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_const_sink_x_0_win) self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(1, (rrc_taps)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.down_convert = blocks.multiply_vcc(1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constellation, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=True, log=False, ) self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb( constellation) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( constellation) self.carrier_source_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -carrier_frequency, 1, 0) self.carrier_source = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, carrier_frequency, 1, 0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc( (symbol_reflection_ampl, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc( (refl_amplitude, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (direct_amplitude, )) self.blocks_delay_2_0 = blocks.delay(gr.sizeof_gr_complex * 1, sps / 4) self.blocks_delay_2 = blocks.delay(gr.sizeof_gr_complex * 1, sps / 4) self.blocks_delay_0_0 = blocks.delay( gr.sizeof_gr_complex * 1, int(symbol_reflection_offset * sps)) self.blocks_delay_0 = blocks.delay( gr.sizeof_gr_complex * 1, int(refl_delay / 360.0 * samp_rate / carrier_frequency)) self.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex * 1) self.blocks_copy_0.set_enabled(True) self.blocks_complex_to_real_1_1_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_1_1 = blocks.complex_to_real(1) self.blocks_complex_to_real_1_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_1_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='SER', win_size=20000, bits_per_symbol=bits_per_symbol, ) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2**bits_per_symbol, 10000)), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0.000001 * 10**(noise_level / 20), 0) self.SER = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1) self.SER.set_update_time(1.5) self.SER.set_title("") labels = ["SER", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.SER.set_min(i, 0) self.SER.set_max(i, 1) self.SER.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.SER.set_label(i, "Data {0}".format(i)) else: self.SER.set_label(i, labels[i]) self.SER.set_unit(i, units[i]) self.SER.set_factor(i, factor[i]) self.SER.enable_autoscale(False) self._SER_win = sip.wrapinstance(self.SER.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._SER_win, 0, 7, 1, 1) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 3)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_complex_to_real_1_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.SER, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_complex_to_real_1_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.down_convert, 1)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_complex_to_real_1_0, 0), (self.qtgui_time_sink_x_1, 4)) self.connect((self.blocks_complex_to_real_1_0_0, 0), (self.qtgui_time_sink_x_1, 3)) self.connect((self.blocks_complex_to_real_1_1, 0), (self.qtgui_time_sink_x_1, 2)) self.connect((self.blocks_complex_to_real_1_1_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_copy_0, 0), (self.blocks_delay_2, 0)) self.connect((self.blocks_copy_0, 0), (self.digital_constellation_decoder_cb_1, 0)) self.connect((self.blocks_copy_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_delay_2, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_delay_2_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 2)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_complex_to_real_1_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_complex_to_real_1_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.up_convert, 0)) self.connect((self.carrier_source, 0), (self.blocks_throttle_0, 0)) self.connect((self.carrier_source_0, 0), (self.down_convert, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.digital_constellation_decoder_cb_1, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_constellation_modulator_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.down_convert, 0), (self.blocks_delay_2_0, 0)) self.connect((self.down_convert, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.down_convert, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_copy_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.up_convert, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.up_convert, 0), (self.blocks_multiply_const_vxx_0, 0))
def set_qpsk(self, qpsk): self.qpsk = qpsk self.set_rxmod( digital.generic_mod(self.qpsk, False, self.base_sps, False, self.excess_bw, False, False))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 45 self.nfilts = nfilts = 25 self.sps_slider = sps_slider = 45 self.samp_rate_0 = samp_rate_0 = 44.1E3 self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts) self.fc_slider = fc_slider = 2200 self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base() self.A_slider = A_slider = 1 ################################################## # Blocks ################################################## self._sps_slider_range = Range(0, 100, 5, 45, 200) self._sps_slider_win = RangeWidget(self._sps_slider_range, self.set_sps_slider, "sps", "counter_slider", float) self.top_layout.addWidget(self._sps_slider_win) self._fc_slider_range = Range(0, 18200, 200, 2200, 150) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, "fc", "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) self._A_slider_range = Range(0, 20, 1, 1, 200) self._A_slider_win = RangeWidget(self._A_slider_range, self.set_A_slider, "A", "counter_slider", int) self.top_layout.addWidget(self._A_slider_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-2, 2) self.qtgui_time_sink_x_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) 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_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_1 = 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_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_1_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_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_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) 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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=True, samples_per_symbol=sps_slider, pre_diff_code=True, excess_bw=0.25, verbose=False, log=False, ) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=1240, server=True, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble="", access_code="", pad_for_usrp=False, ), payload_length=1, ) self.audio_sink_0 = audio.sink(44100, "", True) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, fc_slider, A_slider, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.qtgui_time_sink_x_1, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage1") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage1") 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", "mpsk_stage1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 2 self.excess_bw = excess_bw = 0.10 self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(1, sps, 1, excess_bw, 45) self.bpsk = bpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j]), ([0, 1,]), 2, 2, 0, 1, 0).base() self.arity = arity = 4 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(2.4175e9, 0) self.uhd_usrp_sink_0.set_gain(28, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0.set_bandwidth(100e3, 0) self.digital_crc32_bb_0 = digital.crc32_bb(False, "packet_len") self.digital_constellation_modulator_0 = digital.generic_mod( constellation=bpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 8, "packet_len") self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=8, preamble="", access_code="", pad_for_usrp=True, ), payload_length=0, ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_constellation_modulator_0, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage3") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage3") 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", "mpsk_stage3") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 8 self.payload = payload = range(256) self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.taps = taps = [1.0 + 0.0j, ] self.samp_rate = samp_rate = 250e3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts) self.qpsk_const = qpsk_const = digital.constellation_rect(([-1, +1]), ([0, 1]), 1, 2, 1, 1, 1).base() self.payload_str = payload_str = ''.join(map(lambda x: "{0:08b}".format(x), payload)) self.gain = gain = 50 self.freq = freq = 2.3e9 self.excess_bw = excess_bw = 0.35 self.delay = delay = 32 self.decim = decim = 1 self.arity = arity = 2 self.access_code_str = access_code_str = "1111100110101" self.access_code = access_code = [31, 53] ################################################## # Blocks ################################################## self._delay_layout = Qt.QVBoxLayout() self._delay_tool_bar = Qt.QToolBar(self) self._delay_layout.addWidget(self._delay_tool_bar) self._delay_tool_bar.addWidget(Qt.QLabel("delay"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._delay_counter = qwt_counter_pyslot() self._delay_counter.setRange(0, 100, 1) self._delay_counter.setNumButtons(2) self._delay_counter.setValue(self.delay) self._delay_tool_bar.addWidget(self._delay_counter) self._delay_counter.valueChanged.connect(self.set_delay) self._delay_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._delay_slider.setRange(0, 100, 1) self._delay_slider.setValue(self.delay) self._delay_slider.setMinimumWidth(200) self._delay_slider.valueChanged.connect(self.set_delay) self._delay_layout.addWidget(self._delay_slider) self.top_layout.addLayout(self._delay_layout) self.west_stream_trigged_pdu_0 = west.stream_trigged_pdu("start_payload", 2048) self.west_ber_pdu_0 = west.ber_pdu(payload_str) self._timing_loop_bw_layout = Qt.QVBoxLayout() self._timing_loop_bw_label = Qt.QLabel("Time: BW") self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005) self._timing_loop_bw_slider.setValue(self.timing_loop_bw) self._timing_loop_bw_slider.setMinimumWidth(200) self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw) self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider) self.top_grid_layout.addLayout(self._timing_loop_bw_layout, 3,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_1_0 = qtgui.const_sink_c( 1024, #size "Equalizer", #name 1 #number of inputs ) self.qtgui_const_sink_x_1_0.set_update_time(0.10) self.qtgui_const_sink_x_1_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1_0.enable_autoscale(False) self.qtgui_const_sink_x_1_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_0_win = sip.wrapinstance(self.qtgui_const_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "Clock Sync Output", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 2048, #size "Costas Loop Output", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) 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, 0,1,1,1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( 1, taps=(rrc_taps[:-1]), flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("RF gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 90, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 90, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.015, 2) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb(access_code_str, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) (self.digital_constellation_modulator_0).set_processor_affinity([2]) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk_const) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(16, 1, 0.15/100., 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(sps*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([135, 201]*5000 + access_code + payload*100000, False, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.0001, )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_char*1, int(delay)) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 0.3, 0, 8192) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-1, 1.0, 1) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.west_stream_trigged_pdu_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.west_stream_trigged_pdu_0, "pdus", self.west_ber_pdu_0, "pdus")
def __init__( self, EbN0=0, element_error=0, esprit_decimation=128, fc=436e6, mx=4, my=4, n=1, phi=50, rs_decimation=8, theta=30, ): gr.top_block.__init__(self, "BER Simulation") ################################################## # Parameters ################################################## self.EbN0 = EbN0 self.element_error = element_error self.esprit_decimation = esprit_decimation self.fc = fc self.mx = mx self.my = my self.n = n self.phi = phi self.rs_decimation = rs_decimation self.theta = theta ################################################## # Variables ################################################## self.sps = sps = 5 self.N_BITS = N_BITS = 1e7 self.samp_rate = samp_rate = 32000 self.noise_voltage = noise_voltage = 1.0 / math.sqrt( 1 / float(sps) * 10**(float(EbN0) / 10)) self.intdump_decim = intdump_decim = min(int(N_BITS / 10), 100000) self.const = const = digital.constellation_bpsk().base() self.alpha = alpha = 0.35 self.SKIP = SKIP = 1000 self.RAND_SEED = RAND_SEED = 42 ################################################## # Blocks ################################################## self.lilacsat1_ber_bpsk_0 = lilacsat1_ber_bpsk( bfo=12000, callsign="", ip="::", latitude=0, longitude=0, port=7355, recstart="", ) self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, ( 0, 0, (1 + 1j) / numpy.sqrt(2), )) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=const, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=alpha, verbose=False, log=False, ) self.blocks_vector_source_x_0 = blocks.vector_source_b([1], True, 1, []) self.blocks_vector_sink_x_0 = blocks.vector_sink_f(1, 1024) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, SKIP) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_not_xx_0 = blocks.not_bb() self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(0.1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff( 1.0 / intdump_decim) self.blocks_integrate_xx_0 = blocks.integrate_ff(intdump_decim, 1) self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, int(N_BITS)) self.blocks_and_const_xx_0 = blocks.and_const_bb(1) self.blocks_add_xx_0 = blocks.add_vcc(mx * my) self.beamforming_randomsampler_0 = beamforming.randomsampler( mx * my, rs_decimation) self.beamforming_phasedarray_0 = beamforming.phasedarray( mx, my, theta, phi, fc, (299792458 / (2 * fc)), element_error) self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf( mx, my, fc, (299792458 / (2 * fc)), n, 128) self.beamforming_beamformer_0 = beamforming.beamformer(mx, my, 0) self.analog_vectornoise_source_0 = analog.vectornoise_source( noise_voltage, mx * my) ################################################## # Connections ################################################## self.msg_connect( (self.beamforming_doaesprit_py_cf_0, "doa_port"), (self.beamforming_beamformer_0, "doa_port"), ) self.connect((self.analog_vectornoise_source_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.beamforming_beamformer_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.beamforming_phasedarray_0, 0), (self.blocks_add_xx_0, 0)) self.connect( (self.beamforming_randomsampler_0, 0), (self.beamforming_doaesprit_py_cf_0, 0), ) self.connect((self.blocks_add_xx_0, 0), (self.beamforming_beamformer_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.beamforming_randomsampler_0, 0)) self.connect((self.blocks_and_const_xx_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_head_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_vector_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.lilacsat1_ber_bpsk_0, 0)) self.connect((self.blocks_not_xx_0, 0), (self.blocks_and_const_xx_0, 0)) self.connect( (self.blocks_pack_k_bits_bb_0, 0), (self.digital_constellation_modulator_0, 0), ) self.connect((self.blocks_skiphead_0, 0), (self.blocks_not_xx_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_head_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.beamforming_phasedarray_0, 0)) self.connect((self.lilacsat1_ber_bpsk_0, 0), (self.digital_diff_decoder_bb_0, 0))
def __init__(self, EbN0): gr.top_block.__init__(self, "BER Simulation") ################################################## # Variables ################################################## self.N_BITS = N_BITS = 1e5 self.EbN0 = EbN0 self.sps = sps = 5 self.samp_rate = samp_rate = 32000 self.noise_voltage = noise_voltage = 1.0 / math.sqrt( 1 / float(sps) * 10 ** (float(EbN0) / 10) ) self.intdump_decim = intdump_decim = min(int(N_BITS / 10), 100000) self.const = const = digital.constellation_bpsk().base() self.alpha = alpha = 0.35 self.SKIP = SKIP = 1000 self.RAND_SEED = RAND_SEED = 42 ################################################## # Blocks ################################################## self.lilacsat1_ber_bpsk_0 = lilacsat1_ber_bpsk( bfo=12000, callsign="", ip="::", latitude=0, longitude=0, port=7355, recstart="", ) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=const, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=alpha, verbose=False, log=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_voltage, frequency_offset=0.0, epsilon=1.0, taps=(0, 0, (1 + 1j) / numpy.sqrt(2),), noise_seed=RAND_SEED, block_tags=False, ) self.blocks_vector_source_x_0 = blocks.vector_source_b([1], True, 1, []) self.blocks_vector_sink_x_0 = blocks.vector_sink_f(1, 1024) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, SKIP) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_not_xx_0 = blocks.not_bb() self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(0.1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1.0 / intdump_decim) self.blocks_integrate_xx_0 = blocks.integrate_ff(intdump_decim, 1) self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, int(N_BITS)) self.blocks_and_const_xx_0 = blocks.and_const_bb(1) ################################################## # Connections ################################################## self.connect((self.blocks_and_const_xx_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_head_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect( (self.blocks_integrate_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0) ) self.connect( (self.blocks_multiply_const_vxx_0, 0), (self.blocks_vector_sink_x_0, 0) ) self.connect( (self.blocks_multiply_const_vxx_1, 0), (self.lilacsat1_ber_bpsk_0, 0) ) self.connect((self.blocks_not_xx_0, 0), (self.blocks_and_const_xx_0, 0)) self.connect( (self.blocks_pack_k_bits_bb_0, 0), (self.digital_constellation_modulator_0, 0), ) self.connect((self.blocks_skiphead_0, 0), (self.blocks_not_xx_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_head_0, 0)) self.connect( (self.channels_channel_model_0, 0), (self.blocks_multiply_const_vxx_1, 0) ) self.connect( (self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0), ) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_skiphead_0, 0)) self.connect( (self.digital_diff_decoder_bb_0, 0), (self.digital_descrambler_bb_0, 0) ) self.connect( (self.digital_diff_encoder_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0) ) self.connect( (self.digital_scrambler_bb_0, 0), (self.digital_diff_encoder_bb_0, 0) ) self.connect( (self.lilacsat1_ber_bpsk_0, 0), (self.digital_diff_decoder_bb_0, 0) )
def __init__(self): gr.top_block.__init__(self, "Soft Decoder Example") Qt.QWidget.__init__(self) self.setWindowTitle("Soft Decoder Example") 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", "constellation_soft_decoder") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.samp_rate = samp_rate = 100000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts) self.noise_volt = noise_volt = 0.0001 self.delay = delay = 29 self.constel = constel = digital.constellation_dqpsk().base() self.constel.gen_soft_dec_lut(8) self.arity = arity = 4 ################################################## # Blocks ################################################## self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Channel: Noise Voltage', "slider", float) self.top_grid_layout.addWidget(self._noise_volt_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._delay_options = ( 29, 58, 116, ) self._delay_labels = ( 'BPSK', 'QPSK', 'QAM16', ) self._delay_tool_bar = Qt.QToolBar(self) self._delay_tool_bar.addWidget(Qt.QLabel('Delay' + ": ")) self._delay_combo_box = Qt.QComboBox() self._delay_tool_bar.addWidget(self._delay_combo_box) for label in self._delay_labels: self._delay_combo_box.addItem(label) self._delay_callback = lambda i: Qt.QMetaObject.invokeMethod( self._delay_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._delay_options.index(i))) self._delay_callback(self.delay) self._delay_combo_box.currentIndexChanged.connect( lambda i: self.set_delay(self._delay_options[i])) self.top_grid_layout.addWidget(self._delay_tool_bar, 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.qtgui_time_sink_x_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate '', #name 3 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.05) self.qtgui_time_sink_x_0.set_y_axis(-1, 2) 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 = ['Soft', 'Hard', 'Orig', '', '', '', '', '', '', ''] 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, 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.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size '', #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance( self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_1_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 100.0, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_map_bb_0_0 = digital.map_bb((constel.pre_diff_code())) self.digital_constellation_soft_decoder_cf_0 = digital.constellation_soft_decoder_cf( constel) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constel, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( constel) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb( constel.bits_per_symbol()) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/Trasmited/trasmit_10_mb.txt', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_delay_0 = blocks.delay(gr.sizeof_char * 1, int(delay)) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) 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, 1)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_delay_0, 0), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_map_bb_0_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_map_bb_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_soft_decoder_cf_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_1, 0))
def __init__(self): gr.top_block.__init__(self, "Audio Modem1") Qt.QWidget.__init__(self) self.setWindowTitle("Audio Modem1") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "audio_modem1") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 50 self.nfilts = nfilts = 25 self.samp_rate = samp_rate = 32E3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts) self.BPSK = BPSK = digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "Bit Scope", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Up conversion", #name 2 #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: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "Rx", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1.6E3, .6E3, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, .063, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc( 8, .01, 1, BPSK) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.05, 2, False) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_throttle_1 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * 2, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/Testings/bin_test.txt', True) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/Testings/bin_test_output.txt', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char * 1, addr='127.0.0.1', port=9989, server=False, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=1, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code='', threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) self.audio_source_0 = audio.source(16000, '', True) self.audio_sink_0 = audio.sink(16000, '', True) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -4E3, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc( 1024, 1.55) ################################################## # Connections ################################################## self.connect((self.analog_feedforward_agc_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.blocks_throttle_1, 0), (self.analog_feedforward_agc_cc_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_throttle_1, 0))
def __init__(self): gr.top_block.__init__(self, "Qam Example") Qt.QWidget.__init__(self) self.setWindowTitle("Qam Example") 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", "qam_example") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.variable_constellation_0 = variable_constellation_0 = digital.constellation_qpsk( ).base() self.samp_rate = samp_rate = 500e3 self.freq = freq = 25e3 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(1.9e9, 0) self.uhd_usrp_source_0.set_gain(60, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(1.9e9, 0) self.uhd_usrp_sink_0.set_gain(20, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.digital_qam_demod_0 = digital.qam.qam_demod( constellation_points=4, differential=True, samples_per_symbol=8, excess_bw=0.009, freq_bw=0, timing_bw=0, phase_bw=0, mod_code="gray", verbose=False, log=False, ) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( 8, 0.002, (firdes.root_raised_cosine( 128, 128, 1.0 / float(4), 0.35, 45 * 128)), 32, 8, 1.5, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=variable_constellation_0, differential=True, samples_per_symbol=8, pre_diff_code=True, excess_bw=0.009, verbose=False, log=False, ) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((5, )) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_file_sink_1_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, './qpsk_tx_constellation.log', False) self.blocks_file_sink_1_0.set_unbuffered(False) self.blocks_file_sink_1 = blocks.file_sink( gr.sizeof_gr_complex * 1, './qpsk_rx_constellation.log', False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_float * 1, './qpsk_original_signal.log', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_float * 1, './qpsk_rx_decoded_signal.log', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_char_to_float_1 = blocks.char_to_float(1, 1) self.analog_random_source_x_0 = blocks.vector_source_s( map(int, numpy.random.randint(0, 2, 1000000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_char_to_float_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_file_sink_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_qam_demod_0, 0)) self.connect((self.digital_qam_demod_0, 0), (self.blocks_char_to_float_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
def __init__(self, host='127.0.0.1', iq_port=9094, tx_packet_filename='out_packets.bin'): gr.top_block.__init__(self, "Hurdle 1") ################################################## # Parameters ################################################## self.host = host self.iq_port = iq_port self.tx_packet_filename = tx_packet_filename ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 1000000 self.samp_rate = samp_rate = 4000000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( 1.0, samp_rate, symbol_rate, 0.35, 11 * 4) self.constellation_1 = constellation_1 = digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base() ################################################## # Blocks ################################################## self.hurdle1_zero_pad_0 = hurdle1.zero_pad(gr.sizeof_gr_complex, 'zero_pad') self.hurdle1_traffic_parser_0 = hurdle1.traffic_parser( 'pkt_len', 'zero_pad') self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constellation_1, differential=False, samples_per_symbol=samp_rate / symbol_rate, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink( gr.sizeof_gr_complex * 1, host, iq_port, False) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, tx_packet_filename, False) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 74500, 1, 0) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_tcp_server_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.hurdle1_traffic_parser_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.hurdle1_zero_pad_0, 0)) self.connect((self.hurdle1_traffic_parser_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.hurdle1_zero_pad_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tx Application") Qt.QWidget.__init__(self) self.setWindowTitle("Tx Application") 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", "tx_application") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.usrp_rf_freq = usrp_rf_freq = 2475e6 self.sps = sps = 4 self.samp_rate = samp_rate = 200000 self.qpsk = qpsk = digital.constellation_rect(([0.25*(0.707+0.707j),0.25*( -0.707+0.707j),0.25*( -0.707-0.707j), 0.25*(0.707-0.707j)]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble_qpsk = preamble_qpsk = map(lambda x: x*(1+1j)/pow(2,0.5), preamble) self.payload_size = payload_size = 100 self.length_tag_key = length_tag_key = "packet_len" self.header_len = header_len = 4 self.gain = gain = 26 self.eb = eb = 0.35 self.digital_gain = digital_gain = 1.0/4 self.crc_len = crc_len = 4 self.bps = bps = 2 self.addr = addr = "addr=192.168.60.2" ################################################## # Blocks ################################################## self._usrp_rf_freq_range = Range(2400e6, 2500e6, 100e3, 2475e6, 200) self._usrp_rf_freq_win = RangeWidget(self._usrp_rf_freq_range, self.set_usrp_rf_freq, "Rx Frequency", "counter_slider") self.top_layout.addWidget(self._usrp_rf_freq_win) self._gain_range = Range(0, 31.5, 0.5, 26, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "Tx Gain", "counter_slider") self.top_layout.addWidget(self._gain_win) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join((addr, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_sink_0_0.set_gain(gain, 0) self.uhd_usrp_sink_0_0.set_antenna("J1", 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype usrp_rf_freq, #fc samp_rate, #bw "QT GUI Plot", #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(-120, 20) 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_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(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_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qpsk_preamp_to_bits = blocks.vector_source_b(map(lambda x: int((x*(1j-1)/pow(2,0.5)).real+1), preamble_qpsk), True, 1, []) self.padded_bits = blocks.vector_source_b((0,0,0,0,0,0,0,0), True, 1, []) (self.padded_bits).set_block_alias("padded bits") self.digital_packet_headergenerator_bb_default_0 = digital.packet_headergenerator_bb(header_len*8, length_tag_key) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=eb, verbose=False, log=False, ) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, payload_size, length_tag_key) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)*bps/8,header_len,payload_size+crc_len,6)) self.blocks_pack_k_bits_bb_0_1 = blocks.pack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((digital_gain, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/users/lwei/GITfolder/wirelessacademy/BasicTxRx/wilabt/file_sent.txt", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0_1, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_0_1, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_packet_headergenerator_bb_default_0, 0), (self.blocks_pack_k_bits_bb_0_0, 0)) self.connect((self.padded_bits, 0), (self.blocks_stream_mux_0_0_0, 3)) self.connect((self.qpsk_preamp_to_bits, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_stream_mux_0_0_0, 2)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_packet_headergenerator_bb_default_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0_0, 0), (self.blocks_stream_mux_0_0_0, 1))
def __init__(self): gr.top_block.__init__(self, "Testing Ce") Qt.QWidget.__init__(self) self.setWindowTitle("Testing Ce") 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", "testing_ce") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, eb, 5*sps*nfilts) self.pld_const = pld_const = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base() self.pld_const.gen_soft_dec_lut(8) self.taps_per_filt = taps_per_filt = len(tx_rrc_taps)/nfilts self.samp_rate_array_MCR = samp_rate_array_MCR = [7500000,5000000,3750000,3000000,2500000,2000000,1500000,1000000,937500,882352,833333,714285,533333,500000,421052,400000,380952] self.rxmod = rxmod = digital.generic_mod(pld_const, False, sps, True, eb, False, False) self.rrc_taps = rrc_taps = firdes.root_raised_cosine(sps, sps, 1.0, eb, 11*sps) self.ac_hex = ac_hex = [0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc] self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 39 self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50 self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, eb, 11*sps*nfilts) self.rx_psf_taps = rx_psf_taps = firdes.root_raised_cosine(nfilts, sps*nfilts, 1.0, eb, 11*sps*nfilts) self.modulated_sync_word = modulated_sync_word = digital.modulate_vector_bc(rxmod .to_basic_block(), (ac_hex), ([1])) self.mark_delay = mark_delay = 87 self.frequencia_usrp = frequencia_usrp = 484e6 self.filt_delay_0 = filt_delay_0 = 1+(taps_per_filt-1)/2 self.filt_delay = filt_delay = 1+(len(rrc_taps)-1)/2 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 39, 200) self._variable_qtgui_range_0_1_win = RangeWidget(self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_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._variable_qtgui_range_0_range = Range(0, 90, 1, 50, 200) self._variable_qtgui_range_0_win = RangeWidget(self._variable_qtgui_range_0_range, self.set_variable_qtgui_range_0, 'Gain_TX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_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.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("serial=F5EAC0", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_source_0.set_gain(variable_qtgui_range_0_1, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("serial=F5EAE1", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "RX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_1_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 4, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 100*2, #size samp_rate, #samp_rate 'Rx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 512, #size 1, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-100, 4000) 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_TAG, qtgui.TRIG_SLOPE_POS, 0, 15, 0, 'corr_est') 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 False: self.qtgui_time_sink_x_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win, 3, 2, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 512, #size 1, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-100, 100) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0, 15, 0, 'corr_est') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 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.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c( 1024, #size "RX Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_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_0_0 = qtgui.const_sink_c( 1024, #size "TX Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_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_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_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.qtgui_const_sink_x_0 = qtgui.const_sink_c( 512, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not False: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 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.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=(tx_rrc_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(sps, 6.28/400.0, (rx_rrc_taps), nfilts, nfilts/2, 1.5, 1) self.digital_map_bb_0_0 = digital.map_bb((pld_const.pre_diff_code())) self.digital_map_bb_0 = digital.map_bb((pld_const.pre_diff_code())) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(6.28/100.0, pld_const.arity(), False) self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts(digital.packet_utils.default_access_code, 1, 'packet_len') self.digital_corr_est_cc_0 = digital.corr_est_cc((modulated_sync_word), sps, mark_delay, 0.99) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(pld_const) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((pld_const.points()), 1) self.blocks_stream_mux_0_1_0 = blocks.stream_mux(gr.sizeof_char*1, (96, 896)) self.blocks_repack_bits_bb_2 = blocks.repack_bits_bb(1, 8, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb(8, 1, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb(1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/andre/Desktop/Trasmited/trasmit_10_mb.txt', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0_0_2 = blocks.file_sink(gr.sizeof_char*1, '/home/andre/Desktop/Trasmited/depois.txt', False) self.blocks_file_sink_0_0_0_2.set_unbuffered(False) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.acode_1104 = blocks.vector_source_b([0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0)) self.connect((self.blocks_char_to_float_1_0_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_repack_bits_bb_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_correlate_access_code_xx_ts_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_1, 0), (self.digital_map_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_1, 0), (self.blocks_stream_mux_0_1_0, 1)) self.connect((self.blocks_repack_bits_bb_2, 0), (self.blocks_file_sink_0_0_0_2, 0)) self.connect((self.blocks_stream_mux_0_1_0, 0), (self.blocks_repack_bits_bb_0_1, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.digital_map_bb_0_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0), (self.blocks_char_to_float_1_0_1, 0)) self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0), (self.blocks_repack_bits_bb_2, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_map_bb_0_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Hop on Demand") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.tx_samp_rate = tx_samp_rate = 50e3 self.tx_freq = tx_freq = 100e6 self.sps = sps = 4 self.rx_samp_rate = rx_samp_rate = 2e6 self.rx_freq = rx_freq = 100e6 self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.excess_bw = excess_bw = 0.35 ################################################## # Blocks ################################################## self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1, "tcp://127.0.0.1:5557", 1000, False, -1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=rx_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=rx_samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot", peak_hold=True, ) self.Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(rx_samp_rate) self.uhd_usrp_source_0.set_center_freq(rx_freq, 0) self.uhd_usrp_source_0.set_gain(15, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(tx_samp_rate) self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0) self.uhd_usrp_sink_0.set_gain(30, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, rx_samp_rate, 1e6, 30e3, firdes.WIN_HAMMING, 6.76)) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.blocks_probe_signal_x_0 = blocks.probe_signal_c() self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.blocks_probe_signal_x_0, 0)) ### Added by Bill Urrego ### t = Thread(target=sub, args=(self.change_freq,)) t.start()
def set_sps(self, sps): self.sps = sps self.set_rxmod(digital.generic_mod(self.pld_const, False, self.sps, True, self.eb, False, False)) self.pfb_arb_resampler_xxx_0.set_rate(self.sps)
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage4") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage4") 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", "mpsk_stage4") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j], [0, 1, 2, 3], 4, 2, 2, 1, 1).base() self.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, 'Channel') self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, 'Receiver') self.top_grid_layout.addWidget(self.controls, 0, 0, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28/100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, 'Time: BW', "slider", float) self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0, 0, 1, 1) for r in range(0, 1): self.controls_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.controls_grid_layout_1.setColumnStretch(c, 1) self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Timing Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._time_offset_win, 0, 2, 1, 1) for r in range(0, 1): self.controls_grid_layout_0.setRowStretch(r, 1) for c in range(2, 3): self.controls_grid_layout_0.setColumnStretch(c, 1) self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Noise Voltage', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._noise_volt_win, 0, 0, 1, 1) for r in range(0, 1): self.controls_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.controls_grid_layout_0.setColumnStretch(c, 1) self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._freq_offset_win, 0, 1, 1, 1) for r in range(0, 1): self.controls_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.controls_grid_layout_0.setColumnStretch(c, 1) self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, 'Equalizer: rate', "slider", float) self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0, 1, 1, 1) for r in range(0, 1): self.controls_grid_layout_1.setRowStretch(r, 1) for c in range(1, 2): self.controls_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1 ) 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) labels = ['Equalized', '', '', '', '', '', '', '', '', ''] widths = [2, 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, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.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_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 = ['Timing Recov.', '', '', '', '', '', '', '', '', ''] widths = [2, 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, 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_const_sink_x_1 = qtgui.const_sink_c( 1024, #size '', #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) labels = ['Timing Recov.', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [0.6, 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_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_1_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size '', #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['Equalized', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [0.6, 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, 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.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, rrc_taps, nfilts, nfilts/2, 1.5, 2) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(11, 1, eq_gain, 2) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=taps, noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 256, 10000))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0))
def set_eb(self, eb): self.eb = eb self.set_rxmod(digital.generic_mod(self.pld_const, False, self.sps, True, self.eb, False, False))
def __init__(self, hdr_format=digital.header_format_default( digital.packet_utils.default_access_code, 0)): gr.top_block.__init__(self, "Qpsk Usrp Loopback") Qt.QWidget.__init__(self) self.setWindowTitle("Qpsk Usrp Loopback") 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", "qpsk_usrp_loopback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.hdr_format = hdr_format ################################################## # Variables ################################################## self.qpsk = qpsk = digital.constellation_qpsk().base() self.excess_bw = excess_bw = 0.2 self.base_sps = base_sps = 5 self.sps = sps = 100 self.samp_rate = samp_rate = 0.4e6 self.rxmod = rxmod = digital.generic_mod(qpsk, False, base_sps, False, excess_bw, False, False) self.vec = vec = [ 0x96, 0x85, 0x81, 0x4a, 0xd7, 0x2e, 0x73, 0xe4, 0x33, 0x33, 0x47, 0xfc, 0x67, 0x3f, 0x72, 0x23, 0x44, 0x15, 0xc0, 0x04, 0x09, 0x13, 0x59, 0x77 ] self.rrc_taps_rx = rrc_taps_rx = firdes.root_raised_cosine( 32, samp_rate / base_sps, base_sps, excess_bw, 11 * base_sps * 3) self.nfilts = nfilts = 32 self.modulated_sync_word = modulated_sync_word = digital.modulate_vector_bc( rxmod.to_basic_block(), ([0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc]), ([1])) self.carrier_freq = carrier_freq = 85e3 self.baseband_bw = baseband_bw = (1 + excess_bw) * (samp_rate / sps) self.acc_code = acc_code = "1111111100000000111100001111000011001100111111110000000010101010" ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(carrier_freq), 0) self.uhd_usrp_source_0.set_normalized_gain(0.5, 0) self.uhd_usrp_source_0.set_antenna('A', 0) self.uhd_usrp_source_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(carrier_freq), 0) self.uhd_usrp_sink_0.set_normalized_gain(0.5, 0) self.uhd_usrp_sink_0.set_antenna('A', 0) self.qtgui_time_sink_x_2 = qtgui.time_sink_c( 512, #size samp_rate, #samp_rate "scope", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, False) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) self.qtgui_time_sink_x_2.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_2.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_2.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance( self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Correlation Estimate", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.4) self.qtgui_time_sink_x_1.set_y_axis(-1, 2000) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 5e-05, 0, 'corr_est') self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(True) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 128, #size samp_rate, #samp_rate "End", #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, 150) 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_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "len_key2") 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 = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("BER") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "scope", #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( 512, #size "scope", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.05) self.qtgui_const_sink_x_0.set_y_axis(-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.math_0 = iio.iio_math('10^(-x)', 1) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1.2, samp_rate, 5e3, 1000, firdes.WIN_HAMMING, 6.76)) self.fir_filter_xxx_0 = filter.fir_filter_ccc(sps / base_sps, (100, )) self.fir_filter_xxx_0.declare_sample_delay(0) self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, 'len_key') self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( base_sps, 62.8e-3, (rrc_taps_rx), 36, 36 / 2, 1.25, 3) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc( 5, 5E-3, 3, qpsk) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( 62.8e-3, 4, False) self.digital_correlate_access_code_xx_ts_1_0_0 = digital.correlate_access_code_bb_ts( digital.packet_utils.default_access_code, 2, "len_key2") self.digital_corr_est_cc_0 = digital.corr_est_cc((modulated_sync_word), base_sps, 150, 0.91) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( qpsk) self.blocks_vector_source_x_0 = blocks.vector_source_b( vec, True, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_tagged_stream_mux_0_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_char * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 119, "len_key") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, len(vec), "len_key") self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 1, 8, "", False, gr.GR_MSB_FIRST) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/Testings/test_input.txt', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) 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)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_1, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.fec_ber_bf_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_mux_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.fec_ber_bf_0, 1)) self.connect((self.blocks_tag_gate_0, 0), (self.digital_correlate_access_code_xx_ts_1_0_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_tagged_stream_mux_0_0, 1)) self.connect((self.blocks_tagged_stream_mux_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_1_0_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.fec_ber_bf_0, 0), (self.math_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.math_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
def set_pld_const(self, pld_const): self.pld_const = pld_const self.set_rxmod(digital.generic_mod(self.pld_const, False, self.sps, True, self.eb, False, False))
def set_base_sps(self, base_sps): self.base_sps = base_sps self.set_rxmod( digital.generic_mod(self.qpsk, False, self.base_sps, False, self.excess_bw, False, False))
def __init__(self): gr.top_block.__init__(self, "MPSK Transmitter") Qt.QWidget.__init__(self) self.setWindowTitle("MPSK Transmitter") 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", "mpsk_tx_constellationmod_qt") self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate = samp_rate = 32000 self.qpsk_const = qpsk_const = digital.constellation_rect( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base() self.excess_bw = excess_bw = 0.35 self.arity = arity = 4 ################################################## # Blocks ################################################## self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'QT GUI Plot', #name 5 #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(True) 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(5): 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, 1, 0, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 5 #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(5): 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.digital_constellation_modulator_0_1 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.digital_constellation_modulator_0_0_0_0 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=1.0, verbose=False, log=False, ) self.digital_constellation_modulator_0_0_0 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.5, verbose=False, log=False, ) self.digital_constellation_modulator_0_0 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.22, verbose=False, log=False, ) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.1, verbose=False, log=False, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0_0_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0_1, 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.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_modulator_0_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.digital_constellation_modulator_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.digital_constellation_modulator_0_0_0, 0), (self.qtgui_const_sink_x_0, 3)) self.connect((self.digital_constellation_modulator_0_0_0, 0), (self.qtgui_freq_sink_x_0, 3)) self.connect((self.digital_constellation_modulator_0_0_0_0, 0), (self.qtgui_const_sink_x_0, 4)) self.connect((self.digital_constellation_modulator_0_0_0_0, 0), (self.qtgui_freq_sink_x_0, 4)) self.connect((self.digital_constellation_modulator_0_1, 0), (self.qtgui_const_sink_x_0, 2)) self.connect((self.digital_constellation_modulator_0_1, 0), (self.qtgui_freq_sink_x_0, 2))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage6") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage6") 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", "mpsk_stage6") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.variable_0 = variable_0 = 0 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] # ntaps = 3 # taps = numpy.random.random(ntaps-1) + 1j*numpy.random.random(ntaps-1) # self.taps = taps = numpy.concatenate((numpy.ones(1), taps)) # self.taps = taps self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.phase_bw = phase_bw = 6.28/100.0 self.noise_volt = noise_volt = 0 self.freq_offset = freq_offset = 0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.delay = delay = 58 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, 'Channel') self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, 'Receiver') self.top_grid_layout.addWidget(self.controls, 0,0,1,2) self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28/100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, 'Time: BW', "slider", float) self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0,0,1,1) self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Timing Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._time_offset_win, 0,2,1,1) self.received = Qt.QTabWidget() self.received_widget_0 = Qt.QWidget() self.received_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_0) self.received_grid_layout_0 = Qt.QGridLayout() self.received_layout_0.addLayout(self.received_grid_layout_0) self.received.addTab(self.received_widget_0, 'Constellation') self.received_widget_1 = Qt.QWidget() self.received_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_1) self.received_grid_layout_1 = Qt.QGridLayout() self.received_layout_1.addLayout(self.received_grid_layout_1) self.received.addTab(self.received_widget_1, 'Symbols') self.top_grid_layout.addWidget(self.received, 2,0,1,1) self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28/100.0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, 'Phase: Bandwidth', "slider", float) self.controls_grid_layout_1.addWidget(self._phase_bw_win, 0,2,1,1) self._noise_volt_range = Range(0, 1, 0.01, 0, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Noise Voltage', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._noise_volt_win, 0,0,1,1) self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._freq_offset_win, 0,1,1,1) self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, 'Equalizer: rate', "slider", float) self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0,1,1,1) self._delay_range = Range(0, 200, 1, 58, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, 'Delay', "counter_slider", float) self.top_grid_layout.addWidget(self._delay_win, 1,0,1,1) self.tutorial_my_qpsk_demod_cb_1 = tutorial.my_qpsk_demod_cb(True) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(True) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] 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_1.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 4,0,1,1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 100, #size samp_rate, #samp_rate '', #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 2) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['Rx Bits', 'Tx Bits', '', '', '', '', '', '', '', ''] 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.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 2,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 500, #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, 4) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['Symbols', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.received_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0,0,1,1) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['BER', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1e6, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(True) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 3,0,1,1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0,0,1,1) self.iq_vector_sink = blocks.vector_sink_c(1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_map_bb_0 = digital.map_bb(([0,1,3,2])) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity, False) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2) snr = 18 noise_amp = 10**(-snr/10.0) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_amp, frequency_offset=freq_offset, epsilon=time_offset, taps=(taps), noise_seed=0, block_tags=False ) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_file_sink_0_1 = blocks.file_sink(gr.sizeof_gr_complex*1, 'iq_qpsk.txt', False) self.blocks_file_sink_0_1.set_unbuffered(True) self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_float*1, 'decoded_qpsk.txt', False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float*1, 'ground_truth_qpsk.txt', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, 'ber_qpsk.txt', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_delay_0_1 = blocks.delay(gr.sizeof_char*1, int(delay)) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, int(delay)) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blks2_error_rate = grc_blks2.error_rate( type='BER', win_size=int(1e4), bits_per_symbol=1, ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blks2_error_rate, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_error_rate, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_delay_0_1, 0), (self.blks2_error_rate, 1)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_error_rate, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_delay_0_1, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.iq_vector_sink, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_file_sink_0_1, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.tutorial_my_qpsk_demod_cb_1, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.tutorial_my_qpsk_demod_cb_1, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.tutorial_my_qpsk_demod_cb_1, 0), (self.digital_map_bb_0, 0))
def __init__(self, puncpat='11'): 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.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.H_dec = H_dec = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.H = H = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 5 * sps * nfilts) self.time_offset = time_offset = 1.0 self.samp_rate = samp_rate = 1000000 self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts) self.pld_enc = pld_enc = fec.ldpc_par_mtrx_encoder_make_H(H) self.pld_dec = pld_dec = fec.ldpc_bit_flip_decoder.make( H_dec.get_base_sptr(), 100) self.pld_const = pld_const = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base() self.pld_const.gen_soft_dec_lut(8) self.noise = noise = 0.0 self.freq_offset = freq_offset = 0 self.amp = amp = 1.0 ################################################## # Blocks ################################################## self._time_offset_range = Range(0.99, 1.01, 0.00001, 1.0, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Time Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._time_offset_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._noise_range = Range(0, 5, 0.01, 0.0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise Amp', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_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._freq_offset_range = Range(-0.5, 0.5, 0.0001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Freq. Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_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._amp_range = Range(0, 2, 0.01, 1.0, 200) self._amp_win = RangeWidget(self._amp_range, self.set_amp, 'Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._amp_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Tx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #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, 256) 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, 'packet_length_tag_key') self.qtgui_time_sink_x_0.enable_autoscale(True) 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 = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.fec_extended_encoder_0 = fec.extended_encoder( encoder_obj_list=pld_enc, threading=None, puncpat=puncpat) self.fec_extended_decoder_0_0_1_0_1_0 = fec.extended_decoder( decoder_obj_list=pld_dec, threading=None, ann=None, puncpat=puncpat, integration_period=10000) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 100.0, (rrc_taps), nfilts, nfilts / 2, 1.5, 2) self.digital_map_bb_0_0_0_0_0 = digital.map_bb(([-1, 1])) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( sps, eb, 44, 0.05) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( 6.28 / 100.0, pld_const.arity(), False) self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts( digital.packet_utils.default_access_code, 3, 'packet_len') self.digital_constellation_soft_decoder_cf_0_0 = digital.constellation_soft_decoder_cf( pld_const) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=pld_const, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=eb, verbose=False, log=False, ) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 15, 1, 0.01, 2) self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq_offset, epsilon=time_offset, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=True) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_stream_mux_0_1_0 = blocks.stream_mux( gr.sizeof_char * 1, (96, 1104)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1, (1100, 4)) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char * 1, (440, 2)) self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb( 8, 1, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_1_0_0 = blocks.repack_bits_bb( 1, 8, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb( 1, 8, '', False, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((amp, )) self.blocks_keep_m_in_n_0_1_1_0 = blocks.keep_m_in_n( gr.sizeof_char, 440, 442, 0) self.blocks_keep_m_in_n_0_0_2_0 = blocks.keep_m_in_n( gr.sizeof_char, 1100, 1104, 0) self.blocks_file_source_0_0_1 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/book.txt', False) self.blocks_file_source_0_0_1.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/andre/Desktop/transmitido/depois.txt', False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_1_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_2_0_0 = blocks.char_to_float(1, 1) self.acode_1104 = blocks.vector_source_b([ 0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0 ], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0)) self.connect((self.blocks_char_to_float_0_2_0_0, 0), (self.fec_extended_decoder_0_0_1_0_1_0, 0)) self.connect((self.blocks_char_to_float_1_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_1_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_file_source_0_0_1, 0), (self.blocks_char_to_float_1_0_0, 0)) self.connect((self.blocks_file_source_0_0_1, 0), (self.blocks_repack_bits_bb_1_0_0_1, 0)) self.connect((self.blocks_keep_m_in_n_0_0_2_0, 0), (self.digital_map_bb_0_0_0_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0_1_1_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_char_to_float_1_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.fec_extended_encoder_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.blocks_stream_mux_0_1_0, 1)) self.connect((self.blocks_stream_mux_0_1_0, 0), (self.blocks_repack_bits_bb_1_0_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.channels_channel_model_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.digital_correlate_access_code_xx_ts_0_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_0_0, 0), (self.digital_binary_slicer_fb_0_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0), (self.blocks_keep_m_in_n_0_0_2_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_soft_decoder_cf_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.digital_map_bb_0_0_0_0_0, 0), (self.blocks_char_to_float_0_2_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.fec_extended_decoder_0_0_1_0_1_0, 0), (self.blocks_keep_m_in_n_0_1_1_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blocks_stream_mux_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Sim") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Sim") 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", "mpsk_sim") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.n = n = 4 self.sps = sps = 4 self.nfilts = nfilts = 32 self.m = m = n self.eb = eb = 0.35 self.timing_loop_bw = timing_loop_bw = 0.01 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase_bw = phase_bw = 0.1 self.payload_size = payload_size = 100*n*m self.packed_preamble = packed_preamble = [83, 34, 91, 29, 13, 115, 223, 3] self.noise_volt = noise_volt = 0 self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.freq_offset = freq_offset = 0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, "Transmitter") self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, "Receiver") self.top_grid_layout.addWidget(self.controls, 0,0,1,2) self._timing_loop_bw_layout = Qt.QVBoxLayout() self._timing_loop_bw_label = Qt.QLabel("Time: BW") self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005) self._timing_loop_bw_slider.setValue(self.timing_loop_bw) self._timing_loop_bw_slider.setMinimumWidth(200) self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw) self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider) self.controls_grid_layout_1.addLayout(self._timing_loop_bw_layout, 0,0,1,1) self._time_offset_layout = Qt.QVBoxLayout() self._time_offset_tool_bar = Qt.QToolBar(self) self._time_offset_layout.addWidget(self._time_offset_tool_bar) self._time_offset_tool_bar.addWidget(Qt.QLabel("Timing Offset"+": ")) self._time_offset_counter = Qwt.QwtCounter() self._time_offset_counter.setRange(0.999, 1.001, 0.0001) self._time_offset_counter.setNumButtons(2) self._time_offset_counter.setValue(self.time_offset) self._time_offset_tool_bar.addWidget(self._time_offset_counter) self._time_offset_counter.valueChanged.connect(self.set_time_offset) self._time_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._time_offset_slider.setRange(0.999, 1.001, 0.0001) self._time_offset_slider.setValue(self.time_offset) self._time_offset_slider.setMinimumWidth(200) self._time_offset_slider.valueChanged.connect(self.set_time_offset) self._time_offset_layout.addWidget(self._time_offset_slider) self.controls_grid_layout_0.addLayout(self._time_offset_layout, 0,2,1,1) self._phase_bw_layout = Qt.QVBoxLayout() self._phase_bw_label = Qt.QLabel("Phase: Bandwidth") self._phase_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_bw_slider.setRange(0.0, 1.0, 0.01) self._phase_bw_slider.setValue(self.phase_bw) self._phase_bw_slider.setMinimumWidth(200) self._phase_bw_slider.valueChanged.connect(self.set_phase_bw) self._phase_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._phase_bw_layout.addWidget(self._phase_bw_label) self._phase_bw_layout.addWidget(self._phase_bw_slider) self.controls_grid_layout_1.addLayout(self._phase_bw_layout, 0,2,1,1) self._noise_volt_layout = Qt.QVBoxLayout() self._noise_volt_tool_bar = Qt.QToolBar(self) self._noise_volt_layout.addWidget(self._noise_volt_tool_bar) self._noise_volt_tool_bar.addWidget(Qt.QLabel("Noise Voltage"+": ")) self._noise_volt_counter = Qwt.QwtCounter() self._noise_volt_counter.setRange(0, 1, 0.01) self._noise_volt_counter.setNumButtons(2) self._noise_volt_counter.setValue(self.noise_volt) self._noise_volt_tool_bar.addWidget(self._noise_volt_counter) self._noise_volt_counter.valueChanged.connect(self.set_noise_volt) self._noise_volt_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_volt_slider.setRange(0, 1, 0.01) self._noise_volt_slider.setValue(self.noise_volt) self._noise_volt_slider.setMinimumWidth(200) self._noise_volt_slider.valueChanged.connect(self.set_noise_volt) self._noise_volt_layout.addWidget(self._noise_volt_slider) self.controls_grid_layout_0.addLayout(self._noise_volt_layout, 0,0,1,1) self._freq_offset_layout = Qt.QVBoxLayout() self._freq_offset_tool_bar = Qt.QToolBar(self) self._freq_offset_layout.addWidget(self._freq_offset_tool_bar) self._freq_offset_tool_bar.addWidget(Qt.QLabel("Frequency Offset"+": ")) self._freq_offset_counter = Qwt.QwtCounter() self._freq_offset_counter.setRange(-0.1, 0.1, 0.001) self._freq_offset_counter.setNumButtons(2) self._freq_offset_counter.setValue(self.freq_offset) self._freq_offset_tool_bar.addWidget(self._freq_offset_counter) self._freq_offset_counter.valueChanged.connect(self.set_freq_offset) self._freq_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_offset_slider.setRange(-0.1, 0.1, 0.001) self._freq_offset_slider.setValue(self.freq_offset) self._freq_offset_slider.setMinimumWidth(200) self._freq_offset_slider.valueChanged.connect(self.set_freq_offset) self._freq_offset_layout.addWidget(self._freq_offset_slider) self.controls_grid_layout_0.addLayout(self._freq_offset_layout, 0,1,1,1) self._eq_gain_layout = Qt.QVBoxLayout() self._eq_gain_label = Qt.QLabel("Equalizer: rate") self._eq_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._eq_gain_slider.setRange(0.0, 0.1, 0.001) self._eq_gain_slider.setValue(self.eq_gain) self._eq_gain_slider.setMinimumWidth(200) self._eq_gain_slider.valueChanged.connect(self.set_eq_gain) self._eq_gain_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._eq_gain_layout.addWidget(self._eq_gain_label) self._eq_gain_layout.addWidget(self._eq_gain_slider) self.controls_grid_layout_1.addLayout(self._eq_gain_layout, 0,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.controls_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 1,0,2,2) self.qtgui_sink_x_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_1.set_update_time(1.0/10) self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.controls_grid_layout_1.addWidget(self._qtgui_sink_x_1_win, 1,0,2,2) self.qtgui_sink_x_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.controls_grid_layout_1.addWidget(self._qtgui_sink_x_0_win, 3,0,2,2) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity) self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble), (matched_filter), sps) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=([1]), noise_seed=0, block_tags=False ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b(map(lambda x: (-x+1)/2, preamble), True, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(int(math.log(arity,2))) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)/8,payload_size)) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/franchz/Documents/UTFPR/10o_periodo/TCC2/projeto/tcc/gnuradio/tx_teste.txt", True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/franchz/Documents/UTFPR/10o_periodo/TCC2/projeto/tcc/gnuradio/rx_teste.txt", False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_correlate_and_sync_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_mux_0_0_0, 1))
def test_qpsk_3tap_lms_training(self): # set up fg gain = 0.001 # LMS gain num_taps_fwd = 13 num_taps_rev = 3 num_test = 1000 cons = digital.constellation_qpsk().base() rxmod = digital.generic_mod(cons, False, self.sps, True, self.eb, False, False) modulated_sync_word_pre = digital.modulate_vector_bc( rxmod.to_basic_block(), self.preamble + self.preamble, [1]) modulated_sync_word = modulated_sync_word_pre[86:( 512 + 86)] # compensate for the RRC filter delay corr_max = numpy.abs( numpy.dot(modulated_sync_word, numpy.conj(modulated_sync_word))) corr_calc = self.corr_thresh / (corr_max * corr_max) preamble_symbols = self.map_symbols_to_constellation( self.unpack_values(self.preamble, 8, 2), cons) alg = digital.adaptive_algorithm_lms(cons, gain).base() evm = digital.meas_evm_cc(cons, digital.evm_measurement_t_EVM_PERCENT) dfe = digital.decision_feedback_equalizer(num_taps_fwd, num_taps_rev, self.sps, alg, True, preamble_symbols, 'corr_est') correst = digital.corr_est_cc(modulated_sync_word, self.sps, 12, corr_calc, digital.THRESHOLD_ABSOLUTE) constmod = digital.generic_mod(constellation=cons, differential=False, samples_per_symbol=4, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False) chan = channels.channel_model( noise_voltage=self.noise_voltage, frequency_offset=0.0, epsilon=1.0, taps=(2.0, -0.459489 + -0.156287j, 0.185799 + 0.022878j, 0.060229 + 0.002171j, -0.023041 + -0.016539j, -0.004507 + 0.011984j, -0.002597 + 0.002675j, 0.002320 + 0.000621j, -0.001420 + -0.000126j, -0.000118 + -0.000520j, -0.000029 + -0.000201j, 0.000060 + -0.000002j, 0.169089 + -0.500778j, 0.419112 + 0.042402j, -0.139208 + 0.030027j, -0.080077 + 0.036473j, 0.026689 + 0.000837j, -0.002449 + 0.002320j, -0.000567 + -0.002068j, 0.001528 + 0.002867j, 0.000944 + -0.000166j, 0.000218 + 0.000007j, 0.000214 + -0.000150j, 0.000004 + 0.000008j), noise_seed=-44982235, block_tags=False) repeating_data = self.preamble + self.data * 200 vso = blocks.vector_source_b(repeating_data, False, 1, []) head = blocks.head(gr.sizeof_char * 1, 500) vsi = blocks.vector_sink_f() self.tb.connect(vso, head, constmod, chan, correst, dfe, evm, vsi) self.tb.run() # look at the last 1000 samples, should converge quickly, below 5% EVM upper_bound = tuple(20.0 * numpy.ones((num_test, ))) lower_bound = tuple(0.0 * numpy.zeros((num_test, ))) output_data = vsi.data() output_data = output_data[-num_test:] self.assertLess(output_data, upper_bound) self.assertGreater(output_data, lower_bound)
def __init__(self): gr.top_block.__init__(self, "Cr Application") Qt.QWidget.__init__(self) self.setWindowTitle("Cr Application") 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", "cr_application") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.usrp_rf_freq = usrp_rf_freq = 2405000000 self.usrp_int_freq = usrp_int_freq = 2400000000 self.timing_loop_bw = timing_loop_bw = 6.28/100 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 390625 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.phase_bw = phase_bw = 6.28/100 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.arity = arity = 4 ################################################## # Blocks ################################################## self.crew_db_channel_selector_0 = crew.db_channel_selector('test_may14_r1', 'zigbee', 'max', 0.05) def _usrp_rf_freq_probe(): while True: val = self.crew_db_channel_selector_0.get_freq() try: self.set_usrp_rf_freq(val) except AttributeError, e: pass time.sleep(1.0/(0.2)) _usrp_rf_freq_thread = threading.Thread(target=_usrp_rf_freq_probe) _usrp_rf_freq_thread.daemon = True _usrp_rf_freq_thread.start() self._usrp_int_freq_layout = Qt.QVBoxLayout() self._usrp_int_freq_tool_bar = Qt.QToolBar(self) self._usrp_int_freq_layout.addWidget(self._usrp_int_freq_tool_bar) self._usrp_int_freq_tool_bar.addWidget(Qt.QLabel("usrp_int_freq"+": ")) self._usrp_int_freq_counter = Qwt.QwtCounter() self._usrp_int_freq_counter.setRange(2400000000, 2480000000, 5000000) self._usrp_int_freq_counter.setNumButtons(2) self._usrp_int_freq_counter.setValue(self.usrp_int_freq) self._usrp_int_freq_tool_bar.addWidget(self._usrp_int_freq_counter) self._usrp_int_freq_counter.valueChanged.connect(self.set_usrp_int_freq) self._usrp_int_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._usrp_int_freq_slider.setRange(2400000000, 2480000000, 5000000) self._usrp_int_freq_slider.setValue(self.usrp_int_freq) self._usrp_int_freq_slider.setMinimumWidth(100) self._usrp_int_freq_slider.valueChanged.connect(self.set_usrp_int_freq) self._usrp_int_freq_layout.addWidget(self._usrp_int_freq_slider) self.top_layout.addLayout(self._usrp_int_freq_layout) self.uhd_usrp_source_0_0 = uhd.usrp_source( device_addr="addr=192.168.30.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_source_0_0.set_gain(10, 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", args="addr=192.168.40.2", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(usrp_int_freq, 0) self.uhd_usrp_sink_1.set_gain(40, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="addr=192.168.20.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_sink_0.set_gain(10, 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate/2, #samp_rate "BER", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "BER") self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_map_bb_0 = digital.map_bb(([0,1,2,3])) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(20, 0.02, 2, qpsk) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(qpsk, timing_loop_bw, 0.0001, 0.0002) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=4, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b((170,170), True, 1, []) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=1, ) self.analog_random_source_x_1 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.analog_random_source_x_1, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.crew_db_channel_selector_0, 0))
def __init__(self): gr.top_block.__init__(self, "Packet Coder Test") Qt.QWidget.__init__(self) self.setWindowTitle("Packet Coder 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", "packet_coder_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.sps = sps = 4 self.nfilts = nfilts = 32 self.excess_bw = excess_bw = 0.35 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.samp_rate_0 = samp_rate_0 = 32E3 self.samp_rate = samp_rate = 32000 self.rrc_taps_0 = rrc_taps_0 = firdes.root_raised_cosine(1, sps, 1, excess_bw, 45) self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts) self.phase_bw = phase_bw = 0.0628 self.delay = delay = 0 self.BPSK = BPSK = digital.constellation_qpsk().base() ################################################## # Blocks ################################################## self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28/100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, 'Time: BW', "slider", float) self.top_grid_layout.addWidget(self._timing_loop_bw_win, 0, 0, 1, 1) [self.top_grid_layout.setRowStretch(r,1) for r in range(0,1)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,1)] self._delay_range = Range(0, 200, 1, 0, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, "delay", "counter_slider", float) self.top_grid_layout.addWidget(self._delay_win, 0, 1, 1, 1) [self.top_grid_layout.setRowStretch(r,1) for r in range(0,1)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(1,2)] self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate 'Output Stream', #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 2) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['Rx Bits', 'Tx Bits', '', '', '', '', '', '', '', ''] 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.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 3, 0, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(3,4)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,2)] self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 2, 0, 1, 2) [self.top_grid_layout.setRowStretch(r,1) for r in range(2,3)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,2)] self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "TX", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) 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, 1, 0, 1, 1) [self.top_grid_layout.setRowStretch(r,1) for r in range(1,2)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,1)] self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "RX", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 1, 1, 1) [self.top_grid_layout.setRowStretch(r,1) for r in range(1,2)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(1,2)] self.myblocks_qpsk_demod_v2_0 = myblocks.qpsk_demod_v2(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (rrc_taps_0)) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 1) self.digital_map_bb_0 = digital.map_bb(([0,3,2,1])) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_throttle_1 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, int(delay)) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_throttle_1, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.myblocks_qpsk_demod_v2_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.myblocks_qpsk_demod_v2_0, 0), (self.digital_diff_decoder_bb_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") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 45 self.nfilts = nfilts = 25 self.samp_rate = samp_rate = 44.1E3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts) self.fc_slider = fc_slider = 2200 self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base() ################################################## # Blocks ################################################## self._fc_slider_range = Range(0, 18200, 200, 2200, 150) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, 'fc', "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.25, verbose=False, log=False, ) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr='127.0.0.1', port=1235, server=True, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=1, ) self.audio_sink_0 = audio.sink(44100, '', True) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, fc_slider, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="BSPK eye diagram") ################################################## # Variables ################################################## self.sps = sps = 8 self.samp_rate = samp_rate = 100000 self.pam = pam = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base() self.noise_voltage = noise_voltage = 0 ################################################## # Blocks ################################################## _noise_voltage_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_voltage_text_box = forms.text_box( parent=self.GetWin(), sizer=_noise_voltage_sizer, value=self.noise_voltage, callback=self.set_noise_voltage, label='Noise voltage', converter=forms.float_converter(), proportion=0, ) self._noise_voltage_slider = forms.slider( parent=self.GetWin(), sizer=_noise_voltage_sizer, value=self.noise_voltage, callback=self.set_noise_voltage, minimum=0, maximum=100, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_noise_voltage_sizer) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title='Scope Plot', sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.Add(self.wxgui_scopesink2_0.win) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, sps, 1.0, 0.35, 88)) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=pam, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_voltage, frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_complex_to_real_0, 0))
def __init__(self): gr.top_block.__init__(self, "QPSK Tx") Qt.QWidget.__init__(self) self.setWindowTitle("QPSK Tx") 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", "QPSK_Tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sym_rate = sym_rate = 500000 self.samp_rate = samp_rate = 2000000 self.sps = sps = int(samp_rate/sym_rate) self.sig_amp = sig_amp = 0.5 self.qpsk = qpsk = digital.constellation_rect(([-1-1j, -1+1j, 1+1j, 1-1j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.car_freq = car_freq = 1000000 self.arity = arity = 4 ################################################## # Blocks ################################################## self._sig_amp_layout = Qt.QHBoxLayout() self._sig_amp_layout.addWidget(Qt.QLabel("Signal Amplitude"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._sig_amp_counter = qwt_counter_pyslot() self._sig_amp_counter.setRange(0, 1, 0.05) self._sig_amp_counter.setNumButtons(2) self._sig_amp_counter.setMinimumWidth(200) self._sig_amp_counter.setValue(self.sig_amp) self._sig_amp_layout.addWidget(self._sig_amp_counter) self._sig_amp_counter.valueChanged.connect(self.set_sig_amp) self.top_layout.addLayout(self._sig_amp_layout) self._car_freq_layout = Qt.QHBoxLayout() self._car_freq_layout.addWidget(Qt.QLabel("Carrier Frequency"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._car_freq_counter = qwt_counter_pyslot() self._car_freq_counter.setRange(0, 5000000, 100000) self._car_freq_counter.setNumButtons(2) self._car_freq_counter.setMinimumWidth(200) self._car_freq_counter.setValue(self.car_freq) self._car_freq_layout.addWidget(self._car_freq_counter) self._car_freq_counter.valueChanged.connect(self.set_car_freq) self.top_layout.addLayout(self._car_freq_layout) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(car_freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((sig_amp, )) self.analog_random_source_x_0_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True) ################################################## # Connections ################################################## self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_random_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage6") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage6") 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", "mpsk_stage6") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.phase_bw = phase_bw = 6.28/100.0 self.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.delay = delay = 0 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, "Channel") self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, "Receiver") self.top_grid_layout.addWidget(self.controls, 0,0,1,2) self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28/100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, "Time: BW", "slider", float) self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0,0,1,1) self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, "Timing Offset", "counter_slider", float) self.controls_grid_layout_0.addWidget(self._time_offset_win, 0,2,1,1) self.received = Qt.QTabWidget() self.received_widget_0 = Qt.QWidget() self.received_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_0) self.received_grid_layout_0 = Qt.QGridLayout() self.received_layout_0.addLayout(self.received_grid_layout_0) self.received.addTab(self.received_widget_0, "Constellation") self.received_widget_1 = Qt.QWidget() self.received_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_1) self.received_grid_layout_1 = Qt.QGridLayout() self.received_layout_1.addLayout(self.received_grid_layout_1) self.received.addTab(self.received_widget_1, "Symbols") self.top_grid_layout.addWidget(self.received, 2,0,1,1) self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28/100.0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, "Phase: Bandwidth", "slider", float) self.controls_grid_layout_1.addWidget(self._phase_bw_win, 0,2,1,1) self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, "Noise Voltage", "counter_slider", float) self.controls_grid_layout_0.addWidget(self._noise_volt_win, 0,0,1,1) self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, "Frequency Offset", "counter_slider", float) self.controls_grid_layout_0.addWidget(self._freq_offset_win, 0,1,1,1) self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, "Equalizer: rate", "slider", float) self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0,1,1,1) self._delay_range = Range(0, 200, 1, 0, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, "Delay", "counter_slider", float) self.top_grid_layout.addWidget(self._delay_win, 1,0,1,1) self.tutorial_qpsk_demod_cpp_cb_0 = tutorial.qpsk_demod_cpp_cb(True) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 2) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["Rx Bits", "Tx Bits", "", "", "", "", "", "", "", ""] 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.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 2,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 500, #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, 4) 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_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["Symbols", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.received_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0,0,1,1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) 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.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0,0,1,1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_map_bb_0 = digital.map_bb(([0,1,3,2])) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity, False) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=(taps), noise_seed=0, block_tags=False ) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, int(delay)) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.tutorial_qpsk_demod_cpp_cb_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.tutorial_qpsk_demod_cpp_cb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.tutorial_qpsk_demod_cpp_cb_0, 0), (self.digital_map_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "Bpsk Sender1") ################################################## # Variables ################################################## self.sps = sps = 8 self.nfilts = nfilts = 32 self.transistion = transistion = 100 self.sideband_rx = sideband_rx = 500 self.sideband = sideband = 500 self.samp_rate = samp_rate = 48000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.payload_size = payload_size = 10 self.interpolation = interpolation = 2000 self.gap = gap = 0 self.eb = eb = 0.35 self.delay = delay = 0 self.decimation = decimation = 1 self.constel = constel = digital.constellation_calcdist(([1,- 1]), ([0,1]), 2, 1).base() self.const_type = const_type = 1 self.const = const = (digital.constellation_bpsk(), digital.constellation_qpsk(), digital.constellation_8psk()) self.carrier = carrier = 10000 self.arity = arity = 2 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=interpolation, decimation=decimation, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.band_pass (0.5,samp_rate,10000-sideband,10000+sideband,transistion)), -carrier, samp_rate) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constel, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_wavfile_sink_1 = blocks.wavfile_sink("BPSK_output.wav", 1, 48000, 16) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.1, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "TestData2", False) self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char*1, "inputBinary", False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "inputBinary2", False) self.blocks_file_sink_0_0.set_unbuffered(False) script, sdelay= argv self.blocks_delay_0_0 = blocks.delay(gr.sizeof_char*1, int(sdelay)) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_1, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "MPSK Transmitter") Qt.QWidget.__init__(self) self.setWindowTitle("MPSK Transmitter") 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", "mpsk_tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.usrp_gain = usrp_gain = 20 self.sps = sps = 4 self.samp_rate = samp_rate = 1e6 self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.payload_size = payload_size = 992 self.n = n = 4 self.excess_bw = excess_bw = 0.35 self.arity = arity = 4 ################################################## # Blocks ################################################## self._usrp_gain_layout = Qt.QVBoxLayout() self._usrp_gain_tool_bar = Qt.QToolBar(self) self._usrp_gain_layout.addWidget(self._usrp_gain_tool_bar) self._usrp_gain_tool_bar.addWidget(Qt.QLabel("USRP Gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._usrp_gain_counter = qwt_counter_pyslot() self._usrp_gain_counter.setRange(0, 100, 1) self._usrp_gain_counter.setNumButtons(2) self._usrp_gain_counter.setValue(self.usrp_gain) self._usrp_gain_tool_bar.addWidget(self._usrp_gain_counter) self._usrp_gain_counter.valueChanged.connect(self.set_usrp_gain) self._usrp_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._usrp_gain_slider.setRange(0, 100, 1) self._usrp_gain_slider.setValue(self.usrp_gain) self._usrp_gain_slider.setMinimumWidth(200) self._usrp_gain_slider.valueChanged.connect(self.set_usrp_gain) self._usrp_gain_layout.addWidget(self._usrp_gain_slider) self.top_layout.addLayout(self._usrp_gain_layout) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(2.4e9, 0) self.uhd_usrp_sink_0.set_gain(usrp_gain, 0) self.tcc_sdr_interleaver_bb_0 = tcc_sdr.interleaver_bb(n, n) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(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", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b(map(lambda x: (-x+1)/2, preamble), True, 1, []) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)/8,payload_size)) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/franchz/tcc/gnuradio/tx_teste.txt", True) ################################################## # Connections ################################################## self.connect((self.digital_constellation_modulator_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.tcc_sdr_interleaver_bb_0, 0)) self.connect((self.tcc_sdr_interleaver_bb_0, 0), (self.blocks_stream_mux_0_0_0, 1))
def __init__(self): gr.top_block.__init__(self, "Simulation for SDR TCC") Qt.QWidget.__init__(self) self.setWindowTitle("Simulation for SDR TCC") 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", "sdrSim2") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.timing_loop_bw = timing_loop_bw = 0.005 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase_bw = phase_bw = 6.28/100.0 self.payload_size = payload_size = 992 self.noise_volt = noise_volt = 0.0001 self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.freq_offset = freq_offset = 0 self.freq_bw = freq_bw = 6.28/100.0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.delay = delay = 0 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, "Channel") self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, "Receiver") self.top_grid_layout.addWidget(self.controls, 0,0,1,2) self._timing_loop_bw_layout = Qt.QVBoxLayout() self._timing_loop_bw_label = Qt.QLabel("Time: BW") self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005) self._timing_loop_bw_slider.setValue(self.timing_loop_bw) self._timing_loop_bw_slider.setMinimumWidth(200) self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw) self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider) self.controls_grid_layout_1.addLayout(self._timing_loop_bw_layout, 0,0,1,1) self._time_offset_layout = Qt.QVBoxLayout() self._time_offset_tool_bar = Qt.QToolBar(self) self._time_offset_layout.addWidget(self._time_offset_tool_bar) self._time_offset_tool_bar.addWidget(Qt.QLabel("Timing Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._time_offset_counter = qwt_counter_pyslot() self._time_offset_counter.setRange(0.999, 1.001, 0.0001) self._time_offset_counter.setNumButtons(2) self._time_offset_counter.setValue(self.time_offset) self._time_offset_tool_bar.addWidget(self._time_offset_counter) self._time_offset_counter.valueChanged.connect(self.set_time_offset) self._time_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._time_offset_slider.setRange(0.999, 1.001, 0.0001) self._time_offset_slider.setValue(self.time_offset) self._time_offset_slider.setMinimumWidth(200) self._time_offset_slider.valueChanged.connect(self.set_time_offset) self._time_offset_layout.addWidget(self._time_offset_slider) self.controls_grid_layout_0.addLayout(self._time_offset_layout, 0,2,1,1) self.received = Qt.QTabWidget() self.received_widget_0 = Qt.QWidget() self.received_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_0) self.received_grid_layout_0 = Qt.QGridLayout() self.received_layout_0.addLayout(self.received_grid_layout_0) self.received.addTab(self.received_widget_0, "Constellation") self.received_widget_1 = Qt.QWidget() self.received_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_1) self.received_grid_layout_1 = Qt.QGridLayout() self.received_layout_1.addLayout(self.received_grid_layout_1) self.received.addTab(self.received_widget_1, "Symbols") self.top_grid_layout.addWidget(self.received, 2,0,1,1) self._phase_bw_layout = Qt.QVBoxLayout() self._phase_bw_label = Qt.QLabel("Phase: Bandwidth") self._phase_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_bw_slider.setRange(0.0, 1.0, 0.01) self._phase_bw_slider.setValue(self.phase_bw) self._phase_bw_slider.setMinimumWidth(200) self._phase_bw_slider.valueChanged.connect(self.set_phase_bw) self._phase_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._phase_bw_layout.addWidget(self._phase_bw_label) self._phase_bw_layout.addWidget(self._phase_bw_slider) self.controls_grid_layout_1.addLayout(self._phase_bw_layout, 0,2,1,1) self._noise_volt_layout = Qt.QVBoxLayout() self._noise_volt_tool_bar = Qt.QToolBar(self) self._noise_volt_layout.addWidget(self._noise_volt_tool_bar) self._noise_volt_tool_bar.addWidget(Qt.QLabel("Noise Voltage"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._noise_volt_counter = qwt_counter_pyslot() self._noise_volt_counter.setRange(0, 1, 0.01) self._noise_volt_counter.setNumButtons(2) self._noise_volt_counter.setValue(self.noise_volt) self._noise_volt_tool_bar.addWidget(self._noise_volt_counter) self._noise_volt_counter.valueChanged.connect(self.set_noise_volt) self._noise_volt_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_volt_slider.setRange(0, 1, 0.01) self._noise_volt_slider.setValue(self.noise_volt) self._noise_volt_slider.setMinimumWidth(200) self._noise_volt_slider.valueChanged.connect(self.set_noise_volt) self._noise_volt_layout.addWidget(self._noise_volt_slider) self.controls_grid_layout_0.addLayout(self._noise_volt_layout, 0,0,1,1) self._freq_offset_layout = Qt.QVBoxLayout() self._freq_offset_tool_bar = Qt.QToolBar(self) self._freq_offset_layout.addWidget(self._freq_offset_tool_bar) self._freq_offset_tool_bar.addWidget(Qt.QLabel("Frequency Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_offset_counter = qwt_counter_pyslot() self._freq_offset_counter.setRange(-0.1, 0.1, 0.001) self._freq_offset_counter.setNumButtons(2) self._freq_offset_counter.setValue(self.freq_offset) self._freq_offset_tool_bar.addWidget(self._freq_offset_counter) self._freq_offset_counter.valueChanged.connect(self.set_freq_offset) self._freq_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_offset_slider.setRange(-0.1, 0.1, 0.001) self._freq_offset_slider.setValue(self.freq_offset) self._freq_offset_slider.setMinimumWidth(200) self._freq_offset_slider.valueChanged.connect(self.set_freq_offset) self._freq_offset_layout.addWidget(self._freq_offset_slider) self.controls_grid_layout_0.addLayout(self._freq_offset_layout, 0,1,1,1) self._eq_gain_layout = Qt.QVBoxLayout() self._eq_gain_label = Qt.QLabel("Equalizer: rate") self._eq_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._eq_gain_slider.setRange(0.0, 0.1, 0.001) self._eq_gain_slider.setValue(self.eq_gain) self._eq_gain_slider.setMinimumWidth(200) self._eq_gain_slider.valueChanged.connect(self.set_eq_gain) self._eq_gain_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._eq_gain_layout.addWidget(self._eq_gain_label) self._eq_gain_layout.addWidget(self._eq_gain_slider) self.controls_grid_layout_1.addLayout(self._eq_gain_layout, 0,1,1,1) self._delay_layout = Qt.QVBoxLayout() self._delay_tool_bar = Qt.QToolBar(self) self._delay_layout.addWidget(self._delay_tool_bar) self._delay_tool_bar.addWidget(Qt.QLabel("Delay"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._delay_counter = qwt_counter_pyslot() self._delay_counter.setRange(0, 200, 1) self._delay_counter.setNumButtons(2) self._delay_counter.setValue(self.delay) self._delay_tool_bar.addWidget(self._delay_counter) self._delay_counter.valueChanged.connect(self.set_delay) self._delay_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._delay_slider.setRange(0, 200, 1) self._delay_slider.setValue(self.delay) self._delay_slider.setMinimumWidth(200) self._delay_slider.valueChanged.connect(self.set_delay) self._delay_layout.addWidget(self._delay_slider) self.top_grid_layout.addLayout(self._delay_layout, 1,0,1,1) self.tutorial_my_qpsk_demod_cb_1 = tutorial.my_qpsk_demod_cb(True) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 2) self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) 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: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 2,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 500, #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, 4) 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) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.received_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0,0,1,1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.enable_autoscale(False) 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.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0,0,1,1) self._freq_bw_layout = Qt.QVBoxLayout() self._freq_bw_label = Qt.QLabel("Frequency Bandwidth") self._freq_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_bw_slider.setRange(0.0, 1.0, 0.01) self._freq_bw_slider.setValue(self.freq_bw) self._freq_bw_slider.setMinimumWidth(200) self._freq_bw_slider.valueChanged.connect(self.set_freq_bw) self._freq_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._freq_bw_layout.addWidget(self._freq_bw_label) self._freq_bw_layout.addWidget(self._freq_bw_slider) self.controls_grid_layout_1.addLayout(self._freq_bw_layout, 0,3,1,1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_map_bb_0 = digital.map_bb(([0,1,3,2])) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity) self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble), (matched_filter), sps) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=(taps), noise_seed=0, block_tags=False ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b(map(lambda x: (-x+1)/2, preamble), True, 1, []) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)/8,payload_size)) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/franchz/tcc/gnuradio/tx_teste.txt", True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/franchz/tcc/gnuradio/rx_teste.txt", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, int(delay)) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_correlate_and_sync_cc_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_mux_0_0_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.tutorial_my_qpsk_demod_cb_1, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.tutorial_my_qpsk_demod_cb_1, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "Message Test") Qt.QWidget.__init__(self) self.setWindowTitle("Message 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", "message_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.sps = sps = 8 self.nfilts = nfilts = 32 self.excess_bw = excess_bw = 0.35 self.timing_loop_bw = timing_loop_bw = 62.8e-3 self.taps_0 = taps_0 = [1.0, 0.25 - 0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.taps = taps = [ 1.0 + 0.0j, ] self.samp_rate_0 = samp_rate_0 = 10e3 self.samp_rate = samp_rate = 44.1e3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), excess_bw, 11 * sps * nfilts) self.qpsk = qpsk = digital.constellation_rect( ([1 + 1j, -1 + 1j, -1 - 1j, 1 - 1j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.phase_bw = phase_bw = 62.8e-3 self.eq_gain = eq_gain = 10e-3 self.center_freq = center_freq = 5e3 self.arity = arity = 4 self.BPSK = BPSK = digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("BER") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(True) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] 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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf( sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_map_bb_0_0_0 = digital.map_bb((qpsk.pre_diff_code())) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=True, log=False, ) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( qpsk) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, 32e3, True) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 2, 8, "", False, gr.GR_MSB_FIRST) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, 5000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.fec_ber_bf_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fec_ber_bf_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_map_bb_0_0_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.digital_map_bb_0_0_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="eye_diagram") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 self.constellation_mapper = constellation_mapper = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 4, 1).base() ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title='Scope Plot', sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_FREE, y_axis_label='Counts', ) self.Add(self.wxgui_scopesink2_0.win) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, 8, 1.0, 0.35, 88)) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constellation_mapper, differential=True, samples_per_symbol=8, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_complex_to_real_0, 0))
def __init__(self, EbNo_dB=15, NumBits=100000, MinGap=2040, MaxGap=4095, frequency_offset_hz=100e3, host='127.0.0.1', iq_filename='iq.dat', iq_port=9094, packet_port=9095, rx_packet_filename='rx_packets.bin', timing_offset_ppm=20, truth_filename='truth.bin', tx_packet_filename='out_packets.bin'): gr.top_block.__init__(self, "Hurdle 1") ################################################## # Parameters ################################################## self.EbNo_dB = EbNo_dB self.NumBits = NumBits self.MinGap = MinGap self.MaxGap = MaxGap self.frequency_offset_hz = frequency_offset_hz self.host = host self.iq_filename = iq_filename self.iq_port = iq_port self.packet_port = packet_port self.rx_packet_filename = rx_packet_filename self.timing_offset_ppm = timing_offset_ppm self.truth_filename = truth_filename self.tx_packet_filename = tx_packet_filename ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 1000000 self.samp_rate = samp_rate = 4000000 self.samps_per_sym = samps_per_sym = samp_rate/symbol_rate self.rrc_taps = rrc_taps = firdes.root_raised_cosine(1.0, samp_rate, symbol_rate, 0.35, 11*4) self.qpsk = qpsk = digital.constellation_calcdist(([-1-1j, -1+1j, 1+1j, 1-1j]), ([0, 1, 3, 2]), 4, 1).base() self.noise_voltage = noise_voltage = (samp_rate/(2*symbol_rate)*10**(-EbNo_dB/10.0))**0.5 ################################################## # Blocks ################################################## self.mod = digital.generic_mod( constellation=qpsk, differential=False, samples_per_symbol=samps_per_sym, pre_diff_code=True, excess_bw=0.7, verbose=False, log=False, ) self.hurdle1_zero_pad_0 = hurdle1.zero_pad(gr.sizeof_gr_complex, 'zero_pad') self.hurdle1_traffic_parser_0 = hurdle1.traffic_parser('pkt_len', 'zero_pad') self.hurdle1_tcp_server_source_0 = hurdle1.tcp_server_source(gr.sizeof_char, host, packet_port) self.hurdle1_tcp_server_sink_0 = hurdle1.tcp_server_sink(gr.sizeof_gr_complex, host, iq_port) self.hurdle1_tag_delay_0 = hurdle1.tag_delay(int(22*samps_per_sym)) self.hurdle1_random_packet_source_0 = hurdle1.random_packet_source(0x99999999, 0x1ACFFC1D, NumBits, MinGap, MaxGap, truth_filename) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_voltage, frequency_offset=frequency_offset_hz/samp_rate, epsilon=1+timing_offset_ppm/1e6, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, 'symbols_out.bin', False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, rx_packet_filename, False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, iq_filename, False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.channels_channel_model_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.hurdle1_tcp_server_sink_0, 0)) self.connect((self.hurdle1_random_packet_source_0, 0), (self.hurdle1_traffic_parser_0, 0)) self.connect((self.hurdle1_tag_delay_0, 0), (self.hurdle1_zero_pad_0, 0)) self.connect((self.hurdle1_tcp_server_source_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.hurdle1_traffic_parser_0, 0), (self.mod, 0)) self.connect((self.hurdle1_zero_pad_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.mod, 0), (self.blocks_file_sink_1, 0)) self.connect((self.mod, 0), (self.hurdle1_tag_delay_0, 0))