3

What happens if a sketch uses code like pinMode(18,INPUT_PULLDOWN) to configure internal pull-down (or pull-up) resistors, but is used in a circuit where external resistors are also present?

Are there likely to be any problems, conflicts or unexpected behaviour, e.g. if software sets a pull-down, but there is an external pull-up, or visa versa?

I am using an ESP32 (which has both internal pull-ups and pull-downs available on most GPIO pins), but I would appreciate a general answer. To clarify, I am not after the pros and cons of using external resistors (which is discussed in other questions), but the potential pitfalls of using both, especially if they are pulling in opposite directions.

4

The main risk if you use both internal and external pullup/down resistors working in opposite directions is that the input will be left at an intermediate voltage that is not guaranteed to be read as high or low. Furthermore a little noise on the input might flip a read from high to low or vice versa. There is no risk of damaging the input however

1
  • It is dependent on the value of the resistors. The "resistors" in microprocessors are generally of a high value and have a large value tolerance. Sometimes it is desirable to hold a pin in a specific state until the system initializes it to possibly a different state. – Gil May 31 at 3:15
1

It is actually beneficial for the chip to have an additional pull-up or pull-down. It can help to reduce noise and to protect from ESD on the pin coming in. The internal resistors can only take a very small amount of current and an external can take some of the current in case an ESD event is happening. The downsides of an external resistor are (not complete list):

  • space requirements
  • cost (although very low cost)
  • slightly increased power consumption

If these are not a problem for you, an external resistor is a good idea.

Here is a video (not me), that explains the ESD-part it in more detail.

EDIT: I just re-read your question and saw that you asked about mixing pull-up and pull-down. That you should normally not do as jksemple said.

1

When you add the external resistor it will be connected to the internal pull resistor (up or down) depending on configuration. The pull resistor will either be series or parallel with the external resistor. In series it will behave as a voltage divider, in parallel it will increase the current required to cause the pin to change state. Mixing will not harm the computer as the pull resistor is designed to be connected to the opposite polarity externally. With the data sheet and the value of your resistor you can calculate the current and or voltage. You do not want to use external pull up and pull down resistors on the same pin. It may work but it is best to do the calculations to see if it will give you a viable value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.