Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

A very basic question:

Must each IO pin of a microcontroller that is serving as an input from a switch or jumper have its own pull-up/down resistor?

Simple 3-pin IO schematic

In this example, each pin is pulled down by a resistor, then pulled up by a 1P3T switch to VCC.

It seems straightforward, but as more IO pins are used, are more resistors absolutely required? Is there some clever way to keep the resistor count down?

Related question: Sharing a pull-up resistor

share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

As per the schematic provided, if all 3 inputs were sharing a resistor, then any of the lines being pulled high via the switch would raise all 3 lines to high, countering the purpose of the design - the MCU would not know which switch position is selected.

A common way of reducing part count, not resistor count, for such designs is to use a common bus resistor network or array:
Common Bus Resistor Array (from here)


These are available as through-hole SIP/DIP as well as SMD, in a variety of resistor counts, depending on your needs. The bus pin is connected to ground, and the other pins are connected to the respective MCU inputs as in your schematic. SIP resistor arrays (from here)

SMD resistor arrays (from here)

share|improve this answer
add comment

Most MCUs have optional pull-up (not down) resistors built in for each pin, so it is normal to pull the pins DOWN with the switch (and deal with the polarity inversion in software).

So - no resistors necessary.

As to why pullup, not down, it's a habit left over from the 1970's TTL logic circuitry, where it took much less current to pull an input up than down - a pulldown resistor would waste more power. This no longer applies with today's CMOS logic, but the tradition of pull-ups has persisted, so that early 5V CMOS chips were compatible with older TTL logic.

share|improve this answer
    
+1 for heritage - good background! –  HikeOnPast Dec 5 '12 at 17:06
    
I thought the reason for pull-up was because their common use was with open collector outputs, and once you're in the habit of going one way you'll keep going that way without a good reason. –  dunkers Dec 5 '12 at 20:39
    
Further, TTL outputs can sink 16mA but source only 800uA, so a pull-up might be used to add muscle to an output. A TTL input would pull itself up if you didn't connect it, so a pull-up for input reasons seems a bit strange to me. (Sorry, waited too long in editing the previous comment...) –  dunkers Dec 5 '12 at 20:50
    
"a TTL input would pull itself up" ... to some extent yes, but not reliably - the big orange book specifies a 40 microamp Ih to guarantee Vin > 2.4V (for 7400; 20ua for 74LS) Leaving TTL inputs open was definitely not recommended anywhere I worked... –  Brian Drummond Dec 10 '12 at 17:19
    
Pulldowns versus pullups isn't merely historic. With a pullup resistor, the other side of the switch can be ground, which is often convenient. –  Olin Lathrop Feb 2 '13 at 18:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.