Gong Chen
/
TB6612FNG_Sample
sample for TB6612FNG Library with FRDM-KL25Z
Revision 0:d8e07dd54f68, committed 2016-06-24
- Comitter:
- ppr2013G2
- Date:
- Fri Jun 24 06:44:59 2016 +0000
- Commit message:
- first commit
Changed in this revision
diff -r 000000000000 -r d8e07dd54f68 TB6612FNG.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TB6612FNG.lib Fri Jun 24 06:44:59 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/rabad1/code/TB6612FNG/#8f562bdd5e93
diff -r 000000000000 -r d8e07dd54f68 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 24 06:44:59 2016 +0000 @@ -0,0 +1,43 @@ +//Sample for TB6612FNG +//Gong Chen 2016.6.24s +#include "mbed.h" +#include "TB6612FNG.h" + +// PWMA, AIN1, AIN2, PWMBm, BIN1, BIN2, STBY +TB6612FNG motorDriver(PTC9, PTB1, PTB0, PTA1, PTB3, PTC2, PTB2); + +float fPwmPeriod; +float fPwmPulsewidth; + +int main() { + fPwmPeriod = 0.00002f;//50KHz + fPwmPulsewidth = 1.0;//duty cycle 0.0~1.0 -> 0%~100% + + motorDriver.setPwmAperiod(fPwmPeriod);//set PWM Period + motorDriver.setPwmBperiod(fPwmPeriod); + + motorDriver.setPwmApulsewidth(fPwmPulsewidth);//set PWM Puls Width + motorDriver.setPwmBpulsewidth(fPwmPulsewidth); + + while(1) + { + motorDriver.motorA_ccw();//CounterClockWise + wait(2); + + motorDriver.motorA_cw();//ClockWise + wait(2); + + motorDriver.motorA_stop();//Stop + wait(2); + + motorDriver.motorB_ccw(); + wait(2); + + motorDriver.motorB_cw(); + wait(2); + + motorDriver.motorB_stop(); + wait(2); + } + +}
diff -r 000000000000 -r d8e07dd54f68 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jun 24 06:44:59 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file