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.
Diff: FOC/foc.cpp
- Revision:
- 38:67e4e1453a4b
- Parent:
- 37:c0f352d6e8e3
- Child:
- 44:efcde0af8390
--- a/FOC/foc.cpp Fri Apr 13 13:50:54 2018 +0000
+++ b/FOC/foc.cpp Mon May 14 20:59:02 2018 +0000
@@ -109,13 +109,13 @@
observer->i_q_est += K_O*observer->e_q + .001f*observer->e_q_int;
- //float s_cog = sinf(12.0f*theta);
-
- //float cogging_current =-0.33f*s_cog + .25f*s;
+ float scog12 = FastSin(12.0f*theta);
+ float scog1 = s;
+ float cogging_current = 0.25f*scog1 - 0.3f*scog12;
/// PI Controller ///
float i_d_error = controller->i_d_ref - controller->i_d;
- float i_q_error = controller->i_q_ref - controller->i_q ;// + cogging_current;
+ float i_q_error = controller->i_q_ref - controller->i_q + cogging_current;
float v_d_ff = 2.0f*(controller->i_d_ref*R_PHASE - controller->dtheta_elec*L_Q*controller->i_q_ref); //feed-forward voltages
float v_q_ff = 2.0f*(controller->i_q_ref*R_PHASE + controller->dtheta_elec*(L_D*controller->i_d_ref + WB));