Username:    Password: Remember me

Build a 5A H-Bridge motor driver!
Using cheap TIP127 and TIP122 transistors
Small & high efficiency home-made solution!
By Ibrahim Kamal
Last update: 5/6/08

Overview
In this article, I am going to show you how to build a relatively High power H-bridge motor controller (which is the most common way to control DC motors) With cheap TIP transistors..

My goals were:
1-To build a small module, that can be added to any robot or any system where motor control is required.

2- To build a high efficiency device with a relatively high continuous current rating.

5 Amperes of continuous current through an H-bridge module may not seen "high power" to some
of you, depending on your field and experience, That's why i used the word "relatively". But in the field of hobby electronics and robotics, yes a controller capable of controlling motors with currents as high as 5A at 24V is considered a high power device.


Key Features:
5A Continuous current, 8A peak
High performance cooling system
Protection Circuit included
Compact Design

Unexpensive components


This article will be splitted in two main parts The Theory and the Hardware construction

PART 1: THE THEORY

The H-Bridge & DC Motors..
The H-Bridge is principally a configuration of 4 switches, that are switched in a specific manner to control the direction the of the current through the motor. (For brushed DC motors, the direction of rotation of the armature of the motor is changed by changing the direction of the current flowing though it). While we are talking about DC motors, here is a small useful note to bear in mind: "Current flowing though a motor is proportional to the output torque, while the angular velocity (rpm) of the the output shaft is proportional to the the voltage across the motor windings"

Below is a simplified diagram showing the operation of the H-Bridge configuration.
(you can notice the shape of the schematic, it looks like an 'H' letter.. this is how this famous circuit got this name!) There are 2 possible paths for the current:
1- The red path, where the the current is directed to the motor through the switches S3 and S2, causing the motor to turn clockwise
2- The green path, where the current is directed to the motor through the switches S1 and S4, causing the motor to turn anti-clockwise.

The only difference between this simple H-Bridge and the real H-bridge module explained on this page, is that the switches are replaced by Transistors, in order to electronically control the flow of current in the motor, Hence, allowing us to
control the speed and direction of the motor from a microcontroller, for example.

In case you are a beginner or just not familiar with transistors, I am going to explain in the next section most of what you need to know about transistors to understand and build an H-Bridge.

Introduction to switching transistors:


Detailed switching transistor tutorial can be found here:
http://www.ikalogic.com/tut_bjt_switches.php


One very simple way to use transistors is to use them as switches, to electronically control the flow of current though other electrical elements. The same transistor may be used as a signal amplifier, but this is the messy part of the transistor studies, and we don't need this for our H-bridge. Using transistors as a switch is also called "using transistors in saturation and cut-off mode".
This schematic below simply shows the meaning of using a transistor as a switch. the only difference between a mechanical switch and a transistor switch is that a normal switch is turned ON or OFF mechanically while a transistor switch is turned ON and OFF using small
electrical currents applied on the Base, usually smaller than 20 mA. For an NPN transistor, when a small current flows into the Base of the transistor, current will flow from the Collector to the Emitter, otherwise, no current will through the CE junction (Collector-Emitter junction). On the other hand, for a PNP transistor, when a small current is allowed out from the base of the transistor, current will flow from the Emitter to the collector.

In order to use the transistor as a switch, the base voltage has to be
Higher than the Collector voltage (in case of NPN transistor), or Lower than the collector voltage (in case of PNP transistor). Also, to ensure the transistor is saturated, you must calculate the suitable value of Rb shown in the schematic (this will be discussed in detail later).

You may wonder why are there two different implementations of the Transistor switch, one with NPN transistor, the other with a PNP one. the answer is very simple. it is to ensure that the base voltage is at a suitable level to ensure the transistor is saturated whether it is connected to ground or to 12V. (in the H bridge, 2 transistors are connected to 12V, while the 2 others are connected to Ground.)

Base Resistor calculations for an NPN transistor:
Calculating the suitable Base resistance for an NPN transistor is very easily done by following those steps:
1- Depending on the transistor you are using, gather from the datasheet the following values. sometimes for beginners, finding those values in the datasheet, or the nearest suitable values, need some patience!
VBE The voltage drop between the Base and the Emitter
IBmax The maximum current that can flow into the Base without damaging the transistor (also called Ib Peak in some datasheets)
HFE The current gain of the transistor

