TER Atienza Pongnot 2019 / TLE5206_lib

Fork of TLE5206_lib by nicolas Atienza

Committer:
natienza
Date:
Wed Mar 13 18:33:48 2019 +0000
Revision:
1:1117196d767b
Parent:
0:03a724b7421c
Child:
2:610e4177e391
correction saturation a 0.99

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;
gpongnot 0:03a724b7421c 15 }else if (duty_cycle < 0){
gpongnot 0:03a724b7421c 16 this->pwmIN1 = -duty_cycle;
gpongnot 0:03a724b7421c 17 this->pwmIN2 = 0.0;
gpongnot 0:03a724b7421c 18 }else if (duty_cycle < 1){
gpongnot 0:03a724b7421c 19 this->pwmIN1 = 0.0;
gpongnot 0:03a724b7421c 20 this->pwmIN2 = duty_cycle;
gpongnot 0:03a724b7421c 21 }else {
gpongnot 0:03a724b7421c 22 this->pwmIN1 = 0.0;
natienza 1:1117196d767b 23 this->pwmIN2 = 0.99;
gpongnot 0:03a724b7421c 24 }
gpongnot 0:03a724b7421c 25 }