commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r10903 - gnuradio/branches/developers/jblum/digital


From: jblum
Subject: [Commit-gnuradio] r10903 - gnuradio/branches/developers/jblum/digital
Date: Fri, 24 Apr 2009 13:38:00 -0600 (MDT)

Author: jblum
Date: 2009-04-24 13:38:00 -0600 (Fri, 24 Apr 2009)
New Revision: 10903

Modified:
   gnuradio/branches/developers/jblum/digital/generic_usrp.py
   gnuradio/branches/developers/jblum/digital/receive_path.py
   gnuradio/branches/developers/jblum/digital/transmit_path.py
Log:
implemented tx path with generic usrp, tested rx and tx benchmarks with usrp2

Modified: gnuradio/branches/developers/jblum/digital/generic_usrp.py
===================================================================
--- gnuradio/branches/developers/jblum/digital/generic_usrp.py  2009-04-24 
05:16:43 UTC (rev 10902)
+++ gnuradio/branches/developers/jblum/digital/generic_usrp.py  2009-04-24 
19:38:00 UTC (rev 10903)
@@ -75,6 +75,12 @@
         if self._type == USRP_TYPE: return self._subdev.gain_range()
         elif self._type == USRP2_TYPE: return self._u.gain_range()
 
+    def set_center_freq(self, target_freq):
+        if self._type == USRP_TYPE:
+            return bool(self._u.tune(self._dc, self._subdev, target_freq))
+        elif self._type == USRP2_TYPE:
+            return self._u.set_center_freq(target_freq)
+
 ########################################################################
 # generic usrp source
 ########################################################################
@@ -89,12 +95,6 @@
     def add_options(normal, expert):
         normal.add_option("-R", "--rx-subdev-spec", type="subdev", 
default=None,
                           help="select USRP Rx side A or B")
