# Pull-up Pull-down resistor questions

Hi everyone,

I'm quiet new to electronics and I have few questions about pull-up and pull-down resistor.

If I've understood correctly the pull-up resistor, the value of the resistor is used to :

• control how much current flows from VCC to the ground when the button is pressed
• control the voltage on the input pin when the button is not pressed

So the value of this resistor needs to be high enough in order to not drain too much current when the button is pressed but in the same time should not exceed a certain value so as to the input voltage on the pin is high enough. This is why as a compromise people use a resistance whose value is 1/10 of the MCU internal impedance .
Am I right so far ?

If yes, I don't see the compromise that has to be made in the value of a pull-down resistor. :-\

• When the button is released, I don't see in what this resistance is usefull. Without it the pin of the MCU would still be at the low state
• When the button is pressed the resistor prevents the short between the 5V and the ground and limit the current drained. The input voltage in the pin of the MCU will be 5V whatever the resistor value

So if I am right there is no limit in the the choice of the pull-down resistor value ? The highest it can be the better it is ? I'm sure I'm missing something there...

As a final question would it be right to imagine a pull-down resistor made like this :

GND|-----------SWITCH----////------o 5v
¦
|
o
Input

I would naively say yes as it seems the input is never floating but I may miss the same thing.

It's more complicated than that.
Consider this:
A pin has more than 100Megohm impedance.
High impedance, or a "floating" pin picks up mains hum/interference easier. All wiring has to be shielded.
A switch is not perfect, and could "leak".
Without resistor, the MCU will read the switch as permanently pressed.

Your drawing shows a pull-up resistor (pulls the pin up to 5volt), not a pull-down (to ground).
Not needed, because Arduino pins have an internal pull-up resistor that you can enable in the code with (INPUT_PULLUP).
Leo..

If the resistor is too low you use too much current when it is pressed. When it is too high it is more susceptible to interference. The internal pull-ups are about 30K and are considered weak, you would not want to pull up with any higher value. Most people use 10K but I have always used 4K7.

So the value of this resistor needs to be high enough in order to not drain too much current when the button is pressed

Correct!

but in the same time should not exceed a certain value so as to the input voltage on the pin is high enough.

No. The voltage is either ~5V or ~0V (ground potential) no matter what resistor value is chosen.

If the resistance is too high the input will be vulnerable to noise pick-up. There are electrical signals all around. The strongest is usually from power lines in your house/building. For example, if you touch the signal input to an audio amplifier, you'll get a 50Hz or 60Hz hum/buzz. That's your body acting as an antenna and picking-up the power line "signal".

There was a post recently where someone was getting an interrupt triggered 50 times per second... Power line noise into a high impedance input!

There is a limited amount of energy in those signals. Since higher impedance/resistance requires less current, you'll get higher noise voltage with higher resistance. And, it's the noise voltage that can give false/wrong input. The noise current mostly flows through the pull-up/pull-down resistor, since it has lower resistance.

This is why as a compromise people use a resistance whose value is 1/10 of the MCU internal impedance .

The resistor has be low enough to "overcome" or dominate the internal impedance.... The pull-up resistor and the internal impedance form a [u]voltage divider[/u] and if the pull-up is much lower than the internal impedance (almost) no voltage will be "lost" across the pull-up and it will pull fully-up or full-down (and you can ignore the voltage divider effect).

Although, without studying the chip you don't know if that internal impedance provides a path to ground, or a path to Vcc, or maybe both... So in some cases (such as with the Arduino) you don't strictly have a voltage divider.

The Arduino has an input impedance of around 100 Megohms, (which we can consider "almost infinite" impedance for practical/engineering purposes). 1/10th of that would be too sensitive to noise pick-up.

10K is usually a good compromise. The pull-ups built-into the ATmega chip (which can be optionally enabled) are between 20K and 50K.

When the button is released, I don't see in what this resistance is usefull. Without it the pin of the MCU would still be at the low state

No. The Arduino input is "floating" and undefined when open. I think they tend to float high, but I'm not sure and the datasheet just says undefined.

It depends on the particular part/circuit. TTL logic devices are high when open/unconnected (although it's considered good engineering practice to add a pull-up, and/or to ground unused pins).

Another issue is that there is some input capacitance. A high pull-up or pull-down resistance along with the capacitance will form a low-pass filter and it won't pull-up or down as fast when the switch is open. (With a manual switch, a few microseconds of delay won't be noticed.)

As a final question would it be right to imagine a pull-down resistor made like this :

GND|-----------SWITCH----////------o 5v
¦
|
o
Input

Not quite... The pull-up is always connected to the input. You've got it on the wrong side of the switch.

See this web site for a discussion of pull up v pull down.
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Grumpy_Mike:
See this web site for a discussion of pull up v pull down.
Inputs

According to the web site, I understand that in pull up case, when the switch is close, current will flow from 5V through pull up resistor to the ground because value of resistor is much less than input impedance. So the input pin will read LOW because the amount of current go through this pin is very small.
But for pull down case, when the switch is close, everything wil go the same with pull up case, current go through input pin still very small because its high impedance. So why can the input pin read HIGH?

Don't try to think about current flowing. We are talking about inputs with very very high impedance. There won't be much current flowing in either case. Think about the voltages at different points in the circuit.

With a pullup, when the switch is open the input is connected to +5V through the resistor and nothing else, so it sees 5V since the impedance of the input is so much higher than the resistor. When the switch is closed the input is connected to +5V through the resistor and to Ground through no resistance. This essentially creates a voltage divider with the input pin between a resistance and no resistance, so it reads 0V.

Typical switch contact resistances are in the 1 milliohm to 1 ohm range, depending on how
big the switch and how much oxide and muck has got onto the contacts - this is effectively
zero.

So the only requirements of the resistor value is noise rejection and power consumption. On
the same board 10k or internal pullups are quite adequate, for a remotely mounted switch
perhaps 5k to 1k range is better (depending on the amount of electrical noise around). You
can also decrease noise with a capacitor on the pin to ground.

If you are using a pull-up for a high speed logic signal, you would need the resistor value to
be low enough to keep the rising edges fast enough, since cable and input capacitances have
to charge up through the resistor and this takes time of about RC. For instance 10k and 20pF
has a rise-time of about 200ns.