Techniques for Robust Touch Sensing Design

By Burke Davison

Contributed By Digi-Key Corporation


Capacitive touch sensors operate in noisy, challenging environments. Careful attention to hardware and software design techniques can significantly increase design reliability.

The purpose of this article is to describe the best design practices when developing capacitive touch applications in noisy environments. It will begin by defining the problems caused by noise, and explain how that noise typically affects systems. Hardware guidelines will be provided to help maximize the natural signal-to-noise ratio (SNR) of the application. The software techniques which will be covered describe some of the common methods used to filter a sensor's signal to further increase the SNR and to make a decoding decision based on the behavior of the capacitive sensor.

The hardware design topics covered are:
  1. Selecting a sensor size.
  2. Determining the sensors' separation.
  3. Covering material thickness.
  4. Using ground planes to your advantage.
  5. Designing the sensors' layout.
  6. Selecting an adhesive.
  7. Using series resistance on sensors.
  8. Choosing VDD to maximize noise immunity.
mTouch™ sensing solution systems have passed industry test standards in conducted noise, radiated noise, and radiated susceptibility. This article describes the important aspects of capacitive touch design which, when coupled with good PCB techniques, will allow these systems to continue performing in these extreme testing conditions.

For information on the basics of capacitive touch sensing and other more advanced topics, visit the Microchip web site.


Basic capacitive touch review

Capacitive sensors are areas on a PCB that have been filled with copper and then connected back to the PIC® device using a trace. The PIC device measures the sensor in a manner that allows detection of small shifts in capacitance. This capacitance is continuously read in software and, when a change occurs, the system will register a press on that sensor.

There are two main methods for detecting a shift in capacitance using a PIC device. The first method involves using a voltage measurement. The system places a specific known voltage on the sensor and looks for a shift in the amount of voltage on the sensor. This includes methods such as Microchip's Charge Time Measurement Unit (CTMU) and the Capacitive Voltage Divider (CVD). The alternative is to measure the sensor using a frequency approach such as the Capacitive Sensing Module (CSM). This method uses a fixed current source and a comparator to create a circuit that changes frequency based on the capacitance seen at the sensor. The waveforms for all three scanning methods can be found in Figure 1.

This article will focus on the hardware design of the system and the sections of firmware not involved in signal acquisition. With only a few exceptions, the signal processing portion of the firmware will be identical regardless of the sensing method chosen.

Figure 1

Figure 1: mTouch sensing acquisition method waveforms.

Noise immunity versus low power

When developing a capacitive touch system, it is important to know what your main goal should be from the very start of product development. For the majority of applications, how the system is powered will answer this question.

For line-powered systems, conducted noise immunity is the main concern. Voltage-based acquisition methods should be used. For battery-powered systems, low power is the main concern. Both voltage-based and frequency-based methods can be implemented in these applications. It is also possible that some systems may overlap between these two regions. A cell phone with the option of being powered through a USB cable is one example. The majority of the time the phone would be concerned with low power; however, it needs to be careful of conducted noise when being powered through the main line. For this reason, only voltage-based acquisition methods should be used in these systems.

