Pages: [1] 2   Go Down
Author Topic: Any arguments against using internal pull-ups?  (Read 1296 times)
0 Members and 1 Guest are viewing this topic.
Denmark
Offline Offline
Full Member
***
Karma: 11
Posts: 238
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

"Nothing is foolproof to a sufficiently talented fool"

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27357
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No catch. I use them for the same all the time.
Logged

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.

Offline Offline
Faraday Member
**
Karma: 68
Posts: 2803
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

The way you have it in your schematic isn't the same as how you have it wired up! That goes for me too.

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4335
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27357
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Worst state in America
Offline Offline
God Member
*****
Karma: 32
Posts: 808
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.........
Logged

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

0
Online Online
Shannon Member
****
Karma: 215
Posts: 12463
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

[ I won't respond to messages, use the forum please ]

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Idaho, US
Offline Offline
Edison Member
*
Karma: 21
Posts: 1019
Special User
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#define ACTIVATED LOW

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

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

I only provide help via the forum - please do not contact me for private consultancy.

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 105
Posts: 4687
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: December 14, 2013, 12:13:24 am by JimboZA » Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Idaho, US
Offline Offline
Edison Member
*
Karma: 21
Posts: 1019
Special User
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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
Logged

Offline Offline
Edison Member
*
Karma: 30
Posts: 2494
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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....
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27357
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Saskatchewan, Canada
Offline Offline
Edison Member
*
Karma: 49
Posts: 1419
Coding Geezer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

There are 10 kinds of people in the world,
those who understand binary, and those who don't.

Pages: [1] 2   Go Up
Jump to: