13
\$\begingroup\$

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

\$\endgroup\$

3 Answers 3

17
\$\begingroup\$

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)

\$\endgroup\$
9
\$\begingroup\$

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.

\$\endgroup\$
5
  • \$\begingroup\$ 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. \$\endgroup\$
    – dunkers
    Dec 5, 2012 at 20:39
  • \$\begingroup\$ 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...) \$\endgroup\$
    – dunkers
    Dec 5, 2012 at 20:50
  • \$\begingroup\$ "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... \$\endgroup\$
    – user16324
    Dec 10, 2012 at 17:19
  • 1
    \$\begingroup\$ Pulldowns versus pullups isn't merely historic. With a pullup resistor, the other side of the switch can be ground, which is often convenient. \$\endgroup\$ Feb 2, 2013 at 18:58
  • 1
    \$\begingroup\$ The TI MSP430 family of microcontrollers has both internal pull ups and pull downs. \$\endgroup\$
    – Passerby
    Nov 30, 2014 at 1:17
0
\$\begingroup\$

You never want to leave an input to logic open on the assumption that it would pull itself up or down. if an input is left open, it is a little antenna and also subject to the currents within the logic device. So you pull up or down to ensure you have a clean and predictable input. I learned this rule while I worked at Fairchild Semiconductor in the 1980s.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ This does not answer the question that was asked. \$\endgroup\$
    – The Photon
    Nov 30, 2014 at 0:52
  • \$\begingroup\$ I think, the context of the original question is that there are buttons and switched that are inputs for an MCU. If an I/O pin is unused, it can be made an output then driven low (or high) from firmware. That should address the lurking EMI issues, and it doesn't require an external resistor. \$\endgroup\$ Nov 30, 2014 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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