コード例 #1
0
ファイル: real-display.py プロジェクト: Exadios/PWR
    def __init__(self, sample_rate, center_freq, gain, device_addr=""):
        gr.top_block.__init__(self)

        # Make a local QtApp so we can start it from our side
        self.qapp = QtGui.QApplication(sys.argv)

        fftsize = 2048

        self.src = uhd.single_usrp_source(
            device_addr="serial=4cfc2b4d", io_type=uhd.io_type_t.COMPLEX_FLOAT32, num_channels=1
        )
        self.src.set_samp_rate(sample_rate)
        self.src.set_center_freq(center_freq, 0)
        self.src.set_gain(gain, 0)
        self.src.set_time_now(uhd.time_spec_t(0.0))
        self.snk = qtgui.sink_c(
            fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, center_freq, self.src.get_samp_rate(), "Realtime Display"
        )

        cmd = uhd.cmd_t(uhd.stream_cmd_t.STREAM_MODE_NUM_SAMPS_AND_DONE)
        self.connect(self.src, self.snk)

        # Tell the sink we want it displayed
        self.pyobj = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)
        self.pyobj.show()
コード例 #2
0
    def __init__(self, sample_rate, center_freq, gain, device_addr=""):
        gr.top_block.__init__(self)

        # Make a local QtApp so we can start it from our side
        self.qapp = QtGui.QApplication(sys.argv)

        fftsize = 2048

        self.src = uhd.single_usrp_source(
            device_addr="serial=4cfc2b4d",
            io_type=uhd.io_type_t.COMPLEX_FLOAT32,
            num_channels=1)
        self.src.set_samp_rate(sample_rate)
        self.src.set_center_freq(center_freq, 0)
        self.src.set_gain(gain, 0)
        self.src.set_time_now(uhd.time_spec_t(0.0))
        self.snk = qtgui.sink_c(fftsize,
                                gr.firdes.WIN_BLACKMAN_hARRIS, center_freq,
                                self.src.get_samp_rate(), "Realtime Display")

        cmd = uhd.cmd_t(uhd.stream_cmd_t.STREAM_MODE_NUM_SAMPS_AND_DONE)
        self.connect(self.src, self.snk)

        # Tell the sink we want it displayed
        self.pyobj = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)
        self.pyobj.show()
コード例 #3
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)
        self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.gr_throttle_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.qtgui_sink_x_0, 0))
コード例 #4
0
ファイル: real-signal.py プロジェクト: Exadios/PWR
   def __init__(self, sample_rate, center_freq):
       gr.top_block.__init__(self)

       # Make a local QtApp so we can start it from our side
       self.qapp = QtGui.QApplication(sys.argv)

       fftsize = 2048

       self.src = uhd.single_usrp_source(io_type = uhd.io_type_t.COMPLEX_FLOAT32, num_channels = 1)
       self.snk = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS)

       self.connect(self.src, self.snk)

       # Tell the sink we want it displayed
       self.pyobj = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)
       self.pyobj.show()
コード例 #5
0
ファイル: real-signal.py プロジェクト: manasdas17/PWR
    def __init__(self, sample_rate, center_freq):
        gr.top_block.__init__(self)

        # Make a local QtApp so we can start it from our side
        self.qapp = QtGui.QApplication(sys.argv)

        fftsize = 2048

        self.src = uhd.single_usrp_source(
            io_type=uhd.io_type_t.COMPLEX_FLOAT32, num_channels=1)
        self.snk = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS)

        self.connect(self.src, self.snk)

        # Tell the sink we want it displayed
        self.pyobj = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)
        self.pyobj.show()
コード例 #6
0
    def __init__(self):
        gr.top_block.__init__(self, "Burst View")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Burst View")
        self.setWindowIcon(Qt.QIcon.fromTheme("gnuradio-grc"))
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_sink_x_0 = qtgui.sink_c(
            16 * 1024,  # fftsize
            firdes.WIN_BLACKMAN_hARRIS,  # wintype
            0,  # fc
            samp_rate,  # bw
            "QT GUI Plot",  # name
            True,  # plotfreq
            True,  # plotwaterfall
            True,  # plottime
            True,  # plotconst
        )
        self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)
        self.gr_udp_source_0 = gr.udp_source(gr.sizeof_gr_complex * 1, "127.0.0.1", 12345, 1472, True, True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_udp_source_0, 0), (self.qtgui_sink_x_0, 0))
コード例 #7
0
ファイル: gui.py プロジェクト: manasdas17/PWR
    def __init__(self):
        gr.top_block.__init__(self)

        # Make a local QtApp so we can start it from our side
        self.qapp = QtGui.QApplication(sys.argv)

        fftsize = 2048

        self.src = gr.sig_source_c(1, gr.GR_SIN_WAVE, 0.1, 1)
        self.nse = gr.noise_source_c(gr.GR_GAUSSIAN, 0.0)
        self.add = gr.add_cc()
        self.thr = gr.throttle(gr.sizeof_gr_complex, 100 * fftsize)
        self.snk = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS)

        self.connect(self.src, (self.add, 0))
        self.connect(self.nse, (self.add, 1))
        self.connect(self.add, self.thr, self.snk)

        # Tell the sink we want it displayed
        self.pyobj = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)
        self.pyobj.show()
コード例 #8
0
ファイル: gui.py プロジェクト: Exadios/PWR
   def __init__(self):
       gr.top_block.__init__(self)

       # Make a local QtApp so we can start it from our side
       self.qapp = QtGui.QApplication(sys.argv)

       fftsize = 2048

       self.src = gr.sig_source_c(1, gr.GR_SIN_WAVE, 0.1, 1)
       self.nse = gr.noise_source_c(gr.GR_GAUSSIAN, 0.0)
       self.add = gr.add_cc()
       self.thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize)
       self.snk = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS)

       self.connect(self.src, (self.add, 0))
       self.connect(self.nse, (self.add, 1))
       self.connect(self.add, self.thr, self.snk)

       # Tell the sink we want it displayed
       self.pyobj = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)
       self.pyobj.show()
コード例 #9
0
    def __init__(self):
        gr.top_block.__init__(self)

        Rs = 8000
        f1 = 1000
        f2 = 2000

        fftsize = 2048

        self.qapp = QtGui.QApplication(sys.argv)
        
        src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0)
        src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0)
        src  = gr.add_cc()
        channel = gr.channel_model(0.001)
        thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize)
        self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                 0, Rs,
                                 "Complex Signal Example",
                                 True, True, False, True, False)

        self.connect(src1, (src,0))
        self.connect(src2, (src,1))
        self.connect(src,  channel, thr, self.snk1)

        self.ctrl_win = control_box()
        self.ctrl_win.attach_signal1(src1)
        self.ctrl_win.attach_signal2(src2)

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        pyQt  = self.snk1.pyqwidget()

        # Wrap the pointer as a PyQt SIP object
        # This can now be manipulated as a PyQt4.QtGui.QWidget
        pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)

        self.main_box = dialog_box(pyWin, self.ctrl_win)

        self.main_box.show()
コード例 #10
0
    def __init__(self):
        gr.top_block.__init__(self)

        Rs = 8000
        f1 = 1000
        f2 = 2000

        fftsize = 2048

        self.qapp = QtGui.QApplication(sys.argv)

        src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0)
        src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0)
        src = gr.add_cc()
        channel = gr.channel_model(0.001)
        thr = gr.throttle(gr.sizeof_gr_complex, 100 * fftsize)
        self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, Rs,
                                 "Complex Signal Example", True, True, False,
                                 True, False)

        self.connect(src1, (src, 0))
        self.connect(src2, (src, 1))
        self.connect(src, channel, thr, self.snk1)

        self.ctrl_win = control_box()
        self.ctrl_win.attach_signal1(src1)
        self.ctrl_win.attach_signal2(src2)

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        pyQt = self.snk1.pyqwidget()

        # Wrap the pointer as a PyQt SIP object
        # This can now be manipulated as a PyQt4.QtGui.QWidget
        self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)

        self.main_box = dialog_box(self.pyWin, self.ctrl_win)

        self.main_box.show()
コード例 #11
0
ファイル: lampros.py プロジェクト: katsikas/katsikas-repo
	def __init__(self):
		gr.top_block.__init__(self, "QAM16")
		Qt.QWidget.__init__(self)
		self.setWindowTitle("QAM16")
		self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
		self.top_scroll_layout = Qt.QVBoxLayout()
		self.setLayout(self.top_scroll_layout)
		self.top_scroll = Qt.QScrollArea()
		self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
		self.top_scroll_layout.addWidget(self.top_scroll)
		self.top_scroll.setWidgetResizable(True)
		self.top_widget = Qt.QWidget()
		self.top_scroll.setWidget(self.top_widget)
		self.top_layout = Qt.QVBoxLayout(self.top_widget)
		self.top_grid_layout = Qt.QGridLayout()
		self.top_layout.addLayout(self.top_grid_layout)


		##################################################
		# Variables
		##################################################
		self.variable_qtgui_range_0 = variable_qtgui_range_0 = 474e6
		self.samp_rate = samp_rate = 44100
		self.Useful_Carriers = Useful_Carriers = 1024
		self.Transmission_Frequency = Transmission_Frequency = 474e6
		self.OFDM_Symbols = OFDM_Symbols = 2048
		self.Guard_Interval = Guard_Interval = 4
		self.Gain = Gain = 20
		self.Packets_Number = 2048

		

		
		##################################################
		# My code...
		print(atsc.ATSC_MPEG_PKT_LENGTH);
		print(atsc.MPEG_SYNC_BYTE);
		self.ts = self.make_fake_transport_stream_packet(self.Packets_Number) # make 2048 packets of 188 each one.
		print(len(self.ts))
		##################################################		
	
	

		##################################################
		# Blocks
		##################################################
		self._variable_qtgui_range_0_layout = Qt.QVBoxLayout()
		self._variable_qtgui_range_0_tool_bar = Qt.QToolBar(self)
		self._variable_qtgui_range_0_layout.addWidget(self._variable_qtgui_range_0_tool_bar)
		self._variable_qtgui_range_0_tool_bar.addWidget(Qt.QLabel("Transmission_Frequency"+": "))
		self._variable_qtgui_range_0_counter = Qwt.QwtCounter()
		self._variable_qtgui_range_0_counter.setRange(470e6, 478e6, 1e3)
		self._variable_qtgui_range_0_counter.setNumButtons(2)
		self._variable_qtgui_range_0_counter.setValue(self.variable_qtgui_range_0)
		self._variable_qtgui_range_0_tool_bar.addWidget(self._variable_qtgui_range_0_counter)
		self._variable_qtgui_range_0_counter.valueChanged.connect(self.set_variable_qtgui_range_0)
		self._variable_qtgui_range_0_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
		self._variable_qtgui_range_0_slider.setRange(470e6, 478e6, 1e3)
		self._variable_qtgui_range_0_slider.setValue(self.variable_qtgui_range_0)
		self._variable_qtgui_range_0_slider.setMinimumWidth(200)
		self._variable_qtgui_range_0_slider.valueChanged.connect(self.set_variable_qtgui_range_0)
		self._variable_qtgui_range_0_layout.addWidget(self._variable_qtgui_range_0_slider)
		self.top_layout.addLayout(self._variable_qtgui_range_0_layout)
		self.qtgui_sink_x_0 = qtgui.sink_c(
			OFDM_Symbols, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			Transmission_Frequency, #fc
			8e6, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			False, #plotwaterfall
			True, #plottime
			False, #plotconst
		)
		self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
		self.top_layout.addWidget(self._qtgui_sink_x_0_win)
		self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate)
		#self.gr_file_source_0 = gr.file_source(gr.sizeof_float*1, "/home/katsikas/katsikas-repo/Gnuradio/Common/Text.txt", True)
		self.gr_vector_source_0 = gr.vector_source_f(self.ts, True, 1)
		self.gr_file_sink_0 = gr.file_sink(gr.sizeof_float*1, "/home/katsikas/katsikas-repo/Gnuradio/Common/Results.txt")
		self.gr_file_sink_0.set_unbuffered(False)
		self.digital_ofdm_mod_0 = grc_blks2.packet_mod_f(digital.ofdm_mod(
				options=grc_blks2.options(
					modulation="qam64",
					fft_length=OFDM_Symbols,
					occupied_tones=Useful_Carriers,
					cp_length=OFDM_Symbols/Guard_Interval,
					pad_for_usrp=True,
					log=None,
					verbose=None,
				),
			),
			payload_length=0,
		)
		self.digital_ofdm_demod_0 = grc_blks2.packet_demod_f(digital.ofdm_demod(
				options=grc_blks2.options(
					modulation="qam64",
					fft_length=OFDM_Symbols,
					occupied_tones=Useful_Carriers,
					cp_length=OFDM_Symbols/Guard_Interval,
					snr=20,
					log=None,
					verbose=None,
				),
				callback=lambda ok, payload: self.digital_ofdm_demod_0.recv_pkt(ok, payload),
			),
		)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_throttle_0, 0), (self.qtgui_sink_x_0, 0))
		self.connect((self.digital_ofdm_mod_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.digital_ofdm_mod_0, 0), (self.digital_ofdm_demod_0, 0))
		#self.connect((self.gr_file_source_0, 0), (self.digital_ofdm_mod_0, 0))
		self.connect((self.gr_vector_source_0, 0), (self.digital_ofdm_mod_0, 0))
		self.connect((self.digital_ofdm_demod_0, 0), (self.gr_file_sink_0, 0))
