|
The Basics
This column is intended to be a place to
find really basic information on subjects related to
robotics and electronics. If you have questions about
the basics on these subjects, this column is for you. I
invite you to submit questions or information to this
column. Send me some mail.
Very Basic Circuits
This time in Very Basic Circuits, I
would like to talk about pull-up resistors. The basic
function of a pull-up resistor is to insure that given
no other input, a circuit assumes a default value.
Actually, there are two flavors of this circuit. A
pull-up and a pull-down. Their function is the same, to
create a default value for a circuit, but one pulls the
line high, the other pulls it low.

A floating input gate. Not Good!
Consider this schematic. The gate U1A
has an input (pin 1) and an output (pin 2). The input
state of most logic gates is called a high impedance.
This means it provides no real power of its own.
Therefore, if nothing is connected to pin 1, the value
of the input is considered to be floating. Most gates
will float towards a high state. This is a very weak
condition, and any electrical noise could cause the
input to go low.
When switch S1 is closed (on), the input
state at pin1 goes low. Since there is a definite
connection to an electrical potential (in this case
ground), the state of the pin is stable.
When switch S1 is open (off), then input
pin 1 is susceptible to a wide array of electrical
problems. The traces or wires connected to pin 1 may
very well allow enough electrical noise in (by acting as
little antennas) to cause pin 1 to incorrectly switch
states. What is needed here is a way to connect pin 1 to
an electrical potential that can be removed when the
switch is closed. This electrical potential will allow
the pin to keep a steady state.

A very bad idea!
One thought is to tie the pin to Vcc (+5
volts) to insure that pin 1 doesn't float. The circuit
to the right certainly does that. With pin 1 tied
directly to Vcc, the line does not float, and has an ON
state.
The problem with this circuit is what happens when
switch S1 is closed. This creates a direct electrical
connection between Vcc and GND. In other words, it will
short out the circuit. If you are lucky, it will just
stop your entire system from working. If you are
unlucky, it will burn up the wires!
The problem with short circuits is they
allow too much current to flow from Vcc to GND. This
causes heat to be generated, which can sometimes burn
parts, wires, or even start fires. In addition, most
circuits fail to function correctly because the voltage
at the power supply drops to zero. In general, this is a
bad situation!

Pull-up resistor limits the current
Now consider the next schematic, which
is similar to the first but has added a pull-up
resistor. This resistors function is to limit the amount
of current that can flow through the circuit.
When switch S1 is open (off), pin 1 is
tied to Vcc through the resistor. Since pin1 is a high
impedance input, a voltage meter or logic probe placed
on pin 1 will show Vcc (+5v) if connected to pin 1.
When switch S1 is closed (on), pin 1 has
a direct connection to GND, which takes it to the low
state. The pin1 side of R1 also has a direct connection
to ground. Current will flow from Vcc, through R1, and
to ground. It isn't considered a short, however, because
R1 will limit the amount of current that can flow to a
very small amount. In fact, you can compute this using
Ohms law.
I = V / R
I = 5v / 10,000ohms
I = .0005A (.5mA)
A variation on this them is a pull-down
resistor. Just like the pull-up resistor, it is used to
limit the current that can flow between Vcc and ground.
Though less often used, it is still a valid thing to do.
Most digital circuits use a 10k or a 47k
resistor for pullups. The exact value doesn't actually
matter, as long as it is high enough to prevent too much
current from flowing. 10k seems to be the most common,
but if you are hoping to save as much power as possible,
the a 47k resistor may be right for your application. In
some cases, you can go higher, but then you are
depending on characteristics of the pins on the chip.
In Summary
You will find that pull-up resistors are
extremely common is most digital circuits. The key
function for a pull-up is to prevent input lines from
floating. The key function for the resistor itself is to
prevent too much current from flowing through the
pull-up circuit.

The less
common pull-down
Very Basic Circuits
If you have just read the above article,
you hopefully understand how a resistor limits the
amount of current that can flow through a circuit. In
the above example, we were dealing with input pins.
Expanding on that idea, I would like to present a simple
circuit that use limiting resistors with output pins and
also with an LED.

Unlike an input pin, which has only high
impedance, an output pin is designed to have two states:
Drive (on, or high logic) and Sink (off, or low logic).
Let us look at a simple digital circuit,
the 74HC04 Inverter. The picture on the right shows the
symbol for the 74HC04. Internally, this chip is
constructed using transistors. I have taken great
liberty by reducing the circuit to a single transistor
version, T1. Digital circuits use transistors as
switches. When a current is supplied at pin 1, the
transistor allows current to flow from pin 2 to GND.
I have included a picture of a switch as
well. Closing the switch allows current to flow from pin
2 to GND. These are functionally equivalent circuits.
The actual implementation of the 74HC04 is much more
complex, but the basic ideas presented are still valid.
In digital circuits, output gates are
switches.
In the above drawing, you can see that
the equivalent circuit using the switch demonstrates
that the internals of an output gate use a pull-up
resistor just like I described in the first article. By
replacing the original push button switch by the
equivalent transistor circuit, it looks like the
schematic on the right.

A quick analysis shows that when T1 is
off, R2 pulls the output pin high, which is good for
U2A's input pin. When T1 is on, T1 ties U2A's input pin
to GND, which brings the input pin low. R2 allows a
little bit of current to flow.
Note that on the real 74HC04, the
pull-up resistor R2 is internal to the chip. Therefore,
you can directly connect the output of most integrated
circuits directly to the input of others without an
external pull-up resistor.
There are times when you connect the
output of a gate to a device that isn't the input of
another device. For example, driving an LED, is an
example.
An important consideration when
connecting anything to an output gate is what will
happen when the gate drops to logic zero. This basically
creates a direct line to GND, just like the switch
example. Before you connect anything to an output gate,
you should consider how much current will flow through
the gate in the zero state. Quite often, you will need
to add a current limiting resistor to insure that you
don't burn up the part.
Most logic parts are capable of handling
around 20mA of current per pin. This means that you need
to consider carefully the device being attached.

An LED (Light Emitting Diode) is a
semiconductor that emits light energy when a current
flows through it. Current will only flow one direction,
just like a regular diode. There are a few things you
need to know about an LED before you use one. First, and
most importantly, is that an LED has very low internal
resistance. This means that left to itself, an LED will
pass so much current that it will burn up. They require
an external resistor to limit the current.
Most LED's have a current rating, which
determines the size of the resistor you will need. The
current rating tells you what the maximum allowable
current for the part is. In general, the higher the
current, the brighter the LED.
Most LED's seem to handle at least 15mA.
If you are using a 5 volt circuit, then Ohms law tells
you what resistor value to use. R = V / I, so R = 5v /
.015A = 333 ohms.
Now let us consider what happens when
using the output of a chip, such as the 74HC04, to
operate an external device. For example, the circuit on
the right drives an LED. When the gate is HIGH, then
there is no path to GND for cathode of the LED L1. When
the gate is LOW, then output pin 2 is connected to
ground, and current flows.

Since R3 only allows 15mA of current to
pass, the gate is safe from being overloaded. Remember
that most gates can handle 20mA of current. The same
holds true for most microcontrollers.
The output from gates acts very much
like a switch. When the gate is logic low, it goes to
ground. Most gates can only handle about 20mA of current
without burning up. You should always understand how
much current will flow when the device is connected to a
logic low gate.
|