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: Optimize/Optimize.cpp
- Revision:
- 31:ebe42589ab9d
- Child:
- 32:b31423041c4e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Optimize/Optimize.cpp	Thu Nov 10 14:43:25 2016 +0000
@@ -0,0 +1,33 @@
+#include <math.h>
+
+#include "config_motor.h"
+#include "Optimize.h"
+#include "optimize_constants.h"
+
+void get_ipm_dq(float tau, float *d, float *q) {
+    float tau2 = tau * tau;
+    float alpha = val_alpha(tau, tau2);
+    float u = fastsqrtf(cA * tau2 / alpha + cB * alpha);
+    float v = fastsqrtf(cC * tau2 / alpha + cD * alpha + cE * tau / u);
+    *q = cU * u + cV * v;
+    *d = (-3 * *q * POLE_PAIRS * FLUX_LINKAGE + 2 * tau) / (3 * *q * Lx * POLE_PAIRS);
+}
+
+float val_alpha(float tau, float tau2) {
+    float tau23 = fastcubertf(tau2);
+    if (tau < TAU0) {
+        return tau23 * K1_13 * (c0 + c2 * tau2 + c4 * tau2 * tau2);
+    }
+    else {
+        return s0 + s1 * (tau - TAU0);
+    }
+
+}
+
+float fastsqrtf(float x) {
+    return sqrtf(x);
+}
+
+float fastcubertf(float x) {
+    return powf(x, 1 / 3.f);
+}
\ No newline at end of file