I'm trying to intuit how pull-up and pull-down resistors work

  • Thread starter Thread starter s3a
  • Start date Start date
Click For Summary
Pull-up and pull-down resistors are essential in digital circuits to stabilize input voltages when switches are open, preventing undefined states. When a switch is closed, the resistor ensures that the voltage reflects a clear logic state opposite to that when the switch is open. The choice of resistor value is crucial; it must be low enough to avoid interfering with the circuit's operation but high enough to maintain stability. Directly connecting a microcontroller input to VCC or GND is safe due to high impedance, but resistors prevent potential short circuits. Understanding these concepts is vital for effective digital logic design and operation.
s3a
Messages
819
Reaction score
8
TL;DR
My understanding:
Pull-up resistor:
* Logic high when switch is open
* Logic low when switch is closed

Pull-down resistor:
* Logic low when switch is open
* Logic high when switch is closed

My goal:
I'm trying to intuit what happens in each arrangement when the switch is on and when it's off.
For the attached image (from https://en.wikipedia.org/wiki/Pull-up_resistor), could someone please help me intuit what happens in each arrangement when the switch is on and when it's off?

Pullup_and_pulldown_resistors.webp


So, apparently the pull-up or pull-down resistor is chosen optimally so as to be too low to significantly interfere with the switching device's impedance (as I think can be seen with the voltage divider law), but high enough to prevent a fluctuating voltage when the switch is open.

Also, what is this "to digital input" part exactly? Should I just treat that as a point at which to analyze the potential difference / voltage?

When the switch is closed, is there only one possible logic value for the voltage (assuming proper operation), which would be the opposite of the logical value exhibited when the switch is open or can it be either of the two logic values with the constant and predictable logic value only being the case when the switch is open?

Also, when the switch is open, for both pull-up and pull-down cases, is the reason for the stability because the resistor "pushes" the electrons in the (one) opposite direction, thereby creating certainty?

As you can probably see, I am very confused, so if someone could please help clarify things for me, I would greatly appreciate it!

P.S.
I can also give more information if necessary, so please let me know if you feel something's missing (even if you don't plan to be the one to actually answer my question(s)).

P.P.S.
I included a png version of the svg from Wikipedia for convenience, but the svg is also attached here.
 

Attachments

Engineering news on Phys.org
Just some words of warning. Trying to intuit resistors in digital circuits is going to make your life interesting, sometimes even exciting. There are speed bumps, expect them when you least expect them.

You are only thinking in terms of voltage dividers, with binary logic inputs, that sense voltage, such as CMOS.

Those resistors, to ground or supply rails, also terminate the transmission line impedance, lines that route signals across and between the circuit boards. The termination resistors look like pull-up resistors, but are selected to prevent signal reflections, which would make operation slow and unreliable. Line termination resistors, like the impedance of the lines they terminate, typically have values between 50 and 1k ohms.

There are legacy technologies, such as TTL, that employ current switching logic, not voltage, so voltage is only of secondary interest. With TTL, unused inputs use less supply current when they are tied to the logic high, +5V rail, through a 1k pull-up resistor. That resistor appears initially to be redundant, but it prevents subtle damage to the inputs if the +5V supply spikes momentarily, by a couple of volts. TTL inputs source conventional current to the output that controls them, which at first seems backwards. TTL can also use open-collector logic, with one pull-up resistor, to perform a wired-OR, in negative logic.

There are also current signalling technologies that go beyond TTL, such as I²L, (Integrated Injection Logic). There, logic gates have only one input terminal, but many separate outputs, so the logic is actually performed by wired-OR connections. I²L can operate on a 1V supply, consuming only micro-amps, while baffling any engineer trained only to think in terms of signal voltage.
https://en.wikipedia.org/wiki/Integrated_injection_logic
 
s3a said:
Also, what is this "to digital input" part exactly? Should I just treat that as a point at which to analyze the potential difference / voltage?

Pullup/pulldown resistors and switches are commonly used as inputs to digital logic gates or other digital logic like microcontrollers (uCs). They are used to create high(1)/low(0) logic inputs to those subsequent circuits:

1762993295957.webp

https://learn.sparkfun.com/tutorials/pull-up-resistors/all

If the input impedance of the subsequent logic gate is very high, like with CMOS logic, then you don't have to worry much about voltage divider considerations. If the input impedance is not high (and you have source currents coming from those logic inputs like in the old TTL days), then you do have to pay more attention to the value of the resistors.
 
To Baluncore:
My confusion was far more basic than that, but thanks anyway. For one, I didn't know TTL was the old stuff and CMOS the new. I did see the word CMOS in a textbook that I will eventually read when my knowledge level rises sufficiently.

To both (Baluncore and berkeman):
Having said that, firstly, I guess the microcontroller being directly connected to GND is a logic 0 and directly connected to VCC is a logic 1, but adding things to that basic scenario confuses me.

In the pull-up resistor case, while the micro-controller has a much higher resistance than R_1 of the diagram berkeman showed, is a reason for having R_1 that not having R_1 could damage an input part of it / the micro-controller (to attempt to reiterate part of what Baluncore said in my own words)? That doesn't seem to me to be the reason Wikipedia has given (among other sources); Wikipedia says that the voltage is undefined. Is the indefinition caused by frequent-but-non-consistent current and voltage spikes, and if so, is that mostly from causes like induction from surrounding entities?

