SSZTBV9 november   2015 FDC1004 , FDC2112 , FDC2114 , FDC2212 , FDC2214

 

  1.   1
  2.   2
    1.     3
    2.     Derivative Integration Algorithm
    3.     IIR Filter Implementation
    4.     Summary
    5.     Additional Resources

Rachel Liao

Proximity-sensing applications require the detection of small changes in capacitance (typically on the order of a few femtofarads) around the noise floor. Since there are many ways to process the data to determine whether a target was detected or not, how do you choose the best method? In this post, I’ll describe a simple algorithm that you can use for proximity sensing or capacitive touch applications that does not require significant processing overhead.

Derivative Integration Algorithm

A derivative integration algorithm (see the pseudo code shown in Figure 1) is a simple way to process the data. You can use it for both proximity sensing and capacitive touch buttons; the only difference between the two would be the derivative and integration thresholds for each sensor to obtain a robust and highly sensitive response.

GUID-BD38CA5E-7AD3-461C-B7DD-90A95AD92901-low.jpg Figure 1 Pseudo Code for the Derivative Integration Algorithm

This algorithm tracks the rate of change or derivative, D[i], between the current measurement, X[i], and the previous measurement, X[i-1]. Proximity-sensing applications require the detection of small capacitance changes. This requires the derivative threshold, DT, to be very low. Changes in capacitance due to noise can be a severe problem, especially if the DT is very low. The integral of the derivative, I[i], can start to accumulate and falsely trigger as a detected object. Random noise should stabilize the integral value so that the mean is zero (no capacitance drift occurs), but a high integration threshold, IT, can allow enough noise margin for nonrandom noise.

The leakage factor, L, is a value between 0 (instant dissipation) and 1 (no dissipation). It is typically set at 0.99 to represent that the algorithm has some memory of past values to determine where the detection boundary occurs. You can use various leakage factors for a faster recovery time if the integral swings too far positive. This will cause temporary sensitivity reduction until the integral can stabilize near 0.

Once a human hand approaches the sensing area, the integration value will start to accumulate as long as the derivative of the measurements hits the derivative threshold. If the device detects the hand (the integral value goes below the integration threshold) and the hand stops in the sensing area, the derivative flattens out and the integral stops accumulating. As the hand moves away from the sensor, the integral recedes until it goes above the integral threshold. This indicates that the target object is outside the intended sensing range.

For capacitive touch applications, a low derivative threshold is not required. You can optimize the integration threshold based on the desired button response. You can also implement multiple derivative and integration thresholds to filter out any high-frequency noise seen in the sampled measurements and increase the sensitivity response.

Figure 2 shows an example of a waveform with a target detected using the FDC2214. As the derivative becomes more negative (an object approaches the proximity sensor), the integral count matches the raw code signal, as expected. You can also optimize the thresholds to be robust against any slow-moving drift. Figure 3 shows how a drift in the raw code is compensated in the integral count. The signal is preserved without any distortions due to the slow upward drift.

GUID-9D44010B-29E6-405A-A307-E6DE4EE59DB8-low.png Figure 2 Example 1 – Proximity Raw Code, Derivative and Integral Waveforms
GUID-12D10E07-CCEF-4881-B34A-66C55355450B-low.png Figure 3 Example 2 – Raw Code and Integral Count

IIR Filter Implementation

To improve the signal-to-noise ratio in the measurements, you can implement an Infinite Impulse Response (IIR) filter to process the data and obtain an average measurement before sending it through the derivative integration algorithm. The IIR filter implementation is similar to a moving average except that previous values are not stored and shifted out of the summing order. This process saves memory and computational time at the expense of slight accuracy degradation.

The filter processes a running total of ‘N’ values. The current average (Avg[i]) is calculated by taking the previous average (Avg[i-1]), multiplying by N and subtracting the previous average. Then, the new value (val[i]) is added to the sum to create a “new sum”. Dividing by N creates a new average. Having N be multiples of two allows bit shifting instead of actually dividing, thus saving computational cycles.

Equation 1. GUID-07AB6AB4-CD6C-499E-920E-67B1BD2C36E0-low.png

Summary

The derivative integration algorithm is a simple algorithm that can be used to for proximity sensing and capacitive touch applications. This solution is a foundation that other sophisticated processing algorithms can be combined with to make the algorithm more robust for various system conditions. Depending on the system requirements, you will need to optimize the processing, but the derivation integration algorithm is a great start for quick prototyping.

Additional Resources