def test_sub_cc_2 (self):
     src1_data       = (2-2j,  1-1j, -8+0j,    3-7j,  4+2j, 5+5j)
     src2_data       = (1-1j,  3+2j,  4-2j,    1-8j,  6+1j, 5+5j)
     expected_result = (1-1j, -2+-3j, -12+2j,  2+1j,  -2+1j, 0+0j)
     op = gr.sub_cc (2)
     self.help_cc ((src1_data, src2_data),
                   expected_result, op, port_prefix='complex_in_')
 def test_sub_cc_3 (self):
     src1_data       = (2-2j,  1-1j, -8+0j,    3-7j,  4+2j, 5+5j)
     src2_data       = (1-1j,  3+2j,  4-2j,    1-8j,  6+1j, 5+5j)
     src3_data       = (-1+1j,-3-2j, -4+2j,   -1+8j, -6-1j, -5-5j)
     expected_result = (2-2j,  1-1j, -8+0j,    3-7j,  4+2j, 5+5j)
     op = gr.sub_cc (3)
     self.help_cc ((src1_data, src2_data, src3_data),
                   expected_result, op, port_prefix='complex_in_')
Example #3
0
 def test_sub_cc_1(self):
     src1_data = (2 - 2j, 1 - 1j, -8 + 0j, -3 - 7j, -4 + 2j, 5 + 5j)
     expected_result = (-2 + 2j, -1 + 1j, 8 + 0j, 3 + 7j, 4 - 2j, -5 - 5j)
     op = gr.sub_cc(1)
     self.help_cc((src1_data, ),
                  expected_result,
                  op,
                  port_prefix='SINGLE_PORT')
Example #4
0
 def test_sub_cc_2(self):
     src1_data = (2 - 2j, 1 - 1j, -8 + 0j, 3 - 7j, 4 + 2j, 5 + 5j)
     src2_data = (1 - 1j, 3 + 2j, 4 - 2j, 1 - 8j, 6 + 1j, 5 + 5j)
     expected_result = (1 - 1j, -2 + -3j, -12 + 2j, 2 + 1j, -2 + 1j, 0 + 0j)
     op = gr.sub_cc(2)
     self.help_cc((src1_data, src2_data),
                  expected_result,
                  op,
                  port_prefix='complex_in_')
Example #5
0
    def __init__(self):
        gr.hier_block2.__init__(self, "symbol_1_slicer",
                                gr.io_signature(2, 2, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_float))
        diff = gr.sub_cc()
        to_mag = gr.complex_to_mag_squared()

        self.connect((self, 0), (diff, 0))
        self.connect((self, 1), (diff, 1))
        self.connect(diff, to_mag, self)
Example #6
0
 def test_sub_cc_3(self):
     src1_data = (2 - 2j, 1 - 1j, -8 + 0j, 3 - 7j, 4 + 2j, 5 + 5j)
     src2_data = (1 - 1j, 3 + 2j, 4 - 2j, 1 - 8j, 6 + 1j, 5 + 5j)
     src3_data = (-1 + 1j, -3 - 2j, -4 + 2j, -1 + 8j, -6 - 1j, -5 - 5j)
     expected_result = (2 - 2j, 1 - 1j, -8 + 0j, 3 - 7j, 4 + 2j, 5 + 5j)
     op = gr.sub_cc(3)
     self.help_cc((src1_data, src2_data, src3_data),
                  expected_result,
                  op,
                  port_prefix='complex_in_')
Example #7
0
    def __init__(self):
        gr.hier_block2.__init__(self,
                                "symbol_1_slicer",
                                gr.io_signature(2, 2, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_float))
        diff = gr.sub_cc()
        to_mag = gr.complex_to_mag_squared()

        self.connect((self, 0), (diff, 0))
        self.connect((self, 1), (diff, 1))
        self.connect(diff, 
                     to_mag, 
                     self)
