コード例 #1
0
ファイル: Lime_Auto_Fast.py プロジェクト: sdrpower2/LimeAuto
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Lime Auto Fast")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 50e3

        ##################################################
        # Blocks
        ##################################################
        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.limesdr_source_0 = limesdr.source('', 0, '')
        self.limesdr_source_0.set_sample_rate(samp_rate)
        self.limesdr_source_0.set_center_freq(393.5e6, 0)
        self.limesdr_source_0.set_bandwidth(5e6, 0)
        self.limesdr_source_0.set_gain(39, 0)
        self.limesdr_source_0.set_antenna(3, 0)
        self.limesdr_source_0.calibrate(5e6, 0)

        self.facsink_0 = facsink.fac_sink_c(
            self.GetWin(),
            title='Fast AutoCorrelation',
            sample_rate=samp_rate,
            baseband_freq=0,
            y_per_div=5,
            ref_level=-40,
            fac_size=65536,
            fac_rate=facsink.default_fac_rate,
            average=True,
            avg_alpha=0.3,
            peak_hold=True,
        )
        self.Add(self.facsink_0.win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.limesdr_source_0, 0), (self.facsink_0, 0))
        self.connect((self.limesdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
コード例 #2
0
ファイル: usrp_fac.py プロジェクト: Analias/gr-baz
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        self.frame = frame
        self.panel = panel
        
        parser = OptionParser(option_class=eng_option)
        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("-d", "--decim", type="int", default=16,
                          help="set fgpa decimation rate to DECIM [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("-W", "--waterfall", action="store_true", default=False,
                          help="Enable waterfall display")
        parser.add_option("-8", "--width-8", action="store_true", default=False,
                          help="Enable 8-bit samples across USB")
        parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
                          help="Enable oscilloscope display")
        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            sys.exit(1)

        self.show_debug_info = True
        
        # build the graph

        self.u = usrp.source_c(decim_rate=options.decim)
        if options.rx_subdev_spec is None:
            options.rx_subdev_spec = pick_subdevice(self.u)
        self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec))

        if options.width_8:
            width = 8
            shift = 8
            format = self.u.make_format(width, shift)
            print "format =", hex(format)
            r = self.u.set_format(format)
            print "set_format =", r
            
        # determine the daughterboard subdevice we're using
        self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec)

        input_rate = self.u.adc_freq() / self.u.decim_rate()

        if options.waterfall:
            self.scope = \
              waterfallsink2.waterfall_sink_c (panel, fft_size=1024, sample_rate=input_rate, title = "Waterfall")
        elif options.oscilloscope:
            self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate, title = "Scope" )
        else:
            self.scope = fftsink2.fft_sink_c (panel, fft_size=512, sample_rate=input_rate, title = "FFT")
        self.connect(self.u, self.scope)


        # setup fac sink...  Main FFT Size determined here...
        self.fac = facsink.fac_sink_c (panel, fac_size=32768, sample_rate=input_rate, title = "Auto Correlation")
        self.connect(self.u, self.fac)


        self._build_gui(vbox)

        # set initial values

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

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

        self.set_gain(options.gain)

        if self.show_debug_info:
            self.myform['decim'].set_value(self.u.decim_rate())
            self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate())
            self.myform['dbname'].set_value(self.subdev.name())
            self.myform['baseband'].set_value(0)
            self.myform['ddc'].set_value(0)

        if not(self.set_freq(options.freq)):
            self._set_status_msg("Failed to set initial frequency")
