Give away medical masks when you place an order. learn more

Microcontrollers Enable Touch Sensing Across Many Applications

Touch-based interfaces have transitioned from being a specialty feature on high-end consumer products to a common feature that consumers demand on any product, even inexpensive appliances. The good news for designers is that capacitive-based touch sensing requires the simplest sensor hardware – electrodes etched on a printed circuit board PCB. However, designing touch capabilities correctly requires relatively complex software and/or some dedicated hardware acceleration on a microcontroller (MCU), depending on the application and number of keys. Still, the cost to manufacture capacitive, touch-based interfaces is low, and touch panels are extremely reliable, even in tough environments. So, the trend toward touch interfaces will inevitably continue.

Touch pad complexity and MCUs

Virtually any MCU can handle basic touch sensing. For example, Microchip supports several touch technologies, but the Capacitive Voltage Divider (CVD) scheme works across the company's entire portfolio of MCUs that integrate an A/D converter, including members of the 6-pin PIC10 product family. The CVD technique relies on the A/D Converter's sample and hold capacitor as a reference, and the converter senses the voltage level to detect a touch (Figure 1).

Figure 1: Microchip uses a Capacitive Voltage Divider technique that precharges a sample and hold capacitor and uses an A/D converter to sense a touch.

Devices at the low-end of the 8-bit MCU segment may only be capable of handling a couple of keys. Higher-end 8-bit MCUs can handle many more keys. According to Microchip, the PIC16 8-bit family, the mid range of the company's 8-bit portfolio, includes up to 30 A/D converter channels and a capacitive touch system based on the CVD touch scheme. It also requires one channel per electrode.

But the A/D channel count isn't necessarily the design aspect that limits the number of keys a designer can implement using any MCU. According to Microchip, memory gates the number of keys because of the amount of data necessary to store per sensor.

Microchip supplies touch software, including source code, at no charge to its customers. This software performs myriad functions to ensure accuracy, including filtering 60-Hz noise and high-frequency noise, and adjusting parameters for environmental factors such as temperature and humidity. Of course, the MCU also constantly scans the keys multiplexing the channels to the A/D converter.

According to Microchip, a typical PIC16-based implementation might support 22 keys, requiring approximately 80 percent of the MCU's processing time to run the touch interface and deliver a maximum response time in the 100- to 200-msec range. Customers typically implement four to 10 sensors, according to Microchip.

Charge Time Measurement Unit

Microchip supports a different touch sensing methodology on some MCUs using an analog peripheral called the Charge Time Measurement Unit (CTMU). The CTMU wasn't developed specifically for touch but can be used in touch applications and requires less processor overhead.

The CTMU uses a constant current source to repeatedly charge a touch circuit for a specific period of time and sample the voltage with the A/D converter. The touch circuit will charge to a higher voltage when there is no finger present or a lower voltage when the sensor is touched.

The CTMU scheme allows an MCU to support as many keys as there are A/D channels. It supports key scanning times as low as 4 µs. Microchip offers the peripheral in selected 8-bit PIC18 and 16-bit PIC24 products. For example, the general purpose PIC18F45K22 MCU and the USB-enabled PIC18F46J50 MCU include the CTMU. In the 16-bit line, the general purpose PIC24F04KA201 MCU, the USB-enabled PIC24FJ64GB004 MCU, and the PIC24FJ256DA210 MCU with integrated LCD controller all include the CTMU.

Dedicated hardware for touch

Renesas approaches touch sensing in a different way. Most of the company's MCUs can support a touch interface in software. But Renesas made a strategic decision not to supply and support touch software because, according to the company, software implementations are too susceptible to component drift, noise and influences that impact accuracy.

Instead, Renesas targets members of the 16-bit R8C MCU family that have a peripheral called the Sensor Control Unit (SCU) for touch applications. The SCU is based on state machines, comparators, and timers that, when combined, sense touch and perform noise counter measures and continuous system calibration in hardware. The MCU family includes devices that can sense as many as 36 keys using only 15 percent of the host MCU's compute power.

Figure 2: The Renesas R8C/33T family of MCUs integrates a Sensor Control Unit that offloads much of the touch sensing task from the MCU processor.

The Renesas scheme relies on a comparator that measures the charge and discharge of a reference circuit and touch circuit. The scheme uses timers to measure the time required for the touch circuit to drop below a threshold.

According to Renesas, power consumption is another advantage of dedicated hardware. The company's MCUs can use as little as 16 µA while scanning a keypad for input. The lowest power Renesas has seen for software implementations in industry is in the 30 µA range. Renesas guides customers toward R8C MCUs, either in standalone scenarios to handle touch and application functionality, or as a dedicated touch controller for applications requiring a faster processor.

Software supports software and hardware schemes

Freescale's approach is to give design teams the flexibility of a consistent software interface along with the choice of using an MCU with dedicated touch hardware or a standard MCU that relies on software algorithms. The company's Xtrinsic Touch-Sensing Software (TSS) provides the same interface as the embedded software developer, regardless of the MCU's hardware capabilities. TSS works across the 8-bit HCS08 and 32-bit Coldfire MCU families that have no dedicated touch hardware and across the 32-bit ColdFire+ and Kinetis MCU families that include the company's Touch Sensing Input (TSI) peripheral.

Freescale supports a number of touch algorithms for the HCS08 and Coldfire. Perhaps the simplest is GPIO and uses general-purpose I/O lines. This timer-based scheme measures how long it takes to charge an external capacitor in parallel with the sensor electrode. If a touch is present, it takes longer for the voltage to charge to a set threshold.

The TSI peripheral completely offloads the MCU of the touch-sensing task and supports 16 keys. Freescale says that TSI-enabled MCUs can operate from as little as one µA of current and still awaken when a key is touched.

Figure 3 depicts the software implementation. As shown, the layered architecture allows a design team to use the same interface for keypads, sliders, and rotary sensors regardless of whether the TSI module is present. It also allows the design team to choose among multiple touch algorithms in the absence of the TSI.

Figure 3: Freescale's Xtrinsic Touch-Sensing Software allows embedded designers to write identical code to access keys, sliders, and rotary sensors whether a software algorithm or the company's Touch Sensing Input peripheral handles the touch implementation.

Touch interfaces are a viable possibility for virtually any project. To learn more, designers can access Hotenda product training modules on touch sensing including an mTouch Capacitive Touch Sensing presentation from Microchip and a CapSense Express presentation is from Cypress. The Hotenda website also features a Capacitive Touch resource page with links to a variety of ICs that support touch, MCU vendors and other technical information.