Can this active-high scenario be achieved without an external pull down resistor

pulldownpullup

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 ?

Best Answer

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.