Pinout on the Toshiba TA8250
Pin out on the Toshiba TA8250

Arduino Operating TA8050 H-Bridge Motor Controller

by Lewis Loflin

See:

TA8050P H-Bridge Motor Control YouTube
TA8050P H-Bridge Motor Control

The purpose of this tutorial is the demonstrate using the ATMEGA168/Arduino to control the speed and direction of a 12 volt DC using an "h" bridge.

We will make use of pules-width modulation (PWM) to control motor speed. In this case we are using Toshiba TA8050 integrated circuit and a home-built "H" bridge using power MOSFETs.

An H-bridge is an electronic circuit which enables a voltage to be applied across a load in either direction. These circuits are often used in robotics and other applications to allow DC motors to run forwards and backwards. H-bridges are available as integrated circuits, or can be built from discrete components or even relays and manual switches.

A solid-state H-bridge is typically constructed using reverse polarity devices such as PNP bipolar transistors or P-channel MOSFETs connected to the positive voltage bus and NPN bipolar junction or N-channel MOSFETs connected to the negative voltage bus).

Pulse-width modulation (PWM) is a very efficient way of providing intermediate amounts of electrical power between fully on and fully off. A simple power switch with a typical power source provides full power only when switched on.

PWM is a comparatively-recent technique made practical by modern high speed electronic power switches.

This goes beyond mere thermostats that cycle on and off at very slow rates. An inexpensive solid-state lamp dimmer controls the amount of time each AC half-cycle (120 Hertz) is on. See Basic Triacs and SCRs

In the past, when only partial power was needed (such as for a sewing machine motor), a variable power resistor (foot-controlled; a rheostat) connected in series with the motor adjusted the amount of current flowing through the motor. Part of the power was wasted as heat in the resistor element. Auto transformers could be used but are costly.

In pulse width modulation average voltage is proportional to duty cycle.
Average voltage is proportional to duty cycle.

See Pulse Width Modulation Power Control for Microcontrollers

The term duty cycle describes the proportion of on-time versus off-time. Duty cycle is expressed in percent, 100% being fully on 0% is fully off.

In the Arduino has six digital pins (3, 5, 6, 9, 10, 11) that can be programmed as 8-bit PWMs. Using the command analogWrite(pin, value) where 'pin' is the output pin and 'value' is a number from 0 to 255.

In the above example we could have a frequency (f) of 1000 Hertz which give us the period or cycle time (1/f = T) of 1 millisecond or 1000 microseconds. If the digital pulse is HIGH for 250 microseconds and LOW for 750 microseconds we have a duty cycle of Ton/T X 100 = 250/1000 X 100 = 25%.

For example an analogWrite(3, 0) outputs zero volts or fully off on digital pin 3. And analogWrite(255, 3) outputs 5 volts or fully on with digital pin 3. A value of 128 produces a square wave that's 50% on and 50% off for a duty cycle of 50%.



In the example below the motor would run somewhere around half-speed without wasting half the power as heat if we had used a variable resistor in series. See Q1 in schematic below.

Arduino PWM digital to analog conversion.

Also see:

PWM works well with digital controls because of its on/off nature. Finally a simple resistor/capacitor low pass filter on the output pin will produce an analog voltage of 0 to 5 volts depending on duty cycle.

You do not need to call pinMode() to set the pin as an output before calling analogWrite(). The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles.

This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs.

TA8050 Block hookup Diagram
Ta8050 to Arduino hookup diagram

Shown above is the TA8050P a 1.5 A motor driver that directly drives a DC motor. Inputs Dl1 and Dl2 are combined to select one of forward, reverse, stop, and brake modes. Since the inputs are TTL-compatible, this IC can be controlled directly from a CPU or other control system. The IC also has various protective functions. See TA8050P 'H' Bridge Motor Controller


#define port1 9 
#define port2 10
#define SW1 3
#define SW2 4

int val; // variable 
// A '1' or HIGH are both understood to both be a binary 1.
// A HIGH on a port pin is 5 volts.
// A '0' or LOW are both understood to be a binary 0.
// A LOW on a port pin is 0 volts.

void setup()  {
   pinMode(port1, OUTPUT);  // DL1 TA8050 H bridge
   pinMode(port2, OUTPUT);  // DL2 TA8050 H bridge
   pinMode(SW1, INPUT);
   pinMode(SW2, INPUT);

   digitalWrite(SW1, 1); // pull up on
   digitalWrite(SW2, 1); // pull up on
   // turn off 'H' bridge:
   analogWrite(port1, 0); // 0 volts out or LOW
   analogWrite(port2, 0); // 0 volts out or LOW
   
   } // end setup

void loop() {  // main loop
 
   //  If neither SW1 or SW2 are pushed a digitalRead(pin) 
   // will return a HIGH because of the pull ups.
   //  A return of LOW means the switch was pressed.  
   //  A zero is written to both PWMs on port1 and port2 
   // will ouput a LOW.
   
   //  We need to get the value from a speed control 
   // (variable resistor) connected 
   // analog input 0. This ten bit value from 0-1023 
   // must be divided by four before
   // being written to a PWM pin which is 8 bits.
   val = analogRead(0) / 4 ;
   //If we press SW1:
   if (digitalRead(SW1) == 0) {
     analogWrite(port1, val); // write val to PWM port1.
     analogWrite(port2, 0);
   }
   // If we press SW2:
   if (digitalRead(SW2) == 0) {
     analogWrite(port1, 0); // write val to PWM port2.
     analogWrite(port2, val);
   }
   // while either switch is held down one can adjust the speed.
   
   // if both switches are pushed at the same time the motor will stop
   if ((digitalRead(SW1) == 0) && (digitalRead(SW2) == 0)) {
     analogWrite(port1, 0);
     analogWrite(port2, 0);
     delay(500); // delay half second for key release
   } 
       
} // end loop

TA8050P H-Bridge Motor Control YouTube
TA8050P H-Bridge Motor Control

Optical Isolation of H-Bridge Motor Controls YouTube
Optical Isolation of H-Bridge Motor Controls

Opto-Couplers Theory and Circuits YouTube
Opto-Isolated Transistor Drivers for Micro-Controllers

All NPN Transistor H-Bridge Motor Control YouTube
All NPN Transistor H-Bridge Motor Control

Pulse-Width Modulation Tutorial YouTube
Pulse-Width Modulation Tutorial

PIC12F683 Microcontroller and Circuits YouTube
PIC12F683 Microcontroller and Circuits

You Tube Arduino Microcontroller Video Series March 2012: