def __init__(self, options): gr.top_block.__init__(self) # Create a USRP source with GPIO FPGA build, then configure u = usrp.source_s(decim_rate=options.decim, fpga_filename=gpio.fpga_filename) if options.force_complex_RXA: # This is a dirty hack to force complex mode (receive both I and Q) on basicRX or LFRX # This forces the receive board in RXA (side A) to be used # FIXME: This has as a side effect that the gain for Q is not set. So only use with gain 0 (--gain 0) options.rx_subdev_spec = (0, 0) u.set_mux(0x10) if not (0 == options.gain): print "WARNING, you should set the gain to 0 with --gain 0 when using --force-complex-RXA" print "The gain for Q will now still be zero while the gain for I is not" #options.gain=0 else: if options.rx_subdev_spec is None: options.rx_subdev_spec = usrp.pick_rx_subdevice(u) u.set_mux(usrp.determine_rx_mux_value(u, options.rx_subdev_spec)) subdev = usrp.selected_subdev(u, options.rx_subdev_spec) print "Using RX d'board %s" % (subdev.side_and_name(), ) input_rate = u.adc_freq() / u.decim_rate() print "USB sample rate %s" % (eng_notation.num_to_str(input_rate)) if options.gain is None: # if no gain was specified, use the mid-point in dB g = subdev.gain_range() options.gain = float(g[0] + g[1]) / 2 #TODO setting gain on basicRX only sets the I channel, use a second subdev to set gain of Q channel #see gnuradio-examples/multi-antenna for possible solutions subdev.set_gain(options.gain) #TODO check if freq has same problem as gain when trying to use complex mode on basicRX r = u.tune(0, subdev, options.freq) if not r: sys.stderr.write('Failed to set frequency\n') raise SystemExit, 1 # Connect pipeline src = u if options.nsamples is not None: head = gr.head(gr.sizeof_short, int(options.nsamples) * 2) self.connect(u, head) src = head ana_strip = gr.and_const_ss(0xFFFE) dig_strip = gr.and_const_ss(0x0001) ana_sink = gr.file_sink(gr.sizeof_short, options.ana_filename) dig_sink = gr.file_sink(gr.sizeof_short, options.dig_filename) self.connect(src, ana_strip, ana_sink) self.connect(src, dig_strip, dig_sink)
def __init__(self, options): gr.top_block.__init__(self) # Create a USRP source with GPIO FPGA build, then configure u = usrp.source_s(decim_rate=options.decim, fpga_filename=gpio.fpga_filename) if options.force_complex_RXA: # This is a dirty hack to force complex mode (receive both I and Q) on basicRX or LFRX # This forces the receive board in RXA (side A) to be used # FIXME: This has as a side effect that the gain for Q is not set. So only use with gain 0 (--gain 0) options.rx_subdev_spec = (0, 0) u.set_mux(0x10) if not (0 == options.gain): print "WARNING, you should set the gain to 0 with --gain 0 when using --force-complex-RXA" print "The gain for Q will now still be zero while the gain for I is not" # options.gain=0 else: if options.rx_subdev_spec is None: options.rx_subdev_spec = usrp.pick_rx_subdevice(u) u.set_mux(usrp.determine_rx_mux_value(u, options.rx_subdev_spec)) subdev = usrp.selected_subdev(u, options.rx_subdev_spec) print "Using RX d'board %s" % (subdev.side_and_name(),) input_rate = u.adc_freq() / u.decim_rate() print "USB sample rate %s" % (eng_notation.num_to_str(input_rate)) if options.gain is None: # if no gain was specified, use the mid-point in dB g = subdev.gain_range() options.gain = float(g[0] + g[1]) / 2 # TODO setting gain on basicRX only sets the I channel, use a second subdev to set gain of Q channel # see gnuradio-examples/multi-antenna for possible solutions subdev.set_gain(options.gain) # TODO check if freq has same problem as gain when trying to use complex mode on basicRX r = u.tune(0, subdev, options.freq) if not r: sys.stderr.write("Failed to set frequency\n") raise SystemExit, 1 # Connect pipeline src = u if options.nsamples is not None: head = gr.head(gr.sizeof_short, int(options.nsamples) * 2) self.connect(u, head) src = head ana_strip = gr.and_const_ss(0xFFFE) dig_strip = gr.and_const_ss(0x0001) ana_sink = gr.file_sink(gr.sizeof_short, options.ana_filename) dig_sink = gr.file_sink(gr.sizeof_short, options.dig_filename) self.connect(src, ana_strip, ana_sink) self.connect(src, dig_strip, dig_sink)
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( "-w", "--which", type="int", default=0, help="select which USRP (0, 1, ...) default is %default", metavar="NUM") # parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, # help="select USRP Rx side A or B (default=first one with a daughterboard)") parser.add_option("-A", "--antenna", default=None, help="select Rx Antenna (only on RFX-series boards)") parser.add_option( "-d", "--decim", type="int", default=32, help="set fgpa decimation rate to DECIM [default=%default]") parser.add_option("-f", "--freq", type="eng_float", default=0.0, 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( "--no-hb", action="store_true", default=False, # help="don't use halfband filter in usrp") parser.add_option("-S", "--oscilloscope", action="store_true", default=False, help="Enable oscilloscope display (default)") parser.add_option("-F", "--fft", action="store_true", default=False, help="Enable FFT display") parser.add_option( "-n", "--frame-decim", type="int", default=1, help="set oscope frame decimation factor to n [default=1]") parser.add_option( "-v", "--v-scale", type="eng_float", default=1, help="set oscope initial V/div to SCALE [default=%default]") parser.add_option( "-t", "--t-scale", type="eng_float", default=10e-6, help="set oscope initial s/div to SCALE [default=10us]") parser.add_option( "--digital", action="store_true", default=False, help= "show (only) the digital wave on lsb (will be input from gpio pins with special usrp firmware)" ) parser.add_option( "--analog", action="store_true", default=False, help= "show (only) the analog wave on msbs (will be input from analog inputs)" ) parser.add_option( "--file", default=None, help= "input from file FILE in stead of USRP (will be input from raw file in interleaved short format)" ) (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.options = options self.show_debug_info = True self.u = usrp.source_s(which=options.which, decim_rate=options.decim, fpga_filename=gpio.fpga_filename) print "Warning: This script only supports boards on RXA, change the script if you want otherwise" #options.rx_subdev_spec=(0, 0)#force the use of RXA options.rx_subdev_spec = None #force the use of RXA if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(self.u) #This hardcoded mux setting is why this script only supports RXA #We want both I and Q active, even when using basicRX #set to 0x10 for RXA #set to 0x32 for RXB self.u.set_mux( 0x10 ) #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) #if options.rx_subdev_spec==(0,0): # rx_subdev_spec2=(0,1) # self.subdev2 = usrp.selected_subdev(self.u, rx_subdev_spec2) 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) elif options.fft: self.scope = fftsink2.fft_sink_c(panel, fft_size=1024, sample_rate=input_rate) else: # options.oscilloscope: #self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate) self.scope = scopesink2.scope_sink_c( panel, sample_rate=input_rate, frame_decim=options.frame_decim, v_scale=options.v_scale, t_scale=options.t_scale) self.is2c = gr.interleaved_short_to_complex() if not (options.file is None): self.filesrc = gr.file_source(gr.sizeof_short, options.file, True) thr = gr.throttle(gr.sizeof_short, input_rate) self.connect(self.filesrc, thr, self.is2c, self.scope) elif options.digital: self.select_dig = gr.and_const_ss(0x0001) self.connect(self.u, self.select_dig, self.is2c, self.scope) elif options.analog: self.select_ana = gr.and_const_ss(0xFFFE) self.connect(self.u, self.select_ana, self.is2c, self.scope) else: self.connect(self.u, self.is2c, self.scope) self._build_gui(vbox) self._setup_events() # 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 options.antenna is not None: print "Selecting antenna %s" % (options.antenna, ) self.subdev.select_rx_antenna(options.antenna) 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")
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("-w", "--which", type="int", default=0, help="select which USRP (0, 1, ...) default is %default", metavar="NUM") # parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, # help="select USRP Rx side A or B (default=first one with a daughterboard)") parser.add_option("-A", "--antenna", default=None, help="select Rx Antenna (only on RFX-series boards)") parser.add_option("-d", "--decim", type="int", default=32, help="set fgpa decimation rate to DECIM [default=%default]") parser.add_option("-f", "--freq", type="eng_float", default=0.0, 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( "--no-hb", action="store_true", default=False, # help="don't use halfband filter in usrp") parser.add_option("-S", "--oscilloscope", action="store_true", default=False, help="Enable oscilloscope display (default)") parser.add_option("-F", "--fft", action="store_true", default=False, help="Enable FFT display") parser.add_option("-n", "--frame-decim", type="int", default=1, help="set oscope frame decimation factor to n [default=1]") parser.add_option("-v", "--v-scale", type="eng_float", default=1, help="set oscope initial V/div to SCALE [default=%default]") parser.add_option("-t", "--t-scale", type="eng_float", default=10e-6, help="set oscope initial s/div to SCALE [default=10us]") parser.add_option ("--digital", action="store_true", default=False, help="show (only) the digital wave on lsb (will be input from gpio pins with special usrp firmware)") parser.add_option ("--analog", action="store_true", default=False, help="show (only) the analog wave on msbs (will be input from analog inputs)") parser.add_option ("--file", default=None, help="input from file FILE in stead of USRP (will be input from raw file in interleaved short format)") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.options = options self.show_debug_info = True self.u = usrp.source_s(which=options.which, decim_rate=options.decim, fpga_filename=gpio.fpga_filename) print "Warning: This script only supports boards on RXA, change the script if you want otherwise" #options.rx_subdev_spec=(0, 0)#force the use of RXA options.rx_subdev_spec=None #force the use of RXA if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(self.u) #This hardcoded mux setting is why this script only supports RXA #We want both I and Q active, even when using basicRX #set to 0x10 for RXA #set to 0x32 for RXB self.u.set_mux(0x10) #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) #if options.rx_subdev_spec==(0,0): # rx_subdev_spec2=(0,1) # self.subdev2 = usrp.selected_subdev(self.u, rx_subdev_spec2) 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) elif options.fft: self.scope = fftsink2.fft_sink_c (panel, fft_size=1024, sample_rate=input_rate) else: # options.oscilloscope: #self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate) self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate, frame_decim=options.frame_decim, v_scale=options.v_scale, t_scale=options.t_scale) self.is2c = gr.interleaved_short_to_complex() if not (options.file is None): self.filesrc=gr.file_source(gr.sizeof_short, options.file, True) thr = gr.throttle(gr.sizeof_short, input_rate) self.connect(self.filesrc,thr,self.is2c,self.scope) elif options.digital: self.select_dig=gr.and_const_ss(0x0001) self.connect(self.u, self.select_dig,self.is2c,self.scope) elif options.analog: self.select_ana=gr.and_const_ss(0xFFFE) self.connect(self.u, self.select_ana,self.is2c,self.scope) else: self.connect(self.u,self.is2c,self.scope) self._build_gui(vbox) self._setup_events() # 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 options.antenna is not None: print "Selecting antenna %s" % (options.antenna,) self.subdev.select_rx_antenna(options.antenna) 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")