How to differentiate between floating input and connected to ground using logic? - Page 1
Forum section: electronics / beginners

author: qat
author_rank: Contributor
timestamp: June 18, 2020, 02:44:59 pm
content: I'll get right to the point.I have an input to a circuit that can either be high (+3V3), ground, or it can be disconnected i.e. floating.If the input is high (switch open) then the output should be low, if the input is ground (switch closed) then the output should be high, and if the input is floating the output should also be low.Basically this circuit will be used to trigger the Enable-pin of a switching regulator which boosts the +1V0 from a single battery cell to +5V to operate a signal processor. Preferably, the circuit should work even if the +1V0 fluctuates between +0.8V and +4.5V (above the +3V3!) if other battery chemistries are used but this is not a requirement.The switch and input is part of an external circuit and cannot be changed apart from adding resistors to it, but the resistance to ground when the switch is closed must not exceed 100 Ohms. I would prefer not using a microcontroller and sticking to a few logic and discrete components that can operate at +0.8V unless it is absolutely impossible not to in order to complete this circuit.Thanks in advance for any ideas of how to solve this!

author: sahko123
author_rank: Frequent Contributor
timestamp: June 18, 2020, 03:17:39 pm
content: Im thinking if you need to detect 3.3v, GND, or floating you could have a resistor. One end of the resistor connected to Vcc and the other to the pin that need detection. If the pin goes high (3.3v) current will flow to Vcc (1V0) if the pin is pulled to ground the current will flow from Vcc to ground and if the pin is floating no current will flow in either direction. If you can sense the direction of the current you could tell if the pin is high or low and if you have a NAND gate at those two outputs when neither of them is ON that means there is no current flowing which in turn means that the pin is flowing.

author: qat
author_rank: Contributor
timestamp: June 18, 2020, 08:40:13 pm
content: I think I might have solved it by using a resistor between +1V0 and +3V3 like you suggested, but a slightly different overall configuration using a diode as well. The resistor would prevent the battery being shorted to ground when the switch is closed, and the diode would prevent current flowing from +3V3 into +1V0 when the switch is open. If +3V3 is disconnected current would flow from +1V0 into an inverter which would produce a logic low, and if either the +3V3 or the +1V0 connected to it is pulled low via the switch the inverter would output high. Not sure if the diode is necessary though.Schematic:https://imgur.com/a/fLVewlN

author: westfw
author_rank: Super Contributor
timestamp: June 23, 2020, 10:12:27 am
content: If the pin is floating, it will retain a charge that you output to the pin for a while after you switch the pin back to input. If it’s connected to logic, even by the moderate value resistor you added to keep from exceeding currents when it’s connected to another output...So: set pin to input, read value.Set pin to output, write -value.Set pin Back to input, and read it again. If it has value, then it is probably actually connected to a pin outputting “value.” If it still has -value, the its probably floating.