35

First, I acknowledge that there are several questions regarding this topic in the forum, however, the answers assume too much background knowledge of electronics to be of use to a true beginner (like myself). That being said, if you choose to answer, please limit your responses to heuristic (non-technical) explanations.

My understanding of a pull-up resistor, is to ensure a consistent charge on a line, as opposed to a disconnected line, which could potentially fall victim to electrical fields and then produce noise. The noise could then be interpreted as an input signal and cause unexpected results from your device.

Question 1) Am I correct in my understanding of the purpose of pull-up and pull-down resistors?

Question 2) How does this work? Can someone provide a metaphor or analogy to describe what exactly is taking place with the electrical current?

Zak
  • 635
  • 6
  • 11

2 Answers2

86

First: Yes, your understanding is essentially correct, other than the issue being voltage and not charge.

Here is my analogy:

Consider a door to a house, with really smooth hinges, and no bolt or latch. The door is so light and so well-hinged that the slightest breeze would cause it to flap open and closed.

Now add a light door-spring to the door. The spring keeps the door shut, but not terribly firmly: A gentle push will open it, and letting it go will cause the door to close again.

A so-called "floating input" is like that door - the slightest perturbations in electromagnetic field, like the breeze above, will cause the input to randomly toggle between open and shut (low and high).

Add the pull-up resistor (if you want the default to be "high") or pull-down resistor (if you want it to be "low"), and your spring is in place.

Now, an external voltage applied, like the gentle push, can overcome the "keep the door shut" tendency of the spring / pull-x resistor - and once the push is removed, the input returns to the desired default value.

A low value resistor in such use is like a really stiff spring - it needs a much firmer push to open, but open it will. It will also slam shut faster when the push is removed.

Anindo Ghosh
  • 50,188
  • 8
  • 103
  • 200
  • 6
    I very much like you analogy. Should be very helpful to those trying to understand the concept. – Gustavo Litovsky Feb 04 '13 at 19:23
  • 2
    +1 Excellent analogy, this helps visualize the concept of pull-up and down resistors quite well. – JYelton Feb 04 '13 at 19:30
  • Certain types of doors do not do well with being left ajar (floating) and may rip themselves off the hinges becoming permanently stuck in either the open or closed position. – spearson Mar 12 '13 at 17:34
  • 4
    Answers like these are the gems of EE.SE ! – bdutta74 Apr 25 '13 at 13:44
  • 2
    Damn those huge electronics books which don't explain like this !! Thanks a lot, you don't have any idea , how much time and pain this answer saved me.....my question [here](http://electronics.stackexchange.com/questions/68319/can-transmission-gates-be-used-to-implement-3-state-logic) got downvoted , because i couldn't express the concept of float state properly, now i definitely have understood the concept because of this analogy.......if you have more of these AMAZING analogies, do share it with the community in Q&A style !! – Barath Bushan May 06 '13 at 15:57
  • I like this analogy. To it one might add that in some cases where one needs to operate the door mechanically, it may be convenient to pair a uni-directional mechanism which is only capable of pushing the door open, with a spring that would pull the door closed when the mech is idle, but such a design won't be able to close the door as quickly as one which has a bidirectional mechanism which actively pushes the door open and actively pushes the door closed. Note also that the spring-based mech uses power continuously while the door is open, but the bidirectional mech doesn't. – supercat Jun 07 '13 at 18:56
  • 4
    @AnindoGhosh you made us Indians proud.... Really informative one. Now i will never forget about pull up resistor or pull down resistor in my life – BASIL VARGHESE Aug 26 '14 at 10:35
15

A pull up/down does three things.

1, it stabilizes the line, with a fixed reference (V+ for a pull up, or Gnd for a pull down, in most cases). The line will not float around. This could also be done without the pull-up, by directly connecting it to V+ or Gnd. This is a problem, which part 2 fixes.

2, it protects the circuit. If a line is connected directly to V+, and then it is also connected to Ground, you just created a short circuit. This happens for example, if a microcontroller pin connected directly to V+, is set as an output with logic level low. With a pull-up resistor, you no longer have a short circuit, just a minor load. This is a safety you want in place.

3, it allows you to override the reference on the line, without the short circuit. Aside from just being a safety precaution, it is a desired effect. This is how a microcontroller can read a switch changing from high to low, or low to high, when pressed. When the button connected to Ground is not pressed, with a pull-up the microcontroller reads HIGH state. Once you press the button, the direct connection to ground causes the state to change to LOW instead, since a direct connection is stronger than a weak pull-up. Then it goes back to a HIGH state once the button is released.

@AnindoGhosh analogy of a swinging door is good for part 1 (The spring) and 3 (The push). To add to that, part 2 is the spring preventing a strong wind from slamming the door off the hinges and messing everything in your house up. No spring (Pull-up/down), and a strong wind (A short circuit) can destroy a microcontroller or cause a battery to overheat, catch fire, explode.

Passerby
  • 72,580
  • 7
  • 90
  • 202