Example #8
0
 def __init__ ( self, fft_length ):
   gr.hier_block2.__init__(self, "recursive_timing_metric",
       gr.io_signature(1,1,gr.sizeof_gr_complex),
       gr.io_signature(1,1,gr.sizeof_float))
   
   self.input = gr.kludge_copy(gr.sizeof_gr_complex)
   self.connect(self, self.input)
   
   # P(d) = sum(0 to L-1, conj(delayed(r)) * r)
   conj = gr.conjugate_cc()
   mixer = gr.multiply_cc()
   mix_delay = delay(gr.sizeof_gr_complex,fft_length/2+1)
   mix_diff = gr.sub_cc()
   nominator = accumulator_cc()
   inpdelay = delay(gr.sizeof_gr_complex,fft_length/2)
   
   self.connect(self.input, inpdelay, 
                conj, (mixer,0))
   self.connect(self.input, (mixer,1))
   self.connect(mixer,(mix_diff,0))
   self.connect(mixer, mix_delay, (mix_diff,1))
   self.connect(mix_diff,nominator)
   
   rmagsqrd = gr.complex_to_mag_squared()
   rm_delay = delay(gr.sizeof_float,fft_length+1)
   rm_diff = gr.sub_ff()
   denom = accumulator_ff()
   self.connect(self.input,rmagsqrd,rm_diff,gr.multiply_const_ff(0.5),denom)
   self.connect(rmagsqrd,rm_delay,(rm_diff,1))
   
   
   ps = gr.complex_to_mag_squared()
   rs = gr.multiply_ff()
   self.connect(nominator,ps)
   self.connect(denom,rs)
   self.connect(denom,(rs,1))
   
   div = gr.divide_ff()
   self.connect(ps,div)
   self.connect(rs,(div,1))
   
   self.connect(div,self)
Example #9
0
    def __init__(self, fft_length):
        gr.hier_block2.__init__(self, "recursive_timing_metric",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_float))

        self.input = gr.kludge_copy(gr.sizeof_gr_complex)
        self.connect(self, self.input)

        # P(d) = sum(0 to L-1, conj(delayed(r)) * r)
        conj = gr.conjugate_cc()
        mixer = gr.multiply_cc()
        mix_delay = delay(gr.sizeof_gr_complex, fft_length / 2 + 1)
        mix_diff = gr.sub_cc()
        nominator = accumulator_cc()
        inpdelay = delay(gr.sizeof_gr_complex, fft_length / 2)

        self.connect(self.input, inpdelay, conj, (mixer, 0))
        self.connect(self.input, (mixer, 1))
        self.connect(mixer, (mix_diff, 0))
        self.connect(mixer, mix_delay, (mix_diff, 1))
        self.connect(mix_diff, nominator)

        rmagsqrd = gr.complex_to_mag_squared()
        rm_delay = delay(gr.sizeof_float, fft_length + 1)
        rm_diff = gr.sub_ff()
        denom = accumulator_ff()
        self.connect(self.input, rmagsqrd, rm_diff, gr.multiply_const_ff(0.5),
                     denom)
        self.connect(rmagsqrd, rm_delay, (rm_diff, 1))

        ps = gr.complex_to_mag_squared()
        rs = gr.multiply_ff()
        self.connect(nominator, ps)
        self.connect(denom, rs)
        self.connect(denom, (rs, 1))

        div = gr.divide_ff()
        self.connect(ps, div)
        self.connect(rs, (div, 1))

        self.connect(div, self)
