[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss-gnuradio] Re: Wav transmitter / intro to Tx with USRP
From: |
Eric Blossom |
Subject: |
[Discuss-gnuradio] Re: Wav transmitter / intro to Tx with USRP |
Date: |
Thu, 8 Jun 2006 10:19:30 -0700 |
User-agent: |
Mutt/1.5.9i |
On Thu, Jun 08, 2006 at 01:23:23AM -0500, Brett L Trotter wrote:
> I've got a copy of dsb_tx and tx_am here, if I took my stereo 16bit
> signed PCM 48kHz wav file and ran it through sox and turned it into a
> 48khz mono raw file (no headers), what would I need to do to transmit it
> with either of those scripts/programs? Change the sample rate in tx_am
> to 48000? Does it read in at 16 bit or 8 bit?
The output of the DRM transmitter is probably complex baseband.
That's most like the reason for the "stereo" wav file. Can you
confirm this?
Also, you'll want a much more recent starting point than dbs_tx and
tx_am. They were removed from the tarballs and CVS about a year ago.
I suggest working either from the latest tarballs or CVS.
For setting up the USRP for transmitting, you'll need boilerplate that
looks approximately like this (based on code in fm_tx4.py):
class fm_tx_graph (stdgui.gui_flow_graph):
def __init__(self, frame, panel, vbox, argv):
stdgui.gui_flow_graph.__init__ (self, frame, panel, vbox, argv)
parser = OptionParser (option_class=eng_option)
parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
help="select USRP Tx side A or B")
parser.add_option("-f", "--freq", type="eng_float", default=None,
help="set Tx frequency to FREQ [required]",
metavar="FREQ")
(options, args) = parser.parse_args ()
if len(args) != 0:
parser.print_help()
sys.exit(1)
if options.freq is None:
sys.stderr.write("fm_tx4: must specify frequency with -f FREQ\n")
parser.print_help()
sys.exit(1)
# ----------------------------------------------------------------
# Set up constants and parameters
self.u = usrp.sink_c () # the USRP sink (consumes samples)
self.dac_rate = self.u.dac_rate() # 128 MS/s
self.usrp_interp = XXX # FIXME
self.u.set_interp_rate(self.usrp_interp)
self.usrp_rate = self.dac_rate / self.usrp_interp
# determine the daughterboard subdevice we're using
if options.tx_subdev_spec is None:
options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u)
m = usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec)
#print "mux = %#04x" % (m,)
self.u.set_mux(m)
self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec)
print "Using TX d'board %s" % (self.subdev.side_and_name(),)
self.subdev.set_gain(self.subdev.gain_range()[1]) # set max Tx gain
self.set_freq(options.freq)
self.subdev.set_enable(True) # enable
transmitter
# ---- more code goes here
You'll need to interpolate from 48kS/sec to 128MS/sec.
It's not an integer ratio, so we'll proceed like this.
address@hidden ~]$ factor 128000000
128000000: 2 2 2 2 2 2 2 2 2 2 2 2 2 5 5 5 5 5 5
address@hidden ~]$ factor 48000
48000: 2 2 2 2 2 2 2 3 5 5 5
128e6 = 2^13 * 5^6
48e3 = 2^7 * 3 * 5^3
Dividing:
2^13 * 5^6 2^6 * 5^3
-------------- = -----------
2^7 * 3 * 5^3 3
We'll split this between the FPGA and the software rational resampler.
The FPGA intepolation factor is constrained as follows (from usrp_standard.h):
/*!
* \brief Set interpolator rate. \p rate must be in [4, 512] and a multiple
of 4.
*
* The final complex sample rate across the USB is
* dac_freq () / interp_rate () * nchannels ()
*/
virtual bool set_interp_rate (unsigned int rate);
Thus
2^6 * 5^3 2^2 * 5^3 2^4
----------- = --------- * ----
3 1 3
So, we'll interpolate by 500 in the FPGA, and by 16/3 in software.
A quick sanity check: 48e3 * 500 * 16/3 = 128e6.
The 500 in the FPGA is easy. Just set the usrp interpolation factor
to 500. The 16/3 we get by using
rr = blks.rational_resampler_fff(fg, 16, 3)
See gnuradio-examples/python/audio/test_resampler.py
That's it for now. You'll need to confirm that the output of the DRM
tx is complex baseband. Given that info, the rest of the wiring
follows pretty straight-forwardly.
There's a block, gr.interleaved_short_to_complex(), that will convert
a stream of interleaved shorts (16-bit real, 16-bit imag) into gr_complex.
sox or something else should be able to get you that from the wave file.
Eric
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Discuss-gnuradio] Re: Wav transmitter / intro to Tx with USRP,
Eric Blossom <=