The most valuable piece of
information that I learned from
reading AN1104 was just how
limiting a “matrix mindset” can be
when implementing touch inputs. For
example, I have always assumed that
you need eight input pins in order to
implement a keypad with 16 keys
(four columns and four rows, of
course). However, AN1104 clearly
explains how it’s possible to scan as
many as 21 touch inputs using only
six input pins. Even more amazing —
at least to me — is the fact that eight
input pins can scan up to 36 touch
inputs!
It’s all accomplished by designing
the touch input pads on a PCB in
such a way that they become what
are called paired sensor elements.
Figure 6 (adapted from Figure 4 in
AN1104) shows a traditional single
sensor element on the left side; it’s
simply a rectangular copper area that
that can be connected to a single
input pin and used as a touch sensor.
The element on the right is called a
paired sensor element because each
of its two (separate) copper areas can
be connected to a different input pin.
Whenever a finger touches the
(insulated) surface of a paired sensor
element, touch values of two
different touch inputs are affected.
As a simple example of how
these two types of sensing elements
can be combined, let’s consider how
many sensors we can implement
using only four input pins. First, each
pin can be directly connected to its
own single sensor element (that’s
four sensors so far). Also, each input
pin can be connected to three
different paired sensor elements,
each of which is connected to one of
the remaining three input pins. At
first glance, you might think that
would be 4* 3 or 12 additional
sensors, but it’s actually half that
number. For example, connecting pin
2 and pin 3 to one paired sensor
element is the same as connecting
pin 3 and pin 2 to a second paired
sensor element. In order to eliminate
all those duplications, we need to
divide by two. Therefore, four input
pins can be connected to four single
sensor elements, and ( 4* 3)/2 or six
■ FIGURE 6.
Single sensor
element vs. paired
sensor element.
paired sensor elements for a total of
10 sensors.
If any of that isn’t clear, take a
look at Figure 7 which presents the
same information visually. The
bottom row of Figure 7 displays the
four single sensor elements. The next
row up shows the three possible
paired sensors that include input 4.
The third row from the bottom shows
the two possible paired sensors that
include input 3. (Don’t forget, the 4
and 3 combination has already been
accounted for in the previous row.)
Finally, the top row contains the one
remaining paired sensor combination
that includes input 2. (Again, the
other two possible combinations for
input 2 have already been accounted
for.) So, that gives us a total of 10
sensors for four touch inputs. Of
course, on a PCB the keys aren’t
restricted to the triangular
arrangement of Figure 7; they can be
placed in any arrangement you want
— even a matrix!
In general, N input pins can be
connected to N*(N-1)/2 + N sensors.
If you do a little algebraic
simplification, that formula is
equivalent to N*(N+1)/2; so, with
four touch input pins, we again arrive
at 4*( 5)/2 = 10 sensors. (And you
thought algebra was boring!) If you
do the math, you will see how six
input pins can be used to scan as
many as 21 touch sensors.
If you don’t like doing math (or
algebra), you can refer to Figure 8
which presents the maximum
number of sensors vs. the number of
touch input pins (from 2 to 10). As
you can see, the 10 touch inputs on
the 18M2 make it theoretically
possible for the chip to interface with
55 touch sensors. (However, you
might have to hold your finger on a
touch sensor a little longer than usual
to give the chip enough time to
process all that data!)
PCBS TO THE RESCUE!
A couple of months ago, I
decided to use the information
discussed in AN1104 to design a
PCB for use as a touch-sensitive
keypad. Figure 9 is a photo of my
first prototype PCB installed in an
18M2 breadboard circuit. (The piezo
provides an audible key-click for each
key-press.) Because of the rectangular
key layout, it may look like a matrix
keypad, but it isn’t – I have seen the
light, and I am free!
As you can see, the PCB uses the
same key arrangement as my
frustrating stripboard version. In this
2 & 1
■ FIGURE 7. Visual representation
of a paired
sensor
touchpad.
3& 2 3&1
4& 3 4& 2 4&1
4
3
2
1
Sensors
3
6
10
15
21
28
36
45
55
N*(N+1)/2
■ FIGURE 8. Maximum number of
sensors vs. number of touch
input pins.
Inputs
2
3
4
5
6
7
8
9
10
N
February 2011 17