TER Atienza Pongnot 2019 / TLE5206_lib

Fork of TLE5206_lib by nicolas Atienza

Committer:
natienza
Date:
Thu Mar 28 07:30:04 2019 +0000
Revision:
4:a2009252a961
Parent:
3:fa6c021ddefe
correction petites erreurs syntaxes

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){
natienza 4:a2009252a961 22 this->pwmIN1 = -TLE5206_SAT_LOW/TLE5206_NO_SAT_LOW*duty_cycle;
natienza 4:a2009252a961 23 this->pwmIN2 = 0.0;
natienza 4:a2009252a961 24 }else if (duty_cycle < TLE5206_NO_SAT_LOW){
natienza 4:a2009252a961 25 this->pwmIN1 = 0.0;
natienza 4:a2009252a961 26 this->pwmIN2 = TLE5206_SAT_LOW/TLE5206_NO_SAT_LOW*duty_cycle;
natienza 4:a2009252a961 27 }else if (duty_cycle < TLE5206_SAT_LOW){
natienza 4:a2009252a961 28 this->pwmIN1 = 0.0;
natienza 4:a2009252a961 29 this->pwmIN2 = TLE5206_SAT_LOW;
natienza 4:a2009252a961 30 }else if (duty_cycle < TLE5206_SAT_HIGH){
natienza 4:a2009252a961 31 this->pwmIN1 = 0.0;
natienza 4:a2009252a961 32 this->pwmIN2 = duty_cycle;
gpongnot 0:03a724b7421c 33 }else {
natienza 4:a2009252a961 34 this->pwmIN1 = 0.0;
natienza 4:a2009252a961 35 this->pwmIN2 = TLE5206_SAT_HIGH;
gpongnot 3:fa6c021ddefe 36 }
gpongnot 0:03a724b7421c 37 }