a fork of priustroller

Dependencies:   mbed

Fork of priustroller_current by N K

Revision:
23:7366022ea0ab
Parent:
22:46d164aa4f1c
Child:
48:28edb4c5c04b
--- a/meta/modulators.cpp	Mon Mar 09 07:44:57 2015 +0000
+++ b/meta/modulators.cpp	Mon Mar 09 08:28:22 2015 +0000
@@ -15,76 +15,74 @@
 }
 
 void SvmModulator::Update(float valpha, float vbeta) {
-    float va, vb, vc;
+    float va, vb;
     InverseClarke(valpha, vbeta, &va, &vb);
-    vc = -(va + vb);
-    
-    float dtcA, dtcB, dtcC, t1, t2;
     
-    t1 = 0;
-    t2 = 0;
-    dtcA = 0.0f;
-    dtcB = 0.0f;
-    dtcC = 0.0f;
+    float t1, t2, dtcA, dtcB, dtcC;
     
+    /*
     //for positive dtheta/dt, t1 is decreasing.  t2 is increasing.
     if (va >= 0){  // (xx1)
         if (vb >= 0){ // (x11) 
             //300-360 degrees
-            t1 = va; //was -vc
-            t2 = -vb; //was -va
-            dtcA = 0.5f - t1/2.0f;
-            dtcB = 0.5f + t2/2.0f;
+            t1 = va;
+            t2 = vb;
+            dtcA = 0.5f - t1 / 2.0f;
+            dtcB = 0.5f - t2 / 2.0f;
             dtcC = 1.5f - dtcA - dtcB;
         }
         else {  // (x01)
             if (vc >= 0){  // Sector 5: (1,0,1) 180-240 degrees
-                t1 = -vc;
-                t2 = va;
-                dtcA = 0.5f - t2/2.0f;
-                dtcC = 0.5f + t1/2.0f;
-                dtcB = 1.5f - dtcA - dtcC;
+                t1 = va;
+                t2 = vb;
+                dtcA = 0.5f - t1 / 2.0f;
+                dtcB = 0.5f - t2 / 2.0f;
+                dtcC = 1.5f - dtcA - dtcB;
                                
             }
             else {// Sector 1: (0,0,1) 240-300 degrees
-                t1 = -vb; //was -vb
-                t2 = -vc; //was -vc
-                dtcC = 0.5f + t2/2.0f;
-                dtcB = 0.5f + t1/2.0f;
-                dtcA = 1.5f - dtcC - dtcB;
+                t1 = va;
+                t2 = vb;
+                dtcA = 0.5f - t1 / 2.0f;
+                dtcB = 0.5f - t2 / 2.0f;
+                dtcC = 1.5f - dtcA - dtcB;
             }
         }
     } else { // (xx0)
         if (vb >= 0) { // (x10)
             if (vc >= 0) { // Sector 6: (1,1,0) 60-120 degrees
-                t1 = vb;
-                t2 = vc;
-                dtcB = 0.5f - t1 / 2.0f;
-                dtcC = 0.5f - t2 / 2.0f;
-                dtcA =  1.5f - dtcC - dtcB;
+                t1 = va;
+                t2 = vb;
+                dtcA = 0.5f - t1 / 2.0f;
+                dtcB = 0.5f - t2 / 2.0f;
+                dtcC =  1.5f - dtcA - dtcB;
             }
             else {// Sector 2: (0,1,0) 0-60 degrees
-                t1 = -vc;
-                t2 = -va;
-                dtcC = 0.5f + t1/2.0f;
-                dtcA = 0.5f + t2/2.0f;
-                dtcB = 1.5f - dtcC - dtcA;
+                t1 = va;
+                t2 = vb;
+                dtcA = 0.5f - t1 / 2.0f;
+                dtcB = 0.5f - t2 / 2.0f;
+                dtcC = 1.5f - dtcA - dtcB;
             }
         }
         else { // (x00)
             // Must be Sector 4 since Sector 0 not allowed
             // Sector 4: (1,0,0) 120-180 degrees
-            t1 = -va;  //was -va
-            t2 = -vb;  //was -vb
-            dtcA = 0.5f + t1/2.0f;
-            dtcB = 0.5f + t2/2.0f;
+            t1 = va;
+            t2 = vb;
+            dtcA = 0.5f - t1 / 2.0f;
+            dtcB = 0.5f - t2 / 2.0f;
             dtcC = 1.5f - dtcA - dtcB;
         }
     }
-
+    */
+    
+    t1 = va;
+    t2 = vb;
+    dtcA = 0.5f - t1 / 2.0f;
+    dtcB = 0.5f - t2 / 2.0f;
+    dtcC = 1.5f - dtcA - dtcB;
 
- 
-    
     _inverter->SetDtcA(dtcA);
     _inverter->SetDtcB(dtcB);
     _inverter->SetDtcC(dtcC);