Pull-up and pull-down resistors
Chips such as microcontrollers read switches through inputs. An input measures the voltage on its pin, above or below a threshold, and draws almost no current doing it: it behaves like a resistor of many megohms.
On the board, a push button connects the + rail to column 11. Imagine column 11 wired to a chip's input. Pressing the button puts 9 V on it. And with the button released?
- 0 V, because nothing is pushing it
- 9 V, left over from the last press
- Nothing definite: it is connected to nothing, so it can drift to any voltage
The cure is a resistor from the input to a definite voltage. Add a 10 kΩ resistor from column 11 to the − rail.
With the button up, the resistor ties the input to 0 V. With it pressed, the button connects the input straight to 9 V, and the resistor only lets a small current through to the − rail. This resistor is called a pull-down: it pulls the input down whenever nothing else is driving it.
Measure the input: the multimeter's red probe in column 11, black on the − rail. Then press and hold the button and watch the reading.
What does the input read with the button up?
Answer in V.
Why 10 kΩ? When the button is pressed, the pull-down is connected straight across the 9 V supply.
How much current flows through a 10 kΩ pull-down while the button is held?
Answer in mA.
The mirror image is just as common. Put the resistor between the input and +, and the button between the input and −. Now the input sits high until the button pulls it low. This is a pull-up.
On this fresh board, build one: a 10 kΩ pull-up from the + rail to an input column, and a push button from that column to the − rail.
A pull-up and a pull-down both work. Which is more common for buttons on microcontroller boards?
- The pull-up, with the button to ground: many microcontrollers have pull-ups built in, so the button needs no resistor at all
- The pull-down, because pressing a button should give a high voltage
- Neither: buttons are wired straight to the input
Pull-up and pull-down resistors:
- an input connected to nothing is floating, and reads randomly;
- a pull-down (resistor to −) holds it low until a switch to + pulls it high: active high;
- a pull-up (resistor to +) holds it high until a switch to − pulls it low: active low;
- make the resistor large, 10 kΩ to 100 kΩ, so little current is wasted while the switch is closed.
A pull resistor is really a divider whose bottom half is the input's own enormous resistance: the input gets almost all of the voltage, and a switch can override it with almost no current.