0
\$\begingroup\$

If I understand correctly, few microcontrollers offer internal pull down resistors on their input pins but almost all allow for internal pull up resistors to be configured.

Why exactly is that ?

I understand that for a push button scenario, we can implement logic to interpet

  • 0V = ON (button pressed)
  • 5V or disconnected = OFF (button not pressed, internal pull up activated)

But what if the input is coming from an external system that you cannot control where the following logic needs to be implemented

  • external system is not connected (floating) on the input : should translate to OFF
  • external system is providing 0V on the input : should translate to OFF
  • external system is providing 5V on the input : should translate to ON

In this case you need some kind of active-high setup, but for that the internal pull up gets in the way (as a floating value should not be considered HIGH).

Wouldn't it be useful in such a case to have an internal pull down resistor on the input ?

I could implement this by disabling the internal pull up and use an external pull down resistor by connecting the input to GND via the pulldown.

But can this also be achieved in some way without using an external pull down ?

\$\endgroup\$

3 Answers 3

3
\$\begingroup\$

Following controllers have pull-down resistors (not a complete list and not every variant was looked at, so there might be exceptions):

  • STM32 family
  • MSP430
  • ATxmega
  • PIC24 has change notification pins with pull-downs
  • PIC32
  • NXP LPC800 (their smallest, so I'd say the bigger ones have it as well)
  • ...

So I'd say there are a lot of options to get a controller with pull-down resistors integrated. Only the very low end seems not to integrate pull-down resistors, which makes sense as they are very cost sensitive. Oddly enough is that AVR chose not to integrate them into their UC3 series.

If you have absolutely no choice to switch over to a MCU with pull down resistors, then you could hook it up to an analog input pin and read the voltage with the ADC. A floating pin should give you varying values, if it is grounded or pulled high the variance should decrease drastically and in theory the value should read a solid min or a solid max of the ADC. I've not tried this in practice, but I guess you have to take multiple readings and it might not be 100% reliable.

If your controller has no ADC, then I'm out of my wits, I was thinking something like maybe set the pin to output low, then switch to input and read back the value. But if the switch is providing 5V you will have a short, so that's a bad idea. Maybe it could work when the switch is not a low resistance connection to 5V. My idea behind it was to use the parasitic capacitance of the trace to store the low voltage for a short time before it starts to float at some level again and trigger the input high. If the switch is connected you would read back a high. But that is also quite a speculative approach and has to be tried out.

Still leaving a input pin floating is a bad idea in itself, so I'd say just go for that resistor or switch to one of the MCUs available with pull down resistors.

\$\endgroup\$
6
  • \$\begingroup\$ It involves units that are already out in the field. On some units a free input will be hooked up to such an external system. A SW update would be pushed to all units. So we need to take into account that on some units the input would be floating. I was looking for a solution that wouldn't involve patching all units with an external pull-down resistor to handle the floating scenario. \$\endgroup\$
    – ddewaele
    Sep 2, 2015 at 9:15
  • \$\begingroup\$ I can activate the internal pullups with a SW patch, but that would mean that the external system would need to reverse its logic (sending 0V means ON , sending 5V means OFF) \$\endgroup\$
    – ddewaele
    Sep 2, 2015 at 9:19
  • \$\begingroup\$ @ddewaele While it is nice to have a general question, if you have a specific problem it's better to ask a specific question. In this case it would be helpful to know which controller you are using - there might be quirks in it you can exploit. And you have left the input floating on units in the field? \$\endgroup\$
    – Arsenal
    Sep 2, 2015 at 9:26
  • \$\begingroup\$ Thx ... I'll create a more specific question. inputs have been left floating in the field yes. \$\endgroup\$
    – ddewaele
    Sep 2, 2015 at 13:43
  • \$\begingroup\$ More specific question : electronics.stackexchange.com/questions/188623/… \$\endgroup\$
    – ddewaele
    Sep 2, 2015 at 15:18
0
\$\begingroup\$

I am sure there will be a more complicated way of achieving this without an external pull down resistor, but a simple resistor would be sufficient in most cases. The designers of the chips must make decisions on the benefits compared to the extra complexity of adding pull up/down resistors and their controlling circuity. Pull ups will cover the majority of cases and where they don't, you can add your own pull down.

\$\endgroup\$
2
  • \$\begingroup\$ I assumed that the situation I'm describing with the external system would be very common, so I found it strange it cannot be done out-of-the-box. \$\endgroup\$
    – ddewaele
    Sep 2, 2015 at 9:11
  • \$\begingroup\$ As @Arsenal has stated, some processors have the option of pull downs. There is always going to be a need for additional circuitry when using a processor. If you wanted an LED on an output, you wouldn't expect the processor to have built in LEDs (I wouldn't anyway). \$\endgroup\$
    – HandyHowie
    Sep 2, 2015 at 9:22
0
\$\begingroup\$

If you are asking how to detect an actual open circuit pin there is a way to do that, but you still need to add an extra resistor.

On the pin that might have an open circuit place a high value resistor from that pin to another output pin. Toggle the output pin high then low and read the value of the input pin each time. If the input pin follows the high low signal then the input line is most likely open. (Note that the resistor used here needs to be significantly higher then the expected impedance of the possible input signal.)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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