Products > Embedded Computing

Arduino Internal Pullup Resistor Question - Starting out and in the weeds

<< < (5/5)

Simon has it right!  Don't overthink the math while electronics is a hobby.

Ohm's Law including the Power equation only requires simple division.
The voltage divider is a step up but really turns out to be 2 consecutive applications of Ohm's Law.

Eventually, maybe years down the road, Kirchhoff's Law and Thenenin's Theorem come up.  Norton comes up at the same time.  Even these require just simple arithmetic although, I'll concede, mesh and nodal analysis will likely require some matrix algebra or Gauss Jordan Elimination.  Easy stuff, really!

Where you get into higher order math is when you want to play with the step response of a tuned circuit (RC, RL, RLC) and along about here you really need to step up your game.  But do you really need to deal with this stuff?  Maybe, but it can probably be handled with a hand wave. 
"It looks a lot like this...".

Yes, in the time domain, almost everything is a differential equation..  That's why Laplace Transforms were invented.  But that is years down the road, if ever.  Sure, all the EEs around here know that kind of stuff but the hobbyists?  Probably not! 

Just learn how to sling Ohm's Law around so you can solve for any 1 of the 3 variables and you're good for a long time.

E = I * R
I = E / R
R = E / I

P = I * E  (power equation)  I & E can be substituted with their Ohm's Law equivalent so P = (E2) / R or P =( I2) * R, etc

Those 4 will get you a long way down the road.

Damn, I disagree with every single part of Rstofer's post. Maybe I'm wrong but I think this post is completely out of touch with modern CMOS practice. Maybe as pertains specifically to the OP, some of it is useful. But as a general rule (or LAWs)? I do no subscribe to any of these rules.

--- Quote ---Yes, it means that they don't know nor care what the value turns out to be. 
--- End quote ---
Well, the chips are "grown" in a lab. The values that results will vary, from batch to batch. These values represent the extremes of what they get before they throw out batches as bad. There are a ton of other electrical values they have to test for, so allowing a relatively large range in the pullups greatly increass yields and reduces your cost. It's a value that is not particularly important and can be replaced externally, if it does matter.

--- Quote ---It doesn't matter because while it is suitable for pulling up unused pins, it is just about worthless for external interfaces.  The value is too high, it is too susceptible to external noise, generally worthless. OTOH, we want to define unused pins as input and pull them to some guaranteed level - high or low, doesn't matter.  Since we have the internal pullup resistor, we will pull the unused pins high.
--- End quote ---

This is an opinion. You don't have to define unused pins as inputs. In fact, you should define NC pins as outputs for the lowest amount of power draw when that matters! The internal pullup is literally there for interfacing with external signals, and the value is appropriate for general purpose use. The transition between logic high and low in CMOS is much closer to Vss than Vdd, compared to older logic. I wanna say it's 1.5V for a 5V device. So there's a good amount of tolerable noise that is invisible to a digital input pin. Older logic chips had transition levels closer to the middle.

--- Quote ---Second thing:  NEVER use a solid Vcc as an input.  That's an old school rule but it was an actual LAW (not really, but close).  Use something like a 1k pullup on the pin and pull it down to a solid ground.
--- End quote ---
This is fine, but it is relative. You are using "solid Vss" as an input. The main reason to use solid Vss and a high impedance (pulled up) Vdd is due to convention. There are many examples of the opposite. Many modern digital watches, for some reason, use the positive rail as com, and the inputs are pulled down to ground. There are also many IC's that have logic level push pull outputs made to interface to microcontroller input pins. It's not all open collector outputs, anymore.