Example #10
0
  def __init__(self, data_tones, num_symbols, mode=0):
    symbol_size = data_tones * gr.sizeof_gr_complex
    gr.hier_block2.__init__(self, "SNR",
      gr.io_signature2(2,2, symbol_size, symbol_size),
      gr.io_signature(1,1, gr.sizeof_float))

    sub = gr.sub_cc(data_tones)
    self.connect((self,0), (sub,0))
    self.connect((self,1), (sub,1))

    err = gr.complex_to_mag_squared(data_tones);
    self.connect(sub, err);
    pow = gr.complex_to_mag_squared(data_tones);
    self.connect((self,1), pow);

    if mode == 0:
      # one snr per symbol (num_symbols is ignored)
      snr = gr.divide_ff()
      self.connect(pow, gr.vector_to_stream(gr.sizeof_float, data_tones),
        gr.integrate_ff(data_tones), (snr,0))
      self.connect(err, gr.vector_to_stream(gr.sizeof_float, data_tones),
        gr.integrate_ff(data_tones), (snr,1))
      out = snr
    elif mode == 1:
      # one snr per packet
      snr = gr.divide_ff()
      self.connect(pow, gr.vector_to_stream(gr.sizeof_float, data_tones),
        gr.integrate_ff(data_tones*num_symbols), (snr,0))
      self.connect(err, gr.vector_to_stream(gr.sizeof_float, data_tones),
        gr.integrate_ff(data_tones*num_symbols), (snr,1))
      out = snr
    elif mode == 2:
      # one snr per frequency bin
      snr = gr.divide_ff(data_tones)
      self.connect(pow, raw.symbol_avg(data_tones, num_symbols), (snr,0))
      self.connect(err, raw.symbol_avg(data_tones, num_symbols), (snr,1))
      out = gr.vector_to_stream(gr.sizeof_float, data_tones)
      self.connect(snr, out)

    self.connect(out, gr.nlog10_ff(10), self)
Example #11
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10000000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.random_source_x_0 = gr.vector_source_b(map(int, numpy.random.randint(0, 2, 1000)), True)
        self.gr_vector_to_stream_0 = gr.vector_to_stream(gr.sizeof_gr_complex * 1, 512)
        self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate)
        self.gr_sub_xx_0 = gr.sub_cc(512)
        self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_gr_complex * 1, 512)
        self.gr_file_source_1 = gr.file_source(
            gr.sizeof_gr_complex * 512, "/home/traviscollins/git/BLISS/Matlab/Spectral_Subtraction/hilbert.txt", True
        )
        self.gr_file_source_0 = gr.file_source(
            gr.sizeof_float * 1, "/home/traviscollins/git/BLISS/Matlab/Spectral_Subtraction/INPUT.txt", True
        )
        self.gr_file_sink_0 = gr.file_sink(
            gr.sizeof_float * 1, "/home/traviscollins/git/BLISS/Matlab/Spectral_Subtraction/OUTPUT.txt"
        )
        self.gr_file_sink_0.set_unbuffered(False)
        self.gr_add_xx_0 = gr.add_vcc(1)
        self.fft_vxx_1 = fft.fft_vcc(512, False, (window.blackmanharris(1024)), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(512, True, (window.blackmanharris(1024)), True, 1)
        self.digital_ofdm_mod_0 = grc_blks2.packet_mod_f(
            digital.ofdm_mod(
                options=grc_blks2.options(
                    modulation="bpsk",
                    fft_length=512,
                    occupied_tones=200,
                    cp_length=128,
                    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="bpsk", fft_length=512, occupied_tones=200, cp_length=128, snr=10, log=None, verbose=None
                ),
                callback=lambda ok, payload: self.digital_ofdm_demod_0.recv_pkt(ok, payload),
            )
        )
        self.digital_dxpsk_mod_0 = digital.dbpsk_mod(
            samples_per_symbol=2, excess_bw=0.35, gray_coded=True, verbose=False, log=False
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_file_source_0, 0), (self.digital_ofdm_mod_0, 0))
        self.connect((self.digital_ofdm_demod_0, 0), (self.gr_file_sink_0, 0))
        self.connect((self.gr_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.random_source_x_0, 0), (self.digital_dxpsk_mod_0, 0))
        self.connect((self.digital_ofdm_mod_0, 0), (self.gr_add_xx_0, 0))
        self.connect((self.digital_dxpsk_mod_0, 0), (self.gr_add_xx_0, 1))
        self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.gr_stream_to_vector_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.gr_sub_xx_0, 0))
        self.connect((self.gr_file_source_1, 0), (self.gr_sub_xx_0, 1))
        self.connect((self.gr_vector_to_stream_0, 0), (self.digital_ofdm_demod_0, 0))
        self.connect((self.gr_vector_to_stream_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.gr_add_xx_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.gr_sub_xx_0, 0), (self.fft_vxx_1, 0))
        self.connect((self.fft_vxx_1, 0), (self.gr_vector_to_stream_0, 0))
