Momo-Medical
/
TB6612FNG_Sample
hallo
Diff: main.cpp
- Revision:
- 0:d8e07dd54f68
- Child:
- 1:1c01d379dd37
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); + } + +}