This “Product How-To” article focuses how to use a certain product in an embedded system and is written by a company representative.
Capacitance measurement, widely used to detect proximity of human touch, creates a characteristic capacitive sensing chain like most of environment-sensitive proximity sensing systems. A key part of this sensing chain is the capacitive sensor (Figure 1, below ).
This sensor is the low-layer hardware and software, which drives and monitors the charging process at the same time. Many low-cost systems use only single threshold logic with simple driving, using the constant current charge sensor or charging through a parallel resistor.
|Figure 1. Capacitive Sensing Chain|
Hardware sensors typically provide a fixed or configurable oversampling feature, where multiple subsequent measurements are taken and processed as one value (either a sum or an average). Oversampling is time consuming but offers precision. Software sensors provide discrete sample values, where oversampling may be controlled.
For this article, sensing is the “waiting” time when the driven capacitive signal reaches a known detection threshold (VIH). When oversampling is counted, the waiting time varies in the microseconds range.
Capacitance-to-time conversion (CTC) means that a capacitance added (by a finger) to the base capacitance of the measuring circuitry (Figure 2, below ) increases the measured conversion time. The base capacitance of the measuring circuitry is called parasitic capacitance, which determines the minimum conversion time, called baseline.
|Figure 2 Capacitive Interface & Capacitances|
Depending on the layout, route thickness, and other board- and input pin-specific parameters, the baseline may easily reach tens or even hundreds of microseconds. The finger capacitance can extend this conversion time further.
Without suitable elimination of parasitic capacitance, this baseline can be very high and may even be higher than the finger capacitance being measured. A problem with capacitive measurement is instability and difficulty to estimate hardware parameters and conditions with almost random parasitic capacitance in the range of tens or hundreds of picofarads.
Today's systems have adjustable sensitivity through a single configurable current or voltage source. This setup always requires minimal or at least stable parasitic capacitance in the measuring chain.
These systems don't allow independent control of sensitivity and charge time for various parasitic capacitances and for different physical conditions. This means that higher sensitivity always means longer conversion time with all consequent disadvantages.
The patent-pending capacitive turbo sensing (CTS) approach (Figure 3, below ) allows independently controlled sensitivity and capacitance-to-time conversion. The main advantage of CTS is the fast capacitance-to-time conversion independent of the sensitivity, board design, electrode size, dielectric distance, and other environment conditions.
|Figure 3. [RCT/CTS-sensor] HW, CTC, algorithm, function, i/o|
The CTS circuitry arrangement has two voltage or current sources where the first eliminates the hardware conditions such as parasitic capacitance by using quick charging/discharging control, and the second is used for precise measurement of the remaining capacitance.
The method speeds up this capacitance measurement in range of 1 fF to 100 pF by using general-purpose I/O (GPIO) processor pins with internal pull-up/pull-down resistors being used as second current or voltage sources. The CTS algorithm allows significantly faster measurement and guaranteed maximal conversion time for typical parasitic hardware conditions.
The hardware required by the CTS-sensor is a microcontroller‘s GPIO pin with an internal pull-up resistor, an external resistor, a suitable touch channel, and the touch interface. The pull-up resistor is used by a software turbo-control algorithm to shorten the measurement time. The measurement sensitivity is then achieved by an external resistor.
Sensitivity of the CTS-based sensor comes from the standard resistor-charge-transient (RCT) mathematics (see Equation 1 below) . The microcontroller measures the time to reach the known detection threshold. The ratio (see Equation 3 below) may be used to calculate the characteristic gain factor (See Equation 2 below) of RCT.
Also, the leakage current affects the target sensitivity. The main rule is to use devices with very low leakage current (in the nanoamp range or better). Sensitivity of the hardware specifies basic sensing behavior.
dt[us] =eR[MO) x dC[pF] x GRIH “sensitivity”(Equation 1)
GRIH= -1n(1 – RIH) “gain factor” (Equation 2)
RIH = VIH[V]/(Vdd[V] + eR[MO] x IL[uA]) “Relative VIH” (Equation 3)
Resolution of the sense loop in the time domain is measured using the microcontroller's fBus clock. With a known execution time of the sense loop and the fBus, the time-measurement resolution can be calculated.
For example, with a sense loop ratio equal to nine and and fBus equal to 20 MHz (50-ns tick), the time-measurement resolution is 9 * 50 = 0.45 μs/LSB. The resolution may be viewed as a basic CTS quantization performance (it depends only on the fBus). Changing the fBus causes a change to the CTS-sensor's performance.
Resolution (in pF/LSB or pF) of the CTS-sensor in the capacitive domain is calculated from the sensitivity and the sense loop resolution in the time domain. For example, with a sensitivity of 0.9 μs/pF and a resolution of 0.45 μs/LSB, the CTS-sensor resolution is 0.45/0.9 = 0.5 pF/LSB or 0.5 pF.
The heart of the CTS algorithm is the Turbo-loop, which is a software loop during which the MCU enables an internal pull-up associated with the GPIO pin to speed-up the RC charging. This pull-up is typically in the range of 5 to 60 kΩ. One loop execution of the Turbo-loop is called Turbo-step, and the number of fBus clocks needed for the execution is called Turbo-loop ratio.
During the turbo-control, both pull-up resistors are applied so the total resistance can be calculated by as R=(iPE*eR)/(iPE+eR). For example, with internal pull-up around 24 kΩ, an external pull-up (eR) of about 1 milli-ohms, fBus equal to 20 MHz, and the Turbo-loop ratio equal to 4, each turbo-step eliminates roughly 8.5 pF of the parasitic capacitance (Equation 1).
When Turbo-control is optimized, the remaining capacitance is measured by using the eR-charge time only. This measurement is accomplished by another software loop called Sens-loop. With this example and standard conditions, the measurement of maximum remaining capacitance 8.5 pF takes a maximum of 8.5 microseconds.
This method guarantees a maximum conversion time of a single sample. In the typical implementation with Freescale HCS08 device running at fBus equals 20 MHz, the measurement typically takes 1 to 10 μs.
Accuracy of the CTS-sensor depends on physical and hardware parameters and the conditions. For example, an HCS08 MCU may have differing resistance RIH values, which are typically in range of 0.52 to 0.86, and wide range of leakage currents. Factors affecting accuracy should be added to the RIH equation. Calibration of the CTS-sensor should be done using the sensing software's upper layer.
Precision of capacitive sensing is generally low. Low precision requires high oversampling for better accuracy. Moreover, classical sensor precision is lower for higher parasitic capacitance, which requires higher oversampling. With Freescale's touch sensing solution (TSS), the oversampling is configurable.
For a CTS algorithm, the typical oversampling factor of eight can yield approximately eight times better sensitivity and resolution. For example, with a physical resolution of 0.45 pF/LSB and an oversampling factor of eight, the statistical resolution will be roughly 0.45 pF/8 = 56 fF/LSB, but the oversampling conversion time will consequently be eight times longer.
Using interrupt server routine (ISR) technology for the algorithm is a unique approach developed for a CTS-sensor, which provides the ability to recognize an interrupt occurrence automatically “ex-post” without any cooperation from the user code.
This feature is important because low-priority capacitive sensing integrated with custom embedded code should reliably recognize that the CTS loops (Turbo-loop and Sens-loop) are not interrupted and the capacitive sample is valid for future processing. Customers who use the Freescale TSS solution and CTS-sensor algorithms are not limited in terms of how interrupts are used in the application.
Using CTS effectively
The TSS approach (Figure 4, below ) integrates a CTS-sensor and is royalty free (and can be downloaded from the Freescale web site). Today, it supports the HCS08 MCU family of microcontrollers and applications developed with CodeWarrior Development Studio for Microcontrollers.
|Figure 4. Freescale Touch Sensing Solution (TSS)|
As the full TSS solution provides a lot of other useful algorithms, detectors, and electrode decoders, the low-level CTS measurement calls may be utilized directly from the application when appropriate.
In an example showing the integration of a simple CTS-sensor into custom embedded code (Figure 5, below ), the CTS-sensor doesn't use an MCU module or RAM. Required flash ROM is typically 100 bytes per each GPIO pin that's used as a capacitive channel. Each channel requires just one external pull-up resistor.
|Figure 5. [RCT/CTS-sensor] coding example|
Running the CTS-sensor on an HCS08 device at fBus = 20 MHz results in an average sample time of about 9 μs. Integrating the CTS-sensor is straightforward and its capacitive sensing algorithm can coexist with custom applications on the same platform.
Test results of the CTS-sensor behavior can be seen with different turbo-control values (Figure 6 below, left) . The tested capacitive interface had various parasitic capacitances in the range of 15 to 35 pF, serial resistances in the range 20 to 60 Ω, and a glass dielectric distance of about 4 mm with an outlined electrode area of about 15 by 15 mm.
The figure shows the main difference of measurement time between a simple RCT-sensor (emulated with a CTS-sensor and its CTS_arg=0) and the real CTS-sensor (CTS_arg greater than 0) (Figure 6, right) . Both have been measured on the same capacitive interface and capacitive channel, with the same environmental conditions.
|Figure 6: [RCT/CTS-sensor]: results and comparison|
The results show that the CTS sensor allows for a fast capacitive measurement using the turbo-control. It also shows that with a different conversion time, the sensitivity does not change. The CTS sensor provides a guaranteed conversion time for a wide range of parasitic capacitances using optimized turbo-control.
The CTS algorithm allows for significantly faster capacitance measurements and a guaranteed maximal conversion time for typical hardware conditions. The CTS method offers noise reduction, low accumulated signal error, measurement accuracy, and reduced power consumption.
It's suited for embedded capacitive sensing, which means that the sensor, the sensing software, and the custom application can all coexist in the same firmware. This approach could significantly reduce the cost of the capacitive sensing interface design.
Libor Gecnuk holds an M.Eng. degree in textile engineering from Technical University, Liberec, Czech Republic. He joined Freescale in 2004. His current research interests include embedded systems and sensors, with a focus on automotive, medical, and custom applications. He can be reached at .