Hello friends, I hope you all are doing great. Today, I am going to share the new TB6612FNG Motor Driver Library for Proteus V1.0. The TB6612FNG is the motor driver many makers move to after the L298N: a tiny breakout with Toshiba's dual H-bridge chip that runs two DC motors from an Arduino, wastes almost no voltage and needs no heat sink. It has a standby pin, a separate PWM pin for each motor and two kinds of stop, and now all of it works in your Proteus simulations, together with the yellow TT gear motor of a robot car.

Behind the board sits our own model of the TB6612FNG: the complete truth table of the chip, the internal pull-down resistors, standby, MOSFET outputs that are real analog H-bridges and take real current, PWM speed control, the short brake and the stop. The motor is a model too, with resistance, back-EMF, friction and inertia, so its wheel turns at the speed a real TT motor would. You get three devices: a Simple driver with a live STATUS panel, an Advance driver with a pop-up window and three test tools, and the TT gear motor. The demo runs on our Arduino UNO V4.0 with its serial monitor built into the board.

NOTICE: a motor driver in a simulator is only useful if the motors behave like motors. So we did not draw a spinning icon, we built the physics: the wheel speeds up, slows down under load, brakes and coasts like the real one, and the driver measures every PWM pulse that reaches it. It took our team a lot of hard work. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below or in the Motor Driver board of our forum. And if our free libraries help you, you can buy us a coffee. So, let's get started with the TB6612FNG Motor Driver Library for Proteus V1.0:

Figure: The TB6612FNG demo in Proteus 8.5: node 1 (Simple) steps motor A through its speeds; the pop-up of the Advance driver shows motor A forward and motor B reverse at 39 % PWM, the input waveforms and a 3 s scope.

What is the TB6612FNG Motor Driver?

A microcontroller pin can give a few milliamps; a small DC motor wants a few hundred, and it wants to turn both ways. A motor driver solves both. Its heart is the H-bridge: four switches arranged like the letter H with the motor in the middle. Close the top-left and the bottom-right switch and the current flows through the motor one way; close the other pair and it flows the other way. Close both bottom switches and the motor is shorted, which brakes it.

The TB6612FNG from Toshiba holds two complete H-bridges in a small SSOP-24 chip. Its switches are MOSFETs, and that is the big difference from the older bipolar drivers such as the L298N or the L9110S: a conducting MOSFET behaves like a small resistor, about 0.5 ohm for the two switches in the path, instead of a fixed voltage drop of one or two volts. Your motor gets nearly all of the supply, and the chip stays cool. The chip has two supplies: VM for the motors and VCC for its logic, so a 3.3 V or 5 V microcontroller can drive motors on a 9 V or 12 V battery.

The TB6612FNG dual motor driver breakout
TB6612FNG breakout
ChipToshiba TB6612FNG, two MOSFET H-bridges (SSOP-24)
Motor supply VM2.5 - 13.5 V (15 V absolute maximum)
Logic supply VCC2.7 - 5.5 V
Current1.2 A average per channel, 3.2 A peak
Inputs per motorIN1, IN2 (direction) and PWM (speed), plus one STBY pin for the chip
PWMup to 100 kHz
HeaderPWMA, AIN2, AIN1, STBY, BIN1, BIN2, PWMB, GND and VM, VCC, GND, AO1, AO2, BO2, BO1, GND
Devices in this libraryTB6612TEP (Simple), TB6612ADVTEP (Advance), TTMOTORTEP (the motor)

The Truth Table of the TB6612FNG

Each motor has three inputs: IN1 and IN2 choose what the motor does, the PWM pin lets it happen. One more pin, STBY, wakes the whole chip. The datasheet calls the two directions CW and CCW; in this library CW is forward.

What each input state does (one channel)
IN1IN2PWMSTBYOUT1OUT2The motor
HIGHLOWHIGHHIGHHIGHLOWCW (forward)
LOWHIGHHIGHHIGHLOWHIGHCCW (reverse)
HIGH or LOWLOW or HIGHLOWHIGHLOWLOWShort brake (the PWM off time)
HIGHHIGHanyHIGHLOWLOWShort brake
LOWLOWanyHIGHopenopenStop: the motor coasts
anyanyanyLOWopenopenStandby: the chip sleeps, the motors coast