コード例 #12
0
    def __init__(self):
        gr.top_block.__init__(self)

        self.qapp = QtGui.QApplication(sys.argv)

        self._sample_rate = 200e3

        self.sps = 2
        self.excess_bw = 0.35
        self.gray_code = True
        
        fftsize = 2048

        self.data = scipy.random.randint(0, 255, 1000)
        self.src = gr.vector_source_b(self.data.tolist(), True)
        self.mod = blks2.dqpsk_mod(self.sps, self.excess_bw, self.gray_code, False, 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.alpha = 0.15
        self.beta  = 0.25 * self.alpha * self.alpha
        self.fmin = -1000/self.sample_rate()
        self.fmax = 1000/self.sample_rate()
        
        self.receiver = gr.mpsk_receiver_cc(self.arity, 0,
                                            self.alpha, self.beta,
                                            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, 10*fftsize)
        self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, 1,
                                   "Tx", True, True, False, True, True)

        self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, 1,
                                   "Rx", True, True, False, 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()
コード例 #13
0
	def __init__(self):
		gr.top_block.__init__(self, "Fm Rx")
		Qt.QWidget.__init__(self)
		self.setWindowTitle("Fm Rx")
		self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
		self.top_scroll_layout = Qt.QVBoxLayout()
		self.setLayout(self.top_scroll_layout)
		self.top_scroll = Qt.QScrollArea()
		self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
		self.top_scroll_layout.addWidget(self.top_scroll)
		self.top_scroll.setWidgetResizable(True)
		self.top_widget = Qt.QWidget()
		self.top_scroll.setWidget(self.top_widget)
		self.top_layout = Qt.QVBoxLayout(self.top_widget)
		self.top_grid_layout = Qt.QGridLayout()
		self.top_layout.addLayout(self.top_grid_layout)


		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 2e6
		self.in_rate = in_rate = samp_rate
		self.audio_rate = audio_rate = 44.1e3
		self.volume = volume = 0.2
		self.resamp_rate = resamp_rate = audio_rate/in_rate
		self.nfilts = nfilts = 32
		self.fm_deviation_hz = fm_deviation_hz = 75e3

		##################################################
		# Blocks
		##################################################
		self.rtlsdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + "" )
		self.rtlsdr_source_c_0.set_sample_rate(samp_rate)
		self.rtlsdr_source_c_0.set_center_freq(91.9e6, 0)
		self.rtlsdr_source_c_0.set_freq_corr(0, 0)
		self.rtlsdr_source_c_0.set_dc_offset_mode(0, 0)
		self.rtlsdr_source_c_0.set_iq_balance_mode(0, 0)
		self.rtlsdr_source_c_0.set_gain_mode(0, 0)
		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.qtgui_sink_x_2 = qtgui.sink_f(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			True, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self.qtgui_sink_x_2.set_update_time(1.0 / 10)
		self._qtgui_sink_x_2_win = sip.wrapinstance(self.qtgui_sink_x_2.pyqwidget(), Qt.QWidget)
		self.top_layout.addWidget(self._qtgui_sink_x_2_win)
		self.qtgui_sink_x_1 = qtgui.sink_f(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			True, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self.qtgui_sink_x_1.set_update_time(1.0 / 10)
		self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget)
		self.top_layout.addWidget(self._qtgui_sink_x_1_win)
		self.qtgui_sink_x_0 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			91.9e6, #fc
			samp_rate/2, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			True, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self.qtgui_sink_x_0.set_update_time(1.0 / 10)
		self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
		self.top_layout.addWidget(self._qtgui_sink_x_0_win)
		self.pfb_arb_resampler_xxx_0 = filter.pfb.arb_resampler_fff(
			  resamp_rate,
		          taps=(firdes.low_pass_2(volume*nfilts, nfilts*in_rate, 15e3, 1e3, 60, firdes.WIN_KAISER)),
			  flt_size=nfilts)
			
		self.audio_sink_0 = audio.sink(int(audio_rate), "pulse", True)
		self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(in_rate/(2*math.pi*fm_deviation_hz/8.0))

		##################################################
		# Connections
		##################################################
		self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.audio_sink_0, 0))
		self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.qtgui_sink_x_2, 0))
		self.connect((self.rtlsdr_source_c_0, 0), (self.qtgui_sink_x_0, 0))
		self.connect((self.rtlsdr_source_c_0, 0), (self.analog_quadrature_demod_cf_0, 0))
		self.connect((self.analog_quadrature_demod_cf_0, 0), (self.qtgui_sink_x_1, 0))
		self.connect((self.analog_quadrature_demod_cf_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
コード例 #14
0
ファイル: usrp2_display.py プロジェクト: pgoeser/gnuradio
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-e",
                          "--interface",
                          type="string",
                          default="eth0",
                          help="select Ethernet interface, default is eth0")
        parser.add_option(
            "-m",
            "--mac-addr",
            type="string",
            default="",
            help="select USRP by MAC address, default is auto-select")
        parser.add_option("-W",
                          "--bw",
                          type="eng_float",
                          default=1e6,
                          help="set bandwidth of receiver [default=%default]")
        parser.add_option("-f",
                          "--freq",
                          type="eng_float",
                          default=2412e6,
                          help="set frequency to FREQ",
                          metavar="FREQ")
        parser.add_option("-g",
                          "--gain",
                          type="eng_float",
                          default=None,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("--fft-size",
                          type="int",
                          default=2048,
                          help="Set number of FFT bins [default=%default]")
        (options, args) = parser.parse_args()

        if len(args) != 0:
            parser.print_help()
            sys.exit(1)
        self.options = options
        self.show_debug_info = True

        self.qapp = QtGui.QApplication(sys.argv)

        self.u = usrp2.source_32fc(options.interface, options.mac_addr)
        self._adc_rate = self.u.adc_rate()
        self.set_bandwidth(options.bw)

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.gain_range()
            options.gain = float(g[0] + g[1]) / 2
        self.set_gain(options.gain)

        if options.freq is None:
            # if no frequency was specified, use the mid-point of the subdev
            f = self.u.freq_range()
            options.freq = float(f[0] + f[1]) / 2
        self.set_frequency(options.freq)

        self._fftsize = options.fft_size

        self.snk = qtgui.sink_c(options.fft_size,
                                gr.firdes.WIN_BLACKMAN_hARRIS, self._freq,
                                self._bandwidth, "USRP2 Display", True, True,
                                True, False)

        # Set up internal amplifier
        self.amp = gr.multiply_const_cc(0.0)
        self.set_amplifier_gain(100)

        # Create a single-pole IIR filter to remove DC
        #   but don't connect it yet
        self.dc_gain = 0.001
        self.dc = gr.single_pole_iir_filter_cc(self.dc_gain)
        self.dc_sub = gr.sub_cc()

        self.connect(self.u, self.amp, self.snk)

        if self.show_debug_info:
            print "Decimation rate: ", self._decim
            print "Bandwidth: ", self._bandwidth
            print "D'board: ", self.u.daughterboard_id()

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        # Wrap the pointer as a PyQt SIP object
        #     This can now be manipulated as a PyQt4.QtGui.QWidget
        self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)

        self.main_win = main_window(self.pysink, self)

        self.main_win.set_frequency(self._freq)
        self.main_win.set_gain(self._gain)
        self.main_win.set_bandwidth(self._bandwidth)
        self.main_win.set_amplifier(self._amp_value)

        self.main_win.show()
コード例 #15
0
    def __init__(self, options):
        gr.top_block.__init__(self)

        self.options = options
        self.show_debug_info = True

        self.qapp = QtGui.QApplication(sys.argv)

        self.u = uhd.usrp_source(device_addr=options.address,
                                 stream_args=uhd.stream_args('fc32'))
        self.set_bandwidth(options.samp_rate)

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.get_gain_range()
            options.gain = float(g.start() + g.stop()) / 2
        self.set_gain(options.gain)

        if options.freq is None:
            # if no freq was specified, use the mid-point
            r = self.u.get_freq_range()
            options.freq = float(r.start() + r.stop()) / 2
        self.set_frequency(options.freq)

        if (options.antenna):
            self.u.set_antenna(options.antenna, 0)

        self._fftsize = options.fft_size

        self.snk = qtgui.sink_c(options.fft_size,
                                gr.firdes.WIN_BLACKMAN_hARRIS, self._freq,
                                self._bandwidth, "UHD Display", True, True,
                                True, False)

        # Set up internal amplifier
        self.amp = gr.multiply_const_cc(0.0)
        self.set_amplifier_gain(100)

        # Create a single-pole IIR filter to remove DC
        #   but don't connect it yet
        self.dc_gain = 0.001
        self.dc = gr.single_pole_iir_filter_cc(self.dc_gain)
        self.dc_sub = gr.sub_cc()

        self.connect(self.u, self.amp, self.snk)

        if self.show_debug_info:
            print "Bandwidth: ", self.u.get_samp_rate()
            print "Center Freq: ", self.u.get_center_freq()
            print "Freq Range: ", self.u.get_freq_range()

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        # Wrap the pointer as a PyQt SIP object
        #     This can now be manipulated as a PyQt4.QtGui.QWidget
        self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)

        self.main_win = main_window(self.pysink, self)

        self.main_win.set_frequency(self._freq)
        self.main_win.set_gain(self._gain)
        self.main_win.set_bandwidth(self._bandwidth)
        self.main_win.set_amplifier(self._amp_value)

        self.main_win.show()
コード例 #16
0
ファイル: top_block.py プロジェクト: Oxtay/GNURadio
	def __init__(self):
		gr.top_block.__init__(self, "Top Block")
		Qt.QWidget.__init__(self)
		self.setWindowTitle("Top Block")
		self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
		self.top_scroll_layout = Qt.QVBoxLayout()
		self.setLayout(self.top_scroll_layout)
		self.top_scroll = Qt.QScrollArea()
		self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
		self.top_scroll_layout.addWidget(self.top_scroll)
		self.top_scroll.setWidgetResizable(True)
		self.top_widget = Qt.QWidget()
		self.top_scroll.setWidget(self.top_widget)
		self.top_layout = Qt.QVBoxLayout(self.top_widget)
		self.top_grid_layout = Qt.QGridLayout()
		self.top_layout.addLayout(self.top_grid_layout)


		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 32000

		##################################################
		# Blocks
		##################################################
		self.random_source_x_0 = gr.vector_source_s(map(int, numpy.random.randint(0, 2, 1000)), True)
		self.qtgui_sink_x_0 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			True, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self.qtgui_sink_x_0.set_update_time(1.0 / 10)
		self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
		self.top_layout.addWidget(self._qtgui_sink_x_0_win)
		self.digital_ofdm_mod_0 = grc_blks2.packet_mod_f(digital.ofdm_mod(
				options=grc_blks2.options(
					modulation="qpsk",
					fft_length=512,
					occupied_tones=300,
					cp_length=128,
					pad_for_usrp=True,
					log=None,
					verbose=None,
				),
			),
			payload_length=0,
		)
		self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate)
		self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)

		##################################################
		# Connections
		##################################################
		self.connect((self.random_source_x_0, 0), (self.blocks_short_to_float_0, 0))
		self.connect((self.blocks_short_to_float_0, 0), (self.digital_ofdm_mod_0, 0))
		self.connect((self.digital_ofdm_mod_0, 0), (self.blocks_throttle_0, 0))
		self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_0, 0))
コード例 #17
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        ##################################################
        # Variables
        ##################################################
        self.snr_db = snr_db = 3
        self.noiseAmplitude = noiseAmplitude = sqrt(1 / (10**(0.1 * snr_db)))
        self.constellation = constellation = [-1.3416, -0.4472, 0.4472, 1.3416]
        self.bits = bits = 2

        ##################################################
        # Blocks
        ##################################################
        self.random_source_x_0 = gr.vector_source_b(
            map(int, numpy.random.randint(0, 4, 10000)), True)
        self.qtgui_sink_x_0_0_1 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            400,  #bw
            "QT GUI Plot",  #name
            False,  #plotfreq
            False,  #plotwaterfall
            False,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_0_1.set_update_time(1.0 / 100)
        self._qtgui_sink_x_0_0_1_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_0_1_win)
        self.gr_tag_debug_0 = gr.tag_debug(gr.sizeof_float * 1, "")
        self.gr_noise_source_x_0 = gr.noise_source_f(gr.GR_GAUSSIAN,
                                                     noiseAmplitude, 0)
        self.gr_file_sink_1 = gr.file_sink(gr.sizeof_gr_complex * 1,
                                           "symbols.bin")
        self.gr_file_sink_1.set_unbuffered(False)
        self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char * 1, "output.bin")
        self.gr_file_sink_0_0.set_unbuffered(False)
        self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char * 1, "input.bin")
        self.gr_file_sink_0.set_unbuffered(False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            digital.constellation_calcdist([-3, -1, 1, 3], [], 1, 1).base())
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(
            (constellation), 1)
        self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, 100)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blks2_error_rate_0 = grc_blks2.error_rate(
            type='BER',
            win_size=10000,
            bits_per_symbol=bits,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.random_source_x_0, 0), (self.blks2_error_rate_0, 0))
        self.connect((self.random_source_x_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.gr_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blks2_error_rate_0, 1))
        self.connect((self.random_source_x_0, 0), (self.gr_file_sink_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.gr_file_sink_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.qtgui_sink_x_0_0_1, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.gr_file_sink_1, 0))
        self.connect((self.blks2_error_rate_0, 0), (self.gr_tag_debug_0, 0))
