Two-element capacitative touch sensor

As a distraction from my real project -- building a lightbulb alarm clock for the coming winter -- I've been playing with capacitative sensors. My first effort was a wire taped to a piece of metal foil, and that worked OK. The present iteration is a two-element touch sensor on a milled circuit board.

The sensors are each about 1" by .5" and are connected to the arduino by a 3-pin header. The components on the board are very simple -- two 1M resistors. With a combination of software running on the microcontroller and in the PC, the sensor is made into a virtual slider.

The principle of operation is simple: placing a fingertip near the copper pad -- and the far side of the circuit board is close enough -- changes the capacitance enough to measure. The measurement procedure is as follows:

  1. The pin is discharged to close to 0V by setting the sense pin to an output and putting a logic LOW on it.
  2. The pin is changed to input mode and a 1M pull-up resistor is enabled.
  3. A tight loop counts the number of iterations until the pin reads HIGH.
  4. After reading both sensors in this way, transmit both sensor counts to the PC.
The measurement procedure is repeated approximately 10 times per second. (it could run much faster, easily up to 100Hz)

In my setup, this gives a value typically from 16 iterations (no nearby finger) to 24 iterations (finger pressing on top side of sensor board). A 200-item window of past samples is taken, and that furnishes the minimum and maximum touch values. When a sensor value higher than the minimum value is seen on at least one sensor, a touch is registered. If the touch is only on one sensor, then the slider is 0% or 100%. Otherwise, it is an intermediate position indicated by the ratio between the two sensor values.

One interesting thing about the board is that I milled the holes only part way through, and just stuck the "through hole" components into the blind holes before soldering them. This way the touch surface is completely uninterrupted.

This approach can be expanded to more pads, taking (N+1) I/O pins. I'm presently toying with making an 8-pad board run by a dedicated avr.

Files currently attached to this page:

cap.pde515 bytes
cap.py1.7kB



Entry first conceived on 29 August 2008, 0:49 UTC, last modified on 15 January 2012, 3:46 UTC
Website Copyright © 2004-2017 Jeff Epler