[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4440 - gnuradio/branches/developers/jcorgan/dect/gnur
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r4440 - gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect |
Date: |
Sun, 11 Feb 2007 00:43:47 -0700 (MST) |
Author: jcorgan
Date: 2007-02-11 00:43:46 -0700 (Sun, 11 Feb 2007)
New Revision: 4440
Added:
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/dect_receiver.py
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/usrp_source.py
Modified:
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/Makefile.am
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/README
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/usrp_dect.py
Log:
Work in progress, refactoring and documentation.
Property changes on:
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
Makefile
*.pyc
Modified:
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/Makefile.am
===================================================================
---
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/Makefile.am
2007-02-10 16:36:40 UTC (rev 4439)
+++
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/Makefile.am
2007-02-11 07:43:46 UTC (rev 4440)
@@ -19,7 +19,10 @@
# Boston, MA 02110-1301, USA.
#
-EXTRA_DIST = \
+EXTRA_DIST = \
+ README \
+ dect_receiver.py \
+ usrp_source.py \
usrp_dect.py
-MOSTLYCLEANFILES = *.pyc
+MOSTLYCLEANFILES = *.pyc *~
Modified:
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/README
===================================================================
---
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/README
2007-02-10 16:36:40 UTC (rev 4439)
+++
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/README
2007-02-11 07:43:46 UTC (rev 4440)
@@ -1,6 +1,29 @@
This directory contains a work in progress service monitor for DECT
digital cordless phone base stations and handsets.
+
+Status
+------
+
+2007 Feb 10 - Able to tune and log filtered baseband to file
+
+
+Files
+-----
+
+dect_receiver.py - Top-level hierarchical block (new type) implementing
+ receiver
+
+usrp_source.py - Hierarchical block (new type) implementing a USRP
+ complex source, with convenience functions for tuning,
+ gain, decimation, etc.
+
+usrp_dect.py - DECT receiver application
+
+
+DECT Modulation Details
+-----------------------
+
In the US, the FCC has allocated four carrier frequencies for DECT usage:
Channel Frequency
@@ -12,5 +35,6 @@
These are spaced at 1.728 MHz intervals.
-The DECT PHY uses GMSK with a 0.5 bit-time product at 1.152 Msym/sec,
+The DECT PHY uses GMSK with a 0.5 bandwidth-time product at 1.152 Msym/sec,
for an occupied bandwidth (99% power) of 1.186 MHz (1.03 x symbol rate.)
+
Added:
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/dect_receiver.py
===================================================================
---
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/dect_receiver.py
(rev 0)
+++
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/dect_receiver.py
2007-02-11 07:43:46 UTC (rev 4440)
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+#
+# Copyright 2007 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 2, 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, optfir
+from usrp_source import usrp_source_c
+
+# Top-level hierarchical block that implements DECT demodulation and
+# decoding.
+class dect_receiver(gr.hier_block2):
+ def __init__(self, options):
+ gr.hier_block2.__init__(self,
+ "dect_receiver", # Block typename
+ gr.io_signature(0,0,0), # Input signature
+ gr.io_signature(0,0,0)) # Output signature
+ self._options = options
+
+ # Get 2 MHz swath at channel frequency
+ if_rate = 2e6
+ self._usrp = usrp_source_c(self,
+ which=0,
+ subdev_spec=options.rx_subdev_spec,
+ if_rate=if_rate,
+ gain=options.gain,
+ freq=options.freq,
+ calibration=options.calibration,
+ verbose=options.verbose)
+
+ # Filter baseband to 1.186 MHz passband, 1.728 MHz stopband
+ chan_taps = optfir.low_pass(1.0, # Gain
+ 2e6, # Sample rate
+ 593e3, # One sided modulation
bandwidth
+ 864e3, # One sided channel
bandwidth
+ 0.1, # Passband ripple (db)
+ 60) # Stopband attenuation
(db)
+ if self._options.verbose:
+ print "Channel filter has", len(chan_taps), "taps"
+ self._channel_filter = gr.freq_xlating_fir_filter_ccf(1, #
Decimation rate
+ chan_taps, #
Filter taps
+ 0.0, #
Offset frequency
+ 2e6) #
Sample rate
+
+ # Log baseband to file if requested
+ if options.log_baseband is not None:
+ self._sink = gr.file_sink(gr.sizeof_gr_complex,
options.log_baseband)
+ if options.verbose:
+ print "Logging baseband to file", options.log_baseband
+ else:
+ self._sink = gr.null_sink(gr.sizeof_gr_complex)
+
+ self.define_component("usrp", self._usrp)
+ self.define_component("channel", self._channel_filter)
+ self.define_component("sink", self._sink)
+
+ self.connect("usrp", 0, "channel", 0)
+ self.connect("channel", 0, "sink", 0)
Modified:
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/usrp_dect.py
===================================================================
---
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/usrp_dect.py
2007-02-10 16:36:40 UTC (rev 4439)
+++
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/usrp_dect.py
2007-02-11 07:43:46 UTC (rev 4440)
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2005,2007 Free Software Foundation, Inc.
+# Copyright 2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,144 +20,12 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr
-from gnuradio import gru
-from gnuradio import usrp
-from gnuradio import optfir
-from gnuradio import eng_notation
+from gnuradio import gr, eng_notation
from gnuradio.eng_option import eng_option
from optparse import OptionParser
+from dect_receiver import dect_receiver
+import sys
-class usrp_source_c(gr.hier_block2):
- """
- Create a USRP source object supplying complex floats.
-
- Selects user supplied subdevice or chooses first available one.
-
- Calibration value is the offset from the tuned frequency to
- the actual frequency.
- """
- def __init__(self, fg, which=0, subdev_spec=None, decim=None, gain=None,
freq=None, calibration=None):
- # Call hierarchical block constructor
- # Top-level blocks have no inputs or outputs
- gr.hier_block2.__init__(self,
- "usrp_source_c", #
Block typename
- gr.io_signature(0,0,0), #
Input signature
- gr.io_signature(1,1,gr.sizeof_gr_complex)) #
Output signature
-
- self._u = usrp.source_c(which)
- self.set_subdev(subdev_spec)
- self.set_decim_rate(decim)
- self.set_gain(gain)
- self.set_calibration(gain)
- self.tune(freq)
-
- self.define_component("usrp", self._u)
- self.connect("usrp", 0, "self", 0)
-
- def set_subdev(self, subdev_spec):
- if subdev_spec is None:
- subdev_spec = self.pick_subdevice()
- self._subdev = usrp.selected_subdev(self._u, subdev_spec)
- self._u.set_mux(usrp.determine_rx_mux_value(self._u, subdev_spec))
-
- def pick_subdevice(self):
- """
- The user didn't specify a subdevice.
- If there's a daughterboard on A, select A.
- If there's a daughterboard on B, select B.
- Otherwise, select A.
- """
- if self._u.db[0][0].dbid() >= 0: # dbid is < 0 if there's no
d'board or a problem
- return (0, 0)
- if self._u.db[1][0].dbid() >= 0:
- return (1, 0)
- return (0, 0)
-
- def set_decim_rate(self, decim):
- if decim is None:
- decim = 256 # Max receive decimation
- self._decim = decim
- self._u.set_decim_rate(self._decim)
-
- def set_gain(self, gain):
- # If no gain specified, set to midrange
- if gain is None:
- g = self._subdev.gain_range()
- gain = (g[0]+g[1])/2.0
- self._gain = gain
- self._subdev.set_gain(self._gain)
-
- def set_calibration(self, calibration):
- if calibration is None:
- calibration = 0.0
- self._cal = calibration
-
- def tune(self, freq):
- """
- Set the center frequency we're interested in.
-
- @param target_freq: frequency in Hz
- @rypte: bool
-
- Tuning is a two step process. First we ask the front-end to
- tune as close to the desired frequency as it can. Then we use
- the result of that operation and our target_frequency to
- determine the value for the digital down converter. (NOT IMPLEMENTED)
- """
- self._residual = usrp.tune(self._u, 0, self._subdev, freq)
- if self._residual:
- return True
-
- return False
-
- def rate(self):
- return self._u.adc_rate()/self._decim
-
-
-class dect_receiver(gr.hier_block2):
- def __init__(self, options):
- gr.hier_block2.__init__(self,
- "dect_receiver", # Block typename
- gr.io_signature(0,0,0), # Input signature
- gr.io_signature(0,0,0)) # Output signature
-
- # Get 2 MHz swath at channel frequency
- options.decim = 32
- self._usrp = usrp_source_c(self,
- which=0,
- subdev_spec=options.rx_subdev_spec,
- decim=options.decim,
- gain=options.gain,
- freq=options.freq,
- calibration=options.calibration)
-
- # Filter baseband to 1.186 MHz passband, 1.728 MHz stopband
- chan_taps = optfir.low_pass(1.0, # Gain
- 2e6, # Sample rate
- 593e3, # One sided modulation
bandwidth
- 864e3, # One sided channel
bandwidth
- 0.1, # Passband ripple
- 60) # Stopband attenuation
- print "Channel filter has", len(chan_taps), "taps."
- self._channel_filter = gr.freq_xlating_fir_filter_ccf(1, #
Decimation rate
- chan_taps, #
Filter taps
- 0.0, #
Offset frequency
- 2e6) #
Sample rate
-
- # Log baseband to file if requested
- if options.log_baseband is not None:
- self._sink = gr.file_sink(gr.sizeof_gr_complex,
options.log_baseband)
- else:
- self._sink = gr.null_sink(gr.sizeof_gr_complex)
-
- self.define_component("usrp", self._usrp)
- self.define_component("channel", self._channel_filter)
- self.define_component("sink", self._sink)
-
- self.connect("usrp", 0, "channel", 0)
- self.connect("channel", 0, "sink", 0)
-
def main():
parser = OptionParser(option_class=eng_option)
parser.add_option("-R", "--rx-subdev-spec", type="subdev",
default=None,
@@ -168,10 +36,13 @@
help="set frequency calibration offset to FREQ")
parser.add_option("-g", "--gain", type="eng_float", default=None,
help="set gain in dB (default is midpoint)")
+ parser.add_option("-v", "--verbose", action="store_true", default=False,
+ help="print extra debugging info")
parser.add_option("", "--log-baseband", default=None,
help="log filtered basedband to file")
(options, args) = parser.parse_args()
- if len(args) != 0:
+
+ if len(sys.argv) == 1 or len(args) != 0:
parser.print_help()
sys.exit(1)
Added:
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/usrp_source.py
===================================================================
---
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/usrp_source.py
(rev 0)
+++
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/usrp_source.py
2007-02-11 07:43:46 UTC (rev 4440)
@@ -0,0 +1,133 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2005,2007 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 2, 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, usrp, eng_notation
+n2s = eng_notation.num_to_str
+
+# Hierarchical block implementing a USRP source for complex floats,
+# with convenience functions for gain, tune, decimation, etc.
+#
+class usrp_source_c(gr.hier_block2):
+ """
+ Create a USRP source object supplying complex floats.
+
+ Selects user supplied subdevice or chooses first available one.
+
+ Calibration value is the offset from the tuned frequency to
+ the actual frequency.
+ """
+ def __init__(self, fg, which=0, subdev_spec=None, decim=None,
+ if_rate=None, gain=None, freq=None, calibration=None,
+ verbose=False):
+ # Call hierarchical block constructor
+ # Top-level blocks have no inputs or outputs
+ gr.hier_block2.__init__(self,
+ "usrp_source_c", #
Block typename
+ gr.io_signature(0,0,0), #
Input signature
+ gr.io_signature(1,1,gr.sizeof_gr_complex)) #
Output signature
+
+ self._verbose = verbose
+ self._u = usrp.source_c(which)
+ if self._verbose:
+ print 'ADC sample rate is', n2s(self._u.adc_rate()), "sps"
+ self.set_subdev(subdev_spec)
+ self.set_if_rate(if_rate)
+ self.set_gain(gain)
+ self.set_calibration(gain)
+ self.tune(freq)
+
+ self.define_component("usrp", self._u)
+ self.connect("usrp", 0, "self", 0)
+
+ def set_subdev(self, subdev_spec):
+ if subdev_spec is None:
+ subdev_spec = self.pick_subdevice()
+ self._subdev = usrp.selected_subdev(self._u, subdev_spec)
+ self._u.set_mux(usrp.determine_rx_mux_value(self._u, subdev_spec))
+ if self._verbose:
+ print 'Using', self._subdev.name(), 'daughterboard'
+
+ def pick_subdevice(self):
+ """
+ The user didn't specify a subdevice.
+ If there's a daughterboard on A, select A.
+ If there's a daughterboard on B, select B.
+ Otherwise, select A.
+ """
+ if self._u.db[0][0].dbid() >= 0: # dbid is < 0 if there's no
d'board or a problem
+ return (0, 0)
+ if self._u.db[1][0].dbid() >= 0:
+ return (1, 0)
+ return (0, 0)
+
+ def set_if_rate(self, if_rate):
+ # If no IF rate specified, set to maximum decimation
+ if if_rate is None:
+ self._decim = 256
+ self._if_rate = self._u.adc_rate()/self._decim
+ else:
+ self._if_rate = if_rate
+ self._decim = int(self._u.adc_rate()/self._if_rate)
+
+ self._u.set_decim_rate(self._decim)
+ if self._verbose:
+ print "USRP decimation rate is", self._decim
+ print "USRP IF rate is", n2s(self._if_rate), "sps"
+
+ def set_gain(self, gain):
+ # If no gain specified, set to midrange
+ if gain is None:
+ g = self._subdev.gain_range()
+ gain = (g[0]+g[1])/2.0
+ self._gain = gain
+ self._subdev.set_gain(self._gain)
+
+ def set_calibration(self, calibration):
+ if calibration is None:
+ calibration = 0.0
+ self._cal = calibration
+ if self._verbose:
+ print "Using frequency calibration offset of", n2s(calibration),
"Hz"
+
+ def tune(self, freq):
+ """
+ Set the center frequency we're interested in.
+
+ @param target_freq: frequency in Hz
+ @type: bool
+
+ Tuning is a two step process. First we ask the front-end to
+ tune as close to the desired frequency as it can. Then we use
+ the result of that operation and our target_frequency to
+ determine the value for the digital down converter.
+ """
+ self._tune_result = usrp.tune(self._u, 0, self._subdev, freq+self._cal)
+ if self._tune_result:
+ if self._verbose:
+ print "Baseband frequency is",
n2s(self._tune_result.baseband_freq), "Hz"
+ print "DXC frequency is", n2s(self._tune_result.dxc_freq), "Hz"
+ print "Center frequency is", n2s(freq), "Hz"
+ print "Residual frequency is",
n2s(self._tune_result.residual_freq), "Hz"
+ return True
+
+ return False
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4440 - gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect,
jcorgan <=