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_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) src = gr.add_ff() thr = gr.throttle(gr.sizeof_float, 100*fftsize) self.snk1 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, Rs, "Float Signal Example", True, True, False, True, False) self.connect(src1, (src,0)) self.connect(src2, (src,1)) self.connect(src, 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()
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_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) src = gr.add_ff() thr = gr.throttle(gr.sizeof_float, 100 * fftsize) self.snk1 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, Rs, "Float Signal Example", True, True, False, True, False) self.connect(src1, (src, 0)) self.connect(src2, (src, 1)) self.connect(src, 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()
def __init__(self): gr.top_block.__init__(self, "Simple QAM Simulation") Qt.QWidget.__init__(self) self.setWindowTitle("Simple QAM Simulation") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) ################################################## # Variables ################################################## self.constellation_cardinality = constellation_cardinality = 16 self.const_object = const_object = constellations()['qam']( constellation_cardinality) self.snr_db = snr_db = 20 self.constellation = constellation = const_object.points() self.sps = sps = 8 self.samp_rate = samp_rate = 250000 self.noise_amp = noise_amp = sqrt((10**(-snr_db / 10.)) / 2.) self.constellation_power = constellation_power = sqrt( sum([abs(i)**2 for i in constellation]) / constellation_cardinality) ################################################## # Blocks ################################################## self.tabid_0 = Qt.QTabWidget() self.tabid_0_widget_0 = Qt.QWidget() self.tabid_0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_0) self.tabid_0_grid_layout_0 = Qt.QGridLayout() self.tabid_0_layout_0.addLayout(self.tabid_0_grid_layout_0) self.tabid_0.addTab(self.tabid_0_widget_0, "TX") self.tabid_0_widget_1 = Qt.QWidget() self.tabid_0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_1) self.tabid_0_grid_layout_1 = Qt.QGridLayout() self.tabid_0_layout_1.addLayout(self.tabid_0_grid_layout_1) self.tabid_0.addTab(self.tabid_0_widget_1, "CHANNEL") self.tabid_0_widget_2 = Qt.QWidget() self.tabid_0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_2) self.tabid_0_grid_layout_2 = Qt.QGridLayout() self.tabid_0_layout_2.addLayout(self.tabid_0_grid_layout_2) self.tabid_0.addTab(self.tabid_0_widget_2, "RX") self.top_grid_layout.addWidget(self.tabid_0, 30, 0, 10, 100) self.tabid_2 = Qt.QTabWidget() self.tabid_2_widget_0 = Qt.QWidget() self.tabid_2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_0) self.tabid_2_grid_layout_0 = Qt.QGridLayout() self.tabid_2_layout_0.addLayout(self.tabid_2_grid_layout_0) self.tabid_2.addTab(self.tabid_2_widget_0, "symbol-based") self.tabid_2_widget_1 = Qt.QWidget() self.tabid_2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_1) self.tabid_2_grid_layout_1 = Qt.QGridLayout() self.tabid_2_layout_1.addLayout(self.tabid_2_grid_layout_1) self.tabid_2.addTab(self.tabid_2_widget_1, "bit-based") self.tabid_2_widget_2 = Qt.QWidget() self.tabid_2_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_2) self.tabid_2_grid_layout_2 = Qt.QGridLayout() self.tabid_2_layout_2.addLayout(self.tabid_2_grid_layout_2) self.tabid_2.addTab(self.tabid_2_widget_2, "BER") self.tabid_0_layout_2.addWidget(self.tabid_2) self.tabid_1 = Qt.QTabWidget() self.tabid_1_widget_0 = Qt.QWidget() self.tabid_1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_0) self.tabid_1_grid_layout_0 = Qt.QGridLayout() self.tabid_1_layout_0.addLayout(self.tabid_1_grid_layout_0) self.tabid_1.addTab(self.tabid_1_widget_0, "bit-based") self.tabid_1_widget_1 = Qt.QWidget() self.tabid_1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_1) self.tabid_1_grid_layout_1 = Qt.QGridLayout() self.tabid_1_layout_1.addLayout(self.tabid_1_grid_layout_1) self.tabid_1.addTab(self.tabid_1_widget_1, "scrambled") self.tabid_1_widget_2 = Qt.QWidget() self.tabid_1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_2) self.tabid_1_grid_layout_2 = Qt.QGridLayout() self.tabid_1_layout_2.addLayout(self.tabid_1_grid_layout_2) self.tabid_1.addTab(self.tabid_1_widget_2, "symbol-based") self.tabid_0_grid_layout_0.addWidget(self.tabid_1, 0, 0, 10, 10) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_sink_x_0_1_0_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget) self.tabid_1_layout_0.addWidget(self._qtgui_sink_x_0_1_0_0_win) self.qtgui_sink_x_0_1_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_0_win = sip.wrapinstance( self.qtgui_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.tabid_1_layout_1.addWidget(self._qtgui_sink_x_0_1_0_win) self.qtgui_sink_x_0_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_win = sip.wrapinstance( self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget) self.tabid_1_layout_2.addWidget(self._qtgui_sink_x_0_1_win) self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_0.addWidget(self._qtgui_sink_x_0_0_0_0_win) self.qtgui_sink_x_0_0_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_1.addWidget(self._qtgui_sink_x_0_0_0_win) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime False, #plotconst ) self._qtgui_sink_x_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabid_0_layout_1.addWidget(self._qtgui_sink_x_0_0_win) self.gr_vector_source_x_0_0 = gr.vector_source_b(([1, 0]), True, 1) self.gr_vector_source_x_0 = gr.vector_source_b(([1, 0]), True, 1) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb( int(log2(constellation_cardinality))) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate) self.gr_pack_k_bits_bb_0 = gr.pack_k_bits_bb( int(log2(constellation_cardinality))) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char * 1) self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_amp, 0) self.gr_nlog10_ff_0 = gr.nlog10_ff(1, 1, 0) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vcc( (1. / constellation_power, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc( (constellation_power, )) self.gr_file_sink_0_1_0 = gr.file_sink(gr.sizeof_gr_complex * 1, "rx_sym.32fc") self.gr_file_sink_0_1_0.set_unbuffered(False) self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_gr_complex * 1, "tx_sym.32fc") self.gr_file_sink_0_1.set_unbuffered(False) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char * 1, "rx.8b") self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char * 1, "tx.8b") self.gr_file_sink_0.set_unbuffered(False) self.gr_descrambler_bb_0 = gr.descrambler_bb(0xe4001, 0x7ffff, 19) self.gr_char_to_float_1_0 = gr.char_to_float(1, 1) self.gr_char_to_float_1 = gr.char_to_float(1, 1) self.gr_char_to_float_0 = gr.char_to_float(1, 1) self.gr_add_xx_0 = gr.add_vcc(1) self.digital_scrambler_bb_0 = digital.scrambler_bb( 0xe4001, 0x7fffF, 19) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb( const_object.base(), 6.28 / 100, -0.25, +0.25) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (constellation), 1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=samp_rate, bits_per_symbol=1, ) ################################################## # Connections ################################################## self.connect((self.gr_vector_source_x_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.gr_pack_k_bits_bb_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_descrambler_bb_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_null_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_char_to_float_0, 0), (self.qtgui_sink_x_0_0_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_file_sink_0_1, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.qtgui_sink_x_0_1, 0)) self.connect((self.gr_char_to_float_1, 0), (self.qtgui_sink_x_0_1_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_char_to_float_1, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_char_to_float_1_0, 0), (self.qtgui_sink_x_0_1_0_0, 0)) self.connect((self.gr_vector_source_x_0, 0), (self.gr_char_to_float_1_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_file_sink_0_1_0, 0)) self.connect((self.gr_throttle_0, 0), (self.qtgui_sink_x_0_0_0_0, 0)) self.connect((self.gr_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.gr_nlog10_ff_0, 0)) self.connect((self.gr_vector_source_x_0_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1))
def __init__(self): gr.top_block.__init__(self) 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()
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()
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))
def __init__(self): gr.top_block.__init__(self, "Simple QAM Simulation") Qt.QWidget.__init__(self) self.setWindowTitle("Simple QAM Simulation") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) ################################################## # Variables ################################################## self.constellation_cardinality = constellation_cardinality = 16 self.const_object = const_object = constellations()['qam'](constellation_cardinality) self.snr_db = snr_db = 20 self.constellation = constellation = const_object.points() self.sps = sps = 8 self.samp_rate = samp_rate = 250000 self.noise_amp = noise_amp = sqrt( (10**(-snr_db/10.)) /2. ) self.constellation_power = constellation_power = sqrt(sum([abs(i)**2 for i in constellation])/constellation_cardinality) ################################################## # Blocks ################################################## self.tabid_0 = Qt.QTabWidget() self.tabid_0_widget_0 = Qt.QWidget() self.tabid_0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_0) self.tabid_0_grid_layout_0 = Qt.QGridLayout() self.tabid_0_layout_0.addLayout(self.tabid_0_grid_layout_0) self.tabid_0.addTab(self.tabid_0_widget_0, "TX") self.tabid_0_widget_1 = Qt.QWidget() self.tabid_0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_1) self.tabid_0_grid_layout_1 = Qt.QGridLayout() self.tabid_0_layout_1.addLayout(self.tabid_0_grid_layout_1) self.tabid_0.addTab(self.tabid_0_widget_1, "CHANNEL") self.tabid_0_widget_2 = Qt.QWidget() self.tabid_0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_2) self.tabid_0_grid_layout_2 = Qt.QGridLayout() self.tabid_0_layout_2.addLayout(self.tabid_0_grid_layout_2) self.tabid_0.addTab(self.tabid_0_widget_2, "RX") self.top_grid_layout.addWidget(self.tabid_0, 30,0,10,100) self.tabid_2 = Qt.QTabWidget() self.tabid_2_widget_0 = Qt.QWidget() self.tabid_2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_0) self.tabid_2_grid_layout_0 = Qt.QGridLayout() self.tabid_2_layout_0.addLayout(self.tabid_2_grid_layout_0) self.tabid_2.addTab(self.tabid_2_widget_0, "symbol-based") self.tabid_2_widget_1 = Qt.QWidget() self.tabid_2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_1) self.tabid_2_grid_layout_1 = Qt.QGridLayout() self.tabid_2_layout_1.addLayout(self.tabid_2_grid_layout_1) self.tabid_2.addTab(self.tabid_2_widget_1, "bit-based") self.tabid_2_widget_2 = Qt.QWidget() self.tabid_2_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_2) self.tabid_2_grid_layout_2 = Qt.QGridLayout() self.tabid_2_layout_2.addLayout(self.tabid_2_grid_layout_2) self.tabid_2.addTab(self.tabid_2_widget_2, "BER") self.tabid_0_layout_2.addWidget(self.tabid_2) self.tabid_1 = Qt.QTabWidget() self.tabid_1_widget_0 = Qt.QWidget() self.tabid_1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_0) self.tabid_1_grid_layout_0 = Qt.QGridLayout() self.tabid_1_layout_0.addLayout(self.tabid_1_grid_layout_0) self.tabid_1.addTab(self.tabid_1_widget_0, "bit-based") self.tabid_1_widget_1 = Qt.QWidget() self.tabid_1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_1) self.tabid_1_grid_layout_1 = Qt.QGridLayout() self.tabid_1_layout_1.addLayout(self.tabid_1_grid_layout_1) self.tabid_1.addTab(self.tabid_1_widget_1, "scrambled") self.tabid_1_widget_2 = Qt.QWidget() self.tabid_1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_2) self.tabid_1_grid_layout_2 = Qt.QGridLayout() self.tabid_1_layout_2.addLayout(self.tabid_1_grid_layout_2) self.tabid_1.addTab(self.tabid_1_widget_2, "symbol-based") self.tabid_0_grid_layout_0.addWidget(self.tabid_1, 0,0,10,10) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_sink_x_0_1_0_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget) self.tabid_1_layout_0.addWidget(self._qtgui_sink_x_0_1_0_0_win) self.qtgui_sink_x_0_1_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_0_win = sip.wrapinstance(self.qtgui_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.tabid_1_layout_1.addWidget(self._qtgui_sink_x_0_1_0_win) self.qtgui_sink_x_0_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_win = sip.wrapinstance(self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget) self.tabid_1_layout_2.addWidget(self._qtgui_sink_x_0_1_win) self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_0.addWidget(self._qtgui_sink_x_0_0_0_0_win) self.qtgui_sink_x_0_0_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_1.addWidget(self._qtgui_sink_x_0_0_0_win) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime False, #plotconst ) self._qtgui_sink_x_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabid_0_layout_1.addWidget(self._qtgui_sink_x_0_0_win) self.gr_vector_source_x_0_0 = gr.vector_source_b(([1,0]), True, 1) self.gr_vector_source_x_0 = gr.vector_source_b(([1,0]), True, 1) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(int(log2(constellation_cardinality))) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate) self.gr_pack_k_bits_bb_0 = gr.pack_k_bits_bb(int(log2(constellation_cardinality))) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char*1) self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_amp, 0) self.gr_nlog10_ff_0 = gr.nlog10_ff(1, 1, 0) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vcc((1./constellation_power, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((constellation_power, )) self.gr_file_sink_0_1_0 = gr.file_sink(gr.sizeof_gr_complex*1, "rx_sym.32fc") self.gr_file_sink_0_1_0.set_unbuffered(False) self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_gr_complex*1, "tx_sym.32fc") self.gr_file_sink_0_1.set_unbuffered(False) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char*1, "rx.8b") self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char*1, "tx.8b") self.gr_file_sink_0.set_unbuffered(False) self.gr_descrambler_bb_0 = gr.descrambler_bb(0xe4001, 0x7ffff, 19) self.gr_char_to_float_1_0 = gr.char_to_float(1, 1) self.gr_char_to_float_1 = gr.char_to_float(1, 1) self.gr_char_to_float_0 = gr.char_to_float(1, 1) self.gr_add_xx_0 = gr.add_vcc(1) self.digital_scrambler_bb_0 = digital.scrambler_bb(0xe4001, 0x7fffF, 19) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(const_object.base(), 6.28/100, -0.25, +0.25) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((constellation), 1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=samp_rate, bits_per_symbol=1, ) ################################################## # Connections ################################################## self.connect((self.gr_vector_source_x_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.gr_pack_k_bits_bb_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_descrambler_bb_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_null_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_char_to_float_0, 0), (self.qtgui_sink_x_0_0_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_file_sink_0_1, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.qtgui_sink_x_0_1, 0)) self.connect((self.gr_char_to_float_1, 0), (self.qtgui_sink_x_0_1_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_char_to_float_1, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_char_to_float_1_0, 0), (self.qtgui_sink_x_0_1_0_0, 0)) self.connect((self.gr_vector_source_x_0, 0), (self.gr_char_to_float_1_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_file_sink_0_1_0, 0)) self.connect((self.gr_throttle_0, 0), (self.qtgui_sink_x_0_0_0_0, 0)) self.connect((self.gr_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.gr_nlog10_ff_0, 0)) self.connect((self.gr_vector_source_x_0_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1))
def __init__(self): gr.top_block.__init__(self, "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))