def __init__(self, options): gr.top_block.__init__(self) # Setup USRP self.u = uhd.usrp_sink(options.args, uhd.stream_args('fc32'), "packet_len") if(options.spec): self.u.set_subdev_spec(options.spec, 0) if(options.antenna): self.u.set_antenna(options.antenna, 0) self.u.set_samp_rate(options.rate) # Gain is set in the hopper block if options.gain is None: g = self.u.get_gain_range() options.gain = float(g.start()+g.stop())/2.0 print "-- Setting gain to {} dB".format(options.gain) r = self.u.set_center_freq(options.freq) if not r: print '[ERROR] Failed to set base frequency.' raise SystemExit, 1 hopper_block = FrequencyHopperSrc( options.num_bursts, options.num_channels, options.freq_delta, options.freq, options.samp_per_burst, 1.0, options.hop_time / 1000., options.post_tuning, options.gain, options.verbose, ) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## # self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(1, samp_rate, 1, 0.35, 11*samp_rate)) self.digital_dxpsk_mod_0 = digital.dqpsk_mod( samples_per_symbol=4, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 0), True, 1, []) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.500, )) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble="", access_code="11111111", pad_for_usrp=True, ), payload_length=0, ) self.connect(self.blocks_vector_source_x_0, self.blks2_packet_encoder_0, self.digital_dxpsk_mod_0, self.blocks_multiply_const_vxx_0, hopper_block, self.u)
def __init__(self, amplitude=0.01, excessBW=0.35, sps=4, arity=1): gr.hier_block2.__init__( self, "DPSKTransmitter", gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Parameters ################################################## self.amplitude = amplitude self.excessBW = excessBW self.sps = sps self.arity = arity if (arity != 2 and arity != 4): raise ValueError, "Unsupported modulation order '%d'" % (arity, ) ################################################## # Blocks ################################################## if (self.arity == 2): # BPSK self.digital_dxpsk_mod = digital.dbpsk_mod(samples_per_symbol=sps, excess_bw=excessBW, mod_code="gray", verbose=False, log=False) else: self.digital_dxpsk_mod = digital.dqpsk_mod(samples_per_symbol=sps, excess_bw=excessBW, mod_code="gray", verbose=False, log=False) self.blocks_multiply_const_vxx = blocks.multiply_const_vcc( (amplitude, )) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx, 0), (self, 0)) self.connect((self.digital_dxpsk_mod, 0), (self.blocks_multiply_const_vxx, 0)) self.connect((self, 0), (self.digital_dxpsk_mod, 0))
def __init__(self, address='addr=192.168.10.4', freq=2.45e9, gain=0, samp_rate=32e3): gr.top_block.__init__(self, "UHD TX DPSK") Qt.QWidget.__init__(self) self.setWindowTitle("UHD TX DPSK") 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", "uhd_tx_dpsk") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.address = address self.freq = freq self.gain = gain self.samp_rate = samp_rate ################################################## # Variables ################################################## self.tun_gain = tun_gain = 0 self.tun_freq = tun_freq = 2.45e9 self.samps_per_sym = samps_per_sym = 4 self.ampl = ampl = 0.3 ################################################## # Blocks ################################################## self._tun_freq_range = Range(2.4e9, 2.5e9, 1, 2.45e9, 200) self._tun_freq_win = RangeWidget(self._tun_freq_range, self.set_tun_freq, 'UHD Freq (Hz)', "counter_slider", float) self.top_layout.addWidget(self._tun_freq_win) self._ampl_range = Range(0, 1, 0.01, 0.3, 200) self._ampl_win = RangeWidget(self._ampl_range, self.set_ampl, 'Amplitude', "counter_slider", float) self.top_layout.addWidget(self._ampl_win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join((address, "")), 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(tun_freq, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self._tun_gain_range = Range(0, 20, 1, 0, 200) self._tun_gain_win = RangeWidget(self._tun_gain_range, self.set_tun_gain, 'UHD Tx Gain', "counter_slider", float) self.top_layout.addWidget(self._tun_gain_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype tun_freq, #fc samp_rate, #bw 'Transmit Spectrum', #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(True) 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 = ['', '', '', '', '', '', '', '', '', ''] 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_dxpsk_mod_0 = digital.dqpsk_mod( samples_per_symbol=samps_per_sym, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((ampl, )) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, 'C:\\Users\\ericj\\Desktop\\USRP_TX\\test.txt', True) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=samps_per_sym, bits_per_symbol=2, preamble='', access_code='', pad_for_usrp=True, ), payload_length=0, ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self) self.qapp = QtGui.QApplication(sys.argv) self._sample_rate = 2000e3 self.sps = 2 self.excess_bw = 0.35 self.gray_code = digital.mod_codes.GRAY_CODE fftsize = 2048 self.data = scipy.random.randint(0, 255, 1000) self.src = gr.vector_source_b(self.data.tolist(), True) self.mod = digital.dqpsk_mod(self.gray_code, samples_per_symbol=self.sps, excess_bw=self.excess_bw, verbose=False, log=False) self.rrctaps = gr.firdes.root_raised_cosine(1, self.sps, 1, self.excess_bw, 21) self.rx_rrc = gr.fir_filter_ccf(1, self.rrctaps) # Set up the carrier & clock recovery parameters self.arity = 4 self.mu = 0.5 self.gain_mu = 0.05 self.omega = self.sps self.gain_omega = .25 * self.gain_mu * self.gain_mu self.omega_rel_lim = 0.05 self._loop_bw = 2*scipy.pi/100.0 self.fmin = -1000/self.sample_rate() self.fmax = 1000/self.sample_rate() self.receiver = digital.mpsk_receiver_cc(self.arity, 0, self._loop_bw, self.fmin, self.fmax, self.mu, self.gain_mu, self.omega, self.gain_omega, self.omega_rel_lim) self.snr_dB = 15 noise = self.get_noise_voltage(self.snr_dB) self.fo = 100/self.sample_rate() self.to = 1.0 self.channel = gr.channel_model(noise, self.fo, self.to) self.thr = gr.throttle(gr.sizeof_char, self._sample_rate) self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, self._sample_rate*self.sps, "Tx", True, True, True, True) self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, self._sample_rate, "Rx", True, True, True, True) self.connect(self.src, self.thr, self.mod, self.channel, self.snk_tx) self.connect(self.channel, self.rx_rrc, self.receiver, self.snk_rx) pyTxQt = self.snk_tx.pyqwidget() pyTx = sip.wrapinstance(pyTxQt, QtGui.QWidget) pyRxQt = self.snk_rx.pyqwidget() pyRx = sip.wrapinstance(pyRxQt, QtGui.QWidget) self.main_box = dialog_box(pyTx, pyRx, self); self.main_box.show()
def __init__(self): gr.top_block.__init__(self, "MPSK Demod Demo") Qt.QWidget.__init__(self) self.setWindowTitle("MPSK Demod Demo") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "mpsk_demod") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samps_per_sym = samps_per_sym = 4 self.samp_rate = samp_rate = 32000 self.noise = noise = 0.1 self.freq_off = freq_off = 0 ################################################## # Blocks ################################################## self.notebook = Qt.QTabWidget() self.notebook_widget_0 = Qt.QWidget() self.notebook_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_widget_0) self.notebook_grid_layout_0 = Qt.QGridLayout() self.notebook_layout_0.addLayout(self.notebook_grid_layout_0) self.notebook.addTab(self.notebook_widget_0, 'Constellation') self.notebook_widget_1 = Qt.QWidget() self.notebook_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_widget_1) self.notebook_grid_layout_1 = Qt.QGridLayout() self.notebook_layout_1.addLayout(self.notebook_grid_layout_1) self.notebook.addTab(self.notebook_widget_1, 'Spectrum') self.top_grid_layout.addWidget(self.notebook, 0, 0, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._noise_range = Range(0, 1, 0.01, 0.1, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._freq_off_range = Range(-0.5, 0.5, 0.01, 0, 200) self._freq_off_win = RangeWidget(self._freq_off_range, self.set_freq_off, 'Freq. Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_off_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.notebook_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size '', #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) 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.notebook_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.digital_dxpsk_mod_0 = digital.dqpsk_mod( samples_per_symbol=samps_per_sym, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq_off, epsilon=1.0, 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.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2**8, 10000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.channels_channel_model_0, 0))
def __init__(self, samp=4): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.samp = samp ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32E3 ################################################## # Blocks ################################################## self.digital_dxpsk_mod_0 = digital.dqpsk_mod(samples_per_symbol=samp, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.digital_dxpsk_demod_0 = digital.dqpsk_demod( samples_per_symbol=samp, excess_bw=0.35, freq_bw=6.28 / 100.0, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) 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, 'C:\\Users\\ericj\\Senior-Design\\UMass-Dartmouth.png', False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, 'C:\\Users\\ericj\\Desktop\\out.png', False) self.blocks_file_sink_0.set_unbuffered(True) self.blks2_packet_encoder_0_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=samp, bits_per_symbol=2, preamble='', access_code='', pad_for_usrp=True, ), payload_length=8, ) 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), ), ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_packet_encoder_0_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_packet_encoder_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.digital_dxpsk_demod_0, 0))
def __init__(self): gr.top_block.__init__(self) self.qapp = QtGui.QApplication(sys.argv) self._sample_rate = 2000e3 self.sps = 2 self.excess_bw = 0.35 self.gray_code = digital.mod_codes.GRAY_CODE fftsize = 2048 self.data = scipy.random.randint(0, 255, 1000) self.src = blocks.vector_source_b(self.data.tolist(), True) self.mod = digital.dqpsk_mod(self.gray_code, samples_per_symbol=self.sps, excess_bw=self.excess_bw, verbose=False, log=False) self.rrctaps = filter.firdes.root_raised_cosine( 1, self.sps, 1, self.excess_bw, 21) self.rx_rrc = filter.fir_filter_ccf(1, self.rrctaps) # Set up the carrier & clock recovery parameters self.arity = 4 self.mu = 0.5 self.gain_mu = 0.05 self.omega = self.sps self.gain_omega = .25 * self.gain_mu * self.gain_mu self.omega_rel_lim = 0.05 self._loop_bw = 2 * scipy.pi / 100.0 self.fmin = -1000 / self.sample_rate() self.fmax = 1000 / self.sample_rate() self.receiver = digital.mpsk_receiver_cc(self.arity, 0, self._loop_bw, self.fmin, self.fmax, self.mu, self.gain_mu, self.omega, self.gain_omega, self.omega_rel_lim) self.snr_dB = 15 noise = self.get_noise_voltage(self.snr_dB) self.fo = 100 / self.sample_rate() self.to = 1.0 self.channel = channels.channel_model(noise, self.fo, self.to) self.thr = blocks.throttle(gr.sizeof_char, self._sample_rate) self.snk_tx = qtgui.sink_c(fftsize, filter.firdes.WIN_BLACKMAN_hARRIS, 0, self._sample_rate * self.sps, "Tx", True, True, True, True) self.snk_rx = qtgui.sink_c(fftsize, filter.firdes.WIN_BLACKMAN_hARRIS, 0, self._sample_rate, "Rx", True, True, True, True) self.connect(self.src, self.thr, self.mod, self.channel, self.snk_tx) self.connect(self.channel, self.rx_rrc, self.receiver, self.snk_rx) pyTxQt = self.snk_tx.pyqwidget() pyTx = sip.wrapinstance(pyTxQt, QtGui.QWidget) pyRxQt = self.snk_rx.pyqwidget() pyRx = sip.wrapinstance(pyRxQt, QtGui.QWidget) self.main_box = dialog_box(pyTx, pyRx, self) self.main_box.show()
def __init__(self): gr.top_block.__init__(self, "MPSK Demod Demo") Qt.QWidget.__init__(self) self.setWindowTitle("MPSK Demod Demo") 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_demod") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samps_per_sym = samps_per_sym = 4 self.samp_rate = samp_rate = 50000000 ################################################## # Blocks ################################################## self.notebook = Qt.QTabWidget() self.notebook_widget_0 = Qt.QWidget() self.notebook_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_widget_0) self.notebook_grid_layout_0 = Qt.QGridLayout() self.notebook_layout_0.addLayout(self.notebook_grid_layout_0) self.notebook.addTab(self.notebook_widget_0, "Constellation") self.notebook_widget_1 = Qt.QWidget() self.notebook_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_widget_1) self.notebook_grid_layout_1 = Qt.QGridLayout() self.notebook_layout_1.addLayout(self.notebook_grid_layout_1) self.notebook.addTab(self.notebook_widget_1, "Spectrum") self.top_layout.addWidget(self.notebook) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name 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_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.notebook_layout_1.addWidget(self._qtgui_freq_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_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.notebook_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.digital_dxpsk_mod_0 = digital.dqpsk_mod( samples_per_symbol=samps_per_sym, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_gr_complex*1, addr="127.0.0.1", port=3305, server=True, ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2**8, 1000000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_tcp_sink_0, 0))
def __init__(self, address="addr=192.168.10.2", freq=2.45e9, gain=0, samp_rate=1e6): gr.top_block.__init__(self, "UHD TX DPSK") Qt.QWidget.__init__(self) self.setWindowTitle("UHD TX DPSK") 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", "uhd_tx_dpsk") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.address = address self.freq = freq self.gain = gain self.samp_rate = samp_rate ################################################## # Variables ################################################## self.tun_gain = tun_gain = 0 self.tun_freq = tun_freq = 2.45e9 self.samps_per_sym = samps_per_sym = 4 self.ampl = ampl = 0.1 ################################################## # Blocks ################################################## self._tun_freq_range = Range(2.4e9, 2.5e9, 1, 2.45e9, 200) self._tun_freq_win = RangeWidget(self._tun_freq_range, self.set_tun_freq, "UHD Freq (Hz)", "counter_slider", float) self.top_layout.addWidget(self._tun_freq_win) self._ampl_range = Range(0, 1, 0.01, 0.1, 200) self._ampl_win = RangeWidget(self._ampl_range, self.set_ampl, "Amplitude", "counter_slider", float) self.top_layout.addWidget(self._ampl_win) self._tun_gain_range = Range(0, 20, 1, 0, 200) self._tun_gain_win = RangeWidget(self._tun_gain_range, self.set_tun_gain, "UHD Tx Gain", "counter_slider", float) self.top_layout.addWidget(self._tun_gain_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype tun_freq, #fc samp_rate, #bw "Transmit Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not 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 = ["", "", "", "", "", "", "", "", "", ""] 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_dxpsk_mod_0 = digital.dqpsk_mod( samples_per_symbol=samps_per_sym, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1, "127.0.0.1", 1224, 1472, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((ampl, )) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2**8, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, address='serial=307B618', freq=915e6, gain=0, samp_rate=2e6): gr.top_block.__init__(self, "UHD TX DPSK") Qt.QWidget.__init__(self) self.setWindowTitle("UHD TX DPSK") 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", "uhd_tx_dpsk") 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)) ################################################## # Parameters ################################################## self.address = address self.freq = freq self.gain = gain self.samp_rate = samp_rate ################################################## # Variables ################################################## self.tun_gain = tun_gain = 50 self.tun_freq = tun_freq = 915.8e6 self.samps_per_sym = samps_per_sym = 4 self.ampl = ampl = 0.1 ################################################## # Blocks ################################################## self._tun_gain_range = Range(40, 80, 1, 50, 200) self._tun_gain_win = RangeWidget(self._tun_gain_range, self.set_tun_gain, 'UHD Tx Gain', "counter_slider", float) self.top_layout.addWidget(self._tun_gain_win) self._tun_freq_range = Range(914.8e6, 916.8e6, 1, 915.8e6, 200) self._tun_freq_win = RangeWidget(self._tun_freq_range, self.set_tun_freq, 'UHD Freq (Hz)', "counter_slider", float) self.top_layout.addWidget(self._tun_freq_win) self._ampl_range = Range(0, 1, 0.01, 0.1, 200) self._ampl_win = RangeWidget(self._ampl_range, self.set_ampl, 'Amplitude', "counter_slider", float) self.top_layout.addWidget(self._ampl_win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(('', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(tun_freq, 0) self.uhd_usrp_sink_0.set_gain(tun_gain, 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype tun_freq, #fc samp_rate, #bw 'Transmit Spectrum', #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(True) 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 = ['', '', '', '', '', '', '', '', '', ''] 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_dxpsk_mod_0 = digital.dqpsk_mod( samples_per_symbol=samps_per_sym, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((ampl, )) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2**8, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))