Home>>Technology>>Arduino>>Getting Started with the Pololu TB9051FTG Motor Driver
ArduinoTechnology

Getting Started with the Pololu TB9051FTG Motor Driver

What is the TB9051FTG?

The Toshiba TB9051FTG is a brushed DC motor driver. From Pololu’s website:

The TB9051FTG from Toshiba is an H-bridge motor driver IC that can be used for bidirectional control of a single brushed DC motor at 4.5 V to 28 V. It can supply up to about 2.6 A continuously, and it can deliver peak currents up to 5 A (typical) for a few seconds.

https://www.pololu.com/product/2997

Since a standard, hobby-grade DC motor such as this one draws less than 1 A in normal operation, and less than 3-4 A in a stall condition, the TB9051FTG is a fine choice for many small robotics applications, or other projects where motor control is needed.

What differentiates the TB9051FTG from other motor drivers?

There are many, many different variations of motor drivers available. Some are for stepper motors, others are for brushless motors, still others can only drive very small motors. Some motor drivers even have microcontrollers embedded inside them.

One of the most popular motors drivers is the L298N. This motor driver uses an H-Bridge to control up to 2 motors. Thus, it is useful in some robots which use 2 separate motors for differential drive. However, the TB9051FTG has some useful features that are uncommon on other motor drivers:

  • Current Monitoring – The motor driver reports how much current the motor is drawing
  • Over-Current Response – Normally, a motor controller would simply stop working if the motor connected to it draws excessive current, however, this motor controller can limit the peak current the motor uses.
  • Brake Modes – The TB9051FTG can be configured to either coast or perform regenerative braking when the motor is stopped.

Wiring Guide

Here is a list of the basic connections you will need to make to operate this motor driver:

  1. Terminal block VIN – Voltage input from power source (usually a battery)
  2. Terminal block GND – Ground from power source
  3. Terminal blocks OUT1 and OUT2 – DC motor input.
  4. Header GND/VCC – Ground and 5V from microcontroller.
  5. Header EN – 5V, from microcontroller’s digital output.
  6. Header ENB – 0V, from microcontroller’s digital output.
  7. Header PWM1/PWM2 – Digital pins 5/6 from the microcontroller. (The pinout can change, of course).
  8. Header OCM – Analog pin 1 from microcontroller(Can also be reconfigured).

Here is a wiring example using an Arduino Nano, and 4 AA batteries (which, when fully charged, provide about 5 volts).

Programming the Arduino

Now that we have everything wired up, we need to figure out how to get the Arduino to send the correct signals to the motor controller. There is a very helpful library available for Arduino which makes it very straightforward to interface with this motor controller.

To use this library, open up your Arduino IDE and select Sketch > Mange Libraries > Library Manager. Install the library called TB9051FTGMotorCarrier

Next, upload this code to your Arduino:

#include <TB9051FTGMotorCarrier.h> // Include the library for interfacing with the motor controller

// TB9051FTGMotorCarrier pin definitions
static constexpr uint8_t pwm1Pin{5};
static constexpr uint8_t pwm2Pin{6};
static constexpr uint8_t ocmPin{A1};

int enbPin = 7;
int enPin = 8;

static float throttlePercent{0.0f};

// Instantiate TB9051FTGMotorCarrier with the pins provided
static TB9051FTGMotorCarrier driver{pwm1Pin, pwm2Pin, ocmPin};

void setup() {
  pinMode(enPin, OUTPUT); 
  digitalWrite(enPin, HIGH); // Set Enable pin to High
  pinMode(enbPin, OUTPUT);
  digitalWrite(enbPin, LOW); // Set ENB pin to Low
  
  Serial.begin(9600); // Instantiate Serial port through USB

  driver.enable(); // Enable motor driver
}

void loop() {
  motorRamp();
}

void motorRamp() {
  // ramp up to full speed in 50*200 = 10000 millsec
    for(int i = 0; i < 200; i++) {
      driver.setOutput(throttlePercent);
      Serial.print(throttlePercent);
      Serial.print(" --> ");
      Serial.println(driver.getCurrent());
      throttlePercent+= 0.005;
      delay(50);
    }

    // ramp down to 0 speed in 50*200 = 10000 millsec
    for(int i = 0; i < 200; i++) {
      driver.setOutput(throttlePercent);
      Serial.print(throttlePercent);
      Serial.print(" --> ");
      Serial.println(driver.getCurrent());
      throttlePercent-= 0.005;
      delay(10);
    }

    // ramp down to full REVERSE speed in 50*200 = 10000 millsec
    for(int i = 0; i < 200; i++) {
      driver.setOutput(throttlePercent);
      Serial.print(throttlePercent);
      Serial.print(" --> ");
      Serial.println(driver.getCurrent());
      throttlePercent-= 0.005;
      delay(50);
    }

    // ramp up to 0 speed in 50*200 = 10000 millsec
    for(int i = 0; i < 200; i++) {
      driver.setOutput(throttlePercent);
      Serial.print(throttlePercent);
      Serial.print(" --> ");
      Serial.println(driver.getCurrent());
      throttlePercent+= 0.005;
      delay(50);
    }
}

Make sure to unplug your Arduino’s USB cable before connecting it to the motor, or the USB connection will attempt to supply the current demands of the motor, which could be damaging to your computer.

Hope you liked this tutorial! Below is a video of the circuit and code in this tutorial in action:

Leave a Reply

Your email address will not be published. Required fields are marked *