2
\$\begingroup\$

Apologies for the vague title, wasn't sure how to summarize the question. I've been struggling with this for two days and feeling a bit desperate.

This is how I understand simple CMOS gates work in principle.

enter image description here

I also understand that microcontroller inputs should not be left floating since due to their high impedance they can self bias if so. So we use pull-up/down resistors. What I struggle to understand is, for example in the below we are providing a constant connection to Vcc. Why doesn't that permanently peg the input high, or at least cause issues since a 10K resistor is a comparatively low value considering the input impedance of the microcontroller?

enter image description here

My understanding is something like this would happen in principle (although of course the pins on the microcontroller would have a somewhat different design than an inverter gate)

enter image description here

Is this correct? If so in principle, unless there are some system specific restrictions, you could choose to design your circuit with either pull-up or pulldown resistors and appropriate switches, as you see fit?

I would really appreciate your input.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ The pull-up forms a voltage divider with the resistance of whatever is driving it. When input is low, the result of the voltage divider be below the turn-off threshold, including tolerances, and above the turn-on threshold when input is high. I.e. V_IL(min) and V_IH(max) listed in the datasheet for the chip in the "electrical specifications" section. The pull-up/down should be neither too weak nor too strong, and depends on the application. The range of pull-up values is something like 5K-33K, 10K is very typical. \$\endgroup\$
    – Pete W
    Jan 29, 2021 at 14:14
  • 1
    \$\begingroup\$ Modified your title to say what you are asking. \$\endgroup\$
    – DKNguyen
    Jan 29, 2021 at 14:36
  • 1
    \$\begingroup\$ Because the pullups are resistors. Generally, rather high resistors (10K or more), and therefore pretty weak pullups that can easily be overcome by output transistors, swiches, etc. Short that signal to ground, and 0.5mA or less (5V, 10K) will flow. No big deal ... unless you're trying to get a year's life out of a coin cell. \$\endgroup\$
    – user16324
    Jan 29, 2021 at 15:33
  • \$\begingroup\$ Thank you for the answers. So in principle my understanding is correct? When the switch is in the low position, the path to Vcc (to which we've attached the pull-up resistor) still has an influence on the input pin, however it's is so small that the transistors still bias correctly and the input pin registers the correct value. \$\endgroup\$ Jan 29, 2021 at 18:52

1 Answer 1

2
\$\begingroup\$

The pushbutton is approximately 0 ohms short circuit when it is pushed, so it overrides the voltage to 0V, as the 10k pull-up is so much weaker.

Internal pull resistors are in the 20k to 50k area typically, so having an external pull resistor to one state and internal pull resistor to another state will create problems, it might be that the voltage is something that is an indeterminate digital value, ans extra current flows both via resistors and the FETs.

So basically, either use internal or external resistors if in doubt. Internal pull resistors can typically be enabled or disabled in software, so you are free to choose the external pull direction and value.

\$\endgroup\$
3
  • \$\begingroup\$ Thank you for the answers. So in principle my understanding is correct? When the switch is in the low position, the path to Vcc (to which we've attached the pull-up resistor) still has an influence on the input pin, however it's is so small that the transistors still bias correctly and the input pin registers the correct value. \$\endgroup\$ Jan 29, 2021 at 18:53
  • 2
    \$\begingroup\$ Yes, if the VCC is 5V, there will be 5V over the 10k resistor, and 0.5mA will flow via the resistor and switch and GPIO input is 0. \$\endgroup\$
    – Justme
    Jan 29, 2021 at 19:00
  • \$\begingroup\$ Thank you very much for your attention and help. Have a good weekend. \$\endgroup\$ Jan 29, 2021 at 19:17

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.