That would only explain the open-switch case, though. When the switch is closed, I can see how more current would go from GND to MCU than to R_1 because of the resistance of MCU far exceeding R_1's, but I don't see how VCC and GND affect the input pin. I feel like the voltage at the pin should be (VCC - GND), but then that behaviour seems no different to me than when the switch is open. The behaviour when closing the switch should be the opposite logical value of when the switch is open, right?
 
s3a said:
In the pull-up resistor case, while the micro-controller has a much higher resistance than R_1 of the diagram berkeman showed, is a reason for having R_1 that not having R_1 could damage an input part of it / the micro-controller (to attempt to reiterate part of what Baluncore said in my own words)?
There are a couple reasons for using the "single pole / single throw" SPST switch and resistor versus a "single pole / double throw" SPDT switch (where you connect the two throw pins to Vcc and GND). First, the latter switch is a little more expensive than the former switch (even including the cost of the resistor), and second, with the SPDT switch it needs to be the "break before make" type, so it does not short Vcc to GND when being flipped. So that means there is a time window during the flipping of the switch where the connection to the following logic gate is floating, which is a bad thing for most types of logic.

If you leave a CMOS logic input floating for any amount of time, it can cause oscillations in the logic gate and its output, or it can allow the gate to float to a middle voltage value at its input and output, and that is a high current consumption state (much higher than normal saturated operation).

All of that may be TMI for you at this stage in your learning, but just come back and re-read it occasionally as you get farther in your learning about digital logic. It will make more sense as time goes on. :smile:
 
s3a said:
In the pull-up resistor case, while the micro-controller has a much higher resistance than R_1 of the diagram berkeman showed, is a reason for having R_1 that not having R_1 could damage an input part of it / the micro-controller (to attempt to reiterate part of what Baluncore said in my own words)?

You can connect a microprocessor input directly to VCC or GND without worries as the impedance is very high. You need that resistor so that when the switch is closed you aren't shorting VCC to GND. Your power supply wouldn't like that.

FWIW, some microprocessors have an internal pull-up resistor you can select programmatically. It's nice as it's simpler (no external resistor needed). You just wire the switch in between ground and the input pin.
 
Thanks for your responses and sorry for my late one.

It will probably seem trivial to you guys, but this (Reddit) post explains and solves my biggest confusion.:


Namely, "What I don't get, is when the button is pressed down. Now, the voltage from the pull-up resistor can go either to ground, or into the input pin, but it always goes to ground, so the arduino reads a 0. Why?" and the answer to it I referenced with the link above.

Just another, I suppose, stupid question: Does the GND to the left and below BUTTON and the GND to the right and below MCU's input pin connect to each other if one further draws the circuit (since I suppose they are the same GND by necessity and not just convenience), such that input pin has both endpoints touching (assuming wire with zero resistance) the bottom endpoint of R1? If so, does that have any significance?
511568b7ce395f613f000004.webp
 
I hate the term "army wavy" but that seems to be what you're doing. Learn some actual circuit analysis. Kirchoff's law, ohms law, etc. Arm waving in this scenario works fine in a conversation between two people who understand the math and circuit analysis. You aren't there yet. The terms pull-up and pull-down are quite arm wavy in my opinion but they are accepted because this circuit is well understood. No need to recite the math each time this circuit pops up.
 
  • Like
Likes sophiecentaur, Rive and davenn
Actually, I realized that that explanation I gave doesn't address the voltages, so that logic wouldn't be good enough for at least CMOS technology.

I know about Ohm's and Kirchoff's laws.

In the following image, when BUTTON is pressed, are R1, VCC and input pin in series with the GNDs connecting such that this is all just a single loop?:
511568b7ce395f613f000004.webp

When BUTTON is not pressed, it seems to be a line (not a loop) that goes from VCC to GND, which I guess still works, despite not being some set of loops.

If it's in series, the voltage divider concept would explain things, it seems.
 
  • #10
s3a said:
I know about Ohm's and Kirchoff's laws.
I really have to wonder.
 
  • Like
Likes sophiecentaur
  • #11
When the switch is closed you have a zero ohm resistor in parallel with R2. When the switch is open you have a resistor of infinite ohms in parallel with R2. Do you know how to solve for the total resistance of those parallel resistors?
 
  • #12
So, I find Req at the pin?

Switch open:
Req = 1 / (1/Rs + 1/R2)
Req = 1 / (1/INF + 1/R2)
Req = 1 / (0 + 1/R2)
Req = R2

Switch closed:
Req = 1 / (1/Rs + 1/R2)
Req = 1 / (1/0 + 1/R2)
Req = 1 / (INF + 1/R2)
Req = 1 / (INF)
Req = 0
 
  • #13
Do you know how to apply the results you got to determine what the voltage will be on the pin in each case?
 

Similar threads

Replies
46
Views
10K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 26 ·
Replies
26
Views
7K
  • · Replies 19 ·
Replies
19
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 31 ·
2
Replies
31
Views
2K
  • · Replies 49 ·
2
Replies
49
Views
4K
  • · Replies 42 ·
2
Replies
42
Views
5K
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K