working-est copy with class-based code. still open loop

Dependencies:   mbed

Fork of analoghalls6 by N K

Revision:
9:d3b70c15baa9
Parent:
6:99ee0ce47fb2
Child:
10:b4abecccec7a
--- a/statusupdater.cpp	Wed Mar 04 15:33:32 2015 +0000
+++ b/statusupdater.cpp	Fri Mar 06 19:12:53 2015 +0000
@@ -11,13 +11,15 @@
     _motor = motor;
     _user = user;
     _fast_sample_rate = 5000;
+    _med_sample_rate = 100;
     _slow_sample_rate = 10;
     
     _time_ticker.attach_us(&time_upd_isr, 50);
 }
 
-void StatusUpdater::Config(int fast_sample_rate, int slow_sample_rate) {
+void StatusUpdater::Config(int fast_sample_rate, int med_sample_rate, int slow_sample_rate) {
     _fast_sample_rate = fast_sample_rate;
+    _med_sample_rate = med_sample_rate;
     _slow_sample_rate = slow_sample_rate;
 }
 
@@ -38,9 +40,11 @@
 void StatusUpdater::Start() {
     _time = 0;
     int fast_us = 1000000 / _fast_sample_rate;
+    int med_us = 1000000 / _med_sample_rate;
     int slow_us = 1000000 / _slow_sample_rate;
     
     int last_fast = 0;
+    int last_med = 0;
     int last_slow = 0;
     
     for(;;) {
@@ -50,17 +54,22 @@
             _inverter->UpdateVbus();
             last_fast = _time;
             
-            pc->printf("%f %f %f %f %f\n\r", _motor->angle, _motor->I_c, _motor->I_b, test_alpha, test_beta);
-            //pc->printf("%f %f %f %f\n\r", _motor->angle);
+            //pc->printf("%f %f %f %f %f\n\r", _motor->angle, _motor->I_c, _motor->I_b, test_alpha, test_beta);
+            //pc->printf("%f %f %f\n\r", test_DtcA, test_DtcB, test_DtcC);
                                     
         }
         
+        if (_time - last_med > med_us) {
+                                       
+        } 
+        
         if (_time - last_slow > slow_us) {
             
             _user->UpdateState();
             _motor->UpdateTemp();
             _inverter->UpdateTemp();
             last_slow = _time;
+            pc->printf("%f %f\n\r", test_alpha, test_beta);
                                   
             //pc->printf("%f %f\n\r", _inverter->va, _inverter->vb);
         }