Two details matter in practice. First, every input of the chip has an internal pull-down, so a pin that is not connected reads LOW. That is a safe default for IN1, IN2 and PWM, but it also means that a floating STBY keeps the chip asleep: forget to drive STBY HIGH and nothing ever turns. Second, there are two ways to stop. The short brake connects both motor wires to GND, so the motor's own voltage drives a current that stops it quickly. The stop leaves the outputs open, and the motor rolls out on its own.

Speed Control with PWM

The TB6612FNG has a separate PWM pin per motor, which makes speed control simple: set the direction with IN1 and IN2 and give the PWM pin an analogWrite(). During the on time the motor is driven; during the off time the chip short-brakes it, so the speed follows the duty cycle. The UNO gives 980 Hz on D5 and D6 and 490 Hz on D3, D9, D10 and D11; the chip itself accepts PWM up to 100 kHz.

Standby

Pull STBY LOW and the whole chip sleeps: both motors are released and the chip draws almost nothing. Battery robots use it to save power while they wait. Pull STBY HIGH and the chip continues with whatever IN1, IN2 and PWM say. STBY wins over everything else, so a PWM signal on a sleeping chip does nothing.

The TT Gear Motor

The yellow TT motor is the standard motor of small robot cars: a 130-size DC motor behind a 1:48 plastic gearbox, with a shaft on both sides for a 65 mm wheel. It is the same model as in our L9110S Motor Driver Library for Proteus V1.0, so both libraries share one motor file.

The TT gear motor
TT gear motor 1:48 (the model)
Rated voltage3 - 6 V
No loadabout 250 RPM and 0.15 A at 6 V
Stall1.67 A at 6 V (3.6 ohm)
Response63 % of its speed in about 75 ms
On the schematicthe wheel turns at the simulated speed; RPM, volts, amps; LOAD button

What's New in TB6612FNG Motor Driver Library for Proteus V1.0

  • The real breakout: the red board with the TB6612FNG chip, its capacitors and the 16 header pins in the order of the SparkFun breakout, drawn at about 2 x its real size.
  • MOSFET H-bridges: the outputs drive real current into the motors through 0.25 ohm switches with body diodes, and VM delivers what the motors draw.
  • The full truth table: CW, CCW, short brake by IN1 and IN2, short brake by PWM, stop and standby.
  • The pull-downs: a floating input reads LOW, and a floating STBY keeps the chip asleep, as on the real chip.
  • Two supplies: VCC for the logic (2.7 - 5.5 V) and VM for the motors, each watched against its range.
  • PWM measured: the frequency and duty of every input and each channel's drive, live.
  • The TT gear motor with a wheel that turns at the simulated speed, with RPM, volts, amps and a LOAD button.
  • Three test tools on the Advance driver: Truth table, PWM and Power.
  • A two-node demo on our Arduino UNO V4.0 with SparkFun's Arduino library: speed steps on one node, a robot car on the other.
  • A compact package: about 1.41 MB, without the C++ source code.

Three Devices: Simple, Advance and the Motor

Figure: The three devices as the library draws them: the Simple driver with its STATUS panel, the Advance driver and the TT gear motor.
The three devices (search "TB6612" or "TT MOTOR" in Pick Devices; category Electromechanical)
SimpleAdvanceMotor
DeviceTB6612TEPTB6612ADVTEPTTMOTORTEP
Library fileTEPTB6612.LIBTEPTB6612.LIBTEPMOTOR.LIB
On the schematicThe board + the STATUS panelThe board onlyThe motor with its wheel
StatusBanner, 10 readouts, the last 6 eventsA pop-up: Motors, Event log, TestsRPM, volts, amps
InteractionPANEL buttonOPEN PANEL buttonLOAD button, a click on the wheel

Download TB6612FNG Motor Driver Library for Proteus

