WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

Toshiba TB6612FNG (2 or 3 pin) driver

Controls two DC motors connected to the TB6612FNG motor driver using pulse width modulation (PWM).
The device requires two power supplies:
The device is a 'surface mount' device so I have used the breakout board available from Pololu:
http://www.pololu.com/catalog/product/713/resources
This device is also sold by outlets such as SparkFun and ActiveRobots.
PololuTB6612FNG.jpg
The breakout board comes with header pins for use with a bread board and must be soldered on. Alternatively: for use in a finished robot you can just solder your wires directly to the board. The board also comes with some capacitors and reverse voltage protection for the motor supply.
I have supplied two different software drivers for this board:
2 Pin Mode
Requires two PWM signals per motor. On microprocessors such as the ATMega168 this will mean that the driver will use up Timer 0 and Timer 2. So it really eats into your available timers.
3 Pin Mode
Only requires one PWM signal per motor but requires two digital output pins per motor as well.
TB6612FNG.jpg
The 'STBY' pin can be connected to a digital output pin to put the device into 'stand by' mode. I don't support this directly in the library but if you wish to utilise this feature then connect it to any digital output pin and pull the pin low to put the device into standby or high to enable the device.
NB If you don't want to make use of the standby feature then you must connect the STBY pin to Vcc.
2 Pin Connections
To use the 2 pin driver then you will need to connect the device as follows:
Connect the 5v regulated supply from your micro controller to the Vcc pin
Connect the ground from your micro controller to the GND pin
Connect your motor supply (+ve) to VMOT and the ground wire to GND.
Connect the STBY pin to Vcc if you are not using an output pin to set the controller to standby mode.
DC Motor 1 should be connected to the AO1 and AO2 pins and DC Motor 2 should be connected to the BO1 and BO2 pins.
Connect PWMA to Vcc. AIN1 and AIN2 should be connected to two PWM output pins on your micro controller and these two pins will be used to control motor 1.
Connect PWMB to Vcc. BIN1 and BIN2 should be connected to two PWM output pins on your micro controller and these two pins will be used to control motor 2.
3 Pin Connections
To use the 3 pin driver then you will need to connect the device as follows:
Connect the 5v regulated supply from your micro controller to the Vcc pin
Connect the ground from your micro controller to the GND pin
Connect your motor supply (+ve) to VMOT and the ground wire to GND.
Connect the STBY pin to Vcc if you are not using an output pin to set the controller to standby mode.
DC Motor 1 should be connected to the AO1 and AO2 pins and DC Motor 2 should be connected to the BO1 and BO2 pins.
AIN1 and AIN2 should be connected to +5v digital output pins on your micro controller and PWMA should be connected to one of the PWM output pins on your micro controller. These three pins will be used to control motor 1.
BIN1 and BIN2 should be connected to +5v digital output pins on your micro controller and PWMB should be connected to one of the PWM output pins on your micro controller. These three pins will be used to control motor 2.
Example
Just use the generic example in Actuators
Function Summary

Valid XHTML 1.0 Transitional