2- chose a suitable value for Ibase but without getting too close the the value of Ib max.
The value of Ib you choose must be enough to drive the transistor and deliver the required Collector Current: [ Ib = Ic / HFE ] (where HFE is the current gain of the transistor).
You can always choose a value of Ib higher than what you've calculated, it's even better, as long as it is lower than the Maximum base current specified in the datasheer.

3-Calculate the volt across the resistance Rb. Assuming you are controlling the device with a Standard CMOS or TTL compatible device (5v and 0v outputs):
[ Vr = 5 - Vbe ]

4- Now that we know the voltage across the resistance (Vr), and the current flowing into the Base through that resistance, we can calculate its value:

[Rb = Vr/Ib]
Or,
[Rb = (5-Vbe)/Ib]

Another approach by John Hewes in this very interesting article about switching transistors is to use this formula:

RB =
Vc × hFE
where Vc = the supply voltage of the device driving the base of the transistor (5v in our TTL example)
(Ic is multiplied by 5 as a safety factor)

 
5 × Ic

Base Resistor calculations for a PNP transistor:
Since NPN and PNP transistors react the same way (except all polarities are inverted), You can choose the same base resistor for both types. For the H-bridge circuit, you can calculate the value of the Base Resistors for the NPN transistors and use the same value for the PNP transistor.

The applied circuit
This is the electronics circuit of the device you've seen in the picture at the top the document.
It will be presented to you in 4 main sections, each one shaded with a different color.

1- The Protection And Logic circuit, shaded in light yellow.
3- The H-Bridge, composed of the 2 TIP122 and 2 TIP127 Transistors, shaded in light red.
4- The Fan connections and the 'Power on' LED.

Click on any shaded part to jump to the corresponding explanation in the rest of the document.
Note: Any transistor that is not labled in the schematic, is a 2N2222 BJT
The protection and Logic circuit:

This section's job is to prevent the controller device from giving destructive orders to the H-Bridge, like turning ON all 4 transistors at the same time (this would cause a terrible short circuit, destructing at least one or 2 of the transistors)
It also has the function
of taking the input from another control circuit (a microcontroller or any control device that will control the H-Bridge) with a minimum number of input wires, and, through this simple gate array, control the 4 transistors.
Each one of the 4 end transistor of this stage (Q1, Q2, Q3 and Q4) have the function of inverting the signal and performing voltage & current amplification. They provide Active turn OFF output to control the power transistors of the H bridge. Active Turn Off, means that when the transistor is OFF, it provides output through a pull up or pull down resistor, but when turned ON, they switch off what ever device attached to their output. Active Turn OFF provide a smaller Turn-OFF time, increasing the H bridge performance.

Note that NPN transistors like the TIP122 are switched OFF by applying a 0V on its base, while a PNP transistors like the TIP127 are switched OFF by applying a High (12v) on its base.

The 4 resistors R2, R4, R5 and R10 must be at least 1/2 W rating in order to sustain high currents passing through it, especially if you intend to use this H bridge with a 24V power supply.

