a fork of priustroller

Dependencies:   mbed

Fork of priustroller_current by N K

Revision:
13:79e247e54d78
Parent:
11:dccbaa9274c5
Child:
14:1cc975207995
diff -r c35ad58f6620 -r 79e247e54d78 meta/modulators.cpp
--- a/meta/modulators.cpp	Sun Mar 08 09:02:59 2015 +0000
+++ b/meta/modulators.cpp	Mon Mar 09 01:40:43 2015 +0000
@@ -4,8 +4,12 @@
 #include "sensors.h"
 #include "lut.h"
 
-void SinusoidalModulator::Update(float va, float vb) {    
-    _inverter->SetDtcA(va);
-    _inverter->SetDtcB(((-va + sqrt(3.0f) * vb) / 2.0f));
-    _inverter->SetDtcC(((-va - sqrt(3.0f) * vb) / 2.0f));
+void SinusoidalModulator::Update(float va, float vb) {
+    //--hack to make duty cycles positive
+    float dtcA = va;
+    float dtcB = ((-va + sqrt(3.0f) * vb) / 2.0f);
+    float dtcC = ((-va - sqrt(3.0f) * vb) / 2.0f);
+    _inverter->SetDtcA(dtcA * 0.5f + 0.5f);
+    _inverter->SetDtcB(dtcB * 0.5f + 0.5f);
+    _inverter->SetDtcC(dtcC * 0.5f + 0.5f);
 }
\ No newline at end of file