Electrical – How to check if pin is floating or connected to ground

dcfloating

I am using a DC jack which has 3 pins. 2 for power and one pin which is connected to ground when there is nothing plugged into the jack and disconnected from the ground when the jack is plugged in.

I need a way to know wheater the jack is plugged or floating(ie. is this pin connected to ground or floating).
I was thinking about large pull-up resistor from that pin to the positive voltage, but still unsure about that. It would create small current flowing from gnd through a resistor to positive voltage. Is that okay stuff to do in a system?

I am using LM393 to detect this voltage. Can't figure out what resistor value to choose. Positive voltage is at 17V, so 47K resistor would result in 0.36mA leak – not little and still unsure if LM393 would detect it.

(jack input is not only power input, there are batteries inside, so current would flow through this resistor on all times when jack is not plugged – draining the battery).

Are there any better ideas than pull-up resistor?

Best Answer

To expand on @Jon's answer, something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

95% of the current is consumed by the comparator (lower power ones are available).

R2/R3 set up a reference voltage of about 8.5V. When the switch is closed the voltage on the inverting input is about 2.8V and the output is high. When the switch is open the voltage rises to about 17V and the output is low. Response time is about 20ms (open) or 5ms (close).