Introduction: H-Bridge on a Breadboard
The H-Bridge is a circuit which can drive a motor in forward and reverse. It can be a very simple circuit that requires only a handful of components to build. This Instructable demonstrates how to breadboard a basic H-Bridge. Upon completion you should be familiar with the basic operation of an H-Bridge and be ready to move on to more complicated versions that can support larger, more powerful motors.
Step 1: Gathering the Parts
Only a handful of parts are needed.
1) A bread board
2) A small DC motor capable of operating at ~7 volts
3) A 9-volt battery and battery snap
4) Four small signal NPN transistors. We're using the 2N2222A here. 2N3904 is another common part number and thousands of others will do.
5) Four 22k ohm resitors
6) Two push button switches
7) Jumpers or spare wire to hook everything up
Step 2: H-Bridge Theory
The H-Bridge is a circuit which can drive a DC motor in forward and reverse. The motor direction is changed by switching the polarity of the voltage in order to turn the motor one way or the other. This is easily demonstrated by applying a 9-volt battery to the leads of a small motor and then switching the terminals to change directions. The H-Bridge is given it's name based on the basic circuit which demonstrates it's operation.
The circuit consists of four switches which complete the circuit when applied in pairs. When switches S1 and S4 are closed the motor gets power and spins. When S2 and S3 are closed the motor gets power and spins in the other direction. Note that S1 and S2 or S3 and S4 should never be closed together in order to avoid a short circuit.
Obviously physical switches are impractical since no one is going sit there flipping switches in pairs to get their robot to move forward or in reverse. That's where the transistors comes in.
A transistor acts as a solid state switch that closes when a small current is applied to it's base. Because only a small current is required to activate a transistor we are able to complete one half of the circuit with a single signal.
That's enough theory to get started so let's start building.
Step 3: Powering the H-Bridge
We'll start by laying out the power lines. Connect your battery snap to one corner of the power bus. The convention is to connect the positive voltage to the upper row and the negative to the bottom row to denote the HIGH and LOW signals respectively. We then connect the top and bottom sets of power buses.
Step 4: The Transistor As a Switch
The next step is to set up the transistors. Recall in the theory section that we need four switches to build an H-Bridge, so we'll be using all four transistors here. We're also limited to the layout of a breadboard so the actual circuit will not resemble the letter H.
Let's take a quick look at a transistor to understand the current flow. There are three legs on each transistor known as the collector, base, and emitter. Not all transistors share the same order so be sure to consult a datasheet if you're not using one of the part numbers mentioned in step one.
When a small current is applied to the base, another larger current is allowed to flow from collector to emitter. That's important so I'll say it again. A transistor allows a small current to control a larger current. In this case the emitter should always be connected to ground. Note that the current flow is represented by a small arrow in the figure below.
Step 5: Switching Polarities
Now we're going to line up the transistors on the bottom half of the breadboard, flipping the orientation for every other transistor. Each pair of adjacent transistors will serve as one half of the H-Bridge. An adequate space needs to be left in the middle in order to fit some jumpers and eventually the motor leads.
Next we'll connect the transistors' collector and emitter to the positive and negative power buses respectively. Lastly we'll add the jumpers which will connect to the motor leads.
The transistors are now ready to pass a current when the base is activated.
Step 6: Applying a Signal
We need to apply a small current to each of the transistors in pairs. First we need to hook up a resistor to each transistor's base.
Next we'll connect each set of resistors to a common point in preparation to connect a switch.
Then we'll add the two switches which also connect to the positive bus. These switches will activate one half of the H-Bridge at a time.
And finally we hook up the motor. That's it. Connect your battery and test your circuit. The motor should spin one direction when one button is pushed and the opposite direction when the other button is pushed. The two buttons should not be activated at the same time.
Step 7: Getting a Clear Picture
Here's a diagram of the complete circuit in case you want to save it for reference. The original graphics are courtesy of Oomlout.
Step 8: More Power to Ya
Okay, so you have a shiny new H-Bridge on a breadboard. Now what? The important thing is that you understand how a basic H-Bridge works and that the essentials are the same no matter how much power you're pushing. Here are a few tips to take it a step further in order to support larger motors and more power.
- You can use Pulse Width Modulation (PWM) in place of the two switches to control the speed of the motor. This is easy when you have a microcontroller at your disposal and can also be accomplished with a 555 or 556 timer IC and a few passives without too much trouble.
- The key to supporting higher power motors is higher power transistors. Medium power transistors and Power MOSFETs in TO-220 cases can handle significantly more power than the low power TO-92 transistors we're using here. Proper heatsinks will also increase the capacity.
- Most H-Bridges are built using both NPN and PNP transistors in order to prevent short circuits and optimize current flow. We used only NPN here to simplify the circuit.
- Flyback diodes are usually used in higher power H-Bridges to protect the rest of the circuit from dangerous voltages that are produced by the motor's coils when the power is disconected. These diodes are applied across the transistor in the direction of current flow and resist these harmful EMF back voltages.
- The TIP 102 and TIP 107 are a pair of complementary power transistors that have built in flyback diodes. The TIP 122/127 and 142/147 are similar pairs of power transistors.
That should be enough to put you in the right direction if you want to keep you going.