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.
Preview of the last 15
messages discussing this page. Messages are sorted from the newest to
the oldest. |
Posted
by:
ikalogic
on:
04 Sep 2008 |
Re: I want to have my DIY CNC controller |
|
 |
| 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:
williamkmcn
on:
10 Aug 2008 |
I want to have my DIY CNC controller |
|
 |
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 |
|
|
Posted
by:
ikalogic
on:
12 Jul 2008 |
Re: 5A H-Bridge motor controllers |
|
 |
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 ??  |
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 |
|
 |
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 ??
|
|
|
|
Posted
by:
ikalogic
on:
11 Jul 2008 |
Re: 5A H-Bridge motor controllers |
|
 |
Quoting kemo0o: it isn' the 5th TIP
It is Regulator ( LM 7805 ) 
About The components , It is shown in the schematic just count them  |
kemo did you make any of those H-B on your own? can you share some pics?
|
|
|
|
Posted
by:
kemo0o
on:
11 Jul 2008 |
|
|
Posted
by:
irongoat
on:
11 Jul 2008 |
5A H-Bridge motor controllers |
|
 |
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 |
|
 |
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:
ikalogic
on:
03 Jul 2008 |
Re: 5A H-Bridge motor controllers |
|
 |
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 |
|
 |
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:
ikalogic
on:
13 Jun 2008 |
Re: 5A H-Bridge motor controllers |
|
 |
| 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 |
|
 |
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:
ikalogic
on:
10 May 2008 |
Re: 5A H-Bridge motor controllers |
|
 |
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. |
|
|
|