Electronic – Detecting touch using electrical noise on microcontroller pin

capsensemicrocontrollernoisesensor

I have recently been experimenting with detecting touch on a microcontroller digital input pin using the following method:

  1. Put pin in output mode
  2. Drive the pin high
  3. Put the pin in input mode
  4. Time how long it takes for the pin to switch state from electrical noise.
  5. 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:
enter image description here
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:

  1. Is my understanding of the system correct?
  2. 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?)

Best Answer

An interesting experiment, but there are a few reasons not to rely on this kind of touch-sensing.

  • A CMOS logic gate can suffer from high shoot-through current when input voltage hovers somewhere near half-Vdd.
  • A human antenna boosts noise input to a gate's input, but random noise strength varies over many orders-of-magnitude, making a reliable design quite difficult.

  • Chip manufacturers often specify I/O leakage currents very loosely.
    Might have only an upper limit of one microamp, but could alsobe sub-nanoamp (and most often is very low).

  • A gate input sensitive enough to work with a weak noise source is susceptible to strong nearby noise source. Would you like your touch-sensitive keyboard to spit random characters when a nearby appliance turns on or off, or when you sweep your charged body-part nearby?

Some manufacturers design input pins for this kind of use, but rely on a locally generated signal source rather than an external noise source.