コード例 #3
0
ファイル: top_block.py プロジェクト: ROONOCERUS/gr-radar
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.decim = decim = 64
        self._config_xlate_offset_config = ConfigParser.ConfigParser()
        self._config_xlate_offset_config.read(".grc_udp_fac")
        try:
            config_xlate_offset = self._config_xlate_offset_config.getfloat(
                "main", "xlate_offset")
        except:
            config_xlate_offset = 0
        self.config_xlate_offset = config_xlate_offset
        self.adc_rate = adc_rate = 64000000
        self.xlate_offset_fine = xlate_offset_fine = 0
        self.xlate_offset = xlate_offset = config_xlate_offset
        self.xlate_decim = xlate_decim = 4
        self.xlate_bandwidth = xlate_bandwidth = 250000
        self.samp_rate = samp_rate = adc_rate / decim
        self._config_xlate_bandwidth_config = ConfigParser.ConfigParser()
        self._config_xlate_bandwidth_config.read(".grc_udp_fac")
        try:
            config_xlate_bandwidth = self._config_xlate_bandwidth_config.getfloat(
                "main", "xlate_bandwidth")
        except:
            config_xlate_bandwidth = 250000
        self.config_xlate_bandwidth = config_xlate_bandwidth
        self.baseband_rate = baseband_rate = 250000

        ##################################################
        # Blocks
        ##################################################
        self.main_notebook = self.main_notebook = wx.Notebook(self.GetWin(),
                                                              style=wx.NB_TOP)
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "BB")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "Demod")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Xtra")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "FAC")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "Waterfall")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Quad")
        self.Add(self.main_notebook)
        _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_offset_fine_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(0).GetWin(),
            sizer=_xlate_offset_fine_sizer,
            value=self.xlate_offset_fine,
            callback=self.set_xlate_offset_fine,
            label="Fine Offset",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._xlate_offset_fine_slider = forms.slider(
            parent=self.main_notebook.GetPage(0).GetWin(),
            sizer=_xlate_offset_fine_sizer,
            value=self.xlate_offset_fine,
            callback=self.set_xlate_offset_fine,
            minimum=-10000,
            maximum=10000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_offset_fine_sizer)
        self._xlate_offset_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(0).GetWin(),
            value=self.xlate_offset,
            callback=self.set_xlate_offset,
            label="Xlate Offset",
            converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._xlate_offset_text_box)
        _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_bandwidth_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(0).GetWin(),
            sizer=_xlate_bandwidth_sizer,
            value=self.xlate_bandwidth,
            callback=self.set_xlate_bandwidth,
            label="Xlate BW",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._xlate_bandwidth_slider = forms.slider(
            parent=self.main_notebook.GetPage(0).GetWin(),
            sizer=_xlate_bandwidth_sizer,
            value=self.xlate_bandwidth,
            callback=self.set_xlate_bandwidth,
            minimum=12500,
            maximum=500000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_bandwidth_sizer)
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ("0.0.0.0", 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(
            target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.main_notebook.GetPage(4).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=250000,
            fft_size=512,
            fft_rate=25,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
        )
        self.main_notebook.GetPage(4).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_0_1 = scopesink2.scope_sink_f(
            self.main_notebook.GetPage(5).GetWin(),
            title="Scope Plot",
            sample_rate=250000,
            v_scale=10,
            v_offset=0,
            t_scale=.001,
            ac_couple=True,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.main_notebook.GetPage(5).Add(self.wxgui_scopesink2_0_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.main_notebook.GetPage(1).GetWin(),
            title="Scope Plot",
            sample_rate=250000,
            v_scale=10,
            v_offset=0,
            t_scale=.001,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.main_notebook.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.main_notebook.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=250000,
            fft_size=1024,
            fft_rate=30,
            average=True,
            avg_alpha=.25,
            title="FFT Plot",
            peak_hold=False,
        )
        self.main_notebook.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
            self.main_notebook.GetPage(2).GetWin(),
            title="Constellation Plot",
            sample_rate=54000,
            frame_rate=15,
            const_size=2048,
            M=4,
            theta=.785398,
            loop_bw=5 / 100.0,
            fmax=0.06,
            mu=0.5,
            gain_mu=0.005,
            symbol_rate=18000,
            omega_limit=0.005,
        )
        self.main_notebook.GetPage(2).Add(self.wxgui_constellationsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=54000,
            decimation=250000,
            taps=None,
            fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            xlate_decim,
            (firdes.low_pass(1, samp_rate, xlate_bandwidth / 2, 1000)),
            xlate_offset + xlate_offset_fine, samp_rate)
        self.facsink_0 = facsink.fac_sink_c(
            self.main_notebook.GetPage(3).GetWin(),
            title="Fast AutoCorrelation",
            sample_rate=samp_rate,
            baseband_freq=0,
            y_per_div=10,
            ref_level=50,
            fac_size=131072,
            fac_rate=facsink.default_fac_rate,
            average=True,
            avg_alpha=0,
            peak_hold=False,
        )
        self.main_notebook.GetPage(3).Add(self.facsink_0.win)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_short * 1, 2)
        self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex(
            False, False)
        self.baz_udp_source_0 = baz.udp_source(gr.sizeof_short * 2, "0.0.0.0",
                                               28888, 16384, True, True, True,
                                               True)
        self._baseband_rate_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.baseband_rate,
            callback=self.set_baseband_rate,
            label="BB Rate",
            converter=forms.float_converter(),
        )
        self.Add(self._baseband_rate_static_text)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.wxgui_scopesink2_0_1, 0))
        self.connect((self.baz_udp_source_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_interleaved_short_to_complex_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_interleaved_short_to_complex_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.facsink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.wxgui_constellationsink2_0, 0))
コード例 #4
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.variable_0 = variable_0 = 0
        self.samp_rate = samp_rate = 1e6
        self.delay = delay = 0
        self.channel_freq = channel_freq = 790e6
        self.center_freq = center_freq = 790e6

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(400e6, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(0, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.facsink_0 = facsink.fac_sink_c(
            self.GetWin(),
            title="Fast AutoCorrelation",
            sample_rate=samp_rate,
            baseband_freq=400e6,
            y_per_div=10,
            ref_level=50,
            fac_size=512,
            fac_rate=facsink.default_fac_rate,
            average=False,
            avg_alpha=0,
            peak_hold=False,
        )
        self.Add(self.facsink_0.win)
        _delay_sizer = wx.BoxSizer(wx.VERTICAL)
        self._delay_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_delay_sizer,
            value=self.delay,
            callback=self.set_delay,
            label='delay',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._delay_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_delay_sizer,
            value=self.delay,
            callback=self.set_delay,
            minimum=0,
            maximum=128,
            num_steps=128,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_delay_sizer)
        _channel_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._channel_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_channel_freq_sizer,
            value=self.channel_freq,
            callback=self.set_channel_freq,
            label='channel_freq',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._channel_freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_channel_freq_sizer,
            value=self.channel_freq,
            callback=self.set_channel_freq,
            minimum=780e6,
            maximum=3000e6,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_channel_freq_sizer)
        _center_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._center_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_center_freq_sizer,
            value=self.center_freq,
            callback=self.set_center_freq,
            label='center_freq',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._center_freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_center_freq_sizer,
            value=self.center_freq,
            callback=self.set_center_freq,
            minimum=780e6,
            maximum=3000e6,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_center_freq_sizer)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_0, 0), (self.facsink_0, 0))
