TER Atienza Pongnot 2019 / TLE5206_lib

Fork of TLE5206_lib by nicolas Atienza

Revision:
3:fa6c021ddefe
Parent:
2:610e4177e391
Child:
4:a2009252a961
--- a/TLE5206_lib.cpp	Mon Mar 18 08:25:23 2019 +0000
+++ b/TLE5206_lib.cpp	Tue Mar 26 17:00:06 2019 +0000
@@ -9,23 +9,29 @@
 }
 
 void TLE5206::write(float duty_cycle){
-    if (duty_cycle < -1){
-        this->pwmIN1 = 0.99;
+    if (duty_cycle < -TLE5206_SAT_HIGH){
+        this->pwmIN1 = TLE5206_SAT_HIGH;
         this->pwmIN2 = 0.0;
-    }else if (duty_cycle < -0.4){
-        this->pwmIN1 = -0.4;
-        this->pwmIN2 = 0.0;
-    }else if (duty_cycle < 0){
+    }else if (duty_cycle < -TLE5206_SAT_LOW){
         this->pwmIN1 = -duty_cycle;
         this->pwmIN2 = 0.0;
-    }else if (duty_cycle < 0.4){
-        this.pwmIN1 = 0.0;
-        this.pwmIN2 = 0.4;
-    }else if (dutycycle < 1){
+    }else if (duty_cycle < TLE5206_NO_SAT_LOW){
+        this->pwmIN1 = TLE5206_SAT_LOW;
+        this->pwmIN2 = 0.0;
+    }else if (duty_cycle < 0){
+        this.pwmIN1 = -TLE5206_SAT_LOW/TLE5206_NO_SAT_LOW*duty_cycle;
+        this.pwmIN2 = 0.0;
+    }else if (dutycycle < TLE5206_NO_SAT_LOW){
         this.pwmIN1 = 0.0;
-        this.pwmIN2 = duty_cycle;
+        this.pwmIN2 = TLE5206_SAT_LOW/TLE5206_NO_SAT_LOW*duty_cycle;
+    }else if (dutycycle < TLE5206_SAT_LOW){
+        this.pwmIN1 = 0.0;
+        this.pwmIN2 = TLE5206_SAT_LOW;
+    }else if (dutycycle < TLE5206_SAT_HIGH){
+        this.pwmIN1 = 0.0;
+        this.pwmIN2 = dutycycle;
     }else {
-        this->pwmIN1 = 0.0;
-        this->pwmIN2 = 0.99;    
-    }    
+        this.pwmIN1 = 0.0;
+        this.pwmIN2 = TLE5206_SAT_HIGH;
+    }
 }
\ No newline at end of file