The art of capacitive touch sensing

Touch sensors have been around for years, but recent advances in mixed signal programmable devices are making capacitance-based touch sensors a practical and value-added alternative to mechanical switches in a wide range of consumer products.

Typical capacitive sensor designs specify an overlay of 3 mm or less. Sensing a finger through an overlay becomes increasingly more difficult as the overlay thickness increases. In other words, as the overlay thickness increases, the process of tuning the system moves from science to art. To demonstrate how to make a capacitive sensor that pushes the limits of today’s technology, the thickness of the glass overlay in this example is set at 10mm. Glass is easy to work with, readily available, and transparent so you can see the underlying sensor pads. Glass overlays also have direct application in so-called “white goods” (household appliances).

Finger Capacitance
At the heart of any capacitive-sensing system is a set of conductors which interact with electric fields. The tissue of the human body is filled with conductive electrolytes covered by a layer of skin, a lossy dielectric. It is the conductive property of fingers that makes capacitive touch sensing possible.

A simple parallel plate capacitor has two conductors separated by a dielectric layer. Most of the energy in this system is concentrated directly between the plates. Some of the energy spills over into the area outside the plates, and the electric field lines associated with this effect are called fringing fields. Part of the challenge of making a practical capacitive sensor is to design a set of printed circuit traces which direct fringing fields into an active sensing area accessible to a user. A parallel plate capacitor is not a good choice for such a sensor pattern.

Placing a finger near fringing electric fields adds conductive surface area to the capacitive system. The additional charge storage capacity added by the finger is known as finger capacitance, CF . The capacitance of the sensor without a finger present is denoted as CP in this article, which stands for parasitic capacitance.

A common misconception about capacitive sensors is that the finger needs to be grounded for the system to work. A finger can be sensed because it can hold a charge, and this occurs if the finger is floating or grounded.

PCB Layout of the Sensor
Figure 1 shows the top view of a printed circuit board (PCB) which implements one of the capacitive sensor buttons in this design example.

Figure 1. Top view of PCB

The button diameter is 10 mm, the average size of an adult fingertip. The PCB assembled for this demonstration circuit contains four buttons with centers spaced 20 mm apart. The ground plane is also on the top layer, as shown in the figure. The sensor pad is isolated from the ground plane by a uniform gap. The size of the gap is an important design parameter. If the gap is set too small, too much field energy will go directly to ground. If set too large, control is lost over how the energy is directed through the overlay. The selected gap size of 0.5 mm works well for directing the fringing fields through 10mm of glass overlay.

Figure 2 shows a cross-sectional view of the same sensor pattern.

Figure 2.

A via in the PCB connects the sensor pad to the trace on the bottom side of the board, as shown in the figure. The dielectric constant, εr , influences how tightly the electric field energy can pack into the material as the field tries to find the shortest path to ground. Standard window glass has an εr of around 8, while the FR4 material of the PCB has an εr of around 4. Pyrex glass, which is commonly used in white goods, has an εr r of around 5. In this design example, standard window glass is used. Note that the glass sheet is mounted on the PCB using the nonconductive adhesive film 468-MP from 3M.

Capacitive sensing 101
The fundamental components of a capacitive sensing system are a programmable current source, a precision analog comparator, and an analog mux bus that can sequence through an array of capacitive sensors. A relaxation oscillator functions as the capacitance sensor in the system presented in this article. A simplified circuit diagram of this oscillator is shown in Figure 3 .

Figure 3. The Relaxation Oscillator circuit.

The output of the comparator is fed into the clock input of a pulse width modulator (PWM) circuit, which gates a 16-bit counter clocked at 24 MHz. A finger on the sensor increases the capacitance, thus increasing the counts. This is how a finger is sensed. Typical waveforms for this system are shown in Figure 4 .

Figure 4. Waveforms of the “CapSense” Relaxation Oscillator circuit.

A schematic for an implementation of this project is shown in Figure 5 .

Figure 5. Schematic for the capacitive sensing circuit

