commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r3458 - gnuradio/branches/developers/jcorgan/wip/ezdop


From: jcorgan
Subject: [Commit-gnuradio] r3458 - gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src
Date: Sat, 2 Sep 2006 14:32:03 -0600 (MDT)

Author: jcorgan
Date: 2006-09-02 14:32:03 -0600 (Sat, 02 Sep 2006)
New Revision: 3458

Modified:
   gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src/doppler.cc
   gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src/doppler.h
   gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src/hunter.cc
Log:
Work in progress conversion to use libezdop.

Modified: 
gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src/doppler.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src/doppler.cc   
    2006-09-02 20:31:30 UTC (rev 3457)
+++ 
gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src/doppler.cc   
    2006-09-02 20:32:03 UTC (rev 3458)
@@ -26,7 +26,7 @@
 #include <wx/frame.h>
 
 // Boost includes
-#include <boost/shared_array.hpp>
+#include <boost/scoped_array.hpp>
 
 // System level includes
 #include <cmath>
@@ -97,16 +97,21 @@
     wxASSERT(gui);
 
     m_thread = NULL;
+    m_gui = gui;
 
+    m_phase = complex<float>(0.0, 0.0);
+    m_output = complex<float>(0.0, 0.0);
+    m_alpha = complex<float>(0.0, 0.0);
+    m_beta = complex<float>(0.0, 0.0);
 
-    m_gui = gui;
-    m_phase = 0.0;
     m_offset = 0.0;
+    m_angle = 0.0;
         
     for(int i = 0; i < NUM_RATES; i++) 
         m_calibration[i] = 0.0;
     
     m_ezdop = ezdop_sptr(new ezdop());
+    m_selected_rate = DEFAULT_SELECTED_ROTATION_RATE;
 }
 
 EZDoppler::~EZDoppler()
@@ -174,123 +179,116 @@
 bool EZDoppler::SelectRotationRate(int n)
 {
     wxASSERT(n >= 0 && n < 6);
-    return m_ezdop->set_rate(rotation_rates[n]);
+    wxLogDebug(_T("EZDoppler::SelectRotationRate: %i %i"), n, 
(int)(2000/rotation_rates[n]));
+    m_selected_rate = n;
+    return m_ezdop->set_rate(2000/rotation_rates[n]);
 }
 
 int EZDoppler::GetRotationRate()
 {
-    int rate = m_ezdop->rate();
-    for (int i = 0; i < 6; i++)
-        if (rate == rotation_rates[i])
-            return i;
-
-    return -1;
+    return m_selected_rate;
 }
 
-// HMM: Can I delete this?
-bool EZDoppler::Zero()
-{
-    return true;
-}
-
 bool EZDoppler::SetFilter(int n)
 {
     // TODO: reimplement filtering
+
+    float beta = 10.0/(n*n* m_ezdop->rate()); // Empirically determined
+
+    m_alpha = complex<float>(1.0-beta, 0.0);
+    m_beta = complex<float>(beta, 0.0);
+
+    wxLogDebug(_T("EZDoppler::SetFilter: %i %f %f"), n, 1.0-beta, beta);
     return true;
 }
 
-typedef boost::shared_array<complex<float> > complexf_sarray;
+typedef boost::scoped_array<complex<float> > complexf_scoped_array;
 
