# Math behind pull-up resistors

I have a question about the the math behind of pull-up resistors and how they work. I don't have any experience in the Electric Engineering field so it's probably a basic question.

I saw many explanations regarding WHAT pull up resistor is doing but rarely HOW it is doing it.

Consider that I have the following circuit, where:

$$V_{cc} = 5V$$ $$R_1 = 10K\Omega$$ $$R_2 = 100M\Omega$$

Now, there are two cases:

1. The button is unpressed. In such case we have: $$\I = \dfrac{V_{cc}}{R_1+R_2} = \dfrac{5V}{10,000 \Omega + 100,000,000 \Omega} = 0.000000049A\$$ and then the voltage at $$\R_2\$$ is $$\V_2 = R_2 \cdot I = 100,000,000 \Omega \cdot 0.000000049A = 4.9V\$$ and so the input pin see the input as HIGH. Are my calculations correct here or something else is going on in the circuit?
2. The button is pressed. I do know that the input pin see the input as LOW in such case (some value that is close to $$\0V\$$) but I don't know how to calculate it.

Thanks.

• What exactly do you want to calculate? Considering the button has 0Ohm when pressed, the input will see exactly 0V above GND. In a digital circuit where you only decide between HIGH and LOW, there's typically no need to do further calculations. Jul 24 at 16:08
• I size resistors to supply the current I want. For a switch I want at least 1mA so the resistor size depends on the voltage. In your schematic R1 the pull up resistor is guarenting the state of the input pin if the switch is open. I would use a 4.7K as the pull up, it will give me a little more then 1mA. Same thing for pull down resistors. Your MCU is not an actual circuit but a representation of how it behaves. Your calculations will not be accurate. Look at the data sheet for the approximate value, they are all different and many times not listed or guaranteed.
– Gil
Jul 24 at 21:29

1. The button is unpressed. Are my calculations correct here or something else is going on in the circuit?

Your calculations are correct. Few of us would bother with the calculations as the input impedance is so high. With those values of resistors you have loads of margin because the input voltage is so far above the logic 1 maximum threshold (which will be available in the datasheets).

1. The button is pressed. I do know that the input pin see the input as LOW in such case (some value that is close to 0V) but I don't know how to calculate it.

Do the same calculations again but with R1 as 10 kΩ and the button as, say, 100 mΩ in parallel with R2. You'll quickly see that you can ignore R2's contribution and that the result is ridiculously close to 0 V and well below the minimum low threshold. Again, few of us would bother to check this unless our switch had some odd properties that caused it to have a high resistance.

simulate this circuit – Schematic created using CircuitLab

Figure 1. A quick simulation for a 100 mΩ switch.

Can you show me an example of how to calculate it?

For parallel resistors the equivalent is $$\ R = \frac {R_1 R_2} {R_1 + R_2} = \frac {0.1 \times 100M} {0.1 + 100M} = \frac {10M} {100M} = 0.1 \ \Omega\$$. The 100 MΩ in parallel doesn't make any difference. Don't get hung up on precision. Your 100 MΩ resistor will be ±1% (1 MΩ).

I'm not sure how to calculate the voltage when you have two resistors in parallel after one resistor in series.

Get the equivalent of the parallel pair as I have done above and then do the series calculation. $$\ V_{out} = \frac {0.1}{100k + 0.1} 5 = 50 \ \mathrm{\mu V} \$$.

The current should split somehow proportional to the resistor value?

Well, proportional to the inverse of the resistance values.

Also, the voltage after the switch should be close to 5V, isn't it?

Not when it's closed. It will be closer to zero.

• Incidentally, YouTube channel "Electronics repair school" put up a video today where those "odd properties" had happened to a laptop computer's power switch on the keyboard—it had a resistance in the tens of kiloohms—and ended up using a PNP transistor as a fix instead of replacing the entire keyboard. Jul 24 at 16:27
• Can you show me an example of how to calculate it? I'm not sure how to calculate the voltage when you have two resistors in parallel after one resistor in series. The current should split somehow proportional to the resistor value? Also, the voltage after the switch should be close to 5V, isn't it? Jul 24 at 17:06
• @tesoji7388, see the update. Jul 24 at 17:56
• @Transistor: Thank you very much! Regarding the voltage after the switch is closed, I meant that one side of the branch should be larger than the second. As you wrote the $R_2$ branch should be 0.00005V and the second branch (of the switch) should be 4.99995V, isn't it? Jul 24 at 18:05
• R5, R4 and VM1 will all have the same voltage, 50 μV, across them. They're connected by a common wire so they have to. R1 will have the remainder, 4.99995 V across it. Jul 24 at 18:08

Your calculations are quite on spot analytically (yes they're right) but terribly rounded off numerically.

4.9V high voltage is far too low. Rounding it off 10k/100M is 0.1 out of 1000 or in other words you loose 0.1mV/V which on a 5V supply means 4.9995V output.

In this very case it makes no difference, but as a general voltage divider calculation, it may change the whole story.

So I warmly suggest going over your maths again.