コード例 #18
0
ファイル: LTE_flowgraph.py プロジェクト: LucaBongiorni/gr-lte
	def __init__(self):
		gr.top_block.__init__(self, "LTE flowgraph")
		Qt.QWidget.__init__(self)
		self.setWindowTitle("LTE flowgraph")
		self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
		self.top_scroll_layout = Qt.QVBoxLayout()
		self.setLayout(self.top_scroll_layout)
		self.top_scroll = Qt.QScrollArea()
		self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
		self.top_scroll_layout.addWidget(self.top_scroll)
		self.top_scroll.setWidgetResizable(True)
		self.top_widget = Qt.QWidget()
		self.top_scroll.setWidget(self.top_widget)
		self.top_layout = Qt.QVBoxLayout(self.top_widget)
		self.top_grid_layout = Qt.QGridLayout()
		self.top_layout.addLayout(self.top_grid_layout)


		##################################################
		# Variables
		##################################################
		self.fftlen = fftlen = 512
		self.cpl0 = cpl0 = 160*fftlen/2048
		self.cpl = cpl = 144*fftlen/2048
		self.slotl = slotl = 7*fftlen+6*cpl+cpl0
		self.samp_rate = samp_rate = slotl/0.0005
		self.style = style = "tx_diversity"
		self.interp_val = interp_val = int(samp_rate/1e4)
		self.N_rb_dl = N_rb_dl = 6

		##################################################
		# Blocks
		##################################################
		self.eq = lte.linear_OFDM_equalizer_hier_vcvc(N_rb_dl)
		self.descr = lte.descrambling_vfvf()
		self.demux = lte.pbch_demux_vcvc(N_rb_dl)
		self.daemon = lte.cell_id_daemon(self.eq.eq, self.demux, self.descr)
		self.qtgui_sink_x_0 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			True, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
		self.top_layout.addWidget(self._qtgui_sink_x_0_win)
		self.lte_viterbi_vfvb_0 = lte.viterbi_vfvb()
		self.lte_remove_cp_cvc_1 = lte.remove_cp_cvc(fftlen)
		self.lte_rate_unmatch_vff_0 = lte.rate_unmatch_vff()
		self.lte_qpsk_soft_demod_vcvf_0 = lte.qpsk_soft_demod_vcvf()
		self.lte_pss_sync_hier_cc_0 = lte.pss_sync_hier_cc(fftlen)
		self.lte_pre_decoder_vcvc_0_0 = lte.pre_decoder_vcvc(2, style)
		self.lte_pre_decoder_vcvc_0 = lte.pre_decoder_vcvc(1, style)
		self.lte_mib_unpack_vb_0 = lte.mib_unpack_vb()
		self.lte_layer_demapper_vcvc_0_0 = lte.layer_demapper_vcvc(2, style)
		self.lte_layer_demapper_vcvc_0 = lte.layer_demapper_vcvc(1, style)
		self.lte_hier_sss_sync_cc_0 = lte.hier_sss_sync_cc(self.daemon, fftlen)
		self.lte_hier_freq_estimate_cc_0 = lte.hier_freq_estimate_cc(fftlen)
		self.lte_extract_occupied_tones_vcvc_0 = lte.extract_occupied_tones_vcvc(N_rb_dl,fftlen)
		self.lte_crc_calculator_vbvb_0 = lte.crc_calculator_vbvb()
		self.lte_cp_time_freq_sync_cc_0 = lte.cp_time_freq_sync_cc(fftlen)
		self.gr_vector_to_stream_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, 240)
		self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate)
		self.gr_interleave_0 = gr.interleave(gr.sizeof_gr_complex*240)
		self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/home/demel/Dokumente/Messungen_31_10_2012/samples_12.5MSps_20dB.iq", False)
		self.fft_vxx_0 = fft.fft_vcc(fftlen, True, (window.rectangular(fftlen)), False, 1)
		self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc(
			interpolation=interp_val,
			decimation=1250,
			taps=None,
			fractional_bw=None,
		)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_file_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
		self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.lte_hier_freq_estimate_cc_0, 0), (self.lte_hier_sss_sync_cc_0, 0))
		self.connect((self.lte_pss_sync_hier_cc_0, 0), (self.lte_hier_freq_estimate_cc_0, 0))
		self.connect((self.lte_cp_time_freq_sync_cc_0, 0), (self.lte_pss_sync_hier_cc_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.lte_cp_time_freq_sync_cc_0, 0))
		self.connect((self.lte_hier_sss_sync_cc_0, 0), (self.lte_remove_cp_cvc_1, 0))
		self.connect((self.fft_vxx_0, 0), (self.lte_extract_occupied_tones_vcvc_0, 0))
		self.connect((self.lte_remove_cp_cvc_1, 0), (self.fft_vxx_0, 0))
		self.connect((self.lte_extract_occupied_tones_vcvc_0, 0), (self.eq, 0))
		self.connect((self.lte_pre_decoder_vcvc_0, 0), (self.lte_layer_demapper_vcvc_0, 0))
		self.connect((self.eq, 0), (self.demux, 0))
		self.connect((self.eq, 1), (self.demux, 1))
		self.connect((self.eq, 2), (self.demux, 2))
		self.connect((self.lte_pre_decoder_vcvc_0_0, 0), (self.lte_layer_demapper_vcvc_0_0, 0))
		self.connect((self.lte_layer_demapper_vcvc_0_0, 0), (self.gr_interleave_0, 1))
		self.connect((self.demux, 1), (self.lte_pre_decoder_vcvc_0_0, 1))
		self.connect((self.demux, 1), (self.lte_pre_decoder_vcvc_0, 1))
		self.connect((self.demux, 0), (self.lte_pre_decoder_vcvc_0, 0))
		self.connect((self.demux, 2), (self.lte_pre_decoder_vcvc_0_0, 2))
		self.connect((self.demux, 0), (self.lte_pre_decoder_vcvc_0_0, 0))
		self.connect((self.lte_qpsk_soft_demod_vcvf_0, 0), (self.descr, 0))
		self.connect((self.gr_interleave_0, 0), (self.lte_qpsk_soft_demod_vcvf_0, 0))
		self.connect((self.lte_layer_demapper_vcvc_0, 0), (self.gr_interleave_0, 0))
		self.connect((self.descr, 0), (self.lte_rate_unmatch_vff_0, 0))
		self.connect((self.lte_crc_calculator_vbvb_0, 1), (self.lte_mib_unpack_vb_0, 1))
		self.connect((self.lte_crc_calculator_vbvb_0, 0), (self.lte_mib_unpack_vb_0, 0))
		self.connect((self.lte_viterbi_vfvb_0, 0), (self.lte_crc_calculator_vbvb_0, 0))
		self.connect((self.lte_rate_unmatch_vff_0, 0), (self.lte_viterbi_vfvb_0, 0))
		self.connect((self.gr_interleave_0, 0), (self.gr_vector_to_stream_0, 0))
		self.connect((self.gr_vector_to_stream_0, 0), (self.qtgui_sink_x_0, 0))
コード例 #19
0
ファイル: FMRadio.py プロジェクト: RegWd/gr-fcdproplus
	def __init__(self):
		gr.top_block.__init__(self, "FM radio to test FCDPROplus")
		Qt.QWidget.__init__(self)
		self.setWindowTitle("FM radio to test FCDPROplus")
		self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
		self.top_scroll_layout = Qt.QVBoxLayout()
		self.setLayout(self.top_scroll_layout)
		self.top_scroll = Qt.QScrollArea()
		self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
		self.top_scroll_layout.addWidget(self.top_scroll)
		self.top_scroll.setWidgetResizable(True)
		self.top_widget = Qt.QWidget()
		self.top_scroll.setWidget(self.top_widget)
		self.top_layout = Qt.QVBoxLayout(self.top_widget)
		self.top_grid_layout = Qt.QGridLayout()
		self.top_layout.addLayout(self.top_grid_layout)


		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 192000
		self.Volume = Volume = 1
		self.RxFrequency = RxFrequency = 94300
		self.PPM = PPM = 0
		self.Mixergain = Mixergain = 1
		self.Lna = Lna = 1
		self.Ifgain = Ifgain = 0

		##################################################
		# Blocks
		##################################################
		self._Volume_layout = Qt.QHBoxLayout()
		self._Volume_layout.addWidget(Qt.QLabel("Volume"+": "))
		self._Volume_counter = Qwt.QwtCounter()
		self._Volume_counter.setRange(1, 50, 1)
		self._Volume_counter.setNumButtons(2)
		self._Volume_counter.setMinimumWidth(45)
		self._Volume_counter.setValue(self.Volume)
		self._Volume_layout.addWidget(self._Volume_counter)
		self._Volume_counter.valueChanged.connect(self.set_Volume)
		self.top_grid_layout.addLayout(self._Volume_layout, 0,5,1,1)
		self._RxFrequency_layout = Qt.QHBoxLayout()
		self._RxFrequency_layout.addWidget(Qt.QLabel("Set Frequency "+": "))
		self._RxFrequency_counter = Qwt.QwtCounter()
		self._RxFrequency_counter.setRange(3000, 100000, 1)
		self._RxFrequency_counter.setNumButtons(2)
		self._RxFrequency_counter.setMinimumWidth(200)
		self._RxFrequency_counter.setValue(self.RxFrequency)
		self._RxFrequency_layout.addWidget(self._RxFrequency_counter)
		self._RxFrequency_counter.valueChanged.connect(self.set_RxFrequency)
		self.top_grid_layout.addLayout(self._RxFrequency_layout, 0,0,1,1)
		self._PPM_layout = Qt.QHBoxLayout()
		self._PPM_layout.addWidget(Qt.QLabel("set PPM"+": "))
		self._PPM_counter = Qwt.QwtCounter()
		self._PPM_counter.setRange(-100, 100, 1)
		self._PPM_counter.setNumButtons(2)
		self._PPM_counter.setMinimumWidth(40)
		self._PPM_counter.setValue(self.PPM)
		self._PPM_layout.addWidget(self._PPM_counter)
		self._PPM_counter.valueChanged.connect(self.set_PPM)
		self.top_grid_layout.addLayout(self._PPM_layout, 0,6,1,1)
		self._Mixergain_options = (0, 1, )
		self._Mixergain_labels = ("Off", "On", )
		self._Mixergain_tool_bar = Qt.QToolBar(self)
		self._Mixergain_tool_bar.addWidget(Qt.QLabel("Mixergain"+": "))
		self._Mixergain_combo_box = Qt.QComboBox()
		self._Mixergain_tool_bar.addWidget(self._Mixergain_combo_box)
		for label in self._Mixergain_labels: self._Mixergain_combo_box.addItem(label)
		self._Mixergain_callback = lambda i: self._Mixergain_combo_box.setCurrentIndex(self._Mixergain_options.index(i))
		self._Mixergain_callback(self.Mixergain)
		self._Mixergain_combo_box.currentIndexChanged.connect(
			lambda i: self.set_Mixergain(self._Mixergain_options[i]))
		self.top_grid_layout.addWidget(self._Mixergain_tool_bar, 0,2,1,1)
		self._Lna_options = (0, 1, )
		self._Lna_labels = ("Off", "On", )
		self._Lna_tool_bar = Qt.QToolBar(self)
		self._Lna_tool_bar.addWidget(Qt.QLabel("Lna"+": "))
		self._Lna_combo_box = Qt.QComboBox()
		self._Lna_tool_bar.addWidget(self._Lna_combo_box)
		for label in self._Lna_labels: self._Lna_combo_box.addItem(label)
		self._Lna_callback = lambda i: self._Lna_combo_box.setCurrentIndex(self._Lna_options.index(i))
		self._Lna_callback(self.Lna)
		self._Lna_combo_box.currentIndexChanged.connect(
			lambda i: self.set_Lna(self._Lna_options[i]))
		self.top_grid_layout.addWidget(self._Lna_tool_bar, 0,1,1,1)
		self._Ifgain_layout = Qt.QHBoxLayout()
		self._Ifgain_layout.addWidget(Qt.QLabel("Ifgain"+": "))
		self._Ifgain_counter = Qwt.QwtCounter()
		self._Ifgain_counter.setRange(0, 59, 1)
		self._Ifgain_counter.setNumButtons(2)
		self._Ifgain_counter.setMinimumWidth(45)
		self._Ifgain_counter.setValue(self.Ifgain)
		self._Ifgain_layout.addWidget(self._Ifgain_counter)
		self._Ifgain_counter.valueChanged.connect(self.set_Ifgain)
		self.top_grid_layout.addLayout(self._Ifgain_layout, 0,3,1,1)
		self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
			1024, #size
			samp_rate/4, #bw
			"QT GUI Plot", #name
			1 #number of inputs
		)
		self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
		self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1,4,1,3)
		self.qtgui_sink_x_0 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			RxFrequency*1000, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			True, #plotwaterfall
			False, #plottime
			False, #plotconst
		)
		self.qtgui_sink_x_0.set_update_time(1.0 / 10)
		self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
		self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win, 1,0,1,4)
		self.low_pass_filter_1 = gr.fir_filter_fff(4, firdes.low_pass(
			1, samp_rate, 16000, 300, firdes.WIN_HAMMING, 6.76))
		self.low_pass_filter_0 = gr.fir_filter_ccf(1, firdes.low_pass(
			5, samp_rate, 40000, 300, firdes.WIN_HAMMING, 6.76))
		self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1)
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((Volume, ))
		self.fcdproplus_fcdproplus_0 = fcdproplus.fcdproplus("",1000)
		self.fcdproplus_fcdproplus_0.set_lna(Lna)
		self.fcdproplus_fcdproplus_0.set_mixer_gain(Mixergain)
		self.fcdproplus_fcdproplus_0.set_if_gain(int(Ifgain))
		self.fcdproplus_fcdproplus_0.set_freq_corr(int( PPM))
		self.fcdproplus_fcdproplus_0.set_freq(RxFrequency)
		  
		self.blks2_fm_deemph_0 = blks2.fm_deemph(fs=samp_rate, tau=25e-6)
		self.audio_sink_0 = audio.sink(48000, "default", True)

		##################################################
		# Connections
		##################################################
		self.connect((self.fcdproplus_fcdproplus_0, 0), (self.qtgui_sink_x_0, 0))
		self.connect((self.fcdproplus_fcdproplus_0, 0), (self.low_pass_filter_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink_0, 1))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0))
		self.connect((self.low_pass_filter_0, 0), (self.gr_quadrature_demod_cf_0, 0))
		self.connect((self.low_pass_filter_1, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_quadrature_demod_cf_0, 0), (self.blks2_fm_deemph_0, 0))
		self.connect((self.blks2_fm_deemph_0, 0), (self.low_pass_filter_1, 0))