For capacitive sensing and serial communication, the circuit uses a Cypress CY8C21x34 series PSoC IC which contains a set of analog and digital functional blocks which are configured by firmware stored in on-board flash memory. A second IC handles RS232 level-shifting to provide a communications link to a host computer, enabling data logging of capacitive sensing data at 115,200 baud. The pin assignments for the four capacitive sensing buttons are shown in the table in Figure 5. The PSoC is programmed through the ISSP header that contains power, ground, and the programming pins SCL and SDA, while the host PC connects to the capacitive sense board through a standard DB9 connector.

Tuning the sensor
Every time the “start scan” function is called in the application program, the capacitance of Button1 is measured. The raw count values are stored in an array. The user module also tracks a baseline for the raw counts. The baseline value of each button is an average raw count level computed periodically by an IIR filter in software. The update rate for the IIR filter is programmable. The baseline enables the system to adapt to drift in the system due to temperature and other environmental effects. A switch-difference array contains the raw count values with the baseline offset removed. The current ON/OFF state of the buttons is determined using the switch difference values. This allows the performance of the system to remain constant even though the baseline may be drifting over time. Figure 6 shows the transfer function between difference counts and button state that is implemented in firmware.

Figure 6. Transfer function between difference counts and button state

The hysteresis in this transfer function provides clean transitions between ON and OFF states even though the counts are noisy. This provides a debounce function for the buttons. The lower threshold is called the Noise Threshold, and the upper threshold is called the Finger Threshold. Setting of the threshold levels determines the performance of the system. With very thick overlays, the signal-to-noise ratio is low. Setting the threshold levels in this kind of system is challenging, and this is part of art of capacitive sensing.

An idealized raw counts waveform for a three-second button press is shown in Figure 7 , along with the threshold levels.

Figure 7. Placing the threshold levels on a plot of raw counts with the baseline removed.

The Noise Threshold is set to 10 counts, and the Finger Threshold is set to 60 counts. (The noise component that is always present in real count data is not shown in the figure, so that the threshold levels can be seen clearly.)

Part of the tuning process includes selecting the level of the current source DAC and setting the number of oscillator cycles to accumulate counts. The firmware sets current source to level 200 out of 255, which in low range of current source, about 14 microamps. It also sets the number of oscillator cycles to 253. Analysis of the raw counts and difference counts shows that the system has a parasitic trace capacitance, CP , of around 15 pF, and a finger capacitance, CF , of around 0.5 pF. The finger changes the total capacitance by around 3%. Acquisition of each raw count value only takes 500 microseconds per button.

Measured Performance
The measured performance of the capacitive sensing system is shown in Figure 8 .

Figure 8. Measured performance of the sensor through 10 mm of glass

The difference counts were captured on the host PC via a terminal emulation program, and then plotted with using a spreadsheet. The finger is placed on the 10-mm thick glass overlay for three seconds. The ON/OFF state of the buttons is superimposed on the raw counts. The button transitions cleanly between states, even with the relatively noisy raw-counts signal produced by the sensing through the thick glass. Note how the finger and button threshold are adjusted periodically as the baseline drifts. When a finger press is sensed, the baseline value locks its value until the finger is removed.

Figures 9 and 10 show detail views of each state transition.

Figure 9. Close-up of transition to ON state

Figure 10. Close-up of transition to OFF state

In figure 9, the button state is initially OFF. The first sample of the difference count over the finger threshold transitions the button state to ON. In figure 10, the button makes a transition to the OFF state with the first sample of the difference count below the noise threshold.

The primary advantage of capacitance-based touch sensors over mechanical switches is that capacitance-based touch sensors do not wear out through long-term use, as do mechanical switches. Recent advances in mixed signal technology have not only brought down the expense of touch sensors to the point where they are cost-effective to implement in a wide range of consumer products, but also enable higher sensitivity and reliability of sensing circuits to increase overlay thickness and durability. Using the design techniques presented here, it is possible to sense a finger press through 10 mm of glass, as well as achieve clean transitions between ON and OFF button states using the debounce method based on noise and finger thresholds, making capacitive touch sensors a practical alternative to mechanical components.

About the author
Mark Lee is a Senior Application Engineer at Cypress Semiconductor Corp, San Jose, CA.

0 comments on “The art of capacitive touch sensing

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.