Example #12
0
    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()
Example #13
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10000000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.random_source_x_0 = gr.vector_source_b(
            map(int, numpy.random.randint(0, 2, 1000)), True)
        self.gr_vector_to_stream_0 = gr.vector_to_stream(
            gr.sizeof_gr_complex * 1, 512)
        self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate)
        self.gr_sub_xx_0 = gr.sub_cc(512)
        self.gr_stream_to_vector_0 = gr.stream_to_vector(
            gr.sizeof_gr_complex * 1, 512)
        self.gr_file_source_1 = gr.file_source(
            gr.sizeof_gr_complex * 512,
            "/home/traviscollins/git/BLISS/Matlab/Spectral_Subtraction/hilbert.txt",
            True)
        self.gr_file_source_0 = gr.file_source(
            gr.sizeof_float * 1,
            "/home/traviscollins/git/BLISS/Matlab/Spectral_Subtraction/INPUT.txt",
            True)
        self.gr_file_sink_0 = gr.file_sink(
            gr.sizeof_float * 1,
            "/home/traviscollins/git/BLISS/Matlab/Spectral_Subtraction/OUTPUT.txt"
        )
        self.gr_file_sink_0.set_unbuffered(False)
        self.gr_add_xx_0 = gr.add_vcc(1)
        self.fft_vxx_1 = fft.fft_vcc(512, False, (window.blackmanharris(1024)),
                                     True, 1)
        self.fft_vxx_0 = fft.fft_vcc(512, True, (window.blackmanharris(1024)),
                                     True, 1)
        self.digital_ofdm_mod_0 = grc_blks2.packet_mod_f(
            digital.ofdm_mod(options=grc_blks2.options(
                modulation="bpsk",
                fft_length=512,
                occupied_tones=200,
                cp_length=128,
                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="bpsk",
                    fft_length=512,
                    occupied_tones=200,
                    cp_length=128,
                    snr=10,
                    log=None,
                    verbose=None,
                ),
                callback=lambda ok, payload: self.digital_ofdm_demod_0.
                recv_pkt(ok, payload),
            ), )
        self.digital_dxpsk_mod_0 = digital.dbpsk_mod(samples_per_symbol=2,
                                                     excess_bw=0.35,
                                                     gray_coded=True,
                                                     verbose=False,
                                                     log=False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_file_source_0, 0), (self.digital_ofdm_mod_0, 0))
        self.connect((self.digital_ofdm_demod_0, 0), (self.gr_file_sink_0, 0))
        self.connect((self.gr_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.random_source_x_0, 0),
                     (self.digital_dxpsk_mod_0, 0))
        self.connect((self.digital_ofdm_mod_0, 0), (self.gr_add_xx_0, 0))
        self.connect((self.digital_dxpsk_mod_0, 0), (self.gr_add_xx_0, 1))
        self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.gr_stream_to_vector_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.gr_sub_xx_0, 0))
        self.connect((self.gr_file_source_1, 0), (self.gr_sub_xx_0, 1))
        self.connect((self.gr_vector_to_stream_0, 0),
                     (self.digital_ofdm_demod_0, 0))
        self.connect((self.gr_vector_to_stream_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.gr_add_xx_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.gr_sub_xx_0, 0), (self.fft_vxx_1, 0))
        self.connect((self.fft_vxx_1, 0), (self.gr_vector_to_stream_0, 0))
 def test_sub_cc_1 (self):
     src1_data       = (2-2j,  1-1j,    -8+0j, -3-7j, -4+2j, 5+5j)
     expected_result = (-2+2j, -1+1j, 8+0j, 3+7j, 4-2j, -5-5j)
     op = gr.sub_cc (1)
     self.help_cc ((src1_data,),
                   expected_result, op, port_prefix='SINGLE_PORT')
Example #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,
                                 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()
    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()
Example #17
0
    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()