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?)
  • \$\begingroup\$ Is the human behaving as an antenna or as a large capacitor? What happens if you ground the hand relative to the circuit first? Do you know how capsense works? \$\endgroup\$ – Roger Rowland Jun 19 '17 at 6:28
  • \$\begingroup\$ In capacitive sensing, the time taken with the human touching is greater than the time without a human touching as the human increases capacitance. (in my understanding of capacitive sensing). In this case, the time for the pin to switch state is shorter. In my testing with this system it does not matter whether you pull the pin high or low to begin with. It does not matter if the person is grounded or not. This leads me to conclude that it is noise driving the voltage switch. \$\endgroup\$ – sdfgeoff Jun 19 '17 at 7:27
  • \$\begingroup\$ Atmel QTouch \$\endgroup\$ – JimmyB Jun 19 '17 at 10:15
  • \$\begingroup\$ @JimmyB: Interesting to see that someone else has made this reliable. But my aim for this was to detect touch without external hardware. \$\endgroup\$ – sdfgeoff Jun 19 '17 at 10:28
  • \$\begingroup\$ What do you mean by "without external hardware"? Do a capacitor and a copper area somewhere qualify as "external hardware"? \$\endgroup\$ – JimmyB Jun 19 '17 at 10:33

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.