TER Atienza Pongnot 2019 / TLE5206_lib

Fork of TLE5206_lib by nicolas Atienza

Committer:
natienza
Date:
Mon Mar 18 08:25:23 2019 +0000
Revision:
2:610e4177e391
Parent:
1:1117196d767b
Child:
3:fa6c021ddefe
saturation basse de la loi de commande (a tester)

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 0:03a724b7421c 12 if (duty_cycle < -1){
natienza 1:1117196d767b 13 this->pwmIN1 = 0.99;
gpongnot 0:03a724b7421c 14 this->pwmIN2 = 0.0;
natienza 2:610e4177e391 15 }else if (duty_cycle < -0.4){
natienza 2:610e4177e391 16 this->pwmIN1 = -0.4;
natienza 2:610e4177e391 17 this->pwmIN2 = 0.0;
gpongnot 0:03a724b7421c 18 }else if (duty_cycle < 0){
gpongnot 0:03a724b7421c 19 this->pwmIN1 = -duty_cycle;
gpongnot 0:03a724b7421c 20 this->pwmIN2 = 0.0;
natienza 2:610e4177e391 21 }else if (duty_cycle < 0.4){
natienza 2:610e4177e391 22 this.pwmIN1 = 0.0;
natienza 2:610e4177e391 23 this.pwmIN2 = 0.4;
natienza 2:610e4177e391 24 }else if (dutycycle < 1){
natienza 2:610e4177e391 25 this.pwmIN1 = 0.0;
natienza 2:610e4177e391 26 this.pwmIN2 = duty_cycle;
gpongnot 0:03a724b7421c 27 }else {
gpongnot 0:03a724b7421c 28 this->pwmIN1 = 0.0;
natienza 1:1117196d767b 29 this->pwmIN2 = 0.99;
gpongnot 0:03a724b7421c 30 }
gpongnot 0:03a724b7421c 31 }