Username:    Password: Remember me
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:
User avatar
ikalogic

on: 01 Mar 2010
Re: 5A H-Bridge motor controllers
['Quote ]

Quoting Poncho Magilakutti: Please tell me the use of Q 1-4 (the 2n2222 switching transistor). If you used all TIP 122's, you could eliminate these. Currently, the way this is set up, Q6 and Q8 are always on, unless you switch on Q2 or Q4. Personally, I don't see the problem of controlling the FETs directly with the logic gates, unless your FETs need over 5 volts to turn on. Tip 122 and 127 only need about 1.5 volts to turn on though, so what's the logic in doing this for this specific circuit?


The logic (not that big) is that if you look at the datasheets of TIPs, you will see they not only need voltage, but also current. the 2n2222 transistor are here to increase current to the base of the TIP.

Oh, i just re-read your post, i see where u are confused : TIP are not FET, they are Darlington pair BJTs. I guess that answers ur question
Posted by:
poncho magilakutti
on: 01 Mar 2010
5A H-Bridge motor controllers
['Quote ]
Please tell me the use of Q 1-4 (the 2n2222 switching transistor). If you used all TIP 122's, you could eliminate these. Currently, the way this is set up, Q6 and Q8 are always on, unless you switch on Q2 or Q4. Personally, I don't see the problem of controlling the FETs directly with the logic gates, unless your FETs need over 5 volts to turn on. Tip 122 and 127 only need about 1.5 volts to turn on though, so what's the logic in doing this for this specific circuit?
Posted by:
keiv.k
on: 17 Feb 2010
5A H-Bridge motor controllers
['Quote ]
Need Help!

Im using PIC18F452 as the 'brain' and H-bridge to control my POWER WINDOW MOTOR.
The problem is that when i tried to feed a 50% duty cycle(or below 50%), the motor couldnt run. However, it ran at 60%(and above) duty cycle. What is happening? I want the motor speed at 50% or below duty cycle. Can anyone here gives me some opinions?

Just in case, my email is akira_wind@hotmail.com
Posted by:
dongskie
on: 01 Jan 2010
5A H-Bridge motor controllers
['Quote ]
Greetings from Manila!

Hi everyone! I have been in search of this external H-Bridge (thank you to the author!) that can be controlled by an extracted pwm signal from a modified servo circuit: http://www.fieroaddiction.com/servo.html

I now would like to ask the author of this H-Bridge as to how I can connect the modified servo circuit into your H-bridge. (the idea is to install a small servo circuit to a larger motor that has an independent H-bridge, so that the two circuit system will work as one servo system).

May I please request a PCB drawing in .jpg? I can't open th e.pcb format please email at dongskie2@hotmail.com

Thank you very much!

Ed
Posted by:
ahmed ali
on: 06 Dec 2009
5A H-Bridge motor controllers
['Quote ]
I need help please,
I dont know how to calculate the resistances for the whole circuit so please anyone could send me a full calculations for a 10A H-bridge using transistors as drivers.
Posted by:
dito_zero
on: 03 Dec 2009
5A H-Bridge motor controllers
['Quote ]
nice
Posted by:
tunedynamic
on: 21 Nov 2009
Re: 5A H-Bridge motor controllers
['Quote ]

Quoting mustikahati: can i change tip 132 and 133 with MOSFET

Absolutely yes~but the driver stage & dead-time generation circuit will be necessary for POWER MOSFET...
Posted by:
tunedynamic
on: 18 Nov 2009
5A H-Bridge motor controllers
['Quote ]
emmm~Great~&#65281; i think MOSFET will be more efficient.
Posted by:
nickyhs
on: 27 Oct 2009
Re: 5A H-Bridge motor controllers
['Quote ]
Hi... could u please tell me what is the model of diode that are used?thanks!
Posted by:
lother
on: 20 Oct 2009
5A H-Bridge motor controllers
['Quote ]
thnx for putting details but what is the number of a 4 amp diodes i haven't found them
Posted by:
mustikahati
on: 28 Jul 2009
5A H-Bridge motor controllers
['Quote ]
can i change tip 132 and 133 with MOSFET
Posted by:
silverzed
on: 27 Jul 2009
5A H-Bridge motor controllers
['Quote ]
I just have a question regarding the above cct. I have constructed the cct and I can get the motor to turn one way but it will not turn the other way.

When I measure the voltage across the motor connections without any load I get 12V when it's working and -0.20 Volts when it's not.

I'm using TIP 42C and TIP 41C as the switching transistors and the other transistors consists of BC548 and BC557 all resistors used are the same values described in the cct.

I have checked voltages from the chip and they all appear to be correct....

if you could shed some light on to where the problem might be that would be awesome.
Posted by:
kurdtanshori
on: 22 Jul 2009
5A H-Bridge motor controllers
['Quote ]
@ ronv : I wanna try your schematic..Can U give me Ur schematic in PCB ??thanks... :oops: :oops:
Posted by:
indiangujarati
on: 03 Jul 2009
HALF STEPPER MOTOR DRIVER
['Quote ]
PLEASE GIVE ME CIRCUIT DIAGRAM PCB LAYOUT & HEX CODE OF 3 AXIS HALF STEP STEPPER MOTOR CONTROLER USING 89S52
Posted by:
daswansinator
on: 18 Jun 2009
Re: 5A H-Bridge motor controllers
['Quote ]

Quoting ronv: Andy,
Attached is a schematic of a 12v 30 amp bridge. I am going to build a few for ebay in the next couple of weeks so it hasn't been tested yet.

Ron V.

Did you have any success with your 30 amp bridge? I think I might give it a try. I have some 12V motors with a free spin current of 2.3 amps and a stall current of 115 amps. I don't think the little 2 or 5 amp controllers would hold up to well, but 30 amps might get me proof of concept for the application.

Thanks for the great insight,

Rob
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.