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: SVM/SVM.cpp
- Revision:
- 6:4ee1cdc43aa8
- Parent:
- 5:51c6560bf624
- Child:
- 10:370851e6e132
--- a/SVM/SVM.cpp Sat Mar 12 18:45:22 2016 +0000
+++ b/SVM/SVM.cpp Sat Mar 12 19:55:52 2016 +0000
@@ -2,6 +2,8 @@
#include "mbed.h"
#include "SVM.h"
#include "Inverter.h"
+#define min(x,y,z) (x < y ? (x < z ? x : z) : (y < z ? y : z))
+#define max(x,y,z) (x > y ? (x > z ? x : z) : (y > z ? y : z))
SPWM::SPWM(Inverter *inverter, float V_Bus){
_inverter = inverter;
@@ -28,10 +30,19 @@
}
void SVPWM::Update_DTC(float V_A, float V_B, float V_C){
+
+ float Voff = (min(V_A, V_B, V_C) + max(V_A, V_B, V_C))/2.0f;
+
+ V_A = V_A - Voff;
+ V_B = V_B - Voff;
+ V_C = V_C - Voff;
+
float DTC_A = V_A/_V_Bus + .5f;
float DTC_B = V_B/_V_Bus + .5f;
float DTC_C = V_C/_V_Bus + .5f;
+
+
if(DTC_A > .95f) DTC_A = .95f;
else if(DTC_A < .05f) DTC_A = .05f;
if(DTC_B > .95f) DTC_B = .95f;