FOC Implementation for putting multirotor motors in robots

Dependencies:   FastPWM3 mbed

Revision:
2:8724412ad628
Parent:
1:b8bceb4daed5
Child:
3:6a0015d88d06
--- a/CurrentRegulator/CurrentRegulator.cpp	Fri Feb 05 01:04:57 2016 +0000
+++ b/CurrentRegulator/CurrentRegulator.cpp	Fri Feb 19 04:13:06 2016 +0000
@@ -11,7 +11,7 @@
     _Inverter = inverter;
     PWM = new SPWM(inverter, 2.0);
     _PositionSensor = position_sensor;
-    IQ_Ref = .7;
+    IQ_Ref = 5;
     ID_Ref = 0;
     V_Q = 0;
     V_D = 0;
@@ -30,7 +30,7 @@
     Q_Integral = 0;
     D_Integral = 0;
     Int_Max = .9;
-    DTC_Max = .95;
+    DTC_Max = .97;
     //theta_elec = _PositionSensor->GetElecPosition();
 
     }
@@ -63,9 +63,9 @@
         D_Integral += D_Error*_Ki*_Kp;
         
         if (Q_Integral > Int_Max) Q_Integral = Int_Max;
-        else if(D_Integral < -Int_Max) D_Integral = Int_Max;
+        else if(Q_Integral < -Int_Max) Q_Integral = -Int_Max;
         if (D_Integral > Int_Max) D_Integral = Int_Max;
-        else if(Q_Integral < -Int_Max) Q_Integral = Int_Max;       
+        else if(D_Integral < -Int_Max) D_Integral = -Int_Max;       
          
         V_Q = Q_Integral + _Kp*Q_Error;
         V_D = D_Integral + _Kp*D_Error;