コード例 #20
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.random_source_x_0 = gr.vector_source_s(
            map(int, numpy.random.randint(0, 2, 1000)), True)
        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)
        self.digital_ofdm_mod_0 = grc_blks2.packet_mod_f(
            digital.ofdm_mod(options=grc_blks2.options(
                modulation="qpsk",
                fft_length=512,
                occupied_tones=300,
                cp_length=128,
                pad_for_usrp=True,
                log=None,
                verbose=None,
            ), ),
            payload_length=0,
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.random_source_x_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.digital_ofdm_mod_0, 0))
        self.connect((self.digital_ofdm_mod_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_0, 0))
コード例 #21
0
ファイル: top_block.py プロジェクト: a4a881d4/gr-lte
	def __init__(self):
		gr.top_block.__init__(self, "Top Block")
		Qt.QWidget.__init__(self)
		self.setWindowTitle("Top Block")
		self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
		self.top_scroll_layout = Qt.QVBoxLayout()
		self.setLayout(self.top_scroll_layout)
		self.top_scroll = Qt.QScrollArea()
		self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
		self.top_scroll_layout.addWidget(self.top_scroll)
		self.top_scroll.setWidgetResizable(True)
		self.top_widget = Qt.QWidget()
		self.top_scroll.setWidget(self.top_widget)
		self.top_layout = Qt.QVBoxLayout(self.top_widget)
		self.top_grid_layout = Qt.QGridLayout()
		self.top_layout.addLayout(self.top_grid_layout)


		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 10e6
		self.gain = gain = 10
		self.fc = fc = 806e6

		##################################################
		# Blocks
		##################################################
		self._gain_layout = Qt.QVBoxLayout()
		self._gain_tool_bar = Qt.QToolBar(self)
		self._gain_layout.addWidget(self._gain_tool_bar)
		self._gain_tool_bar.addWidget(Qt.QLabel("gain"+": "))
		self._gain_counter = Qwt.QwtCounter()
		self._gain_counter.setRange(0, 31, 1)
		self._gain_counter.setNumButtons(2)
		self._gain_counter.setValue(self.gain)
		self._gain_tool_bar.addWidget(self._gain_counter)
		self._gain_counter.valueChanged.connect(self.set_gain)
		self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
		self._gain_slider.setRange(0, 31, 1)
		self._gain_slider.setValue(self.gain)
		self._gain_slider.setMinimumWidth(200)
		self._gain_slider.valueChanged.connect(self.set_gain)
		self._gain_layout.addWidget(self._gain_slider)
		self.top_layout.addLayout(self._gain_layout)
		self._fc_layout = Qt.QVBoxLayout()
		self._fc_tool_bar = Qt.QToolBar(self)
		self._fc_layout.addWidget(self._fc_tool_bar)
		self._fc_tool_bar.addWidget(Qt.QLabel("fc"+": "))
		self._fc_counter = Qwt.QwtCounter()
		self._fc_counter.setRange(805e6, 807e6, 1)
		self._fc_counter.setNumButtons(2)
		self._fc_counter.setValue(self.fc)
		self._fc_tool_bar.addWidget(self._fc_counter)
		self._fc_counter.valueChanged.connect(self.set_fc)
		self._fc_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
		self._fc_slider.setRange(805e6, 807e6, 1)
		self._fc_slider.setValue(self.fc)
		self._fc_slider.setMinimumWidth(200)
		self._fc_slider.valueChanged.connect(self.set_fc)
		self._fc_layout.addWidget(self._fc_slider)
		self.top_layout.addLayout(self._fc_layout)
		self.uhd_usrp_source_0 = uhd.usrp_source(
			device_addr="ip=192.168.10.6",
			stream_args=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(fc, 0)
		self.uhd_usrp_source_0.set_gain(gain, 0)
		self.uhd_usrp_source_0.set_antenna("RX2", 0)
		self.qtgui_sink_x_0 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			False, #plotwaterfall
			False, #plottime
			True, #plotconst
		)
		self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
		self.top_layout.addWidget(self._qtgui_sink_x_0_win)
		self.gr_file_sink_0 = gr.file_sink(gr.sizeof_gr_complex*1, "/home/demel/gr-lte/data/Measure_LTE_GAIN"+str(gain)+"_DATE"+str(datetime.datetime.now())+".dat")
		self.gr_file_sink_0.set_unbuffered(False)

		##################################################
		# Connections
		##################################################
		self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_sink_x_0, 0))
		self.connect((self.uhd_usrp_source_0, 0), (self.gr_file_sink_0, 0))
コード例 #22
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 = True
        
        fftsize = 2048

        self.data = scipy.random.randint(0, 255, 1000)
        self.src = gr.vector_source_b(self.data.tolist(), True)
        self.mod = blks2.dqpsk_mod(self.sps, self.excess_bw, self.gray_code, False, 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.alpha = 0.15
        self.beta  = 0.25 * self.alpha * self.alpha
        self.fmin = -1000/self.sample_rate()
        self.fmax = 1000/self.sample_rate()
        
        self.receiver = gr.mpsk_receiver_cc(self.arity, 0,
                                            self.alpha, self.beta,
                                            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, False, True, True)

        self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                   0, self._sample_rate,
                                   "Rx", True, True, False, 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()
コード例 #23
0
ファイル: benchmark_qt_rx.py プロジェクト: GREO/GNU-Radio
    def __init__(self, demodulator, rx_callback, options):
        gr.top_block.__init__(self)

        self._rx_freq            = options.rx_freq         # receiver's center frequency
        self._rx_gain            = options.rx_gain         # receiver's gain
        self._rx_subdev_spec     = options.rx_subdev_spec  # daughterboard to use
        self._decim              = options.decim           # Decimating rate for the USRP (prelim)
        self._bitrate            = options.bitrate
        self._samples_per_symbol = options.samples_per_symbol
        self._demod_class        = demodulator
        self.gui_on              = options.gui
               
        if self._rx_freq is None:
            sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit

        # Set up USRP source
        self._setup_usrp_source(options)

        # copy the final answers back into options for use by demodulator
        options.samples_per_symbol = self._samples_per_symbol
        options.bitrate = self._bitrate
        options.decim = self._decim

        ok = self.set_freq(self._rx_freq)
        if not ok:
            print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(self._rx_freq))
            raise ValueError, eng_notation.num_to_str(self._rx_freq)

        self.set_gain(options.rx_gain)

        # Set up receive path
        self.rxpath = receive_path(demodulator, rx_callback, options) 

        # FIXME: do better exposure to lower issues for control
        self._gain_mu = self.rxpath.packet_receiver._demodulator._mm_gain_mu
        self._alpha = self.rxpath.packet_receiver._demodulator._costas_alpha

        self.connect(self.u, self.rxpath)

        if self.gui_on:
            self.qapp = QtGui.QApplication(sys.argv)
            fftsize = 2048

            bw_in = self.u.adc_rate() / self.decim()
            self.snk_rxin = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                         self._rx_freq, bw_in,
                                         "Received", True, True, False, True, True, False)
            self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                       0, self._bitrate,
                                       "Post-Synchronizer", True, True, False, True, True, False)

            self.snk_rxin.set_frequency_axis(-60, 60)
            self.snk_rx.set_frequency_axis(-60, 20)
            self.snk_rxin.set_time_domain_axis(-2000,2000)
            
            # Connect to the QT sinks
            # FIXME: make better exposure to receiver from rxpath
            self.receiver = self.rxpath.packet_receiver._demodulator.receiver
            self.connect(self.u, self.snk_rxin)
            self.connect(self.receiver, self.snk_rx)
            
            pyRxInQt  = self.snk_rxin.pyqwidget()
            pyRxIn = sip.wrapinstance(pyRxInQt, QtGui.QWidget)
            
            pyRxQt  = self.snk_rx.pyqwidget()
            pyRx = sip.wrapinstance(pyRxQt, QtGui.QWidget)
            
            self.main_box = dialog_box(pyRxIn, pyRx, self)
            self.main_box.show()
