I have recently been experimenting with detecting touch on a microcontroller digital input pin using the following method:
- Put pin in output mode
- Drive the pin high
- Put the pin in input mode
- Time how long it takes for the pin to switch state from electrical noise.
- Filter the value and look for large increases or decreases in time (presumably this is when the user touches the pin).
In brief testing, this time taken for the pin's state to change is several thousand times shorter when a person is touching the pin. With a small demo application toggling an LED, in a relatively low-noise, residential environment it works reliably.
So now I am attempting to understand what the system is, and how it works. I believe the system is: When the human touches the pin, they act as an antenna, increasing the electrical noise going into the pin, and decreasing the time it takes for the parasitic capacitor to change state.
I also believe the voltage on the pin will follow brownian motion, and meander from one state to the other (this is because the capacitor is integrating the white electrical noise). However, without an oscilloscope I have been unable to actually see what the pin voltage is doing.
My Questions Are:
- Is my understanding of the system correct?
- What are the disadvantages and limitations of the system?
Some Limitations I can see:
- Susceptible to spikes in environmental noise (eg turning a microwave on).
- Static electricity from touching the pin may cause damage to microcontroller (Possibly ground the hand relative to the circuit via enclosure?)