Click the button below to download TB6612FNG-Motor-Driver-Library-for-Proteus-v1.0.zip (about 1.41 MB, without the C++ source code):

TB6612FNG Motor Driver Library for Proteus V1.0
  • README.txt: the devices, installation, the demo, wiring, the test tools and real hardware.
  • Proteus Library Files: TEPTB6612.LIB, TEPMOTOR.LIB and ArduinoV4TEP.LIB from our Arduino Library for Proteus V4.0.
  • Proteus Model Files: TEPTB6612.DLL, TEPMOTOR.DLL and TEPARDUINO.DLL.
  • Proteus Simulation: TB6612FNG-Motor-Driver-ArduinoUnoV4.pdsprj, TB6612_Demo.hex and copies of the three DLLs.
  • Arduino Code: TB6612_Demo.ino (it uses the SparkFun TB6612FNG Arduino Library).

No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.

How to Install TB6612FNG Motor Driver Library for Proteus

  1. Close Proteus and extract the whole zip file, for example to your Desktop.
  2. Copy the three files from Proteus Library Files into the LIBRARY folder of Proteus (usually C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\LIBRARY).
  3. Copy TEPTB6612.DLL, TEPMOTOR.DLL and TEPARDUINO.DLL from Proteus Model Files into the MODELS folder.
  4. Delete TEPTB6612.IDX and TEPMOTOR.IDX from the LIBRARY folder if they are there.
  5. Start Proteus, press P and search for TB6612 and TT MOTOR.

Tip: if you already installed our L9110S library, TEPMOTOR.LIB and TEPMOTOR.DLL are the same files, so you can simply overwrite them. Keep the Proteus Simulation folder together, because the project needs its .hex file and the DLLs beside it. The library is tested in Proteus 8.5; Proteus 7 is not supported.

The TB6612FNG Breakout in Proteus

Figure: DRV1, the Simple driver, at full speed on motor A: the ON LED lit, the A LED green and the STATUS panel under the board.

The driver looks like the real breakout: the red board with the TB6612FNG in the middle, the capacitors on VM and VCC, and eight header pins on each side. The inputs come in from the left, in the order PWMA, AIN2, AIN1, STBY, BIN1, BIN2, PWMB, GND, and the supplies and the motor outputs leave to the right: VM, VCC, GND, AO1, AO2, BO2, BO1, GND. That is the pin order of the SparkFun breakout and of the many red boards that copy it, so the wiring you draw in Proteus is the wiring you solder later.

Under the board is the TEP strip. The ON LED is green while the chip has logic power and STBY is HIGH, so a dark ON LED tells you at once that the chip sleeps. The A and B LEDs show each channel: green for forward, red for reverse, brighter with more duty, dark for brake, stop or standby. The strip, its LEDs and the panels are TEP additions; a real board has none of them.

The Simple driver adds the TB6612FNG STATUS panel. Its banner says what both motors do, for example "A: FWD 50 %", or shows STANDBY in amber, NO LOGIC POWER, or the latest warning in red. Ten readouts follow: the state, duty, volts and amps of each channel, VM and VCC, and STBY. At the bottom are the last six events. The red X closes the panel, and the PANEL button on the strip opens it again.

Figure: DRV2, the Advance driver, during a left turn of the robot car: A in reverse (red), B forward (green).

The Advance driver keeps the schematic clean: only the board and its strip. Its live data opens in a pop-up window at Run, and the OPEN PANEL button brings the window back if you close it.

The TT Gear Motor in Proteus

Figure: Motor M1 of the demo at four moments: PWM 128, 191 and 255, then 255 with LOAD on.

While the simulation runs, the wheel turns at the simulated speed, with a motion blur on the spokes when it is fast and a red dot on the hub that shows the real rotation. The strip under the motor shows the speed with its direction, for example "199 RPM CW", the voltage across the motor and its current, as 50 ms averages.

Here the MOSFETs show what they are worth. With the demo's 5 V on VM, motor A reached 88.7, 143.8 and 198.8 RPM at PWM 128, 191 and 255, and at full speed it had 4.91 V across it: less than 0.1 V was lost in the driver at 0.15 A. A bipolar driver loses several times more at the same current, and the motor runs slower for it.

