inTouch Application Kit - Touch Sliders

XC83x
AP08129
inTouch Application Kit - Touch Sliders
Application Note
V1.0, 2012-02
Microcontrollers
Edition 2012-02
Published by
Infineon Technologies AG
81726 Munich, Germany
© 2012 Infineon Technologies AG
All Rights Reserved.
LEGAL DISCLAIMER
THE INFORMATION GIVEN IN THIS APPLICATION NOTE IS GIVEN AS A HINT FOR THE IMPLEMENTATION
OF THE INFINEON TECHNOLOGIES COMPONENT ONLY AND SHALL NOT BE REGARDED AS ANY
DESCRIPTION OR WARRANTY OF A CERTAIN FUNCTIONALITY, CONDITION OR QUALITY OF THE
INFINEON TECHNOLOGIES COMPONENT. THE RECIPIENT OF THIS APPLICATION NOTE MUST VERIFY
ANY FUNCTION DESCRIBED HEREIN IN THE REAL APPLICATION. INFINEON TECHNOLOGIES HEREBY
DISCLAIMS ANY AND ALL WARRANTIES AND LIABILITIES OF ANY KIND (INCLUDING WITHOUT
LIMITATION WARRANTIES OF NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OF ANY
THIRD PARTY) WITH RESPECT TO ANY AND ALL INFORMATION GIVEN IN THIS APPLICATION NOTE.
Information
For further information on technology, delivery terms and conditions and prices, please contact the nearest
Infineon Technologies Office (www.infineon.com).
Warnings
Due to technical requirements, components may contain dangerous substances. For information on the types in
question, please contact the nearest Infineon Technologies Office.
Infineon Technologies components may be used in life-support devices or systems only with the express written
approval of Infineon Technologies, if a failure of such components can reasonably be expected to cause the failure
of that life-support device or system or to affect the safety or effectiveness of that device or system. Life support
devices or systems are intended to be implanted in the human body or to support and/or maintain and sustain
and/or protect human life. If they fail, it is reasonable to assume that the health of the user or other persons may
be endangered.
AP08129
inTouch Application Kit - Touch Sliders
XC83x
Revision History: V1.0 2012-02
Previous Version(s):
Page
Subjects (major changes since last revision)
–
We Listen to Your Comments
Is there any information in this document that you feel is wrong, unclear or missing? Your feedback will help us to
continuously improve the quality of this document. Please send your proposal (including a reference to this document) to:
[email protected]
Application Note
3
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Table of Contents
1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2
2.1
2.2
Hardware & Program Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Program Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3
3.1
3.1.1
3.1.2
3.1.3
3.1.4
Sensing Touch on Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Slider Position Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2-pad Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3-pad Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4-pad Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Library for Position Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
4.1
4.2
U-SPY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
inTouch_Slider.ini . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
inTouch_Slider_II.ini . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
11
11
11
16
22
29
Appendix - Schematics and Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Application Note
4
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Introduction
1
Introduction
In today's Human-Machine Interface (HMI) designs, capacitive touch technology is now often more widely used
than traditional mechanical buttons. Capacitive touch technology is the more popular choice because it brings
flexibility, a high-level of customization, and a significant reduction in overall system cost.
The inTouch Application Kit is available to help learn about working with the advanced touch solutions provided
by Infineon. Step-by-step tutorials covers the basics of Infineon's touch solutions, while example application code
can be used to start developing new touch-related projects.
The inTouch Application Kit comprises of a mother board, supplied as a USB stick, and a number of daughter
boards. Figure 1 shows the USB stick with the Slider daughter board.
Among the many different touch input elements that can be designed with capacitive touch technology, the slider
is gaining popularity because of the intuitive control it provides. This application note describing the slider daughter
board, aims to highlight the ease of implementing a design with Infineon's touch solutions. Topics covered include
program flow, touch behavior and touch position calculation algorithm.
Figure 1
inTouch Application Kit (USB Stick and Slider board)
Application Note
5
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Hardware & Program Flow
2
Hardware & Program Flow
This section describes the hardware used and the connections involved.
2.1
Hardware
Infineon’s XC836MT 2FRI (Figure 2) is used in this application. The XC836MT is embedded in the inTouch
Application Kit’s USB stick. For more details regarding the USB stick, please refer to AP08126: Infineon Touch
Solutions - inTouch Application Kit.
Figure 2
Infineon’s XC836MT 2FRI
The inTouch Slider and inTouch Slider II boards (Figure 3) are available as plug-in daughter boards which are
part of the inTouch Application Kit.
Figure 3
Slider Boards
Application Note
6
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Hardware & Program Flow
The inTouch Slider board consists of a 4-pad slider (Figure 3, left). The inTouch Slider II board consists of a 2pad and a 3-pad slider (Figure 3, right). Both slider boards are standard PCBs with a 1mm thick plexiglas cover
glued to the board.
The 4-pad slider on the inTouch Slider board is connected to 4 LEDTS pad inputs of the XC836. 4 indicator LEDs
are each connected to an LEDTS line pin and they share an LEDTS column pin of the XC836. The 2-pad and 3pad sliders on the inTouch Slider II board are connected to 2 and 3 LEDTS pad inputs of the XC836 respectively.
The schematics are available in the Appendix - Schematics and Layout.
Users can tap or swipe the touch sliders.
2.2
Program Flow
This section presents an overview of the program in terms of the interrupts involved, and then provides the tasks
performed in each interrupt service routine. Both programs for inTouch_Slider and inTouch_Slider_II are
essentially the same. The main difference is that the program for inTouch_Slider has additional tasks to toggle the
indicator LEDs.
In terms of interrupts, the UART interrupt has the highest priority to ensure the smooth transmission of data to USPY. The Time Frame interrupt has the medium priority. In this service routine, touch sense related tasks are
performed each time pad capacitance has been measured. LED updates (for inTouch_Slider board), which are
performed in the Time Slice interrupt, have low priority. The Timer 2 (T2) Overflow interrupt is given lowest priority
due to its slow frequency. Figure 4 and Table 5 provide an illustration of the program overviews for inTouch_Slider
and inTouch_Slider_II boards respectively.
low
Figure 4
TIMER 2 OVERFLOW
every 2ms
low
TIME SLICE
INTERRUPT
every 320μs
medium
TIME FRAME
INTERRUPT
every 640μs
high
UART INTERRUPT
Slider Position
Calculation
LED settings
Touch Sense signal
processing
Communication with
PC (send & receive
data)
RETI
RETI
RETI
RETI
Program Overview for inTouch Slider board
Application Note
7
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Hardware & Program Flow
low
Figure 5
TIMER 2 OVERFLOW
every 2ms
medium
TIME FRAME
INTERRUPT
every 256μs
high
UART INTERRUPT
Slider Position
Calculation
Touch Sense signal
processing
Communication with
PC (send & receive
data)
RETI
RETI
RETI
Program Overview for inTouch Slider II board
The tasks performed in each interrupt service routine are further illustrated in the flowcharts that follow:
•
•
•
•
T2 Overflow Interrupt (Figure 6)
– The T2 module provides a slow time base by generating the T2 Overflow interrupt for calculations necessary
to handle the touch slider.
UART Interrupt (Figure 7)
– The UART module, which is part of the XC800 core, is used for full-duplex UART communication with the
PC.
Time Frame Interrupt (Figure 8)
– The LEDTS module generates this interrupt after every measurement where signal processing and touch
detection take place.
Time Slice Interrupt (Figure 9) (inTouch_Slider board only)
– The LEDTS module generates this interrupt after every LED column activation where the pattern for the next
LED column is loaded into shadow registers.
Application Note
8
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Hardware & Program Flow
Start
Startup over?
Yes
Condition slider
signals
Calculate Slider
Amplitude
No
Calibrate slider
pads
No
Slider
touched?
Yes
Update LEDs (for
inTouch_Slider
board)
Calculate Slider
Position
RETI
Figure 6
Timer 2 Overflow Interrupt Service Routine
Application Note
9
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Hardware & Program Flow
Start
Receiver
Interrupt?
Yes
New
command?
Yes
Retrieve data from
buffer
No
Check selected
button
No
Transmitter
Interrupt?
Yes
Shift data out to
buffer
No
RETI
Figure 7
UART Interrupt Service Routine
Start
Figure 8
RETI
Time Frame Interrupt Service Routine
Start
Figure 9
Mask LEDTS
ROM Library flags
for slider pads
LEDTS pads
signal processing
Dim LEDs based
on touched
position
Set LED LINE and
COMPARE values
RETI
Time Slice Interrupt Service Routine (for inTouch Slider only)
Application Note
10
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
3
Sensing Touch on Slider
This section describes how the LEDTS module of the XC836, complemented with a software library, controls the
touch slider. The algorithm for calculating the location of touch is also explained in the following section.
The main touch sensing functions, handled by software, are as follows:
•
•
•
•
•
Sample accumulation (ROM library)
Signal filtering and moving average calculation (ROM library)
Touch detection (ROM library)
Touch slider calibration (user software in Flash)
Signal tuning (user software in Flash)
If properly configured, the LEDTS automatically measures the capacitance of the slider pads. This capacitance
increases when a slider pad is touched. A library function in ROM processes the capacitance signals and detects
touch on the slider. It does so by accumulating a number of samples and low-pass filtering them to obtain a moving
average. The moving average filters noise and is used as a reference to detect sudden changes in capacitance.
When the slider is touched or released, a corresponding pad flag in RAM will be set or reset. For more information
on the LEDTS ROM Library, please refer to the XC836 User’s Manual.
The pad flags for the slider pads are unused (always cleared) in the slider position calculation algorithm. It is the
moving averages (“pad averages”) that are used instead to calculate the position of the touch. The slider pads are
automatically calibrated to the same sensitivity and resolution during startup. Once the pad averages are stable,
a position calculation algorithm is run if the slider is touched. The calculated position is then used to determine the
location of touch, and is shown on the LEDs.
3.1
Slider Position Calculation
This section describes the algorithm for calculating the location of touch on the slider. This section is categorized
according to the number of pads forming the touch slider.
3.1.1
2-pad Slider
The two touch pads of the slider are placed in a spatially-interpolated manner as shown in Figure 10. The slider
is divided into 2 sections for position calculation.
Section 1
Figure 10
Section 2
Spatially interpolated 2-pad slider layout and abstraction
Application Note
11
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
If the pads are calibrated to roughly the same sensitivity and a finger slides from left to right with constant speed
and constant pressure (constant effective finger area), the pad average signals are expected to behave in a linear
manner in this model as seen in Figure 11.
finger position
Right
Left
Section 1
Section 2
untouched_d
slider_d
untouched_e
slider_e
Figure 11
Pad average signals of the two pads when slider is swiped
Values untouched_d and untouched_e are the pad average levels for pads D and E respectively when they are
not touched.
If the pads have roughly the same sensitivity, the two signals can be tuned to have a common untouched (UT)
level (Figure 12). The actual signals can be expected to look like those in Figure 13. If the two pads have slightly
different sensitivity due to board layout, it may be necessary to manually modify the oscillation windows.
Left
Right
Section 1
Section 2
untouched_d
Figure 12
Pad average signals of the two slider pads after tuning
Application Note
12
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
Figure 13
Actual pad average signals after tuning
The, now common, untouched level (UT) is very high compared to the difference between touched and untouched
states. To make calculations easier, the signals are transformed near to zero by linear combinations which can be
represented by the formulae below. Figure 14 provides an illustration of the transformation.
X = UT – B
Application Note
Y = UT – A
13
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
Left
Right
Section 1
Section 2
UT
E
D
UT-MAXT
Y = UT - D
X = UT - E
MAXT
Y
X
position
0
0
Figure 14
Transformed pad average signals
Before the transformation, Section 1 has two signals between UT and UT-MAXT. UT stands for the untouched
level and UT-MAXT stands for the signal level when the largest area of the respective pad is touched (this happens
at the two extremes).
After the transformation, the X and Y signals have much lower values.
Application Note
14
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
The two signals can be described as:
X = MAXT × d
(1)
Y = MAXT – MAXT × d
X
If we rearrange Equation (1), we get MAXT = ---- which we can substitute in Equation (2):
d
X X
Y = ---- – ---- d
d d
(2)
X
Y + X = ---d
X
d = --------------X+Y
(3)
Y
d = 1 – --------------X+Y
(4)
One division is needed to calculate the position; this operation needs the most computing performance. To
minimize the error, it is safer to use Equation (3) if X is larger and Equation (4) if Y is larger.
A scaling factor of 2R is added to create a more usable calculated position (Figure 15 and Figure 16). R is for
resolution and corresponds to the number of left bitshifts in the numerator.
Section 1
Y × 2R
d = 2 R – ----------------X+Y
Section 2
X × 2R
d = ----------------X+Y
X,Y
MAXT
Y
X
0
d
2R
0
Figure 15
Transformed pad average signals after offsetting and scaling
Application Note
15
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
Figure 16
Actual calculated position
3.1.2
3-pad Slider
The three touch pads of the slider are placed in a spatially-interpolated manner as shown in Figure 17. The slider
is divided into 3 sections for position calculation.
Section 1
Figure 17
Section 2
Section 3
Spatially interpolated 3-pad slider layout and abstraction
If the pads are calibrated to roughly the same sensitivity and the finger slides from left to right with constant speed
and constant pressure (constant effective finger area), the pad average signals are expected to behave in a linear
manner in this model as seen in Figure 18.
Application Note
16
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
Right
Left
Section 1
Section 2
Section 3
slider_a
untouched_a
untouched_c
slider_b
untouched_b
slider_c
Figure 18
Pad average signals of the three slider pads during swiping
Values untouched_a, untouched_b and untouched_c are the pad average levels for pads A, B and C respectively
when they are not touched.
If the pads have roughly the same sensitivity, the three signals can be tuned to have a common untouched level
(Figure 19). The actual signals can be expected to look like those in Figure 20.
Left
Right
Section 1
Section 2
Section 3
untouched_a
slider_a
slider_b
slider_c
Figure 19
Pad average signals of the three slider pads after tuning
Figure 20
Actual pad average signals after tuning
The, now common, untouched (UT) level is very high compared to the difference between touched and untouched
states. To make calculations easier, the signals are transformed near to zero by linear combinations which can be
represented by the formulae below. Figure 21 provides an illustration of the transformation. This transformation
also makes the transitions between sections smooth, which is especially important if the three pads have different
sensitivity or unstable untouched levels due to imperfect calibration or a changing environment.
A+B
X = -------------- – C
2
Application Note
A+C
Y = -------------- – B
2
17
B+C
Z = -------------- – A
2
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
Left
Right
Section 1
Section 2
Section 3
UT
C
B
A
UT-MAXT
X=(A+B)/2-C
Y=(A+C)/2-B
Z=(B+C)/2-A
MAXT
Z
Y
0
position
X
-MAXT/2
Figure 21
Combined pad average signals
The resulting X, Y and Z signals still have three distinct sections.
Section 1
Before the transformation, Section 1 has three signals between UT and UT-MAXT (Figure 22). UT stands for the
untouched level and UT-MAXT stands for the signal level when the largest area of the respective pad is touched
(this happens at section borders).
Application Note
18
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
A, B, C
UT
UT-MAXT
d
Figure 22
Section 1 before transformation
After the transformation, the X, Y and Z signals have much lower values (Figure 23). The position axis has been
arbitrarily scaled from -1 to 2 in this region for convenience.
X, Y, Z
MAXT
Z
Y
0
d
X
-MAXT/2
-1
Figure 23
1
0
2
Section 1 after transformation
Application Note
19
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
Signal X is constant low in this section so it does not participate in the position calculation. The other two signals
can be described as:
MAXT
Y = ----------------- d
2
(1)
MAXT MAXT
Z = ----------------- – ----------------- d
2
2
(2)
MAXT
Y
If we rearrange Equation (1), we get ----------------- = ---- which we can substitute in Equation (2):
2
d
Y Y
Z = ---- – ---- d
d d
Y
Z = ---- ( 1 – d )
d
d(Y + Z) = Y
Y
d = -------------Y+Z
(3)
Z
d = 1 – -------------Y+Z
(4)
One division is needed to calculate the position; this operation needs the most computing performance. To
minimize the error, it is safer to use Equation (3) if Y is larger and Equation (4) if Z is larger.
An offset of 1 and a scaling factor of 2R are added to create a more usable calculated position (Figure 24). R is
for resolution and corresponds to the number of left bitshifts on the numerator.
Section 1 Left
Z × 2R
d = 2 × 2 R – ---------------Y+Z
Section 1 Right
Y × 2R
d = ----------------- + 2 R
Y+Z
Application Note
20
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
X, Y, Z
MAXT
Z
Y
0
d
X
-MAXT/2
0
Figure 24
2R
2*2R
3*2R
Section 1 after offsetting and scaling
Sections 2 and 3
In these two sections, the position can be calculated in a similar way as in Section 1, using the two non-constant
signals. Offsets of 4 and 7, and the same scaling factor, can then be added to sections 2 and 3 respectively to get
a calculated position of 0..9*2R.
Section 2 Left
Y × 2R
d = 5 × 2 R – ----------------X+Y
Section 2 Right
X × 2R
d = ----------------- + 4 × 2 R
X+Y
Section 3 Left
X × 2R
d = 8 × 2 R – ----------------X+Z
Section 3 Right
Z × 2R
d = ---------------- + 7 × 2 R
X+Z
Figure 25 gives an illustration of the calculated position across all 3 sections while Figure 26 shows the actual
calculated position.
Application Note
21
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
position
Left
Right
Z
Y
d
X
calculated position
0
3*2R
6*2R
Figure 25
Calculated position vs real position across all sections
Figure 26
Actual calculated position
3.1.3
4-pad Slider
9*2R
The four touch pads of the slider are placed in a spatially-interpolated manner as shown in Figure 27. The slider
is divided into 4 sections for position calculation.
Application Note
22
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
Section 1
Figure 27
Section 2
Section 3
Section 4
Spatially interpolated 4-pad slider layout and abstraction
If the pads are calibrated to roughly the same sensitivity and the finger slides from left to right with constant speed
and constant pressure (constant effective finger area), the pad average signals are expected to behave in a linear
manner in this model as seen in Figure 28.
Left
slider_a
Right
Section 1
Section 2
Section 3
Section 4
untouched_a
untouched_c
slider_c
untouched_d
untouched_b
slider_b
slider_d
Figure 28
Pad average signals of the four slider pads during swiping
Values untouched_a, untouched_b, untouched_c and untouched_d are the pad average levels for pads A, B, C
and D respectively when they are not touched.
If the pads have roughly the same sensitivity, the four signals can be tuned to have a common untouched level
(Figure 29). The actual signals can be expected to look like those in Figure 30.
Application Note
23
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
Left
Right
Section 1
Section 2
Section 3
Section 4
untouched_a
slider_a
slider_b
slider_c
slider_d
Figure 29
Pad average signals of the four slider pads after tuning
Figure 30
Actual pad average signals after tuning
The, now common, untouched level is very high compared to the difference between touched and untouched
states. To make calculations easier, the signals are transformed near to zero by linear combinations which can be
represented by the formulae below. Figure 31 provides an illustration of the transformation. This transformation
also makes the transitions between sections smooth, which is especially important if the four pads have different
sensitivity or unstable untouched levels due to imperfect calibration or a changing environment.
A+B+C
w = ------------------------- – D
3
Application Note
A+B+D
X = ------------------------- – C
3
A+C+D
Y = ------------------------- – B
3
24
B+C+D
Z = ------------------------- – A
3
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
Left
Right
Section 1
Section 2
Section 3
Section 4
UT
A
B
C
UT-MAXT
D
W=(A+B+C)/3-D
X=(A+B+D)/3-C
Y=(A+C+D)/3-B
Z=(B+C+D)/3-A
MAXT
Z
Y
0
position
X
-MAXT/3
W
Figure 31
Combined pad average signals
The resulting W, X, Y and Z signals still have four distinct sections.
Section 1
Before the transformation, Section 1 has three signals between UT and UT-MAXT (Figure 32). UT stands for the
untouched level and UT-MAXT stands for the signal level when the largest area of the respective pad is touched
(this happens at the section borders).
Application Note
25
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
A, B, C, D
UT
UT-MAXT
d
Figure 32
Section 1 before transformation
After the transformation, the W, X, Y and Z signals have much lower values (Figure 33). The position axis has
been arbitrarily scaled from -0.5 to 1.5 in this region for convenience.
W, X, Y, Z
MAXT
Z
Y
0
d
W, X
-MAXT/3
-0.5
1.5
0
Figure 33
Section 1 after transformation
Signals W and X are constant low in this section so they do not participate in the position calculation. The other
two signals can be described as:
Application Note
MAXT
Y = 2 ----------------- d
3
(1)
MAXT
MAXT
Z = 2 ----------------- – 2 ----------------- d
3
3
(2)
26
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
MAXT
Y
If we rearrange Equation (1), we get 2 ----------------- = ---- which we can substitute in Equation (2):
3
d
Y Y
Z = ---- – ---- d
d d
Y
Z = ---- ( 1 – d )
d
d(Y + Z) = Y
Y
d = -------------Y+Z
(3)
Z
d = 1 – -------------Y+Z
(4)
One division is needed to calculate the position; this operation needs the most computing performance. To
minimize the error, it is safer to use Equation (3) if Y is larger and Equation (4) if Z is larger.
An offset of 0.5 and a scaling factor of 2R are added to create a more usable calculated position (Figure 34). R is
for resolution and corresponds to the number of left bitshifts on the numerator.
Section 1 Left
Z × 2R
d = 1.5 × 2 R – ---------------Y+Z
Section 1 Right
Y × 2R
d = ----------------- + 0.5 × 2 R
Y+Z
W, X, Y, Z
MAXT
Z
Y
0
d
W, X
-MAXT/3
0
Figure 34
2R
2*2R
Section 1 after offsetting and scaling
Sections 2, 3 and 4
In these three sections, the position can be calculated in a similar way as in Section 1, using the two non-constant
signals. Offsets of 2.5, 4.5 and 6.5, and the same scaling factor, can then be added to sections 2, 3 and 4
respectively to get a calculated position of 0..8*2R.
Application Note
27
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
Section 2 Left
Y × 2R
d = 3.5 × 2 R – ----------------X+Y
Section 2 Right
X × 2R
d = ----------------- + 2.5 × 2 R
X+Y
Section 3 Left
X × 2R
d = 5.5 × 2 R – ----------------X+Z
Section 3 Right
Z × 2R
d = ---------------- + 4.5 × 2 R
X+Z
Section 4 Left
X × 2R
d = 7.5 × 2 R – ----------------X+Z
Section 4 Right
Z × 2R
d = ---------------- + 6.5 × 2 R
X+Z
Figure 35 gives an illustration of the calculated position across all 4 sections while Figure 36 shows the actual
calculated position.
position
Left
Right
Z
Y
W
X
d
calculated position
Figure 35
0
2*2R
4*2R
6*2R
8*2R
Calculated position vs real position across all sections
Application Note
28
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Sensing Touch on Slider
Figure 36
Actual calculated position
3.1.4
Library for Position Calculation
Infineon provides a function library for position calculation. The resolution, which was explained in earlier sections,
is user-selectable from 1 to 8. The XC82xMx and XC83xMx microcontrollers have a Multiplication/Division Unit
(MDU) for hardware acceleration. If the MDU is used for the division necessary to calculate the position, the
resolution is fixed at 8. The execution is faster and code size is smaller than without hardware acceleration. The
disadvantage is that the MDU increases the microcontroller’s current consumption almost 1mA.
Application Note
29
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
U-SPY
4
U-SPY
Two settings files, inTouch_Slider.ini and inTouch_Slider_II.ini have been configured for the inTouch_Slider
and inTouch_Slider_II boards respectively.
4.1
inTouch_Slider.ini
This settings file (Figure 37) is customized to allow the user to monitor the calculated slider position and the
parameters of the Touch Slider Library, while running the demonstration program.
Figure 37
inTouch_Slider.ini User Interface
Buttons
The buttons in this settings file are used to select the signal(s) to be monitored. The format of the data transmitted
for the buttons is shown in the following table (Table 1):
Table 1
Transmit Data Format for Buttons
D0
D1
Value (hex)
08
XX
Description
I.D. number
Button number
Application Note
30
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
U-SPY
The data received by the microcontroller will be used to determine the signals that will be transmitted to U-SPY for
display on the Oscilloscope.
Progress Bar
The progress bar displays the calculated slider position. The format of the transmitted data for the progress bar is
as follows (Table 2):
Table 2
Transmit Data Format for Progress Bar
D0
D1
D2
D3
Value (hex)
A2
XX
XX
XX
Description
I.D. number
Progress Bar Index
Calculated Position
(High Byte)
Calculated Position
(Low Byte)
Oscilloscope
The oscilloscope function allows the user to monitor up to 3 signals at a time (Figure 38). A total of 3 oscilloscopes
are available. In this application, only 2 oscilloscopes are used. If the “Slider Avg” button is selected, 4 signals will
be displayed (3 signals on 1 oscilloscope and 1 signal on another). If the “Position, Amp” button is selected, 2
signals will be displayed on 1 oscilloscope. The format of the transmitted data for the oscilloscope is as follows
(Table 3):
Figure 38
U-SPY Oscilloscope
Table 3
Transmit Data Format for Oscilloscope
D0
D1
D2
D3
D4
D5
D6
D7
Value (hex)
A4
01
XX
XX
XX
XX
XX
XX
Description
I.D.
number
Scope
number
Signal 1
high byte
Signal 1
low byte
Signal 2
high byte
Signal 2
low byte
Signal 3
high byte
Signal 3
low byte
Application Note
31
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
U-SPY
As mentioned in the previous section, the user is able to monitor two different types of signals in this settings file.
The signals displayed are as follows (Table 4: Slider Avg Mode, Table 5: Position, Amp Mode):
Table 4
Signals Displayed for Slider Avg Mode
Oscilloscope 1
Description
Colour
Signal 1
Signal 2
Signal 3
Slider_B Current Pad
Average
Slider_C Current Pad
Average
Slider_D Current Pad
Average
Green
Pink
Yellow
Signal 1
Signal 2
Signal 3
Slider_A Current Pad
Average
None
None
Green
Pink
Yellow
Signal 1
Signal 2
Signal 3
Slider Position
Slider Amplitude
None
Green
Pink
Yellow
Oscilloscope 2
Description
Colour
Table 5
Signals Displayed for Position, Amp Mode
Description
Colour
4.2
inTouch_Slider_II.ini
This settings file (Figure 39) is customized to allow the user to monitor the calculated slider position and the
parameters of the Touch Slider Library, while running the demonstration program.
Application Note
32
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
U-SPY
Figure 39
inTouch_Slider_II.ini User Interface
Buttons
The buttons in this settings file are used to select the signal(s) to be monitored. The format of the data transmitted
for the buttons is shown in the following table (Table 6):
Table 6
Transmit Data Format for Buttons
D0
D1
Value (hex)
08
XX
Description
I.D. number
Button number
The data received by the microcontroller will be used to determine the signals that will be transmitted to U-SPY for
display on the Oscilloscope.
Progress Bars
The progress bars display the calculated slider positions for the 2-pad and 3-pad sliders. The format of the
transmitted data for the progress bar is as follows (Table 7):
Application Note
33
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
U-SPY
Table 7
Transmit Data Format for Progress Bar
D0
D1
D2
D3
Value (hex)
A2
XX
XX
XX
Description
I.D. number
Progress Bar Index
Calculated Position
(High Byte)
Calculated Position
(Low Byte)
Oscilloscope
The oscilloscope function allows the user to monitor up to 3 signals at a time (Figure 40). A total of 3 oscilloscopes
are available. In this application, only 2 oscilloscopes are used. If the “Slider Avg” button is selected, 5 signals will
be displayed (2 signals on 1 oscilloscope for 2-pad slider and 3 signals on another for 3-pad slider). If the “Position,
Amp” button is selected, 4 signals will be displayed on 2 oscilloscope (2 signals each). The format of the
transmitted data for the oscilloscope is as follows (Table 8):
Figure 40
U-SPY Oscilloscope
Table 8
Transmit Data Format for Oscilloscope
Value
(hex)
Descriptio
n
D0
D1
D2
D3
D4
D5
D6
D7
A4
01
XX
XX
XX
XX
XX
XX
I.D.
number
Scope
number
Signal 1
high byte
Signal 1
low byte
Signal 2
high byte
Signal 2
low byte
Signal 3
high byte
Signal 3
low byte
As mentioned in the previous section, the user is able to monitor two different types of signals in this settings file.
The signals displayed are as follows (Table 4: Slider Avg Mode, Table 5: Position, Amp Mode):
Application Note
34
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
U-SPY
Table 9
Signals Displayed for Slider Avg Mode
Oscilloscope 1
Description
Colour
Signal 1
Signal 2
Signal 3
Slider_D Current Pad
Average (2-pad Slider)
Slider_E Current Pad
Average (2-pad Slider)
None
Green
Pink
Yellow
Signal 1
Signal 2
Signal 3
Slider_A Current Pad
Average (3-pad Slider)
Slider_B Current Pad
Average (3-pad Slider)
Slider_C Current Pad
Average (3-pad Slider)
Green
Pink
Yellow
Signal 1
Signal 2
Signal 3
2-pad Slider Position
2-pad Slider Amplitude
None
Green
Pink
Yellow
Signal 1
Signal 2
Signal 3
3-pad Slider Position
3-pad Slider Amplitude
None
Green
Pink
Yellow
Oscilloscope 2
Description
Colour
Table 10
Signals Displayed for Position, Amp Mode
Oscilloscope 1
Description
Colour
Oscilloscope 2
Description
Colour
Application Note
35
V1.0, 2012-02
36
D
C
1
2
2
20
18
16
14
12
10
8
6
4
2
AN0
AN1
AN2
AN3
AN4
AN5
AN6
COL2
COL1
COL0
LINE6
LINE5
LINE4
LINE3
COL5 LINE2
COL4 LINE1
COL3 LINE0
TP1
19
17
15
13
11
9
7
5
3
1
PAD_XS
GND
3
TP2
3
4
4
PAD_XS
Application Note
R4 470R
R3 470R
R2 470R
R1 470R
5
LED1
green
LED3
green
LED4
green
Slider
5
Touch Sense Application Kit
LED2
green
Figure 41
B
A
1
6
6
D
C
B
A
AP08129
inTouch Application Kit - Touch Sliders
Appendix - Schematics and Layout
Appendix - Schematics and Layout
inTouch Slider Board Schematics
V1.0, 2012-02
1
TP4
PAD_XS
1
TP3
1
PAD_XS
1
AP08129
inTouch Application Kit - Touch Sliders
Appendix - Schematics and Layout
3DEL
2DEL
1DEL
Figure 42
inTouch Slider Board Componenet Bottom Layout
Figure 43
inTouch Slider Board Top Layout
Application Note
37
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
Appendix - Schematics and Layout
Figure 44
inTouch Slider Board Bottom Layout
Application Note
38
V1.0, 2012-02
39
D
C
1
2
2
20
18
16
14
12
10
8
6
4
2
AN0
AN1
AN2
AN3
AN4
AN5
AN6
COL2
COL1
COL0
LINE6
LINE5
LINE4
LINE3
COL5 LINE2
COL4 LINE1
COL3 LINE0
TP1
19
17
15
13
11
9
7
5
3
1
PAD_XS
GND
3
3
TP2
Application Note
4
4
PAD_XS
Figure 45
B
A
1
Slider
5
Touch Sense Application Kit
5
6
6
D
C
B
A
AP08129
inTouch Application Kit - Touch Sliders
Appendix - Schematics and Layout
inTouch Slider II Board Schematics
V1.0, 2012-02
PAD_XS
1
TP5
1
TP4
PAD_XS
1
TP3
1
PAD_XS
1
AP08129
inTouch Application Kit - Touch Sliders
Appendix - Schematics and Layout
Figure 46
inTouch Slider II Board Top Layout
Figure 47
inTouch Slider II Board Bottom Layout
Application Note
40
V1.0, 2012-02
AP08129
inTouch Application Kit - Touch Sliders
References
References
The list below provides resources that may be useful to the user.
1.
2.
3.
4.
5.
6.
7.
8.
User’s Manual - XC83x; 8-Bit Single-Chip Microcontroller
Application Note - AP08100 - Configuration for Capacitive Touch-Sense Application
Application Note - AP08110 - Design Guidelines for XC82x and XC83x Board Layout
Application Note - AP08113 - Capacitive-Touch Color Wheel Implementation
Application Note - AP08115 - Design Guidelines for Capacitive Touch-Sensing Application
Application Note - AP08121 - Infrared Remote Controller with Capacitive Touch Interface
Application Note - AP08122 - 16-Button Capacitive Touch Interface with XC836T
Application Note - AP08124 - XC82/83x Design Guidelines for Electrical Fast Transient (EFT) Protection in
Touch-Sense Applications
9. Application Note - AP08126 - Infineon Touch Solutions - inTouch Application Kit
10. Application Note - AP08127 - inTouch Application Kit - Buttons
11. Application Note - AP08128 - inTouch Application Kit - Touch Wheel
12. Application Note - AP08130 - inTouch Application Kit - LED Matrix
13. Link to XC83x-Series - www.infineon.com/xc83x
14. Link to Solutions for advanced touch control - www.infineon.com/intouch
Application Note
41
V1.0, 2012-02
w w w . i n f i n e o n . c o m
Published by Infineon Technologies AG