commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r3567 - gnuradio/branches/developers/eb/digital-wip/gn


From: eb
Subject: [Commit-gnuradio] r3567 - gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl
Date: Mon, 18 Sep 2006 15:20:39 -0600 (MDT)

Author: eb
Date: 2006-09-18 15:20:37 -0600 (Mon, 18 Sep 2006)
New Revision: 3567

Modified:
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dbpsk.py
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dqpsk.py
Log:
work-in-progress

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dbpsk.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dbpsk.py
     2006-09-18 20:59:14 UTC (rev 3566)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dbpsk.py
     2006-09-18 21:20:37 UTC (rev 3567)
@@ -38,7 +38,8 @@
 # /////////////////////////////////////////////////////////////////////////////
 
 class dbpsk_mod(gr.hier_block):
-    def __init__(self, fg, samples_per_symbol=2, excess_bw=0.35, 
gray_code=True, verbose=True, debug=False):
+    def __init__(self, fg, samples_per_symbol=2, excess_bw=0.35,
+                 gray_code=True, verbose=True, debug=False):
         """
        Hierarchical block for RRC-filtered QPSK modulation.
 
@@ -155,9 +156,11 @@
 
 # /////////////////////////////////////////////////////////////////////////////
 #                             DBPSK demodulator
+#
+#      Differentially coherent detection of differentially encoded BPSK
 # /////////////////////////////////////////////////////////////////////////////
 
-class 
dbpsk_demod__differentially_coherent_detection_of_differentially_encoded_psk(gr.hier_block):
+class dbpsk_demod(gr.hier_block):
     def __init__(self, fg, samples_per_symbol, excess_bw=0.35,
                  costas_alpha=0.005, gain_mu=0.05, mu=0.5,
                  gray_code=True, verbose=True, debug=False):
@@ -308,13 +311,9 @@
         Given command line options, create dictionary suitable for passing to 
__init__
         """
         return modulation_utils.extract_kwargs_from_options(
-                 
dbpsk_demod__differentially_coherent_detection_of_differentially_encoded_psk.__init__,
-                 ('self', 'fg'), options)
+                 dbpsk_demod.__init__, ('self', 'fg'), options)
     extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
 
-
-dbpsk_demod = 
dbpsk_demod__differentially_coherent_detection_of_differentially_encoded_psk
-
 #
 # Add these to the mod/demod registry
 #

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dqpsk.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dqpsk.py
     2006-09-18 20:59:14 UTC (rev 3566)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dqpsk.py
     2006-09-18 21:20:37 UTC (rev 3567)
@@ -25,7 +25,7 @@
 differential QPSK modulation and demodulation.
 """
 
-from gnuradio import gr, gru
+from gnuradio import gr, gru, modulation_utils
 from math import pi, sqrt
 import psk
 import cmath
@@ -33,12 +33,13 @@
 from pprint import pprint
 
 # /////////////////////////////////////////////////////////////////////////////
-#            QPSK mod/demod with steams of bytes as data i/o
+#                           DQPSK modulator
 # /////////////////////////////////////////////////////////////////////////////
 
 class dqpsk_mod(gr.hier_block):
 
-    def __init__(self, fg, spb=2, excess_bw=0.35, gray_code=True, 
verbose=True, debug=False):
+    def __init__(self, fg, samples_per_symbol=2, excess_bw=0.35,
+                 gray_code=True, verbose=True, debug=False):
         """
        Hierarchical block for RRC-filtered QPSK modulation.
 
@@ -47,8 +48,8 @@
 
        @param fg: flow graph
        @type fg: flow graph
-       @param spb: samples per baud >= 2
-       @type spb: integer
+       @param samples_per_symbol: samples per symbol >= 2
+       @type samples_per_symbol: integer
        @param excess_bw: Root-raised cosine filter excess bandwidth
        @type excess_bw: float
         @param gray_code: Tell modulator to Gray code the bits
