Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-dev-f303 FastPWM3
Diff: CurrentRegulator/CurrentRegulator.cpp
- Revision:
- 18:f1d56f4acb39
- Parent:
- 15:ef00814e38e2
--- a/CurrentRegulator/CurrentRegulator.cpp Sat Dec 10 05:46:08 2016 +0000
+++ b/CurrentRegulator/CurrentRegulator.cpp Sun Dec 11 04:19:15 2016 +0000
@@ -132,6 +132,12 @@
//V_Q = V_Q - w_elec*I_D;
V_D = D_Integral + _Kp*D_Error;
//V_D = V_D + w_elec*I_Q; //decoupling needs moar testing
+ float mag2 = (V_Q*V_Q + V_D*V_D);
+ if(mag2>1){
+ V_Q = V_Q/mag2;
+ V_D = V_D/mag2;
+ }
+
}
void CurrentRegulator::SetVoltage(){