コード例 #24
0
    def __init__(self):
        gr.top_block.__init__(self, "Simple QAM Simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Simple QAM Simulation")
        self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        ##################################################
        # Variables
        ##################################################
        self.constellation_cardinality = constellation_cardinality = 16
        self.const_object = const_object = constellations()['qam'](
            constellation_cardinality)
        self.snr_db = snr_db = 20
        self.constellation = constellation = const_object.points()
        self.sps = sps = 8
        self.samp_rate = samp_rate = 250000
        self.noise_amp = noise_amp = sqrt((10**(-snr_db / 10.)) / 2.)
        self.constellation_power = constellation_power = sqrt(
            sum([abs(i)**2
                 for i in constellation]) / constellation_cardinality)

        ##################################################
        # Blocks
        ##################################################
        self.tabid_0 = Qt.QTabWidget()
        self.tabid_0_widget_0 = Qt.QWidget()
        self.tabid_0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_0_widget_0)
        self.tabid_0_grid_layout_0 = Qt.QGridLayout()
        self.tabid_0_layout_0.addLayout(self.tabid_0_grid_layout_0)
        self.tabid_0.addTab(self.tabid_0_widget_0, "TX")
        self.tabid_0_widget_1 = Qt.QWidget()
        self.tabid_0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_0_widget_1)
        self.tabid_0_grid_layout_1 = Qt.QGridLayout()
        self.tabid_0_layout_1.addLayout(self.tabid_0_grid_layout_1)
        self.tabid_0.addTab(self.tabid_0_widget_1, "CHANNEL")
        self.tabid_0_widget_2 = Qt.QWidget()
        self.tabid_0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_0_widget_2)
        self.tabid_0_grid_layout_2 = Qt.QGridLayout()
        self.tabid_0_layout_2.addLayout(self.tabid_0_grid_layout_2)
        self.tabid_0.addTab(self.tabid_0_widget_2, "RX")
        self.top_grid_layout.addWidget(self.tabid_0, 30, 0, 10, 100)
        self.tabid_2 = Qt.QTabWidget()
        self.tabid_2_widget_0 = Qt.QWidget()
        self.tabid_2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_2_widget_0)
        self.tabid_2_grid_layout_0 = Qt.QGridLayout()
        self.tabid_2_layout_0.addLayout(self.tabid_2_grid_layout_0)
        self.tabid_2.addTab(self.tabid_2_widget_0, "symbol-based")
        self.tabid_2_widget_1 = Qt.QWidget()
        self.tabid_2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_2_widget_1)
        self.tabid_2_grid_layout_1 = Qt.QGridLayout()
        self.tabid_2_layout_1.addLayout(self.tabid_2_grid_layout_1)
        self.tabid_2.addTab(self.tabid_2_widget_1, "bit-based")
        self.tabid_2_widget_2 = Qt.QWidget()
        self.tabid_2_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_2_widget_2)
        self.tabid_2_grid_layout_2 = Qt.QGridLayout()
        self.tabid_2_layout_2.addLayout(self.tabid_2_grid_layout_2)
        self.tabid_2.addTab(self.tabid_2_widget_2, "BER")
        self.tabid_0_layout_2.addWidget(self.tabid_2)
        self.tabid_1 = Qt.QTabWidget()
        self.tabid_1_widget_0 = Qt.QWidget()
        self.tabid_1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_1_widget_0)
        self.tabid_1_grid_layout_0 = Qt.QGridLayout()
        self.tabid_1_layout_0.addLayout(self.tabid_1_grid_layout_0)
        self.tabid_1.addTab(self.tabid_1_widget_0, "bit-based")
        self.tabid_1_widget_1 = Qt.QWidget()
        self.tabid_1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_1_widget_1)
        self.tabid_1_grid_layout_1 = Qt.QGridLayout()
        self.tabid_1_layout_1.addLayout(self.tabid_1_grid_layout_1)
        self.tabid_1.addTab(self.tabid_1_widget_1, "scrambled")
        self.tabid_1_widget_2 = Qt.QWidget()
        self.tabid_1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_1_widget_2)
        self.tabid_1_grid_layout_2 = Qt.QGridLayout()
        self.tabid_1_layout_2.addLayout(self.tabid_1_grid_layout_2)
        self.tabid_1.addTab(self.tabid_1_widget_2, "symbol-based")
        self.tabid_0_grid_layout_0.addWidget(self.tabid_1, 0, 0, 10, 10)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #bw
            "QT GUI Plot",  #name
            1  #number of inputs
        )
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tabid_2_layout_2.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_sink_x_0_1_0_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            False,  #plotfreq
            False,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self._qtgui_sink_x_0_1_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget)
        self.tabid_1_layout_0.addWidget(self._qtgui_sink_x_0_1_0_0_win)
        self.qtgui_sink_x_0_1_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            True,  #plotfreq
            False,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self._qtgui_sink_x_0_1_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
        self.tabid_1_layout_1.addWidget(self._qtgui_sink_x_0_1_0_win)
        self.qtgui_sink_x_0_1 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            False,  #plotfreq
            False,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self._qtgui_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.tabid_1_layout_2.addWidget(self._qtgui_sink_x_0_1_win)
        self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            True,  #plotfreq
            False,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.tabid_2_layout_0.addWidget(self._qtgui_sink_x_0_0_0_0_win)
        self.qtgui_sink_x_0_0_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            False,  #plotfreq
            False,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self._qtgui_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.tabid_2_layout_1.addWidget(self._qtgui_sink_x_0_0_0_win)
        self.qtgui_sink_x_0_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            True,  #plotfreq
            False,  #plotwaterfall
            True,  #plottime
            False,  #plotconst
        )
        self._qtgui_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tabid_0_layout_1.addWidget(self._qtgui_sink_x_0_0_win)
        self.gr_vector_source_x_0_0 = gr.vector_source_b(([1, 0]), True, 1)
        self.gr_vector_source_x_0 = gr.vector_source_b(([1, 0]), True, 1)
        self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(
            int(log2(constellation_cardinality)))
        self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate)
        self.gr_pack_k_bits_bb_0 = gr.pack_k_bits_bb(
            int(log2(constellation_cardinality)))
        self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char * 1)
        self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_amp,
                                                     0)
        self.gr_nlog10_ff_0 = gr.nlog10_ff(1, 1, 0)
        self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vcc(
            (1. / constellation_power, ))
        self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc(
            (constellation_power, ))
        self.gr_file_sink_0_1_0 = gr.file_sink(gr.sizeof_gr_complex * 1,
                                               "rx_sym.32fc")
        self.gr_file_sink_0_1_0.set_unbuffered(False)
        self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_gr_complex * 1,
                                             "tx_sym.32fc")
        self.gr_file_sink_0_1.set_unbuffered(False)
        self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char * 1, "rx.8b")
        self.gr_file_sink_0_0.set_unbuffered(False)
        self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char * 1, "tx.8b")
        self.gr_file_sink_0.set_unbuffered(False)
        self.gr_descrambler_bb_0 = gr.descrambler_bb(0xe4001, 0x7ffff, 19)
        self.gr_char_to_float_1_0 = gr.char_to_float(1, 1)
        self.gr_char_to_float_1 = gr.char_to_float(1, 1)
        self.gr_char_to_float_0 = gr.char_to_float(1, 1)
        self.gr_add_xx_0 = gr.add_vcc(1)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(
            0xe4001, 0x7fffF, 19)
        self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(
            const_object.base(), 6.28 / 100, -0.25, +0.25)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (constellation), 1)
        self.blks2_error_rate_0 = grc_blks2.error_rate(
            type='BER',
            win_size=samp_rate,
            bits_per_symbol=1,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_vector_source_x_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.gr_pack_k_bits_bb_0, 0))
        self.connect((self.gr_pack_k_bits_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 0),
                     (self.gr_file_sink_0_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 0),
                     (self.gr_unpack_k_bits_bb_0, 0))
        self.connect((self.gr_unpack_k_bits_bb_0, 0),
                     (self.gr_descrambler_bb_0, 0))
        self.connect((self.gr_descrambler_bb_0, 0), (self.gr_null_sink_0, 0))
        self.connect((self.gr_multiply_const_vxx_0, 0),
                     (self.digital_constellation_receiver_cb_0, 0))
        self.connect((self.gr_descrambler_bb_0, 0),
                     (self.gr_char_to_float_0, 0))
        self.connect((self.gr_char_to_float_0, 0),
                     (self.qtgui_sink_x_0_0_0, 0))
        self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0))
        self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.gr_multiply_const_vxx_0_0, 0))
        self.connect((self.gr_multiply_const_vxx_0_0, 0),
                     (self.gr_file_sink_0_1, 0))
        self.connect((self.gr_multiply_const_vxx_0_0, 0),
                     (self.qtgui_sink_x_0_1, 0))
        self.connect((self.gr_char_to_float_1, 0),
                     (self.qtgui_sink_x_0_1_0, 0))
        self.connect((self.gr_pack_k_bits_bb_0, 0),
                     (self.gr_char_to_float_1, 0))
        self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_file_sink_0, 0))
        self.connect((self.gr_char_to_float_1_0, 0),
                     (self.qtgui_sink_x_0_1_0_0, 0))
        self.connect((self.gr_vector_source_x_0, 0),
                     (self.gr_char_to_float_1_0, 0))
        self.connect((self.gr_multiply_const_vxx_0_0, 0),
                     (self.gr_add_xx_0, 0))
        self.connect((self.gr_add_xx_0, 0), (self.qtgui_sink_x_0_0, 0))
        self.connect((self.gr_throttle_0, 0),
                     (self.gr_multiply_const_vxx_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.gr_file_sink_0_1_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.qtgui_sink_x_0_0_0_0, 0))
        self.connect((self.gr_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blks2_error_rate_0, 0), (self.gr_nlog10_ff_0, 0))
        self.connect((self.gr_vector_source_x_0_0, 0),
                     (self.blks2_error_rate_0, 0))
        self.connect((self.gr_descrambler_bb_0, 0),
                     (self.blks2_error_rate_0, 1))
コード例 #25
0
ファイル: simple_qam.py プロジェクト: Nishtha13/telclass
	def __init__(self):
		gr.top_block.__init__(self, "Simple QAM Simulation")
		Qt.QWidget.__init__(self)
		self.setWindowTitle("Simple QAM Simulation")
		self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
		self.top_scroll_layout = Qt.QVBoxLayout()
		self.setLayout(self.top_scroll_layout)
		self.top_scroll = Qt.QScrollArea()
		self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
		self.top_scroll_layout.addWidget(self.top_scroll)
		self.top_scroll.setWidgetResizable(True)
		self.top_widget = Qt.QWidget()
		self.top_scroll.setWidget(self.top_widget)
		self.top_layout = Qt.QVBoxLayout(self.top_widget)
		self.top_grid_layout = Qt.QGridLayout()
		self.top_layout.addLayout(self.top_grid_layout)


		##################################################
		# Variables
		##################################################
		self.constellation_cardinality = constellation_cardinality = 16
		self.const_object = const_object = constellations()['qam'](constellation_cardinality)
		self.snr_db = snr_db = 20
		self.constellation = constellation = const_object.points()
		self.sps = sps = 8
		self.samp_rate = samp_rate = 250000
		self.noise_amp = noise_amp = sqrt(  (10**(-snr_db/10.))  /2. )
		self.constellation_power = constellation_power = sqrt(sum([abs(i)**2 for i in constellation])/constellation_cardinality)

		##################################################
		# Blocks
		##################################################
		self.tabid_0 = Qt.QTabWidget()
		self.tabid_0_widget_0 = Qt.QWidget()
		self.tabid_0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_0)
		self.tabid_0_grid_layout_0 = Qt.QGridLayout()
		self.tabid_0_layout_0.addLayout(self.tabid_0_grid_layout_0)
		self.tabid_0.addTab(self.tabid_0_widget_0, "TX")
		self.tabid_0_widget_1 = Qt.QWidget()
		self.tabid_0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_1)
		self.tabid_0_grid_layout_1 = Qt.QGridLayout()
		self.tabid_0_layout_1.addLayout(self.tabid_0_grid_layout_1)
		self.tabid_0.addTab(self.tabid_0_widget_1, "CHANNEL")
		self.tabid_0_widget_2 = Qt.QWidget()
		self.tabid_0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_2)
		self.tabid_0_grid_layout_2 = Qt.QGridLayout()
		self.tabid_0_layout_2.addLayout(self.tabid_0_grid_layout_2)
		self.tabid_0.addTab(self.tabid_0_widget_2, "RX")
		self.top_grid_layout.addWidget(self.tabid_0, 30,0,10,100)
		self.tabid_2 = Qt.QTabWidget()
		self.tabid_2_widget_0 = Qt.QWidget()
		self.tabid_2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_0)
		self.tabid_2_grid_layout_0 = Qt.QGridLayout()
		self.tabid_2_layout_0.addLayout(self.tabid_2_grid_layout_0)
		self.tabid_2.addTab(self.tabid_2_widget_0, "symbol-based")
		self.tabid_2_widget_1 = Qt.QWidget()
		self.tabid_2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_1)
		self.tabid_2_grid_layout_1 = Qt.QGridLayout()
		self.tabid_2_layout_1.addLayout(self.tabid_2_grid_layout_1)
		self.tabid_2.addTab(self.tabid_2_widget_1, "bit-based")
		self.tabid_2_widget_2 = Qt.QWidget()
		self.tabid_2_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_2)
		self.tabid_2_grid_layout_2 = Qt.QGridLayout()
		self.tabid_2_layout_2.addLayout(self.tabid_2_grid_layout_2)
		self.tabid_2.addTab(self.tabid_2_widget_2, "BER")
		self.tabid_0_layout_2.addWidget(self.tabid_2)
		self.tabid_1 = Qt.QTabWidget()
		self.tabid_1_widget_0 = Qt.QWidget()
		self.tabid_1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_0)
		self.tabid_1_grid_layout_0 = Qt.QGridLayout()
		self.tabid_1_layout_0.addLayout(self.tabid_1_grid_layout_0)
		self.tabid_1.addTab(self.tabid_1_widget_0, "bit-based")
		self.tabid_1_widget_1 = Qt.QWidget()
		self.tabid_1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_1)
		self.tabid_1_grid_layout_1 = Qt.QGridLayout()
		self.tabid_1_layout_1.addLayout(self.tabid_1_grid_layout_1)
		self.tabid_1.addTab(self.tabid_1_widget_1, "scrambled")
		self.tabid_1_widget_2 = Qt.QWidget()
		self.tabid_1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_2)
		self.tabid_1_grid_layout_2 = Qt.QGridLayout()
		self.tabid_1_layout_2.addLayout(self.tabid_1_grid_layout_2)
		self.tabid_1.addTab(self.tabid_1_widget_2, "symbol-based")
		self.tabid_0_grid_layout_0.addWidget(self.tabid_1, 0,0,10,10)
		self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
			1024, #size
			samp_rate, #bw
			"QT GUI Plot", #name
			1 #number of inputs
		)
		self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
		self.tabid_2_layout_2.addWidget(self._qtgui_time_sink_x_0_win)
		self.qtgui_sink_x_0_1_0_0 = qtgui.sink_f(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			False, #plotfreq
			False, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self._qtgui_sink_x_0_1_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget)
		self.tabid_1_layout_0.addWidget(self._qtgui_sink_x_0_1_0_0_win)
		self.qtgui_sink_x_0_1_0 = qtgui.sink_f(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			False, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self._qtgui_sink_x_0_1_0_win = sip.wrapinstance(self.qtgui_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
		self.tabid_1_layout_1.addWidget(self._qtgui_sink_x_0_1_0_win)
		self.qtgui_sink_x_0_1 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			False, #plotfreq
			False, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self._qtgui_sink_x_0_1_win = sip.wrapinstance(self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget)
		self.tabid_1_layout_2.addWidget(self._qtgui_sink_x_0_1_win)
		self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			False, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
		self.tabid_2_layout_0.addWidget(self._qtgui_sink_x_0_0_0_0_win)
		self.qtgui_sink_x_0_0_0 = qtgui.sink_f(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			False, #plotfreq
			False, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self._qtgui_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
		self.tabid_2_layout_1.addWidget(self._qtgui_sink_x_0_0_0_win)
		self.qtgui_sink_x_0_0 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			False, #plotwaterfall
			True, #plottime
			False, #plotconst
		)
		self._qtgui_sink_x_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)
		self.tabid_0_layout_1.addWidget(self._qtgui_sink_x_0_0_win)
		self.gr_vector_source_x_0_0 = gr.vector_source_b(([1,0]), True, 1)
		self.gr_vector_source_x_0 = gr.vector_source_b(([1,0]), True, 1)
		self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(int(log2(constellation_cardinality)))
		self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate)
		self.gr_pack_k_bits_bb_0 = gr.pack_k_bits_bb(int(log2(constellation_cardinality)))
		self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char*1)
		self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_amp, 0)
		self.gr_nlog10_ff_0 = gr.nlog10_ff(1, 1, 0)
		self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vcc((1./constellation_power, ))
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((constellation_power, ))
		self.gr_file_sink_0_1_0 = gr.file_sink(gr.sizeof_gr_complex*1, "rx_sym.32fc")
		self.gr_file_sink_0_1_0.set_unbuffered(False)
		self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_gr_complex*1, "tx_sym.32fc")
		self.gr_file_sink_0_1.set_unbuffered(False)
		self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char*1, "rx.8b")
		self.gr_file_sink_0_0.set_unbuffered(False)
		self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char*1, "tx.8b")
		self.gr_file_sink_0.set_unbuffered(False)
		self.gr_descrambler_bb_0 = gr.descrambler_bb(0xe4001, 0x7ffff, 19)
		self.gr_char_to_float_1_0 = gr.char_to_float(1, 1)
		self.gr_char_to_float_1 = gr.char_to_float(1, 1)
		self.gr_char_to_float_0 = gr.char_to_float(1, 1)
		self.gr_add_xx_0 = gr.add_vcc(1)
		self.digital_scrambler_bb_0 = digital.scrambler_bb(0xe4001, 0x7fffF, 19)
		self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(const_object.base(), 6.28/100, -0.25, +0.25)
		self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((constellation), 1)
		self.blks2_error_rate_0 = grc_blks2.error_rate(
			type='BER',
			win_size=samp_rate,
			bits_per_symbol=1,
		)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_vector_source_x_0, 0), (self.digital_scrambler_bb_0, 0))
		self.connect((self.digital_scrambler_bb_0, 0), (self.gr_pack_k_bits_bb_0, 0))
		self.connect((self.gr_pack_k_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
		self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_file_sink_0_0, 0))
		self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_unpack_k_bits_bb_0, 0))
		self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_descrambler_bb_0, 0))
		self.connect((self.gr_descrambler_bb_0, 0), (self.gr_null_sink_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.digital_constellation_receiver_cb_0, 0))
		self.connect((self.gr_descrambler_bb_0, 0), (self.gr_char_to_float_0, 0))
		self.connect((self.gr_char_to_float_0, 0), (self.qtgui_sink_x_0_0_0, 0))
		self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1))
		self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.gr_multiply_const_vxx_0_0, 0))
		self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_file_sink_0_1, 0))
		self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.qtgui_sink_x_0_1, 0))
		self.connect((self.gr_char_to_float_1, 0), (self.qtgui_sink_x_0_1_0, 0))
		self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_char_to_float_1, 0))
		self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_file_sink_0, 0))
		self.connect((self.gr_char_to_float_1_0, 0), (self.qtgui_sink_x_0_1_0_0, 0))
		self.connect((self.gr_vector_source_x_0, 0), (self.gr_char_to_float_1_0, 0))
		self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_add_xx_0, 0))
		self.connect((self.gr_add_xx_0, 0), (self.qtgui_sink_x_0_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.gr_file_sink_0_1_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.qtgui_sink_x_0_0_0_0, 0))
		self.connect((self.gr_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0))
		self.connect((self.blks2_error_rate_0, 0), (self.gr_nlog10_ff_0, 0))
		self.connect((self.gr_vector_source_x_0_0, 0), (self.blks2_error_rate_0, 0))
		self.connect((self.gr_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1))