@@ -59,20 +60,20 @@
         @type debug: bool
        """
 
-        self.fg = fg
-        self.spb = spb
-        self.excess_bw = excess_bw        
+        self._fg = fg
+        self._samples_per_symbol = samples_per_symbol
+        self._excess_bw = excess_bw        
 
-        if not isinstance(spb, int) or spb < 2:
-            raise TypeError, ("sbp must be an integer >= 2, is %d" % spb)
+        if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2:
+            raise TypeError, ("sbp must be an integer >= 2, is %d" % 
samples_per_symbol)
 
-       ntaps = 11 * spb
+       ntaps = 11 * samples_per_symbol
  
-        arity = pow(2,self.bits_per_baud())
+        arity = pow(2,self.bits_per_symbol())
 
         # turn bytes into k-bit vectors
         self.bytes2chunks = \
-          gr.packed_to_unpacked_bb(self.bits_per_baud(), gr.GR_MSB_FIRST)
+          gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)
 
         if gray_code:
             self.gray_coder = gr.map_bb(psk.binary_to_gray[arity])
@@ -85,38 +86,38 @@
 
         # pulse shaping filter
        self.rrc_taps = gr.firdes.root_raised_cosine(
-               spb,            # gain  (spb since we're interpolating by spb)
-               spb,            # sampling rate
-               1.0,            # symbol rate
-               excess_bw,      # excess bandwidth (roll-off factor)
-                ntaps)
+           samples_per_symbol, # gain  (samples_per_symbol since we're 
interpolating by samples_per_symbol)
+            samples_per_symbol, # sampling rate
+            1.0,               # symbol rate
+            excess_bw,          # excess bandwidth (roll-off factor)
+            ntaps)
 
-       self.rrc_filter = gr.interp_fir_filter_ccf(spb, self.rrc_taps)
+       self.rrc_filter = gr.interp_fir_filter_ccf(samples_per_symbol, 
self.rrc_taps)
 
         if verbose:
-            self.verbose()
+            self._print_verbage()
         
         if debug:
-            self.debug()
+            self._setup_logging()
             
        # Connect & Initialize base class
-        self.fg.connect(self.bytes2chunks, self.gray_coder, self.diffenc,
-                        self.chunks2symbols, self.rrc_filter)
-       gr.hier_block.__init__(self, self.fg, self.bytes2chunks, 
self.rrc_filter)
+        self._fg.connect(self.bytes2chunks, self.gray_coder, self.diffenc,
+                         self.chunks2symbols, self.rrc_filter)
+       gr.hier_block.__init__(self, self._fg, self.bytes2chunks, 
self.rrc_filter)
 
     def samples_per_symbol(self):
-        return self.spb
+        return self._samples_per_symbol
 
-    def bits_per_baud(self=None):   # staticmethod that's also callable on an 
instance
+    def bits_per_symbol(self=None):   # staticmethod that's also callable on 
an instance
         return 2
-    bits_per_baud = staticmethod(bits_per_baud)      # make it a static 
method.  RTFM
+    bits_per_symbol = staticmethod(bits_per_symbol)      # make it a static 
method.  RTFM
 
-    def verbose(self):
-        print "bits per symbol = %d" % self.bits_per_baud()
-        print "RRS roll-off factor = %f" % self.excess_bw
+    def _print_verbage(self):
+        print "bits per symbol = %d" % self.bits_per_symbol()
+        print "RRS roll-off factor = %f" % self._excess_bw
 
-    def debug(self):
-        print "Modulation debugging turned on."
+    def _setup_logging(self):
+        print "Modulation logging turned on."
         self.fg.connect(self.bytes2chunks,
                         gr.file_sink(gr.sizeof_char, "bytes2chunks.dat"))
         self.fg.connect(self.gray_coder,
@@ -128,39 +129,46 @@
         self.fg.connect(self.rrc_filter,
                         gr.file_sink(gr.sizeof_gr_complex, "rrc_filter.dat"))
 
-    def arguments(self=None):
-        args = {'spb':2, 'excess_bw':0.3, 'gray_code':True, 'verbose':True, 
'debug':False}
-        return args
-    arguments = staticmethod(arguments)
-
     def add_options(parser):
         """
-        Adds modulation-specific options to the standard parser
+        Adds QPSK modulation-specific options to the standard parser
         """
-        from optparse import OptionConflictError
-        try:
-            parser.add_option("", "--excess-bw", type="float", default=0.3,
-                              help="set RRC excess bandwith factor 
[default=%default]")
-            parser.add_option("", "--no-gray-code", action="store_false", 
default=True,
-                              help="Don't use gray coding on modulated bits 
[default=%default]")
-        except OptionConflictError:
-            pass
+        parser.add_option("", "--excess-bw", type="float", default=0.3,
+                          help="set RRC excess bandwith factor 
[default=%default] (PSK)")
+        parser.add_option("", "--no-gray-code", action="store_false", 
default=True,
+                          help="Don't use gray coding on modulated bits 
[default=%default] (PSK)")
     add_options=staticmethod(add_options)
 
 
-class 
dqpsk_demod__coherent_detection_of_differentially_encoded_psk(gr.hier_block):
-    def __init__(self, fg, spb, excess_bw=0.35, costas_alpha=0.005, 
gain_mu=0.05, mu=0.5,
+    def extract_kwargs_from_options(options):
+        """
+        Given command line options, create dictionary suitable for passing to 
__init__
+        """
+        return modulation_utils.extract_kwargs_from_options(dqpsk_mod.__init__,
+                                                            ('self', 'fg'), 
options)
+    extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
+
+
+# /////////////////////////////////////////////////////////////////////////////
+#                           DQPSK demodulator
+#
+# Differentially coherent detection of differentially encoded qpsk
+# /////////////////////////////////////////////////////////////////////////////
+
+class dqpsk_demod(gr.hier_block):
+    def __init__(self, fg, samples_per_symbol, excess_bw=0.35,
+                 costas_alpha=0.005, gain_mu=0.05, mu=0.5,
                  gray_code=True, verbose=True, debug=False):
         """
