22#define CONTROLLERS_SPACE_VECTOR_MODULATION_HPP
33
44#include " numerical/controllers/TransformsClarkePark.hpp"
5+ #include " numerical/math/CompilerOptimizations.hpp"
56#include " numerical/math/QNumber.hpp"
67
78namespace controllers
@@ -21,6 +22,7 @@ namespace controllers
2122 QNumberType c;
2223 };
2324
25+ ALWAYS_INLINE_HOT
2426 Output Generate (const TwoPhase<QNumberType>& voltagePhase)
2527 {
2628 auto pattern = CalculateSwitchingTimes (voltagePhase.alpha , voltagePhase.beta );
@@ -33,6 +35,7 @@ namespace controllers
3335 }
3436
3537 private:
38+ ALWAYS_INLINE
3639 QNumberType ClampDutyCycle (QNumberType duty)
3740 {
3841 if (duty < zero)
@@ -50,6 +53,7 @@ namespace controllers
5053 QNumberType tc;
5154 };
5255
56+ ALWAYS_INLINE
5357 SwitchingPattern AddCommonInjection (SwitchingPattern pattern)
5458 {
5559 static const QNumberType _half = QNumberType (0 .5f );
@@ -64,48 +68,55 @@ namespace controllers
6468 return pattern;
6569 }
6670
71+ ALWAYS_INLINE
6772 SwitchingPattern Calculate60To120Degrees (QNumberType valpha, QNumberType vbeta)
6873 {
6974 QNumberType t1 = valpha + vbeta * invSqrt3;
7075 QNumberType t2 = -valpha + vbeta * invSqrt3;
7176 return AddCommonInjection ({ t2, t1 + t2, zero });
7277 }
7378
79+ ALWAYS_INLINE
7480 SwitchingPattern Calculate120To180Degrees (QNumberType valpha, QNumberType vbeta)
7581 {
7682 QNumberType t1 = -valpha + vbeta * invSqrt3;
7783 QNumberType t2 = -valpha - vbeta * invSqrt3;
7884 return AddCommonInjection ({ zero, t1 + t2, t2 });
7985 }
8086
87+ ALWAYS_INLINE
8188 SwitchingPattern Calculate180To240Degrees (QNumberType valpha, QNumberType vbeta)
8289 {
8390 QNumberType t1 = -valpha - vbeta * invSqrt3;
8491 QNumberType t2 = vbeta * twoDivSqrt3;
8592 return AddCommonInjection ({ zero, t2, t1 + t2 });
8693 }
8794
95+ ALWAYS_INLINE
8896 SwitchingPattern Calculate240To300Degrees (QNumberType valpha, QNumberType vbeta)
8997 {
9098 QNumberType t1 = -valpha + vbeta * invSqrt3;
9199 QNumberType t2 = -vbeta * twoDivSqrt3;
92100 return AddCommonInjection ({ t2, zero, t1 + t2 });
93101 }
94102
103+ ALWAYS_INLINE
95104 SwitchingPattern Calculate300To360Degrees (QNumberType valpha, QNumberType vbeta)
96105 {
97106 QNumberType t1 = valpha + vbeta * invSqrt3;
98107 QNumberType t2 = -valpha - vbeta * invSqrt3;
99108 return AddCommonInjection ({ t1 + t2, zero, t2 });
100109 }
101110
111+ ALWAYS_INLINE
102112 SwitchingPattern Calculate0To60Degrees (QNumberType valpha, QNumberType vbeta)
103113 {
104114 QNumberType t1 = valpha - vbeta * invSqrt3;
105115 QNumberType t2 = vbeta * twoDivSqrt3;
106116 return AddCommonInjection ({ t1 + t2, t2, zero });
107117 }
108118
119+ ALWAYS_INLINE_HOT
109120 SwitchingPattern CalculateSwitchingTimes (QNumberType valpha, QNumberType vbeta)
110121 {
111122 QNumberType v_ref_60 = (valpha * half - vbeta * sqrt3Div2);
0 commit comments