In the truth table below, the 3 inputs to the gates (P1,P2 and P3) and their relation with the outputs of 4 end transistors in the yellow area (Q1,Q2,Q3 and Q4).
Inputs
Outputs
Result on the H-bridge
P3
P1
P2
Q1
Q2
Q3
Q4
0
X
X
1
1
0
0
Motor is Freewheeling
1
0
0
1
1
1
1
breaking the motor (0v at both leads)
1
0
1
1
1
0
0
Turn the motor clockwise
1
1
0
0
0
1
1
Turn the motor anti-clockwise
1
1
1
0
0
0
0
breaking the motor (12v at both leads)
*(X mean Don't care), 1 = High level Voltage, 0 = Low level voltage.

The Input P3 is the 'Enable' input. Any professional H-Bridge, have an enable input to turn On or Off the whole motor controller, and when turned off, the motor should act as if it wasn't connected to anything (High Impedance). and this exactly what the pin P3 does in this circuit. This functionality is mostly used to control the speed of motors using PWM (pulse width modulation). I am not going to explain what is PWM in this tutorial, but briefly PWM is a way to control the speed of a DC motor by turning it ON and OFF very fast, varying the ON time and the OFF time will affect the speed of the motor.

All the values of the resistors are calculated using the formulas at the top the document, to ensure all transistor are in saturation mode, especially the 4 TIP transistors.



The H-Bridge, composed of the 4 TIP Transistors:
TIP122/TIP127 are power transistors, each one composed of 2 transistors in series in one integrated package, with a current gain of 1000 (which is very high for transistors, causing it to saturate very easily) which makes this transistor very suitable to be used as a switch or in an H-Bridge configuration.

The Diodes D2 to D5 are very important to protect the Transistors from the Back E.M.F. voltages produced by any inductive loads when switched ON or OFF. (DC motors are inductive loads that can cause important back E.M.F. currents)

Note that the TIP122/127 have integrated protection diodes, but we added more diodes as a factor of safety.

J5 is the jack to connect the motor.

The Fan connections and the 'Power on' LED:


Nothing critical about this part, just a connection to power the FAN to cool the transistors, and a red LED as a status to show whether the module is powered or not.

PART 2: Hardware construction

Now let's see how to construct this H-bridge module. Note that I'm am not going to show you how to make PCBs, you can learn this anywhere on the net.
An overview on The PCBs
As you can see there are 2 boards. One of them is the PCB which will hold the control circuit with the 4 TIP transistors.
The other is a heat sink board. actually its a PCB on which i've printed 2 regions, all in copper. (those copper surfaces will act a good heat sink when firmly attached to the transistor)

Why Divide the heat sink in 2 regions? simply because the the back of the transistor that dissipates heat is internally connected to the collector of the transistor, thus each group of 2 transistors (TIP122 & TIP127) have to be electrically isolated from the other 2 transistors.

Below is a view of the TIP122 and TIP127 mounted
on the heat sink board. notice there are still 4 unused holes. those will be connected to the Fan and to the main board.


Main PCB


The assembly

  After the PCB is ready and all components are soldered, plug the FAN+Heat sink+Transistors in the main board.

If your drilling is accurate, the assembly process should be very easy.


Notice How the 6 pins connector is firmly soldered to the wires by the mean of a piece of PCB. This will make a very rigid connector.


Now you're done with the construction of the H-bridge module, start testing your H-bridge with constant currents up to 5A, and peak currents of 8A or even more.. i didn't try beyond this limit!



Download the zip file for this project
containing the full schematic, PCB designs and datasheets to all used transistors.

[note: i use ExpressPCB(FREEWARE) to design the schematics and the PCB]


Discussion (Last 15 posts preview...)
Preview of the last 15 messages discussing this page. Messages are sorted from the newest to the oldest.
Posted by:
User avatar
ikalogic

on: 04 Sep 2008
Re: I want to have my DIY CNC controller
['Quote ]

Quoting williamkmcn: I want to build a CNC mill, as I found in the internet, most of them were not "DIY kit" but commercial fully installed set only. Could you give me a good suggestion in motor controlling?


Yes, i can, but what type of motor are you using? What is the power rating? What voltage? What current rating? :)
Posted by:
topdreams
on: 04 Sep 2008
5A H-Bridge motor controllers
['Quote ]
Very good,I think I can make one for my small motor!
Thanks for sharing!
Posted by:
williamkmcn
on: 10 Aug 2008
I want to have my DIY CNC controller
['Quote ]
I want to build a CNC mill, as I found in the internet, most of them were not "DIY kit" but commercial fully installed set only. Could you give me a good suggestion in motor controlling?
Posted by:
kemo0o
on: 12 Jul 2008
Re: 5A H-Bridge motor controllers
['Quote ]
of course we did
i will picture it and post it :wink:
Posted by:
User avatar
ikalogic

on: 12 Jul 2008
Re: 5A H-Bridge motor controllers
['Quote ]

Quoting kemo0o:
Quoting ikalogic:
kemo did you make any of those H-B on your own? can you share some pics?


Do You Mean That i make own design For H-Bridge
Or i make yours ?? :roll:


I mean did you build this H-Bridge? for your own robot? if you did, then i would like to see some pics.
Posted by:
kemo0o
on: 12 Jul 2008
Re: 5A H-Bridge motor controllers
['Quote ]

Quoting ikalogic:
kemo did you make any of those H-B on your own? can you share some pics?


Do You Mean That i make own design For H-Bridge
Or i make yours ?? :roll:
Posted by:
User avatar
ikalogic

on: 11 Jul 2008
Re: 5A H-Bridge motor controllers
['Quote ]

Quoting kemo0o: it isn' the 5th TIP

It is Regulator ( LM 7805 ) :D

About The components , It is shown in the schematic :shock:
just count them :roll:


kemo did you make any of those H-B on your own? can you share some pics?
Posted by:
kemo0o
on: 11 Jul 2008
Re: 5A H-Bridge motor controllers
['Quote ]
it isn' the 5th TIP

It is Regulator ( LM 7805 ) :D

About The components , It is shown in the schematic :shock:
just count them :roll:
Posted by:
irongoat
on: 11 Jul 2008
5A H-Bridge motor controllers
['Quote ]
Another question regarding this circuit :
What is U2? It looks to be a 5th TIP on
the picture, but the schematic does not
include a 5th tip.

PS. Can you post a parts list? It would
greatly simplify construction.

Thanks much,

Charles
Posted by:
hex0r
on: 06 Jul 2008
5A H-Bridge motor controllers
['Quote ]
Hello .

How can i connect R\C Reciver to this schimatic (a standard remote controller reciver)

and if its posiable to change the schimatic to work with a 7 kgm 900rpm 12v dc motor
Posted by:
User avatar
ikalogic

on: 03 Jul 2008
Re: 5A H-Bridge motor controllers
['Quote ]

Quoting irongoat: Greetings,

Im in the midst of building this project, but I have a small concern.
Will the PCB traces withstand 5A if they are a bit "dotty"? I used
the toner transfer method in order to produce the PCB, and my best
print out of several trials resulted in small dots/holes in the copper.
They aren't too bad, but at a few points, it cracks up the trace. At
these points I have tried to solder-reinforce them.

Also, I am planning on connecting this to a car battery and a
motor which draws 4.5 amps. Is there any worry about arching
on the board? Should it be cooled as well as heat sinked?

Thank you much

Charles



Hello,

As for the tracks, it's hard to say.. your best way to find out is to try.. however i don't think it'll be your major problem.

About the heat sinking, well i think that for as much as 4.5 Amps, heat sinking+fan colling is advisable... good luck

by the way, if you can take some pics of your finished product, could you post them here? it's nice to see how the work was applied elsewhere :)
Posted by:
irongoat
on: 03 Jul 2008
5A H-Bridge motor controllers
['Quote ]
Greetings,

Im in the midst of building this project, but I have a small concern.
Will the PCB traces withstand 5A if they are a bit "dotty"? I used
the toner transfer method in order to produce the PCB, and my best
print out of several trials resulted in small dots/holes in the copper.
They aren't too bad, but at a few points, it cracks up the trace. At
these points I have tried to solder-reinforce them.

Also, I am planning on connecting this to a car battery and a
motor which draws 4.5 amps. Is there any worry about arching
on the board? Should it be cooled as well as heat sinked?

Thank you much

Charles
Posted by:
User avatar
ikalogic

on: 13 Jun 2008
Re: 5A H-Bridge motor controllers
['Quote ]

Quoting blrmkr: Thank you for the tuitorial!! I have a question about R1 and R9. They seem to be marked as 3k8. What is a 3k8 resistor? Or am I just reading the schematic wrong? Thank you very much for your help.


3k8 means 3.8 KOhm
exactly like 3M8 would mean 3.8 mega ohms, or also 3800 Kohm or ahain 3 800 000 ohm! :)

you can see it this way: The prfix"k" or "M" is used also as a decimal point, to simplify the reading. This a convention that you'll find everywhere :)
Posted by:
blrmkr
on: 13 Jun 2008
5A H-Bridge motor controllers
['Quote ]
Thank you for the tuitorial!! I have a question about R1 and R9. They seem to be marked as 3k8. What is a 3k8 resistor? Or am I just reading the schematic wrong? Thank you very much for your help.
Posted by:
User avatar
ikalogic

on: 10 May 2008
Re: 5A H-Bridge motor controllers
['Quote ]

Quoting HeX0R:
HI i dont remember the motor info, i need to talk with my friend.
But i know that eche motor need 65 Amper...


well.. 65Amps >>>> 5 Amps!

This H-bridge is not for your application..

However.. 65Amps seems huuuuuuge...!!! are you sure about that?
You have to be a member to post replies.
Username: Remember me
Register now! it only takes an instant.
Forgot your password?
ikalogic.com: Electronics and Robotics related projects.
All content on this site is provided as is and without any guarantee of any kind. We cannot be held responsible for any errors, omissions, or damages arising out of use of information available on this web site.
Creative Commons License
IMPORTANT COPYRIGHT NOTE: Electronics and Robotics Articles by Ibrahim KAMAL are licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.