--- Quote ---OTOH, there's another RULE that should be a LAW:  Always put a 330 Ohm resistor in series with every used IO pin, input or output.  How many chips do you imagine have been blown up when a pin was configured for output, set high and then shorted to ground with a pushbutton on the wrong pin?  More than one!
--- End quote ---
I'm not sure what this is all about. If you are making an arduino board for playing around with, sure. Try to minimize mistakes by the user. 99.99% of microcontrollers are not "end user configurable computers." They are put into products. You don't add 20 parts to your product just in case you accidentally configure the microcontroller incorrectly on board number 17. You make the firmware and board, and then you pump them out. If driving a transistor or LED or any number of other things, you will need to use an appropriate resistor, as you have calculated, anyway. And the value won't necessarily be 330R.

--- Quote ---CMOS doesn't take much input current so a 330 Ohm resistor won't change the voltage very much.  The only reason we're using a 1K pullup is to provide enough current flow for the switch to function properly.  The problem with high value resistors is they don't provide enough current flow to keep the contacts clean.
--- End quote ---
This 330R is not a terrible idea, but not really necessary. If your inputs/output are all Vdd or lower, with a modern 3-5V micro you are not particularly likely to burn out a pin by accidentally making it an output and further accidentally connecting it to voltage rail anywhere between Vss and Vdd. You will just watch your output voltage sag to match the rail, and your micro will burn 20mA of power. With older 12V stuff, that would be a more legitimate concern. And even then, only if you're making a "12V arduino" for consumer edutainment.

--- Quote ---A low value of pullup resistor only conducts current when the switch is closed.  When the switch is open, the only current flow is the pin input current and that is VERY low.  Yes, you can go up to 10k and maybe higher.  I don't but it probably works.  1K almost always works.
--- End quote ---
If you have noise issues with 10K pullup, it's likely there's so much noise many modern micros won't function at all. And if there are issues that don't affect the micro, then you have a functioning micro. You can deal with bounce and/or noise with firmware. Not that it's always practical. Now if there's a 10 foot cable between your switch and your micro and it's wrapped around a motor, then you might have some noise. You can cross that bridge when you get there, and you will learn more.  And maybe if you have an impossibly clean button and can tap it fast enough to manually do I2C protocol, or something, then you need 1K pullup... or w/e is specified by the protocol for that bus or w/e value is dictated by the signal speeds you need for your application. For a physical switch to be pushed by a 200 lb gorilla (and limited in frequency by bounce, in case you are planning to use a button pushing robot), 50K is quite often as good as anything.

--- Quote ---ETA:  Why do we define unused pins as input?  Because if we have an 'oopsie' and short the pin to Vcc or Gnd, all it does is change an input signal that is never used.  If the pin were output, we stand a good chance of watching the magic smoke come pouring out of the chip.  Remember that 330 Ohm resistor?  It too helps with 'oopsies'.
--- End quote ---
Again, after you've removed the oopsies, then you can remove this nonsense from your BOM and costs and reduce your failure rate.

Furthermore, as long as the voltages the output pin are exposed to are no lower than Vss or higher than Vdd, I have had this type of failure roughly zero times. IME, it's only when driving a transistor that is sourcing voltage out of this range where a dead transistor kills the micro. If it's logic level stuff, the dead transistor is the only part that needs to be replaced (and potentially changed part numbers), IME.

OP, if you follow this advice, in particular regarding the 1K pullup and the 330R series resistor, make sure you are putting that 1K resistor on the output of the button (or other open drain/collector device). You should not put the 1K pullup on the micro pin, itself, as that would make your ViL (logic low input level) at around 1/4 Vdd. This is borderline. It's close to the limit between logic high and low for CMOS. That's for a switch that is tied to Vss. For the output of another IC that may have an allowable VoL up to 0.2V (3.3V) or 0.5V (5V), that puts your ViL squarely in grey territory. So to be clear, the pullup should go on the opposite side of the 330R series resistor from the micro.

You're already playing in a padded child-proof room with the Arduino platform. IMO, the first thing you do shouldn't necessarily be to add more padding and limitations to combat ghosts that aren't there. And if you break a couple eggs on the way to your first omelette, that's probably more efficient than stopping to learn how to pad your spoons.


[0] Message Index

[*] Previous page

There was an error while thanking
Go to full version