commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r11228 - gnuradio/trunk/gnuradio-examples/python/digit


From: trondeau
Subject: [Commit-gnuradio] r11228 - gnuradio/trunk/gnuradio-examples/python/digital
Date: Wed, 17 Jun 2009 17:36:17 -0600 (MDT)

Author: trondeau
Date: 2009-06-17 17:36:17 -0600 (Wed, 17 Jun 2009)
New Revision: 11228

Modified:
   gnuradio/trunk/gnuradio-examples/python/digital/benchmark_tx.py
   gnuradio/trunk/gnuradio-examples/python/digital/transmit_path.py
Log:
Fixing benchmark_tx to use usrp_options interface. Also changes the default 
power output to a normalized range to fit into new USRP model.

Modified: gnuradio/trunk/gnuradio-examples/python/digital/benchmark_tx.py
===================================================================
--- gnuradio/trunk/gnuradio-examples/python/digital/benchmark_tx.py     
2009-06-17 23:33:10 UTC (rev 11227)
+++ gnuradio/trunk/gnuradio-examples/python/digital/benchmark_tx.py     
2009-06-17 23:36:17 UTC (rev 11228)
@@ -30,6 +30,8 @@
 
 # from current dir
 from transmit_path import transmit_path
+from pick_bitrate import pick_tx_bitrate
+import usrp_options
 
 #import os 
 #print os.getpid()
@@ -40,51 +42,53 @@
         gr.top_block.__init__(self)
 
         self._tx_freq            = options.tx_freq         # tranmitter's 
center frequency
-        self._tx_subdev_spec     = options.tx_subdev_spec  # daughterboard to 
use
         self._interp             = options.interp          # interpolating 
rate for the USRP (prelim)
+        self._bitrate            = options.bitrate
+        self._samples_per_symbol = options.samples_per_symbol
+        self._modulator_class    = modulator
 
         if self._tx_freq is None:
             sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be 
specified\n")
             raise SystemExit
 
         # Set up USRP sink; also adjusts interp, and bitrate
-        self._setup_usrp_sink()
+        self._setup_usrp_sink(options)
 
         # copy the final answers back into options for use by modulator
-        #options.bitrate = self._bitrate
+        options.samples_per_symbol = self._samples_per_symbol
+        options.bitrate = self._bitrate
+        options.interp = self._interp
 
+        # Set center frequency of USRP
+        ok = self.set_freq(self._tx_freq)
+        if not ok:
+            print "Failed to set Tx frequency to %s" % 
(eng_notation.num_to_str(self._tx_freq),)
+            raise ValueError
+
+        # Set the USRP for maximum transmit gain
+        # (Note that on the RFX cards this is a nop.)
+        self.set_gain(self.u.gain_range()[1])
+
         self.txpath = transmit_path(modulator, options)
 
         self.connect(self.txpath, 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.u = usrp_options.create_usrp_sink(options)
+        dac_rate = self.u.dac_rate()
 
-        self.u.set_interp_rate(self._interp)
+        (self._bitrate, self._samples_per_symbol, self._interp) = \
+                        pick_tx_bitrate(self._bitrate, 
self._modulator_class.bits_per_symbol(), \
+                                        self._samples_per_symbol, 
self._interp, dac_rate, \
+                                        self.u.get_interp_rates())
 
-        # 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)
+        self.u.set_interp(self._interp)
+        self.set_auto_tr(True)                 # enable Auto Transmit/Receive 
switching
 
-        # Set center frequency of USRP
-        ok = self.set_freq(self._tx_freq)
-        if not ok:
-            print "Failed to set Tx frequency to %s" % 
(eng_notation.num_to_str(self._tx_freq),)
-            raise ValueError
-
-        # 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])
-
-        # enable Auto Transmit/Receive switching
-        self.set_auto_tr(True)
-
     def set_freq(self, target_freq):
         """
         Set the center frequency we're interested in.
@@ -97,24 +101,20 @@
         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 self.u.set_center_freq(target_freq)
 
-        return False
-        
     def set_gain(self, gain):
         """
         Sets the analog gain in the USRP
         """
         self.gain = gain
-        self.subdev.set_gain(gain)
+        self.u.set_gain(gain)
 
     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)
+        return self.u.set_auto_tr(enable)
         
     def interp(self):
         return self._interp
@@ -193,6 +193,7 @@
 
     my_top_block.add_options(parser, expert_grp)
     transmit_path.add_options(parser, expert_grp)
+    usrp_options.add_tx_options(parser)
 
     for mod in mods.values():
         mod.add_options(expert_grp)

Modified: gnuradio/trunk/gnuradio-examples/python/digital/transmit_path.py
===================================================================
--- gnuradio/trunk/gnuradio-examples/python/digital/transmit_path.py    
2009-06-17 23:33:10 UTC (rev 11227)
+++ gnuradio/trunk/gnuradio-examples/python/digital/transmit_path.py    
2009-06-17 23:36:17 UTC (rev 11228)
@@ -70,10 +70,10 @@
 
     def set_tx_amplitude(self, ampl):
         """
-        Sets the transmit amplitude sent to the USRP
-        @param: ampl 0 <= ampl < 32768.  Try 8000
+        Sets the transmit amplitude sent to the USRP in volts
+        @param: ampl 0 <= ampl < 1.
         """
-        self._tx_amplitude = max(0.0, min(ampl, 32767.0))
+        self._tx_amplitude = max(0.0, min(ampl, 1))
         self.amp.set_k(self._tx_amplitude)
         
     def send_pkt(self, payload='', eof=False):
@@ -95,8 +95,8 @@
         if not normal.has_option('--bitrate'):
             normal.add_option("-r", "--bitrate", type="eng_float", 
default=100e3,
                               help="specify bitrate [default=%default].")
-        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("", "--tx-amplitude", type="eng_float", 
default=0.250, metavar="AMPL",
+                          help="set transmitter digital amplitude: 0 <= AMPL < 
1 [default=%default]")
         normal.add_option("-v", "--verbose", action="store_true", 
default=False)
 
         expert.add_option("-S", "--samples-per-symbol", type="int", default=2,





reply via email to

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