Build a 5A H-bridge Motor driver! Old version

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:

  • To build a small module, that can be added to any robot or any system where motor control is required.
  • 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.


The H-bridge & DC Motors.

The H-bridge is principally a configuration of four 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”.

figure 1

Below figure 1, 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 two possible paths for the current:

  • The red path, where the the current is directed to the motor through the switches S3 and S2, causing the motor to turn clockwise
  • 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.

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

figure 2

This schematic figure 2, 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, two transistors are connected to 12V, while the two 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 value of Ibmax. 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 datasheet.
  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/IOr, Rb = ((5-Vbe)/Ib)
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 four main sections, each one shaded with a different color.

  • The Protection And Logic circuit, shaded in light yellow.
  • The H-bridge, composed of the 2 TIP122 and 2 TIP127 Transistors, shaded in light red.
  • The Fan connections and the ‘Power on’ LED in light blue.

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 four transistors at the same time (this would cause a terrible short circuit, destructing at least one or two 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 four transistors.

Each one of the four end transistor of this stage (Q1, Q2, Q3 and Q4) have the function of inverting the signal and performing voltage and 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 four 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 (figure 3), the three inputs to the gates (P1,P2 and P3) and their relation with the outputs of four end transistors in the yellow area (Q1,Q2,Q3 and Q4).

figure 3

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 four TIP transistors.

  • The H-bridge, composed of the 4 TIP Transistors:

TIP122/TIP127 are power transistors, each one composed of two 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.

Download TIP122 datasheet / Download TIP127 datasheet

  • 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 two boards. One of them is the PCB which will hold the control circuit with the four TIP transistors (figure 4.A).

The other is a heat sink board (figure 4.B). Actually its a PCB on which I’ve printed two 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 two 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 two transistors (TIP122 & TIP127) have to be electrically isolated from the other two transistors.

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

figure 4.A

figure 4.B

The assembly

After the PCB is ready and all components are soldered, plug the FAN+Heat sink+Transistors in the main board (figure 5.A). 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.

figure 5.A

figure 5.B

Now you’re done with the construction of the H-bridge module (figure 5.8), 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!


Note: I use ExpressPCB(FREEWARE) to design the schematics and the PCB

Comments ( 3 )

  • Cool Cap Engineer says:

    This was very well done. Initally when I read that you used Bipolar transistors for the switches I cringe a little but when I found out you were using the TIP122/127, I was relieved. Have you thought about adding a speed controller to the next version?

    • Ibrahim KAMAL says:

      Adding a speed controller..? well, i usually leave that open to be adapted for each system, depending on its specifics.. :)

  • Dika says:

    I have built this circuit using two separated PCBs and connect them using a ribbon cable. One PCB for the yellow-shaded part and the other one for the TIP transistor. I can’t find the 3K8 resistor in Indonesia so I decided to use 3K9 resistor for R1, R7, R9 and R12. I used 1N3819 for D2-D5. I used a 12 Volts supply and a MC7805CT to feed the U1 from that main 12 Volts supply.

    I have checked all the connections three times and nothing wrong. But it resulted on a perfect short circuit under no-load condition (no motor connected to J5). Fortunately my bench PSU has a short-circuit protection.

    Then I removed the cable from the yellow-shaded part to the red-shaded part and apply 5V to P1 & P3 and apply 0V to P2. And then I measured the voltage at the collector of Q1-Q4 using Fluke 87-III Multimeter. The voltage at Q1 & Q2 collector was 0.19 V and at Q3 & Q4 collector was 11.87 V. I deduced that the logic circuit has worked correctly and the problem is about incorrect bias to all TIP.

    Do you have any solution ? And what’s your multimeter said about the voltage at Q1-Q4 collector ?

    Thank You

Leave A Comment

Your email address will not be published. Required fields are marked *