コード例 #5
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e5
        self.freq = freq = 500e06

        ##################################################
        # Blocks
        ##################################################
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	label='freq',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	minimum=400e06,
        	maximum=600e06,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freq_sizer)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=-100,
        	maxval=100,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Number Plot",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.fft_vxx_0_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 1)
        self.facsink_0 = facsink.fac_sink_c(
        	self.GetWin(),
        	title="Fast AutoCorrelation",
        	sample_rate=samp_rate,
        	baseband_freq=freq,
                y_per_div=10,
        	ref_level=50,
        	fac_size=512,
                fac_rate=facsink.default_fac_rate,
                average=False,
        	avg_alpha=0,
        	peak_hold=False,
        )
        self.Add(self.facsink_0.win)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 1024)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 1024)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, "/home/nitr/Sagnik/gnuradio_data/cyclo_2.dat", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_real_1_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.baz_delay_0_0 = baz.delay(gr.sizeof_gr_complex*1, 1)
        self.baz_delay_0 = baz.delay(gr.sizeof_gr_complex*1, -1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.baz_delay_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.baz_delay_0_0, 0), (self.blocks_stream_to_vector_0_0, 0))    
        self.connect((self.blocks_complex_to_real_1, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blocks_complex_to_real_1_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_conjugate_cc_0, 0), (self.baz_delay_0_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_real_1, 0))    
        self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_complex_to_real_1_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.baz_delay_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_conjugate_cc_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.facsink_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.fft_vxx_0_0, 0), (self.blocks_vector_to_stream_0_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))    
コード例 #6
0
ファイル: usrp_fac.py プロジェクト: luwangg/gr-Baudline
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        self.frame = frame
        self.panel = panel

        parser = OptionParser(option_class=eng_option)
        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(
            "-d",
            "--decim",
            type="int",
            default=16,
            help="set fgpa decimation rate to DECIM [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("-W",
                          "--waterfall",
                          action="store_true",
                          default=False,
                          help="Enable waterfall display")
        parser.add_option("-8",
                          "--width-8",
                          action="store_true",
                          default=False,
                          help="Enable 8-bit samples across USB")
        parser.add_option("-S",
                          "--oscilloscope",
                          action="store_true",
                          default=False,
                          help="Enable oscilloscope display")
        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            sys.exit(1)

        self.show_debug_info = True

        # build the graph

        self.u = usrp.source_c(decim_rate=options.decim)
        if options.rx_subdev_spec is None:
            options.rx_subdev_spec = pick_subdevice(self.u)
        self.u.set_mux(
            usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec))

        if options.width_8:
            width = 8
            shift = 8
            format = self.u.make_format(width, shift)
            print "format =", hex(format)
            r = self.u.set_format(format)
            print "set_format =", r

        # determine the daughterboard subdevice we're using
        self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec)

        input_rate = self.u.adc_freq() / self.u.decim_rate()

        if options.waterfall:
            self.scope = \
              waterfallsink2.waterfall_sink_c (panel, fft_size=1024, sample_rate=input_rate, title = "Waterfall")
        elif options.oscilloscope:
            self.scope = scopesink2.scope_sink_c(panel,
                                                 sample_rate=input_rate,
                                                 title="Scope")
        else:
            self.scope = fftsink2.fft_sink_c(panel,
                                             fft_size=512,
                                             sample_rate=input_rate,
                                             title="FFT")
        self.connect(self.u, self.scope)

        # setup fac sink...  Main FFT Size determined here...
        self.fac = facsink.fac_sink_c(panel,
                                      fac_size=32768,
                                      sample_rate=input_rate,
                                      title="Auto Correlation")
        self.connect(self.u, self.fac)

        self._build_gui(vbox)

        # set initial values

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

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

        self.set_gain(options.gain)

        if self.show_debug_info:
            self.myform['decim'].set_value(self.u.decim_rate())
            self.myform['fs@usb'].set_value(self.u.adc_freq() /
                                            self.u.decim_rate())
            self.myform['dbname'].set_value(self.subdev.name())
            self.myform['baseband'].set_value(0)
            self.myform['ddc'].set_value(0)

        if not (self.set_freq(options.freq)):
            self._set_status_msg("Failed to set initial frequency")