コード例 #26
0
    def __init__(self, mod_class, demod_class, rx_callback, options):
        gr.top_block.__init__(self)

        self._sample_rate = options.sample_rate

        channelon = True;

        self.gui_on = options.gui

        self._frequency_offset = options.frequency_offset
        self._timing_offset = options.timing_offset
        self._tx_amplitude = options.tx_amplitude
        self._snr_dB = options.snr

        self._noise_voltage = self.get_noise_voltage(self._snr_dB)

        self.txpath = transmit_path(mod_class, options)
        self.throttle = gr.throttle(gr.sizeof_gr_complex, self.sample_rate())
        self.rxpath = receive_path(demod_class, rx_callback, options)

        # FIXME: do better exposure to lower issues for control
        self._gain_mu = self.rxpath.packet_receiver._demodulator._mm_gain_mu
        self._alpha = self.rxpath.packet_receiver._demodulator._costas_alpha

        if channelon:
            self.channel = gr.channel_model(self._noise_voltage,
                                            self.frequency_offset(),
                                            self.timing_offset())
            
            if options.discontinuous:
                z = 20000*[0,]
                self.zeros = gr.vector_source_c(z, True)
                packet_size = 5*((4+8+4+1500+4) * 8)
                self.mux = gr.stream_mux(gr.sizeof_gr_complex, [packet_size-0, int(9e5)])

                # Connect components
                self.connect(self.txpath, self.throttle, (self.mux,0))
                self.connect(self.zeros, (self.mux,1))
                self.connect(self.mux, self.channel, self.rxpath)

            else:
                self.connect(self.txpath, self.throttle, self.channel, self.rxpath)

            if self.gui_on:
                self.qapp = QtGui.QApplication(sys.argv)
                fftsize = 2048

                self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                           0, 1,
                                           "Tx", True, True, False, True, True)
                self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                           0, 1,
                                           "Rx", True, True, False, True, True)

                self.snk_tx.set_frequency_axis(-80, 0)
                self.snk_rx.set_frequency_axis(-60, 20)
            
                # Connect to the QT sinks
                # FIXME: make better exposure to receiver from rxpath
                self.receiver = self.rxpath.packet_receiver._demodulator.receiver
                self.connect(self.channel, self.snk_tx)
                self.connect(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()
                
        else:
            # Connect components
            self.connect(self.txpath, self.throttle, self.rxpath)
コード例 #27
0
ファイル: usrp_display.py プロジェクト: GREO/gnuradio-git
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-w", "--which", type="int", default=0,
                          help="select which USRP (0, 1, ...) default is %default",
			  metavar="NUM")
        parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
                          help="select USRP Rx side A or B (default=first one with a daughterboard)")
        parser.add_option("-A", "--antenna", default=None,
                          help="select Rx Antenna (only on RFX-series boards)")
        parser.add_option("-W", "--bw", type="float", default=1e6,
                          help="set bandwidth of receiver [default=%default]")
        parser.add_option("-f", "--freq", type="eng_float", default=None,
                          help="set frequency to FREQ", metavar="FREQ")
        parser.add_option("-g", "--gain", type="eng_float", default=None,
                          help="set gain in dB [default is midpoint]")
        parser.add_option("-8", "--width-8", action="store_true", default=False,
                          help="Enable 8-bit samples across USB")
        parser.add_option( "--no-hb", action="store_true", default=False,
                          help="don't use halfband filter in usrp")
        parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
                          help="Enable oscilloscope display")
	parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1,
			  help="Set fftsink averaging factor, [default=%default]")
	parser.add_option("", "--ref-scale", type="eng_float", default=13490.0,
			  help="Set dBFS=0dB input value, [default=%default]")
        parser.add_option("", "--fft-size", type="int", default=2048,
                          help="Set FFT frame size, [default=%default]");

        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            sys.exit(1)
	self.options = options
        self.show_debug_info = True

        # Call this before creating the Qt sink
        self.qapp = QtGui.QApplication(sys.argv)

        self._fftsize = options.fft_size

        self.u = usrp.source_c(which=options.which)
        self._adc_rate = self.u.converter_rate()
        self.set_bandwidth(options.bw)

        if options.rx_subdev_spec is None:
            options.rx_subdev_spec = pick_subdevice(self.u)
        self._rx_subdev_spec = options.rx_subdev_spec
        self.u.set_mux(usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec))
        self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec)

        self._gain_range = self.subdev.gain_range()
        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self._gain_range
            options.gain = float(g[0]+g[1])/2
        self.set_gain(options.gain)

        if options.freq is None:
            # if no frequency was specified, use the mid-point of the subdev
            f = self.subdev.freq_range()
            options.freq = float(f[0]+f[1])/2
        self.set_frequency(options.freq)

        self.snk = qtgui.sink_c(self._fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                self._freq, self._bandwidth,
                                "USRP Display",
                                True, True, True, False)

        # Set up internal amplifier
        self.amp = gr.multiply_const_cc(0.0)
        self.set_amplifier_gain(0.001)

        # Connect the flow graph
        self.connect(self.u, self.amp, self.snk)


        # Get the reference pointer to the SpectrumDisplayForm QWidget
        # Wrap the pointer as a PyQt SIP object
        #     This can now be manipulated as a PyQt4.QtGui.QWidget
        self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)

        self.main_win = main_window(self.pysink, self)

        self.main_win.set_frequency(self._freq)
        self.main_win.set_gain(self._gain)
        self.main_win.set_bandwidth(self._bandwidth)
        self.main_win.set_amplifier(self._amp_value)

        self.main_win.show()
コード例 #28
0
    def __init__(self, mod_class, demod_class, rx_callback, options):
        gr.top_block.__init__(self)

        self._sample_rate = options.sample_rate

        channelon = True;

        self.gui_on = options.gui

        self._frequency_offset = options.frequency_offset
        self._timing_offset = options.timing_offset
        self._tx_amplitude = options.tx_amplitude
        self._snr_dB = options.snr

        self._noise_voltage = self.get_noise_voltage(self._snr_dB)

        # With new interface, sps does not get set by default, but
        # in the loopback, we don't recalculate it; so just force it here
        if(options.samples_per_symbol == None):
            options.samples_per_symbol = 2

        self.txpath = transmit_path(mod_class, options)
        self.throttle = gr.throttle(gr.sizeof_gr_complex, self.sample_rate())
        self.rxpath = receive_path(demod_class, rx_callback, options)

        # FIXME: do better exposure to lower issues for control
        self._gain_clock = self.rxpath.packet_receiver._demodulator._timing_alpha
        self._gain_phase = self.rxpath.packet_receiver._demodulator._phase_alpha
        self._gain_freq  = self.rxpath.packet_receiver._demodulator._freq_alpha

        if channelon:
            self.channel = gr.channel_model(self._noise_voltage,
                                            self.frequency_offset(),
                                            self.timing_offset())
            
            if options.discontinuous:
                z = 20000*[0,]
                self.zeros = gr.vector_source_c(z, True)
                packet_size = 5*((4+8+4+1500+4) * 8)
                self.mux = gr.stream_mux(gr.sizeof_gr_complex, [packet_size-0, int(9e5)])

                # Connect components
                self.connect(self.txpath, self.throttle, (self.mux,0))
                self.connect(self.zeros, (self.mux,1))
                self.connect(self.mux, self.channel, self.rxpath)

            else:
                self.connect(self.txpath, self.throttle, self.channel, self.rxpath)

            if self.gui_on:
                self.qapp = QtGui.QApplication(sys.argv)
                fftsize = 2048

                self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                           0, 1,
                                           "Tx", True, True, False, True, True)
                self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                           0, 1,
                                           "Rx", True, True, False, True, True)

                self.snk_tx.set_frequency_axis(-80, 0)
                self.snk_rx.set_frequency_axis(-60, 20)

                self.freq_recov = self.rxpath.packet_receiver._demodulator.freq_recov
                self.phase_recov = self.rxpath.packet_receiver._demodulator.phase_recov
                self.time_recov = self.rxpath.packet_receiver._demodulator.time_recov
                self.freq_recov.set_alpha(self._gain_freq)
                self.freq_recov.set_beta(self._gain_freq/10.0)
                self.phase_recov.set_alpha(self._gain_phase)
                self.phase_recov.set_beta(0.25*self._gain_phase*self._gain_phase)
                self.time_recov.set_alpha(self._gain_clock)
                self.time_recov.set_beta(0.25*self._gain_clock*self._gain_clock)

                # Connect to the QT sinks
                # FIXME: make better exposure to receiver from rxpath
                self.connect(self.channel, self.snk_tx)
                self.connect(self.phase_recov, self.snk_rx)
                #self.connect(self.freq_recov, 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()
                
        else:
            # Connect components
            self.connect(self.txpath, self.throttle, self.rxpath)
