Bipolar Junction Transistor Theory
Transistors are current controlled solid-state
devices that conduct current in proportion to an input current. The symbol
for a transistor is shown in figure 1. The transistor on the left is called
an "NPN" transistor and the transistor on the right is called a PNP
transistor.
Figure 1) NPN and PNP Transistor Schematic Symbols
For an NPN transistor, current flowing "into"
the base leg
of the transistor results in a proportionally larger current to
flow between the collector and the emitter. Conversely the current flowing
"out" of the base of a PNP transistor allows a proportional current to flow
between the emitter and the collector. This is shown in figure 2.
Figure 2) NPN and PNP Transistor Current Flow
The current between the
base and the
emitter is labeled I
be,
and the current between the
collector and the
emitter is I
ce. The
relationship between that currents is called the gain (or sometimes the
Beta) of the transistor and it is labeled H
fe on the
spec sheet.
You'll notice something if you look closely at the current flows, they are
reversed depending on the transistor type. So while the current I
ce in an NPN transistor is positive, the current flows from the emitter to the
collector in a PNP transistor so its I
ce is written as a negative current.
Similarly, I
be on the NPN is positive and I
be on the PNP is negative. This
relationship becomes important when we use them to build a bridge.
The current proportion is H
fe, but the
transistor doesn't actually generate current, what it does is "resist
current less."
What this means is that no current is flowing in the base, the transistor
will resist all attempts to get current flowing between the collector and
emitter. As the current in the base increases, that current multiplied by H
fe is allowed to flow between the collector and emitter,
assuming such a
current could flow.
The last bit is what confuses a number of
people. Let's say you have a 9V battery connected to a 100
ohm resistor and
then connected to and NPN transistor and finally to ground. Let's further
assume that the beta (H
fe) of the transistor is 250. This is shown below in
figure 3.
Figure 3) A simple circuit with a 9V battery and a resistor
What is the maximum current that
can flow
through the transistor? If we replace the transistor with a piece of wire,
then using Ohm's law we can calculate the current flow to be 9/100 or .09
Amps (90 mA).
Now when the current is present, if it has a
current of 2mA flowing into the base the maximum current the transistor will
conduct is 2mA * H
fe, substituting in 250 for H
fe
gives us 2 mA * 250 for a total of 500 mA.
And yet we know that if the transistor was a
wire the most we would see is 90mA. So the actual answer is this "The amount
of current that flows through the transistor is the lesser of the available
current and I
be*H
fe."
Generally if you apply enough base current that the maximum current
possible will always flow, then the transistor is operating like a switch (rather
than
operating like an amplifier). In this mode, the transistor is
said to
be
saturated.
One more thing and then we'll be done with the
theory and into the practice. A BJT transistor will cause a drop in voltage
between the collector and the emitter even when it is saturated (it isn't a
perfect conductor). This voltage drop is called out in the data sheet as V
ce(sat). Typically, this will be
between .2 and 1 volts for
silicon transistors.
That means in an H-bridge configuration, if the top transistor has a .7v
drop and the bottom transistor has a .7 volt drop, there will be a 1.4 volt
drop in total. If you are using a 6v
power supply, that will leave 4.5 volts
for the motors. Ever wonder why a lot of toys use 4.5 volt motors? That's
one reason! With a transistor H-bridge being driven by four batteries,
the motors "see" 4.5 volts. What that means in our example
above, is that if the transistor has a saturation voltage of .7 the max
current that will flow when it is fully switched on it (9 - .7)/100 or 83mA.
There is also a voltage drop across the
base-emitter junction. This is called out as V
be in the data
sheets. When you are calculating the current that will flow in the base, you
must subtract this value from the total voltage drop before you compute the
resistor value. For most (all?) silicon transistors this value is .7 volts.
The V
ce(sat) voltage drop is also the source of power
dissipation in the transistor. If you recall the formula for power is P = I
* E, where I is current and E is voltage and the power is expressed in
Watts. So given that the transistor has a saturation voltage between the
collector and emitter of .7 volts,
and you are conducting 3 amps through that transistor, this means the
transistor is dissipating .7 * 3 or 2.1 watts. That is about the maximum a
TO-220 case can dissipate before you have to put a
heat sink on it. Keep
that in mind when you are building h-bridges.
Picking the Right Transistors
Strangely enough picking the correct
transistor for the job can sometimes be the most challenging. A number of
factors affect the choice, operating voltage, current, cost, etc. and all of
those effect each other in often unpredictable ways. If you imagine that
each choice is an axis in some multi-axis space, the volume the choices
encompass is called the "design space." Since we're building an H-bridge,
not a nuclear reactor, we can be a bit loose with our design constraints.
Pretty arbitrarily I've chosen to design an
H-bridge that lets you control motors that take a DC voltage between 3 and
24 volts, and when stalled do not consume more than 5 or 6 amps of current.
So that is motors that consume somewhere between 15 and 150 watts of power.
The good news is that there are literally thousands of motors in this
category. They are often found in radio controlled toys you might buy on
clearance or at a garage sale, and a number of places like Jameco,
Scientifics Online, and others sell them as well.
The canonical example motor is the
Mabuchi RC-280SA. This motor
typically runs at .75 - 1.5 A and stalls at under 7 amps. It provides good
torque when geared down and is found in a variety of toys and models. This
motor is "too big" for the single chip H-bridges like the
SN754410 and L293D.
Factors to Consider
The two major factors that control this design
are current capacity and cost. I wanted to have a design that was
inexpensive to
build but controlled a wide variety of easily accessible motors.
There are H-bridge chips that control 3 to 6A
but those are generally expensive and you don't learn much by soldering them
on to a board :-). So, low cost was key but so was capability.
Transistor Packages and Heat
As we learned in the theory pages, one of the
limiting factors on transistors is how much heat they can dissipate before
the silicon inside them melts. There are "high power" packages such as
the TO-3 and "low power" packages such as the TO-92, the "midrange power"
package is the TO-220. The TO-220 doesn't take up as much volume as the TO-3
but can dissipate over twice the power of the TO-92 without a heatsink and it
is easy to add a heatsink for more power capacity.
Forward Breakdown Voltage
Transistors are like any semiconductor, when
the voltage across them gets too large the silicon can't resist the flow of
current any longer and they go into "avalanche" mode. Not pretty and it
usually results in the destruction of the device. Unlike FETs, most BJTs have
plenty of headroom here. I've picked a couple that can do 100V. So if you
decided you really had to use 90V DC motors you could. Note however that the
design that is discussed later in this series is not designed to work with
high voltage motors.
Hfe and Drive Current
Finally, transistors are current driven
devices. What that means to this design is that for a given output current
of say 5 amps, and the ability of a microprocessor pin to source at most 20
milliamps (less required is better), the H
fe of our transistors must be
high.
Alternatively we can use a transistor to drive
a transistor. This was pretty common in the early days when the H
fe spec for
a power transistor was 40. (Given an H
fe of 40, a 5A
collector current
requires 125 mA of drive!) Fortunately for us, there are power
darlington transistors that incorporate the base drive transistor in the
same package as the power transistor. Sort of a 3 pin, two
transistor
integrated circuit. This configuration is called a Darlington
configuration
after its inventor.
The TIP102 and TIP107
Given all of the constraints, the best choice
for this project was the
TIP102 and
TIP107 power transistors. These
transistors are packaged in the TO-220 package which can dissipate 2W
without a heat sink. The transistors have a breakdown voltage of 100V (which
easily covers our 3 - 24V requirement). Finally, because they are internally
a darlington pair, they have extraordinarily high H
fe values (as high as
20,000). Finally, they are pretty darn cheap at less than $1 each
in single quantities from a number of places.
These transistors
are sold as a "complimentary pair" which means they are designed to be used
together and many of their characteristics such as voltage drop, current
gain, and breakdown voltage are identical. That further simplifies their use
as the switching element in the BJT H-bridge.
As an added bonus the folks who make these
transistors include a freewheel diode in the package. That can make driving
inductive loads such as motors with them simpler still. But before we talk
about that, lets talk about implementing an H-bridge with the TIP102 and
TIP107 transistors.
Building the Corners
Now that we have the transistors picked out,
we look at implementing an H-bridge using them. Because these transistors
are a complementary pair, the circuit using them is very symmetrical.
The
upper right and upper left corners of the H-bridge are called "sources."
This name originates from their function which is to be a source of current
for the load (in our case the motor). Referring to the schematic on the
right, you can see that there is a 10K resistor between the base of the
TIP107 and the positive terminal of the battery. This is a pull-up resistor
that insures that the transistor is "off" (or not sourcing any current) when
the switch is open. The 1K resistor that is connected in series with the
switch is used to limit the current coming out of the base when the base is
grounded by the switch. So in this case when the switch is closed, the
emitter-base junction becomes forward biased and current flows "out" through
the base. If the battery is 12V and the voltage drop of the Base-Emitter
junction is .7V, then the current flow in the base will be -11.3mA (negative
because it is
flowing "out"). Given the H
fe specs for this transistor, this level of base
current will completely turn "on" this transistor allowing the load to
consume as much current as it needs.
Conversely,
the schematic on the left is called a "sink." Its name is derived from this
circuit's function which is to provide a place for current to go once it has
passed through the load.
The lower left and lower right corners of the
H-bridge are implemented as sink circuits. In the sink circuit the 10K resistor connects the
base of the transistor to ground, which forces the transistor off when the
switch is open. When the switch is closed, current is injected into the base
through the now forward biased base-emitter junction. Again the amount of
current is nearly identical to the source configuration so an equal amount
of current is allowed to flow through the load.
Of course if we have to throw switches to turn
these transistors on it doesn't make for a very useful H-bridge. In order to
drive this H-bridge from a microprocessor we need to put the microprocessor
pins in control.
In the sink circuit, the transistor stays
turned off if the base is grounded, it turns on when current flows through
the 1K resistor and into the base. A typical microprocessor's output pin can
generally put out either 3.3V or 5V as a logic "true" output. Given that we
need only approximately 5 mA to turn the transistor fully on, you could compute the
necessary base resistor by subtracting the base-emitter voltage drop (.7V)
from the logic high voltage (3.3 or 5) and then dividing by the desired base
current (5 mA) to get
the appropriate resistor (660 or 1K ohms respectively). The source circuit is
another problem entirely and an area I call "the high side problem."
Turning
on the source is easily accomplished by grounding the 1K resistor, however
turning it
off requires bringing the 1K resistor up to the motor
voltage. You could tri-state the output and let the 10K resistor bring it up to the motor voltage.
However, if you did, you're microprocessor
pin might be exposed to a voltage that is was not designed to handle. A
solution for this problem is to add
another transistor to the high
side which is a sink circuit to turn on the source circuit!
In the schematic you can see that I added a
2N3904 NPN type transistor which
replaces the switch in the original schematic. This works because the
microprocessor only need turn on the 2N3904 (which is referenced to ground),
then that pulls the base of the source transistor to ground through its 1K
resistor which turns on the source transistor and current then flows into
the load. But as you need to add two transistors anyway to control the two
upper corners of the bridge, there is an even better way to go.
The
picture on the left is the schematic representation of an opto-isolator. An
opto-isolator is an LED and a photo-transistor packaged into a single 4 lead
package. You can get four opto-isolators in a single IC
DIP using the NEC
PS2504-4. When
current flows in the LED the photons it emits illuminate the base of the
photo-transistor. This causes the photo-transistor to turn on and begin
conducting current. The photo-transistor is completely electrically isolated
from the LED so the voltage on the phototransistor has nothing to do with
voltage on the LED. This isolation brings with it two benefits and one
drawback.
The major benefit is that the photo-transistor
can used in place of the switches in our sink and source circuits. This
means that the microprocessor sees four LEDs to light up, but what they
really do is activate the circuits in the bridge. The second benefit is that
the motor power supply with all of the switching noise is completely
isolated from the power supply that is powering the microprocessor.
The drawback is
that the opto-isolator doesn't switch on and off as nearly as fast as a
regular transistor. In fact it can take 4 uS to turn this baby on. That
means that simply turning it off and on as fast as possible results in a
125Khz, 50% duty cycle waveform. (4uS on, 4uS off). In practical terms, if
you want equal PWM steps from 1% to 100%, then the minimum "off" or "on"
time is one 4uS increment. The equal step constraint would limit you to a
PWM period of 400uS, or 2,500 Hz. If you don't care about the edge
conditions you could choose 1 uS as your increment, then given the minimum
4uS switch time, your duty cycle could be 0%, 4%-96%, and 100%. The gaps at
the low end and high end represent the 4uS switching minimum. The benefit
however is that your base period is now 100uS and your base frequency is
10Khz. In summary, a completely symmetric PWM control will be no faster than
2500 Hz. If the areas of very low duty cycle and very high duty cycle are
un-interesting to your application, then the frequency can be increased.
The final thing we have to consider before we
design the circuit is the nature of DC motors. A DC motor looks like a
resistor and an inductor (coil) to the H-bridge. The resistor doesn't cause
us much grief, but the inductor does. That is because inductors do not like
being switched on and off. When the current through an inductor changes, the
voltage across it goes up in proportion to inductance and the
rate of
change in the current. This is expressed in engineering texts as V = L(
di/
dt).
Well switching off 6 amps of the current in 4 uS means the the voltage is
something like L*(6/.000004) or L*1,500,000. Clearly you aren't going to see
several million volts but you will see a spike in voltage when the inductor
is switched.
I'll dive a bit more deeply into this
phenomena in the
analysis section but for
now this means we need some diodes (called free wheeling diodes) to direct
those voltage spikes to places where they can do no harm. Fortunately, the
TIP107 and TIP102 have freewheeling diodes built into them, but if you
decide to use transistors that don't have built in diodes the circuit in the
next section provides for them.
Building the H-Bridge
I really like this H-bridge for a number of
reasons, not the least of which is that if you buy your parts in quantities
of 1, all the parts cost under $5 (excluding tax & shipping of course) for a
1 - 5 amp capable H-bridge. This keeps the final circuit in the "cheap"
category which was one of the design parameters we're optimizing for. The
complete schematic for the bridge is shown below.
The fast recovery diodes (shown in light blue) are optional when you are
using the TIP102/107 as those transistors have a diode built into them. However you can
include them for greater protection at higher currents and still keep the
cost at $5 per bridge. In the table below is a parts list, with prices from
November of 2003, using part
numbers from
Mouser Electronics. You
will note that I also take advantage of the symmetrical nature of the bridge
by using resistor packs rather than individual resistors. These packs allow
for a tighter design while still using through hole technology. If size is
an issue, you'll probably go with surface mount rather than this type of
circuit.
Qty |
Mouser Part # |
Description |
Each |
Total |
2 |
511-TIP107 |
TIP107, PNP Power Darlington Transistor
(TO-220AB) |
$0.70 |
$1.40 |
2 |
511-TIP102 |
TIP102, NPN Power Darlington Transistor
(TO-220AB) |
$0.70 |
$1.40 |
1 |
652-4608X-102-10K |
10K Ohm, SIP Resistor network
(independent resistors) |
$0.23 |
$0.23 |
1 |
652-4608X-102-560 |
560 Ohm, SIP Resistor network
(independent resistors) |
$0.23 |
$0.23 |
1 |
652-4608X-102-1K |
1K Ohm, SIP Resistor network
(independent resistors) |
$0.23 |
$0.23 |
1 |
551-PS2501-4 |
Quad Opto-coupler (16 pin DIP) |
$1.31 |
$1.31 |
4 |
625-1N4933 |
1A Fast Recovery Rectifier
(Optional) |
$0.05 |
$0.20 |
|
|
Total For Components
|
|
$5.00 |
Table 1) Parts List for the
Simple H-Bridge
In the previous section we
discussed the individual parts of this design, here they are gathered
together in a single circuit. You should notice that the opto-isolator
LEDs are connected to three wires labeled "FWD", "REV", and "ENA*." These
wires deserve a bit of explanation.
Processor Interface
The FWD, REV, and ENA* lines are
the interface between the bridge and the microprocessor. You will notice
their is no "ground" signal. When you connect these pins to a BASIC stamp or
a 68HC11 or what-ever, combinations of 1's and 0's on the line turn on
different pairs of transistors. The following table lists all possible
combinations of input.
FWD |
REV |
ENA* |
Description |
1 |
0 |
0 |
Turn on upper left source and
lower right sink. (go forward) |
1 |
0 |
1 |
Disable lower right sink. When
fed a PWM signal the bridge modulates the "forward" current through the
motor. |
1 |
1 |
0 |
Turn on both lower left sink and
lower right sink, shorting the motor. This causes a rotating motor to
stop rotating so this mode is called "Braking." |
1 |
1 |
1 |
Disable both lower sinks. When
fed a PWM signal the bridge modulates the "braking" of the motor. |
0 |
1 |
0 |
Turn on the upper right source
and lower left sink. (go backward) |
0 |
1 |
1 |
Disable lower left sink. When
fed a PWM signal the bridge modulates the "reverse" current through the
motor. |
0 |
0 |
0 |
Turn off all sources and sinks.
"Coast" motor is not engaged at all. |
0 |
0 |
1 |
Turn off all sources and sinks
in a different way, same effect though. |
This works because the processor pins become a
connection to ground when they are outputting a logic 0. Thus when FWD is 1
and ENA is 0, the lower right sink is getting current from FWD which it is
returning through the pin connected to ENA. At any given time the pin must
be able to supply enough current to turn on two LEDs and when set to zero
sink the current of two LEDs. With the 560 ohm resistors and a 5V processor
like the PIC this is not a problem. From the data sheet on the opto-isolator,
each LED has a forward voltage drop of 1.2V, so (5 - 1.2) / 560 is 6.8mA per
LED or 14mA of load total. The PIC is specified to be able to drive 20mA.
You can replace the 560 ohm resistors with 680 ohm resistors to reduce the
current through the LEDs still further. However the LED voltage drop can be
as high as 1.4V and the PIC's operating voltage can be as low as 4.5V, in
that condition with 680 ohm resistors you would only put 4.5mA into each LED
which is below the 5mA specified in the datasheet. The 560 ohm resistor is
the better choice as it maintains sufficient margin.
So why go to all this trouble? The interface
as designed gives you access to all of the interesting combinations of sinks
and sources enable, while not allowing for any "illegal" states. An illegal
state in a full quadrant H-bridge (4 inputs, one for each quadrant) is one
that turns on the upper source and lower sink on the same side. This
combination causes a direct short circuit to be created between the battery
terminals (not good!) and usually causes one or both of the transistors that
are on to go up in smoke. Further, as the low end PIC chips like the
PIC16F628 has a single hardware PWM line, this lets you connect that line to
the bridge and a couple of GPIO pins to the FWD and REV lines to get a
hardware PWM on the bridge. Just remember not to go above 2.5Khz unless you
replace the opto-isolator with a faster one.
Summarizing
So before we solder it all together, lets
analyze the design and try to characterize its performance. This will give
us confidence that this H-bridge will meet the requirements we need it to
meet, and we won't be surprised by it not working on us.
Building a Test Bench
So we've got a parts list, a schematic, and
you could just jump in and build this bridge to see if it will work.
However, as this is both a theory and a practice tutorial I'll dive in a bit
deeper than that.
To understand how this bridge performs in
practice, I built one half of it on a piece of proto-board. I only had to
build "half" the circuit because the circuit is symmetrical, anything I can learn about
this half is equally applicable to the other half. The only thing this won't
tell me is what the behavior would be if the
bridge switches from full forward to full
reverse in one go. The picture on the right shows the half bridge and a
Basic Stamp II board next to it on the left. The Basic Stamp is used as a test pattern
generator for my experiments.
The
schematic
of the test circuit is shown on the right. Inputs to this circuit
are P0 and P1 which reflect the names of the Basic Stamp 2 pins to which
those test points are connected. On the right side of the schematic are four
test points labeled TP1 through TP4 which correspond to the battery and
motor connections in the full schematic.
By building one half of the full h-bridge, I
can turn on one low side (sink) transistor and one high side (source) transistor and then look at the
waveforms and voltages under controlled conditions.
The difference between this schematic and the one in the previous section
is that half of the bridge is missing, and I've added independent control
of the transistors. thus the FWD, REV, and ENA*
lines aren't present.
For the static tests I have the Basic Stamp II
simply turn on the transistors and leave them on. One additional piece of
information gathered was that 470
ohm resistors work as do 560 ohm
resistors. (560 turned out to be my final value that I used). If you don't
have a Stamp or some other piece of equipment that generates signals you can
simply connect the 1K resistors to TP1 and TP4 respectively. That will force
the transistors on while you are doing the tests.
Static Tests
The first set of tests are static
analysis of the transistor behavior. The three parameters I was most
interested in were the voltage drop across the "source" transistor, the
voltage drop across the "sink" transistor, and heat dissipation in the
transistors. These tests are run with a voltmeter and an
adjustable power
supply. The datasheets include graphs of these parameters because they
change for different currents. I thought I would pick three currents from
which to take measurements of 10mA, 100mA, and 1000mA then plot the results.
Note that the next step for current in a log scale would be 10 amps but the
circuit is not rated for 10 amps. You could go to 2 amps (pretty much the
limit without using heatsinks) or to 6 amps if the transistors had heatsinks
installed.
Test #1 : Source side Voltage Drop
Purpose: The purpose of
this test was to ascertain the voltage drop across the high side (source)
transistor. The motor will see the battery voltage minus this voltage and
the voltage drop across the sink transistor so knowing these values help
define the lowest voltage that is practical with this bridge.
Description: A variable
output bench top
power supply is connected to TP1 and TP4. To create a load, a
4.7 ohm, 10 watt, power resistor is connected
between TP2 and TP4. A digital voltmeter was connected between TP1 and TP2
and set to "DC Volts".
The power supply was turned on
and its current output adjusted to 10 mA, a reading was taken on
the voltmeter, then the current is increased to 100 mA and finally 1000
mA.
Test Results: The results
of this test are collated in the table below. As the current through the
transistor is changed from 10mA to 1000mA the voltage drop changes from a
low of about .6 V to a high of about .9V. This change is plotted in
the chart on the right side of the table.
Current |
Measured
Voltage Drop |
Chart |
10 mA |
0.602 V
|
|
100 mA |
0.687 V |
1000 mA |
0.950 V |
What this tells us is that as the
current gets larger the transistor is less like a conductor and more like a
resistor. The physics behind this change are due to the fact that silicon,
unlike other metals, is transferring charge carriers (electrons and holes)
through a crystal lattice. The larger the current, the more charge carriers
are required, and the space in the lattice is finite. The result is that
more charge carriers collide with the lattice generating heat, and the
difference in charge going in vs. that going out is measured as a voltage
drop. (recall that the voltage potential between two points is simply the
difference in charge between those points)
Test #2 : Sink side Voltage Drop
Purpose: The purpose of
this test was to ascertain the voltage drop across the low side (sink)
transistor. The motor will see the battery voltage minus this voltage and
the voltage drop across the source transistor so knowing these values help
define the lowest voltage that is practical with this bridge.
Description: A variable
output bench top power supply is connected to TP1 and TP4. To create a load, a
4.7 ohm, 10 watt, power resistor is connected
between TP1 and TP3. A
digital voltmeter was connected between TP3 and TP4
and set to "DC Volts".
The power supply was turned on
and its current output adjusted to 10 mA, a reading was taken on
the voltmeter, then the current is increased to 100 mA and finally 1000
mA.
Test Results: Again I've
collected the results into a table below. To bring this back to a global
point about this
web site, there is a page in my "physical" robotics
notebook where I hand drew a box with 10, 100, and 1000 in the left hand
side, then as I got measurements I wrote them to the right. Around the box I
identified these results as being "Sink Experiment #2" and the date. I can
go back later and refer to the notebook pages I created during this project
and easily re-create my experiment or refresh my self on the results of that
experiment.
Current |
Measured
Voltage Drop |
Chart |
10 mA |
0.576 V |
|
100 mA |
0.637 V |
1000 mA |
0.763 V |
When that transistor is "off" the
voltage rises to the input voltage of 10V, when the transistor is "on" it
drops to the difference between the voltage on the low side collector and
the battery minus connection. Again its in the neighborhood of .75V. In the
chart I've shown the sink voltage drop in red and the source voltage drop in
green.
Test #3 : Thermal Constants for the TIP107 and TIP102
Purpose: The purpose of
this test was to ascertain what the current capacity for the bridge will be
when it does not have
heat sinks on the transistors. This value will vary
with ambient conditions but this test attempts to establish a baseline which
will help us decide if we must put heat sinks on the transistors in general
or only in special cases.
Description: The half
bridge is set up with a
variable power supply attached to the "Battery
Positive" and "Battery Negative" test points. A resistor is
connected between the sink resistor and "Battery Positive" which will
provide a regulated load. The transistor was instrumented with a type K
thermocouple that was attached to my Fluke meter. The transistor with the
thermocouple attached is shown in the picture to the right. I took great care to put an insulator
between the transistor tab and the bolt to prevent the bolt from becoming
part of the thermal mass being measured.
Under three loads, 10mA, 100mA,
and 1000mA, the temperature is measured until it stabilizes. Note that for
both the 100mA and 1000mA tests the voltage is constantly adjusted to keep
the current level the same. This is because BJT transistors have a
'negative' temperature coefficient, when they get hotter they conduct more
current. This can lead to thermal runaway if the supply and load can conduct
higher currents. In addition to the temperature
measurements, the voltage drop is measured across the transistor.
The power being dissipated by the
transistor will be equal to the current multiplied by the Vce
voltage. The Rtheta(ca) value (case to ambient) will be the difference in
temperature (from the initial reading) divided by the dissipation in watts giving a value in °C/Watt.
Initially I used a non-contact thermometer
to measure the temperature of the transistor. I have the IR-101 from
La Crosse Technology. This
can measure either Centigrade or Fahrenheit and also maintains min/max
measurements. The challenge was reading the transistor and not the resistor
(which gets really hot), and the emissivity of the transistor tab doesn't
give good readings (accurate to 2.5 degrees).
Test Results: Initial measurements put the
TO-220 case at 20.1 °C, The temperature measured at each current level is
recorded in the table below. The value for Rtheta(ja) is computed for each
measurement point.
Current |
Voltage
Drop |
Power
Dissipation |
Measured
Temperature |
Computed
Rtheta(ja) |
0 mA
|
N/A |
N/A |
20.1 °C |
N/A |
10 mA |
0,576 V |
.006 W |
20.8 °C (+ 0.7 °C) |
116.7 °C/W |
100 mA |
0.637 V |
.064 W |
27.6
°C (+ 7.5 °C) |
117.2 °C/W |
1000 mA |
0.717 V |
.717 W |
67.7 °C (+ 47.6 °C) |
66.4 °C/W |
The interesting thing to me was
that the temperature coefficient got a lot smaller when the current was
greater. The data sheet for the TO-220 specs a value of 62 °C/W which
is pretty close to the last measurement. When I thought about it I realized
that this effect stems from the "thermal resistance" of the ambient air. The
energy transfer is proportional to the difference in temperature, as the
temperature difference goes up, more heat is pushed "into" the air more
quickly. Further, a convection current is established as the air next to the
transistor heats up and rises allowing cooler air to replace it. By blowing
on the transistor I could easily bring the temperature down to 60 °C.
Static Tests Summary
The transistors have a voltage
drop that is between .7 and 1V under load. Its "between" these numbers because as the
current through the transistor increases so does the voltage drop. Given
that the torque output of a motor is proportional to its current, we must
insure that the voltage the motor "sees" will be sufficient to get the
maximum torque. Referring to the Mabuchi
RS-280RA/SA data sheet, we
see that the 7.2V model (RS-280RA-2485) delivers maximum torque (220g*cm) at
6.6Amps of current when it is stalled. To get this much current requires a
full 7.2V of voltage potential so the motor, so allowing for 2V of voltage
drop means the input batteries should probably be 9.6V NiCd's. However, the
nominal power this motor consumes is 1.18A when pushing 33.3 g·cm
of torque (at 14,300 RPM). If you've geared this down 10:1 your looking at
333 g·cm
of torque at 1430 RPM. A "fast" robot can move at 10'/second so to travel at
1430 RPM that is 24 revolutions per second, and to cover 120" each
revolution would have to move the robot 5". Dividing 5 by π gives a diameter
of 1.6" (or a radius of 2 cm). So torque delivered by the motor to the rim
of a wheel 4cm in diameter behind a 10:1 gearbox will be about 150 gm. Two
of these motors would provide 300gm of torque to the ground while cruising.
Startup torque (to accelerate from a dead stop) 1.1Kg per wheel or
2.2Kg for two wheels. Basically enough to accelerate a 3Kg Sumo robot at
nearly 1G if the traction held.
The bottom line is that for a
robot that weighs 5 to 16 lbs (2 - 8 Kg) a pair of these bridges driving a
pair of the Mabuchi motors with 10:1 gearboxes would make for a pretty peppy
robot. The closer you got to an 8Kg robot the more likely you would need to
add heatsinks to the bridge (more often pulling more than 1.5A) and for
robots of 2 or 3 Kg the bridge as is will be fine.
Dynamic Tests
In order to investigate how this
bridge responds when it is driving an inductive load, a slight change was made. The modification consists of
adding two fast recovery silicon rectifiers. I've used a pair of
1N4936 diodes which are a bit of
overkill with a 400V reverse voltage limit but they are inexpensive.
Further, having a
better margin for error is always good. The updated schematic is shown to
the right. You will recall these diodes are shown as "optional" in the full
H-bridge circuit. The newly added diodes are installed in place of the sink
transistor in the lower left of the bridge and the source transistor in the upper right
area.
The two transistors are sporting
light blue diode symbols to remind you that the TIP 102 and TIP 107
transistors have a built in freewheeling diode. If you re-arrange the
circuit it would like like the schematic shown on the left.
With The test circuit I still can't reverse the motor's direction,
but I can change its speed. As the h-bridge circuit
is symmetric, I can use this circuit to study the behavior of the bridge
when it is driving a motor with a DC signal and a PWM signal.
To generate control signals for the dynamic
tests I've used a
test pattern generator. My "test pattern generator" in this case is a Parallax
Basic Stamp II that is running
The following simple program:
'{STAMP BS2}
'
' A Simple Test Program to run my test bench setup
'
DIRA = 3
' Set up pins 0 and 1 as outputs
OUTA = 0
' Initial state, transistors off.
Loop:
OUTA = StateA
' Transistor state set to "A"
PULSOUT 2,100
' A finer grain delay than PAUSE
OUTA = StateB
' Transistor state set to "B"
PULSOUT 2,100
' A finer grain delay than PAUSE
GOTO Loop
END |
When pin P0 on the BS2 is set to be an output
and "high" (logic 1 level) it puts 5V on the P0 input of our test circuit.
This causes the opto-isolator's LED to illuminate and that causes the
transistor to turn "on." The opto-isolator's transistor connects the base of
the TIP107 transistor to ground and that turns that transistor on. Similarly
when P1 is made "1" by the BS2, it turns on the sink transistor using a
similar mechanism. As you can see in the program the transistors
are changed from state "A" to state "B" and back again, but neither "A" nor
"B" are specified. That is because there are many ways you might
want to drive your bridge.
There are two primary ways of driving an
H-bridge, one is called "sign magnitude" and "locked anti-phase." A good
description of the difference can be found on
Larry Barrello's site
(see the motion control pages). I tend to use sign-magnitude as it does not
depend on specific timing relationships between the source and sink
transistors. Specifically, transistors do not turn on and off at the same
speed. The locked anti-phase technique of motor control requires that the bridge
switch directions "instantly" so that there isn't an opportunity for
both the source and sink transistors of the same side of the bridge, being
active at the same time. Bridges that support locked anti-phase will have
logic inside the bridge to specifically delay the turn on of the sink our
source to match the turn off time of that element's counterpart.
Test #1 : Contributions of Resistance and Inductance
Purpose: A permanent
magnet DC motor can be modeled by three components in series;, a resistor,
an inductor, and a voltage source. Resistance is due to the wire resistance
of the motor's windings, inductance is due to the geometry of those
windings, and the voltage source arises from the interaction between the
permanent magnets in the motor and the windings. The purpose of
this test was to look at the waveform of the voltage across the motor when
the bridge was operating and to determine how each of these three components
contribute to that waveform.
Description: An oscilloscope is set up to take a differential
measurement between TP2 and TP3. This is accomplished by hooking channel 1
to TP2, channel 2 to TP3 and then using the "add" and "invert" buttons to
create a composite output. The result can be expressed mathematically as
"CH1 + (- CH2)." As they are both measuring a waveform with respect too a
common ground, any difference in the two waveforms will show up in the
composite waveform. Three sub-tests tests are run, one with a resistor
connected between TP2 and TP3, one with an inductor connected between TP2
and TP3, and one with a motor connected between TP2 and TP3. Each test
generated a waveform and each waveform is photographed and recorded. The
Basic Stamp II is connected to P0 and P1 and the test program is run. StateA
was set to 3 (both transistors on) and StateB was set to 0 (both transistors
off).
Test Results: The results
of this test were fairly interesting to me, they gave me a good picture of
what the components of the waveform observed were.
The first sub-test used a
resistor. The results were photographed and are shown in the scope trace
to the right. There isn't a whole lot of surprise here, the output is an
amplified version of the square wave that the BS2 is generating. The
scope was set to 10V per division so the resulting square wave is 10V
peak to peak. The bottom trace is an expanded view of the upper trace. |
Resistor
|
The second sub-test used an
inductor. The photograph of those results is shown on the right. Again
the scope is set to a resolution of 10V per division, but this time when
the transistors turn off there is a -10V "spike". There are two things
about the spike that are interesting, the first is that it is nearly
exactly -10V, and the second is that it is quite short. More about that
in a bit. |
Inductor
|
The final sub-test used a
permanent magnet DC motor. Again the results are in the photograph to
the right. This one has the square wave from the resistor, the spike
from the inductor, and now a moderately curving up tick to 5V and
periodic glitches to 10V (not visible in this image sorry.) |
Motor
|
I've re-drawn the final waveform
and annotated the results, they are shown below.
Starting from the left of the
waveform and moving to the right. The voltage across the motor jumps to 10V
when the two transistors are switched "on." This part of the wave form comes
from the resistive nature of the motor, if it were a perfect conductor then
the voltage drop across the motor would be zero according to Ohm's law. Then
when they are switched "off" the voltage makes an apparent reversal (more on
this after test #2) and the voltage stays at -10V for a short period of time
while the current in the motor's windings decays. This component is
contributed by the inductance of the motor as it matches exactly the
waveform of the inductor only subtest. Finally the motor returns to zero but
then continues to 5V. This is the contribution of the "generator effect" or
back EMF voltage of the motor. Because the motor has mass and it is still
spinning, its inertia causes it to continue to rotate. This rotation moves
the windings past the permanent magnets and the motor becomes a generator.
The interesting thing for me was
the spikes in the EMF component. After thinking about it for a while I
realized that a permanent magnet DC motor has brushes that reverse the
polarity of the windings when the stator is turning. When those brushes
switch, they disconnect the motor winding resulting in an inductive spike as
well. That spike can be controlled (but not eliminated) by putting a
capacitor across the motor terminals.
Test #2 : Which to switch, High, Low, or Both
Purpose: One of the arguments that you
hear in robot groups and on line is how sign magnitude PWM should be
implemented. Specifically, should you switch both the high side and low side
transistors? Or just the high side? or just the low side? The argument goes
that switching the high side eliminates spikes or switching them both
increases efficiency, and on and on. This test was designed to try all three
options (high, low, and both) and to analyze the results.
Description:
An oscilloscope is set up to take a differential measurement between TP2 and
TP3. This is accomplished by hooking channel 1 to TP2, channel 2 to TP3 and
then using the "add" and "invert" buttons to create a composite output. The
result can be expressed mathematically as "CH1 + (- CH2)." As they are both
measuring a waveform with respect too a common ground, any difference in the
two waveforms will show up in the composite waveform. Three sub-tests
tests are run; One by switching off both transistors, one by switching off
the sink (low) transistor, and one by switching off the source (high)
transistor. Each test generated a waveform and each waveform is photographed
and recorded. The Basic Stamp II is connected to P0 and P1 and the test
program is run. The following values are used for variable StateA and StateB.
Sub-test |
StateA |
StateB |
Both Transistors switched |
0x03 |
0x00 |
Sink Transistor (low side) switched |
0x03 |
0x02 |
Source Transistor (high side) switched |
0x03 |
0x01 |
Test Results: The results are collected
in the table below.
Resistor |
Inductor |
Motor |
Description |
|
|
|
This is the series of tests
where I switch both the source and the sink transistor at the same
time. The interesting thing to note is the larger spike when the
bridge is switched "off" |
|
|
|
This is the series of tests
where I switched off the "sink" transistor only. This leaves the
source transistor on during the entire time. In these sequences you
can see the inductive kick from the inductor is apparently "missing"
(it isn't however...) |
As it turned out the last two sub-tests produced
identical results so only one set of results is not shown. It was interesting
to me that there were only two unique results out of three possible tests. To
understand that I needed to understand what was going on with the motor
inductance.
Remember in test #1 above where the voltage
across the inductor appears to go negative? Well how could that be given that
an inductor resists a change in current? The answer is that it isn't actually
negative. Remember that the scope probes are measuring the voltage across the
inductor, when there is a current flowing in the inductor a magnetic field
develops around it (this is its way of storing energy). When the current stops
because a switch is thrown open, the collapsing magnetic field of the inductor
continues to push current through. But a current, is really just charge in
motion. The charge in question has no where to go. So that charge "builds up"
on the end of the inductor. And because voltage is simply the difference in
charge, the voltage potential between the ends the inductor begins to rise.
Its important to note that the charge came from the other end of the inductor,
so this voltage potential is really relative to that end. The relationship
between the voltage rise relative to the other end of the inductor means that
some path needs to be found to return those electrons to the other side. If
you somehow managed to eject the motor the dielectric constant of the air
would break down as the voltage potential rose and you would get an arc as a
circuit was created with ionized air to the other terminal! Fortunately,
the h-bridge has other paths.
When both transistors are switched off, the
voltage rises until it begins to be higher than than the battery voltage. At
that point there is a circuit path backwards through the battery to the other
end of the inductor. This, in effect, dumps charge back into the battery. (not
a lot, just the amount of charge stored as flux in the magnetic field of the
inductor).
When only
one transistor is switched off
the story is completely different. Now as the potential rises it eventually
passes the forward voltage of the 1N4963 free wheeling diode. At that point it
sees the "conducting" transistor on the other side of the bridge, Once it is
higher than that transistor's voltage drop the rest can simply pass through to
the other end of the inductor. That wave form looks like the one below.
Now instead of seeing "-10V" the
inductor sees something like -1.5 volts. Why not zero volts? Because the
current is traveling through the freewheeling diode and the transistor that is
still on, consequently there are two voltage drops between it and the other
end of the inductor. When summed together those drops add up to about 1.5
volts.
Now I can draw a picture of the
test circuit and all the various current paths. This is shown in the schematic
below. The blue dashed line represents the current flow before the PWM wave
form is switched "off." The red dashed lines represent the path of the decay
current out of the inductor depending on which option you use for switching
off the transistors.
One of the members of the HBRC
asked, "But if you switch just one transistor, isn't the other one shorting
the motor and causing it to brake?" This is an excellent question and one that
I might have answered incorrectly had I not been through this analysis.
When you short a rotating motor the
voltage that the motor is generating is opposite to the voltage that you would
need to turn the motor the other way (hence the term 'back' EMF). If you look
at the scope traces and refer to the schematic above, you will note that for
our test cases the back EMF is "positive" with respect to our measuring
probes. That means that the voltage generated creates a higher potential on
the left terminal of the motor than the right terminal. If you create a
connection between the left and right terminal of the motor, the current will
flow from the left terminal, into the right terminal and try to drive the
motor in the other direction. (Just as if we had switched the bridge the other
way) But this current in our circuit is impeded by the freewheeling diode on
the right terminal that is reverse biased relative to that voltage. Hence, no
braking action occurs. If on the other hand you turn on the upper right
transistor while the upper left transistor is on, there is nothing to impede
the flow and the motor slows down rapidly.
Layout Considerations
Generally this circuit is fairly free of
layout restrictions, however there are some things that you can do to make
your life easier. A sample layout is shown below.
One
of the things to note is that the
transistors are arranged "back to back" with their tabs facing each other.
In my layout I have spaced them 3/8" apart which allows me to put a piece of
1" x 3/8" x copper bar stock down the middle and with #4-40 machine bolts to
secure it. A 1 - 1/2" piece of this stock weighs about 3 oz. This basically
doubles to current capacity of the bridge, and if you then bolt the copper
bar to a metal enclosure you can triple the capacity to a full 6 amps
continuous duty. Further, the two left transistors are the "upper" source
transistors and the two right transistors are the lower "sink" transistors.
That means that any thermal solution will have heat being injected from
diagonal corners which further maximizes the benefit by spreading out the
heat injection. The point here is to think about whether or not you are
going to put heat sinks on the transistors and lay them out accordingly.
If you decide you would actually like to build
a few PCBs for your club or for a class or something, there is a
ZIP file available that has everything you need
to order them from
APCircuits. As of
this writing (December '03) it will cost you about $100 to have 14 boards
made up (there is a $66 dollar "hit" just to set up the board, then each
board is $2.44 after that. However, 14 boards for $100 is about $7 each net
so you're looking at about a $12 per bridge cost). The layout in the zip
file is very slightly different than the first run, I added more room for
the over-voltage snubber and added a place to put a .01uf capacitor across
the motor leads (cuts down on brush noise).
Alternatively you can build this bridge on a
piece of perfboard and just solder it together. Be sure and use at least 18
ga wire on the legs of the transistors.
Microprocessor Control
To use this h-bridge with a microprocessor,
you must connect the three control lines to output pins on the
microprocessor. Using the BasicStamp II as an example, consider the
following hookup diagram.
As you can see three pins from
the
Basic Stamp are connected to each H-bridge board. In this example they
are P0, P1, and P2 to the board controlling the left motor and P4, P5, and
P6 to the board controlling the right motor. One of the advantages of using three pins that are both
right next to each other, and in the same group of four bits (called nybbles)
is that you can use a
single variable (one of OUTA, OUTB, OUTC, or OUTD) to
write to four pins at once.
This is really only important on
chips like the BASIC Stamp where their can be a millisecond or more between
the execution of one instruction and the next. By connecting them this way
you can cause both motors to start turning with a single instruction such as
this assignment:
OUTL = $33
Whereas if you did two
instructions :
OUTA = $03
OUTB = $03
You would find that the left
motor started turning first, then the right motor. So on a robot that
steered with two motors the motor would make a slight turn to the right,
then go straight. If you turned them off in the same sequence you would find
that the robot corrected its heading back to the original heading but would
not have traveled "straight" ahead. For systems that use
gear motors such as
the 12V Brevel motors or the Globe motors, this won't be a noticeable
problem, but higher performance motors will definitely suffer.
Alternatively you could use
something like my
ServoGizmo
project to drive one or two of these boards. The
AntWeight ESC code could be
easily modified to drive this
bridge circuit rather than the 754410, however
you could even drive two of these at the same time with some additional
code. When the 754410 is not mounted on the Gizmo board you get 6 outputs
from the PIC. If I have time I'll write a dual motor control with serial
input so that you could connect the Gizmo to just one pin of the BASIC stamp
and send it serial commands to control two motors.
The
easiest way to use PWM on the
motor is to start with the direction and enable bits "high" or at a logic 1
value. This turns on the high side (source) transistor and leaves the sink
side transistor off. You can then send "low" pulses out the ENA*
line to turn the motor on and off. This would allow you to use a single 'PWM'
output, such as the one that is available on the PIC16F628, to control the
PWM duty cycle in hardware while the PIC managed other aspects of
controlling the motor. The most common use would be to provide encoder
feedback into the PIC that would allow a simple PID algorithm to be
implemented. With two bits of encoder input, three bits of motor control,
and two bits for serial I/O the 16F628 would be well engaged.
Summary
The previous pages have gone
through the design of simple H-bridge using bipolar junction transistors. If
you read through this tutorial and build the H-bridge, you will be able to
use this information in many
future robots. The H-bridge that is presented
is well suited to a wide variety of hobby motors and because you should
understand it completely, it should be easily repaired should something
fail. The next step in building H-bridges is to build them out of MOSFETs.
This is a rather more complicated endeavor and the topic of the next section
in the H-bridge
Theory and Practice tutorial.