def __init__(self): gr.top_block.__init__(self) # grc_wxgui.top_block_gui.__init__(self, title="Top Block") # _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" # self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.samp_per_sym = samp_per_sym = 8 ################################################## # Blocks ################################################## # Docs for osmosdr parms are in: http://cgit.osmocom.org/gr-osmosdr/tree/grc/gen_osmosdr_blocks.py self.rtlsdr_source_c_0 = osmosdr.source( args="nchan=1") self.rtlsdr_source_c_0.set_sample_rate(samp_rate) self.rtlsdr_source_c_0.set_center_freq(500e6, 0) self.rtlsdr_source_c_0.set_freq_corr(0, 0) self.rtlsdr_source_c_0.set_iq_balance_mode(0, 0) # 0 is off, 1 manual, 2 automatic self.rtlsdr_source_c_0.set_gain_mode(1, 0) # automatic gain. 0 means manual, 1 means automatic # self.rtlsdr_source_c_0.set_gain(10, 0) # self.rtlsdr_source_c_0.set_if_gain(20, 0) # self.rtlsdr_source_c_0.set_bb_gain(20, 0) # self.rtlsdr_source_c_0.set_antenna("", 0) self.rtlsdr_source_c_0.set_bandwidth(0, 0) self.digital_dxpsk_demod_0 = digital.dqpsk_demod( mod_code='gray', samples_per_symbol=8, excess_bw=0.35, freq_bw=6.28/1000.0, phase_bw=6.28/1000.0, timing_bw=6.28/1000.0, # gray_coded=True, verbose=True, log=True ) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/sdr_output.txt") self.blocks_file_sink_0.set_unbuffered(False) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code="0001000100010001", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) ################################################## # Connections ################################################## self.connect((self.digital_dxpsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.rtlsdr_source_c_0, 0), (self.digital_dxpsk_demod_0, 0))
def __init__(self, address='serial=307B618', freq=2.45e9, freq_offset=0, gain=0, samp_rate=1e6): gr.top_block.__init__(self, "UHD RX DPSK") Qt.QWidget.__init__(self) self.setWindowTitle("UHD RX 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_rx_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.freq_offset = freq_offset 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.rx_freq_off = rx_freq_off = 0 self.rolloff = rolloff = .35 self.nfilts = nfilts = 32 ################################################## # Blocks ################################################## 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._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._rx_freq_off_range = Range(-100e3, 100e3, 1, 0, 200) self._rx_freq_off_win = RangeWidget(self._rx_freq_off_range, self.set_rx_freq_off, 'Rx Freq Offset (Hz)', "counter_slider", float) self.top_layout.addWidget(self._rx_freq_off_win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((address, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(tun_freq+rx_freq_off, 0) self.uhd_usrp_source_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 "", #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 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_demod_0 = digital.dqpsk_demod( samples_per_symbol=samps_per_sym, 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.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1) ################################################## # Connections ################################################## self.connect((self.digital_dxpsk_demod_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.tun_gain = tun_gain = 0 self.tun_freq = tun_freq = 2.45e9 self.samp_rate = samp_rate = 32000 self.rx_freq_off = rx_freq_off = 0 self.freq = freq = 2.45e9 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.3", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_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._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._rx_freq_off_range = Range(-100e3, 100e3, 1, 0, 200) self._rx_freq_off_win = RangeWidget(self._rx_freq_off_range, self.set_rx_freq_off, "Rx Freq Offset (Hz)", "counter_slider", float) self.top_layout.addWidget(self._rx_freq_off_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "USRP RX", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "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_demod_0 = digital.dqpsk_demod(samples_per_symbol=4, 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.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, "/home/test/Desktop/RX.png", False) self.blocks_file_sink_0.set_unbuffered(False) 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.digital_dxpsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_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, samp_rate=1e6, freq=2.45e9, gain=0, freq_offset=0, address="addr=192.168.10.3"): grc_wxgui.top_block_gui.__init__(self, title="UHD RX DPSK") ################################################## # Parameters ################################################## self.samp_rate = samp_rate self.freq = freq self.gain = gain self.freq_offset = freq_offset self.address = address ################################################## # Variables ################################################## self.tun_gain = tun_gain = gain self.tun_freq = tun_freq = freq self.timing_bw = timing_bw = 6.28/100.0 self.samps_per_sym = samps_per_sym = 4 self.rx_freq_off = rx_freq_off = freq_offset self.phase_bw = phase_bw = 6.28/100.0 ################################################## # Blocks ################################################## _tun_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._tun_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_tun_gain_sizer, value=self.tun_gain, callback=self.set_tun_gain, label="UHD Gain", converter=forms.float_converter(), proportion=0, ) self._tun_gain_slider = forms.slider( parent=self.GetWin(), sizer=_tun_gain_sizer, value=self.tun_gain, callback=self.set_tun_gain, minimum=0, maximum=20, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tun_gain_sizer) _tun_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._tun_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_tun_freq_sizer, value=self.tun_freq, callback=self.set_tun_freq, label="Freq (Hz)", converter=forms.float_converter(), proportion=0, ) self._tun_freq_slider = forms.slider( parent=self.GetWin(), sizer=_tun_freq_sizer, value=self.tun_freq, callback=self.set_tun_freq, minimum=2.4e9, maximum=2.5e9, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tun_freq_sizer) _timing_bw_sizer = wx.BoxSizer(wx.VERTICAL) self._timing_bw_text_box = forms.text_box( parent=self.GetWin(), sizer=_timing_bw_sizer, value=self.timing_bw, callback=self.set_timing_bw, label="Timing Loop BW", converter=forms.float_converter(), proportion=0, ) self._timing_bw_slider = forms.slider( parent=self.GetWin(), sizer=_timing_bw_sizer, value=self.timing_bw, callback=self.set_timing_bw, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_timing_bw_sizer) _rx_freq_off_sizer = wx.BoxSizer(wx.VERTICAL) self._rx_freq_off_text_box = forms.text_box( parent=self.GetWin(), sizer=_rx_freq_off_sizer, value=self.rx_freq_off, callback=self.set_rx_freq_off, label="RX Freq Offset (Hz)", converter=forms.float_converter(), proportion=0, ) self._rx_freq_off_slider = forms.slider( parent=self.GetWin(), sizer=_rx_freq_off_sizer, value=self.rx_freq_off, callback=self.set_rx_freq_off, minimum=-100e3, maximum=+100e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_rx_freq_off_sizer) _phase_bw_sizer = wx.BoxSizer(wx.VERTICAL) self._phase_bw_text_box = forms.text_box( parent=self.GetWin(), sizer=_phase_bw_sizer, value=self.phase_bw, callback=self.set_phase_bw, label="Phase Loop BW", converter=forms.float_converter(), proportion=0, ) self._phase_bw_slider = forms.slider( parent=self.GetWin(), sizer=_phase_bw_sizer, value=self.phase_bw, callback=self.set_phase_bw, minimum=0, maximum=1.0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_phase_bw_sizer) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=tun_freq, y_per_div=10, y_divs=10, ref_level=10, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c( self.GetWin(), title="Constellation Plot", sample_rate=samp_rate, frame_rate=5, const_size=2048, M=4, theta=0, loop_bw=6.28/100.0, fmax=0.06, mu=0.5, gain_mu=0.005, symbol_rate=samp_rate/samps_per_sym, omega_limit=0.005, ) self.Add(self.wxgui_constellationsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((address, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(tun_freq+rx_freq_off, 0) self.uhd_usrp_source_0.set_gain(tun_gain, 0) self.digital_dxpsk_demod_0 = digital.dqpsk_demod( samples_per_symbol=samps_per_sym, 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.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1) ################################################## # Connections ################################################## self.connect((self.digital_dxpsk_demod_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_constellationsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))