Bayley Wang / Mbed 2 deprecated foc-ed_in_the_bot_compact

Dependencies:   FastPWM3 mbed

Revision:
40:22aede3d096f
Parent:
32:b31423041c4e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AnalyticOptimize/optimize_constants.h	Mon Dec 12 14:18:02 2016 +0000
@@ -0,0 +1,56 @@
+#ifndef __CONFIG_OPTIMIZE
+#define __CONFIG_OPTIMIZE
+
+#include "config_motor.h"
+#include <math.h>
+
+/*
+* Precomputed constants for analytic IPM optimization
+*/
+
+#define Lx (Ld-Lq)
+#define Lx2 (Lx * Lx)
+#define Lx3 (Lx2 * Lx)
+#define Lx4 (Lx2 * Lx2)
+#define Lx6 (Lx2 * Lx4)
+
+#define P2 (POLE_PAIRS * POLE_PAIRS)
+#define P3 (POLE_PAIRS * P2)
+#define P4 (P2 * P2)
+#define P6 (P4 * P2)
+#define P8 (P4 * P4)
+
+#define PSI2 (FLUX_LINKAGE * FLUX_LINKAGE)
+#define PSI4 (PSI2 * PSI2)
+#define PSI8 (PSI4 * PSI4)
+
+#define K1 (27.f * Lx2 * P4 * PSI2)
+#define K2 (243.f * 3.f * Lx4 * P8 * PSI4)
+#define K3 (1024.f * 3.f * Lx6 * P6)
+#define K1_13 (powf(K1, 1.f / 3))
+#define K3_13 (14.537f * Lx2 * P2) //K3^(1/3)
+#define SQRTK3 (-55.426f * Lx3 * P3)
+
+#define cA (-8.80514f)
+#define cB (0.605707f / (Lx2 * P2))
+#define cC (2.93505f)
+#define cD (-0.201902f / (Lx2 * P2))
+#define cE (2.3094f * FLUX_LINKAGE / (Lx2 * POLE_PAIRS))
+
+#define c0 (1.25992f)
+#define c2 (0.4424414f * Lx2 / (P2 * PSI4))
+#define c4 (-0.6214814f * Lx4 / (P4 * PSI8))
+
+#define TAU0 (K1 / SQRTK3)
+#define s0 (1.3415f * K1 / K3_13)
+#define s1 (-3.81274f * Lx * POLE_PAIRS)
+
+#define cU (-0.2887f)
+#define cV (0.5f)
+
+#define cF (0.25f * Lq/(Ld * Lq-Ld * Ld) * FLUX_LINKAGE)
+#define cG (FLUX_LINKAGE / Ld)
+#define cH (1 / (Ld * Ld))
+#define cI (0.25f * FLUX_LINKAGE / (Lq - Ld))
+
+#endif
\ No newline at end of file