Go Down

### Topic: Right way to use a pull up resistor (Read 3565 times)previous topic - next topic

#### deleenheir

##### Aug 14, 2013, 02:37 pm
What is the right way to use a pull up resistor?

or

I'm talking about the 100 Ohm resistor that is added in the first example. What is it's purpose?

#### michael_x

#1
##### Aug 14, 2013, 03:29 pm
It protects against a bad programming the pin as Output.

#2
##### Aug 14, 2013, 03:50 pm
Can use the internal pullup instead:

pinMode (pinX, INPUT_PULLUP);

or

pinMode (pinX, INPUT);
digitalWrite (pinX, HIGH); // enables internal pullup

This keeps input pins from floating and providing nonsense readings.
100 ohm is way too low a value. Internal is 20K to 50K.
External only needs to be 10K.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### michael_x

#3
##### Aug 14, 2013, 04:19 pm
Quote
100 ohm is way too low a value. Internal is 20K to 50K.

Agreed, this 100 Ohms before the pin is not a Pullup nor Pulldown resistance.
Quote
What is it's purpose?

If "none" is a too simplistic answer, there just remains (my previous reply) "to limit the current into the Arduino pin in case of errors".
Any other suggestions ?

#### RoyK

#4
##### Aug 14, 2013, 04:39 pm
Or to limit the current out of the pin. Suppose the pin were for some reason configured as an output and written to HIGH with the switch closed.

#### deleenheir

#5
##### Aug 14, 2013, 04:57 pm
So if it's correct that it serves to protect the chip, shouldn't it be at least 125 Ohm? The atmega is rated up to 40mA @ 5V so 5/0.04 = 125 Ohm (150 Ohm to be shure)

#### pwillard

#6
##### Aug 14, 2013, 05:25 pmLast Edit: Aug 14, 2013, 07:33 pm by pwillard Reason: 1
It doesn't *have* to be there... unless you would like to save yourself from a stupid mistake on a breadboard where you would accidentally  cause a short on the PIN and "smoke" it.  I have seen designs with other non-Atmel microcontrollers where 200 Ohms is used.  In this particular circuit... it's best suited for bread board usage... but when you move to a final PCB where stray wires are unlikely, you can remove it.

So, it's probably "what it is" for the following reasons:

100 Ohm resistor is readily available
100 Ohm resistor is "close enough"
Many "hobbyists" go on and on about how 40 Ma is just a "line in the sand" set by Atmel as a safety margin and the pin can tolerate 60mA or even 80mA with no ill effects (I'm not one of those) but this discussion continues "ad nauseum" in other threads and does not need to be continued here

This is why I keep a few 220 Ohm DIP arrays in my "junkbox".

#7
##### Aug 14, 2013, 07:13 pm
If you're trying to limit current flow in & out of the pin, you want the resistor in series with the pin, not pulling up to 5V.
See "Protection Details" in the middle of the Rugged Circuits design discussion here
http://www.ruggedcircuits.com/html/ruggeduino.html
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### larryd

#8
##### Aug 16, 2013, 03:40 am
Quote
you want the resistor in series with the pin

I agree.
See attached:
No technical PMs.
The last thing you did is where you should start looking.

#### MarkT

#9
##### Aug 16, 2013, 03:22 pm
Actually I'd just make both resistors 10k, then you only need to buy one value (or share resistors
in a resistor array) - the protection resistor's actual value isn't important at all so long as its > 200 or so
and not so high as to allow capacitive noise pickup by the input pin.

Having a 10k protection resistor also means that if the switch is remote and its cable gets damaged and
12V (say) gets onto the switch line, the Arduino isn't going to instantly be fried.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#10