TER Atienza Pongnot 2019 / TLE5206_lib

Fork of TLE5206_lib by nicolas Atienza

Committer:
gpongnot
Date:
Tue Mar 26 17:00:06 2019 +0000
Revision:
3:fa6c021ddefe
Parent:
2:610e4177e391
Child:
4:a2009252a961
Saturation basse desature en tres bas niveau

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gpongnot 0:03a724b7421c 1 #include "mbed.h"
gpongnot 0:03a724b7421c 2 #include "TLE5206_lib.h"
gpongnot 0:03a724b7421c 3
gpongnot 0:03a724b7421c 4 TLE5206::TLE5206(PinName IN1,PinName IN2):pwmIN1(IN1),pwmIN2(IN2){};
gpongnot 0:03a724b7421c 5
gpongnot 0:03a724b7421c 6 void TLE5206::setup(int periode_us){
gpongnot 0:03a724b7421c 7 this->pwmIN1.period_us(periode_us);
gpongnot 0:03a724b7421c 8 this->pwmIN2.period_us(periode_us);
gpongnot 0:03a724b7421c 9 }
gpongnot 0:03a724b7421c 10
gpongnot 0:03a724b7421c 11 void TLE5206::write(float duty_cycle){
gpongnot 3:fa6c021ddefe 12 if (duty_cycle < -TLE5206_SAT_HIGH){
gpongnot 3:fa6c021ddefe 13 this->pwmIN1 = TLE5206_SAT_HIGH;
gpongnot 0:03a724b7421c 14 this->pwmIN2 = 0.0;
gpongnot 3:fa6c021ddefe 15 }else if (duty_cycle < -TLE5206_SAT_LOW){
gpongnot 0:03a724b7421c 16 this->pwmIN1 = -duty_cycle;
gpongnot 0:03a724b7421c 17 this->pwmIN2 = 0.0;
gpongnot 3:fa6c021ddefe 18 }else if (duty_cycle < TLE5206_NO_SAT_LOW){
gpongnot 3:fa6c021ddefe 19 this->pwmIN1 = TLE5206_SAT_LOW;
gpongnot 3:fa6c021ddefe 20 this->pwmIN2 = 0.0;
gpongnot 3:fa6c021ddefe 21 }else if (duty_cycle < 0){
gpongnot 3:fa6c021ddefe 22 this.pwmIN1 = -TLE5206_SAT_LOW/TLE5206_NO_SAT_LOW*duty_cycle;
gpongnot 3:fa6c021ddefe 23 this.pwmIN2 = 0.0;
gpongnot 3:fa6c021ddefe 24 }else if (dutycycle < TLE5206_NO_SAT_LOW){
natienza 2:610e4177e391 25 this.pwmIN1 = 0.0;
gpongnot 3:fa6c021ddefe 26 this.pwmIN2 = TLE5206_SAT_LOW/TLE5206_NO_SAT_LOW*duty_cycle;
gpongnot 3:fa6c021ddefe 27 }else if (dutycycle < TLE5206_SAT_LOW){
gpongnot 3:fa6c021ddefe 28 this.pwmIN1 = 0.0;
gpongnot 3:fa6c021ddefe 29 this.pwmIN2 = TLE5206_SAT_LOW;
gpongnot 3:fa6c021ddefe 30 }else if (dutycycle < TLE5206_SAT_HIGH){
gpongnot 3:fa6c021ddefe 31 this.pwmIN1 = 0.0;
gpongnot 3:fa6c021ddefe 32 this.pwmIN2 = dutycycle;
gpongnot 0:03a724b7421c 33 }else {
gpongnot 3:fa6c021ddefe 34 this.pwmIN1 = 0.0;
gpongnot 3:fa6c021ddefe 35 this.pwmIN2 = TLE5206_SAT_HIGH;
gpongnot 3:fa6c021ddefe 36 }
gpongnot 0:03a724b7421c 37 }