For sure, a not connected analog input reads nonsense.
Picture 1 shows my circuit and as long as A and B are connected there will be no floating signal. If it is not, the analog input measures ~1,2 V instead of 0. Nothing new. But driving a motor with that signal in case I got a broken connection is critical.
First thought: Connect a pulldown resistor to the analog input is a bad idea, because I get a voltage divider.
Picture 2 shows the same circuit with a diode and if A and B is not connected there is no floating?!
My quesiton: Why does it work? I mean the diode shouldn't have changed anything?!
Threadrag:
For sure, a not connected analog input reads nonsense.
Picture 1 shows my circuit and as long as A and B are connected there will be no floating signal. If it is not, the analog input measures ~1,2 V instead of 0. Nothing new. But driving a motor with that signal in case I got a broken connection is critical.
First thought: Connect a pulldown resistor to the analog input is a bad idea, because I get a voltage divider.
No, that's the price you must pay, but its not a big price, just use a 1M resistor in parallel with 100nF, hardly
any effect on the voltage from a 10k pot
Picture 2 shows the same circuit with a diode and if A and B is not connected there is no floating?!
My quesiton: Why does it work? I mean the diode shouldn't have changed anything?!
No it doesn't work, unless the diode is faulty, (such a diode is already present in the microcontroller anyway,
since the analog inputs have input protection diodes). A reverse biased silicon diode at room temperature is an
open-circuit (for all practical purposes). You may be seeing the effect of the junction capacitance of a discrete
diode being much bigger than that of the on-chip protection diodes.
No the diode is not faulty. Current flows from anode to cathode and the diode blocks from cathode do anode. I tested it with my multimeter.
jremington:
A diode is a low impedance path in one direction, but it is not a good solution to the problem.
Yes, but the diode is installed the other way around with positive voltage at cathode and ground at anode, so current cannot flow.
MarkT:
You may be seeing the effect of the junction capacitance of a discrete diode being much bigger than that of the on-chip protection diodes.
Yes that might be the reason. Because I used a 5 mm LED to test it. And that's a hughe diode compared to the IC's diode.
MarkT i will test the 1M resistor and 100nF combination. Thank you for the advise. Because my 10K pull down resistor does work for all circumstances, but not if the pot loses ground. Then I have my voltage divider and wrong values for my input.
If you want a fail-safe design you'll have to measure the current through the pot ground wire too, then
if that gets detached you can take action. Or add some series resistance at the Vcc side of the pot, if the
ground wire is detached the wiper rises above the normal maximum voltage and this can be spotted - there
are various ways of detecting open-circuits like this, but you will need to monitor two or more voltages.
1M resistor and capacitor works very well. Additional monitoring is not what I like to do and i don't need it. I use only about a 10th of the resolution. If the pot loses ground isn't noticed. Great!