AN3236 · Application noteHow to increase the number of touchkeys for touch sensing applications on STM32 MCUs
Download .pdfOpen in the full document

Adding an extra touchkey

Basic hardware implementation

As shown in the figure below, a standard touchkey is made of a single-ended electrode. Two single electrodes can generate a third touchkey by interlacing teeth coming from each electrode.
Figure 1. Basic hardware implementation


Software implementation

The touch sensing library manages the channels acquisition as if there were only two single electrodes. The application must decode the result of the acquisition as shown in the table below.
Table 2. Decoding example
TouchkeysChannel 1 stateChannel 2 state
No touchIdleIdle
Touchkey 1 touchedDetectIdle
Touchkey 2 touchedIdleDetect
Touchkey 3 touchedDetectDetect

Limitation

The drawback of this hardware and software implementation is that there is no way to discriminate a touch on both touchkey 1 and touchkey 2, from a single touch on touchkey 3 as implemented in Figure 1 Basic hardware implementation.

This solution suits applications where only one touchkey can be detected at once or, if a few touchkeys are valid at the same time, where the touchkeys do not share an electrode.

Combined implementation

Combined implementation allows any touchkey from set 1, 2, or 3 to be touched simultaneously (see the figure below).
Figure 2. Combined implementation for multitouch capability


If two touchkeys from the same set are touched concurrently, an incorrect touchkey is detected. For example, the user can touch touchkeys 1, 6, and 8 at the same time, and the application decodes them correctly. If touchkeys 2 and 3 are touched simultaneously, only touchkey 3 is reported. Likewise, if touchkeys 4 and 5 are touched concurrently, touchkey 6 is incorrectly reported.

A channel can be connected to several double-ended electrodes with the following results:
  • The number of touchkeys can be doubled (very suitable for products with few channels)
  • GPIOs used for the touch sensing acquisition can be reduced
The figure below gives an example of an implementation where six touchkeys are generated with only three channels.
Figure 3. Implementation for six touchkeys with only three channels


Matrix hardware implementation

The double-ended electrode solution can be extended to create an electrode network as shown in the figure below.
Figure 4. Matrix hardware implementation


In this implementation example, seven channels provide a touchkey matrix of 12 touchkeys. Each touchkey is generated by interlacing a channel row with a channel column. For example, touchkey 1 is generated by interlacing CH1 with CH4.

It is recommended to have homogeneous sized touchkeys, so that each touchkey has the same sensitivity. This simplifies the threshold setup and acquisition can be achieved using the same sampling capacitor value.

Software implementation

The channel acquisition is managed by the touch sensing firmware library in the same way as for single electrodes. A decoding step must be also performed at application level depending on the combination of detected channels.

A touch on touchkey 1 triggers a detection on two channels, CH1 and CH4 (see Figure 4 Matrix hardware implementation ).

The decoding table mirrors the matrix shown in Figure 4 Matrix hardware implementation. A touchkey is activated when the two channels it is connected to, are in detection state.

Limitation

For such a touchkey matrix, one or several touchkeys can be touched simultaneously on the same row or the same column. As shown in the figure below, touchkey 1, 4, 7, and 10 are touched simultaneously and can be decoded without ambiguity.
Figure 5. Decodable multi-touch

However, when two touchkeys are touched on different rows or columns, four channels are detected and it is difficult to discriminate a true touch from a false one. This phenomenon is known as the “ghost” effect.

In the figure below, touchkey 1 and touchkey 5 are touched but, channels 1, 2, 4 and 5 are detected. From the application, it is impossible to determine which of the four touchkeys are touched.
Figure 6. Ghost effect

Maximizing the number of touchkeys

The user can combine the touchkey matrix with single electrode touchkeys to maximize the number of possible touchkeys. This gives a pure single touch interface.

In this configuration, single electrodes are added on each row and column of the touchkey matrix as shown in the figure below.
Figure 7. Touchkey matrix with a single electrode on each channel
There are two decoding cases detailed below:
  • If one channel is detected, the connected single electrode touchkey is touched.
  • If two channels are detected, the touchkey corresponding to the intersection of the two channels is touched.

In the case of multitouches, it is impossible to discriminate which touchkeys are touched. This solution is only adapted for applications where the user touches one key at a time.

Touchkeys set definition

For extra touchkeys and touchkey matrices, it is important to define the sets of touchkeys in which the touchkeys cannot be touched at the same time. This allows multi-touching capability across sets.

Sets can be categorized as follows:
  • a touchkey matrix and a few independent touchkeys that allow simultaneous touches on any of the independent touchkeys plus one touch on the touchkey matrix
  • two touchkey matrices that allow simultaneous touches on each touchkey matrix