+// IQ is 2 complex floats, maximum rate is 2000, QUANTUM is period in seconds
+complex<float> buffer[(int)(2*QUANTUM*2000)];
+
 bool EZDoppler::Sample(float &in_phase, float &quadrature, float &volume)
 {
     int nsamples = (int)(m_ezdop->rate()*QUANTUM);
-    complexf_sarray buffer = complexf_sarray(new complex<float>[nsamples]);
 
-    if (!m_ezdop->read_iq(buffer.get(), nsamples))
+    if (!m_ezdop->read_iq(buffer, nsamples))
         return false;
 
+    for (int i=0; i < nsamples; i++)
+        m_phase = m_alpha*m_phase + m_beta*buffer[i];
 
-/*
-    // m_phase is the actual instrument reading regardless of calibration
-    m_phase = atan2(m_quadrature, m_in_phase);
+    // m_angle is the actual instrument reading regardless of calibration
+    m_angle = atan2(m_phase.imag(), m_phase.real());
 
     // Calibration angle is sum of equalized offset and global offset
-    float cal = m_calibration[m_selected_rate] + m_offset;
+    float cal_angle = m_calibration[m_selected_rate] + m_offset;
 
     // Rotate I, Q by calibration angle
-    float i_cal = cos(cal);
-    float q_cal = sin(cal);
-    in_phase = m_in_phase*i_cal - m_quadrature*q_cal;
-    quadrature = m_quadrature*i_cal + m_in_phase*q_cal;
-*/
+    complex<float> cal = complex<float>(cos(cal_angle), sin(cal_angle));
+    m_output = m_phase*cal;
 
-    in_phase = 0.0;
-    quadrature = 0.0;
-    volume = 0.0;
+    in_phase = m_output.real()*nsamples;
+    quadrature = m_output.imag()*nsamples;
+    volume = 0.0; // not yet implemented in libezdop
 
+    wxLogDebug(_T("%f %f %f"), in_phase, quadrature, volume);
     return true;
 }
 
 bool EZDoppler::Calibrate(float phase)
 {
-/*
-    float offset = phase - m_phase;
+
+    float offset = phase - m_angle;
     NORMALIZEPHASE(offset);
-    m_calibration[2000/m_ezdop->rate()] = offset;
-*/
+    m_calibration[m_selected_rate] = offset;
+
     return true;
 }
 
 bool EZDoppler::SetCalibration(int rate, float offset)
 {
-/*
+
     wxASSERT(rate >= 0 && rate < 7);
     if (rate < 6)
-        m_calibration[2000/rate] = offset;
+        m_calibration[m_selected_rate] = offset;
     else
         m_offset = offset;
-*/
+
     return true;
 }
 
 float EZDoppler::GetCalibration(int rate)
 {
-/*
     wxASSERT(rate >= 0 && rate < 7);
     if (rate < 6)
         return m_calibration[rate];
     else
         return m_offset;        
-*/
+
     return 0.0;
 }
 
 bool EZDoppler::SetOffset(float offset)
 {
-/*
-    m_offset = offset-m_phase-m_calibration[m_selected_rate];
+    m_offset = offset-m_angle-m_calibration[m_selected_rate];
     NORMALIZEPHASE(m_offset);
     NORMALIZEPHASE(m_offset);
     NORMALIZEPHASE(m_offset);
-*/
 }
 
 bool EZDoppler::Nudge(float amount)
 {
-/*
     float cal = m_calibration[m_selected_rate];
     cal += amount;
     NORMALIZEPHASE(cal);
     m_calibration[m_selected_rate] = cal;
-*/
+
     return true;
 }
 
 bool EZDoppler::NudgeAll(float amount)
 {
-/*  
     m_offset += amount;
     NORMALIZEPHASE(m_offset);
     return true;
-*/
 }

Modified: 
gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src/doppler.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src/doppler.h    
    2006-09-02 20:31:30 UTC (rev 3457)
+++ 
gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src/doppler.h    
    2006-09-02 20:32:03 UTC (rev 3458)
@@ -24,6 +24,7 @@
     #include "config.h"
 #endif
 
+// Application level includes
 #include <ezdop.h>
 #include <boost/shared_ptr.hpp>
 #include <wx/event.h>
@@ -83,7 +84,6 @@
     bool IsOnline();
     bool Start();
     bool Stop();
-    bool Zero();
     bool SetFilter(int n);
     bool SelectRotationRate(int n);
     int  GetRotationRate();
@@ -98,11 +98,17 @@
             
 private:
     ezdop_sptr m_ezdop;
+    int m_selected_rate;
     wxWindow *m_gui;
     DopplerBackground *m_thread;
 
-    float m_phase;              // Actual phase of doppler before calibration
-    float m_offset;             // Global calibration angle
+    complex<float> m_phase;         // Actual phase of doppler before 
calibration
+    complex<float> m_output;        // Calibrated output phase
+    complex<float> m_alpha;         // Exponential average constant
+    complex<float> m_beta;          // Exponential average constant
+    
+    float m_angle;                  // Actual angle of doppler before 
calibration
+    float m_offset;                 // Global calibration angle
     float m_calibration[NUM_RATES]; // Individual rotation rate offset
 };    
 

Modified: 
gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src/hunter.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src/hunter.cc    
    2006-09-02 20:31:30 UTC (rev 3457)
+++ 
gnuradio/branches/developers/jcorgan/wip/ezdop/src/host/hunter/src/hunter.cc    
    2006-09-02 20:32:03 UTC (rev 3458)
@@ -606,7 +606,7 @@
     static int delay;
     
     if (which == 0) {       // Set up doppler 
-        delay = XRCCTRL(*this, "doppler_filter_slider", 
wxSlider)->GetValue()/3; // Empirically determined
+        delay = XRCCTRL(*this, "doppler_filter_slider", 
wxSlider)->GetValue()*2; // Empirically determined
         if (delay == 0)
             delay = 1;
     }





reply via email to

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