commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r3481 - gnuradio/branches/developers/jcorgan/pager/gr-


From: jcorgan
Subject: [Commit-gnuradio] r3481 - gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python
Date: Mon, 4 Sep 2006 00:31:12 -0600 (MDT)

Author: jcorgan
Date: 2006-09-04 00:31:12 -0600 (Mon, 04 Sep 2006)
New Revision: 3481

Added:
   gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/flex_demod.py
   gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/usrp_flex.py
Modified:
   gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/Makefile.am
Log:
Added USRP receive script and start of decoder module.  It can write
baseband demodulated FSK to a file.


Modified: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/Makefile.am
===================================================================
--- gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/Makefile.am  
2006-09-04 04:19:53 UTC (rev 3480)
+++ gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/Makefile.am  
2006-09-04 06:31:12 UTC (rev 3481)
@@ -30,4 +30,4 @@
 noinst_PYTHON = \
     qa_pager.py
 
-MOSTLYCLEANFILES = *~ *.pyc
\ No newline at end of file
+MOSTLYCLEANFILES = *~ *.pyc *.tmp
\ No newline at end of file

Added: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/flex_demod.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/flex_demod.py    
                            (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/flex_demod.py    
    2006-09-04 06:31:12 UTC (rev 3481)
@@ -0,0 +1,47 @@
+#
+# Copyright 2006 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 
+
+from gnuradio import gr
+from math import pi
+
+class flex_demod(gr.hier_block):
+    """
+    FLEX protocol demodulation block.
+
+    This block demodulates a band-limited, complex down-converted baseband 
+    channel into FLEX protocol frames.
+
+    Flow graph (so far):
+
+    QUAD - Quadrature demodulator converts FSK to baseband amplitudes  
+
+    ---
+
+    @param fg: flowgraph
+    @param channel_rate:  incoming sample rate of the baseband channel
+    @type sample_rate: integer
+    """
+
+    def __init__(self, fg, channel_rate):
+        k = channel_rate/(2*pi*4800)        # 4800 Hz max deviation
+        QUAD = gr.quadrature_demod_cf(k)
+
+        gr.hier_block.__init__(self, fg, QUAD, QUAD)

Added: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/usrp_flex.py
===================================================================
--- gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/usrp_flex.py 
                        (rev 0)
+++ gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/usrp_flex.py 
2006-09-04 06:31:12 UTC (rev 3481)
@@ -0,0 +1,159 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, gru, usrp, optfir, eng_notation, blks
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+import time, os, sys
+
+# This will force us to make it a package
+from flex_demod import flex_demod
+
+"""
+This example application demonstrates receiving and demodulating the
+FLEX pager protocol.
+
+A receive chain is built up of the following signal processing
+blocks:
+
+USRP  - Daughter board source generating complex baseband signal.
+CHAN  - Low pass filter to select channel bandwidth
+RFSQL - RF squelch zeroing output when input power below threshold
+AGC   - Automatic gain control leveling signal at [-1.0, +1.0]
+FLEX  - FLEX pager protocol decoder
+SINK  - File sink for decoded output 
+
+The following are required command line parameters:
+
+-f FREQ                USRP receive frequency
+
+The following are optional command line parameters:
+
+-R SUBDEV   Daughter board specification, defaults to first found
+-c FREQ     Calibration offset.  Gets added to receive frequency.
+            Defaults to 0.0 Hz.
+-g GAIN     Daughterboard gain setting. Defaults to mid-range.
+-r RFSQL       RF squelch in db. Defaults to -50.0.
+
+Once the program is running, ctrl-break (Ctrl-C) stops operation.
+"""
+
+def make_filename(dir, freq):
+    t = time.strftime('%Y%m%d-%H%M%S')
+    f = 'r%s-%s.dat' % (t, eng_notation.num_to_str(freq))
+    return os.path.join(dir, f)
+
+class usrp_source_c(gr.hier_block):
+    """
+    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, subdev_spec, decim, gain=None, calibration=0.0):
+        self._decim = decim
+        self._src = usrp.source_c()
+        if subdev_spec is None:
+            subdev_spec = usrp.pick_rx_subdevice(self._src)
+        self._subdev = usrp.selected_subdev(self._src, subdev_spec)
+        self._src.set_mux(usrp.determine_rx_mux_value(self._src, subdev_spec))
+        self._src.set_decim_rate(self._decim)
+
+        # If no gain specified, set to midrange
+        if gain is None:
+            g = self._subdev.gain_range()
+            gain = (g[0]+g[1])/2.0
+
+        self._subdev.set_gain(gain)
+        self._cal = calibration
+
+        gr.hier_block.__init__(self, fg, self._src, self._src)
+
+    def tune(self, freq):
+        result = usrp.tune(self._src, 0, self._subdev, freq+self._cal)
+        # TODO: deal with residual
+
+    def rate(self):
+        return self._src.adc_rate()/self._decim
+
+class app_flow_graph(gr.flow_graph):
+    def __init__(self, options, args):
+        gr.flow_graph.__init__(self)
+        self.options = options
+        self.args = args
+
+        USRP = usrp_source_c(self,          # Flow graph
+                    options.rx_subdev_spec, # Daugherboard spec
+                       250,                    # IF decimation ratio gets 256K 
if_rate
+                    options.gain,           # Receiver gain
+                    options.calibration)    # Frequency offset
+        USRP.tune(options.frequency)
+
+        if_rate = USRP.rate()
+        channel_rate = 32000                # Oversampled by 10 or 20
+        channel_decim = if_rate // channel_rate
+       
+        CHAN_taps = optfir.low_pass(1.0,          # Filter gain
+                                    if_rate,      # Sample rate
+                                               8000,         # One sided 
modulation bandwidth
+                                       10000,        # One sided channel 
bandwidth
+                                                   0.1,              # 
Passband ripple
+                                                   60)                   # 
Stopband attenuation
+       
+        CHAN = gr.freq_xlating_fir_filter_ccf(channel_decim, # Decimation rate
+                                              CHAN_taps,     # Filter taps
+                                              0.0,           # Offset frequency
+                                              if_rate)       # Sample rate
+
+        RFSQL = gr.pwr_squelch_cc(options.rf_squelch, # Power threshold
+                                  125.0/channel_rate, # Time constant
+                                                 channel_rate/20,    # 50ms 
rise/fall
+                                  False)              # Zero, not gate output
+
+        AGC = gr.agc_cc(1.0/channel_rate,  # Time constant
+                        1.0,               # Reference power 
+                        1.0,               # Initial gain
+                        1.0)               # Maximum gain
+       
+        FLEX = flex_demod(self, 32000)      
+
+        SINK = gr.file_sink(gr.sizeof_float, options.filename)
+
+        self.connect(USRP, CHAN, RFSQL, AGC, FLEX, SINK)
+       
+def main():
+    parser = OptionParser(option_class=eng_option)
+    parser.add_option("-f", "--frequency", type="eng_float",
+                      help="set receive frequency to Hz", metavar="Hz")
+    parser.add_option("-R", "--rx-subdev-spec", type="subdev",
+                      help="select USRP Rx side A or B", metavar="SUBDEV")
+    parser.add_option("-c",   "--calibration", type="eng_float", default=0.0,
+                      help="set frequency offset to Hz", metavar="Hz")
+    parser.add_option("-g", "--gain", type="int", default=None,
+                      help="set RF gain", metavar="dB")
+    parser.add_option("-r", "--rf-squelch", type="eng_float", default=-50.0,
+                      help="set RF squelch to dB", metavar="dB")
+    parser.add_option("-F", "--filename", default=None)
+    parser.add_option("-D", "--dir", default=None)
+    (options, args) = parser.parse_args()
+
+    if options.frequency < 1e6:
+       options.frequency *= 1e6
+       
+    if options.filename is None and options.dir is None:
+        sys.stderr.write('Must specify either -F FILENAME or -D DIR\n')
+        parser.print_help()
+        sys.exit(1)
+
+    if options.filename is None:
+        options.filename = make_filename(options.dir, options.frequency)
+
+    fg = app_flow_graph(options, args)
+    try:
+        fg.run()
+    except KeyboardInterrupt:
+        pass
+
+if __name__ == "__main__":
+    main()


Property changes on: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/python/usrp_flex.py
___________________________________________________________________
Name: svn:executable
   + *





reply via email to

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