How to size external pull up resistor? - Page 1
Forum section: electronics / general

author: pacmann
author_rank: Contributor
timestamp: April 28, 2023, 08:54:59 am
content: How do you size the external pull up resistor that connects to a GPIO input? The other side is an open drain comparator to indicate if a cable is connected, not high speed switching. Does it depend on microcontroller GPIO properties?

author: peter-h
author_rank: Super Contributor
timestamp: April 28, 2023, 10:24:52 am
content: Yes; check the CPU data sheet for any permanently connected pullups or pulldowns, and check your init code to see whether any of these are being enabled by software. If you can enable a pullup in software, you may not need one externally (although the internal ones tend to have a really wide tolerance).Apart from the above, your external resistor can be almost any reasonable value, within limits of leakage. Use whatever resistor you have lots in stock, like 100k

author: Picuino
author_rank: Super Contributor
timestamp: April 28, 2023, 10:28:20 am
content: 10k Ohm works well and does not draw too much current. If you want higher rise speed, put a smaller resistor.

author: jpanhalt
author_rank: Super Contributor
timestamp: April 28, 2023, 10:45:55 am
content: As for value, if your MCU shows typical current for an internal weak pull-up (WPU), you can calculate the equivalent resistance. For PIC's, that current is given. For example, if the WPU current is 100 uA at 5V = 50k. That's an "equivalent" resistance and doesn't mean the MCU actually uses a resistor. It's my understanding it may actually be a mosfet (https://electronics.stackexchange.com/questions/109074/internal-pullup-for-input-in-pic-microcontroller)You can also look at the impedance of an input and use that to calculate how much current you want the pull-up to allow. Of course, lower values may be needed depending on the purpose. For example, I2C would likely need something lower than 50k to 100k.

author: Siwastaja
author_rank: Super Contributor
timestamp: April 28, 2023, 04:41:32 pm
content: Things to consider* Noise immunity (higher the R, higher the coupled noise voltage)* Switching speed (higher the R, slower the charge of parasitic C)* Margin for low level logic threshold (the lower the R, the higher the voltage when transistor is pulling it to GND because transistor has on-state R, say ~50 ohms for an open drain IO pin)* Power consumption (during low state, I = U/R)TLDR:Hundreds of k for battery operated things (careful with noise and speed).4.7k - 10k general purpose1k high speed I2C etc. (lower than that and '0' state voltage quickly becomes a problem)

author: SiliconWizard
author_rank: Super Contributor
timestamp: April 28, 2023, 06:15:15 pm
content: TLDR: it depends.

author: temperance
author_rank: Super Contributor
timestamp: April 29, 2023, 12:25:07 pm
content: And in case of mechanical contacts such as connectors and switches, the minimum wetting current should be considered.

author: Zero999
author_rank: Super Contributor
timestamp: April 29, 2023, 01:21:51 pm
content: Quote from: temperance on April 29, 2023, 12:25:07 pmA small capacitor in parallel, say 100nF, can help with that.