def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit='Units', minval=-100, maxval=100, factor=1.0, decimal_places=10, ref_level=0, sample_rate=samp_rate, number_rate=15, average=False, avg_alpha=None, label='Number Plot', peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_float_to_char_1 = blocks.float_to_char(1, 1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=8, ) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 10000, 1, 0) self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, 0.125, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_float_to_char_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_float_to_char_1, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_float_to_char_0, 0))
def __init__(self,EbN0db,semente): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.d = d = 0.1633 self.dj = dj = d*1j self.cj = cj = d*3j self.c = c = 3*d self.bj = bj = d*5j self.b = b = 5*d self.aj = aj = d*7j self.a = a = 7*d self.value = value = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63 self.symbol = symbol = (-a-aj),(-b-aj),(-c-aj),(-d-aj),(+a-aj),(+b-aj),(+c-aj),(+d-aj),(-a-bj),(-b-bj),(-c-bj),(-d-bj),(+a-bj),(+b-bj),(+c-bj),(+d-bj),(-a-cj),(-b-cj),(-c-cj),(-d-cj),(+a-cj),(+b-cj),(+c-cj),(+d-cj),(-a-dj),(-b-dj),(-c-dj),(-d-dj),(+a-dj),(+b-dj),(+c-dj),(+d-dj),(-a+aj),(-b+aj),(-c+aj),(-d+aj),(+a+aj),(+b+aj),(+c+aj),(+d+aj),(-a+bj),(-b+bj),(-c+bj),(-d+bj),(+a+bj),(+b+bj),(+c+bj),(+d+bj),(-a+cj),(-b+cj),(-c+cj),(-d+cj),(+a+cj),(+b+cj),(+c+cj),(+d+cj),(-a+dj),(-b+dj),(-c+dj),(-d+dj),(+a+dj),(+b+dj),(+c+dj),(+d+dj) self.samp_rate = samp_rate = 200000 self.constellation = constellation = digital.constellation_calcdist((symbol), (value), 0, 1).base() ################################################## # Blocks ################################################## self.vectorSink = blocks.vector_sink_f(1) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((symbol), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=10000000, bits_per_symbol=int(math.log(len(symbol))/math.log(2)), ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 64, 4000000)), False) self.analog_noise_source_x_0 =analog.noise_source_c(analog.GR_GAUSSIAN,self.EbN0_to_noise_voltage(EbN0db,int(6)),semente) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.vectorSink, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate_0, 1))
def __init__(self, options): """ Hierarchical block for DQPSK demodulation. The input is the complex modulated signal at baseband and the output is a stream of bytes. @param sps: samples per symbol @type sps: integer """ gr.hier_block2.__init__(self, "dqpsk_demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input gr.io_signature(0, 0, 0)) # Output self.sps = options.samples_per_symbol self.dqpsk_demod = digital.psk_demod( constellation_points=4, differential=True, samples_per_symbol=self.sps, excess_bw=0.35, phase_bw=(6.28)/100.0, timing_bw=(6.28)/100.0, gray_coded="gray", verbose=False, log=False, ) self.gr_null_sink_f = gr.null_sink(gr.sizeof_float*1) self._vector_source_ref = gr.vector_source_b(([1,]), True, 1) #create a comparator self.comparator = howto.compare_vector_cci((1, 1, 1, 1 ,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1), (0,0, 1, 1, 0,0), 5, 0, True) self._ber = grc_blks2.error_rate(type='SER', win_size=1000, bits_per_symbol=1) self.connect(self, self.dqpsk_demod, self.comparator, (self._ber,0)) self.connect(self._vector_source_ref, (self._ber,1)) self.connect(self._ber, self.gr_null_sink_f)
def __init__(self,EbN0db,semente): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.value = value = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 self.symbol = symbol = (0.33333+1/3j),(0.33333+1j),1+1/3j,1+1j,-0.33333+1/3j,-1+1/3j,-0.33333+1j,-1+1j,-0.33333-1/3j,-0.33333-1j,-1-1/3j,-1-1j,0.33333-1/3j,1-1/3j,0.33333-1j,1-1j self.samp_rate = samp_rate = 200000 self.constellation = constellation = digital.constellation_calcdist((symbol), (value), 4, 1).base() ################################################## # Blocks ################################################## self.vectorSink = blocks.vector_sink_f(1) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((symbol), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=10000000, bits_per_symbol=int(math.log(len(symbol))/math.log(2)), ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 16, 10000000)), False) self.analog_noise_source_x_0 =analog.noise_source_c(analog.GR_GAUSSIAN,self.EbN0_to_noise_voltage(EbN0db,int(4)),semente) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.vectorSink, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate_0, 1))
def __init__(self, parameter_0=0): gr.top_block.__init__(self, "BER 4FSK ") Qt.QWidget.__init__(self) self.setWindowTitle("BER 4FSK ") 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", "rrc_heir") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.parameter_0 = parameter_0 ################################################## # Variables ################################################## self.samp_per_sym = samp_per_sym = 120 self.symb_rate = symb_rate = 1200 self.rrc_taps = rrc_taps = samp_per_sym * 6 + 1 self.tcola_r = tcola_r = 1 self.tcola_m = tcola_m = 32 self.symbol_delay = symbol_delay = rrc_taps / samp_per_sym self.samp_rate = samp_rate = symb_rate * samp_per_sym self.noise = noise = 0 self.fsk_deviation_hz = fsk_deviation_hz = 648 self.fc = fc = 900e6 self.bits_per_sym = bits_per_sym = 2 ################################################## # Blocks ################################################## self._noise_range = Range(0, 5, 0.01, 0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, "Noise", "counter_slider", float) self.top_layout.addWidget(self._noise_win) self.tcola_time_compression_0 = tcola.time_compression_c( tcola_m, tcola_r, ()) self.tcola_overlap_add_0 = tcola.overlap_add_c(tcola_m, tcola_r, ()) 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(0, 3) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = [ "Symbols", "Received Symbols", "RRC RX", "", "", "", "", "", "", "" ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, 2, -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_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4096, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-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_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["Post RRC Tx", "Post RRC Rx", "", "", "", "", "", "", "", ""] 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_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0.set_min(i, 0.0) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_0_win) self.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("") 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, -7) self.qtgui_number_sink_0.set_max(i, 0) 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_layout.addWidget(self._qtgui_number_sink_0_win) self.four_level_rrc_transmitter_0 = four_level_rrc_transmitter( alpha=0.350, bits_per_symbol=2, rrc_taps=rrc_taps, samp_per_sym=samp_per_sym, sym_rate=symb_rate, ) self.four_level_rrc_receiver_0_0 = four_level_rrc_receiver( alpha=0.350, bits_per_sym=2, rrc_taps=rrc_taps, samp_per_sym=samp_per_sym, sym_rate=symb_rate, ) self.four_level_rrc_receiver_0 = four_level_rrc_receiver( alpha=0.350, bits_per_sym=2, rrc_taps=rrc_taps, samp_per_sym=samp_per_sym, sym_rate=symb_rate, ) self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0) self.digital_glfsr_source_x_0 = digital.glfsr_source_b(8, True, 0, 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=0.0, epsilon=1.0, taps=(1, ), noise_seed=0, block_tags=False) self.blocks_vco_c_0 = blocks.vco_c(samp_rate, fsk_deviation_hz * 2 * math.pi, 1) self.blocks_pack_k_bits_bb_0_0 = 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_char * 1) self.blocks_delay_2 = blocks.delay( gr.sizeof_char * 1, (symbol_delay + symb_rate) * bits_per_sym - 2) self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, samp_rate) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, samp_rate - tcola_m) self.blocks_delay_0 = blocks.delay( gr.sizeof_float * 1, symbol_delay * samp_per_sym / 2 + samp_rate) 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_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=1, ) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz)) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz)) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.four_level_rrc_receiver_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.four_level_rrc_receiver_0_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.blocks_delay_0_0_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.blocks_delay_2, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_delay_2, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_delay_2, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.fec_ber_bf_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0_0, 0), (self.fec_ber_bf_0, 1)) self.connect((self.blocks_vco_c_0, 0), (self.blocks_delay_0_0_0, 0)) self.connect((self.blocks_vco_c_0, 0), (self.tcola_time_compression_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.tcola_overlap_add_0, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.blocks_delay_2, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.four_level_rrc_transmitter_0, 0)) self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.four_level_rrc_receiver_0, 2), (self.blks2_error_rate_0, 1)) self.connect((self.four_level_rrc_receiver_0, 2), (self.blocks_char_to_float_0, 0)) self.connect((self.four_level_rrc_receiver_0, 2), (self.blocks_pack_k_bits_bb_0_0, 0)) self.connect((self.four_level_rrc_receiver_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.four_level_rrc_receiver_0_0, 2), (self.blocks_null_sink_0, 0)) self.connect((self.four_level_rrc_receiver_0_0, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.four_level_rrc_transmitter_0, 1), (self.blocks_delay_0, 0)) self.connect((self.four_level_rrc_transmitter_0, 1), (self.blocks_vco_c_0, 0)) self.connect((self.tcola_overlap_add_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.tcola_time_compression_0, 0), (self.channels_channel_model_0, 0))
def __init__(self): gr.top_block.__init__(self, "Dqpsk Simu") Qt.QWidget.__init__(self) self.setWindowTitle("Dqpsk Simu") 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", "dqpsk_simu") 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 = 100000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts) self.qpsk_gray = qpsk_gray = 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 = 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.9, 1.1, 0.005, 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, 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_0_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate '', #name 3 #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_NORM, 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(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(True) 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(3): 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_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -7) self.qtgui_number_sink_0.set_max(i, 7) 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(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.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, 2, 3])) 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_gray, 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_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_sub_xx_0 = blocks.sub_ff(1) self.blocks_delay_1 = blocks.delay(gr.sizeof_char * 1, 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_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=2, ) 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, 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_sub_xx_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_sub_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_delay_1, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0_0, 2)) 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, 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_1, 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_my_qpsk_demod_cb_1, 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_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): grc_wxgui.top_block_gui.__init__(self, title="Fhss Sync") ################################################## # Variables ################################################## self.samp_sym = samp_sym = 64 self.tone_freq = tone_freq = 2000 self.samp_rate = samp_rate = 800e3 self.init = init = 1, 1, 1, 1 self.generator = generator = 1, 1, 0, 0, 1 self.code_rate = code_rate = int(samp_sym * 10000) ################################################## # Blocks ################################################## _tone_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._tone_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_tone_freq_sizer, value=self.tone_freq, callback=self.set_tone_freq, label="Tone Frequency", converter=forms.float_converter(), proportion=0, ) self._tone_freq_slider = forms.slider( parent=self.GetWin(), sizer=_tone_freq_sizer, value=self.tone_freq, callback=self.set_tone_freq, minimum=-1 * samp_rate / 2, maximum=samp_rate / 2, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tone_freq_sizer) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Received Spread Spectrum ", ) self.Add(self.wxgui_waterfallsink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=0, maxval=1, factor=1.0, decimal_places=10, ref_level=0, sample_rate=samp_rate, number_rate=15, average=False, avg_alpha=None, label="Error Rate", peak_hold=False, show_gauge=False, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Despread Signal", peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0.win, 0, 2, 2, 4) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.1, frequency_offset=1 / samp_rate, epsilon=1 + 0.0000, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=2, ) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, tone_freq, 2, 0) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 1000)), True) self.Spread_synthesizer_0 = Spread.synthesizer(code_rate, 0, samp_rate, (generator), (init)) self.Spread_rx_synthesizer_0 = Spread.rx_synthesizer(code_rate, samp_sym, samp_rate, 12000, 50000, 0.16, (generator), (init)) self.Spread_cpfsk_mod_0 = Spread.cpfsk_mod(samp_sym) self.Spread_cpfsk_demod_0 = Spread.cpfsk_demod(samp_sym) ################################################## # Connections ################################################## self.connect((self.Spread_rx_synthesizer_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.Spread_rx_synthesizer_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.Spread_cpfsk_demod_0, 0)) self.connect((self.Spread_cpfsk_mod_0, 0), (self.Spread_synthesizer_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.Spread_cpfsk_mod_0, 0)) self.connect((self.Spread_cpfsk_demod_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blks2_error_rate_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.Spread_synthesizer_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.Spread_rx_synthesizer_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") 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.samp_rate = samp_rate = 4e6 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 = 58 self.constel = constel = digital.constellation_calcdist((digital.psk_4()[0]), (digital.psk_4()[1]), 4, 1).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) [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_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) [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 = 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) [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.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("") 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_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) [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.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_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) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=sps, ) 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.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) 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.blks2_error_rate_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_char_to_float_0_0_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.blks2_error_rate_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, "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.variable_constellation_0_1 = variable_constellation_0_1 = digital.constellation_calcdist(([1+0j,0.707+0.707j, -0.707+0.707j, 0+1j, 0.707-0.707j, 0-1j, -1+0j, -0.707-0.707j]), ([0, 1, 2, 3, 4, 5, 6, 7]), 4, 1).base() self.variable_constellation_0_0 = variable_constellation_0_0 = digital.constellation_calcdist(([0.707+0.707j, -0.707-0.707j]), ([0, 1]), 4, 1).base() self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 1).base() self.samp_rate = samp_rate = 10000 self.EbN0 = EbN0 = 10 ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0_0 = filter.fir_filter_ccf(4, firdes.root_raised_cosine( 1, samp_rate, samp_rate/4, 0.35, 10*4)) self.root_raised_cosine_filter_0 = filter.interp_fir_filter_ccf(4, firdes.root_raised_cosine( 1, samp_rate, samp_rate/4, 0.35, 10*4)) self.qtgui_time_sink_x_1_0_0_1_0_0 = qtgui.time_sink_f( 24*2, #size samp_rate/10, #samp_rate "Tx Bits", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0_1_0_0.set_update_time(.10) self.qtgui_time_sink_x_1_0_0_1_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0_0_1_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1_0_0_1_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0_1_0_0.enable_autoscale(True) self.qtgui_time_sink_x_1_0_0_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0_1_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0_0_1_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0_1_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_0_1_0_0_win) self.qtgui_time_sink_x_1_0_0_1_0 = qtgui.time_sink_f( 24*2, #size samp_rate/10, #samp_rate "RX bits", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0_1_0.set_update_time(.10) self.qtgui_time_sink_x_1_0_0_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0_0_1_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1_0_0_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0_1_0.enable_autoscale(True) self.qtgui_time_sink_x_1_0_0_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0_1_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0_0_1_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0_0_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_0_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_0_1_0_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["BER", "", "", "", "", "", "", "", "", ""] units = ["x10^-4", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1e4, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 10) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(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_2 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_2.set_update_time(0.10) self.qtgui_const_sink_x_2.set_y_axis(-2, 2) self.qtgui_const_sink_x_2.set_x_axis(-2, 2) self.qtgui_const_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_2.enable_autoscale(True) self.qtgui_const_sink_x_2.enable_grid(False) if not True: self.qtgui_const_sink_x_2.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_2.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_2.set_line_label(i, labels[i]) self.qtgui_const_sink_x_2.set_line_width(i, widths[i]) self.qtgui_const_sink_x_2.set_line_color(i, colors[i]) self.qtgui_const_sink_x_2.set_line_style(i, styles[i]) self.qtgui_const_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_2_win = sip.wrapinstance(self.qtgui_const_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_2_win) self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate) self._fosphor_qt_sink_c_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._fosphor_qt_sink_c_0_win) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(variable_constellation_0_1) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(([1+0j,0.707+0.707j, -0.707+0.707j, 0+1j, 0.707-0.707j, 0-1j, -1+0j, -0.707-0.707j]), 1) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(3) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(3) self.blocks_delay_1 = blocks.delay(gr.sizeof_char*1, 30) 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.blks2_error_rate_0 = grc_blks2.error_rate( type='SER', win_size=100000, bits_per_symbol=2, ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 10000)), True) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 1.0 / math.sqrt(2*2.0 * digital.constellation_8psk().bits_per_symbol() * 10**(EbN0/10)), 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_delay_1, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.root_raised_cosine_filter_0_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_1_0_0_1_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1_0_0_1_0_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.root_raised_cosine_filter_0, 0), (self.fosphor_qt_sink_c_0, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.qtgui_const_sink_x_2, 0))
def __init__(self): gr.top_block.__init__(self, "Testes") Qt.QWidget.__init__(self) self.setWindowTitle("Testes") 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", "testes") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.r = r = 10 self.n = n = 64800 self.EsN0_dB = EsN0_dB = 50 ################################################## # Blocks ################################################## self._EsN0_dB_range = Range(-50, 50, 1, 50, 200) self._EsN0_dB_win = RangeWidget(self._EsN0_dB_range, self.set_EsN0_dB, "EsN0_dB", "counter_slider", float) self.top_layout.addWidget(self._EsN0_dB_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.mapper_atsc_0 = mapper_atsc( m=4, n=2, r=r, ) self.demapper_atsc_0 = demapper_atsc( m=4, r=r, size_in=1, ) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream( gr.sizeof_float * 1, n) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_char * 1, n) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector( gr.sizeof_float * 1, n) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_char * 1, n) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, '/home/rossi/PN.ts', False) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000000000, bits_per_symbol=8, ) self.analog_noise_source_x_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, math.sqrt(1 / math.pow(10.0, (EsN0_dB / 10.0))), 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.demapper_atsc_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.mapper_atsc_0, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.demapper_atsc_0, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.mapper_atsc_0, 0), (self.blocks_add_xx_0, 1))
def __init__(self): gr.top_block.__init__(self, "Psk Test") Qt.QWidget.__init__(self) self.setWindowTitle("Psk Test") 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", "psk_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.my_constellation = my_constellation = digital.constellation_calcdist( (complex(0, 1), complex(1, 0), complex(0, 0), complex(1, 1)), (00, 01, 10, 11), 2, 2).base() ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 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.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_const_sink_x_0 = qtgui.const_sink_c( 1024, #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_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_decoder_cb_0 = digital.constellation_decoder_cb( my_constellation) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (my_constellation.points()), my_constellation.dimensionality()) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_head_0_0 = blocks.head(gr.sizeof_char * 1, 2000000) self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, 2000000) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1, "QPSK_in", False) self.blocks_file_sink_0_0.set_unbuffered(True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, "QPSK_out", False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=2, ) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, 1000)), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0.1, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_head_0_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_head_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_head_0, 0))
def __init__(self, address='serial=30AD34D'): gr.top_block.__init__(self, "MPSK TX RX") Qt.QWidget.__init__(self) self.setWindowTitle("MPSK TX RX") 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_RX") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.address = address ################################################## # Variables ################################################## self.const_type = const_type = 2 self.bits_per_symbol = bits_per_symbol = int(const_type + 1) self.samples_per_symbol = samples_per_symbol = int(2 * (bits_per_symbol)) self.probe_SNR = probe_SNR = 0 self.nfilts = nfilts = 32 self.bitrate = bitrate = 64e3 self.variable_qtgui_label_0 = variable_qtgui_label_0 = { 0: 'BPSK', 1: 'QPSK', 2: '8-PSK' }[const_type] + " - Change const_type for different constellation types!" self.tun_gain_tx = tun_gain_tx = 40 self.tun_freq_tx = tun_freq_tx = 2.39e9 self.timing_bw = timing_bw = 2 * math.pi / 100.0 self.samp_rate = samp_rate = samples_per_symbol * bitrate self.phase_bw = phase_bw = 2 * math.pi / 100.0 self.ntaps = ntaps = 11 * int(samples_per_symbol * nfilts) self.lo_offset = lo_offset = 6e6 self.gain_rx = gain_rx = 0.75 self.freq_rx = freq_rx = 2390e6 self.freq_bw = freq_bw = 2 * math.pi / 100.0 self.fll_ntaps = fll_ntaps = 55 self.excess_bw = excess_bw = 0.35 self.constellation = constellation = (digital.constellation_bpsk(), digital.constellation_qpsk(), digital.constellation_8psk()) self.arrity = arrity = pow(2, bits_per_symbol) self.ampl = ampl = 0.7 self.SNR = SNR = probe_SNR ################################################## # Blocks ################################################## self._tun_gain_tx_range = Range(0, 80, 1, 40, 200) self._tun_gain_tx_win = RangeWidget(self._tun_gain_tx_range, self.set_tun_gain_tx, 'UHD Tx Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._tun_gain_tx_win, 1, 0, 1, 1) self._tun_freq_tx_range = Range(2.3e9, 2.5e9, 1, 2.39e9, 200) self._tun_freq_tx_win = RangeWidget(self._tun_freq_tx_range, self.set_tun_freq_tx, 'UHD Tx Freq (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._tun_freq_tx_win, 0, 0, 1, 1) self._lo_offset_options = ( 0, 6e6, 11e6, ) self._lo_offset_labels = ( str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), ) self._lo_offset_tool_bar = Qt.QToolBar(self) self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": ")) self._lo_offset_combo_box = Qt.QComboBox() self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label) self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) self._lo_offset_callback(self.lo_offset) self._lo_offset_combo_box.currentIndexChanged.connect( lambda i: self.set_lo_offset(self._lo_offset_options[i])) self.top_grid_layout.addWidget(self._lo_offset_tool_bar, 2, 1, 1, 1) self._gain_rx_range = Range(0, 1, 0.01, 0.75, 200) self._gain_rx_win = RangeWidget(self._gain_rx_range, self.set_gain_rx, 'UHD Rx Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_rx_win, 1, 1, 1, 1) self._freq_rx_range = Range(2350e6, 2500e6, 10e6, 2390e6, 200) self._freq_rx_win = RangeWidget(self._freq_rx_range, self.set_freq_rx, 'UHD Rx Freq (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_rx_win, 0, 1, 1, 1) self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c( 2, 1000, 10 / bitrate) self._const_type_options = ( 0, 1, 2, ) self._const_type_labels = ( 'DBPSK', 'DQPSK', 'D8PSK', ) self._const_type_tool_bar = Qt.QToolBar(self) self._const_type_tool_bar.addWidget(Qt.QLabel("const_type" + ": ")) self._const_type_combo_box = Qt.QComboBox() self._const_type_tool_bar.addWidget(self._const_type_combo_box) for label in self._const_type_labels: self._const_type_combo_box.addItem(label) self._const_type_callback = lambda i: Qt.QMetaObject.invokeMethod( self._const_type_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._const_type_options.index(i))) self._const_type_callback(self.const_type) self._const_type_combo_box.currentIndexChanged.connect( lambda i: self.set_const_type(self._const_type_options[i])) self.top_layout.addWidget(self._const_type_tool_bar) self._ampl_range = Range(0, 1, 0.01, 0.7, 200) self._ampl_win = RangeWidget(self._ampl_range, self.set_ampl, 'Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._ampl_win, 2, 0, 1, 1) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: x self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel('Constellation Type' + ": ")) self._variable_qtgui_label_0_label = Qt.QLabel( str( self._variable_qtgui_label_0_formatter( self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget( self._variable_qtgui_label_0_label) self.top_layout.addWidget(self._variable_qtgui_label_0_tool_bar) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((address, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_subdev_spec('A:A', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(freq_rx, rf_freq=freq_rx - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_normalized_gain(gain_rx, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join((address, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_subdev_spec('A:B', 0) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(tun_freq_tx, 0) self.uhd_usrp_sink_0_0.set_gain(tun_gain_tx, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self.qtgui_number_sink_0_1 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_1.set_update_time(0.10) self.qtgui_number_sink_0_1.set_title("BER") labels = ['BER', '', '', '', '', '', '', '', '', ''] units = ['x10^-6', '', '', '', '', '', '', '', '', ''] 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_1.set_min(i, 0) self.qtgui_number_sink_0_1.set_max(i, 1) self.qtgui_number_sink_0_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_1.set_label(i, labels[i]) self.qtgui_number_sink_0_1.set_unit(i, units[i]) self.qtgui_number_sink_0_1.set_factor(i, factor[i]) self.qtgui_number_sink_0_1.enable_autoscale(True) self._qtgui_number_sink_0_1_win = sip.wrapinstance( self.qtgui_number_sink_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_1_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-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, 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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 3, 1, 1, 1) def _probe_SNR_probe(): while True: val = self.digital_probe_mpsk_snr_est_c_0.snr() try: self.set_probe_SNR(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_SNR_thread = threading.Thread(target=_probe_SNR_probe) _probe_SNR_thread.daemon = True _probe_SNR_thread.start() self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( samples_per_symbol, taps=(firdes.root_raised_cosine(nfilts, nfilts, 1.0, 0.35, ntaps)), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x8A, 0x7F, 7) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( samples_per_symbol, timing_bw, (firdes.root_raised_cosine( nfilts, nfilts * samples_per_symbol, 1.0, 0.35, ntaps)), nfilts, nfilts // 2, 1.5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( samples_per_symbol, excess_bw, fll_ntaps, freq_bw) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(arrity) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(arrity) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x8A, 0x7F, 7) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( timing_bw, pow(2, bits_per_symbol), False) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb( constellation[const_type].base()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (constellation[const_type].points()), 1) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([ 1, ], True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_b([ 1, ], True, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb( bits_per_symbol) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(bits_per_symbol) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((ampl, )) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=10000, bits_per_symbol=1, ) self.analog_agc2_xx_0 = analog.agc2_cc(0.6e-1, 1e-3, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) self._SNR_tool_bar = Qt.QToolBar(self) if None: self._SNR_formatter = None else: self._SNR_formatter = lambda x: x self._SNR_tool_bar.addWidget(Qt.QLabel("SNR" + ": ")) self._SNR_label = Qt.QLabel(str(self._SNR_formatter(self.SNR))) self._SNR_tool_bar.addWidget(self._SNR_label) self.top_layout.addWidget(self._SNR_tool_bar) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0_1, 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, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_probe_mpsk_snr_est_c_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "BER Simulation") Qt.QWidget.__init__(self) self.setWindowTitle("BER Simulation") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "ber_simulation") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.tx_amp = tx_amp = 10 self.samp_rate_0 = samp_rate_0 = 32000 self.samp_rate = samp_rate = 100e3 self.offset = offset = math.pi / 4 self.freq = freq = 1e3 self.const_type = const_type = 2 self.const = const = (digital.constellation_bpsk(), digital.constellation_qpsk(), digital.constellation_8psk()) self.EbN0 = EbN0 = 10 ################################################## # Blocks ################################################## self._offset_range = Range(0, math.pi / 2, math.pi / 20, math.pi / 4, 20) self._offset_win = RangeWidget(self._offset_range, self.set_offset, 'Offset', "dial", float) self.top_grid_layout.addWidget(self._offset_win, 3, 2, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(3, 4)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(2, 3)] self._EbN0_range = Range(-10, 200, 1, 10, 200) self._EbN0_win = RangeWidget(self._EbN0_range, self.set_EbN0, 'Eb / N0 (dB)', "counter_slider", float) self.top_grid_layout.addWidget(self._EbN0_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_number_sink_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0_0.set_update_time(0.01) self.qtgui_number_sink_0_0_0.set_title("Combined") labels = ['BER', '', '', '', '', '', '', '', '', ''] units = ['x10^-6', '', '', '', '', '', '', '', '', ''] 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_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0.set_max(i, 1) self.qtgui_number_sink_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0.enable_autoscale(True) self._qtgui_number_sink_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_win, 1, 2, 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(2, 3)] self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0.set_update_time(0.01) self.qtgui_number_sink_0_0.set_title("Vertical") labels = ['BER', '', '', '', '', '', '', '', '', ''] units = ['x10^-6', '', '', '', '', '', '', '', '', ''] 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_0.set_min(i, 0) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(True) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_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.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.01) self.qtgui_number_sink_0.set_title("Horizontal") labels = ['BER', '', '', '', '', '', '', '', '', ''] units = ['x10^-6', '', '', '', '', '', '', '', '', ''] 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, 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_0_0 = qtgui.const_sink_c( 1024, #size "Result of Maximal Combining", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_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.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0.disable_legend() labels = [ "Constellation: " + str(const[const_type].arity()) + "-PSK", '', '', '', '', '', '', '', '', '' ] 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 = [0.6, 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.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2, 2, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(2, 3)] self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "Vertical Channel", #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 = [ "Constellation: " + str(const[const_type].arity()) + "-PSK", '', '', '', '', '', '', '', '', '' ] 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 = [0.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 2, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "Horizontal Channel", #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 = [ "Constellation: " + str(const[const_type].arity()) + "-PSK", '', '', '', '', '', '', '', '', '' ] 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 = [0.6, 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, 2, 0, 1, 1) [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, 1)] self.digital_constellation_decoder_cb_0_0_0 = digital.constellation_decoder_cb( const[const_type].base()) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb( const[const_type].base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( const[const_type].base()) self.digital_chunks_to_symbols_xx = digital.chunks_to_symbols_bc( (const[const_type].points()), 1) self.blocks_throttle = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_xx = blocks.add_vcc(1) self.blks2_error_rate_1 = grc_blks2.error_rate( type='BER', win_size=int(1e7), bits_per_symbol=const[const_type].bits_per_symbol(), ) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=int(1e7), bits_per_symbol=const[const_type].bits_per_symbol(), ) self.blks2_error_rate = grc_blks2.error_rate( type='BER', win_size=int(1e7), bits_per_symbol=const[const_type].bits_per_symbol(), ) self.analog_random_source_x = blocks.vector_source_b( map(int, numpy.random.randint(0, const[const_type].arity(), 10000000)), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1.0 / math.sqrt(2.0 * const[const_type].bits_per_symbol() * 10**(math.cos(math.pi / 2 - offset) * math.cos(math.pi / 2 - offset) * EbN0 / 10)), -42) self.analog_noise_source_x = analog.noise_source_c( analog.GR_GAUSSIAN, 1.0 / math.sqrt(2.0 * const[const_type].bits_per_symbol() * 10**(math.cos(offset) * math.cos(offset) * EbN0 / 10)), -42) self.Maximal_Combining_0 = Maximal_Combining() ################################################## # Connections ################################################## self.connect((self.Maximal_Combining_0, 0), (self.digital_constellation_decoder_cb_0_0_0, 0)) self.connect((self.Maximal_Combining_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.analog_noise_source_x, 0), (self.blocks_add_xx, 1)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x, 0), (self.blocks_throttle, 0)) self.connect((self.analog_random_source_x, 0), (self.digital_chunks_to_symbols_xx, 0)) self.connect((self.blks2_error_rate, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blks2_error_rate_1, 0), (self.qtgui_number_sink_0_0_0, 0)) self.connect((self.blocks_add_xx, 0), (self.Maximal_Combining_0, 0)) self.connect((self.blocks_add_xx, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_add_xx, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.Maximal_Combining_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.blocks_throttle, 0), (self.blks2_error_rate, 0)) self.connect((self.blocks_throttle, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_throttle, 0), (self.blks2_error_rate_1, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.blocks_add_xx, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate, 1)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_constellation_decoder_cb_0_0_0, 0), (self.blks2_error_rate_1, 1))
def __init__(self, options): """ Hierarchical block for O-QPSK demodulation. The input is the complex modulated signal at baseband and the output is a stream of bytes. @param sps: samples per symbol @type sps: integer """ try: #self.sps = kwargs.pop('sps') self.sps = 2 except KeyError: pass gr.hier_block2.__init__(self, "oqpsk_demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input gr.io_signature(0, 0, 0)) # Output # Demodulate FM sensitivity = (pi / 2) / self.sps #self.fmdemod = gr.quadrature_demod_cf(1.0 / sensitivity) self.fmdemod = gr.quadrature_demod_cf(1) # Low pass the output of fmdemod to allow us to remove # the DC offset resulting from frequency offset alpha = 0.0008/self.sps self.freq_offset = gr.single_pole_iir_filter_ff(alpha) self.sub = gr.sub_ff() # recover the clock omega = self.sps gain_mu=0.03 mu=0.5 omega_relative_limit=0.0002 freq_error=0.0 gain_omega = .25*gain_mu*gain_mu # critically damped # Descramble BERT sequence. A channel error will create 3 incorrect bits #self._descrambler = gr.descrambler_bb(0x8A, 0x7F, 31) # CCSDS 7-bit descrambler self.clock_recovery_f = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit) self.gr_float_to_complex = gr.float_to_complex(1) #Create a vector source reference to calculate BER self._vector_source_ref = gr.vector_source_b(([1,]), True, 1) #create a comparator self.comparator = howto.compare_vector_cci((1, 1, 1, 1 ,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1), (0,0, 1, 1, 0,0), 5, 0, True) self._ber = grc_blks2.error_rate(type='BER', win_size=1000, bits_per_symbol=1) self._slicer = digital.binary_slicer_fb() self.gr_null_sink_f = gr.null_sink(gr.sizeof_float*1) # Add an SNR probe on the demodulated constellation #self._snr_probe = gr.probe_mpsk_snr_c(10.0/symbol_rate) self._snr_probe = digital.mpsk_snr_est_cc(0, 10000, 0.001) # 0 at the first mean Simple self.gr_null_sink_cc = gr.null_sink(gr.sizeof_gr_complex*1) self.gr_null_source = gr.null_source(gr.sizeof_float*1) ############################### ###-------> -->gr_float_to_complex--->_snr_probe --> gr_null_sink_cc ###---->fmdemod -->freq_offset--->sub-->clock_recovery --> _slicer -->_descrambler --> comparator -->_ber--> self.gr_null_sink_f ###'''''''''''''|-->----------------|-->' _vector_source_ref--> ############################# # Connect self.connect(self, self.fmdemod) self.connect(self.fmdemod, (self.sub, 0)) self.connect(self.fmdemod, self.freq_offset, (self.sub, 1)) #self.connect(self.sub, self.clock_recovery_f, self._slicer, self._descrambler, self.comparator, (self._ber, 0)) self.connect(self.sub, self.clock_recovery_f, self._slicer, self.comparator, (self._ber, 0)) # self.connect(self.clock_recovery_f, (self.gr_float_to_complex, 1)) # self.connect(self.gr_null_source, (self.gr_float_to_complex, 0)) # # self.connect(self.gr_float_to_complex, self._snr_probe, self.gr_null_sink_cc) self.connect(self._vector_source_ref, (self._ber,1)) self.connect(self._ber, self.gr_null_sink_f)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.thresh = thresh = 900*10**-3 self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## _thresh_sizer = wx.BoxSizer(wx.VERTICAL) self._thresh_text_box = forms.text_box( parent=self.GetWin(), sizer=_thresh_sizer, value=self.thresh, callback=self.set_thresh, label='thresh', converter=forms.float_converter(), proportion=0, ) self._thresh_slider = forms.slider( parent=self.GetWin(), sizer=_thresh_sizer, value=self.thresh, callback=self.set_thresh, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_thresh_sizer) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=200*10**-3, v_offset=0, t_scale=100*10**-3, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=0, maxval=1, factor=1.0, decimal_places=6, ref_level=0, sample_rate=samp_rate, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.digital_glfsr_source_x_0 = digital.glfsr_source_b(6, True, 0, 1) self.blocks_xor_xx_0 = blocks.xor_bb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_threshold_ff_0 = blocks.threshold_ff(thresh, thresh, 0) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((0.5, )) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1280, bits_per_symbol=1, ) self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_UNIFORM, 0.5, 32) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_xor_xx_0, 1)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_xor_xx_0, 0)) self.connect((self.blocks_xor_xx_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_glfsr_source_x_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__( self, "8PSK Modulation and Demodulation with Frequency Correction Simulation" ) Qt.QWidget.__init__(self) self.setWindowTitle( "8PSK Modulation and Demodulation with Frequency Correction Simulation" ) qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "E8PSK_ModDemod_FC") 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.RangeRow = RangeRow = 0 self.BiRow = BiRow = RangeRow + 1 self.ConsRow = ConsRow = BiRow + 1 self.samp_rate = samp_rate = 1e6 self.nfilts = nfilts = 100 self.SampSymb = SampSymb = 8 self.FreqRow = FreqRow = ConsRow + 1 self.FDP = FDP = 0.005 self.rrc_taps_0 = rrc_taps_0 = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(SampSymb), 0.35, 45 * nfilts) self.min_PLL = min_PLL = 2 * np.pi * (1 / float(SampSymb) - 1 / float(SampSymb) * FDP) self.max_PLL = max_PLL = 2 * np.pi * (1 / float(SampSymb) + 1 / float(SampSymb) * FDP) self.Values = Values = 2 self.TimeRow = TimeRow = FreqRow + 1 self.SPS = SPS = 2 self.QPSK_CO = QPSK_CO = digital.constellation_qpsk().base() self.Noise = Noise = 0 self.LBP_PLL = LBP_PLL = (samp_rate / float(SampSymb) - samp_rate / float(SampSymb) * FDP * 2) self.HBP_PLL = HBP_PLL = (samp_rate / float(SampSymb) + samp_rate / float(SampSymb) * FDP * 2) self.FreqOff = FreqOff = 0.005 ################################################## # Blocks ################################################## self._Noise_range = Range(0, 1, 0.01, 0, 200) self._Noise_win = RangeWidget(self._Noise_range, self.set_Noise, 'Channel Noise', "counter_slider", float) self.top_grid_layout.addWidget(self._Noise_win, 0, 1, 1, 2) [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, 3)] self._FreqOff_range = Range(-1, 1, 0.001, 0.005, 200) self._FreqOff_win = RangeWidget(self._FreqOff_range, self.set_FreqOff, 'Frequency Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._FreqOff_win, 0, 3, 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(3, 4)] self.sync_encoder = sync_encoder.blk() self.sync_decoder = sync_decoder.blk() self.repeat_first_byte = repeat_first_byte.blk(repeat=3) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 512, #size samp_rate, #samp_rate "Original vs Received Data", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.064) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['Original', 'Received', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(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, 1, 0, 1, 3) [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, 3)] self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_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_0.set_min(i, 0) self.qtgui_number_sink_0_0.set_max(i, 255) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win, 0, 4, 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(4, 5)] 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("First Byte") 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, 0) self.qtgui_number_sink_0.set_max(i, 255) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 5, 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(5, 6)] self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Pre PSK Demod", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.064) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['Received', 'Mod', '', '', '', '', '', '', '', ''] 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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 1, 3, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(3, 5)] self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Post Polyphase Clock", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(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, 3, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(3, 4)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Post_Channel_Model", #name 3 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = [ 'Post PLL CPSK', 'Post Filter', 'Pre Filter', '', '', '', '', '', '', '' ] 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(3): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 3, 0, 1, 1) [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, 1)] self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "Pre Polyphase Clock", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.1) 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(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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 2, 0, 1, 1) [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, 1)] self.get_first_byte = get_first_byte.blk() self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=8, mod_code="gray", differential=True, samples_per_symbol=SampSymb, excess_bw=0.35, verbose=False, log=False, ) self.digital_psk_demod_0 = digital.psk.psk_demod( constellation_points=8, differential=True, samples_per_symbol=SampSymb, excess_bw=0.35, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False, ) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( SampSymb, 0.1, (rrc_taps_0), nfilts, nfilts / 2, 1.5, 1) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.1, 8, False) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 15, 1, .01, 2) self.channels_channel_model_0 = channels.channel_model( noise_voltage=Noise, frequency_offset=FreqOff, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False) self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_skiphead_1 = blocks.skiphead(gr.sizeof_char * 1, 3) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, 31) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 1, 8, "", False, gr.GR_MSB_FIRST) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_char * 1, 5) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=64000, bits_per_symbol=8, ) self.band_pass_filter_0_0 = filter.interp_fir_filter_ccf( 1, firdes.band_pass(1, samp_rate, (2 * samp_rate / float(SampSymb) - 130e3), (2 * samp_rate / float(SampSymb) + 100e3), 10e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.interp_fir_filter_ccf( 1, firdes.band_pass(1, samp_rate, 95e3, 105e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0_0_0 = analog.sig_source_c( samp_rate, analog.GR_SIN_WAVE, 100e3, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_SIN_WAVE, 100e3, 1, 0) self.analog_pll_refout_cc_0 = analog.pll_refout_cc( 0.2, 2 * np.pi * 103e3 / samp_rate, 2 * np.pi * 97e3 / samp_rate) self.Video_Source = blocks.file_source( gr.sizeof_char * 1, '/home/teddy/Documents/DVB_last_stand/Source_Files/Test_Video.ts', False) self.Video_Sink = blocks.file_sink( gr.sizeof_char * 1, '/home/teddy/Documents/DVB_last_stand/Received_Files/Test_Video_8PSK_FC_received.ts', False) self.Video_Sink.set_unbuffered(True) self._Values_range = Range(0, 255, 1, 2, 200) self._Values_win = RangeWidget(self._Values_range, self.set_Values, 'Vector Values', "counter_slider", int) self.top_grid_layout.addWidget(self._Values_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.Post_Polyphase_Clock_Cons = qtgui.const_sink_c( 1024, #size 'Post Polyphase Clock', #name 1 #number of inputs ) self.Post_Polyphase_Clock_Cons.set_update_time(0.10) self.Post_Polyphase_Clock_Cons.set_y_axis(-2, 2) self.Post_Polyphase_Clock_Cons.set_x_axis(-2, 2) self.Post_Polyphase_Clock_Cons.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.Post_Polyphase_Clock_Cons.enable_autoscale(False) self.Post_Polyphase_Clock_Cons.enable_grid(True) self.Post_Polyphase_Clock_Cons.enable_axis_labels(True) if not False: self.Post_Polyphase_Clock_Cons.disable_legend() 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 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 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(1): if len(labels[i]) == 0: self.Post_Polyphase_Clock_Cons.set_line_label( i, "Data {0}".format(i)) else: self.Post_Polyphase_Clock_Cons.set_line_label(i, labels[i]) self.Post_Polyphase_Clock_Cons.set_line_width(i, widths[i]) self.Post_Polyphase_Clock_Cons.set_line_color(i, colors[i]) self.Post_Polyphase_Clock_Cons.set_line_style(i, styles[i]) self.Post_Polyphase_Clock_Cons.set_line_marker(i, markers[i]) self.Post_Polyphase_Clock_Cons.set_line_alpha(i, alphas[i]) self._Post_Polyphase_Clock_Cons_win = sip.wrapinstance( self.Post_Polyphase_Clock_Cons.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._Post_Polyphase_Clock_Cons_win, 2, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self.Post_Costas_Loop_Freq = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Post Costas Loop", #name 1 #number of inputs ) self.Post_Costas_Loop_Freq.set_update_time(0.10) self.Post_Costas_Loop_Freq.set_y_axis(-140, 10) self.Post_Costas_Loop_Freq.set_y_label('Relative Gain', 'dB') self.Post_Costas_Loop_Freq.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.Post_Costas_Loop_Freq.enable_autoscale(False) self.Post_Costas_Loop_Freq.enable_grid(False) self.Post_Costas_Loop_Freq.set_fft_average(1.0) self.Post_Costas_Loop_Freq.enable_axis_labels(True) self.Post_Costas_Loop_Freq.enable_control_panel(False) if not False: self.Post_Costas_Loop_Freq.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.Post_Costas_Loop_Freq.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.Post_Costas_Loop_Freq.set_line_label( i, "Data {0}".format(i)) else: self.Post_Costas_Loop_Freq.set_line_label(i, labels[i]) self.Post_Costas_Loop_Freq.set_line_width(i, widths[i]) self.Post_Costas_Loop_Freq.set_line_color(i, colors[i]) self.Post_Costas_Loop_Freq.set_line_alpha(i, alphas[i]) self._Post_Costas_Loop_Freq_win = sip.wrapinstance( self.Post_Costas_Loop_Freq.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._Post_Costas_Loop_Freq_win, 3, 3, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(3, 4)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(3, 4)] self.Post_Costas_Loop_Cons = qtgui.const_sink_c( 1024, #size 'Post Costas Loop', #name 1 #number of inputs ) self.Post_Costas_Loop_Cons.set_update_time(0.10) self.Post_Costas_Loop_Cons.set_y_axis(-2, 2) self.Post_Costas_Loop_Cons.set_x_axis(-2, 2) self.Post_Costas_Loop_Cons.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.Post_Costas_Loop_Cons.enable_autoscale(False) self.Post_Costas_Loop_Cons.enable_grid(False) self.Post_Costas_Loop_Cons.enable_axis_labels(True) if not False: self.Post_Costas_Loop_Cons.disable_legend() labels = ['Locked', '', '', '', '', '', '', '', '', ''] 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 xrange(1): if len(labels[i]) == 0: self.Post_Costas_Loop_Cons.set_line_label( i, "Data {0}".format(i)) else: self.Post_Costas_Loop_Cons.set_line_label(i, labels[i]) self.Post_Costas_Loop_Cons.set_line_width(i, widths[i]) self.Post_Costas_Loop_Cons.set_line_color(i, colors[i]) self.Post_Costas_Loop_Cons.set_line_style(i, styles[i]) self.Post_Costas_Loop_Cons.set_line_marker(i, markers[i]) self.Post_Costas_Loop_Cons.set_line_alpha(i, alphas[i]) self._Post_Costas_Loop_Cons_win = sip.wrapinstance( self.Post_Costas_Loop_Cons.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._Post_Costas_Loop_Cons_win, 2, 3, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(3, 4)] self.Post_CMA_Equalizer_Freq = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Post CMA Equalizer", #name 1 #number of inputs ) self.Post_CMA_Equalizer_Freq.set_update_time(0.10) self.Post_CMA_Equalizer_Freq.set_y_axis(-140, 10) self.Post_CMA_Equalizer_Freq.set_y_label('Relative Gain', 'dB') self.Post_CMA_Equalizer_Freq.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.Post_CMA_Equalizer_Freq.enable_autoscale(False) self.Post_CMA_Equalizer_Freq.enable_grid(False) self.Post_CMA_Equalizer_Freq.set_fft_average(1.0) self.Post_CMA_Equalizer_Freq.enable_axis_labels(True) self.Post_CMA_Equalizer_Freq.enable_control_panel(False) if not False: self.Post_CMA_Equalizer_Freq.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.Post_CMA_Equalizer_Freq.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.Post_CMA_Equalizer_Freq.set_line_label( i, "Data {0}".format(i)) else: self.Post_CMA_Equalizer_Freq.set_line_label(i, labels[i]) self.Post_CMA_Equalizer_Freq.set_line_width(i, widths[i]) self.Post_CMA_Equalizer_Freq.set_line_color(i, colors[i]) self.Post_CMA_Equalizer_Freq.set_line_alpha(i, alphas[i]) self._Post_CMA_Equalizer_Freq_win = sip.wrapinstance( self.Post_CMA_Equalizer_Freq.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._Post_CMA_Equalizer_Freq_win, 3, 2, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(3, 4)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(2, 3)] self.Post_CMA_Eq_Cons = qtgui.const_sink_c( 1024, #size 'Post CMA Equalizer', #name 1 #number of inputs ) self.Post_CMA_Eq_Cons.set_update_time(0.10) self.Post_CMA_Eq_Cons.set_y_axis(-2, 2) self.Post_CMA_Eq_Cons.set_x_axis(-2, 2) self.Post_CMA_Eq_Cons.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.Post_CMA_Eq_Cons.enable_autoscale(False) self.Post_CMA_Eq_Cons.enable_grid(False) self.Post_CMA_Eq_Cons.enable_axis_labels(True) if not False: self.Post_CMA_Eq_Cons.disable_legend() 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 xrange(1): if len(labels[i]) == 0: self.Post_CMA_Eq_Cons.set_line_label(i, "Data {0}".format(i)) else: self.Post_CMA_Eq_Cons.set_line_label(i, labels[i]) self.Post_CMA_Eq_Cons.set_line_width(i, widths[i]) self.Post_CMA_Eq_Cons.set_line_color(i, colors[i]) self.Post_CMA_Eq_Cons.set_line_style(i, styles[i]) self.Post_CMA_Eq_Cons.set_line_marker(i, markers[i]) self.Post_CMA_Eq_Cons.set_line_alpha(i, alphas[i]) self._Post_CMA_Eq_Cons_win = sip.wrapinstance( self.Post_CMA_Eq_Cons.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._Post_CMA_Eq_Cons_win, 2, 2, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(2, 3)] ################################################## # Connections ################################################## self.connect((self.Video_Source, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.band_pass_filter_0, 0), (self.analog_pll_refout_cc_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.digital_psk_demod_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_multiply_xx_1, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.blocks_skiphead_0, 0), (self.sync_decoder, 0)) self.connect((self.blocks_skiphead_1, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_skiphead_1, 0), (self.blocks_uchar_to_float_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_skiphead_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.repeat_first_byte, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_uchar_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 2)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.Post_CMA_Eq_Cons, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.Post_CMA_Equalizer_Freq, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.Post_Costas_Loop_Cons, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.Post_Costas_Loop_Freq, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.Post_Polyphase_Clock_Cons, 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_freq_sink_x_0_0, 0)) self.connect((self.digital_psk_demod_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.digital_psk_mod_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.get_first_byte, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.repeat_first_byte, 0), (self.sync_encoder, 0)) self.connect((self.sync_decoder, 0), (self.Video_Sink, 0)) self.connect((self.sync_decoder, 0), (self.blks2_error_rate_0, 1)) self.connect((self.sync_decoder, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.sync_decoder, 0), (self.get_first_byte, 0)) self.connect((self.sync_encoder, 0), (self.digital_psk_mod_0, 0))
def __init__(self): gr.top_block.__init__(self, "Img Transfer Simu") Qt.QWidget.__init__(self) self.setWindowTitle("Img Transfer Simu") 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", "img_transfer_simu") 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.000 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_gray = qpsk_gray = 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.payload_lenght = payload_lenght = 0 self.noise_volt = noise_volt = 0.0100 self.freq_offset = freq_offset = 0.000 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) self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28 / 100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, "Time: BW", "counter_slider", float) self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0, 0, 1, 1) self._time_offset_range = Range(0.9, 1.1, 0.005, 1.000, 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", "counter_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.0100, 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.000, 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", "counter_slider", float) self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0, 1, 1, 1) self.tutorial_my_qpsk_demod_cb_1 = tutorial.my_qpsk_demod_cb(True) 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(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_control_panel(True) 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_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.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(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.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_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_gray, 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_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 2, 8, "", False, gr.GR_MSB_FIRST) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, "/home/tochou/SDR-ACARS/dqpsk_receiver/sources_files/babouin.png", True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, "/home/tochou/SDR-ACARS/dqpsk_receiver/out_files/img_out.png", False) self.blocks_file_sink_0.set_unbuffered(True) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=4, bits_per_symbol=2, preamble="", access_code="", pad_for_usrp=False, ), payload_length=payload_lenght, ) 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.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=2, ) ################################################## # Connections ################################################## self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_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_my_qpsk_demod_cb_1, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_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_my_qpsk_demod_cb_1, 0), (self.digital_map_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "BER Simulation") Qt.QWidget.__init__(self) self.setWindowTitle("BER Simulation") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "ber_simulation") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.const_type = const_type = 1 self.variable_qtgui_label_0 = variable_qtgui_label_0 = { 0: 'BPSK', 1: 'QPSK', 2: '8-PSK' }[const_type] + " - Change const_type for different constellation types!" self.samp_rate = samp_rate = 100e3 self.const = const = (digital.constellation_bpsk(), digital.constellation_qpsk(), digital.constellation_8psk()) self.EbN0 = EbN0 = 10 ################################################## # Blocks ################################################## self._EbN0_range = Range(-10, 200, 1, 10, 200) self._EbN0_win = RangeWidget(self._EbN0_range, self.set_EbN0, 'Eb / N0 (dB)', "counter_slider", float) self.top_layout.addWidget(self._EbN0_win) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel('Constellation Type' + ": ")) self._variable_qtgui_label_0_label = Qt.QLabel( str( self._variable_qtgui_label_0_formatter( self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget( self._variable_qtgui_label_0_label) self.top_layout.addWidget(self._variable_qtgui_label_0_tool_bar) 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("") labels = ['BER', '', '', '', '', '', '', '', '', ''] units = ['x10^-6', '', '', '', '', '', '', '', '', ''] 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, 1, 0, 1, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "foo", #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 = [ "Constellation: " + str(const[const_type].arity()) + "-PSK", '', '', '', '', '', '', '', '', '' ] 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 = [0.6, 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, 2, 0, 1, 1) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( const[const_type].base()) self.digital_chunks_to_symbols_xx = digital.chunks_to_symbols_bc( (const[const_type].points()), 1) self.blocks_throttle = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, 'test_output.txt', True) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_add_xx = blocks.add_vcc(1) self.blks2_error_rate = grc_blks2.error_rate( type='BER', win_size=int(1e7), bits_per_symbol=const[const_type].bits_per_symbol(), ) self.analog_random_source_x = blocks.vector_source_b( map(int, numpy.random.randint(0, const[const_type].arity(), 10000000)), True) self.analog_noise_source_x = analog.noise_source_c( analog.GR_GAUSSIAN, 1.0 / math.sqrt( 2.0 * const[const_type].bits_per_symbol() * 10**(EbN0 / 10)), 42) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x, 0), (self.blocks_add_xx, 1)) self.connect((self.analog_random_source_x, 0), (self.blocks_throttle, 0)) self.connect((self.analog_random_source_x, 0), (self.digital_chunks_to_symbols_xx, 0)) self.connect((self.blks2_error_rate, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_add_xx, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_add_xx, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_add_xx, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle, 0), (self.blks2_error_rate, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.blocks_add_xx, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate, 1))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.my_constellation = my_constellation = digital.constellation_calcdist(([-1, -1j,1,1j]), ([0, 1,2,3]), 4, 1).base() ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-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_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_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(True) 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_decoder_cb_0 = digital.constellation_decoder_cb(my_constellation) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((1, 1j, -1, -1j), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_head_0_1 = blocks.head(gr.sizeof_char*1, 100000) self.blocks_head_0_0_0 = blocks.head(gr.sizeof_char*1, 100000) self.blocks_file_sink_0_0_1 = blocks.file_sink(gr.sizeof_char*1, "/home/ubuntu/trx_qpsk_30.bin", False) self.blocks_file_sink_0_0_1.set_unbuffered(True) self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char*1, "/home/ubuntu/rx_qpsk_30.bin", False) self.blocks_file_sink_0_0_0.set_unbuffered(True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=1, ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 4, 100000)), True) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 30, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_head_0_1, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_head_0_0_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.blocks_head_0_1, 0), (self.blocks_file_sink_0_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_head_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Viterbi Equalization") Qt.QWidget.__init__(self) self.setWindowTitle("Viterbi Equalization") 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", "viterbi_equalization") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.modulation = modulation = fu.pam4 self.channel = channel = fu.c_channel self.tot_mod = tot_mod = fu.make_isi_lookup(modulation, channel, False) self.fsm = fsm = trellis.fsm(len(modulation[1]), len(channel)) self.bpsym = bpsym = int(round(math.log(fsm.I()) / math.log(2))) self.EsN0_dB = EsN0_dB = 2 self.Es = Es = numpy.mean((numpy.square(numpy.abs(tot_mod[1])))) self.noisevar = noisevar = 10**(-EsN0_dB / 10.0) * Es / 2.0 self.block = block = bpsym * 1000 self.R = R = 100e3 ################################################## # Blocks ################################################## self.trellis_viterbi_combined_xx_0 = trellis.viterbi_combined_fb( trellis.fsm(fsm), block / bpsym, -1, -1, tot_mod[0], (tot_mod[1]), digital.TRELLIS_EUCLIDEAN) 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 = ['BER', '', '', '', '', '', '', '', '', ''] 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, 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(False) 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.fir_filter_xxx_0 = filter.fir_filter_fff(1, (fu.c_channel)) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bf( (modulation[1]), modulation[0]) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bpsym) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, R, True) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(bpsym) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_add_xx_1 = blocks.add_vff(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=1, ) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, 1007)), True) self.analog_noise_source_x_0 = analog.noise_source_f( analog.GR_GAUSSIAN, noisevar**0.5, -42) self._EsN0_dB_range = Range(-10, 30, 1, 2, 200) self._EsN0_dB_win = RangeWidget(self._EsN0_dB_range, self.set_EsN0_dB, 'Es/N0 (dB)', "counter_slider", float) self.top_layout.addWidget(self._EsN0_dB_win) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_null_sink_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.trellis_viterbi_combined_xx_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.trellis_viterbi_combined_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
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, "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 __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.interleave_depth = interleave_depth = 4 self.hamming_distance = hamming_distance = 0 self.ber = ber = 0 ################################################## # 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("") 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, 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(False) 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.channelcoding_binary_symmetric_channel_0 = channelcoding.binary_symmetric_channel(0.1,8,1653) self.ccsds_rs_encode_0 = ccsds.rs_encode(1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char*1, (256, interleave_depth*255+4)) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=8, ) self._ber_range = Range(0, 1, 0.01, 0, 200) self._ber_win = RangeWidget(self._ber_range, self.set_ber, "BER", "counter_slider", float) self.top_layout.addWidget(self._ber_win) self.analog_random_uniform_source_x_0_0 = analog.random_uniform_source_b(0, 256, 27) self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b(0, 256, 0) ################################################## # Connections ################################################## self.connect((self.analog_random_uniform_source_x_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.analog_random_uniform_source_x_0_0, 0), (self.ccsds_rs_encode_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.channelcoding_binary_symmetric_channel_0, 0)) self.connect((self.ccsds_rs_encode_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.channelcoding_binary_symmetric_channel_0, 0), (self.blks2_error_rate_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="fhss_test") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_sym = samp_sym = 64 self.samp_rate = samp_rate = 400e3 self.init = init = 1, 1, 1, 1 self.generator = generator = 1, 1, 0, 0, 1 self.code_rate = code_rate = int(samp_sym * 500) ################################################## # Blocks ################################################## self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Received Spread Spectrum ", ) self.Add(self.wxgui_waterfallsink2_0.win) self.wxgui_numbersink2_0_0_0_0_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-100e5, maxval=100e5, factor=1.0, decimal_places=10, ref_level=0, sample_rate=samp_rate, number_rate=60, average=False, avg_alpha=None, label="Error", peak_hold=False, show_gauge=False, ) self.Add(self.wxgui_numbersink2_0_0_0_0_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Despread Signal", peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0.win, 0, 2, 2, 4) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "serial=F54381")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_source("internal", 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(500e6, 0) self.uhd_usrp_source_0.set_gain(47, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "serial=F54358")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_clock_source("internal", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(500e6, 0) self.uhd_usrp_sink_0.set_gain(50, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 1, 1, 1), True, 1, []) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.9, )) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=1, ) self.Spread_synthesizer_0 = Spread.synthesizer(code_rate, 0, samp_rate, (generator), (init)) self.Spread_rx_synthesizer_0 = Spread.rx_synthesizer( code_rate, samp_sym, samp_rate, 12000, 50000, 0.16, (generator), (init)) self.Spread_cpfsk_mod_0 = Spread.cpfsk_mod(samp_sym) self.Spread_cpfsk_demod_0 = Spread.cpfsk_demod(samp_sym) ################################################## # Connections ################################################## self.connect((self.blks2_error_rate_0, 0), (self.wxgui_numbersink2_0_0_0_0_0, 0)) self.connect((self.Spread_cpfsk_demod_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blocks_vector_source_x_0, 0), (self.Spread_cpfsk_mod_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.Spread_rx_synthesizer_0, 0)) self.connect((self.Spread_synthesizer_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.Spread_rx_synthesizer_0, 0), (self.Spread_cpfsk_demod_0, 0)) self.connect((self.Spread_cpfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.Spread_synthesizer_0, 0)) self.connect((self.Spread_rx_synthesizer_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit='%', minval=0, maxval=1, factor=1.0, decimal_places=10, ref_level=0, sample_rate=samp_rate, number_rate=15, average=True, avg_alpha=None, label='Number Plot', peak_hold=True, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2, bt=0.35, verbose=False, log=False, ) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_vector_source_x_0 = blocks.vector_source_b((7, 8, 9), True, 1, []) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((12e3, )) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_float * 1, '/home/steve-wang/test.txt', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=4, bits_per_symbol=2, preamble='', access_code='', pad_for_usrp=True, ), payload_length=0, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_f( grc_blks2.packet_decoder( access_code='', threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=2, ) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 10000, 42) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blks2_error_rate_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 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) ################################################## # Variables ################################################## self.snr_db = snr_db = 3 self.noiseAmplitude = noiseAmplitude = sqrt(1 / (10**(0.1 * snr_db))) self.constellation = constellation = [-1.3416, -0.4472, 0.4472, 1.3416] self.bits = bits = 2 ################################################## # Blocks ################################################## self.random_source_x_0 = gr.vector_source_b( map(int, numpy.random.randint(0, 4, 10000)), True) self.qtgui_sink_x_0_0_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 400, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_0_0_1.set_update_time(1.0 / 100) self._qtgui_sink_x_0_0_1_win = sip.wrapinstance( self.qtgui_sink_x_0_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_0_1_win) self.gr_tag_debug_0 = gr.tag_debug(gr.sizeof_float * 1, "") self.gr_noise_source_x_0 = gr.noise_source_f(gr.GR_GAUSSIAN, noiseAmplitude, 0) self.gr_file_sink_1 = gr.file_sink(gr.sizeof_gr_complex * 1, "symbols.bin") self.gr_file_sink_1.set_unbuffered(False) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char * 1, "output.bin") self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char * 1, "input.bin") self.gr_file_sink_0.set_unbuffered(False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( digital.constellation_calcdist([-3, -1, 1, 3], [], 1, 1).base()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( (constellation), 1) self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, 100) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=10000, bits_per_symbol=bits, ) ################################################## # Connections ################################################## self.connect((self.random_source_x_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.gr_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.random_source_x_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_sink_x_0_0_1, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.gr_file_sink_1, 0)) self.connect((self.blks2_error_rate_0, 0), (self.gr_tag_debug_0, 0))
def __init__(self): gr.top_block.__init__(self, "IEEE 802.15.4 Transceiver using OQPSK PHY") Qt.QWidget.__init__(self) self.setWindowTitle("IEEE 802.15.4 Transceiver using OQPSK PHY") 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", "ber_ser") 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.tx_gain = tx_gain = float(d_txdb) self.samp = samp = 4 self.rx_gain = rx_gain = float(d_rxdb) self.freq = freq = float(d_freq) self.buf = buf = 0x8000 self.bits = bits = 16 ################################################## # Blocks ################################################## self._tx_gain_range = Range(-20, 64, 0.01, float(d_txdb), 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "tx_gain", "counter_slider", float) self.top_layout.addWidget(self._tx_gain_win) self._rx_gain_range = Range(0, 72, 0.01, float(d_rxdb), 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, "rx_gain", "counter_slider", float) self.top_layout.addWidget(self._rx_gain_win) self._freq_options = [2450000000, 915000000, 430000000] self._freq_labels = ['2.45GHz', '915MHz', '430MHz'] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) self._bits_range = Range(1, 127, 1, 43, 200) self._bits_win = RangeWidget(self._bits_range, self.set_bits, "bits", "counter_slider", int) self.top_layout.addWidget(self._bits_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 1, qtgui.NUM_GRAPH_HORIZ, 2) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = [ 'BER', 'SER', 'Latency', 'Bit Error Rate', 'Symbol Error Rate', 'SNR', '', '', '', '' ] units = ['', '', 'ms', '', '', 'dB', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(2): 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(False) 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.pluto_source_0 = iio.pluto_source(d_rxid, int(freq), int(4e6), int(20000000), buf * 16, True, True, True, "manual", rx_gain, '', True) self.pluto_sink_0 = iio.pluto_sink(d_txid, int(freq), int(4e6), int(20000000), buf, False, tx_gain, '', True) self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack( ([129]), ([131]), ([132]), ([23, 42])) self.ieee802_15_4_phy_0_0 = ieee802_15_4_oqpsk_phy() self.ieee802_15_4_phy_0 = ieee802_15_4_oqpsk_phy() if argv[7] == 'ook': exec "d_thr = " + argv[8] in locals() self.ieee802_15_4_phy_0_0 = ieee802_15_4_ook_phy(threshold=d_thr) self.ieee802_15_4_phy_0 = ieee802_15_4_ook_phy(threshold=d_thr) print "Modulation: OOK\nThreshold: " + str(d_thr) + "\n" elif argv[7] == 'fsk': self.ieee802_15_4_phy_0_0 = ieee802_15_4_cpfsk_phy() self.ieee802_15_4_phy_0 = ieee802_15_4_cpfsk_phy() print "Modulation: FSK\n" self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False, 0x8841, 0, 0x1aaa, 0xffff, 0x3344) self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False) self.foo_packet_pad_0 = foo.packet_pad(False, False, 0.001, buf, buf) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_message_strobe_0_0 = blocks.message_strobe( pmt.intern(''.join(chr(e) for e in range(65, 65 + bits))), 500) self.blocks_file_sink_1_0 = blocks.file_sink(gr.sizeof_float * 1, d_dir + '/ser.bin', False) self.blocks_file_sink_1_0.set_unbuffered(False) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1, d_dir + '/ber.bin', False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/hrbenitez/Desktop/output_padded.pcap', False) self.blocks_file_sink_0.set_unbuffered(True) self.blks2_error_rate_0_0 = grc_blks2.error_rate( type='SER', win_size=2**20, bits_per_symbol=2, ) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=2**20, bits_per_symbol=1, ) self.bar_out_sync_0 = bar.out_sync(10) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_phy_0, 'txin')) self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC')) self.msg_connect((self.ieee802_15_4_phy_0_0, 'rxout'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.ieee802_15_4_phy_0_0, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'), (self.blocks_socket_pdu_0_0, 'pdus')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in')) self.connect((self.bar_out_sync_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.bar_out_sync_0, 2), (self.blks2_error_rate_0, 1)) self.connect((self.bar_out_sync_0, 1), (self.blks2_error_rate_0_0, 0)) self.connect((self.bar_out_sync_0, 3), (self.blks2_error_rate_0_0, 1)) self.connect((self.blks2_error_rate_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blks2_error_rate_0_0, 0), (self.blocks_file_sink_1_0, 0)) self.connect((self.blks2_error_rate_0_0, 0), (self.qtgui_number_sink_0, 1)) self.connect((self.foo_packet_pad_0, 0), (self.ieee802_15_4_phy_0, 0)) self.connect((self.foo_packet_pad_0, 0), (self.pluto_sink_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.ieee802_15_4_phy_0, 2), (self.bar_out_sync_0, 0)) self.connect((self.ieee802_15_4_phy_0, 3), (self.bar_out_sync_0, 1)) self.connect((self.ieee802_15_4_phy_0, 1), (self.bar_out_sync_0, 2)) self.connect((self.ieee802_15_4_phy_0, 0), (self.foo_packet_pad_0, 0)) self.connect((self.ieee802_15_4_phy_0_0, 2), (self.bar_out_sync_0, 3)) self.connect((self.ieee802_15_4_phy_0_0, 3), (self.bar_out_sync_0, 4)) self.connect((self.ieee802_15_4_phy_0_0, 1), (self.bar_out_sync_0, 5)) self.connect((self.ieee802_15_4_phy_0_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.pluto_source_0, 0), (self.ieee802_15_4_phy_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Superposition Coding") Qt.QWidget.__init__(self) self.setWindowTitle("Superposition Coding") 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", "int_cancellation") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.snr_db = snr_db = 10 self.prefix = prefix = "/opt/usr/src/gnuradio/gr-trellis/examples/python/fsm_files/" self.noisevar = noisevar = 10**(-snr_db / 10) self.fsm2 = fsm2 = "awgn1o2_4.fsm" self.fsm1 = fsm1 = "awgn1o2_16.fsm" self.block = block = 1000 self.alpha = alpha = .1 self.R = R = 100e3 ################################################## # Blocks ################################################## self._alpha_range = Range(0, 1, .01, .1, 200) self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha, 'P1/P', "counter_slider", float) self.top_layout.addWidget(self._alpha_win) self.trellis_viterbi_combined_xx_2 = trellis.viterbi_combined_cb( trellis.fsm(prefix + fsm2), block, -1, -1, 1, ((1 - alpha)**0.5 * 1, (1 - alpha)**0.5 * 1j, (1 - alpha)**0.5 * (-1j), (1 - alpha)**0.5 * (-1)), digital.TRELLIS_EUCLIDEAN) self.trellis_viterbi_combined_xx_1 = trellis.viterbi_combined_cb( trellis.fsm(prefix + fsm1), block, -1, -1, 1, (alpha**0.5 * 1, alpha**0.5 * 1j, alpha**0.5 * (-1j), alpha**0.5 * (-1)), digital.TRELLIS_EUCLIDEAN) self.trellis_viterbi_combined_xx_0_0 = trellis.viterbi_combined_cb( trellis.fsm(prefix + fsm1), block, -1, -1, 1, (alpha**0.5 * 1, alpha**0.5 * 1j, alpha**0.5 * (-1j), alpha**0.5 * (-1)), digital.TRELLIS_EUCLIDEAN) self.trellis_viterbi_combined_xx_0 = trellis.viterbi_combined_cb( trellis.fsm(prefix + fsm2), block, -1, -1, 1, ((1 - alpha)**0.5 * 1, (1 - alpha)**0.5 * 1j, (1 - alpha)**0.5 * (-1j), (1 - alpha)**0.5 * (-1)), digital.TRELLIS_EUCLIDEAN) self.trellis_encoder_xx_2_0 = trellis.encoder_bb( trellis.fsm(prefix + fsm2), 0, 0) if False else trellis.encoder_bb( trellis.fsm(prefix + fsm2), 0) self.trellis_encoder_xx_2 = trellis.encoder_bb( trellis.fsm(prefix + fsm1), 0, 0) if False else trellis.encoder_bb( trellis.fsm(prefix + fsm1), 0) self.trellis_encoder_xx_1 = trellis.encoder_bb( trellis.fsm(prefix + fsm2), 0, 0) if False else trellis.encoder_bb( trellis.fsm(prefix + fsm2), 0) self.trellis_encoder_xx_0 = trellis.encoder_bb( trellis.fsm(prefix + fsm1), 0, 0) if False else trellis.encoder_bb( trellis.fsm(prefix + fsm1), 0) self._snr_db_range = Range(0, 20, 1, 10, 200) self._snr_db_win = RangeWidget(self._snr_db_range, self.set_snr_db, 'P/sigma^2 (dB)', "counter_slider", float) self.top_layout.addWidget(self._snr_db_win) self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0.set_title( 'BER 1 (after cancelling user 2)') 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0.set_max(i, 1) self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 1, 0, 1, 1) self.qtgui_number_sink_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0.set_title( "BER 2 (after cancelling user 1)") 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0.set_max(i, 1) self.qtgui_number_sink_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_win, 1, 1, 1, 1) self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("BER 2 (Raw)") 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0.set_min(i, 0) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win, 0, 1, 1, 1) 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("BER1 (Raw)") 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 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.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_chunks_to_symbols_xx_0_0_1 = digital.chunks_to_symbols_bc( (1, 1j, -1j, -1), 1) self.digital_chunks_to_symbols_xx_0_0_0 = digital.chunks_to_symbols_bc( (1, 1j, -1j, -1), 1) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (1, 1j, -1j, -1), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (1, 1j, -1j, -1), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, R, True) self.blocks_sub_xx_2_0 = blocks.sub_cc(1) self.blocks_sub_xx_2 = blocks.sub_cc(1) self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vcc( ((1 - alpha)**0.5, )) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc( (alpha**0.5, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc( ((1 - alpha)**0.5, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (alpha**0.5, )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0_0_0_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=2, ) self.blks2_error_rate_0_0_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=2, ) self.blks2_error_rate_0_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=2, ) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=2, ) self.analog_random_source_x_1 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, block)), True) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, block)), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, noisevar, -42) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 2)) self.connect((self.analog_random_source_x_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blks2_error_rate_0_0_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.trellis_encoder_xx_0, 0)) self.connect((self.analog_random_source_x_1, 0), (self.blks2_error_rate_0_0, 0)) self.connect((self.analog_random_source_x_1, 0), (self.blks2_error_rate_0_0_0, 0)) self.connect((self.analog_random_source_x_1, 0), (self.trellis_encoder_xx_1, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blks2_error_rate_0_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blks2_error_rate_0_0_0, 0), (self.qtgui_number_sink_0_0_0, 0)) self.connect((self.blks2_error_rate_0_0_0_0, 0), (self.qtgui_number_sink_0_0_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_2, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_2_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.trellis_viterbi_combined_xx_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.trellis_viterbi_combined_xx_2, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_sub_xx_2, 1)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_sub_xx_2_0, 1)) self.connect((self.blocks_sub_xx_2, 0), (self.trellis_viterbi_combined_xx_0, 0)) self.connect((self.blocks_sub_xx_2_0, 0), (self.trellis_viterbi_combined_xx_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0_1, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.trellis_encoder_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.trellis_encoder_xx_1, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.trellis_encoder_xx_2, 0), (self.digital_chunks_to_symbols_xx_0_0_0, 0)) self.connect((self.trellis_encoder_xx_2_0, 0), (self.digital_chunks_to_symbols_xx_0_0_1, 0)) self.connect((self.trellis_viterbi_combined_xx_0, 0), (self.blks2_error_rate_0_0_0, 1)) self.connect((self.trellis_viterbi_combined_xx_0_0, 0), (self.blks2_error_rate_0_0_0_0, 1)) self.connect((self.trellis_viterbi_combined_xx_1, 0), (self.blks2_error_rate_0, 1)) self.connect((self.trellis_viterbi_combined_xx_1, 0), (self.trellis_encoder_xx_2, 0)) self.connect((self.trellis_viterbi_combined_xx_2, 0), (self.blks2_error_rate_0_0, 1)) self.connect((self.trellis_viterbi_combined_xx_2, 0), (self.trellis_encoder_xx_2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Simple QAM Simulation") Qt.QWidget.__init__(self) self.setWindowTitle("Simple QAM Simulation") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 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) ################################################## # Variables ################################################## self.constellation_cardinality = constellation_cardinality = 16 self.const_object = const_object = constellations()['qam'](constellation_cardinality) self.snr_db = snr_db = 20 self.constellation = constellation = const_object.points() self.sps = sps = 8 self.samp_rate = samp_rate = 250000 self.noise_amp = noise_amp = sqrt( (10**(-snr_db/10.)) /2. ) self.constellation_power = constellation_power = sqrt(sum([abs(i)**2 for i in constellation])/constellation_cardinality) ################################################## # Blocks ################################################## self.tabid_0 = Qt.QTabWidget() self.tabid_0_widget_0 = Qt.QWidget() self.tabid_0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_0) self.tabid_0_grid_layout_0 = Qt.QGridLayout() self.tabid_0_layout_0.addLayout(self.tabid_0_grid_layout_0) self.tabid_0.addTab(self.tabid_0_widget_0, "TX") self.tabid_0_widget_1 = Qt.QWidget() self.tabid_0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_1) self.tabid_0_grid_layout_1 = Qt.QGridLayout() self.tabid_0_layout_1.addLayout(self.tabid_0_grid_layout_1) self.tabid_0.addTab(self.tabid_0_widget_1, "CHANNEL") self.tabid_0_widget_2 = Qt.QWidget() self.tabid_0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_2) self.tabid_0_grid_layout_2 = Qt.QGridLayout() self.tabid_0_layout_2.addLayout(self.tabid_0_grid_layout_2) self.tabid_0.addTab(self.tabid_0_widget_2, "RX") self.top_grid_layout.addWidget(self.tabid_0, 30,0,10,100) self.tabid_2 = Qt.QTabWidget() self.tabid_2_widget_0 = Qt.QWidget() self.tabid_2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_0) self.tabid_2_grid_layout_0 = Qt.QGridLayout() self.tabid_2_layout_0.addLayout(self.tabid_2_grid_layout_0) self.tabid_2.addTab(self.tabid_2_widget_0, "symbol-based") self.tabid_2_widget_1 = Qt.QWidget() self.tabid_2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_1) self.tabid_2_grid_layout_1 = Qt.QGridLayout() self.tabid_2_layout_1.addLayout(self.tabid_2_grid_layout_1) self.tabid_2.addTab(self.tabid_2_widget_1, "bit-based") self.tabid_2_widget_2 = Qt.QWidget() self.tabid_2_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_2) self.tabid_2_grid_layout_2 = Qt.QGridLayout() self.tabid_2_layout_2.addLayout(self.tabid_2_grid_layout_2) self.tabid_2.addTab(self.tabid_2_widget_2, "BER") self.tabid_0_layout_2.addWidget(self.tabid_2) self.tabid_1 = Qt.QTabWidget() self.tabid_1_widget_0 = Qt.QWidget() self.tabid_1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_0) self.tabid_1_grid_layout_0 = Qt.QGridLayout() self.tabid_1_layout_0.addLayout(self.tabid_1_grid_layout_0) self.tabid_1.addTab(self.tabid_1_widget_0, "bit-based") self.tabid_1_widget_1 = Qt.QWidget() self.tabid_1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_1) self.tabid_1_grid_layout_1 = Qt.QGridLayout() self.tabid_1_layout_1.addLayout(self.tabid_1_grid_layout_1) self.tabid_1.addTab(self.tabid_1_widget_1, "scrambled") self.tabid_1_widget_2 = Qt.QWidget() self.tabid_1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_2) self.tabid_1_grid_layout_2 = Qt.QGridLayout() self.tabid_1_layout_2.addLayout(self.tabid_1_grid_layout_2) self.tabid_1.addTab(self.tabid_1_widget_2, "symbol-based") self.tabid_0_grid_layout_0.addWidget(self.tabid_1, 0,0,10,10) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_sink_x_0_1_0_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget) self.tabid_1_layout_0.addWidget(self._qtgui_sink_x_0_1_0_0_win) self.qtgui_sink_x_0_1_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_0_win = sip.wrapinstance(self.qtgui_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.tabid_1_layout_1.addWidget(self._qtgui_sink_x_0_1_0_win) self.qtgui_sink_x_0_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_win = sip.wrapinstance(self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget) self.tabid_1_layout_2.addWidget(self._qtgui_sink_x_0_1_win) self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_0.addWidget(self._qtgui_sink_x_0_0_0_0_win) self.qtgui_sink_x_0_0_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_1.addWidget(self._qtgui_sink_x_0_0_0_win) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime False, #plotconst ) self._qtgui_sink_x_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabid_0_layout_1.addWidget(self._qtgui_sink_x_0_0_win) self.gr_vector_source_x_0_0 = gr.vector_source_b(([1,0]), True, 1) self.gr_vector_source_x_0 = gr.vector_source_b(([1,0]), True, 1) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(int(log2(constellation_cardinality))) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate) self.gr_pack_k_bits_bb_0 = gr.pack_k_bits_bb(int(log2(constellation_cardinality))) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char*1) self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_amp, 0) self.gr_nlog10_ff_0 = gr.nlog10_ff(1, 1, 0) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vcc((1./constellation_power, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((constellation_power, )) self.gr_file_sink_0_1_0 = gr.file_sink(gr.sizeof_gr_complex*1, "rx_sym.32fc") self.gr_file_sink_0_1_0.set_unbuffered(False) self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_gr_complex*1, "tx_sym.32fc") self.gr_file_sink_0_1.set_unbuffered(False) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char*1, "rx.8b") self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char*1, "tx.8b") self.gr_file_sink_0.set_unbuffered(False) self.gr_descrambler_bb_0 = gr.descrambler_bb(0xe4001, 0x7ffff, 19) self.gr_char_to_float_1_0 = gr.char_to_float(1, 1) self.gr_char_to_float_1 = gr.char_to_float(1, 1) self.gr_char_to_float_0 = gr.char_to_float(1, 1) self.gr_add_xx_0 = gr.add_vcc(1) self.digital_scrambler_bb_0 = digital.scrambler_bb(0xe4001, 0x7fffF, 19) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(const_object.base(), 6.28/100, -0.25, +0.25) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((constellation), 1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=samp_rate, bits_per_symbol=1, ) ################################################## # Connections ################################################## self.connect((self.gr_vector_source_x_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.gr_pack_k_bits_bb_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_descrambler_bb_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_null_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_char_to_float_0, 0), (self.qtgui_sink_x_0_0_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_file_sink_0_1, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.qtgui_sink_x_0_1, 0)) self.connect((self.gr_char_to_float_1, 0), (self.qtgui_sink_x_0_1_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_char_to_float_1, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_char_to_float_1_0, 0), (self.qtgui_sink_x_0_1_0_0, 0)) self.connect((self.gr_vector_source_x_0, 0), (self.gr_char_to_float_1_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_file_sink_0_1_0, 0)) self.connect((self.gr_throttle_0, 0), (self.qtgui_sink_x_0_0_0_0, 0)) self.connect((self.gr_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.gr_nlog10_ff_0, 0)) self.connect((self.gr_vector_source_x_0_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1))
def __init__(self): gr.top_block.__init__(self, "sic_mpsk_sim") Qt.QWidget.__init__(self) self.setWindowTitle("sic_mpsk_sim") 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", "sic_mpsk_sim") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.snr_db = snr_db = 10 self.const_type = const_type = 1 self.variable_qtgui_label_0 = variable_qtgui_label_0 = { 0: 'BPSK', 1: 'QPSK', 2: '8-PSK' }[const_type] + " - Change const_type for different constellation types!" self.noisevar = noisevar = 10**(-snr_db / 10) self.const = const = (digital.constellation_bpsk(), digital.constellation_qpsk(), digital.constellation_8psk()) self.block = block = 1000 self.alpha = alpha = .1 self.R = R = 100e3 ################################################## # Blocks ################################################## self._alpha_range = Range(0, 1, .01, .1, 200) self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha, 'Alpha (P1/P)', "counter_slider", float) self.top_layout.addWidget(self._alpha_win) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: x self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel('Constellation Type' + ": ")) self._variable_qtgui_label_0_label = Qt.QLabel( str( self._variable_qtgui_label_0_formatter( self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget( self._variable_qtgui_label_0_label) self.top_layout.addWidget(self._variable_qtgui_label_0_tool_bar) self._snr_db_range = Range(0, 20, 1, 10, 200) self._snr_db_win = RangeWidget(self._snr_db_range, self.set_snr_db, 'P/sigma^2 (dB)', "counter_slider", float) self.top_layout.addWidget(self._snr_db_win) self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0.set_title( 'BER 1 (after cancelling user 2)') 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0.set_max(i, 1) self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 1, 0, 1, 1) self.qtgui_number_sink_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0.set_title( "BER 2 (after cancelling user 1)") 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0.set_max(i, 1) self.qtgui_number_sink_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_win, 1, 1, 1, 1) self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("BER 2 (Without Cancellation)") 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0.set_min(i, 0) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win, 0, 1, 1, 1) 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("BER1 (Without Cancellation)") 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 0, 1, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "Constellation", #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 = [ "Constellation: " + str(const[const_type].arity()) + "-PSK", '', '', '', '', '', '', '', '', '' ] 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 = [0.6, 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_layout.addWidget(self._qtgui_const_sink_x_0_0_win) self.digital_constellation_decoder_cb_0_0_0_0 = digital.constellation_decoder_cb( const[const_type].base()) self.digital_constellation_decoder_cb_0_0_0 = digital.constellation_decoder_cb( const[const_type].base()) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb( const[const_type].base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( const[const_type].base()) self.digital_chunks_to_symbols_xx_2 = digital.chunks_to_symbols_bc( (const[const_type].points()), 1) self.digital_chunks_to_symbols_xx_1_0 = digital.chunks_to_symbols_bc( (const[const_type].points()), 1) self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc( (const[const_type].points()), 1) self.digital_chunks_to_symbols_xx = digital.chunks_to_symbols_bc( (const[const_type].points()), 1) self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_char * 1, R, True) self.blocks_sub_xx_2_0 = blocks.sub_cc(1) self.blocks_sub_xx_2 = blocks.sub_cc(1) self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vcc( ((1 - alpha)**0.5, )) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc( (alpha**0.5, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc( ((1 - alpha)**0.5, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (alpha**0.5, )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0_0_0_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=2, ) self.blks2_error_rate_0_0_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=2, ) self.blks2_error_rate_0_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=2, ) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=2, ) self.analog_random_source_x_1 = blocks.vector_source_b( map(int, numpy.random.randint(0, const[const_type].arity(), block)), True) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, const[const_type].arity(), block)), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, noisevar, -42) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 2)) self.connect((self.analog_random_source_x_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blks2_error_rate_0_0_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0_1, 0)) self.connect((self.analog_random_source_x_1, 0), (self.blks2_error_rate_0_0, 0)) self.connect((self.analog_random_source_x_1, 0), (self.blks2_error_rate_0_0_0, 0)) self.connect((self.analog_random_source_x_1, 0), (self.digital_chunks_to_symbols_xx_2, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blks2_error_rate_0_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blks2_error_rate_0_0_0, 0), (self.qtgui_number_sink_0_0_0, 0)) self.connect((self.blks2_error_rate_0_0_0_0, 0), (self.qtgui_number_sink_0_0_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_2, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_2_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_sub_xx_2, 1)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_sub_xx_2_0, 1)) self.connect((self.blocks_sub_xx_2, 0), (self.digital_constellation_decoder_cb_0_0_0, 0)) self.connect((self.blocks_sub_xx_2_0, 0), (self.digital_constellation_decoder_cb_0_0_0_0, 0)) self.connect((self.blocks_throttle_0_1, 0), (self.digital_chunks_to_symbols_xx, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.digital_chunks_to_symbols_xx_1_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_2, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_chunks_to_symbols_xx_1, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.blks2_error_rate_0_0, 1)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.digital_chunks_to_symbols_xx_1_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0_0, 0), (self.blks2_error_rate_0_0_0, 1)) self.connect((self.digital_constellation_decoder_cb_0_0_0_0, 0), (self.blks2_error_rate_0_0_0_0, 1))
def __init__(self, options): gr.hier_block2.__init__(self, "bpsk_demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature grc_wxgui.top_block_gui.__init__(self, title="Top Block") self._samples_per_symbol = options.samples_per_symbol # Number of bits per symbol self._bits_per_symbol = 1 # Create AGC to scale input to unity self._agc = gr.agc_cc(1e-5, 1.0, 1.0, 1.0) # Create RRC with specified excess bandwidth taps = gr.firdes.root_raised_cosine(1.0, # Gain self._samples_per_symbol, # Sampling rate 1.0, # Symbol rate 0.35, # Roll-off factor 11*self._samples_per_symbol) # Number of taps self._rrc = gr.fir_filter_ccf(1, taps) # Create a Costas loop frequency/phase recovery block self._costas = digital.costas_loop_cc(6.28/100.0, 2) self.gr_null_sink_f1 = gr.null_sink(gr.sizeof_float*1) # Create a M&M bit synchronization retiming block self._mm = digital.clock_recovery_mm_cc(self._samples_per_symbol, # Initial samples/symbol 1e-06, # Second order gain 0.5, # Initial symbol phase 0.001, # First order gain 0.0001) # Maximum timing offset # Add an SNR probe on the demodulated constellation #self._snr_probe = gr.probe_mpsk_snr_c(10.0/symbol_rate) self._symbol_rate = options.data_rate / self._bits_per_symbol #self._snr_probe = digital.mpsk_snr_est_cc(0, 10000, 0.001) # 0 at the first mean Simple self._snr_probe = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, alpha=10.0/self._symbol_rate) #self._snr_probe = digital.mpsk_snr_est_cc(digital.SNR_EST_SIMPLE, alpha=10.0/self._symbol_rate) # Slice the resulting constellation into bits. # Get inphase channel and make decision about 0 self._c2r = gr.complex_to_real() self._slicer = digital.binary_slicer_fb() # Descramble BERT sequence. A channel error will create 3 incorrect bits self._descrambler = gr.descrambler_bb(0x8A, 0x7F, 31) # CCSDS 7-bit descrambler # Measure BER by the density of 0s in the stream # self._ber = gr.probe_density_b(1.0/symbol_rate) self._ber = grc_blks2.error_rate(type='BER', win_size=1000, bits_per_symbol=1) #self.create_number_sink(self._samples_per_symbol) self.gr_null_sink_f2 = gr.null_sink(gr.sizeof_float*1) #Create a vector source reference to calculate BER self._vector_source_ref = gr.vector_source_b(([1,]), True, 1) #create a comparator self.comparator = howto.compare_vector_cci((1, 1, 1, 1 ,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1), (0,0, 1, 1, 0,0), 5, 0, True) #Connection of blocks #"""""""""""""""""""""""""""""""""-->_snr_probe-->gr_null_sink_cc # agc --> _rrc --> costas --> _mm --> _c2r --> _slicer --> _descrambler --> _ber --> gr_null_sink_f2 #"""""""""""""""""""""""""--> gr_null_sink_f1 "" _vector_source_ref--> # # self.connect(self, self._agc, self._rrc, self._costas, self._mm, # self._c2r, self._slicer, self._descrambler, self.comparator, (self._ber, 1)) # self.connect(self, self._agc, self._rrc, self._costas, self._mm, self._c2r, self._slicer, self._descrambler, (self._ber, 1)) self.connect((self._costas, 1), (self.gr_null_sink_f1, 0)) self.connect(self._mm, self._snr_probe) self.connect(self._vector_source_ref, (self._ber,0)) self.connect(self._ber, self.gr_null_sink_f2)
def __init__(self): gr.top_block.__init__(self, "Simple QAM Simulation") Qt.QWidget.__init__(self) self.setWindowTitle("Simple QAM Simulation") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 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) ################################################## # Variables ################################################## self.constellation_cardinality = constellation_cardinality = 16 self.const_object = const_object = constellations()['qam']( constellation_cardinality) self.snr_db = snr_db = 20 self.constellation = constellation = const_object.points() self.sps = sps = 8 self.samp_rate = samp_rate = 250000 self.noise_amp = noise_amp = sqrt((10**(-snr_db / 10.)) / 2.) self.constellation_power = constellation_power = sqrt( sum([abs(i)**2 for i in constellation]) / constellation_cardinality) ################################################## # Blocks ################################################## self.tabid_0 = Qt.QTabWidget() self.tabid_0_widget_0 = Qt.QWidget() self.tabid_0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_0) self.tabid_0_grid_layout_0 = Qt.QGridLayout() self.tabid_0_layout_0.addLayout(self.tabid_0_grid_layout_0) self.tabid_0.addTab(self.tabid_0_widget_0, "TX") self.tabid_0_widget_1 = Qt.QWidget() self.tabid_0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_1) self.tabid_0_grid_layout_1 = Qt.QGridLayout() self.tabid_0_layout_1.addLayout(self.tabid_0_grid_layout_1) self.tabid_0.addTab(self.tabid_0_widget_1, "CHANNEL") self.tabid_0_widget_2 = Qt.QWidget() self.tabid_0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_2) self.tabid_0_grid_layout_2 = Qt.QGridLayout() self.tabid_0_layout_2.addLayout(self.tabid_0_grid_layout_2) self.tabid_0.addTab(self.tabid_0_widget_2, "RX") self.top_grid_layout.addWidget(self.tabid_0, 30, 0, 10, 100) self.tabid_2 = Qt.QTabWidget() self.tabid_2_widget_0 = Qt.QWidget() self.tabid_2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_0) self.tabid_2_grid_layout_0 = Qt.QGridLayout() self.tabid_2_layout_0.addLayout(self.tabid_2_grid_layout_0) self.tabid_2.addTab(self.tabid_2_widget_0, "symbol-based") self.tabid_2_widget_1 = Qt.QWidget() self.tabid_2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_1) self.tabid_2_grid_layout_1 = Qt.QGridLayout() self.tabid_2_layout_1.addLayout(self.tabid_2_grid_layout_1) self.tabid_2.addTab(self.tabid_2_widget_1, "bit-based") self.tabid_2_widget_2 = Qt.QWidget() self.tabid_2_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_2) self.tabid_2_grid_layout_2 = Qt.QGridLayout() self.tabid_2_layout_2.addLayout(self.tabid_2_grid_layout_2) self.tabid_2.addTab(self.tabid_2_widget_2, "BER") self.tabid_0_layout_2.addWidget(self.tabid_2) self.tabid_1 = Qt.QTabWidget() self.tabid_1_widget_0 = Qt.QWidget() self.tabid_1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_0) self.tabid_1_grid_layout_0 = Qt.QGridLayout() self.tabid_1_layout_0.addLayout(self.tabid_1_grid_layout_0) self.tabid_1.addTab(self.tabid_1_widget_0, "bit-based") self.tabid_1_widget_1 = Qt.QWidget() self.tabid_1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_1) self.tabid_1_grid_layout_1 = Qt.QGridLayout() self.tabid_1_layout_1.addLayout(self.tabid_1_grid_layout_1) self.tabid_1.addTab(self.tabid_1_widget_1, "scrambled") self.tabid_1_widget_2 = Qt.QWidget() self.tabid_1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_2) self.tabid_1_grid_layout_2 = Qt.QGridLayout() self.tabid_1_layout_2.addLayout(self.tabid_1_grid_layout_2) self.tabid_1.addTab(self.tabid_1_widget_2, "symbol-based") self.tabid_0_grid_layout_0.addWidget(self.tabid_1, 0, 0, 10, 10) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_sink_x_0_1_0_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget) self.tabid_1_layout_0.addWidget(self._qtgui_sink_x_0_1_0_0_win) self.qtgui_sink_x_0_1_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_0_win = sip.wrapinstance( self.qtgui_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.tabid_1_layout_1.addWidget(self._qtgui_sink_x_0_1_0_win) self.qtgui_sink_x_0_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_win = sip.wrapinstance( self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget) self.tabid_1_layout_2.addWidget(self._qtgui_sink_x_0_1_win) self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_0.addWidget(self._qtgui_sink_x_0_0_0_0_win) self.qtgui_sink_x_0_0_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_1.addWidget(self._qtgui_sink_x_0_0_0_win) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime False, #plotconst ) self._qtgui_sink_x_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabid_0_layout_1.addWidget(self._qtgui_sink_x_0_0_win) self.gr_vector_source_x_0_0 = gr.vector_source_b(([1, 0]), True, 1) self.gr_vector_source_x_0 = gr.vector_source_b(([1, 0]), True, 1) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb( int(log2(constellation_cardinality))) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate) self.gr_pack_k_bits_bb_0 = gr.pack_k_bits_bb( int(log2(constellation_cardinality))) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char * 1) self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_amp, 0) self.gr_nlog10_ff_0 = gr.nlog10_ff(1, 1, 0) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vcc( (1. / constellation_power, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc( (constellation_power, )) self.gr_file_sink_0_1_0 = gr.file_sink(gr.sizeof_gr_complex * 1, "rx_sym.32fc") self.gr_file_sink_0_1_0.set_unbuffered(False) self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_gr_complex * 1, "tx_sym.32fc") self.gr_file_sink_0_1.set_unbuffered(False) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char * 1, "rx.8b") self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char * 1, "tx.8b") self.gr_file_sink_0.set_unbuffered(False) self.gr_descrambler_bb_0 = gr.descrambler_bb(0xe4001, 0x7ffff, 19) self.gr_char_to_float_1_0 = gr.char_to_float(1, 1) self.gr_char_to_float_1 = gr.char_to_float(1, 1) self.gr_char_to_float_0 = gr.char_to_float(1, 1) self.gr_add_xx_0 = gr.add_vcc(1) self.digital_scrambler_bb_0 = digital.scrambler_bb( 0xe4001, 0x7fffF, 19) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb( const_object.base(), 6.28 / 100, -0.25, +0.25) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (constellation), 1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=samp_rate, bits_per_symbol=1, ) ################################################## # Connections ################################################## self.connect((self.gr_vector_source_x_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.gr_pack_k_bits_bb_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_descrambler_bb_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_null_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_char_to_float_0, 0), (self.qtgui_sink_x_0_0_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_file_sink_0_1, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.qtgui_sink_x_0_1, 0)) self.connect((self.gr_char_to_float_1, 0), (self.qtgui_sink_x_0_1_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_char_to_float_1, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_char_to_float_1_0, 0), (self.qtgui_sink_x_0_1_0_0, 0)) self.connect((self.gr_vector_source_x_0, 0), (self.gr_char_to_float_1_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_file_sink_0_1_0, 0)) self.connect((self.gr_throttle_0, 0), (self.qtgui_sink_x_0_0_0_0, 0)) self.connect((self.gr_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.gr_nlog10_ff_0, 0)) self.connect((self.gr_vector_source_x_0_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Verhalten bei Phasenoffset") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100e3 self.phase_offset = phase_offset = 0 self.fO = fO = 0 self.constellation = constellation = digital.constellation_qpsk() self.EbN0 = EbN0 = 10 ################################################## # Blocks ################################################## _phase_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._phase_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_phase_offset_sizer, value=self.phase_offset, callback=self.set_phase_offset, label='Phase Offset', converter=forms.float_converter(), proportion=0, ) self._phase_offset_slider = forms.slider( parent=self.GetWin(), sizer=_phase_offset_sizer, value=self.phase_offset, callback=self.set_phase_offset, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_phase_offset_sizer) _fO_sizer = wx.BoxSizer(wx.VERTICAL) self._fO_text_box = forms.text_box( parent=self.GetWin(), sizer=_fO_sizer, value=self.fO, callback=self.set_fO, label='Frequency Offset', converter=forms.float_converter(), proportion=0, ) self._fO_slider = forms.slider( parent=self.GetWin(), sizer=_fO_sizer, value=self.fO, callback=self.set_fO, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_fO_sizer) _EbN0_sizer = wx.BoxSizer(wx.VERTICAL) self._EbN0_text_box = forms.text_box( parent=self.GetWin(), sizer=_EbN0_sizer, value=self.EbN0, callback=self.set_EbN0, label='Eb/N0 (dB)', converter=forms.float_converter(), proportion=0, ) self._EbN0_slider = forms.slider( parent=self.GetWin(), sizer=_EbN0_sizer, value=self.EbN0, callback=self.set_EbN0, minimum=-10, maximum=200, num_steps=211, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_EbN0_sizer) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Constellation: " + str(constellation.arity()) + "-PSK", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=True, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.GridAdd(self.wxgui_scopesink2_0.win, 2, 0, 1, 1) self.wxgui_numbersink2 = numbersink2.number_sink_f( self.GetWin(), unit='%', minval=0.0, maxval=1.0, factor=100, decimal_places=4, ref_level=0, sample_rate=samp_rate, number_rate=15, average=False, avg_alpha=None, label='BER', peak_hold=False, show_gauge=False, ) self.GridAdd(self.wxgui_numbersink2.win, 1, 0, 1, 1) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( constellation.base()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (constellation.points()), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (numpy.exp(1j * 2 * numpy.pi * phase_offset), )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate = grc_blks2.error_rate( type='BER', win_size=int(1e5), bits_per_symbol=constellation.bits_per_symbol(), ) self.analog_sig_source_x_0 = analog.sig_source_c( 1, analog.GR_COS_WAVE, fO, 1, 0) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, constellation.arity(), 10000000)), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1.0 / math.sqrt(2.0 * 2 * 10**(EbN0 / 10)), 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blks2_error_rate, 0), (self.wxgui_numbersink2, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_error_rate, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate, 1))
def __init__(self): gr.top_block.__init__(self, "Bicm Atsc 2") Qt.QWidget.__init__(self) self.setWindowTitle("Bicm Atsc 2") 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", "BICM_ATSC_2") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.r = r = 10 self.n = n = 64800 self.EsN0_dB = EsN0_dB = [4, 5, 6, 7, 8, 9, 10, 11, 12] ################################################## # Blocks ################################################## for EsNo in self.EsN0_dB: self._EsN0_dB_range = Range(-50, 50, 1, EsNo, 200) self._EsN0_dB_win = RangeWidget(self._EsN0_dB_range, self.set_EsN0_dB, "EsN0_dB", "counter_slider", float) self.top_layout.addWidget(self._EsN0_dB_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [ ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black") ] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.mapper_atsc_0 = mapper_atsc( m=4, n=2, r=r, ) self.mack_sdr_rossi_Bit_interleaver_ATSC_0 = mack_sdr_rossi.Bit_interleaver_ATSC( n, r, 4) self.mack_sdr_rossi_Bit_deinterleaver_ATSC_0 = mack_sdr_rossi.Bit_deinterleaver_ATSC( n, r, 4) self.ldpc_enc_0 = ldpc_enc( n=n, r=r, ) self.ldpc_dec_0 = ldpc_dec( n=n, r=r, ) self.demapper_atsc_0 = demapper_atsc( m=4, r=r, size_in=1, ) self.blocks_vector_to_stream_0_0_0 = blocks.vector_to_stream( gr.sizeof_float * 1, n) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_char * 1, n) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector( gr.sizeof_float * 1, n) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_char * 1, n) 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/rossi/PN.ts', False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/media/rossi/02C46D54C46D4ACD/Users/grgan/Desktop/RESULTADOS_COMPLETO/PN_bicm_completo_' + str(EsNo) + '.bin', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000000000, bits_per_symbol=8, ) self.bch_enc_0 = bch_enc( fec=r, size=n, ) self.bch_dec_0 = bch_dec( fec=r, size=n, ) self.analog_noise_source_x_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, math.sqrt(1 / math.pow(10.0, (EsNo / 10.0))), 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.bch_dec_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.bch_enc_0, 0), (self.ldpc_enc_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.demapper_atsc_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.mack_sdr_rossi_Bit_interleaver_ATSC_0, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.mack_sdr_rossi_Bit_deinterleaver_ATSC_0, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.ldpc_dec_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.bch_enc_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.mapper_atsc_0, 0)) self.connect((self.blocks_vector_to_stream_0_0_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.demapper_atsc_0, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.ldpc_dec_0, 0), (self.bch_dec_0, 0)) self.connect((self.ldpc_enc_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.mack_sdr_rossi_Bit_deinterleaver_ATSC_0, 0), (self.blocks_vector_to_stream_0_0_0, 0)) self.connect((self.mack_sdr_rossi_Bit_interleaver_ATSC_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.mapper_atsc_0, 0), (self.blocks_add_xx_0, 1))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.const_type = const_type = 1 self.variable_static_text_0 = variable_static_text_0 = { 0: 'BPSK', 1: 'QPSK', 2: '8-PSK' }[const_type] + " - Change const_type for different constellation types!" self.samp_rate = samp_rate = 100000 self.const = const = (digital.constellation_bpsk(), digital.constellation_qpsk(), digital.constellation_8psk()) self.EbN0 = EbN0 = 10 ################################################## # Blocks ################################################## _EbN0_sizer = wx.BoxSizer(wx.VERTICAL) self._EbN0_text_box = forms.text_box( parent=self.GetWin(), sizer=_EbN0_sizer, value=self.EbN0, callback=self.set_EbN0, label='Eb / N0 (dB)', converter=forms.float_converter(), proportion=0, ) self._EbN0_slider = forms.slider( parent=self.GetWin(), sizer=_EbN0_sizer, value=self.EbN0, callback=self.set_EbN0, minimum=-10, maximum=200, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_EbN0_sizer) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit='%', minval=0, maxval=1, factor=100, decimal_places=4, ref_level=0, sample_rate=100000, number_rate=15, average=True, avg_alpha=None, label='BER', peak_hold=False, show_gauge=False, ) self.GridAdd(self.wxgui_numbersink2_0.win, 1, 0, 1, 1) self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c( self.GetWin(), title='Constellation Plot', sample_rate=samp_rate, frame_rate=5, const_size=2048, M=2, theta=0, loop_bw=6.28 / 100.0, fmax=0.06, mu=0.5, gain_mu=0.005, symbol_rate=samp_rate / 4., omega_limit=0.005, ) self.GridAdd(self.wxgui_constellationsink2_0.win, 2, 0, 1, 1) self._variable_static_text_0_static_text = forms.static_text( parent=self.GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label='Constellation Type', converter=forms.float_converter(), ) self.Add(self._variable_static_text_0_static_text) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( const[const_type].base()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (const[const_type].points()), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=int(10e6), bits_per_symbol=const[const_type].bits_per_symbol(), ) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, const[const_type].arity(), int(10e6))), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1.0 / math.sqrt( 2.0 * const[const_type].bits_per_symbol() * 10**(EbN0 / 10)), 42) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.wxgui_constellationsink2_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate_0, 1))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage6") ################################################## # 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 = 7 # 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.tutorial_my_qpsk_demod_cb_1 = tutorial.my_qpsk_demod_cb(True) self.iq_vector_sink = blocks.vector_sink_c(1) self.raw_vector_sink = blocks.vector_sink_f(1) self.decoded_vector_sink = blocks.vector_sink_f(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=self.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_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.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, 100000)), 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.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, 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_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.blocks_char_to_float_0_0, 0), (self.decoded_vector_sink, 0)) self.connect((self.blocks_delay_0, 0), (self.raw_vector_sink, 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.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.digital_map_bb_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="fhss_test") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_sym = samp_sym = 64 self.samp_rate = samp_rate = 400e3 self.init = init = 1, 1, 1, 1 self.generator = generator = 1, 1, 0, 0, 1 self.code_rate = code_rate = int(samp_sym * 500) ################################################## # Blocks ################################################## self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Received Spread Spectrum ", ) self.Add(self.wxgui_waterfallsink2_0.win) self.wxgui_numbersink2_0_0_0_0_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-100e5, maxval=100e5, factor=1.0, decimal_places=10, ref_level=0, sample_rate=samp_rate, number_rate=60, average=False, avg_alpha=None, label="Error", peak_hold=False, show_gauge=False, ) self.Add(self.wxgui_numbersink2_0_0_0_0_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Despread Signal", peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0.win, 0, 2, 2, 4) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "serial=F54381")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_source("internal", 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(500e6, 0) self.uhd_usrp_source_0.set_gain(47, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "serial=F54358")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_clock_source("internal", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(500e6, 0) self.uhd_usrp_sink_0.set_gain(50, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.blocks_vector_source_x_0 = blocks.vector_source_b((1,1,1,1), True, 1, []) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.9, )) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=1, ) self.Spread_synthesizer_0 = Spread.synthesizer(code_rate, 0, samp_rate, (generator), (init)) self.Spread_rx_synthesizer_0 = Spread.rx_synthesizer(code_rate, samp_sym, samp_rate, 12000, 50000, 0.16, (generator), (init)) self.Spread_cpfsk_mod_0 = Spread.cpfsk_mod(samp_sym) self.Spread_cpfsk_demod_0 = Spread.cpfsk_demod(samp_sym) ################################################## # Connections ################################################## self.connect((self.blks2_error_rate_0, 0), (self.wxgui_numbersink2_0_0_0_0_0, 0)) self.connect((self.Spread_cpfsk_demod_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blocks_vector_source_x_0, 0), (self.Spread_cpfsk_mod_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.Spread_rx_synthesizer_0, 0)) self.connect((self.Spread_synthesizer_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.Spread_rx_synthesizer_0, 0), (self.Spread_cpfsk_demod_0, 0)) self.connect((self.Spread_cpfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.Spread_synthesizer_0, 0)) self.connect((self.Spread_rx_synthesizer_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.r = r = 10 self.n = n = 64800 self.mult = mult = 100 self.SNR = SNR = 20 ################################################## # Blocks ################################################## self._SNR_range = Range(-50, 50, 1, 20, 200) self._SNR_win = RangeWidget(self._SNR_range, self.set_SNR, "SNR", "counter_slider", float) self.top_layout.addWidget(self._SNR_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 16200, #size samp_rate, #samp_rate 'LDPC IN', #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(-mult - 0.1, mult + 0.1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 10800, #size samp_rate, #samp_rate 'LDPC OUT', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-0.1, 1.1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0.5, 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 = ['x10-6', '', '', '', '', '', '', '', '', ''] 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, -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_layout.addWidget(self._qtgui_number_sink_0_win) self.mapper_prbs_source_b_0 = mapper.prbs_source_b("PRBS7", 108000) self.mapper_prbs_sink_b_0 = mapper.prbs_sink_b("PRBS7", 108000) self.mack_sdr_ldpc_encoder_0 = mack_sdr.ldpc_encoder(n, r) self.ldpc_dec_soft_0 = ldpc_dec_soft( n=n, r=r, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((2, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult, )) 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_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000000, bits_per_symbol=1, ) self.analog_noise_source_x_0 = analog.noise_source_f( analog.GR_GAUSSIAN, math.pow(10.0, -(SNR - 1.25) / 20.0) / math.sqrt(2.0) * mult, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.ldpc_dec_soft_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.ldpc_dec_soft_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.ldpc_dec_soft_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.ldpc_dec_soft_0, 0), (self.mapper_prbs_sink_b_0, 0)) self.connect((self.mack_sdr_ldpc_encoder_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.mapper_prbs_source_b_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.mapper_prbs_source_b_0, 0), (self.mack_sdr_ldpc_encoder_0, 0))
def __init__(self): gr.top_block.__init__(self, "Superposition coding with MPSK modulation") Qt.QWidget.__init__(self) self.setWindowTitle("Superposition coding with MPSK modulation") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.snr_db = snr_db = 10 self.noisevar = noisevar = 10**(-snr_db / 10) self.block = block = 1000 self.alpha = alpha = .1 self.R = R = 100e3 ################################################## # Blocks ################################################## self._alpha_range = Range(0, 1, .01, .1, 200) self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha, 'P1/P', "counter_slider", float) self.top_layout.addWidget(self._alpha_win) self._snr_db_range = Range(0, 20, 1, 10, 200) self._snr_db_win = RangeWidget(self._snr_db_range, self.set_snr_db, 'P/sigma^2 (dB)', "counter_slider", float) self.top_layout.addWidget(self._snr_db_win) self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("BER 2 (Raw)") 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0.set_min(i, 0) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win, 0, 1, 1, 1) 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("BER1 (Raw)") 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 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.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_scrambler_bb_0_1 = digital.scrambler_bb(0x8A, 0x7F, 7) self.digital_scrambler_bb_0_0 = digital.scrambler_bb(0xDA, 0x7F, 7) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x8A, 0x7F, 7) self.digital_psk_mod_0_1 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.35, verbose=False, log=False, ) self.digital_psk_mod_0_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.35, verbose=False, log=False, ) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.35, verbose=False, log=False, ) self.digital_psk_demod_0_0 = digital.psk.psk_demod( constellation_points=4, differential=True, samples_per_symbol=2, excess_bw=0.35, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False, ) self.digital_psk_demod_0 = digital.psk.psk_demod( constellation_points=4, differential=True, samples_per_symbol=2, excess_bw=0.35, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False, ) self.digital_descrambler_bb_0_1 = digital.descrambler_bb(0xDA, 0x7F, 7) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x8A, 0x7F, 7) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char * 1, R, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, R, True) self.blocks_sub_xx_2 = blocks.sub_cc(1) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc( (alpha**0.5, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc( ((1 - alpha)**0.5, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (alpha**0.5, )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=2, ) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=2, ) self.analog_random_source_x_1 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, block)), True) self.analog_random_source_x_0_0_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, block)), True) self.analog_random_source_x_0_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, block)), True) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, block)), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, noisevar, -42) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 2)) self.connect((self.analog_random_source_x_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.analog_random_source_x_0_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.analog_random_source_x_0_0_0, 0), (self.blks2_error_rate_0_0, 0)) self.connect((self.analog_random_source_x_1, 0), (self.digital_scrambler_bb_0_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blks2_error_rate_0_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_2, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_psk_demod_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_psk_demod_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_sub_xx_2, 1)) self.connect((self.blocks_sub_xx_2, 0), (self.blocks_null_sink_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.digital_psk_mod_0_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_descrambler_bb_0, 0), (self.digital_scrambler_bb_0_1, 0)) self.connect((self.digital_descrambler_bb_0_1, 0), (self.blks2_error_rate_0_0, 1)) self.connect((self.digital_psk_demod_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_psk_demod_0_0, 0), (self.digital_descrambler_bb_0_1, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_psk_mod_0_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_psk_mod_0_1, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_scrambler_bb_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.digital_scrambler_bb_0_1, 0), (self.digital_psk_mod_0_1, 0))