Pull Up or Pull Down?

I am wiring 15 limit switches to a project. 12 stepper motors are being controlled by Uno modules, 1 per motor (12 Uno modules total).

I understand that it is essentially the same to the Uno whether a digital input pin is high or low. Is it preferable to use pull up resistors due to less current being used?

Due to several numerous stepper motors and possible noise, I believe using external resistors is preferable. My other question is what value? I have read 1K, 3K, and 10K.

Also, is it recommended to use 100 ohm resistors to the input pin as shown in the diagram?

pull up dn.jpg

thank you

Mark

pull up dn.jpg

If the switch is close to the Arduino, then you don't need any resistors at all.

Just connect the switch between pin and ground.

And enable the internal (inside MCU) pull up resistor with code.

pinMode(switchPin, INPUT_PULLUP);

Leo..

Edit:
A low value resistor (the 100ohm resistor) could be needed if the pin is used as OUTPUT.
e.g. to drive a LED, or the gate of a mosfet.
Not normally used when the pin is used as INPUT.

100Ω should not be needed.
10K for pull-up or pulldown is usually good enough.

In noisy conditions I prefer a N.C. limit switch and a low value pull-up.

larryd:
In noisy conditions I prefer a N.C. limit switch and a low value pull-up.

+1
Limit switches should be normally closed.
An old/oxidised/bad switch still opens reliably.
Leo..

I think if your switches are a long distance away from the Arduino, pull-down resistors will be more reliable. If there is enough resistance in the wires or noise in the lines, it makes a difference because LOW is defined as less than 0.5 volts, and HIGH is defined as more than 0.5 volts. The difference between 0.5 and 5 volts is a lot more than the distance between 0 and 0.5.

EDIT: Not sure where the 0.5 came from. This is totally not correct. See reply #6 by Coding Badly for correct numbers.

As far as how much current is flowing, that may be a less important issue. With limit switches, reliability is probably more important than power saving. Also, how much time is the switch going to be closed as opposed to open? Very little current flows when the switch is open, since the input is voltage based and not current based. And when the switch is closed, it makes no difference whether you're pull-up or pull-down.

Wawa:
+1
Limit switches should be normally closed.
An old/oxidised/bad switch still opens reliably.
Leo..

NC is failsafe in some respects, if wiring or terminations fail, usually they fail open circuit.
Tom.... :slight_smile:

Jimmus:
...it makes a difference because LOW is defined as less than 0.5 volts...

VIL = 0.3VCC
VIL = 0.3(5.0)
VIL = 1.5 V

You're only off by a volt.

...HIGH is defined as more than 0.5 volts...

VIH = 0.6VCC
VIH = 0.6(5.0)
VIH = 3.0 V

You're off by a bit more with that one.

The difference between 0.5 and 5 volts is a lot more than the distance between 0 and 0.5.

No doubt. But that is not particular relevant.

...pull-down resistors will be more reliable...

That does seem to be true when the switch is failing with an increasing closed contact resistance. With a 10k pulldown, the resistance across the switch can be as high as 6666 ohms and the pin will just reach 3.0 V. With a 10k pullup, the resistance across the switch can only be as high as 4284 ohms and the pin will just reach 1.5 V.

Which means putting the switch on an analog input would allow the processor to detect a switch that has an unexpectedly high resistance.

Wow. I totally missed the part where you have to multiply the 0.3 by Vcc. Thank you for schooling me on this.

So the difference between pull-down and pull-up is much less than I had thought. Pull-downs are only about 1.5 times as reliable, as opposed to 9 times that I had figured.