Selecting Resistor Values
What value should be used for pull up (or pull down) resistors? A lot depends on the demands of the application. A big part of the decision is how much power the application can afford to use.
When a switch is closed, current will flow through the resistor. The current will depend on the value of the resistor and the voltage used to power the circuit. The current can be determined with Ohm’s Law:
I = V/R
Similarly, the power consumed by using the formula:
With a 1000 (1K) ohm resistor and a 5V supply voltage, we get the following:
I = V/R = 5/1000 = .005 A or 5 ma P= V^2/R = 5 * 5/1000 = .025W or 25 mw
With a 10,000 (10K) ohm resistor in the same circuit we get:
I = V/R = 5/10000 = .0005 A or .5 ma P= V^2/R = 5 * 5/10000 = .0025W or 2.5 mw
Clearly using a higher value resistor uses less power, so why not just use very large resistors for switch pull ups? The problem is that high resistor values make the circuit more sensitive to noise. A small amount of noise current injected into a high impedance circuit could generate enough voltage to cause an incorrect reading.
Too high a resistance can also make a circuit sensitive to leakage from moisture or contamination on the circuit board. I once designed a portable device with a PIC microcontroller. It had some input switches for operator control. Wanting to maximize battery life, I used 47K Ω pull up resistors. Things worked fine until units started to get returned for erratic operation. They all worked fine once they got back. The ones getting returned were coming back from Central America and Pacific islands. It turned out that condensation from the high humidity was enough of a path to pull the input pins low. After that the boards were given a conformal coating to keep moisture off the conductors.
The purpose of the switch will also determine how critical power consumption is, even in a battery application. If the switch is a push button type the user only presses occasionally for a fraction of second, the total power consumption will be low. A slide or toggle switch that might be left in the closed position for long periods of time could cause significant battery drain.
As a practical matter, values greater than 1KΩ and less than 20KΩ will work pretty well. Unless I have some special needs I usually just use 10K resistors as a good compromise between power use and noise immunity. A future section of this series will cover handling other ways of dealing with noise on input lines.