commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r4352 - in gnuradio/branches/developers/nldudok1/digit


From: nldudok1
Subject: [Commit-gnuradio] r4352 - in gnuradio/branches/developers/nldudok1/digital-wip3: gnuradio-core/src/lib/general gnuradio-core/src/python/gnuradio/blksimpl gnuradio-examples/python/digital
Date: Wed, 31 Jan 2007 19:21:29 -0700 (MST)

Author: nldudok1
Date: 2007-01-31 19:21:28 -0700 (Wed, 31 Jan 2007)
New Revision: 4352

Added:
   
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-examples/python/digital/benchmark_rx_oscope.py
Modified:
   
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc
   
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.h
   
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.i
   
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/python/gnuradio/blksimpl/qam16.py
   
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/python/gnuradio/blksimpl/qam64.py
   
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-examples/python/digital/receive_path.py
Log:
add working qam16 receiver and benchmark_rx_oscope

Modified: 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc
===================================================================
--- 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc
     2007-02-01 02:07:51 UTC (rev 4351)
+++ 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc
     2007-02-01 02:21:28 UTC (rev 4352)
@@ -95,7 +95,15 @@
     d_decision = &gr_mpsk_receiver_cc::decision_qpsk;
     break;
 
-  default: // generic algorithms for any M (power of 2?) but not pretty
+  case 16: // generic algorithms for any M (power of 2?) QAM but not pretty
+  case 64:
+  case 256: 
+  case 1024: 
+    d_phase_error_detector = &gr_mpsk_receiver_cc::phase_error_detector_qam;
+    d_decision = &gr_mpsk_receiver_cc::decision_qam;
+    break;
+
+  default: // generic algorithms for any M (power of 2?) PSK (not QAM) but not 
pretty
     d_phase_error_detector = 
&gr_mpsk_receiver_cc::phase_error_detector_generic;
     d_decision = &gr_mpsk_receiver_cc::decision_generic;
     break;
@@ -125,9 +133,38 @@
 float
 gr_mpsk_receiver_cc::phase_error_detector_bpsk(gr_complex sample) const
 {
-  return (sample.real()*sample.imag());
+  return -(sample.real()*sample.imag());
 }
 
+float gr_mpsk_receiver_cc::phase_error_detector_qam(gr_complex sample) const
+{
+  //unsigned int min_i = 0;
+  //unsigned int min_q = 0;
+  unsigned int min_m = 0;
+  gr_complex constpoint;
+  gr_complex expj_theta=gr_expj(d_theta);
+  float min_s = 65535;
+  float error = 0;
+
+  // Develop all possible constellation points and find the one that minimizes
+  // the Euclidean distance (error) with the sample
+  for(unsigned int m=0; m < d_M; m++) {
+      constpoint = d_constellation_points[m]*expj_theta;
+      gr_complex diff = (constpoint - sample)*(constpoint - sample);
+      
+      if(fabs(diff.real()) < min_s) {
+        min_s = fabs(diff.real());
+        min_m = m;
+      }
+    }
+  // Use this constellation point to derotate the sample
+  constpoint = d_constellation_points[min_m]*expj_theta;
+  // get the error in the sample as the phase difference from the real axis
+  error = -gr_fast_atan2f(sample*(constpoint));
+
+  return error;
+}
+
 float gr_mpsk_receiver_cc::phase_error_detector_generic(gr_complex sample) 
const
 {
   unsigned int min_m = 0;
@@ -179,6 +216,34 @@
 }
 
 gr_complex
+gr_mpsk_receiver_cc::decision_qam(gr_complex sample) const
+{
+  unsigned int min_m = 0;
+  //unsigned int min_q = 0;
+  gr_complex constpoint;
+  gr_complex expj_theta=gr_expj(d_theta);
+  float min_s = 65535;
+  
+  // Get all possible constellation points and find the one that minimizes
+  // the Euclidean distance (error) with the sample
+  
+  //for(unsigned int i=0; i < d_I; i++)
+    for(unsigned int m=0; m < d_M; m++) {
+      constpoint = d_constellation_points[m]*expj_theta;
+      gr_complex diff = (constpoint - sample)*(constpoint - sample);
+      
+      if(fabs(diff.real()) < min_s) {
+        min_s = fabs(diff.real());
+        min_m = m;
+        //min_q = q;
+      }
+    }
+  // Return the constellation point that minimizes the error
+  constpoint = d_constellation_points[min_m]*expj_theta;
+  return constpoint;
+}
+
+gr_complex
 gr_mpsk_receiver_cc::decision_generic(gr_complex sample) const
 {
   unsigned int min_m = 0;
@@ -201,6 +266,7 @@
   return constpoint;
 }
 
