Electronic – Two-way voltage limiting circuit to protect microcontroller

microcontrollertransistors

I am making a device with a micro controller that has a single exposed pin that needs to be able to function as either an input or an output based on the software. When in OUTPUT mode, there has to be at least 1kΩ impedance so it can't get shorted. When in input mode, I have to limit the incoming voltage. The external voltage could be ±10 V but the micro controller can only handle 0 – 5 V. This port will carry a digital signal so it does not need to care about the analog value. It just needs to transmit HIGH and LOW states effectively (around 0 V and 5 V).

My current solution looks like this:

schematic

simulate this circuit – Schematic created using CircuitLab

It works perfectly in OUTPUT mode, and it is almost perfect in INPUT mode, as long as the input is capable of sinking current. But, if I leave the input floating, the micro controller's side is pulled HIGH (I want it to be LOW by default).

My first thought was to add a pulldown resistor on the input, but it then works as a voltage divider in OUTPUT mode, reducing the voltage. If I put a small enough pulldown resistor to counteract the pullup force on the microcontroller side, then the output is reduced enough to no longer register as "HIGH".

Is there any relatively simple way I can fix this problem? Or is there a better type of circuit to use for this purpose? Maybe something based on diodes would be simpler?

Thanks for your help!

Best Answer

Maybe something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

This typically clamps at about -300mV/5.1V and does not depend on the 5V supply sinking current.