コード例 #29
0
ファイル: usrp2_display.py プロジェクト: GREO/gnuradio-git
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-e", "--interface", type="string", default="eth0",
                          help="select Ethernet interface, default is eth0")
        parser.add_option("-m", "--mac-addr", type="string", default="",
                          help="select USRP by MAC address, default is auto-select")
        parser.add_option("-W", "--bw", type="eng_float", default=1e6,
                          help="set bandwidth of receiver [default=%default]")
        parser.add_option("-f", "--freq", type="eng_float", default=2412e6,
                          help="set frequency to FREQ", metavar="FREQ")
        parser.add_option("-g", "--gain", type="eng_float", default=None,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("--fft-size", type="int", default=2048,
                          help="Set number of FFT bins [default=%default]")
        (options, args) = parser.parse_args()

        if len(args) != 0:
            parser.print_help()
            sys.exit(1)
	self.options = options
        self.show_debug_info = True
        
        self.qapp = QtGui.QApplication(sys.argv)

        self.u = usrp2.source_32fc(options.interface, options.mac_addr)
        self._adc_rate = self.u.adc_rate()
        self.set_bandwidth(options.bw)

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.gain_range()
            options.gain = float(g[0]+g[1])/2
        self.set_gain(options.gain)

        if options.freq is None:
            # if no frequency was specified, use the mid-point of the subdev
            f = self.u.freq_range()
            options.freq = float(f[0]+f[1])/2
        self.set_frequency(options.freq)

        self._fftsize = options.fft_size

        self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS,
                                self._freq, self._bandwidth,
                                "USRP2 Display",
                                True, True, True, False)

        # Set up internal amplifier
        self.amp = gr.multiply_const_cc(0.0)
        self.set_amplifier_gain(100)

        # Create a single-pole IIR filter to remove DC
        #   but don't connect it yet
        self.dc_gain = 0.001
        self.dc = gr.single_pole_iir_filter_cc(self.dc_gain)
        self.dc_sub = gr.sub_cc()

        self.connect(self.u, self.amp, self.snk)

        if self.show_debug_info:
            print "Decimation rate: ", self._decim
            print "Bandwidth: ", self._bandwidth
            print "D'board: ", self.u.daughterboard_id()

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        # Wrap the pointer as a PyQt SIP object
        #     This can now be manipulated as a PyQt4.QtGui.QWidget
        self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)

        self.main_win = main_window(self.pysink, self)

        self.main_win.set_frequency(self._freq)
        self.main_win.set_gain(self._gain)
        self.main_win.set_bandwidth(self._bandwidth)
        self.main_win.set_amplifier(self._amp_value)

        self.main_win.show()
コード例 #30
0
    def __init__(self, demodulator, rx_callback, options):
        gr.top_block.__init__(self)

        self._rx_freq            = options.rx_freq         # receiver's center frequency
        self._rx_gain            = options.rx_gain         # receiver's gain
        self._rx_subdev_spec     = options.rx_subdev_spec  # daughterboard to use
        self._decim              = options.decim           # Decimating rate for the USRP (prelim)
        self._bitrate            = options.bitrate
        self._samples_per_symbol = options.samples_per_symbol
        self._demod_class        = demodulator
        self.gui_on              = options.gui
        
        if self._rx_freq is None:
            sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit

        # Set up USRP source
        self._setup_usrp_source(options)

        # copy the final answers back into options for use by demodulator
        options.samples_per_symbol = self._samples_per_symbol
        options.bitrate = self._bitrate
        options.decim = self._decim

        ok = self.set_freq(self._rx_freq)
        if not ok:
            print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(self._rx_freq))
            raise ValueError, eng_notation.num_to_str(self._rx_freq)

        self.set_gain(options.rx_gain)

        # Set up receive path
        self.rxpath = receive_path(demodulator, rx_callback, options) 

        # FIXME: do better exposure to lower issues for control
        self._gain_clock = self.rxpath.packet_receiver._demodulator._timing_alpha
        self._gain_phase = self.rxpath.packet_receiver._demodulator._phase_alpha
        self._gain_freq  = self.rxpath.packet_receiver._demodulator._freq_alpha

        self.connect(self.u, self.rxpath)

        if self.gui_on:
            self.qapp = QtGui.QApplication(sys.argv)
            fftsize = 2048

            bw_in = self.u.adc_rate() / self.decim()
            self.snk_rxin = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                         self._rx_freq, bw_in,
                                         "Received", True, True, False, True, True, False)
            self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                       0, self._bitrate,
                                       "Post-Synchronizer", True, True, False, True, True, False)

            self.snk_rxin.set_frequency_axis(-140, 20)
            self.snk_rx.set_frequency_axis(-80, 20)
            self.snk_rxin.set_time_domain_axis(-2000,2000)
            
            # Connect to the QT sinks
            # FIXME: make better exposure to receiver from rxpath
            self.receiver = self.rxpath.packet_receiver._demodulator.phase_recov
            #self.receiver = self.rxpath.packet_receiver._demodulator.freq_recov
            self.connect(self.u, self.snk_rxin)
            self.connect(self.receiver, self.snk_rx)
            
            pyRxInQt  = self.snk_rxin.pyqwidget()
            pyRxIn = sip.wrapinstance(pyRxInQt, QtGui.QWidget)
            
            pyRxQt  = self.snk_rx.pyqwidget()
            pyRx = sip.wrapinstance(pyRxQt, QtGui.QWidget)

            self.snk_freq = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                         0, self._bitrate,
                                         "FLL", True, False, False, True, False, False)
            
            self.main_box = dialog_box(pyRxIn, pyRx, self)
            self.main_box.show()
コード例 #31
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option(
            "-w",
            "--which",
            type="int",
            default=0,
            help="select which USRP (0, 1, ...) default is %default",
            metavar="NUM")
        parser.add_option(
            "-R",
            "--rx-subdev-spec",
            type="subdev",
            default=None,
            help=
            "select USRP Rx side A or B (default=first one with a daughterboard)"
        )
        parser.add_option("-A",
                          "--antenna",
                          default=None,
                          help="select Rx Antenna (only on RFX-series boards)")
        parser.add_option("-W",
                          "--bw",
                          type="float",
                          default=1e6,
                          help="set bandwidth of receiver [default=%default]")
        parser.add_option("-f",
                          "--freq",
                          type="eng_float",
                          default=None,
                          help="set frequency to FREQ",
                          metavar="FREQ")
        parser.add_option("-g",
                          "--gain",
                          type="eng_float",
                          default=None,
                          help="set gain in dB [default is midpoint]")
        parser.add_option("-8",
                          "--width-8",
                          action="store_true",
                          default=False,
                          help="Enable 8-bit samples across USB")
        parser.add_option("--no-hb",
                          action="store_true",
                          default=False,
                          help="don't use halfband filter in usrp")
        parser.add_option("-S",
                          "--oscilloscope",
                          action="store_true",
                          default=False,
                          help="Enable oscilloscope display")
        parser.add_option(
            "",
            "--avg-alpha",
            type="eng_float",
            default=1e-1,
            help="Set fftsink averaging factor, [default=%default]")
        parser.add_option("",
                          "--ref-scale",
                          type="eng_float",
                          default=13490.0,
                          help="Set dBFS=0dB input value, [default=%default]")
        parser.add_option("",
                          "--fft-size",
                          type="int",
                          default=2048,
                          help="Set FFT frame size, [default=%default]")

        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            sys.exit(1)
        self.options = options
        self.show_debug_info = True

        # Call this before creating the Qt sink
        self.qapp = QtGui.QApplication(sys.argv)

        self._fftsize = options.fft_size

        self.u = usrp.source_c(which=options.which)
        self._adc_rate = self.u.converter_rate()
        self.set_bandwidth(options.bw)

        if options.rx_subdev_spec is None:
            options.rx_subdev_spec = pick_subdevice(self.u)
        self._rx_subdev_spec = options.rx_subdev_spec
        self.u.set_mux(
            usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec))
        self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec)

        self._gain_range = self.subdev.gain_range()
        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self._gain_range
            options.gain = float(g[0] + g[1]) / 2
        self.set_gain(options.gain)

        if options.freq is None:
            # if no frequency was specified, use the mid-point of the subdev
            f = self.subdev.freq_range()
            options.freq = float(f[0] + f[1]) / 2
        self.set_frequency(options.freq)

        self.snk = qtgui.sink_c(self._fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                self._freq, self._bandwidth, "USRP Display",
                                True, True, False, True, False)

        # Set up internal amplifier
        self.amp = gr.multiply_const_cc(0.0)
        self.set_amplifier_gain(0.001)

        # Connect the flow graph
        self.connect(self.u, self.amp, self.snk)

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        # Wrap the pointer as a PyQt SIP object
        #     This can now be manipulated as a PyQt4.QtGui.QWidget
        self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)

        self.main_win = main_window(self.pysink, self)

        self.main_win.set_frequency(self._freq)
        self.main_win.set_gain(self._gain)
        self.main_win.set_bandwidth(self._bandwidth)
        self.main_win.set_amplifier(self._amp_value)

        self.main_win.show()
コード例 #32
0
ファイル: usrp2_wfm_qt.py プロジェクト: GREO/GNU-Radio
    def __init__(self):
        gr.top_block.__init__(self)
        
        parser = OptionParser(option_class=eng_option)
        parser.add_option("-e", "--interface", type="string", default="eth0",
                          help="select Ethernet interface, default is eth0")
        parser.add_option("-m", "--mac-addr", type="string", default="",
                          help="select USRP by MAC address, default is auto-select")
        #parser.add_option("-A", "--antenna", default=None,
        #                  help="select Rx Antenna (only on RFX-series boards)")
        parser.add_option("-f", "--freq", type="eng_float", default=100.1,
                          help="set frequency to FREQ", metavar="FREQ")
        parser.add_option("-g", "--gain", type="eng_float", default=None,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("-V", "--volume", type="eng_float", default=None,
                          help="set volume (default is midpoint)")
        parser.add_option("-O", "--audio-output", type="string", default="",
                          help="pcm device name.  E.g., hw:0,0 or surround51 or /dev/dsp")

        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            sys.exit(1)
        
        self._volume = options.volume
        self._usrp_freq = options.freq
        self._usrp_gain = options.gain
        self._audio_rate = int(32e3)

        # build graph
     
        self.u = usrp2.source_32fc(options.interface, options.mac_addr)

        # calculate decimation values to get USRP BW at 320 kHz
        self.calculate_usrp_bw(320e3)

        self.set_decim(self._usrp_decim)

        #FIXME: need named constants and text descriptions available to (gr-)usrp2 even
        #when usrp(1) module is not built.  A usrp_common module, perhaps?
        dbid = self.u.daughterboard_id()
        print "Using RX d'board 0x%04X" % (dbid,)
        #if not (dbid == 0x0001 or #usrp_dbid.BASIC_RX
        #        dbid == 0x0003 or #usrp_dbid.TV_RX
        #        dbid == 0x000c or #usrp_dbid.TV_RX_REV_2
        #        dbid == 0x0040 or #usrp_dbid.TV_RX_REV_3
        #        dbid == 0x0043 or #usrp_dbid.TV_RX_MIMO
        #        dbid == 0x0044 or #usrp_dbid.TV_RX_REV_2_MIMO
        #        dbid == 0x0045 ): #usrp_dbid.TV_RX_REV_3_MIMO
        #    print "This daughterboard does not cover the required frequency range"
        #    print "for this application.  Please use a BasicRX or TVRX daughterboard."
        #    raw_input("Press ENTER to continue anyway, or Ctrl-C to exit.")

        chan_filt_coeffs = optfir.low_pass (1,                 # gain
                                            self._usrp_rate,   # sampling rate
                                            80e3,        # passband cutoff
                                            115e3,       # stopband cutoff
                                            0.1,         # passband ripple
                                            60)          # stopband attenuation
        #print len(chan_filt_coeffs)
        chan_filt = gr.fir_filter_ccf (self._chanfilt_decim, chan_filt_coeffs)

        self.guts = blks2.wfm_rcv (self._demod_rate, self._audio_decim)

        self.volume_control = gr.multiply_const_ff(1)

        # sound card as final sink
        #audio_sink = audio.sink (int (audio_rate),
        #                         options.audio_output,
        #                         False)  # ok_to_block
        audio_sink = audio.sink (self._audio_rate,
                                 options.audio_output)

        
        if self._usrp_gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.gain_range()
            print "Gain range: ", g
            self._usrp_gain = float(g[0]+g[1])/2

        if self._volume is None:
            g = self.volume_range()
            self._volume = float(g[0]+g[1])/2
            
        if abs(self._usrp_freq) < 1e6:
            self._usrp_freq *= 1e6

        # set initial values
        self.set_gain(self._usrp_gain)
        self.set_volume(self._volume)
        if not(self.set_freq(self._usrp_freq)):
            print ("Failed to set initial frequency")


        # Define a GUI sink to display the received signal
        self.qapp = QtGui.QApplication(sys.argv)
        fftsize = 2048
        
        self.usrp_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                    -self._usrp_rate/2.0, self._usrp_rate/2.0,
                                    "Received Signal", True, True, False, True, False,
                                    use_openGL=False)
        self.usrp_rx2 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                    -self._usrp_rate/2.0, self._usrp_rate/2.0,
                                    "Received Signal", True, True, False, True, False)
        
        # now wire it all together
        self.connect (self.u, chan_filt, self.guts, self.volume_control, audio_sink)
        self.connect (self.u, self.usrp_rx)
        self.connect (self.volume_control, self.usrp_rx2)
        
        usrp_rx_widget = sip.wrapinstance(self.usrp_rx.pyqwidget(), QtGui.QWidget)
        usrp_rx2_widget = sip.wrapinstance(self.usrp_rx2.pyqwidget(), QtGui.QWidget)
        
        self.main_box = dialog_box(usrp_rx_widget, usrp_rx2_widget, self)
        self.main_box.show()