The LOAD Button

Figure: LOAD on: a finger presses on the tyre. Motor M1 dropped from 198.8 to 136.2 RPM and its current rose from 0.15 to 0.48 A.

Click LOAD under a motor, or click its wheel, and a finger presses on the tyre: 0.2 kg.cm of friction on the wheel. The motor slows down and draws more current, exactly what your sketch and your battery will meet in a real robot. Click again to lift the finger. The property LOAD adds a constant load in kg.cm for the whole run.

Figure: Motor B in reverse at PWM 128: -88.5 RPM, and the readout says CCW.

If a motor is held for half a second at more than 0.5 A, it writes STALLED to the simulation log; above 7.5 V it warns about the over-voltage, because the TT motor is rated for 3 - 6 V.

The Demo Circuit

Figure: The demo project running: node 1 with the Simple driver and two motors, node 2 with the Advance driver and two motors.

The demo project has two nodes. Each one is an Arduino UNO V4.0 from our Arduino UNO Library for Proteus V4.0, one TB6612FNG driver and two TT motors. Both UNOs run the same TB6612_Demo.hex; the D12 pin chooses the demo. Node 1 leaves D12 open and runs the speed steps on the Simple driver; node 2 ties D12 to GND and drives its Advance driver as a robot car.

Figure: The same project before Run: the wheels stand still and the STATUS panel waits for the simulation.

Wiring

