Bald Engineer: I need to take a break from this "Portable PI" project!
There are two questions that keep coming up from the pull-up resistors tutorial:
1) Why not just use a wire and, 2) What is the right value to pick for the resistor?
In this AddOhms electronics tutorial, I will answer both of those questions.
So... let's go pick!
[Music Playing] (Let me know in comments if these are helpful!)
First! If you haven't watched it already check out the full tutorial on pull-up resistors.
You can find a link in the description or use the card above to take you there.
(Just remember to come back when you're done!)
As a quick review, if we have a microcontroller pin and a push-button...
... with the button connected to ground. The input pin is left in a floating state,
when the button is not pressed.
This means the pin will randomly read as high or low.
A pull up resistor pulls the signal to a known state.
I recommend picking values between 1 kiloohm (1kΩ) and 100 kiloohm (100kΩ). But why?
And why use a resistor at all? Why not just tie the floating pin directly to the supply?
If we use the wire we could say the resistance is 0 ohms which is also an electric short.
While that WOULD be a strong pull-up... there's a problem!
When the button is pressed it creates a short circuit between the supply and ground!
That's Bad! Very Bad!
The resistor prevents this short circuit.
Let's go look at the other extreme. Without something there...
...there the pin floats. Another way to think of this is an open.
Which could be considered "infinite" ohms. Side note!
Technically an open is not infinite. Air and the PCB's solder mask all have some resistance associated with them.
But for our discussion, we are just going to call it infinite.
Well a range of 0 to infinity isn't very helpful is it? That's why I say pick between 1k and 100k.
But! I know you want to know where am I getting THOSE numbers?
So let's take a look at an example the ATmega 328p. This is the processor in the Arduino Uno.
Its datasheet says its internal pull-up resistors are rated between 20 and 50 kiloohms.
Let's just round that up to 100 kiloohms. As for the low end, the 1kohm...
That's just from my experience. Stick with me on that one.
On our chart, now we have a more reasonable range to pick from.
But I know... you still want an actual number and like the math that goes behind it!
Here is why I keep sticking to ranges.
A large resistance value is called a "weak" pull-up and small values are called "strong" pull-ups.
Now to me that sounds backwards. The reason is...
that the lower resistance values allow more current to flow making the pull to the supply *stronger*.
YOUR design determines the exact value to use! Like all things in engineering, there are trade-offs to consider.
A weak pull-up, one that is too big, starts to look like an open. Which makes the pin start to float.
The downside to a strong pull up or smaller value is
that when the button is pressed, the resistor burns more power. Which means wasted energy.
If you're using a battery you might want to be using larger resistors.
So again, it depends on YOUR application!
So a specific case that I see this problem with, like the 50 kilo ohm internal pull-ups...
... is with I-squared-C (I2C). If the wires, or traces, connecting a sensor are too long...
..you might need a strong pull-up. Which means a *smaller* value.
In review, unless you have a specific reason for another value,
I suggest using something between: 1 KΩ and 10 KΩ. go up to 100 KΩ when using a battery.
The actual value is not all that critical! You don't need a complex formula or detailed explanation.
Pick the resistor that works! It really is that simple.
Thank you for watching another AddOhms electronics tutorial!
If you have questions about pull-up resistors leave them with this video.
Check out addohms.com/ep25 For show notes, links to other stuff, and a link to our Discord server.
For now I'm going to get back to my Raspberry Pi project.
In the meantime, remember if your circuit isn't working:
Just add ohms: You know between 1 and 100 K!
[Music Playing] Please comment if these transcriptions are helpful!