ST STMPE811 Specification sheet

January 2009 Rev1 1/13
TN0074
Technical note
Calibration procedure for a resistive touchscreen
system based on the STMPE811
Introduction
This document describes the calibration procedures for a resistive touchscreen system
based on the STMPE811 8-bit port expander with advanced touchscreen controller. The
system consists of a screen to display information to the user, and a touch sensor panel
controlled by the STMPE811 to detect and define the location of a touch event. Each
component has its own resolution and independent coordinate system.
It may not be possible to use the touch coordinates produced by the touchpanel directly as
the screen coordinates. This is because typically there is a mismatch between the two
coordinate systems caused by factors such as mechanical placement error, scale
difference, or the series resistance of the tracks connecting the touchpanel and its driver IC.
A set of transfer functions must be used to convert the touchpanel coordinates to the screen
coordinates. The constants of the functions are defined during the calibration process.
www.st.com

Contents TN0074
2/13
Contents
1 2-constants calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 3-constants calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

TN0074 2-constants calibration
3/13
1 2-constants calibration
2-constants calibration only corrects misalignment on the X and Y axes, both scaling factor
and offset. Angle misalignment is not corrected. This type of calibration is suitable when the
angle error is negligible (small screen) and a simple calculation is required. The procedure
for 2-constants calibration is quite straightforward.
Figure 1. Mismatch which can be corrected with 2-constants calibration
Point A in Figure 1 is located at coordinate (3,3) on the touchpanel, but on the screen it is
located at coordinate (1.6,1.4). This condition can be corrected using the following transfer
function:
Equation 1
Equation 2
Where:
●YDis the screen's Y value
●XDis the screen's X value
●Y is the touchpanel's Y value
●X is the touchpanel's X value
●a, b, c, d are the transfer function parameters
The two unknowns in both equations can be resolved by choosing two points and defining
them on the screen. For an example, please refer to Figure 2.
AM01966v1
A
baYYD+=
dcXXD+=

2-constants calibration TN0074
4/13
Figure 2. Example of calibration points
The calibration points are described in Table 1 below:
After the user touches the points on the touchpanel, the panel coordinates are as shown in
Table 2, assuming there is some variation in touch locations.
Only two points are required to solve the equations, but it is recommended to perform the
equations twice and use an average of the results.
In this illustration, there are two groups of equations to be solved. Group 1 is defined as
follows:
Equation 3
Equation 4
Table 1. 2-constants calibration points
Point XDYD
113
211
351
453
Table 2. Input from touchpanel for defined points
Point X Y
11.86.3
21.852.3
39.752.2
4 9.8 6.35
AM01967v1
1
2
3
4
1
2
3
4
5
1
2
3
4
5
6
7
8
9
10
11
3
2
1
1
2
3
4
5
6
7
11D bYaY +=
11D dXcX +=

TN0074 2-constants calibration
5/13
To solve these equations, points 1 and 3 are used:
●Y axis
Equation 5
Solving the matrix results in a1 = 0.487 and b1 = -0.073
●X axis
Similarly, the results are c1 = 0.503 and d1 = 0.095
Group 2 is defined as follows:
Equation 6
Equation 7
Point 2 and 4 are used to solve these equations:
●Y axis
Solving the equation:
Equation 8
●X axis
Solving the equation:
Equation 9
At this point, take an average of the results from the two groups of equations, and this is the
final result of the calibration.
Table 3. Final calibration result using the average of the two point groups
Parameter 1 2 Average
a 0.487 0.494 0.4905
b -0.073 -0.136 -0.1045
c 0.503 0.497 0.5
d 0.095 0.130 0.1125
⎟
⎟
⎠
⎞
⎜
⎜
⎝
⎛
⎟
⎟
⎠
⎞
⎜
⎜
⎝
⎛
=
⎟
⎟
⎠
⎞
⎜
⎜
⎝
⎛
1Y 1Y
b
a
Y
Y
3
1
1
1
3D
1D
⎟
⎟
⎠
⎞
⎜
⎜
⎝
⎛
⎟
⎟
⎠
⎞
⎜
⎜
⎝
⎛
=
⎟
⎟
⎠
⎞
⎜
⎜
⎝
⎛
12.2 13.6
b
a
1
3
1
1
22D bYaY +=
22D dXcX +=
a2 = 0.494 and b2 = -0.136
c2 = 0.497 and d2 = 0.130

