[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8978 - gnuradio/branches/features/experimental-gui
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r8978 - gnuradio/branches/features/experimental-gui |
Date: |
Tue, 22 Jul 2008 12:23:27 -0600 (MDT) |
Author: jcorgan
Date: 2008-07-22 12:23:25 -0600 (Tue, 22 Jul 2008)
New Revision: 8978
Added:
gnuradio/branches/features/experimental-gui/tx_mpsk.py
Modified:
gnuradio/branches/features/experimental-gui/const_streamer.py
gnuradio/branches/features/experimental-gui/const_top_block.py
gnuradio/branches/features/experimental-gui/simple_usrp.py
gnuradio/branches/features/experimental-gui/usrp_const.py
Log:
wip
Modified: gnuradio/branches/features/experimental-gui/const_streamer.py
===================================================================
--- gnuradio/branches/features/experimental-gui/const_streamer.py
2008-07-22 17:30:41 UTC (rev 8977)
+++ gnuradio/branches/features/experimental-gui/const_streamer.py
2008-07-22 18:23:25 UTC (rev 8978)
@@ -55,10 +55,16 @@
gr.io_signature(1, 1, gr.sizeof_gr_complex),
# Input signature
gr.io_signature(1, 1,
gr.sizeof_gr_complex*frame_size)) # Output signature
+
+
+ costas_beta = 0.25*costas_alpha*costas_alpha
+ costas_min = -costas_max
+ mm_omega = float(sample_rate)/bit_rate
+ mm_gain_omega = 0.25*mm_gain_mu*mm_gain_mu
+ mm_mu=0.5 # Center of bit
+
# Costas frequency/phase recovery loop
# Critically damped 2nd order PLL
- costas_beta = 0.25*costas_alpha*costas_alpha
- costas_min = -costas_max
self._costas = gr.costas_loop_cc(costas_alpha,
costas_beta,
costas_max,
@@ -67,9 +73,6 @@
# Timing recovery loop
# Critically damped 2nd order DLL
- mm_omega = float(sample_rate)/bit_rate
- mm_gain_omega = 0.25*mm_gain_mu*mm_gain_mu
- mm_mu=0.5 # Center of bit
self._retime = gr.clock_recovery_mm_cc(mm_omega,
mm_gain_omega,
mm_mu,
@@ -79,13 +82,15 @@
# Scale to unity power
self._agc = gr.agc_cc(1e-6);
+ # Decimate to requested frame rate
self._decim =
blks2.stream_to_vector_decimator(item_size=gr.sizeof_gr_complex,
sample_rate=bit_rate,
vec_rate=frame_rate,
vec_len=frame_size)
- self.connect(self, self._costas, self._retime, self._agc, self._decim,
self)
+ self.connect(self, self._agc, self._costas, self._retime, self._decim,
self)
+
def set_costas_alpha(self, alpha):
self._costas.set_alpha(alpha)
@@ -108,4 +113,4 @@
self._retime.set_gain_omega(gain_omega)
def gain_omega(self):
- return self._return.gain_omega()
+ return self._retime.gain_omega()
Property changes on:
gnuradio/branches/features/experimental-gui/const_top_block.py
___________________________________________________________________
Name: svn:executable
- *
Modified: gnuradio/branches/features/experimental-gui/simple_usrp.py
===================================================================
--- gnuradio/branches/features/experimental-gui/simple_usrp.py 2008-07-22
17:30:41 UTC (rev 8977)
+++ gnuradio/branches/features/experimental-gui/simple_usrp.py 2008-07-22
18:23:25 UTC (rev 8978)
@@ -118,3 +118,63 @@
Get USRP RX sample rate in samples/sec.
"""
return self._u.adc_rate()/self._decim
+
+class sink_c(gr.hier_block2):
+ def __init__(self,
+ which=0,
+ interp=32,
+ subdev_spec=None,
+ freq=None):
+ """!
+ Create a simple_usrp object accepting complex samples.
+
+ @param which USRP # on USB bus (default is 0)
+ @param interp Transmit sample rate interpolation (default is
32)
+ @param subdev_spec Daughterboard selection (default is first found)
+ @param freq Daughterboard TX frequency (default is
mid-range)
+ """
+
+ gr.hier_block2.__init__(self, "simple_usrp.sink_c",
+ gr.io_signature(1, 1, gr.sizeof_gr_complex), #
Input signature
+ gr.io_signature(0, 0, 0)) #
Output signature
+
+ self._setup_usrp(which, interp)
+ self._setup_db(subdev_spec, freq)
+ self.connect(self, self._u)
+
+ def _setup_usrp(self, which, interp):
+ self._u = usrp.sink_c(which=which)
+ self.set_interp(interp)
+
+ def _setup_db(self, subdev_spec, freq):
+ if subdev_spec is None:
+ subdev_spec = usrp.pick_tx_subdevice(self._u)
+ self._u.set_mux(usrp.determine_tx_mux_value(self._u, subdev_spec))
+ self._subdev = usrp.selected_subdev(self._u, subdev_spec)
+ self.set_freq(freq)
+
+ def set_interp(self, interp):
+ """!
+ Set USRP TX interpolation.
+
+ @param interp TX decimation rate
+ """
+ self._interp = interp
+ self._u.set_interp_rate(interp)
+
+ def set_freq(self, freq):
+ """!
+ Set USRP/Daughterboard TX center frequency.
+
+ @param freq TX center frequency, (None=mid-range)
+ """
+ if freq is None:
+ f = self._subdev.freq_range()
+ freq = float(f[0]+f[1])/2.0
+ return self._u.tune(0, self._subdev, freq)
+
+ def sample_rate(self):
+ """!
+ Get USRP TX sample rate in samples/sec.
+ """
+ return self._u.dac_rate()/self._interp
Added: gnuradio/branches/features/experimental-gui/tx_mpsk.py
===================================================================
--- gnuradio/branches/features/experimental-gui/tx_mpsk.py
(rev 0)
+++ gnuradio/branches/features/experimental-gui/tx_mpsk.py 2008-07-22
18:23:25 UTC (rev 8978)
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, blks2
+from optparse import OptionParser
+from gnuradio.eng_option import eng_option
+from math import pi, log10
+import simple_usrp
+
+class tx_mpsk_top_block(gr.top_block):
+ def __init__(self,
+ arity=2,
+ p_order=10,
+ sps=2,
+ which=0,
+ subdev_spec=None,
+ freq=None,
+ amp=1600,
+ sym_rate=250e3,
+ excess_bw=0.35):
+
+ gr.top_block.__init__(self, "tx_mpsk")
+
+ # Create pseudorandom symbol stream
+ self._bits_per_sym = int(log10(arity)/log10(2.0))
+ self._bits = gr.glfsr_source_b(p_order)
+ self._u2p = gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
+ self._p2u = gr.packed_to_unpacked_bb(self._bits_per_sym,
gr.GR_MSB_FIRST)
+
+ # Map to constellation
+ self._constellation = blks2.constellation[arity]
+ self._mapper = gr.chunks_to_symbols_bc(self._constellation)
+
+ # Throttle to specified symbol rate
+ self._throttle = gr.throttle(gr.sizeof_gr_complex, sym_rate)
+
+ # Create RRC with specified excess bandwidth
+ taps = gr.firdes.root_raised_cosine(sps*amp, # Gain
+ sps, # Sampling rate
+ 1.0, # Symbol rate
+ excess_bw, # Roll-off factor
+ 11*sps) # Number of taps
+
+ self._rrc = gr.interp_fir_filter_ccf(sps, # Interpolation rate
+ taps) # FIR taps
+
+ self._interp = int(128e6/sym_rate/sps)
+ self._usrp = simple_usrp.sink_c(which=which,
+ interp=self._interp,
+ subdev_spec=subdev_spec,
+ freq=freq)
+
+ self.connect(self._bits, self._u2p, self._p2u, self._mapper,
self._throttle,
+ self._rrc, self._usrp)
+
+def get_options():
+ 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("-T", "--tx-subdev-spec", type="subdev", default=None,
+ help="select USRP Tx side A or B (default=first one with
a daughterboard)")
+ parser.add_option("-f", "--freq", type="eng_float", default=None,
+ help="set frequency to FREQ", metavar="FREQ")
+ parser.add_option("-a", "--amplitude", type="eng_float", default=1600,
+ help="set Tx amplitude (0-32767) (default is 1600)")
+ parser.add_option("-m", "--modulation", type="choice",
choices=['bpsk','qpsk'], default='bpsk',
+ help="Select modulation from 'bpsk', 'qpsk', default is
'bpsk'")
+ parser.add_option("-r", "--rate", type="eng_float", default=250e3,
+ help="Select modulation symbol rate [default=%default]")
+ parser.add_option("", "--sps", type="int", default=2,
+ help="Select samples per symbol [default=%default]")
+ parser.add_option("", "--excess-bw", type="eng_float", default=0.35,
+ help="Select RRC excess bandwidth [default=%default]")
+
+ (options, args) = parser.parse_args()
+ if len(args) != 0:
+ parser.print_help()
+ sys.exit(1)
+
+ if options.modulation == 'bpsk':
+ options.arity = 2
+ elif options.modulation == 'qpsk':
+ options.arity = 4
+
+ return (options, args)
+
+
+
+if __name__ == "__main__":
+ (options, args) = get_options()
+
+ tb = tx_mpsk_top_block(arity=options.arity,
+ sps=options.sps,
+ which=options.which,
+ subdev_spec=options.tx_subdev_spec,
+ freq=options.freq,
+ amp=options.amplitude,
+ sym_rate=options.rate,
+ excess_bw=options.excess_bw)
+
+ tb.run()
Property changes on: gnuradio/branches/features/experimental-gui/tx_mpsk.py
___________________________________________________________________
Name: svn:executable
+ *
Modified: gnuradio/branches/features/experimental-gui/usrp_const.py
===================================================================
--- gnuradio/branches/features/experimental-gui/usrp_const.py 2008-07-22
17:30:41 UTC (rev 8977)
+++ gnuradio/branches/features/experimental-gui/usrp_const.py 2008-07-22
18:23:25 UTC (rev 8978)
@@ -77,7 +77,6 @@
if __name__ == "__main__":
(options, args) = get_options()
- print options
# Applications have a 2-step initialization
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8978 - gnuradio/branches/features/experimental-gui,
jcorgan <=