Username:    Password: Remember me
Follow us:
Build a 5A H-bridge motor driver
By Ibrahim Kamal
Last update: 6/6/08


This H-bridge is easy to build, without any critical components. It is based on the famous and cheap TIP122 and TIP127 power transistors. It have been used on many of our robots and proved to be very versatile and robust.

Another major advantage is that it only needs 4 wires for 12V power supply and direction control. Nevertheless, it allows bidirectional control, breaking and freewheeling.

1.The hardware
The schematic can seem a little complicated at the first sight, but, practically, it only consists of 2 logic ICs and a bunch of transistors.

figure 1.a

Q1, Q2, Q3 and Q4 are 2N2222 BJT. They can be replaced with any generic switching transistor.

Resistors R2, R4, R5 and R10 have to be 1 WATT rated, to support high currents, especially if a 24V power supply is used.

The wire connection W1 to W4 are the wires between this H-bridge module and the controller board that provides the 12/24V power supply and the logic signals for direction control.

The wire connection W3 can be connected to a power source from 10V to 24V, without circuit modifications.

The wire connection W1 and W2 are for connecting the H-bridge to a microcontroller or another logic device allowing the control of the motor. A truth table is given below showing the effect of every combination of the logic states of W1 and W2:


Inputs
Result on the connected motor
W1
W2
0
0
Motor is freewheeling (disconnected, High impendence)
0
1
Turn the motor clockwise
1
0
Turn the motor anti-clockwise
1
1
breaking the motor
*(X mean Don't care), 1 = Logic high Voltage (5V), 0 = Logic low voltage (0V).

Diodes D2 to D4 are simple rectifier diodes, with forward current ratings of at least 4A.

LED D1 is only used to signal the presence of power in the circuit.

The whole is assembled in a 5cm X 5cm PCB like in the picture below (figure 1.b). The length of the cable is not critical, it can be up to 1 meter, assuming you're PWM frequency is below 50 KHz. Heatsinks can be added to protect the TIP transistors from overheating. Be careful, the metallic back of the TIP is internally connected the collector, so be careful not to cause short circuits.

Actually, as you can see in figure 1.b, each pair of TIP122 and TIP127 share the same heatsink, without any risk of short circuits, since their collectors are already connected together in the circuit (If the schematic in figure 1.a, Q5 and Q6 have their collector connected together, as well as Q7 and Q8).

figure 1.b


2. Associated motor control algorithm
Here are some example C source codes showing how to control a motor using this H-bridge. The source codes are written for 8051 micro controller under the KEIL IDE, but can be easily modified for any other kind of microcontrollers or compiler.

This first example shows a function that control the direction/state of the motor, without speed variation.
#define w1 P1_0
#define w2 P1_1
#define motor_free 0
#define motor_break 1
#define motor_clockwise 2
#define motor_anti_clockwise 3

drive_motor(state){
   if (state == motor_free){
      w1 = 0;
      w2 = 0;
   }else if(state == motor_break){
      w1 = 1;
      w2 = 1;
   }else if(state == motor_clockwise){
      w1 = 1;
      w2 = 0;
   }else if(state == motor_anti_clockwise){
      w1 = 0;
      w2 = 1;
   }
}


The above function can then be called anytime in your program to change the state of the motor as in the example below:

drive_motor(motor_clockwise); //turn clockwise


The same function can be used in a more complicated code that controls the speed (or breaking torque) of a motor via PWM signals (for more information about PWM signals and speed control, check this article). The following example shows how to use this h-bridge with speed variations via PWM:

//global variables
unsigned char pwm_counter;
//used to count from 0 to max_pwm
unsigned char max_pwm = 100;
//this controls the period of one complete cycle
unsigned char pwm = 50;
//this controls the duty cycle.

void main(){
    while(1){
        pwm_counter++
        if (pwm_counter > max_pwm){ pwm_counter = 0; }
        if (pwm_counter < pwm){
//ON cycle
              drive_motor(motor_clockwise);
//turn clockwise
        }else{
//OFF cycle
              drive_motor(motor_free);
//motor freewheeling
        }
    }
}


The above example drives a motor with a 50% duty cycle PWM signal. It can be integrated in any program without causing any delays or disturbance the other functions.

You can download the PCB and the schematic for that h-bridge though the link below:

Download the zip file for the project.
Containing the full schematic and the PCB designs.
[note: i use ExpressPCB(FREEWARE) to design the schematics and the PCB]



I hope this article was useful. Any comments and further questions are welcome in the forum below.

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:
salih_arel
on: 01 Feb 2012
5A H-Bridge motor controllers
['Quote ]
Hello

I wanna make h-bridge motor driver. I will just use H- Bridge motor driver in this circuit. Is it enought for me?? :))
Posted by:
wes_leigh
on: 31 Jan 2012
5A H-Bridge motor controllers
['Quote ]
I'm trying to download the files, but it seems to be corrupted ): . Can you please update the files?
Posted by:
kennyquintens
on: 30 Jan 2012
5A H-Bridge motor controllers
['Quote ]
I've some big issue with this schematic.
When i try to make this it wouldn't work properly.
I have tried the parts apart and then it works good, but togeter it gives some big problem.
My TIP127 becomes very hot. I think some short circuit, but can't figure it out.
I have at two of the four endings of the ic's 1V and at the other two 2V is this normal, can somebody give me the correct values of this? At the four outputs of the 7400 and the 7402.

thanks,
Kenny.
Posted by:
ze.gmonteiro
on: 29 Jan 2012
5A H-Bridge motor controllers
['Quote ]
I'm trying to download the files, but it seems to be corrupted or something like that. Can you update de files?
Posted by:
yawstick
on: 08 Nov 2011
5A H-Bridge motor controllers
['Quote ]
I've tried to download your zip file and getting errors when I try to open it... seems to be corrupted... nice article otherwise.
Posted by:
junior
on: 22 Apr 2011
Re: 5A H-Bridge motor controllers
['Quote ]
ok thanks :D
Posted by:
User avatar
ikalogic

on: 22 Apr 2011
Re: 5A H-Bridge motor controllers
['Quote ]

Quoting Junior: Hi I'm new in this so i would you ask that the names of the diodes are need for 5A H-Bridge motor controllers and can that works without diodes.
Thanks !



there MUST be diodes!

any rectifier diodes will do just fine, (but they should have a forward current of 5 to 10 A :)
Posted by:
junior
on: 22 Apr 2011
Re: 5A H-Bridge motor controllers
['Quote ]
Hi I'm new in this so i would you ask that the names of the diodes are need for 5A H-Bridge motor controllers and can that works without diodes.
Thanks !
Posted by:
gojko_sisa
on: 16 Apr 2011
Re: 5A H-Bridge motor controllers
['Quote ]
Salam,

I am currently building a Line following robot, and I want to use this H-bridge for the engine control. I have downloaded this PCB schematic, but I I can't figure out what are the inputs P3, P4, P5 for??
I have already found what you previously said on this forum:

[/quote]
P4 = 12V / 24V
P5 = 5V
P6 = Ground
[/quote]

Studying this schematic; however, I have found a few issues. In my opinion this inputs should be connected in this way:

P1 - pin 1
P2- pin 4
P3- (+12v)
P4-GND
P5-PWM input
P6-(+5v)
p7-(+FAN)
P8-(-FAN)

Can you double-check yours schematic ?
Thnx
Posted by:
wesleyross
on: 14 Apr 2011
Re: 5A H-Bridge motor controllers
['Quote ]
I plan to use your circuit to move a 100lb sliding steel door. No micro or pwm. Just 24v. My only concern is driving the TIP's. You mentioned in previous posts, you used 10-25 VDC. Do you see any problem keeping all resistors the same, but using 24vDC? Thanks to all for their insight and knowledge. Schematic attached.
Posted by:
onibnasir
on: 21 Feb 2011
Re: 5A H-Bridge motor controllers
['Quote ]

Quoting onibnasir: I made the circuit on breadboard but it is not working. I want to ask one thing. We have to take the output from the collector terminals of the TIP transistors? Please respond quickly



i don't understand the question?

also, you say it's not working, what is the problem exactly?


The problem is that the potential difference that I am getting at the collector is 0.5 to 0.6 V ....
Posted by:
onibnasir
on: 20 Feb 2011
5A H-Bridge motor controllers
['Quote ]
I made the circuit on breadboard but it is not working. I want to ask one thing. We have to take the output from the collector terminals of the TIP transistors? Please respond quickly



i don't understand the question?

also, you say it's not working, what is the problem exactly?
Posted by:
kenny6
on: 23 Jan 2011
5A H-Bridge motor controllers
['Quote ]
I have built a h bridge with these tip transistors and controlling them through an Ardunio and i have biased the bases with 330 ohm resistors.This works ok on 6 volts but i cant work out why when i try to run it on 12 volts the transistors start to fry bad immediatly.Yet when i try to biase the bases with 1000 ohm resistors the thing wont even turn on,yet i think the qs get very hot still.I have tied bases together on each side.I am using small mabuchi motors.
Im aware that motors resistance influences collector current
I have calculated that the ideal resistor i should use is about 2000 ohms.if the motors resistance is about 10 ohms.mabuchi motors at 6 volts divides by full load current gives around this value for motor resistance.(6/.560).
My questions are.
What motors are you running on your bridge.?
Any sugestions to make improvements thanks
back again .I am now using motors by solarbotics and have much better results.I believe these motors draw less current than the Mabuchis.I have a couple of ideas to tinker with when i get time.
Posted by:
karookann
on: 09 Jan 2011
Re: 5A H-Bridge motor controllers
['Quote ]
8) Now I completely know the purpose of each component, thanks you very much.
Posted by:
User avatar
ikalogic

on: 05 Jan 2011
Re: 5A H-Bridge motor controllers
['Quote ]

Quoting karookann: I am still thinking of eliminating these two ICs by appropriate code in my MC, as I have plenty of i/o pins available and enough room for code too. So I would like to have your opinion in this regard.
Furthermore I want to know the purpose of transisters Q1-Q4. I suspect these are for power or voltage issues but I want your expert opinion. :wink:


Hello,

Sure, if you have spare I/O pins, then you can get rid of those ICs.

The transistors Q1 to Q4 are very important, because they provide high enough base current for the TIP transistors. the I/O from logic gates or from the µC do not give enough current.
You have to be a member to post replies.
Username: Remember me
Register now! it only takes an instant.
Forgot your password?


Unless mentioned, all content is written and designed by Ibrahim Kamal, copying is prohibited and unethical
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.