![](/media/cache/group/cropped-logo_small-2_BOjObak.png.50x50_q85.png)
hallo
main.cpp@1:1c01d379dd37, 2019-07-24 (annotated)
- Committer:
- kerim4040
- Date:
- Wed Jul 24 12:53:42 2019 +0000
- Revision:
- 1:1c01d379dd37
- Parent:
- 0:d8e07dd54f68
kl
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ppr2013G2 | 0:d8e07dd54f68 | 1 | //Sample for TB6612FNG |
ppr2013G2 | 0:d8e07dd54f68 | 2 | //Gong Chen 2016.6.24s |
ppr2013G2 | 0:d8e07dd54f68 | 3 | #include "mbed.h" |
ppr2013G2 | 0:d8e07dd54f68 | 4 | #include "TB6612FNG.h" |
ppr2013G2 | 0:d8e07dd54f68 | 5 | |
ppr2013G2 | 0:d8e07dd54f68 | 6 | // PWMA, AIN1, AIN2, PWMBm, BIN1, BIN2, STBY |
kerim4040 | 1:1c01d379dd37 | 7 | TB6612FNG motorDriver(PC_6, PD_10, PD_8, PC_8, PG_2, PG_4, PD_12); |
ppr2013G2 | 0:d8e07dd54f68 | 8 | |
ppr2013G2 | 0:d8e07dd54f68 | 9 | float fPwmPeriod; |
ppr2013G2 | 0:d8e07dd54f68 | 10 | float fPwmPulsewidth; |
ppr2013G2 | 0:d8e07dd54f68 | 11 | |
ppr2013G2 | 0:d8e07dd54f68 | 12 | int main() { |
ppr2013G2 | 0:d8e07dd54f68 | 13 | fPwmPeriod = 0.00002f;//50KHz |
ppr2013G2 | 0:d8e07dd54f68 | 14 | fPwmPulsewidth = 1.0;//duty cycle 0.0~1.0 -> 0%~100% |
ppr2013G2 | 0:d8e07dd54f68 | 15 | |
ppr2013G2 | 0:d8e07dd54f68 | 16 | motorDriver.setPwmAperiod(fPwmPeriod);//set PWM Period |
ppr2013G2 | 0:d8e07dd54f68 | 17 | motorDriver.setPwmBperiod(fPwmPeriod); |
ppr2013G2 | 0:d8e07dd54f68 | 18 | |
ppr2013G2 | 0:d8e07dd54f68 | 19 | motorDriver.setPwmApulsewidth(fPwmPulsewidth);//set PWM Puls Width |
ppr2013G2 | 0:d8e07dd54f68 | 20 | motorDriver.setPwmBpulsewidth(fPwmPulsewidth); |
ppr2013G2 | 0:d8e07dd54f68 | 21 | |
ppr2013G2 | 0:d8e07dd54f68 | 22 | while(1) |
ppr2013G2 | 0:d8e07dd54f68 | 23 | { |
ppr2013G2 | 0:d8e07dd54f68 | 24 | motorDriver.motorA_ccw();//CounterClockWise |
ppr2013G2 | 0:d8e07dd54f68 | 25 | wait(2); |
ppr2013G2 | 0:d8e07dd54f68 | 26 | |
ppr2013G2 | 0:d8e07dd54f68 | 27 | motorDriver.motorA_cw();//ClockWise |
ppr2013G2 | 0:d8e07dd54f68 | 28 | wait(2); |
kerim4040 | 1:1c01d379dd37 | 29 | |
ppr2013G2 | 0:d8e07dd54f68 | 30 | motorDriver.motorB_ccw(); |
ppr2013G2 | 0:d8e07dd54f68 | 31 | wait(2); |
ppr2013G2 | 0:d8e07dd54f68 | 32 | |
ppr2013G2 | 0:d8e07dd54f68 | 33 | motorDriver.motorB_cw(); |
ppr2013G2 | 0:d8e07dd54f68 | 34 | wait(2); |
ppr2013G2 | 0:d8e07dd54f68 | 35 | |
kerim4040 | 1:1c01d379dd37 | 36 | |
ppr2013G2 | 0:d8e07dd54f68 | 37 | } |
ppr2013G2 | 0:d8e07dd54f68 | 38 | |
ppr2013G2 | 0:d8e07dd54f68 | 39 | } |