Should not be clipping the error here.
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_mpsk_receiver_cc.cc
index cdb5bdc0ea49801f157a2226b80b23830e1ecf15..89ea4a232c1f0bb2d91a52708f5c6ef7dd23515a 100644 (file)
@@ -35,7 +35,7 @@
 
 #define M_TWOPI (2*M_PI)
 #define VERBOSE_MM     0     // Used for debugging symbol timing loop
-#define VERBOSE_COSTAS 0     // Used for debugging phase and frequency tracking
+#define VERBOSE_COSTAS 1     // Used for debugging phase and frequency tracking
 
 // Public constructor
 
@@ -123,9 +123,21 @@ gr_mpsk_receiver_cc::forecast(int noutput_items, gr_vector_int &ninput_items_req
 float
 gr_mpsk_receiver_cc::phase_error_detector_qpsk(gr_complex sample) const
 {
-  float phase_error = -((sample.real()>0 ? 1.0 : -1.0) * sample.imag() -
-                       (sample.imag()>0 ? 1.0 : -1.0) * sample.real());
-  return -phase_error;
+  float phase_error = 0;
+  if(fabsf(sample.real()) > fabsf(sample.imag())) {
+    if(sample.real() > 0)
+      phase_error = -sample.imag();
+    else
+      phase_error = sample.imag();
+  }
+  else {
+    if(sample.imag() > 0)
+      phase_error = sample.real();
+    else
+      phase_error = -sample.real();
+  }
+  
+  return phase_error;
 }
 
 float
@@ -253,8 +265,6 @@ gr_mpsk_receiver_cc::phase_error_tracking(gr_complex sample)
 
   // Make phase and frequency corrections based on sampled value
   phase_error = (*this.*d_phase_error_detector)(sample);
-
-  phase_error = gr_branchless_clip(phase_error, 1.0);
     
   d_freq += d_beta*phase_error;             // adjust frequency based on error
   d_phase += d_freq + d_alpha*phase_error;  // adjust phase based on error