コード例 #33
0
	def __init__(self):
		gr.top_block.__init__(self, "FM Demodulation - 91.9 MHz")
		Qt.QWidget.__init__(self)
		self.setWindowTitle("FM Demodulation - 91.9 MHz")
		self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
		self.top_scroll_layout = Qt.QVBoxLayout()
		self.setLayout(self.top_scroll_layout)
		self.top_scroll = Qt.QScrollArea()
		self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
		self.top_scroll_layout.addWidget(self.top_scroll)
		self.top_scroll.setWidgetResizable(True)
		self.top_widget = Qt.QWidget()
		self.top_scroll.setWidget(self.top_widget)
		self.top_layout = Qt.QVBoxLayout(self.top_widget)
		self.top_grid_layout = Qt.QGridLayout()
		self.top_layout.addLayout(self.top_grid_layout)


		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 1152e3

		##################################################
		# Blocks
		##################################################
		self.rtlsdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + "" )
		self.rtlsdr_source_c_0.set_sample_rate(samp_rate)
		self.rtlsdr_source_c_0.set_center_freq(91.9e6, 0)
		self.rtlsdr_source_c_0.set_freq_corr(0, 0)
		self.rtlsdr_source_c_0.set_dc_offset_mode(0, 0)
		self.rtlsdr_source_c_0.set_iq_balance_mode(0, 0)
		self.rtlsdr_source_c_0.set_gain_mode(0, 0)
		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.qtgui_sink_x_1 = qtgui.sink_f(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate/24, #bw
			"QT GUI Plot - Demodulated Signal", #name
			True, #plotfreq
			True, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self.qtgui_sink_x_1.set_update_time(1.0 / 10)
		self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget)
		self.top_layout.addWidget(self._qtgui_sink_x_1_win)
		self.qtgui_sink_x_0 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			91.9e6, #fc
			samp_rate, #bw
			"QT GUI Plot - Source", #name
			True, #plotfreq
			True, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self.qtgui_sink_x_0.set_update_time(1.0 / 10)
		self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
		self.top_layout.addWidget(self._qtgui_sink_x_0_win)
		self.blks2_wfm_rcv_0 = blks2.wfm_rcv(
			quad_rate=samp_rate,
			audio_decimation=24,
		)
		self.audio_sink_0 = audio.sink(48000, "", True)

		##################################################
		# Connections
		##################################################
		self.connect((self.rtlsdr_source_c_0, 0), (self.blks2_wfm_rcv_0, 0))
		self.connect((self.blks2_wfm_rcv_0, 0), (self.audio_sink_0, 0))
		self.connect((self.rtlsdr_source_c_0, 0), (self.qtgui_sink_x_0, 0))
		self.connect((self.blks2_wfm_rcv_0, 0), (self.qtgui_sink_x_1, 0))
コード例 #34
0
    def __init__(self, mod_class, demod_class, rx_callback, options):
        gr.top_block.__init__(self)

        self._sample_rate = options.sample_rate

        if(options.samples_per_symbol is None):
            options.samples_per_symbol = 2

        channelon = True;

        self.gui_on = options.gui

        self._frequency_offset = options.frequency_offset
        self._timing_offset = options.timing_offset
        self._tx_amplitude = options.tx_amplitude
        self._snr_dB = options.snr

        self._noise_voltage = self.get_noise_voltage(self._snr_dB)

        self.txpath = transmit_path(mod_class, options)
        self.throttle = gr.throttle(gr.sizeof_gr_complex, self.sample_rate())
        self.rxpath = receive_path(demod_class, rx_callback, options)

        # FIXME: do better exposure to lower issues for control
        self._timing_gain_alpha = self.rxpath.packet_receiver._demodulator._mm_gain_mu
        self._alpha = self.rxpath.packet_receiver._demodulator._costas_alpha

        if channelon:
            self.channel = gr.channel_model(self._noise_voltage,
                                            self.frequency_offset(),
                                            self.timing_offset())
            
            if options.discontinuous:
                z = 20000*[0,]
                self.zeros = gr.vector_source_c(z, True)
                packet_size = 5*((4+8+4+1500+4) * 8)
                self.mux = gr.stream_mux(gr.sizeof_gr_complex, [packet_size-0, int(9e5)])

                # Connect components
                self.connect(self.txpath, self.throttle, (self.mux,0))
                self.connect(self.zeros, (self.mux,1))
                self.connect(self.mux, self.channel, self.rxpath)

            else:
                self.connect(self.txpath, self.throttle, self.channel, self.rxpath)

            if self.gui_on:
                self.qapp = QtGui.QApplication(sys.argv)
                fftsize = 2048

                self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                           0, self._sample_rate,
                                           "Tx", True, True, False, True, True)
                self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
                                           0, self._sample_rate,
                                           "Rx", True, True, False, True, True)

                self.snk_tx.set_frequency_axis(-80, 0)
                self.snk_rx.set_frequency_axis(-60, 20)
            
                # Connect to the QT sinks
                # FIXME: make better exposure to receiver from rxpath
                self.receiver = self.rxpath.packet_receiver._demodulator.receiver
                self.receiver.set_alpha(2)
                self.receiver.set_beta(0.02)
                self.connect(self.channel, self.snk_tx)
                self.connect(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()
                
        else:
            # Connect components
            self.connect(self.txpath, self.throttle, self.rxpath)
コード例 #35
0
ファイル: uhd_display.py プロジェクト: ahsscott77/gnuradio
    def __init__(self, options):
        gr.top_block.__init__(self)

        self.options = options
        self.show_debug_info = True
        
        self.qapp = QtGui.QApplication(sys.argv)

        self.u = uhd.usrp_source(device_addr=options.address,
                                 io_type=uhd.io_type.COMPLEX_FLOAT32,
                                 num_channels=1)
        self.set_bandwidth(options.samp_rate)

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.get_gain_range()
            options.gain = float(g.start()+g.stop())/2
        self.set_gain(options.gain)

        if options.freq is None:
            # if no freq was specified, use the mid-point
            r = self.u.get_freq_range()
            options.freq = float(r.start()+r.stop())/2
        self.set_frequency(options.freq)

        if(options.antenna):
            self.u.set_antenna(options.antenna, 0)

        self._fftsize = options.fft_size

        self.snk = qtgui.sink_c(options.fft_size,
                                gr.firdes.WIN_BLACKMAN_hARRIS,
                                self._freq, self._bandwidth,
                                "UHD Display",
                                True, True, True, False)

        # Set up internal amplifier
        self.amp = gr.multiply_const_cc(0.0)
        self.set_amplifier_gain(100)

        # Create a single-pole IIR filter to remove DC
        #   but don't connect it yet
        self.dc_gain = 0.001
        self.dc = gr.single_pole_iir_filter_cc(self.dc_gain)
        self.dc_sub = gr.sub_cc()

        self.connect(self.u, self.amp, self.snk)

        if self.show_debug_info:
            print "Bandwidth: ", self.u.get_samp_rate()
            print "Center Freq: ", self.u.get_center_freq()
            print "Freq Range: ", self.u.get_freq_range()

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        # Wrap the pointer as a PyQt SIP object
        #     This can now be manipulated as a PyQt4.QtGui.QWidget
        self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)

        self.main_win = main_window(self.pysink, self)

        self.main_win.set_frequency(self._freq)
        self.main_win.set_gain(self._gain)
        self.main_win.set_bandwidth(self._bandwidth)
        self.main_win.set_amplifier(self._amp_value)

        self.main_win.show()
コード例 #36
0
	def __init__(self):
		gr.top_block.__init__(self, "writeToFile")
		Qt.QWidget.__init__(self)
		self.setWindowTitle("writeToFile")
		self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
		self.top_scroll_layout = Qt.QVBoxLayout()
		self.setLayout(self.top_scroll_layout)
		self.top_scroll = Qt.QScrollArea()
		self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
		self.top_scroll_layout.addWidget(self.top_scroll)
		self.top_scroll.setWidgetResizable(True)
		self.top_widget = Qt.QWidget()
		self.top_scroll.setWidget(self.top_widget)
		self.top_layout = Qt.QVBoxLayout(self.top_widget)
		self.top_grid_layout = Qt.QGridLayout()
		self.top_layout.addLayout(self.top_grid_layout)
		self.bufferRE = collections.deque(400*[0], 400) # init buffer of 400 entries, max length 400
		self.bufferIM = collections.deque(400*[0], 400) # init buffer of 400 entries, max length 400
         
		##################################################
		# Variables
		##################################################
		self.variable_function_probe_1 = variable_function_probe_1 = 0
		self.variable_function_probe_0 = variable_function_probe_0 = 0
		self.samp_rate = samp_rate = 320000
		self.receiveFrequency = receiveFrequency = 900000000

		##################################################
		# Blocks
		##################################################
		self.gr_probe_signal_f_1 = gr.probe_signal_f()
		self.gr_probe_signal_f_0 = gr.probe_signal_f()
		def _variable_function_probe_1_probe():
			while True:
				val = self.gr_probe_signal_f_1.level()
				try: self.set_variable_function_probe_1(val)
				except AttributeError, e: pass
				time.sleep(1.0/(100)) # Sample rate 100 Hz
		# starts the thread that samples the signal continuously
		_variable_function_probe_1_thread = threading.Thread(target=_variable_function_probe_1_probe)
		_variable_function_probe_1_thread.daemon = True
		_variable_function_probe_1_thread.start()
		def _variable_function_probe_0_probe():
			while True:
				val = self.gr_probe_signal_f_0.level()
				try: self.set_variable_function_probe_0(val)
				except AttributeError, e: pass
				time.sleep(1.0/(100)) # Sample rate 100 Hz
		# starts the thread that samples the signal continuously
		_variable_function_probe_0_thread = threading.Thread(target=_variable_function_probe_0_probe)
		_variable_function_probe_0_thread.daemon = True
		_variable_function_probe_0_thread.start()
		### TODO: Write values read from the channel continuously into a buffer
		### TODO: read out the buffer continuously in another thread for classification
		### TODO: output the classification
		def _variable_classification():
#			myFile = open("classification.tab", "a")
#			myFile.write('mean\tmedian\tvar\tTCM\tRMS\tmax\tmin\tdiff\tcountmax10%\tdirectionchange\tzeroCross\tDirChanzeroCross\tavgzerocross\tstddeviation\tlocation-coordinator\n')
#			#myFile.write('mean\tmedian\tvar\tTCM\tRMS\tmax\tmin\tdiff\tcountmax10%\tdirectionchange\tEntropy\tSpecenergy\tzeroCross\tDirChanzeroCross\tavgzerocross\tavgFFT\tstddeviation\tlocation-coordinator\n') # Write a feature string to a tab file  #18 features
#			myFile.write('c\tc\tc\tc\tc\tc\tc\tc\tc\tc\tc\tc\tc\tc\td\n')  #18 
#			myFile.write('\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass\n')
#			myFile.close()
			while True:
				# TODO: do classification here
				classification = self.get_classification()
				# TODO: Write out classification
				time.sleep(1.0/(2)) # One classification every 0.5 seconds
		# starts the thread that samples the signal continuously
		_variable_classification_thread = threading.Thread(target=_variable_classification)
		_variable_classification_thread.daemon = True
		_variable_classification_thread.start()

		def _variable_featureVisualisation(*args):
		  while True:
		    for data in args:
		      plot(data)
		      show()
		    time.sleep(1.0/(2))
		_variable_featureVisualisation_thread = threading.Thread(target=_variable_featureVisualisation)
		_variable_featureVisualisation_thread.daemon = True
		_variable_featureVisualisation_thread.start()
		#p = Process(target=plot_graph, args=([1, 2, 3],))
		#p.start()
		
		self.uhd_usrp_source_0 = uhd.usrp_source(
			device_addr="",
			stream_args=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(receiveFrequency, 0)
		self.uhd_usrp_source_0.set_gain(20, 0)
		self.qtgui_sink_x_0 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			True, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self.qtgui_sink_x_0.set_update_time(1.0 / 10)
		self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
		self.top_layout.addWidget(self._qtgui_sink_x_0_win)
		self.gr_complex_to_float_0 = gr.complex_to_float(1)

		##################################################
		# Connections
		##################################################
		self.connect((self.uhd_usrp_source_0, 0), (self.gr_complex_to_float_0, 0))
		self.connect((self.gr_complex_to_float_0, 0), (self.gr_probe_signal_f_0, 0))
		self.connect((self.gr_complex_to_float_0, 1), (self.gr_probe_signal_f_1, 0))
		self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_sink_x_0, 0))