While noise immunity and low power are not mutually exclusive, focusing on one will require that design trade-offs be made with regard to the other. For example, implementing a slew rate limiter filter to reduce susceptibility to conducted noise will require increasing the sample rate of the system which will increase the overall power consumption. Lowering VDD is an excellent idea in low-power applications, but doing so will also decrease noise immunity (see the Hardware design consideration #8 section later in this article). This article focuses on decreasing noise susceptibility and treats low power as a secondary goal. If low power is the main goal of the application, visit www.microchip/en_us/technology/xlp for more technical details.

Effects of noise on capacitive touch sensors

Mechanical buttons versus capacitive sensors

Before considering how to develop a robust capacitive touch application, it is important to understand the fundamental reason why noise is a concern. When using a mechanical button, the microcontroller's port circuitry decides whether the switch's pin is being pulled high or low and provides a single-bit, digital result to the user. This result is then debounced to adjust for ringing, and the state of the button is based on the state of the debounce variable.

Capacitive touch sensor applications, however, are analog. The first clear difference is the need to manually perform the reading process. When using a mechanical switch, the microcontroller is able to read the pin using its internal hardware logic. For capacitive touch applications, separate hardware modules need to be used to manipulate the sensor line. Whether using a voltage-based measurement or a frequency-based measurement, the analog result will be provided in the form of an integer value. This value is typically filtered using different digital signal processing techniques to amplify the signal and attenuate the noise. The filter value is sent through some form of debounce algorithm and a more complex decoding process. An extra layer of complexity is added when the system is designed to perform in a closed loop manner, adjusting its behavior based on the sensor's current state.

The capacitive touch software process can be simplified into three distinct phases:
  1. Acquisition - using a voltage-based or frequency-based measurement technique to obtain a sample from the capacitive touch sensor.
  2. Filtering - manipulating the incoming sensor samples to increase the effective SNR of the system by attenuating the noise.
  3. Decoding - determining whether a sensor is pressed or released, based on the current value of the sensor samples and the sensor's previous behavior.
Figure 2(a) illustrates the difference between push buttons and capacitive touch sensors, and labels the three main software stages of a capacitive touch system.

Figure 2a

Figure 2a: Mechanical button versus capacitive touch sensor software process.

The difference between digital and analog results can also be seen in Figure 2(b). The push button is always in one of three states: high, low, or ringing from a recent transition. The capacitive touch sensor does not perform in the same way due to its analog result. Instead, it is able to drift and move. When noise is injected on the sensor, it affects the quality of the readings, not just the time required to make a state transition.

Figure 2b

Figure 2b: Mechanical button versus capacitive touch sensor signal noise behavior.

Conducted and radiated noise

Conducted and radiated noise are the two main classifications of injected noise that can create instability in capacitive touch systems.

Conducted noise is caused in systems that are powered externally from the device. This can include systems powered off the main line power, desktop-powered USB devices, or any other situation in which the user is not sharing a ground with the device.

Radiated noise is a common challenge across all capacitive touch systems. Since the capacitive touch sensor is a high-impedance input when being scanned, it essentially performs as a high-frequency antenna. Thus, electronic devices radiating electromagnetic fields near the capacitive touch system cause the readings to be affected. This can include cell phones, high-power communication lines, and fluorescent lights.

There are two main reasons that these two types of noise show up:
  1. When a user presses on a capacitive touch sensor, the user is becoming part of the system, so, if the user and the system are on different ground references, the system will interpret the user as an injected AC signal on the sensor.
  2. Analog readings are susceptible to outside forces pushing them slightly in one direction or the other. The digital result of a mechanical switch is either high or low.
This article will describe different system design techniques recommended to overcome these two noise types. In addition to these guidelines, designers should be aware of the future working environment of the application and ensure there are no excessively noisy electronics nearby that may interfere with the system.

Capacitive touch sensor noise behavior

Injecting noise on a capacitive touch sensor will cause the system to become more unstable. Voltage-based mTouch sensing solution reading methods such as CTMU and CVD will be affected differently than frequency-based reading methods such as CSM. In voltage-based systems, the voltage of the sensor at a specific point in time is what determines the integer value of the reading. In frequency-based systems, the effect on the readings will vary based on the frequency of the injected noise. For this reason, voltage-based acquisition systems should be used on any system concerned with conducted or radiated noise immunity.

In voltage-based systems, injected noise can cause a positive or negative offset away from the natural sample value. If the sampling rate falls on a harmonic of the injected noise, resonance can occur. When this happens, the samples are falling on the peaks or valleys of the injected noise. An example of this behavior can be seen in Figure 3. When sampling at one of these harmonics, the readings may all fall on the peaks of the noise or somewhere in the middle based on the starting time of the acquisition. Because of this, multiple readings at the same frequency will show a large amount of noise. This can be seen in Figure 4 where some of the noise frequencies are harmonics of the sampling rate and others are not.

Figure 3

Figure 3: Voltage-based harmonic acquisition example.


Figure 4

Figure 4: Example of a voltage-based acquisition noise behavior.

Given the knowledge of how the system will behave, some important hardware considerations that make development a faster and simpler process can now be defined.

Signal-to-noise ratio

First, in order to understand how hardware and software changes are affecting the system, it is necessary to have a way of measuring the current signal performance. Sensitivity, or the amount that the system shifts, is not a sufficient measure alone to define if a system is stable. For example, in a system where the average sensor output value is 20000 and a shift of 2000 is reached, you could simply subtract 18000 from each reading and claim a one hundred percent, 2000 count shift was achieved. In reality, however, the shift or "signal" must be compared with the amount of noise. If noise was causing the sensor to drift by 1000 counts at any point in time, the system is in trouble.

One of the easiest ways to determine how stable a system is, or how much the system is affected by noise, is to look at its SNR. Just as it sounds, this is a way of measuring how strong the signal is when compared to unwanted disturbances of noise.

For the purpose of this article, the SNR formula being used is:

Equation 1

Equation 1: Signal-to-noise ratio.

Where:
µU is the unpressed average
µP is the pressed average
σ is the unpressed standard deviation

The numerator of the equation is the amount that the system will shift when pressed. The denominator is a measure of how much the noise is able to affect the readings. Using these as a ratio, a single number can be used to describe the quality of the sensor's signal by answering the question: How much shift are you looking for compared to the amount of noise you are trying to avoid? An example SNR calculation is shown in Figure 5.

Figure 5

Figure 5: Example of an SNR calculation.

There are many other ways to calculate the SNR of a system. The important thing is to choose a method that provides consistent numbers across multiple measurements to ensure informed decisions can be made about which of the changes made are good and which are bad.

For reference, Figure 6 is provided to show an example of what a signal-to-noise ratio of one would look like using Equation 1. Note that since the standard deviation of the noise and not the peak-to-peak value is being used, an SNR of one leaves no safe place to put a threshold. To be able to place a fixed threshold on the system, so that the pressed section plus its noise is completely separated from the unpressed section plus its noise, a system with an SNR of at least 3.5 is needed.

Hardware design

The hardware design of a capacitive touch application is crucial to the system's overall success. The decisions made in this step of the process will determine how difficult it is to get a working, robust application. If the hardware design guidelines are followed, it will be significantly easier and faster to pass industry noise standards. Likewise, not following the guidelines will make success much more difficult and in some cases impossible. Keep this in mind while deciding which of these guidelines to follow in your future applications.

Figure 6

Figure 6: Example of a signal-to-noise ratio = 1.0.

The basic capacitance equation

The most important thing about hardware design is to remember that the basic capacitance equation, shown in Equation 2, defines the relationship between hardware design decisions and the resulting sensitivity of the system.

Equation 2

Equation 2: Capacitance/Sensitivity

Where:
C is the capacitance, or sensitivity
εr is the relative permittivity of the cover
ε0 is the permittivity of free space
A is overlapping area
d is the distance


For example, if the distance between the finger and the sensor is decreased by half, the sensitivity will double. If the area of the sensor is doubled (assuming it is still smaller than the area of a finger's press), then the sensitivity will also double. Another important characteristic of capacitive touch sensors is the existence of parasitic capacitance, CP. Equation 3 explains how CP, can affect a system's sensitivity. You are only able to take a measurement of the total capacitance on the sensor, CTOT, so the stronger the effect of CP the less you may be able to see CF, the change in capacitance due to a finger. This relationship is shown in Figure 7.

Equation 3

Equation 3: Total capacitance

Where:
CTOT is the total capacitance
CP is the parasitic capacitance
CF is the finger's capacitance


Figure 7

Figure 7: Diagram showing CF and CP.

Equation 2 and Equation 3 will be the basis of the hardware design guidelines for capacitive touch. The equations are simply physics.

The guidelines are recommendations that will attempt to maximize your system's base SNR and should be followed whenever possible. In some cases, an application may require that some of the guidelines not be followed. For example, a system might have size constraints or may require a thick covering material to protect it from damage. If this is the case, extra care should be taken to ensure a quality signal-to-noise ratio.

Hardware design consideration #1

Selecting a sensor size

Best option: The sensor size should be the same as an average user's finger press (15 mm x 15 mm or 0.6 inch x 0.6 inch).

Option 2: Design sensors are smaller than optimal. Effects:
  • Overlapping area, "A" in Equation 2, is limited, which reduces the maximum sensitivity.
  • Adequate sensor separation will become more important to minimize the amount of sensor crosstalk.
  • Use a thin cover to gain some extra sensitivity.
Option 3: Design sensors are larger than optimal. Effects:
  • Parasitic capacitance, "CP" in Equation 3, can increase because of the increased proximity to ground which reduces sensitivity.
  • Conducted noise disturbance is increased.
  • Press shifts will vary by larger degrees because small fingers will cause less of a shift than large fingers due to less overlapping area, "A" in Equation 2.
  • Proximity sensing capability is increased.
In Equation 2, "A" is defined as the overlapping area. For capacitive touch applications, this means that you are limited by the smallest capacitive plate. If the sensor is smaller than a finger press, the sensor area is the limiting factor. If the sensor is larger than a finger press, the finger is now the limiting factor.

You cannot change the user's finger size, but you can adjust the sensor size to maximize the sensitivity. The larger the sensor, the more parasitic capacitance will be able to lower the sensitivity and the more conducted noise will be injected into the system from a user press. The smaller the sensor the greater the chance that it is the limiting factor on sensitivity instead of the user's finger size. For this reason the ideal sensor size is about the area of a finger press.

Some exceptions to this rule do exist. Thick covers will lower the sensitivity of a sensor drastically, so slightly larger sensors may be warranted. There are also situations where the user's finger is not what you are trying to detect. For example, if you are designing a proximity sensor, and you are only interested in knowing when a user's hand is near the sensor, you could use a much larger sensor.

Hardware design consideration #2

Determining the sensors' separation

Best option: Separate sensors as often as possible. The ideal minimum separation is two to three times the cover's thickness. Effects:
  • The distance, "d" in Equation 2, between the sensors is kept high compared to the distance between the finger and the sensor, which results in reduced sensor crosstalk.
  • Parasitic capacitance, "CP" in Equation 3, is kept low compared to the finger's capacitance, "CF," which results in increased sensitivity.
Option 2: Create slotted air gaps in the cover. Effects:
  • The relative permittivity, "Er" in Equation 2, between the sensors is lowered to "one", which results in decreased coupling between the sensors, which in turn decreases sensor crosstalk.
Option 3: Use ground traces between the sensors. Effects:
  • The distance, "d" in Equation 2, between the sensor and ground is lowered, increasing the amount of coupling between sensor and ground. This results in a slight shielding effect and reduces the crosstalk between sensors separated by the ground.
  • However, this increases the parasitic capacitance, "CP" in Equation 3, which will reduce sensitivity.
Crosstalk can become a challenge in capacitive touch applications if covers are too thick or sensors are too closely placed together. Crosstalk is the unwanted shift to a different sensor from the one you are intending to press. If crosstalk is a problem in an application, the software must compare the two sensors and determine which sensor is "more pressed." This adds an extra step to the decoding process, increases the likelihood of error, and – depending on how it is implemented – can limit your system to one touch at a time. To include multi-touch in a "most pressed" system, you can change the algorithm to be a "two most pressed" configuration or you can physically separate one of the sensors that will be pressed from the others similar to a computer's shift key. Following this guideline will allow you to avoid implementing a system that must compare each sensor with every other sensor.

Figure 8(a) shows how a finger press can affect the sensors located around the target sensor. By separating the sensors by two to three times the cover's thickness, the strength of the finger-to-sensor coupling is limited to a low and manageable amount. An alternative way of thinking about this relationship is to focus on the distance variable – "d" in Equation 2. If the sensors are separated by the same distance as the thickness of the cover, a press on one sensor will be like pressing the other sensor through a cover that is 1.4 times thicker. By separating the sensors as shown in Figure 8(a) by a distance 2.5 times the cover's thickness, that crosstalk press is now equivalent to pressing through a cover that is 2.7 times the cover's thickness. This results in a decreased crosstalk response from the system, which in turn increases your effective signal.

Figure 8a

Figure 8a: Diagram of finger-to-sensor coupling.

Sensor-to-sensor coupling is the other form of crosstalk that can negatively impact a design. Figure 8(b) shows how field lines will radiate from a capacitive sensor. The ability of those field lines to affect a neighboring sensor is based on the distance they travel and the material they are travelling through.

Figure 8b

Figure 8b: Capacitive sensor field lines.


Figure 8c

Figure 8c: Diagram of field lines showing sensor-to-sensor crosstalk.

If the field lines are able to propagate only through the cover as shown in Figure 8(c), the effect will be strong. If the field lines must go through the cover, exit into free space, and then return through the cover in order to affect a neighboring sensor, the amount of crosstalk will be significantly reduced. This is shown in the figure as the difference between the strong and weak coupling field lines. By following the first hardware design guideline, the field lines will be forced to travel through free space to reach a neighboring sensor, so the crosstalk caused by sensor-to-sensor coupling will be insignificant.

Alternatively, air gaps could be placed in the cover or PCB which would require the field lines to travel through free space. Figure 8(d) illustrates this possibility. Notice how the crosstalk path now has a very small capacitor in series with the normal parasitic capacitances. This small capacitor will dominate the others and will result in an overall crosstalk shift that is very low. The larger the air gap, the smaller the capacitor, and the better this method will perform.

Figure 8d

Figure 8d: Diagram of crosstalk in a slotted cover system.

Finally, another option is to limit the sensitivity of the sensor by using nearby ground traces to block the field lines. Before using this technique, review the "Hardware design consideration #5" section later in this article to understand the recommended use of ground near sensors. Reducing the sensitivity of a system should not be a design decision that is made lightly and should only be used when other possibilities have been exhausted.

By following this hardware design guideline, your designs will have reduced finger-to-sensor coupling and sensor-to-sensor coupling. This will result in a system that sees very little crosstalk and will allow the response time to increase due to lower processing overhead. As a result, the reliability of the system will increase as the sensors' signals become more immune to these negative effects.

Hardware design consideration #3

Covering material thickness

Best option: Keep the cover as thin as possible. Ideally, given 15 mm x 15 mm sensors, the cover thickness should not exceed 3 mm to maximize sensitivity. See Figure 8(a).

Option 2: The cover is thicker than optimal, but the sensors' areas are increased to provide additional sensitivity. See Figure 8(b).

Option 3: The cover is thicker than optimal, but slots in the covering material are created to allow the sensor closer to the surface. See Figure 8(b).

Option 4: The cover is thicker than optimal, but slots in the covering material are created to allow EMI gaskets or springs to bridge the gap between the PCB and the finger. See Figure 8(b). When covers are thicker than optimal:
  • The distance, "d" in Equation 2, between the sensor and the user's finger increases, which causes the capacitance between the finger and the sensor, "CF" in Equation 3, to decrease, resulting in decreased sensitivity.
  • Sensor-to-sensor crosstalk increases, as shown in Figure 8(c), due to additional sensor field lines being able to travel through the high-permittivity cover compared to the low-permittivity air.
The thickness of the covering material is very important in affecting the sensitivity of capacitive touch systems. Product designers will usually try to make the covering material as thick as they can to increase the durability of the end product, but thick covers will greatly decrease system sensitivity. Equation 2 helps to explain why thick covers are such a concern for capacitive touch applications. As the distance between the PCB and the finger is increased, the expected capacitance shift is decreased.

The relationship between cover thickness and sensitivity can be seen in Figure 9. One thing to note about the graph is the role that the permittivity of the material plays in defining the curves. A high permittivity material will allow for a larger sensitivity shift than an equally thick, but lower permittivity material. However, high permittivity has the negative effect of increasing the amount of crosstalk. Figure 8(a) shows the effect that a finger can have on a neighboring sensor. As the cover's permittivity increases, so does this coupling.

Figure 9

Figure 9: Relationship between cover thickness and sensitivity.

If your application absolutely requires a thick covering material for some reason, consider creating a slot in the covering material where the sensor will be so the sensor can be placed closer to the user's finger. Conductive foam products are also available that can be used to fill the gap if the whole PCB cannot fit in the slot. For more information about avoiding air gaps between the PCB and the covering material, see the "Selecting an adhesive" section later in this article.

Figure 10

Figure 10: Cross-sectional diagram of grounding techniques to design for high sensitivity or high noise immunity.

Hardware design consideration #4 Using ground planes to your advantage

Ground planes on the front of the PCB:
  • Increases human-to-electrical-ground coupling, reducing the effect of conducted noise.
  • Increases parasitic capacitance, "CP" in Equation 3, when placed near sensors which results in decreased sensitivity.
To minimize CP and maximize conducted noise reduction, a sensor-to-ground-plane separation of one to two times the cover thickness is suggested. Solid ground planes are recommended to maximize the human-to-electrical-ground coupling.

Ground planes on the back of the PCB:
  • Shields sensors from radiated emissions coming from behind the system.
  • Increases parasitic capacitance, "CP" in Equation 3, when placed near or behind sensors which results in decreased sensitivity.
Unless shielding from a radiating source behind the system is required, not placing ground planes directly behind sensors is recommended to keep sensitivities high. If shielding is required but sensitivity is a concern, consider using a gridded ground plane.

You can adjust CP in Equation 3 using these techniques if you know that an increased amount of noise will be present near a sensor. The negative effects could become a challenge if the sensitivity of the system is suffering, but many times this allows the designer to anticipate problems and proactively correct them. Solid and gridded ground planes can be combined behind and to the sides of sensors. By using these tools effectively, CP can be designed to find a balance between sensitivity and noise immunity.

Figure 10 demonstrates three levels of noise immunity that are possible using different grounding techniques around the sensors.

It is hard to stress enough the importance of providing your application with a sufficient forward-facing ground plane if conducted noise will be a concern. For systems that do not have a direct connection to earth ground, a finger can appear to be a noise source injected directly on top of a capacitive touch sensor. The extra ground planes will allow the finger to couple better to the floating ground, decreasing the amount of disturbance.

Hardware design consideration #5

Designing the sensors' layout

Best option: Keep sensor traces thin and short.

There are two main reasons to follow this advice. First, keeping trace lengths short will minimize CP and increase the sensitivity of the system. Long traces are also more susceptible to behaving like antennas which will increase the noise floor of the application. Communication lines should be kept away from sensor traces if at all possible. If not, run them perpendicular to the sensor traces to minimize their disturbance. You can also guard them with ground traces to couple the communication lines to ground instead of the more sensitive capacitive sensor traces. Avoid running capacitive sensor traces parallel with any noise-causing lines and keep them separated from ground and other capacitive sensor lines to reduce parasitic capacitance.

Keep sensitivities high and noise low. Keep sensor trace lengths short.

Hardware design consideration #6

Selecting an adhesive

Best option: Always use an appropriate adhesive.

An adhesive is used to secure the covering material to the PCB and is another important element to a robust capacitive touch system. Equation 2 will help to explain the necessity of a good connection. The relative permittivity of air is about one. Plastics are usually between two and three; glass is about four. If you have air separating the cover and PCB, your effective εr will be significantly decreased. For example, a 1 mm air gap will decrease your sensitivity to one half or one quarter of what it was. Remember that when three capacitors are in series, the smallest will dominate.

For systems using the metal-over-capacitive technique, it is especially important to find a good adhesive for the application. Distances of tens of microns (10 micron ≈ 0.4 mil) can make a significant difference in these designs. Talking to a representative from 3M or another adhesives manufacturer is recommended to ensure that your choice is the best for your custom application.

There are several other important factors to keep in mind when choosing or working with a commercial adhesive:
  1. Keep the adhesive thin in order to keep your sensitivity high. For most regular capacitive touch systems, 2 mil (50 micron) is a good thickness.
  2. Always read the bonding instructions for the adhesive. Some data sheets specify a required amount of pressure, temperature, and time to achieve a secure, lasting grip.
  3. Check the temperature limitations of your adhesive. In some environmental conditions the glue can fail, which will lead to unpredictable behavior from your capacitive touch application.
  4. Be careful of air bubbles when applying the adhesive. If there are bubbles in the glue, your sensitivity will suffer the same as if you had an air gap between the cover and the PCB.
  5. Make sure that the adhesive type matches well with the covering material. Different adhesives are made for low surface energy and high surface energy plastics. Most adhesives will adhere to glass and PCB with few problems.
Some example adhesives that may perform well are:

High surface energy plastics:
  • Example: ABS or Polycarbonate (PC)
  • 3M's Adhesive Transfer Tape 467MP
Low surface energy plastics:
  • Example: Polypropylene (PP)
  • 3M's Adhesive Transfer Tape 9626
  • 3M's Adhesive Transfer Tape F-9752PC
  • 3M's Adhesive Transfer Tape 9122
3M's Optically Clear Adhesive (OCA):
  • 8211, 8212, 8213, 8214, 8215
All of these will adhere to PCB and glass.

Hardware design consideration #7

Using series resistance on sensors

While not as mandatory as the other provided guidelines, this simple step will stabilize the sensor readings in voltage-based and frequency-based systems. A typical resistor value is 1 kΩ, but the value can range from 100 Ω to 10 kΩ. Figure 11 demonstrates the relative difference a series resistor can make during an industry noise test.

Note: If using the CTMU acquisition method, do not exceed the module's maximum input impedance of 2.5 k? or the scan rate will decrease.

Figure 11

Figure 11: Effect of a series resistor on the stability of a sensor's readings.

Hardware design consideration #8

Choosing VDD to maximize noise immunity

Best option: Keep VDD as high as possible to maximize noise immunity.

Although not ideal for low-power applications, high VDD systems will perform better in conducted noise environments than low VDD systems. This is due to the fact that all capacitive touch systems will eventually be overpowered by the injected noise as the voltage level of the noise is increased. Making VDD a higher value will require a higher voltage level of injected noise. In voltage-based acquisition systems, the behavior you are attempting to delay is the reverse press phenomenon. Figure 12 shows a regular sensor being injected with noise of increasing voltage levels. The noise begins adding voltage to the reading, which eventually overpowers the normal capacitive sensing behavior and causes a positive shift when pressed.

Figure 12

Figure 12: Reverse shift behavior when injecting conducted noise on a voltage-based acquisition system.

Software techniques

Consider your system requirements

Your system's limitations are based on two main factors. First, your hardware design decisions will result in a base SNR for the application. If the base SNR is high, the software will not need to filter the signal as much and the detection process will be fast and easy. If the base SNR is low, the software will need to heavily filter the signal and the detection process will need to go through more steps to make sure no false triggers are registered.

The second factor in determining your limitations is the application's performance requirements. If the product must have a specific response time, or if there is a limited amount of memory available, then some software techniques may not be applicable.

For example, in gaming systems speed is the most important requirement. Care should be taken when choosing a software filtering technique so that the response time does not suffer significantly. The code size should be kept small to allow for fast execution. In addition, the system sampling rate may need to be increased.

When considering any of the techniques described in this section, remember that all of them have a cost in time, power, and memory usage. The benefits should always be weighed against the costs.

Sampling rates

One of the first decisions when creating capacitive touch firmware is whether to trigger a new scan from the main loop or from the interrupt service routine. For applications concerned with noise, the second approach is recommended. Fixed-time sampling rates are important to the correct operation of filters, and detection decisions should be based on how long in real-world time a new behavior has been measured. If the sample rate of the system is based on a non-fixed interval like a function call from the main loop, other applications in the system could change the sampling rate. For example, a system that is actively controlling a power supply's output voltage will have priority over mTouch sensing due to its special timing requirements. If the power supply control application does not allow mTouch sensing to regularly scan, the system could miss a press or release.

The second decision that must be made is: What will the fixed sampling rate be? This is largely dependent on the acquisition method that has been chosen, as well as the specific requirements of the system. Voltage-based acquisition methods scan often and very quickly, while frequency-based acquisition methods scan over a longer period of time at a slower rate. Gaming systems that require a very fast response time may scan over 100 times per second, while a battery-powered proximity sensor may only scan three times a second until it notices a user nearby. For many systems concerned about noise, the sampling rate and the decoding rate may be different. For example, a system could scan a sensor once every 50 µs, continuously updating the filter, but only run the decoding sequence every 10 ms. This can reduce the amount of processing overhead while still allowing the system to adjust constantly to the changing environment.

Software filters and the decoding algorithm will need to be designed with the sampling rate of the sensors in mind. If not, the filters will become too fast and suffer from too little noise reduction or they will become too slow and may cause the signal to be dampened or slowed. Decoding algorithms which do not consider the sampling rate of the system may have problems achieving a required response time or may change states (on/off) too quickly.

Jittering the sample rate

Voltage-based acquisition methods only

One of the problems that can occur in systems that use the interrupt service routine to trigger a new scan is that the scans are then vulnerable to noise being injected at a harmonic of the sampling rate. Jittering helps to dampen high frequency noise being injected on to the system either through radiated or conducted noise. Figure 13 shows an example of what this can look like.

Figure 13

Figure 13: Sampling example – before and after jittering the sample rate.

The simplest solution is to change the sampling rate by a very small amount each time a sample is taken using the jittering technique. For example, if you are scanning a sensor once every 400 µs you may decide to delay the reading by an extra 0 to 10 µs (an amount that changes each time a sample is taken) to make sure you are not hitting any harmonics. Although this will technically change our sample rate, it will not change the average sampling rate and the change you are making is insignificant compared to the total sampling interval.

In the jittering implementation shown in Example 1, the least significant bits from our last ADC sample are used to create the random, short delay. The value is masked with 0x0F to limit the maximum amount of delay that is possible.

Example 1: Jittering.

#define UINT8 (unsigned char)
#define UINT16 (unsigned int)

void interrupt ISR()
{
  • if (T0IE & T0IF)
    {
    • // Short Delay
      jitter = ADRESL & 0x0F;
      while (jitter--);

      CVD_Service();
  • }
}

Oversampling

Oversampling is the process of using more than one acquisition sample per reading. For example, in most systems the interrupt service routine determines when a new reading should take place. When this occurs, the system acquires a value and saves it as the new reading. To increase the stability of your readings, you could have the system acquire two samples off the same sensor by scanning it twice and then adding the two samples together to create one sensor reading.

There are two reasons why this technique is helpful to a system:
  1. Sampling errors caused by impulse noise will not affect the system as much since each sample is only part of a full reading value. The system effectively averages out some of the errors during the acquisition process.
  2. Samples do not have decimal values. By allowing the system to scan multiple times per reading, it is able to gain additional resolution on the signal.
The benefit of this method to the effective SNR of the system is shown in Figure 14, but it does have clear diminishing returns that should be considered against the requirement of time and power consumption.

Figure 14

Figure 14: Oversampling trade-off-time versus SNR increase.

Software filters

Filters are algorithms that take an input signal and output a modified version of the signal. The function a filter performs is based on the type of filter it is. The bandwidth of a filter also plays a large role in how it performs. From a firmware perspective, the function of the filter is defined in the code structure and operations that are performed. The bandwidth is usually set by constants in the implementation that determine what number a value should be divided by, how many times to bit-shift left or right, and what coefficient should be used to multiply the result.

With filters there is a constant trade-off between noise reduction and response time delay. This trade-off can be visualized in the bandwidth of the filter as shown in Figure 15.

Figure 15

Figure 15: The noise reduction versus response time trade-off.

If the filter's bandwidth is narrow, less noise will be able to pass through, but it may take a long time for the filter to follow the signal. On the other hand if the filter's bandwidth is wide, more noise will be able to pass through, but it will follow the signal more closely. Combining multiple filters can allow the designer to get the benefits of each while limiting the negative impact.

There are three types of filters that are commonly used in mTouch sensing solution applications. More filters could easily be added to this list and may be more appropriate for a specific application, but these have been chosen because most designs will be able to use one or more of them.

The three filter types are:
  1. Slew rate limiter
    Used as the first input filter on new incoming samples to reject impulse noise and smooth the signal.
    Implemented in the acquisition routine.
  2. L-point running average
    Used to create a slow-updating (high time constant) baseline ("average") for each sensor as a reference point during decoding.
    Allows the system to track environmental changes such as temperature and humidity.
    Implemented in the filtering routine.
  3. Low-pass Butterworth
    Used to reject white noise on the sensor readings while still maintaining a fast response time (low time constant).
    Implemented on the reading variable in the filtering routine before sending it to the decoding algorithm.
FIR filters versus IIR filters

Finite impulse response (FIR) filters take a fixed number of previous inputs and use them to create the next output.

Finite impulse response filter benefits include:
  • Simple implementations.
  • Better filter stability.
  • Fewer concerns about integer precision.
Infinite impulse response (IIR) filters take the input and use it in combination with the previous output of the filter to determine the next filter output.

Infinite impulse response filter benefits include:
  • Low memory requirements.
  • Low processing requirements.
Ultimately, both filter types can be useful to an application.

For capacitive touch systems, IIR filters can be used for slowly-updating environmental baselines. The filter should be designed so that it can handle impulse noise without becoming unstable. FIR filters can be used for quickly-updating sensor variables like the reading.

Filter: slew rate limiter

The slew rate limiter (SRL) filter's main design goal is to reject impulse noise from sensor readings. Unlike the other two filters described in this section, implementing the SRL filter requires a specific scanning technique that will possibly change the sample rate of your design.

The concept of the SRL filter is simple. The PIC device maintains a current reading variable for each sensor. In most systems, when a new sensor reading is created, the current reading variable is replaced by the new value. In an SRL filtered system, when a new reading value is generated, the current reading value is then either decremented or incremented by one based on whether the latest reading is higher or lower than the current reading variable. For example, if a sensor's current reading is 200 and the next acquisition results in a value of 300, the system will update the current reading to 201. In order for the system to reach a current reading of 300, the next 99 scans must be higher than the current reading.

This behavior is very beneficial because it limits the influence of each sample. If impulse noise is affecting the system, a single impulse-noise-affected reading will only cause 1-bit of noise on the reading variable. On the other hand, because you are updating the current reading variable so slowly, you need to update the rate of the samples. When a user presses on a sensor, the current reading variable needs to be able to move with the finger's capacitance at a fast rate. There is no need to access the decoding function of the system after each individual reading since it can only shift by one each time.

There will be several parts to the SRL filter implementation which take care of these special requirements. First, the system will scan based on a timer's interrupt at a fast rate. After each of these scans, it will run the SRL filter to increment/decrement the current reading variable. After the Nth sample, a flag is set that allows the decode function to run. An example code implementation of this filter can be seen in Example 2. The benefits of this filter can be seen in Figure 16. The impulse noise on the system has been rejected and the signal is now more easily decoded.

Care should be taken to make sure the SRL filter is not moving too slowly. If the sampling rate is too low, the current reading value will not update fast enough, which can cause problems with response times. An example of what this too-slow behavior will look like is shown in Figure 17.

Example 2: Slew rate limiter filter.

#define SCANS_PER_DECODE 100 UINT16 reading; UINT16 counter; void main(void) {
// Main Loop
while(1)
{
    if (counter >= SCANS_PER_DECODE)
    {
        mTouch_decode();
        counter = 0;
    }
}

}

void interrupt ISR(void)
{
UINT16 newReading;
if (TMR0IE && TMR0IF)
{
    // Take a reading and store the value
    newReading = mTouch_getReading();
    // Initialize the reading if starting
    if (reading == 0) reading = newReading;
    // Slew Rate Limiter
    if (newReading > reading) reading++;
    else reading--;

    counter++;
}

}


To solve this issue, either:
  1. Reduce the amount of time between timer interrupts, or
  2. Change the increment/decrement amount to a value larger than one. However, the larger this value is, the less the filter will be able to reject impulse noise.
Figure 16

Figure 16: Slew rate limiter filter behavior.


Figure 17

Figure 17: Excessively slow slew rate limiter filter example.

Calculating the minimum sampling rate in a slew rate limited system

The system needs to be able to transition from its average, unpressed sensor value to the sensor's threshold in the required response time. That leads to the creation of Equation 4(a), with the example behavior shown in Figure 18(a).

Equation 4a

Equation 4a: Minimum sampling frequency (basic).

Where:
fs min is the minimum sampling frequency
T is the absolute value of the relative (to the baseline) press threshold
tr is the required response time
nmax is the maximum step size of the SRL filter after one sample

Figure 18a

Figure 18a: Fixed interval decode function calls.

Calculating the minimum sample frequency with a system that implements debouncing is also simple. The previous result can be multiplied by the debounce requirement to determine how fast the system must sample to make sure a press can be detected in the given response time, as shown in Equation 4(b).

Equation 4b

Equation 4b: Minimum sampling frequency (decode after fixed number of samples).

Where:
fs min is the minimum sampling frequency
T is the absolute value of the relative (to the baseline) press threshold
tr is the required esponse time
nmax is the maximum step size of the SRL filter after one sample
debouncemax is the maximum required debounce count to change states

Because the speed of the SRL filter is defined to be T∇/nmax, if the press occurs asynchronously with the decode function calls, it will not be past the threshold by the time the next decode function call is performed. There will be a system delay while waiting for the next call.

However, we know that we are, at minimum, going to call the decode function once while the shift is occurring or we will call it right as the threshold is reached. Instead of calling the decode function every T∇/nmax samples, the counter value can be calculated each time to determine the minimum number of steps required to cross the threshold given the current reading value. This decode counter calculation is shown in Equation 5 and an example of its behavior is shown in Figure 18(b).

Equation 4c

Equation 4c: Minimum sampling frequency (decode selectively).

Where:
fs min is the minimum sampling frequency
T is the absolute value of the relative (to the baseline) press threshold
tr is the required response time
nmax is the maximum step size of the SRL filter after one sample
Nmax is the minimum number of samples per decode function call

It is important to be careful when calling the decode function at non-fixed intervals. If the system is using a secondary filter in later stages for the sake of decoding real-time motion, the amount of time that elapses between decode function calls will change. This means that the secondary filter will need to be updated with care.

Figure 18b

Figure 18b: Selective decode function calls.

Equation 4(c) shows how to calculate the minimum sampling rate for a system that has the same required response time as before but is now able to call the decode function selectively.

Equation 5

Equation 5: Decode function call counter calculation.

Where:
reading is the current reading value
TP is the absolute press threshold
nmax is the maximum step size of the SRL filter after one sample

Filter: L-point running averages

This filtering technique is used in a vast number of applications and has been documented thoroughly. Its behavior is defined in Equation 6. The current value, x[n], is averaged with the last L-1 values. When deciding on a value for L, keep in mind the division operation. If a power of two is chosen for the value of L, the division operation can be simplified to a series of bit-shifts, reducing the complexity of the filter.

Equation 6

Equation 6: L-point running average (FIR).

Where:
y[n] is the output at time "n"
x[n] is the input at time "n"
L is the memory of the filter
k is a counter variable

Example 3: FIR L-point average filter.

#define HISTORY 8     // 'L' #define UINT8 (unsigned char)
#define UINT16 (unsigned int)
UINT16 reading[HISTORY];
UINT8 index;
UINT16 FIR_Average(UINT16 newReading)
{
  • UINT8 i;
    UINT16 average = 0;
    // Replace oldest reading
    reading[index] = newReading;
    // Sum all reading values
    for (i = 0; i < HISTORY; i++)
    {
    • average += reading[i];
  • }
    // Divide by the history window size
    // NOTE: This operation is simple and fast
    // as long as HISTORY is a power of 2.
    average = (UINT16)(average/HISTORY);
    // Update index for next function call
    index++;
    if (index >= HISTORY)
    {
    • index = 0;
  • }
    return average;
}

An example code implementation of the above filter can be seen in Example 3.

Also notice that, as implemented in Equation 6, this is an FIR filter, which means that a single reading can only affect the output for a specific number of samples, L. After this period, the sample no longer has an influence on the system's behavior. For noise-injected situations this is a very beneficial characteristic for our filters to have. However, the memory cost of this filter will make any filters with a large window difficult to implement.

To solve this limitation of the filter, its behavior can be changed from FIR to IIR as shown in Equation 7. This creates a fixed, low memory cost for the filter but degrades some of its features. The IIR version of the L-point running average will become more distorted from the original as L gets larger.

Equation 7

Equation 7: L-point running average estimate (IIR).

An example code implementation of the above filter can be seen in Example 4.

Example 4: IIR L-point average filter.

#define HISTORY 8      // 'L'
#define UINT8 (unsigned char)
#define UINT16 (unsigned int)
UINT16 average;
UINT16 IIR_Average(UINT16 newReading)
{
  • // Update Average
    average -= (UINT16)(average/HISTORY);
    average += newReading;
    // NOTE: This filter implementation has a gain of 'HISTORY'. For that reason, we must either divide the average by HISTORY or multiply the reading by HISTORY before we are able to compare them.
    return (UINT16)(average/HISTORY);
}

Figure 19 shows the difference between the FIR L-point running average and the IIR L-point running average estimation. Notice that the estimation introduces a response time delay in the system. For this reason, it is not recommended to use this filter directly on the reading signal. However, the time delay of this filter is not a problem for the baseline calculation. Since the baseline should be moving very slowly, the time delay will not negatively affect its behavior.

Figure 19

Figure 19: FIR versus IIR running averages.

Filter: Low-pass Butterworth

This filter implementation is an alternative to the L-point running average. While both are low-pass filters, the digital low-pass filter in this section is based on the digital implementation of a Butterworth filter and can be seen defined in Equation 8. Notice that the only complex operation in this filter is the multiplication between K and the previous output of the filter. If K is chosen wisely, this filter can be easily implemented with the use of bit-shifts.

Equation 8

Equation 8: Digital Butterworth low-pass filter.

Where:
y[n] is the output at time "n"
x[n] is the input at time "n"
A is the filter's coefficient (0≤A<1)

Smart values for "A" include: 0.8125,0.8750,0.9375, and 0.9688, to name a few. These can be implemented easily using only bit-shift operations on the y[n-l] value. An example of this can be seen below:

Example 5: Low-pass Butterworth filter.

#define UINT8     (unsigned char)
#define UINT16    (unsigned int)
#define FILTER_GAIN 3
typedef struct
{
UINT16 y;
UINT16 x;

} FILTER;
FILTER filter [NUM_BTTNS];
UINT16 LP_Butterworth(UINT16 reading)
{
// Pointer to the correct filter
// variables for our sensor...
FILTER* h = &filter[index];
// Temporary variables
UINT16 x1, y1, ay1;
UINT16 temp0, temp1;
// Populate temporary variables
x1 = (h -> x);
y1 = (h -> y);
// Calculate: ( a * y[1] )
// Where, a = 0.8125.
temp0 = y1 >> 2;
temp1 = y1 >> 4;
ay1 = y1 - temp0 + temp1;
// 1st Order Filter Equation:
// y1 = x[0] + x[1] + (a * y[1])
y1 = reading + x1 + ay1;
// Store values for next time
(h -> y) = y1;
(h -> x) = reading;
// Return the filter's new result
return y1 >> FILTER_GAIN;

}


Equation 9

Equation 9: Calculating for “A”.

As the value of "A" gets closer to one, the cutoff frequency of the Butterworth low-pass filter approaches zero. This increases the effectiveness of the filter, but will slightly increase the filter's settling time. Also, as "A" gets closer to one, the integer value of y[n] will increase quickly. This puts an upper limit on the value of "A" if you want to continue representing each sensor's signal with the typical 16-bit integer value.

The benefit of this type of filter when compared with the L-point running average can be seen in Figure 20. The increase in the effective SNR of the sensor is much higher when implementing the Butterworth than the running average. However, the running average estimate is very inexpensive to implement and performs the job well as a filter for the sensor's baseline.

Figure 20

Figure 20: Low-pass Butterworth filter versus L-point running average.

Setting thresholds

After the sensor signal has been read and filtered, the decoding process should begin. During this step the sensor's signal will be compared against a pre-determined threshold to decide if there is a press.

When establishing a threshold there are two main options: setting a fixed threshold or calculating the threshold at run-time. Setting a fixed threshold is the easiest and least time/memory intensive, but it may not work in every situation. For mass production systems, it is possible there will be slight differences in the sensor's default values across boards. If the application is using a fixed threshold, there is a possibility that the threshold may not work for all of them.

Calculating the threshold at run-time is the other option. When this is implemented, the system will take several readings on power-up and will determine where the threshold should be set based on the system's samples. For the majority of applications, a calculated threshold will not significantly affect the system's behavior and is preferred for its flexibility.

In some cases, two thresholds may be used in the same way as hysteresis – one used to enter the pressed state and one used to enter the released state. A diagram showing this behavior is seen in Figure 21.

Figure 21

Figure 21: Threshold hysteresis behavior.

Choosing where to place the thresholds for a system can be one of the most important and difficult tasks involved with getting a robust solution working. Assuming the sensor's signal moves down when pressed, if the threshold is too high, false triggers can become a risk. If the threshold is too low, the system may be unable to detect a press in all situations. It is important to remember that your system will be used by a wide variety of people. People with big hands will cause more of a shift than those with small hands. Make sure you are setting the thresholds and testing them with a cross-section of individuals so that everyone will be able to activate the sensor.

Figure 22

Figure 22: Sensor signal versus time and frequency of result.

Envelope detector

The Envelope detector is a decoding technique that uses an extra variable to track the average deviation from the sensor's baseline (or average). This can be particularly effective in systems that experience a large amount of injected noise. Figure 23 illustrates an example of a system that would benefit from this decoding technique.

When a high level of injected noise is present on capacitive touch sensors, press detection can be difficult if the decoding algorithm is only looking for a shift in sample values. Some frequencies of noise may cause the press behavior shown in Figure 23. When this occurs, an envelope can be created to track the noise level of the system and this can be used with a threshold to make press decisions. An example implementation of this decoding technique has been provided in Example 6.

Keep in mind while implementing this technique that the delta value is the absolute value of the difference between the current sensor reading and the average. This means that shifts in both the positive and negative direction will cause the envelope to increase. If this behavior is not desirable for your system, the absolute value section of the code example can be removed. For more information about the envelope detector decoding algorithm, see application note AN1317, mTouch™ Conducted Noise Immunity Techniques for the CTMU.

Figure 23

Figure 23: Envelope example during high injected noise.

Example 6: Envelope detector.

#define INT16 (signed int)
#define UINT16 (unsigned int)
#define UPDATE_SPEED 4
// Fastest-Slowest
// 2, 4, 8, 16, 32
UINT16 envelope;
UINT16 reading;
UINT16 average;
UINT16 Update_Envelope_Detector(void)
{
INT16 delta;
// Delta = | Average - Reading |
delta = average - reading;
if (delta < 0)
{
     delta = -delta;
}
// Update envelope
envelope -= (UINT16)(envelope/UPDATE_SPEED);
envelope += (UINT16)(delta);
return envelope;

}


Common challenges

There are several behaviors which commonly appear in capacitive touch systems. In this section, the main issues seen in these applications will be discussed and the different possible solutions described that can be used.

The challenges and solutions covered in this section are:
  • Crosstalk
  • Impulse noise
  • Unresponsive buttons
  • Flickering buttons
  • Reversed operation

Common challenges: Crosstalk

Crosstalk is the undesired shift of a sensor when an adjacent sensor is pressed. It is mainly a side effect of placing sensors too close together, but can be also significantly affected based on the thickness and relative permittivity of the covering material.

Best option: Increase the amount of separation between sensors. See the Hardware design consideration #1 section earlier in the article for all available options.

If possible, reducing the amount of crosstalk using hardware design techniques is preferred to making software adjustments. Crosstalk will also become more of a problem in systems with thick covers, so reducing the thickness may also be a required step. For more information on the causes of crosstalk and the hardware changes you can make to reduce this effect, see the "Hardware design consideration #1" section earlier in this article.

Option 2: Adjust the thresholds.

If these hardware solutions are not adequate or cannot be used by your specific application, adjusting the software may be your only solution. Changing the threshold by increasing the amount of shift required to detect a press might be the best option if the system has more sensitivity than needed. By requiring that the sensor's readings shift more than the maximum crosstalk shift of the system, you can eliminate the ability of crosstalk to activate a sensor. Keep in mind when doing this, however, that noise on the system may increase the maximum crosstalk shift, which could cause false triggers in the future.

Option 3: Implement the "most pressed" algorithm.

Alternatively, you can change the system to compare each sensor's shift with the other sensors in order to determine which one is "most pressed." Implementing this algorithm will limit your system's capabilities. First, the system will only be able to support one press at a time since only the highest shift sensor is always picked.

To minimize the effect of this limitation, only compare nearby sensors to each other. The second limitation this algorithm places on a design is on response time. The extra execution time required by the processor and the requirement that all sensors must be scanned before the decoding process can begin will both slow the system down. Depending on the application, this may or may not be an acceptable design trade-off.

Common challenges: Impulse noise

Impulse noise appears as individual or small groups of readings that behave in a significantly different manner than the readings before and after due to a noise source and not a finger press. These spikes can quickly destabilize a system if not handled correctly. Additionally, if noise spikes are a common problem for the system, they can also lower the effective SNR.

Software filters are usually the easiest method for removing this problem. The key is to adjust the filter to reduce the effect of the spikes, but not to affect the response time of the system. For example, if the decision is made to take the average and just slow it down to minimize the impact a single reading can have, it will reduce the noise spikes in the system. However, it will also slow down the response time since reliance is now on a much slower average.

Best solution: Implement the slew rate limiter filter.

Infinite impulse response (IIR) filters are not going to be as effective as finite impulse response (FIR) filters will be in this case. Since IIR filters allow one reading to affect the signal for a (theoretically) infinite period of time into the future, the effect of a noise spike could cause the filter to become unstable. The best option in this case is to use the slew rate limiter filter described earlier in the "Software techniques" section of this article. Because of its design, it will eliminate all impulse noise from the system with a minimal impact on the overall system.

Common challenges: Unresponsive buttons Unresponsive buttons are sensors that will not change state when a finger is placed on them. The two main software features that will affect your sensors to possibly make them unresponsive are thresholds and debounce values. Sensor sensitivity can change as noise is injected on a system. This change can reduce the sensitivity to the point that the threshold is no longer crossed. Increased noise on the system will increase the probability of a single sensor reading falling outside of the acceptable range to change state. If the maximum debounce value is high and the noise is high, it is possible the sensor will never respond.

There are several things that can be done to fix this problem in a system.

Best solution: Adjust the thresholds.

First, the threshold can be made easier to cross by modifying the software. When noise reduces the sensitivity of the system, the easier threshold will decrease the possibility of an unresponsive button. This may not be a solution if making the threshold easier to cross will introduce false triggers into the system. The best way to make sure there is plenty of sensitivity to work with in this situation is to follow the hardware design guidelines described in this article.

Option 2: Check both directions for shifts.

Another possibility is that the system is being injected with a specific amount of noise that has caused it to reverse its press behavior. When this happens, pressing on the sensor will cause a shift in the opposite direction as expected. The solution to this problem is to place the threshold on both sides of the readings. This may not be an option, however. In some systems, the direction of a shift indicates a specific event. For example, in some water-resistant systems a shift in one direction is a press while a shift in another direction indicates the presence of water. Implementing a shift-check in both directions would eliminate the water resistance of the application.

Option 3: Use hardware to increase sensitivity.

Finally, if adjusting the thresholds does not solve the problem, hardware changes may need to be made to increase your system's base sensitivity. First, make sure the application is following all of the design guidelines. The next step is to begin increasing sensor area, decreasing crosstalk through sensor separation, decreasing the cover thickness, or changing its material. All of these suggestions can be traced back to their origins in Equation 2 which defines the relationship between capacitance and hardware design.

Common challenges: Flickering buttons

The term "flickering button" refers to a sensor that will rapidly toggles its state while a finger is present. This is distinctly separate from a false trigger, which is a sensor changing state while there is no finger. Flickering buttons are caused in the same way as unresponsive sensors. As noise is injected on a sensor, the sensitivity of the sensor can change. If the sensitivity is reduced to the point that it approaches the threshold, noise can sometime cause the readings to jump above and below it. This will result in the sensor rapidly changing states.

Best solution: Implement threshold hysteresis.

The best and most effective solution to this problem is to adjust your algorithm so that it implements a large hysteresis on the thresholds. Separate press and release thresholds will be able to tolerate a much larger amount of system noise. If sensitivity levels are high, the thresholds will be able to be placed farther apart, increasing the noise resistance of the system. Similarly, as the thresholds are placed closer together, the system begins to return to its single-threshold behavior and can once again experience flickering buttons. For these reasons a combination of hysteresis and debouncing should be the default solution to this problem in applications.

Option 2: Increase the debounce requirement.

The easiest way to reduce this problem is to increase the maximum debounce value, but this method can have mixed results. Increasing the debounce count will decrease the response time of the system and will only decrease the probability of flickering. The smaller probability of flickering will translate to a slower flicker, but most likely not the complete elimination of it.

Option 3: Adjust the thresholds.

A third option is to make the threshold easier to cross or to increase the sensitivity of the system through hardware changes. However, if there is a large amount of noise on the system, this still may not be enough by itself to solve the problem.

Common challenges: Reversed operation

Reversed operation can occur in systems with a high amount of injected noise. The noise can cause the system to shift in the opposite direction as the no-noise behavior. If the system was shifting down on each press, it is now shifting up. This can be a problem in systems that only look for a shift in one direction. Figure 24 shows how a system looking for a "down" shift can enter a reversed operation state if an "up" shift occurs. There are two main ways of solving this problem. The baseline's speed can be decreased and thresholds can be placed on both sides of the baseline.

Figure 24

Figure 24: Entering reversed operation due to noise.

Best solution: Check both directions for shifts.

The more robust solution to this problem is to create a threshold on either side of the average so that a shift in either direction will result in a detected press. Not all systems may work well with this solution. For example, in some systems designed to work in wet conditions, a shift in one direction means a finger is present while a shift in the other direction corresponds to a the effect of water. In a situation such as this, it may be wiser to ignore any shifts in the wrong direction. Ultimately, the decision should be based on the specific application's requirements.

Option 1: Adjust the filters' time constants.

Slowing down the baseline's speed would require that a longer opposite direction from normal shift would occur before the system enters the reversed operation state. This would cause unresponsive buttons when specific types of noise are injected onto the application, but may be the best option for a given system. Just slowing down the average will not eliminate the problem, however. If a user were to press on a sensor for a very long period of time, the slow average will eventually follow the finger and when it is finally removed, reversed operation could still occur. This is a performance trade-off that must be considered when using any baseline in a system. Determining the difference between the environment naturally shifting the readings and a finger artificially shifting the readings can sometimes be difficult.

Option 2: Increase the VDD of the system.

While this will not eliminate the problem, raising VDD will fight against the reversing behavior by increasing the amount of noise that must be injected on the system before it flips. This option is placed last because increasing VDD results in a higher current consumption for the system.

Conclusion

Good hardware design choices are the foundation of a robust capacitive touch design. By following the design guidelines detailed in this article, your custom application will have a high base SNR, which will decrease your required software overhead, speed up your system's overall response time, and allow your system to perform well even in noisy conditions.

Although there are many opportunities to adjust a design to meet a specific application's needs, the best design choices for a robust system are as follows:
  1. The sensor size should be the same as an average user's finger press (15 mm x 15 mm).
  2. Sensors should be separated as much as possible. Ideal minimum separation is two to three times the cover's thickness.
  3. Keep the cover as thin as possible. Ideally the cover thickness should not exceed 3 mm to maximize sensitivity.
  4. Use ground planes to your advantage to minimize radiated and conducted noise, but be careful of reducing sensitivity.
  5. Keep sensor traces thin and short.
  6. Always use an appropriate adhesive.
  7. Add series resistors to the sensor traces.
  8. Keep VDD as high as possible to maximize noise immunity.

Strategic use of acquisition techniques such as jittering the sample rate and implementing a slew rate limiter will reduce the amount of noise that is introduced through the readings. Digital filters such as the L-point running average and the low-pass Butterworth filter allow the system to track environmental changes and further increase the SNR of the signal. Finally, specific algorithm implementations such as threshold hysteresis, debouncing, and the "most pressed" algorithm will allow the system to react to even the most rare of noise disturbances.

From start to finish, capacitive touch systems should be developed with the key focus of increasing the SNR of the sensors' signal. Changing from a digital, mechanical switch to an analog, capacitive sensor is not a one-step process, but following the hardware suggestions and implementing the software algorithms found in this article will make your system both cost effective and robust.

Digi-Key Logo

Disclaimer: The opinions, beliefs, and viewpoints expressed by the various authors and/or forum participants on this website do not necessarily reflect the opinions, beliefs, and viewpoints of Digi-Key Corporation or official policies of Digi-Key Corporation.