Go Down

Topic: Any arguments against using internal pull-ups? (Read 1 time) previous topic - next topic

Peter_I

I really like internal pull-ups for reading buttons and switches.
It simplifies matters a bit, to have the code and the chip doing the work, rather than external components.



But it is so easy, I think there must be a catch?
Are there any arguments against using internal pull-ups?
"Nothing is foolproof to a sufficiently talented fool"

CrossRoads

No catch. I use them for the same all the time.
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

These I believe are 10k-50k.
I use them all the time.
However in a noisy environment and with longish cables you my want to use a low external value 470=1K.
The way you have it in your schematic isn't the same as how you have it wired up!

UKHeliBob

If I could have my way they would be pull-downs because it seems more logical to me somehow that pressing a button should take it HIGH, but having said that I have no problem using INPUT_PULLUP and testing for LOW on a pin.  The convenience of not having to wire in an external resistor far outweighs other considerations.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

CrossRoads

Positive Logic, Negative Logic, can think of it either way: active is the level that the signal is not at normally. High when normally resting Low, and Low when normally resting High.
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.

Krupski


These I believe are 10k-50k.
I use them all the time.
However in a noisy environment and with longish cables you my want to use a low external value 470=1K.


THIS exactly. I had a problem with a little controller that I built to use in a rather noisy (electrically noisy) area. Simply using "PINMODE INPUT_PULLUP" was not enough. At first I thought I had *really bad* switches that bounced a lot (and had to write some debounce code with a hideously long 100 msec timeout to make it work).

It kept bugging me that the switches couldn't be THAT bad, so I did a little test code to read the digital ports as fast as possible and record it to SRAM. Then I looked at it. Lots of noise, and doing an FFT on the noise showed (surprise) a 60 and 120 hz component (ac line noise).

Changed to using hard wired 1K (1000 ohm) pullups. No problems now at all... solid as a rock.

For what it's worth.........
Gentlemen may prefer Blondes, but Real Men prefer Redheads!

MarkT


If I could have my way they would be pull-downs because it seems more logical to me somehow that pressing a button should take it HIGH, but having said that I have no problem using INPUT_PULLUP and testing for LOW on a pin.  The convenience of not having to wire in an external resistor far outweighs other considerations.


The reason pull-ups are used is that then the switches can all wire to ground (which
is usually available everywhere as the groundplane or chassis or box in which the
equipment is mounted).  You don't need another wire to run Vcc to all your buttons.

Also several bus protocols use pull-up resistors and open-drain outputs, so there are
two reasons why pull-ups are more commonly wanted than pull-downs.
[ I won't respond to messages, use the forum please ]

PeterH

I think the biggest reason why active-low has become the preferred approach is that it avoids needing to supply power to remote switches/devices, which means there's less risk of a wiring fault/damage shorting the power to ground. When your only wires are ground, and something that is designed to be pulled down to ground, then it's pretty difficult to blow it up.
I only provide help via the forum - please do not contact me for private consultancy.

tylernt


If I could have my way they would be pull-downs because it seems more logical to me somehow that pressing a button should take it HIGH,


Code: [Select]

#define ACTIVATED LOW

if(switchpin == ACTIVATED) // see now it makes sense :)
  {
  // do stuff
  }

PeterH


Code: [Select]

if(switchpin == ACTIVATED) // see now it makes sense :)



Shouldn't that have a digitalRead() in there somewhere?
I only provide help via the forum - please do not contact me for private consultancy.

JimboZA

#10
Dec 14, 2013, 05:06 am Last Edit: Dec 14, 2013, 06:13 am by JimboZA Reason: 1
There was a great tip here somewhere a while ago, to help remember the button position for pullup / active low systems. With a momentary push-button, the position of the button itself is the state...

Button up, ie inactive normal position, and in its physically "high" (= up) position, is logic high.
Button down, ie active and pressed, and in its physically "low" (= down) position, is logic low.
Arduino ethernet server here.... http://jimboza.gotdns.com:8085/

No PMs for help please

tylernt



Code: [Select]

if(switchpin == ACTIVATED) // see now it makes sense :)



Shouldn't that have a digitalRead() in there somewhere?


Sorry, I couldn't find the "pseudocode" button.  :smiley-roll:

cjdelphi

I have one argument....

Using a resistor ensures it's pulled up, what happens when you accidentally remove the pullup or switch states accidentally and you then spend hours debugging to find it....

CrossRoads

How do you accidentally remove the pullup? That sounds like poor coding to me. Usually its turned on in void setup and then not changed.

You're more likely to hose yourself with = when you wanted ==, or leaving out a digitalRead and then making a decision.
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.

lar3ry


I have one argument....

Using a resistor ensures it's pulled up, what happens when you accidentally remove the pullup or switch states accidentally and you then spend hours debugging to find it....


You mean, in case you accidentally change the pinMode from INPUT_PULLUP to INPUT? or accidentally change the condition in an if from LOW to HIGH or vice versa?

Or are you thinking you might accidentally pull a pullup or pulldownout of a solderless breadboard?

In either case, I hardly think it would take hours to figure out what went wrong.
There are 10 kinds of people in the world,
those who understand binary, and those who don't.

Go Up