5
\$\begingroup\$

If you have a pullup resistor setup:

pullup connects power to input

Image Source: Sparkfun - Pull-up Resistors

If the button is open, is voltage and current constantly being drawn through the input pin or does the high impedance mean that a value can be read but little leakage current occurs? Would this be suitable for a lower power system?

\$\endgroup\$
2
  • \$\begingroup\$ Which situation you mean? Button not pushed, or button pushed? What assumptions are made of the MCU input, is it an ideal CMOS input with no leakage current? Or something else? \$\endgroup\$
    – Justme
    May 20 at 16:00
  • \$\begingroup\$ Usually input pins are designed so they take barely any current at all. \$\endgroup\$
    – user253751
    May 20 at 18:13

3 Answers 3

7
\$\begingroup\$

The circuit draws significant current whenever the switch is closed. You can make R1 high value, but that can invite noise (perhaps mitigated by a capacitor) and there will be a limit based on the maximum leakage current of the input (typically at the highest junction temperature), the lower logic threshold and the desired noise immunity. There may also be insufficient 'wetting' current for a mechanical switch to be reliable.

One approach to reducing power consumption is to return R1 to a second GPIO rather than Vcc. You can then pulse the output high briefly, read the switch state, and return the output to low. If you only need to read state changes every 100ms and you can read the state with the second GPIO high for only 10us then you are effectively increasing the value of R1 by 10,000:1, so a convenient 20kΩ resistor would draw about as much average current as an impractical 200MΩ pullup.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Many MCUs also provide internal pull-ups on GPIO pins which can be enabled and disabled as needed. So a very low quiescent power approach without sacrificing another GPIO pin can look like: keep pin configured as output low when idle, and when it is time to poll, switch to input, enable pull-up, read value, switch back to output low. Or instead of polling, use interrupts: keep pin as input with pull-up enabled, when the button pulls it low and fires an interrupt, switch over to the polling routine I just mentioned and keep doing that until the button is released and input goes high again. \$\endgroup\$
    – TooTea
    May 21 at 12:13
  • \$\begingroup\$ To make it clear to others, the reason @TooTea has the GPIO set as output (or pull-down if the chip has that capability) between reads is that a CMOS input circuitry (even a Schmitt-trigger type) can draw significant current internally if left to float. \$\endgroup\$ May 21 at 15:09
  • \$\begingroup\$ Another even better approach is to use a double-throw switch which can drive the input either high or low, and then use a switchable pull-up or pull-down to drive the switch in a direction opposite its present observed state. If desired, the pull-up or pull-down could be high-value resistor in series with the output of a a discrete logic non-inverting buffer, providing reliable debouncing and near-zero-quiescent-current operation without any CPU intervention. The only time the circuit would draw non-trivial quiescent current outside transistor leakage would be if a switch had... \$\endgroup\$
    – supercat
    May 21 at 19:30
  • \$\begingroup\$ ...a small amount of leakage, but not enough to reach the switching threshold against the pull-up or pull-down. Note that the pull-up or pull-down could be very weak because it would merely be required to hold the pin in its present state, rather than switch it to a new state. \$\endgroup\$
    – supercat
    May 21 at 19:33
3
\$\begingroup\$

The answer to whether or not a pull-up resistor consumes power depends on whether or not current flows through the resistor.

If the pull-up resistor is used to hold an input to a logic high level, and the input pin merely drives the gate of a MOSFET, the current through the resistor will be negligible.

The same applies to most MOSFET gpio pins configured as inputs.

BJT inputs, however, generally draw current.

If the pull-up resistor is used to pull up a pin that can also be driven low by some other device, such as a manual switch connected to ground, or an open collector or open drain output, then the pull-up resistor will consume power when the output is low.

\$\endgroup\$
2
\$\begingroup\$

Assuming that VCC (for the pullup) is the same voltage as the VCC for the MCU, a simple mechanical button, and a typical design for the input pin on the MCU:

The system consumes non negligible power when the button is pressed. During that time, a current (given by ohms law) flows through the resistor and dissipates power.

When the button is not pressed, the only power consumption is a tiny leakage current associated with the input pin's circuitry. The datasheet for your MCU should give an estimated range of currents for this leakage, but it's usually on the order of microamps at most. For the atmega328p, the datasheet states that the leakage current will be 1 μA at most.

\$\endgroup\$

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.