-       Hierarchical block for RRC-filtered QPSK demodulation
+       Hierarchical block for RRC-filtered DQPSK demodulation
 
        The input is the complex modulated signal at baseband.
        The output is a stream of bits packed 1 bit per byte (LSB)
 
        @param fg: flow graph
        @type fg: flow graph
-       @param spb: samples per baud >= 2
-       @type spb: float
+       @param samples_per_symbol: samples per symbol >= 2
+       @type samples_per_symbol: float
        @param excess_bw: Root-raised cosine filter excess bandwidth
        @type excess_bw: float
         @param costas_alpha: loop filter gain
@@ -175,16 +183,16 @@
         @type debug: bool
        """
 
-        self.fg = fg
-        self.spb = spb
-        self.excess_bw = excess_bw
-        self.costas_alpha = costas_alpha
-        self.gain_mu = gain_mu
+        self._fg = fg
+        self._samples_per_symbol = samples_per_symbol
+        self._excess_bw = excess_bw
+        self._costas_alpha = costas_alpha
+        self._gain_mu = gain_mu
 
-        if spb < 2:
-            raise TypeError, "sbp must be >= 2, is %d" % spb
+        if samples_per_symbol < 2:
+            raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol
 
-        arity = pow(2,self.bits_per_baud())
+        arity = pow(2,self.bits_per_symbol())
  
         # Automatic gain control
         self.preamp = gr.multiply_const_cc(10e-5)
@@ -193,14 +201,14 @@
         # Costas loop (carrier tracking)
         # FIXME: need to decide how to handle this more generally; do we pull 
it from higher layer?
         costas_order = 4
-        beta = .25 * self.costas_alpha * self.costas_alpha
-        self.costas_loop = gr.costas_loop_cc(self.costas_alpha, beta, 0.1, 
-0.1, costas_order)
+        beta = .25 * self._costas_alpha * self._costas_alpha
+        self.costas_loop = gr.costas_loop_cc(self._costas_alpha, beta, 0.1, 
-0.1, costas_order)
 
         # RRC data filter
-        ntaps = 11 * spb
+        ntaps = 11 * samples_per_symbol
         self.rrc_taps = gr.firdes.root_raised_cosine(
             1.0,                # gain 
-            spb,                # sampling rate
+            samples_per_symbol, # sampling rate
             1.0,                # symbol rate
             excess_bw,          # excess bandwidth (roll-off factor)
             ntaps)
@@ -208,13 +216,13 @@
         self.rrc_filter=gr.fir_filter_ccf(1, self.rrc_taps)
 
         # symbol clock recovery
-        omega = spb
+        omega = samples_per_symbol
         gain_omega = .25 * gain_mu * gain_mu
         omega_rel_limit = 0.5
         mu = 0.05
         gain_mu = 0.1
         self.clock_recovery=gr.clock_recovery_mm_cc(omega, gain_omega,
-                                                    mu, self.gain_mu,
+                                                    mu, self._gain_mu,
                                                     omega_rel_limit)
 
         # find closest constellation point
@@ -230,36 +238,34 @@
         self.gray_decoder = gr.map_bb(psk.gray_to_binary[arity])
         
         # unpack the k bit vector into a stream of bits
-        self.unpack = gr.unpack_k_bits_bb(self.bits_per_baud())
+        self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol())
 
         if verbose:
-            self.verbose()
+            self._print_verbage()
         
         if debug:
-            self.debug()
+            self._setup_logging()
  
         # Connect & Initialize base class
-        self.fg.connect(self.preamp, self.agc, self.costas_loop, 
self.rrc_filter, self.clock_recovery,
-                        self.diffdec, self.slicer, self.gray_decoder, 
self.unpack)
-        #self.fg.connect(self.preamp, self.agc, self.costas_loop, 
self.rrc_filter, self.clock_recovery,
-        #           self.slicer, self.diffdec, self.gray_decoder, self.unpack)
-        gr.hier_block.__init__(self, self.fg, self.preamp, self.unpack)
+        self._fg.connect(self.preamp, self.agc, self.costas_loop, 
self.rrc_filter, self.clock_recovery,
+                         self.diffdec, self.slicer, self.gray_decoder, 
self.unpack)
+        gr.hier_block.__init__(self, self._fg, self.preamp, self.unpack)
 
     def samples_per_symbol(self):
-        return self.spb
+        return self._samples_per_symbol
 
-    def bits_per_baud(self=None):   # staticmethod that's also callable on an 
instance
+    def bits_per_symbol(self=None):   # staticmethod that's also callable on 
an instance
         return 2
-    bits_per_baud = staticmethod(bits_per_baud)      # make it a static 
method.  RTFM
+    bits_per_symbol = staticmethod(bits_per_symbol)      # make it a static 
method.  RTFM
 
-    def verbose(self):
-        print "bits per symbol = %d"         % self.bits_per_baud()
-        print "RRC roll-off factor = %.2f"   % self.excess_bw
-        print "Costas Loop alpha = %.5f"     % self.costas_alpha
-        print "M&M symbol sync gain  = %.5f" % self.gain_mu
+    def _print_verbage(self):
+        print "bits per symbol = %d"         % self.bits_per_symbol()
+        print "RRC roll-off factor = %.2f"   % self._excess_bw
+        print "Costas Loop alpha = %.5f"     % self._costas_alpha
+        print "M&M symbol sync gain  = %.5f" % self._gain_mu
 
-    def debug(self):
-        print "Modulation debugging turned on."
+    def _setup_logging(self):
+        print "Modulation logging turned on."
         self.fg.connect(self.agc,
                         gr.file_sink(gr.sizeof_gr_complex, "agc.dat"))
         self.fg.connect(self.costas_loop,
@@ -279,31 +285,34 @@
         self.fg.connect((self.costas_loop,1),
                         gr.file_sink(gr.sizeof_gr_complex, "costas.dat"))
 
-    def arguments(self=None):
-        args = {'spb':2, 'excess_bw':0.3, 'costas_alpha':0.005, 
'gain_mu':0.05, 'mu':0.5,
-                'gray_code':True, 'verbose':True, 'debug':False}
-        return args
-    arguments = staticmethod(arguments)
 
     def add_options(parser):
         """
         Adds modulation-specific options to the standard parser
         """
-        from optparse import OptionConflictError
-        try:
-            parser.add_option("", "--excess-bw", type="float", default=0.3,
-                              help="set RRC excess bandwith factor 
[default=%default]")
-            parser.add_option("", "--no-gray-code", action="store_false", 
default=True,
-                              help="Don't use gray coding on modulated bits 
[default=%default]")
-            parser.add_option("", "--costas-alpha", type="float", 
default=0.005,
-                              help="set Costas loop alpha value 
[default=%default]")
-            parser.add_option("", "--gain-mu", type="float", default=0.05,
-                              help="set M&M symbol sync loop gain mu value 
[default=%default]")
-            parser.add_option("", "--mu", type="float", default=0.5,
-                              help="set M&M symbol sync loop mu value 
[default=%default]")
-        except OptionConflictError:
-            pass
+        parser.add_option("", "--excess-bw", type="float", default=0.3,
+                          help="set RRC excess bandwith factor 
[default=%default] (PSK)")
+        parser.add_option("", "--no-gray-code", action="store_false", 
default=True,
+                          help="Don't use gray coding on modulated bits 
[default=%default] (PSK)")
+        parser.add_option("", "--costas-alpha", type="float", default=0.005,
+                          help="set Costas loop alpha value [default=%default] 
(PSK)")
+        parser.add_option("", "--gain-mu", type="float", default=0.05,
+                          help="set M&M symbol sync loop gain mu value 
[default=%default] (PSK)")
+        parser.add_option("", "--mu", type="float", default=0.5,
+                          help="set M&M symbol sync loop mu value 
[default=%default] (PSK)")
     add_options=staticmethod(add_options)
- 
-dqpsk_demod = dqpsk_demod__coherent_detection_of_differentially_encoded_psk
 
+    def extract_kwargs_from_options(options):
+        """
+        Given command line options, create dictionary suitable for passing to 
__init__
+        """
+        return modulation_utils.extract_kwargs_from_options(
+            dqpsk_demod.__init__, ('self', 'fg'), options)
+    extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
+
+
+#
+# Add these to the mod/demod registry
+#
+modulation_utils.add_type_1_mod('dqpsk', dqpsk_mod)
+modulation_utils.add_type_1_demod('dqpsk', dqpsk_demod)





reply via email to

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