Pages: [1]   Go Down
Author Topic: Pull up?  (Read 556 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm a marine electrician (I work on ships) and I'm having trouble trying to figure out why some people say it's better to use a pull up resistor for an input as opposed to a pull down resistor.

In my experience, switching neutral and/or negative only leads to problems, some which could be quite serious.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16523
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm a marine electrician (I work on ships) and I'm having trouble trying to figure out why some people say it's better to use a pull up resistor for an input as opposed to a pull down resistor.

In my experience, switching neutral and/or negative only leads to problems, some which could be quite serious.

Well different worlds, AC neutral and DC negative. Also one is not switching voltage source wires when they talk of pull-ups or pull-down for arduino input pins.

 Here is the thing, arduino input pins, if they have nothing wired to them are said to be in a 'floating condition', meaning they have no default electrical signal wired to them, therefore when executing a digitalRead() statement on a 'floating' input pin will return random HIGH or LOW results just due to circuit noise, emf, phase of the moon, etc.

 So to read a typical manual switch contact input (button is a common term used) on a arduino digital input pin, there has to somehow be a default valid digital voltage source (either +5vdc or ground) applied to the pin when the switch contact is in the open condition. Wiring a say 10k ohm resistor to either ground or +5vdc and the other end to the input pin is one way to satisfy that condition. So if we wire a pull-up resistor to +5vdc and the input pin and also wire a switch contact between the input pin and ground, when the switch contact is open it will read as a HIGH and when the switch contact is closed the input will read as LOW. Conversly wiring a pull-down resistor to ground and the input pin, and the switch to the input pin and +5vdc, will result in a valid LOW when not pressed and a valid HIGH when pressed.

 Now the reason to favor using a pull-up design over a pull-down design, is that the AVR chip used on the arduino has a software enabled option to apply an internal pull-up resistor to any digital input pin. So using that option allows one to simply wire a switch contact between the input pin and ground, when not pressed the internal pull-up supplies a valid logic voltage and when pressed the switch supplies a ground to the pin overriding the pull-up voltage and the pin will read as a valid logic level LOW. So one gets to use a required pull-up without actually needing a physical external resistor. Note that there is no software enable internal pull-down resistor option avalible.

So the choice of pull-up or pull-down is strictly up to you to decide what's best for your external circuit. However by utilizing the software enabled internal pull=up resistors for the input pins saves you one physical resistor for each input pin you are using. Note this only applies to reading switch contacts or open-collector transistors wired to input pins. Any electrical signal that is active low 0vdc, and active high, +5vdc can be wired directly to an input pin without the need of pull-up or down resistors, as the signal always has a valid logic voltage level, so the input pin never 'sees' a 'floating' input state. Note then when wiring a active electrical signal to a arduino pin there must also be a common ground wire run between the arduino and the external device suppling the signal to the input pin if that device is being powered by a different voltage source, rather then the +5vdc from the arduino board.

That make sense?

Lefty
« Last Edit: August 12, 2011, 06:14:26 pm by retrolefty » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I've just seen some posts saying that "noobs" don't understand that it's better or somehow more correct to use a pull-up. In my world, doing something like that would constantly be using power, but I guess the Arduino inputs would have a high enough impedance that the power drawn in a pull-up situation would be extremely small.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16523
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but I guess the Arduino inputs would have a high enough impedance that the power drawn in a pull-up situation would be extremely small.

Correct. From the datasheet input leakage current with either a HIGH or LOW voltage input is 1 microamp.

Quote
In my world, doing something like that would constantly be using power,

In that case your world must hate the on-board power is on LED.  smiley-wink

Lefty
« Last Edit: August 12, 2011, 07:23:41 pm by retrolefty » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I've just seen some posts saying that "noobs" don't understand that it's better or somehow more correct to use a pull-up. In my world, doing something like that would constantly be using power, but I guess the Arduino inputs would have a high enough impedance that the power drawn in a pull-up situation would be extremely small.

What is more important is not pull up or pull down, but that inputs be connected to a valid logic level, ie low or high. THe problem is that some CMOS ic's are exquisitely sensitive and can pick up stray charges and act unpredictably if allowed to float( ie - remain not connected). So some CMOS ic's (VS1053) advice all unused logic inputs to be grounded etc. So it depends on the manufacturers recommendation about floating inputs.

The AVR's inputs have very high impedance in the mega ohm range i suppose, so a pull up resistor would not cause any appreciable curent increase.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 509
Posts: 31472
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
noobs" don't understand that it's better or somehow more correct to use a pull-up.
Yes that is correct.

We are not switching power here the rules are different. Imagine a switch on the end of a wire. If you use this to pull up the two wires are the 5V and the signal. However if it is the pull down, the two wires are ground and the signal. It is much safer to have long runs of ground that long runs of the power rail. It also the interference it picks up is much less damaging. Also an accidental short of a ground is much less damaging that shorting the power.

Finally with a lot of logic technologies it takes mush less current to switch to ground and pull up than the other way round. For example with TTL logic the maximum pull down resistor is about 220R where as the maximum pull up resistor is about 10K.
Logged

Pages: [1]   Go Up
Jump to: