Go Down

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

deleenheir

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

It protects against a bad programming the pin as Output.

CrossRoads

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. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

michael_x

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

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

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 pm Last 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".


CrossRoads

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. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

LarryD

Quote
you want the resistor in series with the pin

I agree.
See attached:
The way you have it in your schematic isn't the same as how you have it wired up!

MarkT

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 won't respond to messages, use the forum please ]

polymorph

That is what the OP had in the first diagram, the one he was asking about.
Steve Greenfield AE7HD
CET Consumer Electronics and Computer
Please don't read your attitudes into my messages

Go Up