-        normal.add_option("--rx-gain", type="eng_float", default=None, 
metavar="GAIN",
-                          help="set receiver gain in dB [default=midpoint].  
See also --show-rx-gain-range")
-        normal.add_option("--show-rx-gain-range", action="store_true", 
default=False, 
-                          help="print min and max Rx gain available on 
selected daughterboard")
-        expert.add_option("-d", "--decim", type="intx", default=None,
-                          help="set fpga decimation rate to DECIM 
[default=%default]")
         add_options(normal, expert)
 
     def __init__(self, options):
@@ -110,9 +110,6 @@
         #usrp2 options
         self._interface = options.interface
         self._mac_addr = options.mac_addr
-        #generic options
-        self._rx_gain = options.rx_gain
-        self._show_rx_gain_range = options.show_rx_gain_range
 
         #pick usrp or usrp2
         if options.usrp or self._rx_subdev_spec:
@@ -123,8 +120,6 @@
             try: self._setup_usrp2_source()
             except: self._setup_usrp_source()
         self.connect(self._u, self)
-        if options.show_rx_gain_range:
-            print "Rx Gain Range: minimum = %g, maximum = %g, step size = 
%g"%tuple(self.gain_range())
 
     ####################################################################
     # generic access methods
@@ -134,12 +129,6 @@
         elif self._type == USRP2_TYPE: return self._u.set_decim(decim)
     
     def adc_rate(self): return self._u.adc_rate()
-    
-    def set_center_freq(self, target_freq):
-        if self._type == USRP_TYPE:
-            return bool(self._u.tune(0, self._subdev, target_freq))
-        elif self._type == USRP2_TYPE:
-            return self._u.set_center_freq(target_freq) or True
 
     ####################################################################
     # setup usrp methods
@@ -153,7 +142,9 @@
             self._rx_subdev_spec = usrp.pick_rx_subdevice(self._u)
         self._subdev = usrp.selected_subdev(self._u, self._rx_subdev_spec)
         self._u.set_mux(usrp.determine_rx_mux_value(self._u, 
self._rx_subdev_spec))
+        self._subdev.set_auto_tr(True)
         self._type = USRP_TYPE
+        self._dc = 0
     
     def _setup_usrp2_source(self):
         self._u = usrp2.source_32fc(self._interface, self._mac_addr)
@@ -177,12 +168,6 @@
     def add_options(normal, expert):
         normal.add_option("-T", "--tx-subdev-spec", type="subdev", 
default=None,
                           help="select USRP Tx side A or B")
-        normal.add_option("--tx-gain", type="eng_float", default=None, 
metavar="GAIN",
-                          help="set receiver gain in dB [default=midpoint].  
See also --show-tx-gain-range")
-        normal.add_option("--show-tx-gain-range", action="store_true", 
default=False, 
-                          help="print min and max Tx gain available on 
selected daughterboard")
-        expert.add_option("-i", "--interp", type="intx", default=None,
-                          help="set fpga interpolation rate to INTERP 
[default=%default]")
         add_options(normal, expert)
 
     def __init__(self, options):
@@ -198,9 +183,6 @@
         #usrp2 options
         self._interface = options.interface
         self._mac_addr = options.mac_addr
-        #generic options
-        self._tx_gain = options.tx_gain
-        self._show_tx_gain_range = options.show_tx_gain_range
 
         #pick usrp or usrp2
         if options.usrp or self._tx_subdev_spec:
@@ -211,8 +193,6 @@
             try: self._setup_usrp2_source()
             except: self._setup_usrp_source()
         self.connect(self, self._u)
-        if options.show_tx_gain_range:
-            print "Tx Gain Range: minimum = %g, maximum = %g, step size = 
%g"%tuple(self.gain_range())
 
     ####################################################################
     # generic access methods
@@ -222,13 +202,11 @@
         elif self._type == USRP2_TYPE: return self._u.set_interp(interp)
     
     def dac_rate(self): return self._u.dac_rate()
-    
-    def set_center_freq(self, target_freq):
-        if self._type == USRP_TYPE:
-            return bool(self._u.tune(self._subdev.which(), self._subdev, 
target_freq))
-        elif self._type == USRP2_TYPE:
-            return self._u.set_center_freq(target_freq)
 
+    def ampl_range(self):
+        if self._type == USRP_TYPE: return (0.0, 2.**15-1)
+        elif self._type == USRP2_TYPE: return (0.0, 1.0)
+
     ####################################################################
     # setup usrp methods
     ####################################################################
@@ -241,7 +219,9 @@
             self._tx_subdev_spec = usrp.pick_tx_subdevice(self._u)
         self._subdev = usrp.selected_subdev(self._u, self._tx_subdev_spec)
         self._u.set_mux(usrp.determine_tx_mux_value(self._u, 
self._tx_subdev_spec))
+        self._subdev.set_auto_tr(True)
         self._type = USRP_TYPE
+        self._dc = self._subdev.which()
     
     def _setup_usrp2_source(self):
         self._u = usrp2.sink_32fc(self._interface, self._mac_addr)

Modified: gnuradio/branches/developers/jblum/digital/receive_path.py
===================================================================
--- gnuradio/branches/developers/jblum/digital/receive_path.py  2009-04-24 
05:16:43 UTC (rev 10902)
+++ gnuradio/branches/developers/jblum/digital/receive_path.py  2009-04-24 
19:38:00 UTC (rev 10903)
@@ -43,16 +43,12 @@
 
         options = copy.copy(options)    # make a copy so we can destructively 
modify
 
-        self._which              = options.which           # the USRP board 
attached
         self._verbose            = options.verbose
         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._bitrate            = options.bitrate         # desired bit rate
         self._decim              = options.decim           # Decimating rate 
for the USRP (prelim)
         self._samples_per_symbol = options.samples_per_symbol  # desired 
samples/symbol
-        self._fusb_block_size    = options.fusb_block_size # usb info for USRP
-        self._fusb_nblocks       = options.fusb_nblocks    # usb info for USRP
 
         self._rx_callback   = rx_callback      # this callback is fired when 
there's a packet available
         self._demod_class   = demod_class      # the demodulator_class we're 
using
@@ -64,10 +60,11 @@
         # Set up USRP source; also adjusts decim, samples_per_symbol, and 
bitrate
         self._setup_usrp_source(options)
 
+        if options.show_rx_gain_range:
+            print "Rx Gain Range: minimum = %g, maximum = %g, step size = 
%g"%tuple(self.u.gain_range())
+
         self.set_gain(options.rx_gain)
 
-        #TODO self.set_auto_tr(True)                 # enable Auto 
Transmit/Receive switching
-
         # Set RF frequency
         ok = self.set_freq(self._rx_freq)
         if not ok:
@@ -198,6 +195,12 @@
                           help="set samples/symbol [default=%default]")
         expert.add_option("", "--rx-freq", type="eng_float", default=None,
                           help="set Rx frequency to FREQ [default=%default]", 
metavar="FREQ")
+        normal.add_option("--rx-gain", type="eng_float", default=None, 
metavar="GAIN",
+                          help="set receiver gain in dB [default=midpoint].  
See also --show-rx-gain-range")
+        normal.add_option("--show-rx-gain-range", action="store_true", 
default=False, 
+                          help="print min and max Rx gain available on 
selected daughterboard")
+        expert.add_option("-d", "--decim", type="intx", default=None,
+                          help="set fpga decimation rate to DECIM 
[default=%default]")
         expert.add_option("", "--log", action="store_true", default=False,
                           help="Log all parts of flow graph to files (CAUTION: 
lots of data)")
         expert.add_option("", "--log-rx-power", action="store_true", 
default=False,

Modified: gnuradio/branches/developers/jblum/digital/transmit_path.py
===================================================================
--- gnuradio/branches/developers/jblum/digital/transmit_path.py 2009-04-24 
05:16:43 UTC (rev 10902)
+++ gnuradio/branches/developers/jblum/digital/transmit_path.py 2009-04-24 
19:38:00 UTC (rev 10903)
@@ -28,6 +28,7 @@
 
 # from current dir
 from pick_bitrate import pick_tx_bitrate
+import generic_usrp
 
 # /////////////////////////////////////////////////////////////////////////////
 #                              transmit path
@@ -44,16 +45,12 @@
 
         options = copy.copy(options)    # make a copy so we can destructively 
modify
 
-        self._which              = options.which           # the USRP board 
attached
         self._verbose            = options.verbose
         self._tx_freq            = options.tx_freq         # tranmitter's 
center frequency
         self._tx_amplitude       = options.tx_amplitude    # digital amplitude 
sent to USRP
-        self._tx_subdev_spec     = options.tx_subdev_spec  # daughterboard to 
use
         self._bitrate            = options.bitrate         # desired bit rate
         self._interp             = options.interp          # interpolating 
rate for the USRP (prelim)
         self._samples_per_symbol = options.samples_per_symbol  # desired 
samples/baud
-        self._fusb_block_size    = options.fusb_block_size # usb info for USRP
-        self._fusb_nblocks       = options.fusb_nblocks    # usb info for USRP
         self._use_whitener_offset = options.use_whitener_offset # increment 
start of whitener XOR data
         
         self._modulator_class = modulator_class         # the modulator_class 
we are using
@@ -63,7 +60,7 @@
             raise SystemExit
 
         # Set up USRP sink; also adjusts interp, samples_per_symbol, and 
bitrate
-        self._setup_usrp_sink()
+        self._setup_usrp_sink(options)
 
         # copy the final answers back into options for use by modulator
         options.samples_per_symbol = self._samples_per_symbol
@@ -90,14 +87,11 @@
 
         # Set the USRP for maximum transmit gain
         # (Note that on the RFX cards this is a nop.)
-        self.set_gain(self.subdev.gain_range()[1])
+        self.set_gain(self.u.gain_range()[1])
 
         self.amp = gr.multiply_const_cc(1)
         self.set_tx_amplitude(self._tx_amplitude)
 
-        # enable Auto Transmit/Receive switching
-        self.set_auto_tr(True)
-
         # Display some information about the setup
         if self._verbose:
             self._print_verbage()
@@ -105,14 +99,12 @@
         # Create and setup transmit path flow graph
         self.connect(self.packet_transmitter, self.amp, self.u)
 
-    def _setup_usrp_sink(self):
+    def _setup_usrp_sink(self, options):
         """
         Creates a USRP sink, determines the settings for best bitrate,
         and attaches to the transmitter's subdevice.
         """
-        self.u = usrp.sink_c(self._which,
-                             fusb_block_size=self._fusb_block_size,
-                             fusb_nblocks=self._fusb_nblocks)
+        self.u = generic_usrp.generic_usrp_sink_c(options)
         dac_rate = self.u.dac_rate();
 
         # derive values of bitrate, samples_per_symbol, and interp from 
desired info
@@ -120,15 +112,9 @@
             pick_tx_bitrate(self._bitrate, 
self._modulator_class.bits_per_symbol(),
                             self._samples_per_symbol, self._interp, dac_rate)
         
-        self.u.set_interp_rate(self._interp)
+        self.u.set_interp(self._interp)
 
-        # determine the daughterboard subdevice we're using
-        if self._tx_subdev_spec is None:
-            self._tx_subdev_spec = usrp.pick_tx_subdevice(self.u)
-        self.u.set_mux(usrp.determine_tx_mux_value(self.u, 
self._tx_subdev_spec))
-        self.subdev = usrp.selected_subdev(self.u, self._tx_subdev_spec)
 
-
     def set_freq(self, target_freq):
         """
         Set the center frequency we're interested in.
@@ -141,33 +127,23 @@
         the result of that operation and our target_frequency to
         determine the value for the digital up converter.
         """
-        r = self.u.tune(self.subdev.which(), self.subdev, target_freq)
-        if r:
-            return True
-
-        return False
+        return self.u.set_center_freq(target_freq)
         
     def set_gain(self, gain):
         """
         Sets the analog gain in the USRP
         """
-        self.gain = gain
-        self.subdev.set_gain(gain)
+        return self.u.set_gain(gain)
 
     def set_tx_amplitude(self, ampl):
         """
         Sets the transmit amplitude sent to the USRP
         @param: ampl 0 <= ampl < 32768.  Try 8000
         """
-        self._tx_amplitude = max(0.0, min(ampl, 32767.0))
+        ampl_range = self.u.ampl_range()
+        self._tx_amplitude = max(ampl_range[0], min(ampl, ampl_range[1]))
         self.amp.set_k(self._tx_amplitude)
-        
-    def set_auto_tr(self, enable):
-        """
-        Turns on auto transmit/receive of USRP daughterboard (if exits; else 
ignored)
-        """
-        return self.subdev.set_auto_tr(enable)
-        
+
     def send_pkt(self, payload='', eof=False):
         """
         Calls the transmitter method to send a packet
@@ -191,14 +167,10 @@
         if not normal.has_option('--bitrate'):
             normal.add_option("-r", "--bitrate", type="eng_float", 
default=None,
                               help="specify bitrate.  samples-per-symbol and 
interp/decim will be derived.")
-        normal.add_option("-w", "--which", type="int", default=0,
-                          help="select USRP board [default=%default]")
-        normal.add_option("-T", "--tx-subdev-spec", type="subdev", 
default=None,
-                          help="select USRP Tx side A or B")
-        normal.add_option("", "--tx-amplitude", type="eng_float", 
default=12000, metavar="AMPL",
+        generic_usrp.generic_usrp_sink_c.add_options(normal, expert)
+        normal.add_option("--tx-amplitude", type="eng_float", default=12000, 
metavar="AMPL",
                           help="set transmitter digital amplitude: 0 <= AMPL < 
32768 [default=%default]")
         normal.add_option("-v", "--verbose", action="store_true", 
default=False)
-
         expert.add_option("-S", "--samples-per-symbol", type="int", 
default=None,
                           help="set samples/symbol [default=%default]")
         expert.add_option("", "--tx-freq", type="eng_float", default=None,
@@ -217,7 +189,7 @@
         """
         Prints information about the transmit path
         """
-        print "Using TX d'board %s"    % (self.subdev.side_and_name(),)
+        print "Using TX d'board %s"    % (self.u,)
         print "Tx amplitude     %s"    % (self._tx_amplitude)
         print "modulation:      %s"    % (self._modulator_class.__name__)
         print "bitrate:         %sb/s" % 
(eng_notation.num_to_str(self._bitrate))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]