2-constants calibration TN0074
6/13
Hence, the transfer functions from the touchpanel coordinates to the display coordinates
are:
The points chosen for calibration should be capable of representing the entire screen area.
The recommended positions are the corners of the screen, but not too close to the center of
the screen or the borders of the touchpanel. Choosing calibration points too close to the
center results in poor representation of the areas further away from the center. However, if
the points are too near the edges, any mechanical imperfections present in the panel may
affect the result of the calibration.
It is recommended to use points located at 20% and 80% of the X and Y axes, as shown in
Figure 3 below.
Figure 3. Recommended calibration point positions: 20% and 80% of X and Y axes
1125.0X5.0X 1045.0X4905.0Y
D
D
+=
−=
AM01968v1
20%
80%
100%
80%
100%
20%

TN0074 3-constants calibration
7/13
2 3-constants calibration
This method of calibration corrects misalignment of the X and Y axes, as well as angle
misalignment. Figure 4 shows an illustration of mechanical misalignment.
Figure 4. Mechanical placement error which includes angle error
Mathematical expressions can be derived from Figure 4. They are:
Equation 10
Equation 11
Introducing a scale difference between the panel and the display, we have:
Equation 12
If an error is introduced in the X and Y axis (represented by XTand YT) of Equation 12, the
resulting equation is:
Equation 13
Using trigonometric identity with the assumption that ∆θ → 0, the result is:
Equation 14
and Equation 13 can be modified to:
AM01969v1
θ
-
Δθ
θ
Δθ
(X
D
,YD)
(X,Y)
()
[]
θθ= sinR,cosRY,X
() ()()
[]
θ∆−θθ∆−θ= sinR,cosRY,X DDDD
( ) () ()
[]
θ∆−θθ∆−θ= sinRK,cosRKY,X YXDD
( ) () ()
[]
TYTXDD YsinRK,XcosRKY,X +θ∆−θ+θ∆−θ=
()
θ−θθ∆=θ∆−θ
θθ∆+θ=θ∆−θ
sincos)sin( sincoscos

3-constants calibration TN0074
8/13
Equation 15
Equation 16
To simplify the equations, Equation 15 and 16 can be rewritten as:
Equation 17
Equation 18
It is clear that to solve Equation 17 and 18, at least 3 points are required. The points used
must be independent of each other (not in a straight line).
The 3 independent points chosen are illustrated in Figure 5. The coordinate (XDn,YDn)
contain the chosen points of the screen coordinate, while (Xn,Yn) represents the user’s
input on the touchpanel corresponding to the points displayed on the screen.
Figure 5. Example of 3 independent points
The matrix representation is as follows:
Equation 19
TXXD XsinRKcosRKX +θθ∆+θ=
TYYD YsinRKcosRKY +θ−θθ∆=
CBYAXXD++=
FEYDXYD++=
AM01970v1
(X1,Y 1)
(X2,Y 2)
(X3,Y 3)
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
×
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
=
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
C
B
A
1YX 1YX 1YX
X
X
X
33
22
11
3D
2D
1D

TN0074 3-constants calibration
9/13
Equation 20
The unknown can be calculated using the equations that follow.
Equation 21
Equation 22
where
and
To increase accuracy, more points can be used to solve the equation. An example 5-point
calibration is shown below. Similar to 3-point calibration, a matrix representation is formed:
Equation 23
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
×
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
=
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
F
E
D
1YX 1YX 1YX
Y
Y
Y
33
22
11
3D
2D
1D
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
=
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
−
3D
2D
1D
1
X
X
X
C
B
AM
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
=
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
3D
2D
1D
1
Y
Y
Y
F
E
DM
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
=
1YX 1YX 1YX
33
22
11
M
() ()
M
M
MAdj
det1
1=
−
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
×=
⎟
⎟
⎟
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎜
⎜
⎜
⎝
⎛
C
B
A
X
X
X
X
X
5D
4D
3D
2D
1D
M

3-constants calibration TN0074
10/13
Equation 24
where
Equation 23 and 24 are solved by multiplying both sides by (MTxM)-1x MTto get:
Equation 25
Equation 26
To simplify, the values of the unknowns are calculated as follows:
Equation 27
where
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
×=
⎟
⎟
⎟
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎜
⎜
⎜
⎝
⎛
F
E
D
Y
Y
Y
Y
Y
5D
4D
3D
2D
1D
M
⎟
⎟
⎟
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎜
⎜
⎜
⎝
⎛
=
1YX 1YX 1YX 1YX 1YX
55
44
33
22
11
M
()
⎟
⎟
⎟
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎜
⎜
⎜
⎝
⎛
×××=
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
−
5D
4D
3D
2D
1D
T
1
T
X
X
X
X
X
C
B
AMMM
()
⎟
⎟
⎟
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎜
⎜
⎜
⎝
⎛
×××=
⎟
⎟
⎟
⎠
⎞
⎜
⎜
⎜
⎝
⎛
−
5D
4D
3D
2D
1D
T
1
T
Y
Y
Y
Y
Y
F
E
DMMM
d/dF d/dE d/dD d/dC d/dB d/dA
3Y
2Y
1Y
3X
2X
1X
=
=
=
=
=
=

TN0074 3-constants calibration
11/13
Equation 28
The recommended points to use in 5-point calibration are shown in Figure 6.
Figure 6. Recommended point locations for 5-point calibration
(
)
()( )()
()()()
()( )
()
()( )()
()()()
()( )
()
2
YYY3Y
YYYYY2Y
YYYYY1Y
2
XXX3X
XXXXX2X
XXXXX1X
222
mlkd
mlkkl5d mkllk5d mlkd
mlkkl5d mkllk5d 25d
χ−β×α×+φ×α−ε×χ×+ε×β−φ×χ×=
φ×α−ε×χ×+ε×−φ××ε+χ×−α××=
ε×β−φ×χ×+φ×−ε
××φ+χ−β××=
χ−β×α×+φ×α−ε×χ×+ε×β−φ×χ×=
φ×α−ε×χ×+ε×−φ××ε+χ×−α××=
ε×β−φ×χ×+φ×−ε××φ+χ−β××=
ε×β−φ×α−φ×ε×χ×+χ−β×
α×=
∑
=
=α
5
1k
2
k
X∑
=
=β
5
1k
2
k
Y∑
=
×=χ
5
1k kk YX ∑
=
=ε
5
1k k
X∑
=
=φ
5
1k k
Y
∑
=
×=
5
1k DkkX XXk ∑
=
×=
5
1k DkkX XYl ∑
=
=
5
1k DkX Xm ∑
=
×=
5
1k DkkY YXk
∑
=
×=
5
1k DkkY YYl ∑
=
=
5
1k DkY Ym
AM01971v1
2
0%
80%
1
00%
80%
1
00%
2
0%

Revision history TN0074
12/13
3 Revision history
Table 4. Document revision history
Date Revision Changes
26-Jan-2009 1 Initial release.

TN0074
13/13
Please Read Carefully:
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,
DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE
GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.
© 2009 STMicroelectronics - All rights reserved
STMicroelectronics group of companies
Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan -
Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America
www.st.com
Other ST Computer Hardware manuals

ST
ST X-NUCLEO-OUT04A1 User manual

ST
ST X-NUCLEO-DRP1M1 User manual

ST
ST STM32G071B-DISCO User manual

ST
ST X-NUCLEO-EEPRMA2 User manual

ST
ST FP-ATR-BLE1 User manual

ST
ST X-NUCLEO-OUT16A1 User manual

ST
ST STM32F3DISCOVERY User manual

ST
ST X-NUCLEO-OUT19A1 User manual

ST
ST PCC020V1 User manual

ST
ST L6470H User manual

ST
ST STM32WL Series User manual

ST
ST AN1235 Installation and operating instructions

ST
ST X-NUCLEO-IDB04A1 User manual

ST
ST MotionTL User manual

ST
ST ST25DV-DISCOVERY User manual

ST
ST X-LINUX-NFC5 User manual

ST
ST X-NUCLEO-53L8A1 User manual

ST
ST X-NUCLEO-OUT02A1 User manual

ST
ST STM32 Nucleo User manual

ST
ST STM32F4 Series User manual