summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrondeau2009-06-17 23:36:17 +0000
committertrondeau2009-06-17 23:36:17 +0000
commit52c307d29e3b75858a73bbff56dfa4a156dee165 (patch)
tree807992f58008bfddf5a5dd8cdd86fdf8baa6feef
parent663886aaf001dea5d5eaea9822a51da36e29639b (diff)
downloadgnuradio-52c307d29e3b75858a73bbff56dfa4a156dee165.tar.gz
gnuradio-52c307d29e3b75858a73bbff56dfa4a156dee165.tar.bz2
gnuradio-52c307d29e3b75858a73bbff56dfa4a156dee165.zip
Fixing benchmark_tx to use usrp_options interface. Also changes the default power output to a normalized range to fit into new USRP model.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11228 221aa14e-8319-0410-a670-987f0aec2ac5
-rwxr-xr-xgnuradio-examples/python/digital/benchmark_tx.py63
-rw-r--r--gnuradio-examples/python/digital/transmit_path.py10
2 files changed, 37 insertions, 36 deletions
diff --git a/gnuradio-examples/python/digital/benchmark_tx.py b/gnuradio-examples/python/digital/benchmark_tx.py
index 3e3ce8a46..225d10386 100755
--- a/gnuradio-examples/python/digital/benchmark_tx.py
+++ b/gnuradio-examples/python/digital/benchmark_tx.py
@@ -30,6 +30,8 @@ import random, time, struct, sys
# 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,50 +42,52 @@ class my_top_block(gr.top_block):
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.set_interp_rate(self._interp)
+ self.u = usrp_options.create_usrp_sink(options)
+ dac_rate = self.u.dac_rate()
- # 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._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())
- # 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)
+ self.u.set_interp(self._interp)
+ self.set_auto_tr(True) # enable Auto Transmit/Receive switching
def set_freq(self, target_freq):
"""
@@ -97,24 +101,20 @@ class my_top_block(gr.top_block):
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 @@ def main():
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)
diff --git a/gnuradio-examples/python/digital/transmit_path.py b/gnuradio-examples/python/digital/transmit_path.py
index 11d370269..9badcdc08 100644
--- a/gnuradio-examples/python/digital/transmit_path.py
+++ b/gnuradio-examples/python/digital/transmit_path.py
@@ -70,10 +70,10 @@ class transmit_path(gr.hier_block2):
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 @@ class transmit_path(gr.hier_block2):
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,