Figure: The wiring of node 1: every header pin climbs to a net label; the same name is the same wire.
The wiring (the same in Proteus and on a real board; the pins of SparkFun's example)
BoardArduino UNONote
AIN1D2motor A direction
AIN2D4motor A direction
PWMAD5PWM 980 Hz, motor A speed
BIN1D7motor B direction
BIN2D8motor B direction
PWMBD6PWM 980 Hz, motor B speed
STBYD9HIGH = run
VCC5Vlogic, 2.7 - 5.5 V
VM5Vor a separate motor supply
GNDGNDall three GND pins, common with the motor supply
AO1, AO2motor AAO1 to +, AO2 to -
BO1, BO2motor BBO1 to +, BO2 to -

In Proteus every header pin reaches its UNO through a wire with a net label: D2_1, D4_1, D5_1, D6_1, D7_1, D8_1, D9_1 and 5V_1 for node 1, the same with _2 for node 2, and GND. The labels climb in a staircase, so no wire crosses another. The motors are wired straight to the outputs, so you can follow each wire from the chip to the motor. The serial monitor needs no wires at all, because it is built into the UNO V4.0.

Node 1: Speed Steps on the Simple Driver

Figure: Node 1 at PWM 191: motor A at about 144 RPM, motor B held by the short brake.

The speed steps run motor A at 25, 50, 75 and 100 %, then motor B in reverse at 50 and 100 %, both forward at 60 %, a short brake, both at 100 % and finally standby. Most steps last 2.5 s, and the list starts again. While one motor runs, the other one is held by the short brake.

Node 2: The Robot Car on the Advance Driver

Figure: Node 2 turning left: motor A turns backward and motor B forward at about 64 RPM, so the car spins on the spot.

The robot car drives forward at PWM 200, turns left and right by running the motors in opposite directions at PWM 100, drives backward at PWM 200 (-150.6 RPM in the run), brakes and then sleeps in standby. A real two-wheel car does exactly this with the same sketch.

Figure: The last move of the robot car: STBY LOW, the ON LED is dark, both outputs are open and the wheels have rolled to a stop.

The Arduino Code

The demo uses the SparkFun TB6612FNG Arduino Library, which you can install from the Library Manager of the Arduino IDE. New to Arduino? Start with Arduino Tutorial for Beginners and Introduction to Arduino UNO. The sketch begins with the library and the pins of SparkFun's own example:

#include <SparkFun_TB6612.h>

#define AIN1 2
#define AIN2 4
#define PWMA 5
#define BIN1 7
#define BIN2 8
#define PWMB 6
#define STBY 9
#define MODE_PIN 12

Each motor becomes a Motor object with its two direction pins, its PWM pin, an offset and the shared STBY pin. The offset is a handy trick: if a motor turns the wrong way, change its offset to -1 instead of swapping wires.

// offset 1 or -1 flips a motor's direction in software (no rewiring)
const int offsetA = 1;
const int offsetB = 1;

Motor motor1 = Motor(AIN1, AIN2, PWMA, offsetA, STBY);
Motor motor2 = Motor(BIN1, BIN2, PWMB, offsetB, STBY);

The library does the truth table for you. drive(speed) takes -255 to 255: it pulls STBY HIGH, sets IN1 and IN2 for the direction and writes the speed to the PWM pin. brake() sets IN1 and IN2 HIGH, the short brake. standby() pulls STBY LOW. There is one trap: brake() does not touch STBY, so after standby() a brake would do nothing and the motors would keep coasting. The demo wakes the chip first:

// the library's brake() leaves STBY as it is: wake the chip first, or a brake after STANDBY would do nothing (the motors coast)
void wake() { digitalWrite(STBY, HIGH); sleeping = false; }
void setA(int s) { speedA = constrain(s, -255, 255); wake(); if (speedA) motor1.drive(speedA); else motor1.brake(); }
void setB(int s) { speedB = constrain(s, -255, 255); wake(); if (speedB) motor2.drive(speedB); else motor2.brake(); }

Standby needs only one call, because both motors share the STBY pin:

void standbyBoth() { motor1.standby(); speedA = speedB = 0; sleeping = true; }   // STBY LOW: both motors off (coast)

Each speed is printed as a percentage with its PWM value. The percentage is rounded, so PWM 191 prints 75 %:

void printMotor(char m, int s) {
  Serial.print(m);
  if (sleeping) { Serial.print(F(" STANDBY")); return; }
  if (s > 0) Serial.print(F(" FORWARD ")); else if (s < 0) Serial.print(F(" REVERSE ")); else { Serial.print(F(" BRAKE")); return; }
  Serial.print(((long)abs(s) * 100 + 127) / 255); Serial.print(F(" % (PWM ")); Serial.print(abs(s)); Serial.print(')');
}

The two demos are tables of steps. Each step holds the speed of motor A, the speed of motor B, how long it lasts and its name; the special value 999 puts the chip in standby:

const int STBY_STEP = 999;
struct Step { int a, b; uint16_t ms; const char* name; };
const Step CAR[] = {{200, 200, 3000, C0}, {-100, 100, 2000, C1}, {100, -100, 2000, C2}, {-200, -200, 3000, C3}, {0, 0, 1500, C4}, {STBY_STEP, 0, 1500, C5}};

The robot car uses the library's two-motor helpers. Note that left() and right() halve the speed you give them, so the sketch passes twice the turning speed:

  else if (car) {                        // the robot car uses the library's two-motor helpers
    if (s.a > 0 && s.b > 0) forward(motor1, motor2, s.a);
    else if (s.a < 0 && s.b < 0) back(motor1, motor2, -s.a);
    else if (s.a < 0) left(motor1, motor2, 2 * s.b);   // left(): the left motor back, the right one forward, at speed / 2
    else if (s.b < 0) right(motor1, motor2, 2 * s.a);
    else { wake(); brake(motor1, motor2); }

In setup() the D12 pin decides the demo. Its internal pull-up keeps it HIGH when it is open:

void setup() {
  pinMode(MODE_PIN, INPUT_PULLUP);
  car = digitalRead(MODE_PIN) == LOW;
  Serial.begin(9600);

The commands from the serial monitor are read in loop(). "A" or "B" with a number sets that motor and stops the automatic demo; BRAKE and STANDBY act on both motors:

  if ((c[0] == 'A' || c[0] == 'B') && (c[1] == ' ' || c[1] == '=')) {
    autoRun = false;
    const int v = atoi(c + 2);
    if (c[0] == 'A') setA(v); else setB(v);
    report("SET");
  } else if (!strcmp(c, "BRAKE")) { autoRun = false; wake(); brake(motor1, motor2); speedA = speedB = 0; report("BRAKE"); }
  else if (!strcmp(c, "STANDBY")) { autoRun = false; standbyBoth(); report("STANDBY"); }
  if (autoRun) {
    const Step& s = car ? CAR[step] : STEPS[step];
    if (millis() - stepAt >= s.ms) {

The HEX file is in the package. To change the sketch, install the SparkFun library, open the sketch in the Arduino IDE and export the compiled binary, as in How to get the HEX file from Arduino. It needs 6,770 bytes of flash and 411 bytes of RAM.

The Advance Pop-Up Window

At Run, the Advance driver opens TEP TB6612FNG Motor Driver Advance, with the look of our TEP Serial Monitor Advance for Proteus. It has three tabs, Motors, Event log and Tests, plus Settings and Help behind the gear and question mark icons.

Motors

Figure: The Motors page during a left turn: motor A in reverse, motor B forward, both at PWM 100 (39 %).

Each motor gets a card. The big coloured bar names the drive and its duty: green for forward, red for reverse, amber for a brake and grey for standby. The gauge below runs from full reverse to full forward. Then come IN1, IN2, PWM and the output over the last 10 ms as waveforms, so you see the pulses the sketch sends and the output turning amber in every PWM off time, which is the short brake at work. The tiles give the direction inputs, the PWM duty and frequency, the output volts and amps as 100 ms averages, the peak current of the run and STBY.

Figure: The turn right: on the scope, motor A crosses from reverse to forward and motor B the other way, with a current peak at the reversal.

The scope at the bottom draws the output volts (blue) and amps (orange) of both channels over the last 3 s. Watch the moment a motor reverses: the current jumps while the motor is still turning the wrong way, then settles. In this run the largest peak was 1.76 A, still well under the chip's 3.2 A peak rating. Freeze holds the page for a closer look.

Figure: STANDBY typed into ARD2's monitor: both cards say STANDBY - OUTPUTS OPEN although PWMA and PWMB still pulse at 79 %.

This screenshot shows why STBY matters. The sketch was in the middle of driving backward when STANDBY arrived; the library only pulled STBY LOW, so PWMA and PWMB kept pulsing. The chip ignores them: both outputs are open, the scope shows the voltage and the current returning to zero, and the status bar says STANDBY (STBY LOW).

Event Log

Figure: The Event log of the robot car: power on, then every change of the drive with its reason, newest first.

The Event log lists power on and off, every drive change that held for 40 ms, and the warnings. Each drive change says why it happened, for example "B BRAKE - IN1 = IN2 = HIGH" or "B COAST (OUTPUTS OPEN) - STANDBY (STBY LOW)", so you can tell a short brake from a stop and a stop from standby at a glance. Filter it by drive changes or warnings, pause it, or clear it. PWM 200 appears as 79 % here, while the sketch prints 78 %: the UNO's timer gives a duty of (200 + 1) / 256 on these pins, and the model measures the real pulses.

The Test Tools

The Tests tab holds three tools. Each one reads the driver as the model sees it and gives every row a green, amber or red verdict.

Figure: Truth table: the six states with their outputs, the state each channel is in now and the time it spent in each.

Truth table is good for a motor that never turns, turns the wrong way or never stops. It lists the six states of the chip, CW, CCW, the short brake in the PWM off time, the short brake with IN1 and IN2 HIGH, stop and standby, with OUT1, OUT2 and what the motor does. It highlights the state each channel is in right now and counts the seconds each channel spent in each state since Start counting. If a channel never leaves standby, you know where to look.

Figure: PWM: every input with its duty and frequency or its steady level, each channel's drive, STBY and the UNO's PWM pins.

PWM is good for a motor that only runs at full speed or not at all, or a sketch that uses a pin without PWM. Every input shows its duty and frequency, or a steady HIGH or LOW with the number of edges so far, and the tool reminds you which UNO pins give 980 Hz and which 490 Hz. A direction pin that changes every few seconds is shown as steady, not as PWM.

Figure: Power: VCC and VM against their ranges, the motor current, each channel against the 1.2 A and 3.2 A ratings and the heat in the chip.

Power is good for a motor that slows when the other one starts, or a supply that sags. It shows VCC and VM against their ranges, the current taken from VM, each channel's average and peak current against the 1.2 A and 3.2 A ratings and the heat in the chip. At 0.156 A per channel, the two 0.25 ohm switches in the path turn only about 0.012 W into heat, which is why a TB6612FNG breakout needs no heat sink.

The Serial Monitor

Both UNOs have the serial monitor built in, and it opens at Run. The screenshots use its Simple interface. Node 1 starts like this:

Figure: ARD1's monitor: the speed steps, each with what motor A and motor B get.
TB6612FNG Dual Motor Driver demo - www.TheEngineeringProjects.com
Mode: SPEED STEPS (D12 open)
Commands: A <-255..255> | B <-255..255> | BRAKE | STANDBY | RUN | HELP
A 25 %: A FORWARD 25 % (PWM 64), B BRAKE
A 50 %: A FORWARD 50 % (PWM 128), B BRAKE
A 75 %: A FORWARD 75 % (PWM 191), B BRAKE
A 100 %: A FORWARD 100 % (PWM 255), B BRAKE
B reverse 50 %: A BRAKE, B REVERSE 50 % (PWM 128)
B reverse 100 %: A BRAKE, B REVERSE 100 % (PWM 255)
both forward 60 %: A FORWARD 60 % (PWM 153), B FORWARD 60 % (PWM 153)
short brake: A BRAKE, B BRAKE

Every step prints its name, then what each motor gets. BRAKE means the short brake; STANDBY means the chip sleeps. Node 2 runs the robot car:

Figure: ARD2's monitor: the robot car's moves.
Mode: ROBOT CAR (D12 to GND)
CAR forward: A FORWARD 78 % (PWM 200), B FORWARD 78 % (PWM 200)
CAR turn left: A REVERSE 39 % (PWM 100), B FORWARD 39 % (PWM 100)
CAR turn right: A FORWARD 39 % (PWM 100), B REVERSE 39 % (PWM 100)
CAR backward: A REVERSE 78 % (PWM 200), B REVERSE 78 % (PWM 200)

Commands

Figure: Two commands typed in ARD1's monitor: A -200 and B 120.

Type a command in the monitor and press Enter. A 150 or A -200 sets motor A, B ... motor B, and 0 is the short brake. BRAKE brakes both motors, STANDBY puts the chip to sleep, RUN starts the demo again and HELP lists them. In the run, the two commands answered:

A -200
SET: A REVERSE 78 % (PWM 200), B FORWARD 100 % (PWM 255)
B 120
SET: A REVERSE 78 % (PWM 200), B FORWARD 47 % (PWM 120)
Figure: After the commands: motor A turns backward at 151.2 RPM, motor B forward at 81.4 RPM.

Standby, Then Brake

Figure: STANDBY, BRAKE, STANDBY, A 0 and A 150 typed into ARD1's monitor.

This sequence tests the trap from the code section. After STANDBY the chip sleeps; BRAKE wakes it and both motors are short-braked; after the second STANDBY, A 0 wakes it again and brakes motor A, and B, whose inputs were still both HIGH, is braked too. The driver model confirmed each state in the run.

STANDBY
STANDBY: A STANDBY, B STANDBY
BRAKE
BRAKE: A BRAKE, B BRAKE
STANDBY
STANDBY: A STANDBY, B STANDBY
A 0
SET: A BRAKE, B BRAKE
A 150
SET: A FORWARD 59 % (PWM 150), B BRAKE

The Simulation Log

Figure: The simulation log: each part introduces itself, the drivers report power on and every drive change with its reason.

Each driver writes its power-up and every drive change to the simulation log, so a long run leaves a readable story of what the motors did. At the start you can see both channels in standby for a moment, before the sketch has pulled STBY HIGH. After 60 drive changes the log stops and points to the Event log, which keeps them all.

How the Simulation Handles PWM

Proteus solves the analog part of a circuit in time steps, here at most 2 ms long, and it solves each step before it runs the digital part up to that time. So the driver learns about a PWM edge only after the step that contains it. The model therefore feeds each step with the average of the inputs, predicted from the step before, and corrects the difference in the next step. The time integral of the drive, which is what turns the motor, is exact, and on a PC we checked that the speed ripple this causes stays under 3 RPM.

One consequence: the volts and amps you see are averages, not single PWM pulses. A real motor also smooths the pulses with its inductance and its inertia, so the average is what matters for its speed.

Troubleshooting

  • Nothing turns and the ON LED is dark: STBY is LOW or not connected (STANDBY in the banner), or VCC is missing (NO LOGIC POWER).
  • The ON LED is lit but nothing turns: no supply on VM, or IN1 and IN2 are both LOW (stop); check the Truth table tool.
  • A motor stays braked: IN1 and IN2 are both HIGH, or the PWM pin stays LOW; analogWrite(PWMA, 0) is a short brake.
  • Full speed or nothing: the PWM pin has no PWM on the UNO, or the sketch only writes 0 and 255; check the PWM tool.
  • The motor turns the wrong way: swap its two wires, or set its offset to -1 in SparkFun's Motor.
  • A brake after standby does nothing: the chip still sleeps; drive STBY HIGH first, as the demo does.
  • OVER 1.2 A or PEAK warnings: a stalled or heavily loaded motor, or a reversal at full speed.
  • No part, no wheels or no monitor: TEPTB6612.DLL, TEPMOTOR.DLL or TEPARDUINO.DLL is missing from MODELS and the project folder; a closed monitor opens again with a click on the UNO's USB port.

Things to Know Before Using a Real TB6612FNG

  • Two supplies: feed the motors from their own battery on VM and the logic from the Arduino's 5V or 3.3V on VCC, with all grounds common. TT motors draw up to 1.5 A when they start or stall, more than an Arduino's 5V pin should give.
  • Low VM: the chip gives its full current from 4.5 V on VM; between 2.5 and 4.5 V the datasheet allows much less.
  • STBY: drive it from a pin or tie it to VCC; left open, its pull-down keeps the chip asleep.
  • PWM pins: D5 and D6 give 980 Hz, D3, D9, D10 and D11 give 490 Hz; the chip accepts up to 100 kHz.
  • Reversing: brake or slow down before you reverse a fast motor; the current peak is hard on the chip and on your battery.

Limitations of the Simulation

  • The outputs follow PWM one SPICE step (up to 2 ms) late and show averages; single pulses are not resolved.
  • Not modelled: the chip's heating and thermal shutdown, the lower current limit below 4.5 V on VM, dead time and switching delays, the motor's inductance and current ripple, gearbox backlash, a stepper motor, and damage from over-voltage or over-current (the model warns).
  • The strip, its LEDs, the panels and the LOAD button are TEP additions.
  • The models are our own, written from Toshiba's TB6612FNG datasheet and the published TT motor data; this library is not made or endorsed by Toshiba, SparkFun or Labcenter.
  • Licences: the HEX file contains the SparkFun TB6612FNG Arduino Library (MIT licence, its notice is in the README) and the Arduino AVR core 1.8.6 with LGPL-licensed code; the sketch is included.
  • Tested in Proteus 8.5 in October 2026 (the demo as shipped on two Arduino UNO V4.0 boards with their built-in monitors: the speed steps, the robot car, standby, the LOAD button, the commands, the pop-up and the three tools; about 0.4 x real time with the pop-up and both monitors open). Proteus 7 is not supported.

So, that was all about the TB6612FNG Motor Driver Library for Proteus V1.0. I hope the truth table, PWM speed control, the short brake, the stop and standby are clear now, so your robot car drives straight from its first run. If you use the TB6612FNG Motor Driver Library for Proteus in a project, please share it in the comments or in our forum, and if you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!