TB6612FNG motor driver
The Toshiba TB6612FNG dual motor driver on its breakout board: two H bridges for two DC motors. Aliases: TB6612, SparkFun motor driver, dual H-bridge.
It is the driver in the SparkFun Inventor's Kit and most small robot kits. Its bridges are MOSFETs rather than the L293D's Darlingtons, so it keeps a fraction of a volt where an L293D keeps more than two, and its logic runs on 3.3 V as well as 5 V.
Pins
Logic side on the left, power side on the right, in the order the SparkFun board prints them:
| Pin | What it does |
|---|---|
PWMA, PWMB |
Each channel's speed: analogWrite here. |
AIN1, AIN2 |
Channel A's direction. |
BIN1, BIN2 |
Channel B's direction. |
STBY |
Must be HIGH, or both channels are off. |
VCC |
Logic supply, 2.7 V to 5.5 V. |
VM |
Motor supply, 2.5 V to 13.5 V (15 V absolute maximum). |
AO1, AO2 |
Motor A. |
BO1, BO2 |
Motor B. |
GND (three) |
One ground, strapped on the board. |
The truth table
For each channel, with STBY high:
| IN1 | IN2 | PWM | Outputs | Mode |
|---|---|---|---|---|
| H | L | H | OUT1 high, OUT2 low | clockwise |
| L | H | H | OUT1 low, OUT2 high | counterclockwise |
| H or L | the other | L | both low | short brake |
| H | H | any | both low | short brake |
| L | L | any | both off | stop, the motor coasts |
PWM low is a short brake, not a coast. So at half duty the motor is driven and braked in turn, and it slows down firmly rather than drifting.
While it runs
The face shows what each channel is doing: off, CW, CCW or brake.
The library
SparkFun_TB6612.h works as the Inventor's Kit uses it:
#include <SparkFun_TB6612.h>
Motor motor1 = Motor(2, 4, 5, 1, 9); // AIN1, AIN2, PWMA, offset, STBY
Motor motor2 = Motor(7, 8, 6, 1, 9); // BIN1, BIN2, PWMB, offset, STBY
void loop() {
motor1.drive(255, 1000); // forward at full speed for a second
motor1.drive(-255, 1000); // and back
motor1.brake();
forward(motor1, motor2, 150);
delay(1000);
brake(motor1, motor2);
delay(1000);
}
drive() takes -255 to 255 and sets STBY high itself; brake(), standby(),
forward(), back(), left() and right() do what upstream's do. The offset
argument, 1 or -1, flips a motor wired the other way around.
What the model gets right
From Toshiba's datasheet:
The truth table, row for row, including the brake on PWM low.
Internal pull-downs. Every input has 200 k to ground inside, so an unwired
STBY reads LOW and the chip does nothing at all. That is the first fault on every
forum thread about this board.
The volts it keeps. 0.5 V at 1 A across the two transistors of a bridge, which is 0.25 ohm a side.
Where the current comes from. With a battery or a bench supply on VM, the
bridge is part of the analog solve, so the motors' current comes out of the motor
rail and a battery sags under it.
The supplies. Under 2.7 V of logic, under 2.5 V of motor supply or over the 15 V absolute maximum, the outputs are dead.
What it does not model
The 1.2 A average and 3.2 A peak current limits and the thermal shutdown behind them, the dead time, the 100 kHz PWM ceiling, and the flyback diodes.
Common mistakes
Leaving STBY unwired. Its pull-down holds the chip in standby.
Expecting PWM to coast. On this chip it brakes.
Running the motors from the logic supply. Give VM its own supply, and join the
grounds.
See it in action
TB6612 robot drive runs two gearbox motors from a four-AA pack. Open it at /templates.