def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option( "-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) ampl = 0.1 src = digital.glfsr_source_b(32) # Pseudorandom noise source b2f = digital.chunks_to_symbols_bf([ampl, -ampl], 1) dst = audio.sink(sample_rate, options.audio_output) self.connect(src, b2f, dst)
def test_diff_decoder_bb(): top = gr.top_block() src = digital.glfsr_source_b(7) diffdecoder = digital.diff_decoder_bb(2) probe = blocks.probe_rate(gr.sizeof_char) top.connect(src, diffdecoder, probe) return top, probe
def __init__(self, ebno_db=0, min_errors=100, samp_per_sym=1): gr.top_block.__init__(self, "BER 4FSK ") ################################################## # Parameters ################################################## self.ebno_db = ebno_db self.min_errors = min_errors self.samp_per_sym = samp_per_sym ################################################## # Variables ################################################## self.symb_rate = symb_rate = 4800 self.bits_per_sym = bits_per_sym = 1 self.bit_rate = bit_rate = float(symb_rate)*bits_per_sym self.average_power = average_power = 1.0 self.ebno = ebno = 10**(ebno_db/10.0) self.eb = eb = average_power/bit_rate self.samp_rate = samp_rate = symb_rate*samp_per_sym self.no = no = eb/ebno self.noise_variance = noise_variance = no*samp_rate/2.0 ################################################## # Blocks ################################################## self.sample_counter = sample_counter() self.probe_avg_power = analog.probe_avg_mag_sqrd_f(0, 1) self.pack_rx_bits = blocks.pack_k_bits_bb(8) self.pack_msg_bits = blocks.pack_k_bits_bb(8) self.glfsr = digital.glfsr_source_b(8, True, 0, 1) self.four_level_symbol_mapper_0 = four_level_symbol_mapper( symbol_map=[-1,1], ) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([-1,1]), 1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_per_sym) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, samp_per_sym) self.blocks_add_xx_0 = blocks.add_vff(1) self.ber_sink = blocks.vector_sink_f(1) self.ber_measure = fec.ber_bf(True, min_errors, -7.0) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f(analog.GR_GAUSSIAN, math.sqrt(noise_variance), 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.ber_measure, 0), (self.ber_sink, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.four_level_symbol_mapper_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.probe_avg_power, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.four_level_symbol_mapper_0, 0), (self.sample_counter, 0)) self.connect((self.glfsr, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.glfsr, 0), (self.pack_msg_bits, 0)) self.connect((self.pack_msg_bits, 0), (self.ber_measure, 0)) self.connect((self.pack_rx_bits, 0), (self.ber_measure, 1)) self.connect((self.sample_counter, 0), (self.pack_rx_bits, 0))
def __init__(self): """ Especifíca la primera función que se ejecutará al crear un objeto de la clase my_top_block con el argumento self, por lo que servirá para cualquier proceso de inicializacián, este se define como el constructor de la clase,la interconexión de los bloques es la siguiente: +------------------------+ +------------------------+ +--------------------+ | GLFSR Source +-----+ Chunks to Symbol bf +-----+ Audio Sink | +------------------------+ +------------------------+ +--------------------+ Con gr.top_block.__init__(self) se llama a la función inicial del modulo top_block del paquete gr y se pasa como argumento el objeto creado. digital.glfsr_sorce_b Fuente pseudoaleatoria LFSR de Galois que genera salidas flotantes -1.0 - 1.0 chunks_to_symbols_bf Asigna un flujo de índices de símbolos desempaquetados al flujo de puntos de constelación flotantes o complejos en dimensiones D (D = 1 por defecto). audio.sink Este módulo envía las señales a la tarjeta de audio para poder reproducirlas. """ gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 """ Las siguientes instrucciones definen la tasa de muestreo (obtenida de options) y la amplitud """ sample_rate = int(options.sample_rate) ampl = 0.1 src = digital.glfsr_source_b(32) # Pseudorandom noise source b2f = digital.chunks_to_symbols_bf([ampl, -ampl], 1) dst = audio.sink(sample_rate, options.audio_output) """ se debe realizar la conexión entre los bloques que se han definido anteriormente paracompletar el grafo: Con esto se crea la conexión logica del grafo uniendo los puertos de entrada y salida (src-fuente y dst-destino). """ self.connect(src, b2f, dst)
def test_002_correlation_b(self): for degree in range(1,11): # Higher degrees take too long to correlate src = digital.glfsr_source_b(degree, False) b2f = digital.chunks_to_symbols_bf((-1.0,1.0), 1) dst = blocks.vector_sink_f() del self.tb # Discard existing top block self.tb = gr.top_block() self.tb.connect(src, b2f, dst) self.tb.run() self.tb.disconnect_all() actual_result = dst.data() R = auto_correlate(actual_result) self.assertEqual(R[0], float(len(R))) # Auto-correlation peak at origin for i in range(len(R)-1): self.assertEqual(R[i+1], -1.0) # Auto-correlation minimum everywhere else
def __init__(self): gr.top_block.__init__(self) parser = ArgumentParser() parser.add_argument("-O", "--audio-output", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_argument("-r", "--sample-rate", type=eng_float, default=48000, help="set sample rate to RATE (48000)") args = parser.parse_args() sample_rate = int(args.sample_rate) ampl = 0.1 src = digital.glfsr_source_b(32) # Pseudorandom noise source b2f = digital.chunks_to_symbols_bf([ampl, -ampl], 1) dst = audio.sink(sample_rate, args.audio_output) self.connect(src, b2f, dst)
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) ampl = 0.1 src = digital.glfsr_source_b(32) # Pseudorandom noise source b2f = digital.chunks_to_symbols_bf([ampl, -ampl], 1) dst = audio.sink(sample_rate, options.audio_output) self.connect(src, b2f, dst)
def __init__(self,mod,delay=0,n_0=0,min_errors=100): ModMeasurementGraph.__init__(self, mod, "BER Measurement") self.__probe_thread = None self._did_timeout = False # Blocks self.src = digital.glfsr_source_b(8, True, 0, 1) # self.src = blocks.vector_source_b(np.concatenate((np.ones(5,dtype='B'),np.zeros(10,dtype='B'))).tolist(),True) # self.src = blocks.vector_source_b(np.zeros(10,dtype='B').tolist(),True) self.noise = analog.noise_source_c(analog.GR_GAUSSIAN, math.sqrt(float(n_0)), 0) self.delay = blocks.delay(gr.sizeof_char,delay) self.add = blocks.add_vcc(1) self.skiphead_orig = blocks.skiphead(gr.sizeof_char,500) self.skiphead_rx = blocks.skiphead(gr.sizeof_char,500) self.pack_rx_bits = blocks.pack_k_bits_bb(8) self.pack_msg_bits = blocks.pack_k_bits_bb(8) self.ber_measure = fec.ber_bf(True, min_errors, -7.0) self.ber_sink = blocks.vector_sink_f(1) # Connections self.connect(self.src,self.mod_in_bits) # Adding noise to tx output of mod self.connect(self.mod_out_signal,(self.add,0)) self.connect(self.noise,(self.add,1)) self.connect(self.add,self.mod_in_signal) # Rx bits from mod to ber measure self.connect(self.mod_out_bits,self.skiphead_rx) self.connect(self.skiphead_rx,self.pack_rx_bits) self.connect(self.pack_rx_bits,(self.ber_measure,1)) # delayed bits to ber measure self.connect(self.src,self.delay) self.connect(self.delay,self.skiphead_orig) self.connect(self.skiphead_orig,self.pack_msg_bits) self.connect(self.pack_msg_bits,(self.ber_measure,0)) self.connect(self.ber_measure,self.ber_sink)
def __init__(self, mod, num_bits=1000): ModMeasurementGraph.__init__(self, mod, "Eb Measurement") self.num_bits = num_bits # self.bitSrc = blocks.vector_source_b(get_random_bits(num_bits).tolist(), True) self.bitSrc = digital.glfsr_source_b(8, True, 0, 1) self.src = blocks.head(gr.sizeof_char, num_bits) self.nop_c = blocks.delay(gr.sizeof_gr_complex, 0) self.null_sink_b = blocks.null_sink(gr.sizeof_char) self.power = blocks.complex_to_mag_squared(1) self.dest = blocks.vector_sink_f() # Connections self.connect(self.bitSrc, self.src) self.connect(self.src, self.mod_in_bits) self.connect(self.mod_out_signal, self.power) self.connect(self.power, self.dest) # Only care about the power output of the transmission pad # null sink / source the other inputs/outputs self.connect(self.mod_out_signal, self.nop_c) self.connect(self.nop_c, self.mod_in_signal) self.connect(self.mod_out_bits, self.null_sink_b)
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, "qam_mod") Qt.QWidget.__init__(self) self.setWindowTitle("qam_mod") 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.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## 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(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_qam_mod_0 = digital.qam.qam_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.35, verbose=False, log=False, ) self.digital_glfsr_source_x_0 = digital.glfsr_source_b(4, True, 0, 1) ################################################## # Connections ################################################## self.connect((self.digital_glfsr_source_x_0, 0), (self.digital_qam_mod_0, 0)) self.connect((self.digital_qam_mod_0, 0), (self.qtgui_const_sink_x_0, 0))
def __init__(self, corr_tag_delay=131): gr.top_block.__init__(self, "Lab3 BER") Qt.QWidget.__init__(self) self.setWindowTitle("Lab3 BER") 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", "lab3_ber") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Parameters ################################################## self.corr_tag_delay = corr_tag_delay ################################################## # Variables ################################################## self.rolloff = rolloff = 0.5 self.sps = sps = 4 self.snr_default = snr_default = 8.5 self.rolloff_ = rolloff_ = rolloff self.payload_len = payload_len = 31 self.num_tag_key = num_tag_key = "packet_num" self.nfilts_pfb = nfilts_pfb = 32 self.mark_delays = mark_delays = [0, 0, 34, 56, 87, 119] self.len_tag_key = len_tag_key = "packet_length" self.header_len = header_len = 32 self.cw_len = cw_len = 32 self.tag_s = tag_s = gr.tag_utils.python_to_tag( (0, pmt.intern(len_tag_key), pmt.from_long(payload_len), pmt.intern("vect_test_src"))) self.tag0 = tag0 = gr.tag_utils.python_to_tag( (0, pmt.intern(len_tag_key), pmt.from_long(cw_len), pmt.intern("vect_cw_src"))) self.sync_seq = sync_seq = [ 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1 ] self.snr_db = snr_db = snr_default self.samp_rate = samp_rate = 1e3 self.rrc_filter = rrc_filter = firdes.root_raised_cosine( 4, sps, 1, rolloff_, 32 * sps + 1) self.reset_ber = reset_ber = 0 self.pn_order = pn_order = np.round(np.log2(payload_len + 1)) self.pn6_padded = pn6_padded = [ 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1 - 1 - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] self.pn6 = pn6 = [ 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1 - 1 - 1 ] self.pn5 = pn5 = [ 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1 ] self.pi = pi = np.pi self.pfb_filter = pfb_filter = firdes.root_raised_cosine( nfilts_pfb, nfilts_pfb * sps, 1, rolloff_, nfilts_pfb * 11 * sps + 1) self.mark_delay = mark_delay = mark_delays[sps] self.header_formatter_0 = header_formatter_0 = digital.packet_header_default( header_len, len_tag_key, num_tag_key, 1) self.header_formatter = header_formatter = digital.packet_header_default( header_len, len_tag_key, num_tag_key, 1) self.fc = fc = 900e6 self.const = const = digital.constellation_calcdist( digital.psk_2()[0], digital.psk_2()[1], 2, 1).base() self.buffer_size = buffer_size = 32768 self.bFilter = bFilter = 1 self.agc_rate = agc_rate = 1e-4 ################################################## # Blocks ################################################## self._snr_db_range = Range(0, 20, 0.5, snr_default, 200) self._snr_db_win = RangeWidget(self._snr_db_range, self.set_snr_db, 'SNR (dB)', "counter_slider", float) self.top_grid_layout.addWidget(self._snr_db_win) self._rolloff__range = Range(0.01, 0.99, 0.01, rolloff, 200) self._rolloff__win = RangeWidget(self._rolloff__range, self.set_rolloff_, 'Beta (Excess BW)', "counter_slider", float) self.top_grid_layout.addWidget(self._rolloff__win) _reset_ber_push_button = Qt.QPushButton('Reset BER') _reset_ber_push_button = Qt.QPushButton('Reset BER') self._reset_ber_choices = {'Pressed': 1, 'Released': 0} _reset_ber_push_button.pressed.connect( lambda: self.set_reset_ber(self._reset_ber_choices['Pressed'])) _reset_ber_push_button.released.connect( lambda: self.set_reset_ber(self._reset_ber_choices['Released'])) self.top_grid_layout.addWidget(_reset_ber_push_button) # Create the options list self._bFilter_options = ( 1, 2, ) # Create the labels list self._bFilter_labels = ( 'Raised Cosine (Mis-Matched)', 'Root Raised Cosine (Matched)', ) # Create the combo box self._bFilter_tool_bar = Qt.QToolBar(self) self._bFilter_tool_bar.addWidget(Qt.QLabel('TX Filter Select' + ": ")) self._bFilter_combo_box = Qt.QComboBox() self._bFilter_tool_bar.addWidget(self._bFilter_combo_box) for _label in self._bFilter_labels: self._bFilter_combo_box.addItem(_label) self._bFilter_callback = lambda i: Qt.QMetaObject.invokeMethod( self._bFilter_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._bFilter_options.index(i))) self._bFilter_callback(self.bFilter) self._bFilter_combo_box.currentIndexChanged.connect( lambda i: self.set_bFilter(self._bFilter_options[i])) # Create the radio buttons self.top_grid_layout.addWidget(self._bFilter_tool_bar) self._agc_rate_range = Range(1e-4, 1e-3, 1e-4, 1e-4, 200) self._agc_rate_win = RangeWidget(self._agc_rate_range, self.set_agc_rate, 'AGC Decay Rate', "counter_slider", float) self.top_grid_layout.addWidget(self._agc_rate_win) self.wes_packet_tx_0 = wes_packet_tx( cw_len=cw_len, payload_len=payload_len, samp_rate=samp_rate, ) self.wes_ber_0 = wes.ber(1, reset_ber) 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("# of Errors") 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 range(1): self.qtgui_number_sink_0_0.set_min(i, -1) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_grid_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("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 range(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #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.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) 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, 1, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(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) self.pulse_shape_hier_0 = pulse_shape_hier( bFilter=bFilter, rect_taps=(1, 1, 1, 1), roll_off=rolloff_, sps=sps, ) self.iio_pluto_source_0 = iio.pluto_source('', int(fc), int(samp_rate * 1e3), 20000000, buffer_size, True, True, True, 'manual', 18, '', True) self.iio_pluto_sink_0 = iio.pluto_sink('', int(fc), int(samp_rate * 1e3), 20000000, buffer_size, False, 10.0, '', True) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 2 * pi / 200, pfb_filter, nfilts_pfb, int(nfilts_pfb / 2), 0.5, 1) self.digital_packet_headerparser_b_0_0 = digital.packet_headerparser_b( header_formatter.formatter()) self.digital_header_payload_demux_0 = digital.header_payload_demux( header_len, 1, 0, "packet_length", "corr_est", False, gr.sizeof_gr_complex, "rx_time", 1, (), 0) self.digital_glfsr_source_x_0 = digital.glfsr_source_b( int(pn_order), True, 0, 1) self.digital_diff_decoder_bb_0_0 = digital.diff_decoder_bb(2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( 2 * pi / 200, 2, False) self.digital_corr_est_cc_0 = digital.corr_est_cc( pn6_padded, 1, 64, 0.7, digital.THRESHOLD_ABSOLUTE) self.digital_constellation_decoder_cb_0_0_0_0_0 = digital.constellation_decoder_cb( const) self.digital_constellation_decoder_cb_0_0_0_0 = digital.constellation_decoder_cb( const) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, np.sqrt(2) * np.sqrt(0.5 / np.power(10, snr_db / 10)), 0) self.analog_agc_xx_0 = analog.agc_cc(agc_rate, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect( (self.digital_packet_headerparser_b_0_0, 'header_data'), (self.digital_header_payload_demux_0, 'header_data')) self.connect((self.analog_agc_xx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0_0_0_0_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.qtgui_const_sink_x_0, 1)) self.connect((self.digital_constellation_decoder_cb_0_0_0_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0_0_0_0, 0), (self.digital_diff_decoder_bb_0_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_packet_headerparser_b_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0_0, 0), (self.wes_ber_0, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.wes_ber_0, 1)) self.connect((self.digital_glfsr_source_x_0, 0), (self.wes_packet_tx_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.blocks_add_xx_0, 1)) self.connect((self.digital_header_payload_demux_0, 0), (self.digital_constellation_decoder_cb_0_0_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.iio_pluto_source_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.pulse_shape_hier_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.wes_ber_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.wes_ber_0, 1), (self.qtgui_number_sink_0_0, 0)) self.connect((self.wes_packet_tx_0, 0), (self.pulse_shape_hier_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 4") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 4") 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", "lab4") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.echo_gain_iir = echo_gain_iir = 0 self.delay_limit = delay_limit = 64 self.delay_iir = delay_iir = 1 self.sps = sps = 4 self.pn6 = pn6 = [1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1 -1 -1] self.pn5 = pn5 = [1,-1,1,-1,1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1] self.iir_taps_2 = iir_taps_2 = np.concatenate( ([1], np.zeros(int(delay_iir-1)),[-echo_gain_iir],np.zeros(int(delay_limit-delay_iir))) ) self.h_filt = h_filt = [1,1,1,1] self.freqc = freqc = 900 self.samp_rate = samp_rate = 1000 self.pn6_up = pn6_up = sp.upfirdn( h_filt, pn6, sps ) self.pn5_up = pn5_up = sp.upfirdn( h_filt, pn5, sps ) self.phase_shift = phase_shift = 1 self.lw = lw = 2 self.iir_taps = iir_taps = iir_taps_2 self.gain_ = gain_ = 0.5 self.freqc_ = freqc_ = freqc self.fps = fps = 30 self.fo = fo = 800 self.equalize_on = equalize_on = 0 self.echo_gain = echo_gain = 0 self.delay = delay = 0 self.const_qpsk = const_qpsk = digital.constellation_calcdist(digital.psk_4()[0], digital.psk_4()[1], 4, 1).base() self.const_bpsk = const_bpsk = digital.constellation_calcdist(digital.psk_2()[0], digital.psk_2()[1], 2, 1).base() self.bw = bw = 1 self.buff_size = buff_size = 32768 self.axis = axis = 2 self.PLL_ON = PLL_ON = 0 ################################################## # Blocks ################################################## self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Cross-Correlation') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Spectrum') self.top_grid_layout.addWidget(self.tab0, 0, 0, 10, 2) for r in range(0, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) _phase_shift_check_box = Qt.QCheckBox('PI Phase Shift') self._phase_shift_choices = {True: 1, False: 0} self._phase_shift_choices_inv = dict((v,k) for k,v in self._phase_shift_choices.items()) self._phase_shift_callback = lambda i: Qt.QMetaObject.invokeMethod(_phase_shift_check_box, "setChecked", Qt.Q_ARG("bool", self._phase_shift_choices_inv[i])) self._phase_shift_callback(self.phase_shift) _phase_shift_check_box.stateChanged.connect(lambda i: self.set_phase_shift(self._phase_shift_choices[bool(i)])) self.top_grid_layout.addWidget(_phase_shift_check_box, 12, 1, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._gain__range = Range(0.1, 1, 0.01, 0.5, 200) self._gain__win = RangeWidget(self._gain__range, self.set_gain_, 'Gain (Amp)', "counter_slider", float) self.top_grid_layout.addWidget(self._gain__win, 10, 1, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._freqc__range = Range(70, 6000, .01, freqc, 200) self._freqc__win = RangeWidget(self._freqc__range, self.set_freqc_, 'Carrier (MHz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freqc__win, 10, 0, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._fo_range = Range(-10000, 10000, 1, 800, 200) self._fo_win = RangeWidget(self._fo_range, self.set_fo, 'Frequency Offset (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._fo_win, 12, 0, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._equalize_on_options = (0, 1, ) # Create the labels list self._equalize_on_labels = ('Equalizer Off', 'Equalizer On', ) # Create the combo box self._equalize_on_tool_bar = Qt.QToolBar(self) self._equalize_on_tool_bar.addWidget(Qt.QLabel('Equalizer Select' + ": ")) self._equalize_on_combo_box = Qt.QComboBox() self._equalize_on_tool_bar.addWidget(self._equalize_on_combo_box) for _label in self._equalize_on_labels: self._equalize_on_combo_box.addItem(_label) self._equalize_on_callback = lambda i: Qt.QMetaObject.invokeMethod(self._equalize_on_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._equalize_on_options.index(i))) self._equalize_on_callback(self.equalize_on) self._equalize_on_combo_box.currentIndexChanged.connect( lambda i: self.set_equalize_on(self._equalize_on_options[i])) # Create the radio buttons self.top_grid_layout.addWidget(self._equalize_on_tool_bar, 13, 0, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._echo_gain_range = Range(0, 1, 0.01, 0, 200) self._echo_gain_win = RangeWidget(self._echo_gain_range, self.set_echo_gain, 'Echo Path Gain (A)', "counter_slider", float) self.top_grid_layout.addWidget(self._echo_gain_win, 11, 0, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._delay_range = Range(0, delay_limit, 1, 0, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, 'Delay (samples)', "counter_slider", float) self.top_grid_layout.addWidget(self._delay_win, 11, 1, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._PLL_ON_options = (0, 1, ) # Create the labels list self._PLL_ON_labels = ('PLL ON', 'PLL OFF', ) # Create the combo box self._PLL_ON_tool_bar = Qt.QToolBar(self) self._PLL_ON_tool_bar.addWidget(Qt.QLabel('PLL Select' + ": ")) self._PLL_ON_combo_box = Qt.QComboBox() self._PLL_ON_tool_bar.addWidget(self._PLL_ON_combo_box) for _label in self._PLL_ON_labels: self._PLL_ON_combo_box.addItem(_label) self._PLL_ON_callback = lambda i: Qt.QMetaObject.invokeMethod(self._PLL_ON_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._PLL_ON_options.index(i))) self._PLL_ON_callback(self.PLL_ON) self._PLL_ON_combo_box.currentIndexChanged.connect( lambda i: self.set_PLL_ON(self._PLL_ON_options[i])) # Create the radio buttons self.top_grid_layout.addWidget(self._PLL_ON_tool_bar, 13, 1, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 4096, #size samp_rate*1000, #samp_rate "Cross Correlation", #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(-2, 2) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ['blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_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.tab0_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*1e3, #bw "", #name 1 ) self.qtgui_freq_sink_x_0.set_update_time(1/fps) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(True) labels = ['In-Phase', 'Quadrature', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0.set_processor_affinity([0]) self.interp_fir_filter_xxx_1_0 = filter.interp_fir_filter_ccc(sps, (1,1,1,1)) self.interp_fir_filter_xxx_1_0.declare_sample_delay(0) self.iir_filter_xxx_0 = filter.iir_filter_ccz([(1)], iir_taps, True) self.iio_pluto_source_0 = iio.pluto_source(epy_module_0.RX, int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, True, True, True, 'manual', 32, '', True) self.iio_pluto_sink_0 = iio.pluto_sink(epy_module_0.TX, int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, False, 10.0, '', True) self._echo_gain_iir_range = Range(0, 1, 0.01, 0, 200) self._echo_gain_iir_win = RangeWidget(self._echo_gain_iir_range, self.set_echo_gain_iir, 'Equalizer Gain (A)', "counter_slider", float) self.top_grid_layout.addWidget(self._echo_gain_iir_win, 14, 0, 1, 1) for r in range(14, 15): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.digital_glfsr_source_x_0 = digital.glfsr_source_b(6, True, 0, 1) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(3.14/100, 2, False) self.digital_corr_est_cc_0 = digital.corr_est_cc(pn6_up, sps, 0, 0.7, digital.THRESHOLD_ABSOLUTE) self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc(const_bpsk.points(), 1) self._delay_iir_range = Range(1, delay_limit, 1, 1, 200) self._delay_iir_win = RangeWidget(self._delay_iir_range, self.set_delay_iir, 'Equalizer Delay (samples)', "counter_slider", float) self.top_grid_layout.addWidget(self._delay_iir_win, 14, 1, 1, 1) for r in range(14, 15): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.blocks_tag_gate_0_0_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0_0_0.set_single_key("time_est") self.blocks_tag_gate_0_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0_0.set_single_key("corr_est") self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("amp_est") self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex*1,equalize_on,0) self.blocks_selector_0_0.set_enabled(True) self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex*1,PLL_ON,0) self.blocks_selector_0.set_enabled(True) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_cc((1/63/sps)*np.exp(1j*pi*phase_shift)) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(echo_gain) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(gain_ ) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, delay) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate*1000, analog.GR_COS_WAVE, fo, 1, 0, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.blocks_selector_0, 1)) self.connect((self.analog_agc_xx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_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_tag_gate_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_selector_0, 0), (self.blocks_selector_0_0, 0)) self.connect((self.blocks_selector_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_selector_0_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.blocks_selector_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_tag_gate_0_0, 0)) self.connect((self.blocks_tag_gate_0_0, 0), (self.blocks_tag_gate_0_0_0, 0)) self.connect((self.blocks_tag_gate_0_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_1_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_selector_0, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.digital_chunks_to_symbols_xx_1, 0)) self.connect((self.iio_pluto_source_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_selector_0_0, 1)) self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_delay_0, 0))
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, "Bipolar NRZ over AWGN channel") Qt.QWidget.__init__(self) self.setWindowTitle("Bipolar NRZ over AWGN channel") 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.seed = seed = 1 self.scale = scale = 0.5 self.samp_rate = samp_rate = 32000 self.noise_amplitude = noise_amplitude = 0.000001 self.noiseSourceSeed = noiseSourceSeed = 0 self.mask = mask = 0 self.degree = degree = 20 self.constant = constant = -1 self.K = K = 8 ################################################## # Blocks ################################################## self._noise_amplitude_range = Range(0.000001, 100, 0.000001, 0.000001, 200) self._noise_amplitude_win = RangeWidget(self._noise_amplitude_range, self.set_noise_amplitude, 'Noise amplitude (Vrms)', "counter_slider", float) self.top_layout.addWidget(self._noise_amplitude_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_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.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0) self.digital_glfsr_source_x_0 = digital.glfsr_source_b( degree, True, mask, seed) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_pack_k_bits_bb_0_0 = blocks.pack_k_bits_bb(K) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(K) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, scale) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((constant, )) self.analog_noise_source_x_0 = analog.noise_source_f( analog.GR_GAUSSIAN, noise_amplitude, noiseSourceSeed) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0, 1)) 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.digital_binary_slicer_fb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_pack_k_bits_bb_0_0, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Dsss") Qt.QWidget.__init__(self) self.setWindowTitle("Dsss") 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", "dsss") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.spread_factor = spread_factor = 8 self.spc = spc = 4 self.const = const = digital.constellation_qpsk().base() self.sps = sps = spc * spread_factor self.samp_rate = samp_rate = 100e3 self.point = point = const.points() ################################################## # Blocks ################################################## self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=sps, excess_bw=0.35, verbose=False, log=False, ) self.digital_glfsr_source_x_0 = digital.glfsr_source_b(16, True, 0, 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.0001, frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False) self.blocks_xor_xx_0 = blocks.xor_bb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, 10000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_xor_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_xor_xx_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.blocks_xor_xx_0, 1)) self.connect((self.digital_psk_mod_0, 0), (self.channels_channel_model_0, 0))
def __init__(self): gr.top_block.__init__(self, "Bipolar NRZ over AWGN with convolution FEC code and Viterbi decoder") Qt.QWidget.__init__(self) self.setWindowTitle("Bipolar NRZ over AWGN with convolution FEC code and Viterbi decoder") 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.seed = seed = 1 self.samp_rate = samp_rate = 32000 self.noise_voltage = noise_voltage = 1 self.mask = mask = 0 self.encoder = encoder = fec.cc_encoder_make(2048, 7, 2, ([79,109]), 0, fec.CC_STREAMING, False) self.degree = degree = 20 self.decoder = decoder = fec.cc_decoder.make(2048, 7, 2, ([79,109]), 0, -1, fec.CC_STREAMING, False) ################################################## # Blocks ################################################## self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] 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_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-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, 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(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.glfsr_source_0 = digital.glfsr_source_b(degree, True, mask, seed) self.fec_extended_encoder_0 = fec.extended_encoder(encoder_obj_list=encoder, threading='capillary', puncpat='11') self.fec_extended_decoder_0 = fec.extended_decoder(decoder_obj_list=decoder, threading='capillary', ann=None, puncpat='11', integration_period=10000) self.fec_ber_bf_0 = fec.ber_bf(False, 100, -10) 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_char_to_float_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_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.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, noise_voltage, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.fec_extended_decoder_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_char_to_float_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.fec_ber_bf_0, 1)) self.connect((self.blocks_pack_k_bits_bb_0_0, 0), (self.fec_ber_bf_0, 0)) self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.fec_extended_decoder_0, 0), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.fec_extended_decoder_0, 0), (self.blocks_pack_k_bits_bb_0_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blocks_char_to_float_1, 0)) self.connect((self.glfsr_source_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.glfsr_source_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.glfsr_source_0, 0), (self.fec_extended_encoder_0, 0))
def test_000_make_b(self): src = digital.glfsr_source_b(16) self.assertEqual(src.mask(), 0x8016) self.assertEqual(src.period(), 2**16-1)
def test_001_degree_b(self): self.assertRaises(RuntimeError, lambda: digital.glfsr_source_b(0)) self.assertRaises(RuntimeError, lambda: digital.glfsr_source_b(33))
def __init__(self): gr.top_block.__init__(self, "Gnuradioflow") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 25e6 self.constellation = constellation = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base() self.center_freq = center_freq = 915.1e6 ################################################## # Blocks ################################################## self.usrp_source = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.usrp_source.set_samp_rate(samp_rate) #self.usrp_source.set_time_unknown_pps(uhd.time_spec()) self.usrp_source.set_center_freq(center_freq, 0) self.usrp_source.set_gain(20, 0) self.usrp_source.set_antenna("RX2", 0) self.usrp_source.set_bandwidth(samp_rate, 0) self.usrp_sink = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.usrp_sink.set_samp_rate(samp_rate) #self.usrp_sink.set_time_unknown_pps(uhd.time_spec()) self.usrp_sink.set_center_freq(center_freq, 0) self.usrp_sink.set_gain(3, 0) self.usrp_sink.set_antenna("TX/RX", 0) self.usrp_sink.set_bandwidth(samp_rate, 0) #set USRP start time... start_time=self.usrp_sink.get_time_now().get_real_secs()+.1 self.usrp_sink.set_start_time(uhd.time_spec(start_time)) self.usrp_source.set_start_time(uhd.time_spec(start_time)) #print "time is now: %d",int(start_time)-5 #print "test starting at: %d",int(start_time) self.digital_glfsr_source_x_0 = digital.glfsr_source_b(7, False, 0, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constellation, differential=True, samples_per_symbol=2, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.5, )) self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, 3000000) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/mewing/Desktop/rxwave", False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/mewing/Desktop/txwave", False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.usrp_sink, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_glfsr_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.usrp_source, 0), (self.blocks_head_0, 0))
def __init__(self, cw_len=64, payload_len=255, samp_rate=1e6): gr.hier_block2.__init__( self, "Wes Packet Tx", gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signaturev(6, 6, [ gr.sizeof_gr_complex * 1, gr.sizeof_char * 1, gr.sizeof_char * 1, gr.sizeof_char * 1, gr.sizeof_char * 1, gr.sizeof_char * 1 ]), ) ################################################## # Parameters ################################################## self.cw_len = cw_len self.payload_len = payload_len self.samp_rate = samp_rate ################################################## # Variables ################################################## self.num_tag_key = num_tag_key = "packet_num" self.len_tag_key = len_tag_key = "packet_length" self.header_len = header_len = 32 self.throttle_rate = throttle_rate = 100e3 self.tag_s = tag_s = gr.tag_utils.python_to_tag( (0, pmt.intern(len_tag_key), pmt.from_long(payload_len), pmt.intern("vect_test_src"))) self.tag0 = tag0 = gr.tag_utils.python_to_tag( (0, pmt.intern(len_tag_key), pmt.from_long(cw_len), pmt.intern("vect_cw_src"))) self.sync_seq = sync_seq = [ 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1 ] self.sync_len = sync_len = 63 self.sym_table = sym_table = [-1, 1] self.pi = pi = 3.141592654 self.header_formatter = header_formatter = digital.packet_header_default( header_len, len_tag_key, num_tag_key, 1) self.diff_mod = diff_mod = 4 self.cw = cw = int((cw_len / 4)) * [1, 0, 1, 0] self.const = const = digital.constellation_calcdist( digital.psk_4()[0], digital.psk_4()[1], 2, 1).base() ################################################## # Blocks ################################################## self.digital_packet_headergenerator_bb_0_0 = digital.packet_headergenerator_bb( header_formatter.formatter(), len_tag_key) self.digital_glfsr_source_x_0 = digital.glfsr_source_b(6, True, 0, 1) self.digital_diff_encoder_bb_0_0 = digital.diff_encoder_bb(2) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (-1, 1), 1) self.blocks_vector_source_x_0_0 = blocks.vector_source_b( cw, True, 1, [tag0]) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, len_tag_key, 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_char * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, sync_len, "packet_length") self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, payload_len, len_tag_key) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, header_len, len_tag_key) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 1, 1, "packet_length", False, gr.GR_LSB_FIRST) ################################################## # Connections ################################################## self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self, 5)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0), (self.digital_diff_encoder_bb_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0), (self.digital_packet_headergenerator_bb_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self, 2)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_tagged_stream_mux_0, 2)) self.connect((self.digital_diff_encoder_bb_0, 0), (self, 4)) self.connect((self.digital_diff_encoder_bb_0_0, 0), (self.blocks_tagged_stream_mux_0, 3)) self.connect((self.digital_diff_encoder_bb_0_0, 0), (self, 3)) self.connect((self.digital_glfsr_source_x_0, 0), (self.blocks_stream_to_tagged_stream_1, 0)) self.connect((self.digital_packet_headergenerator_bb_0_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self, 0), (self.blocks_stream_to_tagged_stream_0_0_0, 0))
def __init__(self, min_errors=100, noise=0, samp_per_sym=50, tcola_m=32, tcola_r=1): gr.top_block.__init__(self, "BER 4FSK TCOLA") ################################################## # Parameters ################################################## self.min_errors = min_errors self.noise = noise self.samp_per_sym = samp_per_sym self.tcola_m = tcola_m self.tcola_r = tcola_r ################################################## # Variables ################################################## self.symb_rate = symb_rate = 4800 self.rrc_taps = rrc_taps = samp_per_sym * 6 + 1 self.symbol_delay = symbol_delay = rrc_taps / samp_per_sym - 1 self.samp_rate = samp_rate = symb_rate * samp_per_sym self.fsk_deviation_hz = fsk_deviation_hz = 648 self.bits_skip = bits_skip = 10000 self.bits_per_sym = bits_per_sym = 2 ################################################## # Blocks ################################################## self.delay = blocks.delay(gr.sizeof_char * 1, (symbol_delay + symb_rate) * bits_per_sym) self.vco = blocks.vco_c(samp_rate, fsk_deviation_hz * 2 * math.pi, 1) 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.sample_counter = sample_counter() self.quadrature_demod = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz)) self.probe_avg_power = analog.probe_avg_mag_sqrd_c(0, 1) self.pack_rx_bits = blocks.pack_k_bits_bb(8) self.pack_msg_bits = blocks.pack_k_bits_bb(8) self.glfsr = digital.glfsr_source_b(8, True, 0, 1) self.four_level_rrc_transmitter = 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 = 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.channel_model = channels.channel_model(noise_voltage=noise, frequency_offset=0.0, epsilon=1.0, taps=(1, ), noise_seed=0, block_tags=False) self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_char * 1, bits_skip) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, bits_skip) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, samp_rate - tcola_m) self.ber_sink = blocks.vector_sink_f(1) self.ber_measure = fec.ber_bf(True, min_errors, -7.0) ################################################## # Connections ################################################## self.connect((self.ber_measure, 0), (self.ber_sink, 0)) self.connect((self.blocks_delay_0_0, 0), (self.quadrature_demod, 0)) self.connect((self.blocks_skiphead_0, 0), (self.sample_counter, 0)) self.connect((self.blocks_skiphead_0_0, 0), (self.pack_rx_bits, 0)) self.connect((self.channel_model, 0), (self.tcola_overlap_add_0, 0)) self.connect((self.delay, 0), (self.blocks_skiphead_0, 0)) self.connect((self.four_level_rrc_receiver, 2), (self.blocks_skiphead_0_0, 0)) self.connect((self.four_level_rrc_transmitter, 1), (self.vco, 0)) self.connect((self.glfsr, 0), (self.delay, 0)) self.connect((self.glfsr, 0), (self.four_level_rrc_transmitter, 0)) self.connect((self.pack_msg_bits, 0), (self.ber_measure, 0)) self.connect((self.pack_rx_bits, 0), (self.ber_measure, 1)) self.connect((self.quadrature_demod, 0), (self.four_level_rrc_receiver, 0)) self.connect((self.sample_counter, 0), (self.pack_msg_bits, 0)) self.connect((self.tcola_overlap_add_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.tcola_time_compression_0, 0), (self.channel_model, 0)) self.connect((self.tcola_time_compression_0, 0), (self.probe_avg_power, 0)) self.connect((self.vco, 0), (self.tcola_time_compression_0, 0))