commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r4439 - in gnuradio/branches/developers/jcorgan/dect/g


From: jcorgan
Subject: [Commit-gnuradio] r4439 - in gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python: . dect
Date: Sat, 10 Feb 2007 09:36:40 -0700 (MST)

Author: jcorgan
Date: 2007-02-10 09:36:40 -0700 (Sat, 10 Feb 2007)
New Revision: 4439

Added:
   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.

Added: 
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/Makefile.am
                         (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/Makefile.am
 2007-02-10 16:36:40 UTC (rev 4439)
@@ -0,0 +1,25 @@
+#
+# 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.
+# 
+
+EXTRA_DIST =           \
+       usrp_dect.py
+
+MOSTLYCLEANFILES = *.pyc

Added: 
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/README
===================================================================
--- 
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/README  
                            (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/README  
    2007-02-10 16:36:40 UTC (rev 4439)
@@ -0,0 +1,16 @@
+This directory contains a work in progress service monitor for DECT
+digital cordless phone base stations and handsets.
+
+In the US, the FCC has allocated four carrier frequencies for DECT usage:
+
+Channel                Frequency
+-------                ---------
+   1           1921.536 MHz
+   2           1923.264 MHz
+   3           1924.992 MHz
+   4           1926.720 MHz
+
+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,
+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/usrp_dect.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/usrp_dect.py
                                (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/usrp_dect.py
        2007-02-10 16:36:40 UTC (rev 4439)
@@ -0,0 +1,193 @@
+#!/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
+from gnuradio import gru
+from gnuradio import usrp
+from gnuradio import optfir
+from gnuradio import eng_notation
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+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,
+                          help="select USRP Rx 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("", "--calibration", type="eng_float", default=0.0,
+                          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("", "--log-baseband", default=None,
+                          help="log filtered basedband to file")
+        (options, args) = parser.parse_args()
+        if len(args) != 0:
+            parser.print_help()
+            sys.exit(1)
+       
+       # Create an instance of a hierarchical block
+       top_block = dect_receiver(options)
+                             
+       # Create an instance of a runtime, passing it the top block
+       # to process
+       runtime = gr.runtime(top_block)
+
+       try:    
+            # Run forever
+            runtime.run()
+       except KeyboardInterrupt:
+            # Ctrl-C exits
+            pass
+
+if __name__ == '__main__':
+    main ()


Property changes on: 
gnuradio/branches/developers/jcorgan/dect/gnuradio-examples/python/dect/usrp_dect.py
___________________________________________________________________
Name: svn:executable
   + *





reply via email to

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