+
 int
 gr_mpsk_receiver_cc::general_work (int noutput_items,
                                   gr_vector_int &ninput_items,
@@ -215,7 +281,7 @@
   
   int i=0, o=0;
 
-  while(i < ninput_items[0]) {    
+  while((i < ninput_items[0]) && (o<noutput_items)) {    
     while((d_mu > 1) && (i < ninput_items[0]))  {
       d_mu--;             // skip a number of symbols between sampling
       d_phase += d_freq;  // increment the phase based on the frequency of the 
rotation
@@ -277,7 +343,9 @@
       phase_error = (*this.*d_phase_error_detector)(interp_sample);
       d_freq += d_beta*phase_error;
       d_phase += d_alpha*phase_error;
-
+      //d_freq -= d_beta*phase_error;
+      //d_phase -= d_alpha*phase_error;
+      
       while(d_phase>M_TWOPI)
        d_phase -= M_TWOPI;
       while(d_phase<-M_TWOPI)

Modified: 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.h
===================================================================
--- 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.h
      2007-02-01 02:07:51 UTC (rev 4351)
+++ 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.h
      2007-02-01 02:21:28 UTC (rev 4352)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2006 Free Software Foundation, Inc.
  *
  * This file is part of GNU Radio
  *
@@ -92,6 +92,9 @@
   //! (M&M) Returns omega gain factor
   float gain_omega() const { return d_gain_omega;}
 
+  //! (M&M) Returns the constellation points, output is a two-dimensional 
complex vector  
+  //gr_complex constellation_points () {return d_constellation_points; }
+
   //! (M&M) Sets value of mu
   void set_mu (float mu) { d_mu = mu; }
   
@@ -108,8 +111,17 @@
   //! (M&M) Sets value for omega gain factor
   void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; }
 
-
-
+  //! (M&M) Sets the constellation points, input is a two-dimensional complex 
vector
+  /*void set_constellation_points (const std::vector<std::vector<gr_complex> > 
&constellation_points) { 
+    d_constellation_points = constellation_points; 
+    d_I=constellation_points.size();
+    d_Q=constellation_points[0].size();
+  }*/
+  void set_constellation_points (const std::vector<gr_complex> 
&constellation_points) { 
+    d_constellation_points = constellation_points; 
+    //d_I=constellation_points.size();
+    //d_Q=constellation_points[0].size();
+  }
   // Member function related to the phase/frequency tracking portion of the 
receiver
   //! (CL) Returns the value for alpha (the phase gain term)
   float alpha() const { return d_alpha; }
@@ -167,6 +179,22 @@
    *
    * \param sample   the I&Q sample from which to determine the phase error
    *
+   * This function determines the phase error for any QAM signal by using the 
QAM constellation points
+   * and doing a brute-force search to see which point minimizes the Euclidean 
distance. This point is then used
+   * to derotate the sample to the real-axis and a atan (using the fast 
approximation function) to determine the
+   * phase difference between the incoming sample and the real constellation 
point
+   *
+   * This should be cleaned up and made more efficient.
+   *
+   * \returns the approximated phase error.
+ */
+  float phase_error_detector_qam(gr_complex sample) const; // generic for M 
but more costly
+  
+/*!
+   * \brief Phase error detector for MPSK modulations.
+   *
+   * \param sample   the I&Q sample from which to determine the phase error
+   *
    * This function determines the phase error for any MPSK signal by creating 
a set of PSK constellation points
    * and doing a brute-force search to see which point minimizes the Euclidean 
distance. This point is then used
    * to derotate the sample to the real-axis and a atan (using the fast 
approximation function) to determine the
@@ -202,8 +230,21 @@
   float phase_error_detector_qpsk(gr_complex sample) const;
  
 
-
  /*!
+   * \brief Decision maker for a generic QAM constellation.
+   *
+   * \param sample   the baseband I&Q sample from which to make the decision
+   *
+   * This decision maker is a generic implementation which uses the set of 
constellation point for QAM
+   * and does a brute-force search for the constellation point that minimizes 
the error from the incoming
+   * signal.
+   *
+   * \returns the constellation point that minimizes error.
+ */
+  gr_complex decision_qam(gr_complex sample) const;
+  
+  
+ /*!
    * \brief Decision maker for a generic MPSK constellation.
    *
    * \param sample   the baseband I&Q sample from which to make the decision
@@ -243,7 +284,9 @@
   gr_complex decision_qpsk(gr_complex sample) const;
 
   private:
-  unsigned int d_M;
+  unsigned int d_M;//number of values in constellation
+  unsigned int d_I;//number of values on real axis in constellation for QAM
+  unsigned int d_Q;//number of values on imag axis in constellation for QAM  
   float        d_theta;
 
   // Members related to carrier and phase tracking
@@ -251,6 +294,10 @@
   float d_beta;
   float d_freq, d_max_freq, d_min_freq;
   float d_phase;
+  //The actual constellation points (two-dimensional complex vector)
+  //std::vector<std::vector<gr_complex> > d_constellation_points;
+  //The actual constellation points (one-dimensional complex vector)
+  std::vector<gr_complex > d_constellation_points;
 
 /*!
    * \brief Decision maker function pointer 

Modified: 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.i
===================================================================
--- 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.i
      2007-02-01 02:07:51 UTC (rev 4351)
+++ 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.i
      2007-02-01 02:21:28 UTC (rev 4352)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2006 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -40,6 +40,7 @@
   float omega() const { return d_omega;}
   float gain_mu() const { return d_gain_mu;}
   float gain_omega() const { return d_gain_omega;}
+  //gr_complex constellation_points () {return d_constellation_points; }
   void set_mu (float mu) { d_mu = mu; }
   void set_omega (float omega) { 
     d_omega = omega;
@@ -48,6 +49,11 @@
   }
   void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; }
   void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; }
+  void set_constellation_points (const std::vector<gr_complex > 
&constellation_points) { 
+    d_constellation_points = constellation_points; 
+    //d_I=constellation_points.size();
+    //d_Q=constellation_points[0].size();
+  }
   float alpha() const { return d_alpha; }
   float beta() const { return d_beta; }
   float freq() const { return d_freq; }

Modified: 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/python/gnuradio/blksimpl/qam16.py
===================================================================
--- 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/python/gnuradio/blksimpl/qam16.py
      2007-02-01 02:07:51 UTC (rev 4351)
+++ 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/python/gnuradio/blksimpl/qam16.py
      2007-02-01 02:21:28 UTC (rev 4352)
@@ -22,7 +22,7 @@
 # See gnuradio-examples/python/digital for examples
 
 """
-QAM16 modulation and demodulation.
+differential QPSK modulation and demodulation.
 """
 
 from gnuradio import gr, gru, modulation_utils
@@ -32,19 +32,33 @@
 import Numeric
 from pprint import pprint
 
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 2
+"""
+# default values for 8psk(used in __init__ and add_options)
+_def_samples_per_symbol = 3
 _def_excess_bw = 0.35
 _def_gray_code = True
 _def_verbose = False
 _def_log = False
 
-_def_costas_alpha = None
-_def_gain_mu = 0.03
-_def_mu = 0.05
+_def_costas_alpha = 0.5
+_def_gain_mu = 0.3
+_def_mu = 0.5
 _def_omega_relative_limit = 0.005
+"""
 
+# default values for qam (used in __init__ and add_options)
+_def_samples_per_symbol = 2
+_def_excess_bw = 0.35
+_def_gray_code = True
+_def_verbose = False
+_def_log = False
 
+_def_costas_alpha = 0.5 #None
+_def_gain_mu = 0.3 #0.03
+_def_mu = 0.4 #0.05
+_def_omega_relative_limit = 0.005 #0.005
+
+
 # /////////////////////////////////////////////////////////////////////////////
 #                           QAM16 modulator
 # /////////////////////////////////////////////////////////////////////////////
@@ -178,7 +192,7 @@
 #
 # /////////////////////////////////////////////////////////////////////////////
 
-class qam16_demod(gr.hier_block):
+class qam16_demod_uit(gr.hier_block):
 
     def __init__(self, fg,
                  samples_per_symbol=_def_samples_per_symbol,
@@ -195,11 +209,206 @@
         pass
     
     def bits_per_symbol(self=None):   # staticmethod that's also callable on 
an instance
+        return 6
+    bits_per_symbol = staticmethod(bits_per_symbol)      # make it a static 
method.  RTFM
+
+    
+# /////////////////////////////////////////////////////////////////////////////
+#                           QAM16 demodulator
+#
+# Differentially coherent detection of differentially encoded qam16
+# /////////////////////////////////////////////////////////////////////////////
+
+class qam16_demod(gr.hier_block):
+
+    def __init__(self, fg,
+                 samples_per_symbol=_def_samples_per_symbol,
+                 excess_bw=_def_excess_bw,
+                 costas_alpha=_def_costas_alpha,
+                 gain_mu=_def_gain_mu,
+                 mu=_def_mu,
+                 omega_relative_limit=_def_omega_relative_limit,
+                 gray_code=_def_gray_code,
+                 verbose=_def_verbose,
+                 log=_def_log):
+        """
+       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 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
+        @type costas_alphas: float
+        @param gain_mu: for M&M block
+        @type gain_mu: float
+        @param mu: for M&M block
+        @type mu: float
+        @param omega_relative_limit: for M&M block
+        @type omega_relative_limit: float
+        @param gray_code: Tell modulator to Gray code the bits
+        @type gray_code: bool
+        @param verbose: Print information about modulator?
+        @type verbose: bool
+        @param debug: Print modualtion data to files?
+        @type debug: bool
+       """
+
+        self._fg = fg
+        self._samples_per_symbol = samples_per_symbol
+        self._excess_bw = excess_bw
+        self._costas_alpha = costas_alpha
+        self._mm_gain_mu = gain_mu
+        self._mm_mu = mu
+        self._mm_omega_relative_limit = omega_relative_limit
+        self._gray_code = gray_code
+
+        if samples_per_symbol < 2:
+            raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol
+
+        arity = pow(2,self.bits_per_symbol())
+ 
+        # Automatic gain control
+        scale = (1.0/16384.0)
+        self.pre_scaler = gr.multiply_const_cc(scale)   # scale the signal 
from full-range to +-1
+        self.agc = gr.agc2_cc(2e-1, 1e-3, 1, 1, 100)
+        #self.agc = gr.feedforward_agc_cc(16, 1.0)
+
+        # RRC data filter
+        ntaps = 11 * samples_per_symbol
+        self.rrc_taps = gr.firdes.root_raised_cosine(
+            1.0,                      # gain
+            self._samples_per_symbol, # sampling rate
+            1.0,                      # symbol rate
+            self._excess_bw,          # excess bandwidth (roll-off factor)
+            ntaps)
+        self.rrc_filter=gr.interp_fir_filter_ccf(1, self.rrc_taps)        
+
+        # symbol clock recovery
+        self._mm_omega = self._samples_per_symbol
+        self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu
+        self._costas_beta  = 0.25 * self._costas_alpha * self._costas_alpha
+        fmin = -0.05
+        fmax = 0.05
+
+        self.receiver=gr.mpsk_receiver_cc(arity, 0,
+                                         self._costas_alpha, self._costas_beta,
+                                         fmin, fmax,
+                                         self._mm_mu, self._mm_gain_mu,
+                                         self._mm_omega, self._mm_gain_omega,
+                                         self._mm_omega_relative_limit)
+        # Perform Differential decoding on the constellation
+        self.diffdec = gr.diff_phasor_cc()
+        self.diffdec_bb = gr.diff_decoder_bb(arity)
+        # find closest constellation point
+        rot = 1
+        rotated_const = map(lambda pt: pt * rot, qam.constellation[arity])
+        self._mm_constellation=rotated_const[:]
+        self._mm_constellation.reverse()
+        #self._mm_constellation=[]
+        #for i in range(8):
+        #  self._mm_constellation.append([])
+        #  for q in range(8):
+        #    self._mm_constellation[i].append(rotated_const[i*8+q])
+        #print "self._mm_constellation",self._mm_constellation
+        #self._mm_constellation=rotated_const
+        self.receiver.set_constellation_points(self._mm_constellation)
+        self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity))
+
+        if self._gray_code:
+            self.symbol_mapper = gr.map_bb(qam.gray_to_binary[arity])
+        else:
+            self.symbol_mapper = gr.map_bb(qam.ungray_to_binary[arity])
+
+        
+        # unpack the k bit vector into a stream of bits
+        self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol())
+
+        if verbose:
+            self._print_verbage()
+        
+        if log:
+            self._setup_logging()
+ 
+        # Connect & Initialize base class
+        self._fg.connect(self.pre_scaler, self.agc, self.rrc_filter, 
self.receiver,
+                           self.slicer, self.diffdec_bb,self.symbol_mapper, 
self.unpack)
+                         #self.diffdec, self.slicer, self.symbol_mapper, 
self.unpack)
+        gr.hier_block.__init__(self, self._fg, self.pre_scaler, self.unpack)
+
+    def samples_per_symbol(self):
+        return self._samples_per_symbol
+
+    def bits_per_symbol(self=None):   # staticmethod that's also callable on 
an instance
         return 4
     bits_per_symbol = staticmethod(bits_per_symbol)      # make it a static 
method.  RTFM
 
+    def _print_verbage(self):
+        print "\nDemodulator:"
+        print "bits per symbol:     %d"   % self.bits_per_symbol()
+        print "Gray code:           %s"   % self._gray_code
+        print "RRC roll-off factor: %.2f" % self._excess_bw
+        print "Costas Loop alpha:   %.2e" % self._costas_alpha
+        print "Costas Loop beta:    %.2e" % self._costas_beta
+        print "M&M mu:              %.2f" % self._mm_mu
+        print "M&M mu gain:         %.2e" % self._mm_gain_mu
+        print "M&M omega:           %.2f" % self._mm_omega
+        print "M&M omega gain:      %.2e" % self._mm_gain_omega
+        print "M&M omega limit:     %.2f" % self._mm_omega_relative_limit
+        
+
+    def _setup_logging(self):
+        print "Modulation logging turned on."
+        self._fg.connect(self.pre_scaler,
+                         gr.file_sink(gr.sizeof_gr_complex, 
"rx_prescaler.dat"))
+        self._fg.connect(self.agc,
+                         gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat"))
+        self._fg.connect(self.rrc_filter,
+                         gr.file_sink(gr.sizeof_gr_complex, 
"rx_rrc_filter.dat"))
+        self._fg.connect(self.receiver,
+                         gr.file_sink(gr.sizeof_gr_complex, "rx_receiver.dat"))
+        self._fg.connect(self.diffdec,
+                         gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat")) 
       
+        self._fg.connect(self.slicer,
+                         gr.file_sink(gr.sizeof_char, "rx_slicer.dat"))
+        self._fg.connect(self.symbol_mapper,
+                         gr.file_sink(gr.sizeof_char, "rx_gray_decoder.dat"))
+        self._fg.connect(self.unpack,
+                         gr.file_sink(gr.sizeof_char, "rx_unpack.dat"))
+
+    def add_options(parser):
+        """
+        Adds modulation-specific options to the standard parser
+        """
+        parser.add_option("", "--excess-bw", type="float", 
default=_def_excess_bw,
+                          help="set RRC excess bandwith factor 
[default=%default] (PSK)")
+        parser.add_option("", "--no-gray-code", dest="gray_code",
+                          action="store_false", default=_def_gray_code,
+                          help="disable gray coding on modulated bits (PSK)")
+        parser.add_option("", "--costas-alpha", type="float", default=None,
+                          help="set Costas loop alpha value [default=%default] 
(PSK)")
+        parser.add_option("", "--gain-mu", type="float", default=_def_gain_mu,
+                          help="set M&M symbol sync loop gain mu value 
[default=%default] (PSK)")
+        parser.add_option("", "--mu", type="float", default=_def_mu,
+                          help="set M&M symbol sync loop mu value 
[default=%default] (PSK)")
+    add_options=staticmethod(add_options)
+
+    def extract_kwargs_from_options(options):
+        """
+        Given command line options, create dictionary suitable for passing to 
__init__
+        """
+        return modulation_utils.extract_kwargs_from_options(
+            qam16_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('qam16', qam16_mod)
-#modulation_utils.add_type_1_demod('qam16', qam16_demod)
+modulation_utils.add_type_1_demod('qam16', qam16_demod)

Modified: 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/python/gnuradio/blksimpl/qam64.py
===================================================================
--- 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/python/gnuradio/blksimpl/qam64.py
      2007-02-01 02:07:51 UTC (rev 4351)
+++ 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-core/src/python/gnuradio/blksimpl/qam64.py
      2007-02-01 02:21:28 UTC (rev 4352)
@@ -32,19 +32,33 @@
 import Numeric
 from pprint import pprint
 
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 2
+"""
+# default values for 8psk(used in __init__ and add_options)
+_def_samples_per_symbol = 3
 _def_excess_bw = 0.35
 _def_gray_code = True
 _def_verbose = False
 _def_log = False
 
-_def_costas_alpha = None
-_def_gain_mu = 0.03
-_def_mu = 0.05
+_def_costas_alpha = 0.5
+_def_gain_mu = 0.3
+_def_mu = 0.5
 _def_omega_relative_limit = 0.005
+"""
 
+# default values for qam (used in __init__ and add_options)
+_def_samples_per_symbol = 2
+_def_excess_bw = 0.35
+_def_gray_code = True
+_def_verbose = False
+_def_log = False
 
+_def_costas_alpha = 0.5 #None
+_def_gain_mu = 0.3 #0.03
+_def_mu = 0.4 #0.05
+_def_omega_relative_limit = 0.005 #0.005
+
+
 # /////////////////////////////////////////////////////////////////////////////
 #                           QAM64 modulator
 # /////////////////////////////////////////////////////////////////////////////
@@ -178,7 +192,7 @@
 #
 # /////////////////////////////////////////////////////////////////////////////
 
-class qam64_demod(gr.hier_block):
+class qam64_demod_uit(gr.hier_block):
 
     def __init__(self, fg,
                  samples_per_symbol=_def_samples_per_symbol,
@@ -198,8 +212,201 @@
         return 6
     bits_per_symbol = staticmethod(bits_per_symbol)      # make it a static 
method.  RTFM
 
+    
+# /////////////////////////////////////////////////////////////////////////////
+#                           QAM64 demodulator
 #
+# Differentially coherent detection of differentially encoded qam64
+# /////////////////////////////////////////////////////////////////////////////
+
+class qam64_demod(gr.hier_block):
+
+    def __init__(self, fg,
+                 samples_per_symbol=_def_samples_per_symbol,
+                 excess_bw=_def_excess_bw,
+                 costas_alpha=_def_costas_alpha,
+                 gain_mu=_def_gain_mu,
+                 mu=_def_mu,
+                 omega_relative_limit=_def_omega_relative_limit,
+                 gray_code=_def_gray_code,
+                 verbose=_def_verbose,
+                 log=_def_log):
+        """
+       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 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
+        @type costas_alphas: float
+        @param gain_mu: for M&M block
+        @type gain_mu: float
+        @param mu: for M&M block
+        @type mu: float
+        @param omega_relative_limit: for M&M block
+        @type omega_relative_limit: float
+        @param gray_code: Tell modulator to Gray code the bits
+        @type gray_code: bool
+        @param verbose: Print information about modulator?
+        @type verbose: bool
+        @param debug: Print modualtion data to files?
+        @type debug: bool
+       """
+
+        self._fg = fg
+        self._samples_per_symbol = samples_per_symbol
+        self._excess_bw = excess_bw
+        self._costas_alpha = costas_alpha
+        self._mm_gain_mu = gain_mu
+        self._mm_mu = mu
+        self._mm_omega_relative_limit = omega_relative_limit
+        self._gray_code = gray_code
+
+        if samples_per_symbol < 2:
+            raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol
+
+        arity = pow(2,self.bits_per_symbol())
+ 
+        # Automatic gain control
+        scale = (1.0/16384.0)
+        self.pre_scaler = gr.multiply_const_cc(scale)   # scale the signal 
from full-range to +-1
+        self.agc = gr.agc2_cc(2e-1, 1e-3, 1, 1, 100)
+        #self.agc = gr.feedforward_agc_cc(16, 1.0)
+
+        # RRC data filter
+        ntaps = 11 * samples_per_symbol
+        self.rrc_taps = gr.firdes.root_raised_cosine(
+            1.0,                      # gain
+            self._samples_per_symbol, # sampling rate
+            1.0,                      # symbol rate
+            self._excess_bw,          # excess bandwidth (roll-off factor)
+            ntaps)
+        self.rrc_filter=gr.interp_fir_filter_ccf(1, self.rrc_taps)        
+
+        # symbol clock recovery
+        self._mm_omega = self._samples_per_symbol
+        self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu
+        self._costas_beta  = 0.25 * self._costas_alpha * self._costas_alpha
+        fmin = -0.05
+        fmax = 0.05
+
+        self.receiver=gr.mpsk_receiver_cc(arity, 0,
+                                         self._costas_alpha, self._costas_beta,
+                                         fmin, fmax,
+                                         self._mm_mu, self._mm_gain_mu,
+                                         self._mm_omega, self._mm_gain_omega,
+                                         self._mm_omega_relative_limit)
+        # Perform Differential decoding on the constellation
+        self.diffdec = gr.diff_phasor_cc()
+
+        # find closest constellation point
+        rot = 1
+        rotated_const = map(lambda pt: pt * rot, qam.constellation[arity])
+        self._mm_constellation=rotated_const
+        #self._mm_constellation=[]
+        #for i in range(8):
+        #  self._mm_constellation.append([])
+        #  for q in range(8):
+        #    self._mm_constellation[i].append(rotated_const[i*8+q])
+        #print "self._mm_constellation",self._mm_constellation
+        #self._mm_constellation=rotated_const
+        self.receiver.set_constellation_points(self._mm_constellation)
+        self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity))
+
+        if self._gray_code:
+            self.symbol_mapper = gr.map_bb(qam.gray_to_binary[arity])
+        else:
+            self.symbol_mapper = gr.map_bb(qam.ungray_to_binary[arity])
+
+        
+        # unpack the k bit vector into a stream of bits
+        self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol())
+
+        if verbose:
+            self._print_verbage()
+        
+        if log:
+            self._setup_logging()
+ 
+        # Connect & Initialize base class
+        self._fg.connect(self.pre_scaler, self.agc, self.rrc_filter, 
self.receiver,
+                         self.diffdec, self.slicer, self.symbol_mapper, 
self.unpack)
+        gr.hier_block.__init__(self, self._fg, self.pre_scaler, self.unpack)
+
+    def samples_per_symbol(self):
+        return self._samples_per_symbol
+
+    def bits_per_symbol(self=None):   # staticmethod that's also callable on 
an instance
+        return 6
+    bits_per_symbol = staticmethod(bits_per_symbol)      # make it a static 
method.  RTFM
+
+    def _print_verbage(self):
+        print "\nDemodulator:"
+        print "bits per symbol:     %d"   % self.bits_per_symbol()
+        print "Gray code:           %s"   % self._gray_code
+        print "RRC roll-off factor: %.2f" % self._excess_bw
+        print "Costas Loop alpha:   %.2e" % self._costas_alpha
+        print "Costas Loop beta:    %.2e" % self._costas_beta
+        print "M&M mu:              %.2f" % self._mm_mu
+        print "M&M mu gain:         %.2e" % self._mm_gain_mu
+        print "M&M omega:           %.2f" % self._mm_omega
+        print "M&M omega gain:      %.2e" % self._mm_gain_omega
+        print "M&M omega limit:     %.2f" % self._mm_omega_relative_limit
+        
+
+    def _setup_logging(self):
+        print "Modulation logging turned on."
+        self._fg.connect(self.pre_scaler,
+                         gr.file_sink(gr.sizeof_gr_complex, 
"rx_prescaler.dat"))
+        self._fg.connect(self.agc,
+                         gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat"))
+        self._fg.connect(self.rrc_filter,
+                         gr.file_sink(gr.sizeof_gr_complex, 
"rx_rrc_filter.dat"))
+        self._fg.connect(self.receiver,
+                         gr.file_sink(gr.sizeof_gr_complex, "rx_receiver.dat"))
+        self._fg.connect(self.diffdec,
+                         gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat")) 
       
+        self._fg.connect(self.slicer,
+                         gr.file_sink(gr.sizeof_char, "rx_slicer.dat"))
+        self._fg.connect(self.symbol_mapper,
+                         gr.file_sink(gr.sizeof_char, "rx_gray_decoder.dat"))
+        self._fg.connect(self.unpack,
+                         gr.file_sink(gr.sizeof_char, "rx_unpack.dat"))
+
+    def add_options(parser):
+        """
+        Adds modulation-specific options to the standard parser
+        """
+        parser.add_option("", "--excess-bw", type="float", 
default=_def_excess_bw,
+                          help="set RRC excess bandwith factor 
[default=%default] (PSK)")
+        parser.add_option("", "--no-gray-code", dest="gray_code",
+                          action="store_false", default=_def_gray_code,
+                          help="disable gray coding on modulated bits (PSK)")
+        parser.add_option("", "--costas-alpha", type="float", default=None,
+                          help="set Costas loop alpha value [default=%default] 
(PSK)")
+        parser.add_option("", "--gain-mu", type="float", default=_def_gain_mu,
+                          help="set M&M symbol sync loop gain mu value 
[default=%default] (PSK)")
+        parser.add_option("", "--mu", type="float", default=_def_mu,
+                          help="set M&M symbol sync loop mu value 
[default=%default] (PSK)")
+    add_options=staticmethod(add_options)
+
+    def extract_kwargs_from_options(options):
+        """
+        Given command line options, create dictionary suitable for passing to 
__init__
+        """
+        return modulation_utils.extract_kwargs_from_options(
+            qam64_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('qam64', qam64_mod)
-#modulation_utils.add_type_1_demod('qam16', qam16_demod)
+modulation_utils.add_type_1_demod('qam64', qam64_demod)

Added: 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-examples/python/digital/benchmark_rx_oscope.py
===================================================================
--- 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-examples/python/digital/benchmark_rx_oscope.py
                          (rev 0)
+++ 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-examples/python/digital/benchmark_rx_oscope.py
  2007-02-01 02:21:28 UTC (rev 4352)
@@ -0,0 +1,412 @@
+#!/usr/bin/env python
+#
+# Copyright 2005,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., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+
+from gnuradio import gr, gru, modulation_utils
+from gnuradio import usrp
+from gnuradio import eng_notation
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+import random
+import struct
+import sys
+
+# from current dir
+from receive_path import receive_path
+import fusb_options
+
+#import os
+#print os.getpid()
+#raw_input('Attach and press enter: ')
+
+
+class my_graph(gr.flow_graph):
+
+    def __init__(self, demod_class, rx_callback, options):
+        gr.flow_graph.__init__(self)
+        self.rxpath = receive_path(self, demod_class, rx_callback, options)
+
+#!/usr/bin/env python
+#
+# Copyright 2004,2005,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., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+
+# print "Loading revised usrp_oscope with additional options for scopesink..."
+
+from gnuradio import gr, gru
+from gnuradio import usrp
+from gnuradio import eng_notation
+from gnuradio.eng_option import eng_option
+from gnuradio.wxgui import stdgui, fftsink, waterfallsink, scopesink, form, 
slider
+from optparse import OptionParser
+import wx
+import sys
+
+
+def pick_subdevice(u):
+    """
+    The user didn't specify a subdevice on the command line.
+    If there's a daughterboard on A, select A.
+    If there's a daughterboard on B, select B.
+    Otherwise, select A.
+    """
+    if u.db[0][0].dbid() >= 0:       # dbid is < 0 if there's no d'board or a 
problem
+        return (0, 0)
+    if u.db[1][0].dbid() >= 0:
+        return (1, 0)
+    return (0, 0)
+
+
+#class my_graph(gr.flow_graph):
+#
+#    def __init__(self, demod_class, rx_callback, options):
+#        gr.flow_graph.__init__(self)
+#        self.rxpath = receive_path(self, demod_class, rx_callback, options)
+        
+class app_flow_graph(stdgui.gui_flow_graph):
+    def __init__(self, frame, panel, vbox, argv):
+        stdgui.gui_flow_graph.__init__(self)
+        
+        global n_rcvd, n_right
+    
+        n_rcvd = 0
+        n_right = 0
+        
+        def rx_callback(ok, payload):
+            global n_rcvd, n_right
+            (pktno,) = struct.unpack('!H', payload[0:2])
+            n_rcvd += 1
+            if ok:
+                n_right += 1
+    
+            print "ok = %5s  pktno = %4d  n_rcvd = %4d  n_right = %4d" % (
+                ok, pktno, n_rcvd, n_right)
+    
+    
+        demods = modulation_utils.type_1_demods()
+    
+        # Create Options Parser:
+        parser = OptionParser (option_class=eng_option, 
conflict_handler="resolve")
+        expert_grp = parser.add_option_group("Expert")
+    
+        parser.add_option("-m", "--modulation", type="choice", 
choices=demods.keys(), 
+                          default='gmsk',
+                          help="Select modulation from: %s [default=%%default]"
+                                % (', '.join(demods.keys()),))
+        parser.add_option("-n", "--frame-decim", type="int", default=1,
+                          help="set oscope frame decimation factor to n 
[default=1]")
+        parser.add_option("-v", "--v-scale", type="eng_float", default=1000,
+                          help="set oscope initial V/div to SCALE 
[default=%default]")
+        parser.add_option("-t", "--t-scale", type="eng_float", default=49e-6,
+                          help="set oscope initial s/div to SCALE 
[default=50us]")
+        
+        receive_path.add_options(parser, expert_grp)
+        
+        self.show_debug_info = True
+        
+        for mod in demods.values():
+            mod.add_options(expert_grp)
+    
+        fusb_options.add_options(expert_grp)
+        (options, args) = parser.parse_args ()
+    
+        if len(args) != 0:
+            parser.print_help(sys.stderr)
+            sys.exit(1)
+    
+        if options.rx_freq is None:
+            sys.stderr.write("You must specify -f FREQ or --freq FREQ\n")
+            parser.print_help(sys.stderr)
+            sys.exit(1)
+    
+    
+        # build the graph
+        #fg = my_graph(demods[options.modulation], rx_callback, options)
+        demod_class=demods[options.modulation]
+        #rx_callback=rx_callback, 
+        #options=options
+        r = gr.enable_realtime_scheduling()
+        if r != gr.RT_OK:
+            print "Warning: Failed to enable realtime scheduling."
+    
+        #fg.start()        # start flow graph
+        #fg.wait()         # wait for it to finish
+        self.rxpath = receive_path(self, demod_class, rx_callback, options)
+        self.demodulator=self.rxpath.packet_receiver._demodulator
+        self.receiver=self.rxpath.packet_receiver._demodulator.receiver
+        self.frame = frame
+        self.panel = panel
+        
+        input_rate=64.0e6/self.rxpath._decim
+        self.scope = scopesink.scope_sink_c(self, panel, 
sample_rate=input_rate,
+                                            frame_decim=options.frame_decim,
+                                            v_scale=options.v_scale,
+                                            t_scale=options.t_scale)
+        #print self.rxpath.packet_receiver._demodulator
+        self.connect(self.receiver, self.scope)
+
+        self._build_gui(vbox)
+
+
+        #if self.show_debug_info:
+        #    self.myform['decim'].set_value(self.u.decim_rate())
+        #    self.myform['address@hidden'].set_value(self.u.adc_freq() / 
self.u.decim_rate())
+        #    self.myform['dbname'].set_value(self.subdev.name())
+        #    self.myform['baseband'].set_value(0)
+        #    self.myform['ddc'].set_value(0)
+                        
+        if not(self.set_freq(self.rxpath.freq)):
+            self._set_status_msg("Failed to set initial frequency")
+        
+        if not(self.set_alpha(self.receiver.alpha())):
+            self._set_status_msg("Failed to set initial alpha")
+        if not(self.set_beta(self.receiver.beta())):
+            self._set_status_msg("Failed to set initial beta")  
+        if not(self.set_mu(self.receiver.mu())):
+            self._set_status_msg("Failed to set initial mu")   
+        if not(self.set_gain_mu(self.receiver.gain_mu())):
+            self._set_status_msg("Failed to set initial gain_mu")   
+        if not(self.set_omega(float(self.receiver.omega()))):
+            self._set_status_msg("Failed to set initial omega")   
+        if not(self.set_gain_omega(self.receiver.gain_omega())):
+            self._set_status_msg("Failed to set initial gain_omega")           
  
+        
+
+    def _set_status_msg(self, msg):
+        self.frame.GetStatusBar().SetStatusText(msg, 0)
+
+    def _build_gui(self, vbox):
+
+        def _form_set_freq(kv):
+            return self.set_freq(kv['freq'])
+
+        def _form_set_alpha(kv):
+            return self.set_alpha(kv['alpha'])
+        def _form_set_beta(kv):
+            return self.set_beta(kv['beta'])
+        def _form_set_mu(kv):
+            return self.set_mu(kv['mu'])
+        def _form_set_gain_mu(kv):
+            return self.set_gain_mu(kv['gain_mu'])
+        def _form_set_omega(kv):
+            return self.set_omega(kv['omega'])
+        def _form_set_gain_omega(kv):
+            return self.set_gain_omega(kv['gain_omega'])
+           
+        vbox.Add(self.scope.win, 10, wx.EXPAND)
+        
+        # add control area at the bottom
+        self.myform = myform = form.form()
+        hbox = wx.BoxSizer(wx.HORIZONTAL)
+        hbox.Add((5,0), 0, 0)
+        myform['freq'] = form.float_field(
+            parent=self.panel, sizer=hbox, label="Center freq", weight=1,
+            callback=myform.check_input_and_call(_form_set_freq, 
self._set_status_msg))
+        
+        hbox.Add((5,0), 0, 0)
+        myform['alpha'] = form.float_field(
+            parent=self.panel, sizer=hbox, label="alpha", weight=1,
+            callback=myform.check_input_and_call(_form_set_alpha, 
self._set_status_msg))
+        hbox.Add((5,0), 0, 0)
+        myform['beta'] = form.float_field(
+            parent=self.panel, sizer=hbox, label="beta", weight=1,
+            callback=myform.check_input_and_call(_form_set_beta, 
self._set_status_msg))
+        hbox.Add((5,0), 0, 0)
+        myform['mu'] = form.float_field(
+            parent=self.panel, sizer=hbox, label="mu", weight=1,
+            callback=myform.check_input_and_call(_form_set_mu, 
self._set_status_msg))
+        hbox.Add((5,0), 0, 0)
+        myform['gain_mu'] = form.float_field(
+            parent=self.panel, sizer=hbox, label="gain_mu", weight=1,
+            callback=myform.check_input_and_call(_form_set_gain_mu, 
self._set_status_msg))
+        hbox.Add((5,0), 0, 0)
+        myform['omega'] = form.float_field(
+            parent=self.panel, sizer=hbox, label="omega", weight=1,
+            callback=myform.check_input_and_call(_form_set_omega, 
self._set_status_msg))
+        hbox.Add((5,0), 0, 0)
+        myform['gain_omega'] = form.float_field(
+            parent=self.panel, sizer=hbox, label="gain_omega", weight=1,
+            callback=myform.check_input_and_call(_form_set_gain_omega, 
self._set_status_msg))
+        
+        hbox.Add((5,0), 0, 0)
+        g = self.rxpath.subdev.gain_range() #(0.0,20.0) 
#self.subdev.gain_range()
+        myform['gain'] = form.slider_field(parent=self.panel, sizer=hbox, 
label="Gain",
+                                           weight=3,
+                                           min=int(g[0]), max=int(g[1]),
+                                           callback=self.set_gain)
+
+        hbox.Add((5,0), 0, 0)
+        vbox.Add(hbox, 0, wx.EXPAND)
+
+        #self._build_subpanel(vbox)
+
+    def _build_subpanel(self, vbox_arg):
+        # build a secondary information panel (sometimes hidden)
+
+        # FIXME figure out how to have this be a subpanel that is always
+        # created, but has its visibility controlled by foo.Show(True/False)
+        
+        def _form_set_decim(kv):
+            return self.set_decim(kv['decim'])
+
+        if not(self.show_debug_info):
+            return
+
+        panel = self.panel
+        vbox = vbox_arg
+        myform = self.myform
+
+        #panel = wx.Panel(self.panel, -1)
+        #vbox = wx.BoxSizer(wx.VERTICAL)
+
+        hbox = wx.BoxSizer(wx.HORIZONTAL)
+        hbox.Add((5,0), 0)
+        
+        myform['decim'] = form.int_field(
+            parent=panel, sizer=hbox, label="Decim",
+            callback=myform.check_input_and_call(_form_set_decim, 
self._set_status_msg))
+
+        hbox.Add((5,0), 1)
+        myform['address@hidden'] = form.static_float_field(
+            parent=panel, sizer=hbox, label="address@hidden")
+
+        hbox.Add((5,0), 1)
+        myform['dbname'] = form.static_text_field(
+            parent=panel, sizer=hbox)
+
+        hbox.Add((5,0), 1)
+        myform['baseband'] = form.static_float_field(
+            parent=panel, sizer=hbox, label="Analog BB")
+
+        hbox.Add((5,0), 1)
+        myform['ddc'] = form.static_float_field(
+            parent=panel, sizer=hbox, label="DDC")
+
+        hbox.Add((5,0), 0)
+        vbox.Add(hbox, 0, wx.EXPAND)
+
+        
+    def set_freq(self, target_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.
+        """
+        self.rxpath.set_freq(target_freq)
+        #r = usrp.tune(self.u, 0, self.subdev, target_freq)
+        
+        if True:
+            self.myform['freq'].set_value(target_freq)     # update displayed 
value
+            #if self.show_debug_info:
+                #self.myform['baseband'].set_value(r.baseband_freq)
+                #self.myform['ddc'].set_value(r.dxc_freq)
+            return True
+
+        return False
+
+    def set_gain(self, gain):
+        self.myform['gain'].set_value(gain)     # update displayed value
+        self.rxpath.set_gain(gain)
+        #self.subdev.set_gain(gain)
+
+    def set_alpha(self, alpha):
+        self.myform['alpha'].set_value(alpha)     # update displayed value
+        self.receiver.set_alpha(alpha)
+        self.set_beta(0.25 * alpha * alpha)
+        return True
+
+    def set_beta(self, beta):
+        self.myform['beta'].set_value(beta)     # update displayed value
+        self.receiver.set_beta(beta)
+        return True
+        
+    def set_omega(self, omega):
+        self.myform['omega'].set_value(omega)     # update displayed value
+        self.receiver.set_omega(omega)
+        return True
+
+    def set_gain_omega(self, gain_omega):
+        self.myform['gain_omega'].set_value(gain_omega)     # update displayed 
value
+        self.receiver.set_gain_omega(gain_omega)        
+        return True
+    
+    def set_mu(self, mu):
+        self.myform['mu'].set_value(mu)     # update displayed value
+        self.receiver.set_mu(mu)
+        return True
+
+    def set_gain_mu(self, gain_mu):
+        self.myform['gain_mu'].set_value(gain_mu)     # update displayed value
+        self.receiver.set_mu(gain_mu)
+        self.set_gain_omega(0.25 * gain_mu * gain_mu)
+        return True
+"""
+    def set_decim(self, decim):
+        ok = self.u.set_decim_rate(decim)
+        if not ok:
+            print "set_decim failed"
+        input_rate = self.u.adc_freq() / self.u.decim_rate()
+        self.scope.set_sample_rate(input_rate)
+        if self.show_debug_info:  # update displayed values
+            self.myform['decim'].set_value(self.u.decim_rate())
+            self.myform['address@hidden'].set_value(self.u.adc_freq() / 
self.u.decim_rate())
+        return ok
+"""
+
+# /////////////////////////////////////////////////////////////////////////////
+#                                   main
+# /////////////////////////////////////////////////////////////////////////////
+
+global n_rcvd, n_right
+
+def main():
+    app = stdgui.stdapp(app_flow_graph, "USRP QAM O'scope", nstatus=1)
+    app.MainLoop()
+
+if __name__ == '__main__':
+    try:
+        main()
+    except KeyboardInterrupt:
+        pass


Property changes on: 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-examples/python/digital/benchmark_rx_oscope.py
___________________________________________________________________
Name: svn:executable
   + *

Modified: 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-examples/python/digital/receive_path.py
===================================================================
--- 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-examples/python/digital/receive_path.py
 2007-02-01 02:07:51 UTC (rev 4351)
+++ 
gnuradio/branches/developers/nldudok1/digital-wip3/gnuradio-examples/python/digital/receive_path.py
 2007-02-01 02:21:28 UTC (rev 4352)
@@ -51,6 +51,8 @@
         self._rx_callback   = rx_callback      # this callback is fired when 
there's a packet available
         self._demod_class   = demod_class      # the demodulator_class we're 
using
 
+        self.u=None
+        self.subdev=None
         if self._rx_freq is None:
             sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be 
specified\n")
             raise SystemExit
@@ -146,6 +148,7 @@
         the result of that operation and our target_frequency to
         determine the value for the digital up converter.
         """
+        self.freq=target_freq
         r = self.u.tune(0, self.subdev, target_freq)
         if r:
             return True





reply via email to

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