hallo

Dependencies:   mbed TB6612FNG

main.cpp

Committer:
ppr2013G2
Date:
2016-06-24
Revision:
0:d8e07dd54f68
Child:
1:1c01d379dd37

File content as of revision 0:d8e07dd54f68:

//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);
    }
    
}