stock mbed AnalogReads current loop closed and working

Dependencies:   mbed

Fork of priustroller_2 by N K

Revision:
49:0603121a0538
Parent:
48:28edb4c5c04b
Child:
50:16b43e8fe04f
--- a/callbacks.cpp	Fri Apr 17 05:19:21 2015 +0000
+++ b/callbacks.cpp	Tue Apr 21 03:52:08 2015 +0000
@@ -31,19 +31,18 @@
     dbg_loop_d = vd = c->pid_d->Update(ref_d, d_filtered);
     dbg_loop_q = vq = c->pid_q->Update(ref_q, q_filtered);
     
-    dbg_loop_d = vd = 0.0f;
-    dbg_loop_q = vq = c->user->throttle / 2.0f;
-
     /*
+    
     if(c->user->throttle <= 0.1f){
         float ramp = (c->user->throttle*10.0f)*(c->user->throttle*10.0f);
         vd = ramp*vd;
         vq = ramp*vq;
-    }    
+        }
+    
+    */
         
     dbg_loop_d = vd;
     dbg_loop_q = vq;
-    */
         
     InverseParke(vd, vq, angle, &valpha, &vbeta);
     
@@ -53,34 +52,6 @@
     c->modulator->Update(valpha, vbeta); 
 }
 
-void fast_test(Context *c) {
-    float angle, angle120, angle240;
-    angle = c->motor->GetPosition();
-    angle120 = angle + 120.0f;
-    if (angle120 >= 360.0f) angle120 -= 360.0f;
-    if (angle120 < 0.0f) angle120 += 360.0f;
-    angle240 = angle -120.0f;
-    if (angle240 >= 360.0f) angle240 -= 360.0f;
-    if (angle240 < 0.0f) angle240 += 360.0f;
-    
-    dbg_dtcA = 0.5f + 0.5f * FastSin(angle) * c->user->throttle;
-    dbg_dtcC = 0.5f + 0.5f * FastSin(angle120) * c->user->throttle;
-    dbg_dtcB = 0.5f + 0.5f * FastSin(angle240) * c->user->throttle;
-    c->inverter->SetDtcA(dbg_dtcA);
-    c->inverter->SetDtcB(dbg_dtcB);
-    c->inverter->SetDtcC(dbg_dtcC);
-}
-
-void fast_test2(Context *c) {
-    float vd, vq, valpha, vbeta, angle;
-    angle = c->motor->GetPosition();
-    vd = 0.0f;
-    vq = c->user->throttle;
-    //vq = 1.0f;
-    InverseParke(vd, vq, angle, &valpha, &vbeta);
-    c->modulator->Update(valpha, vbeta);
-}
-
 void slow(Context *c) {
     c->user->UpdateThrottle();
     //c->user->throttle = c->filter_th->Update(c->user->throttle);
@@ -89,12 +60,11 @@
 void debug(Context *c) {
     //c->serial->printf("%f %f %f %f %f %f\n\r", dbg_d_filtered, dbg_q_filtered, dbg_ref_d, dbg_ref_q, dbg_loop_d, dbg_loop_q);
     //c->serial->printf("%f\n\r", dbg_angle);
-    //c->serial->printf("%f %f %f %f\n\r", c->user->throttle, dbg_dtcA, dbg_dtcB, dbg_dtcC);
+    //c->serial->printf("%f\n\r", c->user->throttle);
+    c->serial->printf("%f %f\n\r", dbg_ib, dbg_ic);
 }
 
 void log(Context *c) {
-    //c->debugger->Write(0, dbg_dtc_b);
+    //c->debugger->Write(0, dbg_angle);
     //c->debugger->Write(1, dbg_q_filtered);
-    //c->debugger->Write(1, dbg_dtc_b);
-    //c->debugger->Write(2, dbg_dtc_c);
 }
\ No newline at end of file