This post is also available in: Türkçe

  1. Video Lesson
  2. Touch Panel Calibration

  3. Mathematical Solution of Calibration
  4. Result


  • Touch panels are used by attaching them to the screens. However, the coordinates of the panel and the coordinates of the screen do not match. That’s why they have to be calibrated.
  • Previously I had to calibrate through the function in the library I wrote for 4-wire resistive type panes. However, I learned the mathematical solution of the 2 point calibration method with the aim of learning the calibration mathematics of users of different types of touch panel.
  • Do not forget to watch the video lesson.


  • There are many calibration methods. (2-4-6-12-16 point methods are available.)
  • In general, large screens are calibrated using 2 denier values to provide angular calibration.
  • Even though it is a 2 point method, touch 4 points. This is because X1 is X2 and Y1 is Y2.
  • To do this, first of all, on the screen where the touch panel is installed, pixels are formed in certain places.
en ideal kalibrasyon ölçüleri
Positions to create for user
  • The picture above is a template. Here 4 red dots are our calibration points.
  • These points are created in the GLCD where the pixel rendering function corresponds to the above metrics. This is just to show where the user will touch.
  • For a 240×128 GLCD, the coordinates that need to be created are points that need to be touched according to the template image above;
    • 1.POINT   x=%20 ve y=%80 so x=240*20/100= 48   y=128*80/100=102   so (48,102)
    • 2.POINT  x=%20 ve y=%20 so x=240*20/100=48     y=128*20/100=25     so (48,25)
    • 3.POINT  x=%80 ve y=%20 so x=240*80/100=192   y=128*20/100=25     so (192,25)
    • 4.POINT  x=%80 ve y=%80 so x=240*80/100=192   y=128*80/100=102  so (192,102)
  •  We have calculated above in which coordinates the 4 calibration points on the 240×128 screen should be created on the screen. Pixels will be created at these points and the user will be asked to touch the place.
  • When the user touches this point, the raw x and y values coming from the touch panel will be read. (see circuit diagram and other details for “resistive touch panel library”)
  • For example (the raw values are the values used in the lesson, and the value that each panel gives may vary).
    • The raw value read when the first POINT is touched is x = 230 and y = 730. That is, when the point on the GLCD is touched (48,102), the read value is (230,730).
    • The raw value read when the second POINT is touched is x = 228 and y = 237. That is, the value read when the point (48,25) on the GLCD is touched (228,237) is.
    • The raw value read when the third POINT is touched is x = 780 and y = 232. That is, when the point (192,25) is touched on the GLCD, the read value is (780,232).
    • The raw value read when the fourth POINT is touched is x = 773 and y = 704. That is, when the point (192,102) on the GLCD is touched, the read value is (773,704).
  • We record the points touched in the above manner and the raw data from these points (the data comes from the touch panel).
  • For screen control, you can use the “SAP1024B_GRAFIK_LCD” library I wrote earlier.
Dokunmatik Panel Kalibrasyonu
Four points are created on the screen above and the user is asked to touch. Thus, the received data is processed. We call it the “virtual spots” from here.
Touched Points in GLCD Values read from Touch Panel
1.POINT 48 102 230 730
2.POINT 48 25 228 237
3.POINT 192 25 780 232
4.POINT 192 102 773 704
  • The values read when this point is touched are our raw values.
  • After these values, the mathematical operation sequence came up.
  • With this process we will arrive at the solution by calculating our deviation shares.
    As can be understood from its name, the deviation share calculates the deviation between the GLCD and the touch panel. Correcting the values accordingly enables the GLCD to have the same point in the coordinate plane in the touch panel.
  • Example = If you touch the point of the screen (100,100) this time you will read it (100,100) through the touch panel instead of the different value.


Dokunmatik Panel Kalibrasyonu
Formulas to calculate deviation values and result formula

 Calculation of Deviation Values

  • Before going to the end with the last formula, I need to calculate 4 values which I call “deviation value“.
  • We will calculate the deviation values by using the table above.
  • Four deviation values will be calculated. These are “a” value, “b” value, “c” value and “d” value.
  • Each value will be calculated as “(a1 + a2) / 2 = averaging”.
  • For all deviation values, 4 formulas will be used as shown in the picture above.


Calculation of Deviation Values “a1 and b1

  • Let’s put into place by reading the values from the table above.
    102=  (730a1) + b1
     –25(232a1– b1
    a1=(77/498) = 0,154
  • Let us find the value of b1 based on the value of a1.
    b1=(2537,728)= -10,728


Calculation of Deviation Values “a2 and b2

  • Let’s put into place by reading the values from the table above.
    25= (237a2)  b2
    102=  (704a2b2
    a2=(77/467) = 0,164
  • Let us find the value of b2 over this value as we find the value of a2.
    b2=(2538,868)= -13,868


Calculation of Deviation Values “c1 and d1

  • Let’s put into place by reading the values from the table above.
    48= (230c1)  d1
    192=  (780c1+ d1
    c1=(144/550) = 0,261
  • Let’s find the value of d1 based on this value as we find the value of c1.
    d1=(4860,03)= -12,03


Calculation of Deviation Values “c2 and d2

  • Let’s put into place by reading the values from the table above.
    48= (228c2)  d2
    192=  (773c2+ d2
    c2=(144/545) = 0,264
  • Since we find the value of c2, let’s find the value of d2 over this value.
    d2=(4860,192)= -12,192


Deviation Values Result Table

1 2 Average
a 0,154 0,164  0,159
b -10,728 -13,868  -12,298
c 0,261 0,264  0,262
d -12,03 -12,192  -12,111
  • The results from the above tablature will be used in the final form.
  • The averaging method is (a1 + a2) / 2.


Calibration by Using Result Formula

  • After all values have been calculated, calibration can now be done.
  • The “Result Formula” above is the last point in the software. With this formula, the software calibrates. See how it works with examples.
  • As an example I will use the values given in the table above.
  • For example, I read 730 on the Y axis. But the point I clicked is actually 102 dir. (see the table at the beginning)
    Let’s place them in the form;
  • I saw that the point I touched when I made transactions based on the deviations I have found should be 103. Actually, the point I actually touched is 102. Such deviations can be caused by touching places and fractions. However, it should not be taken into consideration. Because the software is processed with the value of the float, a large part of the fractions are accounted for, and such mistakes are eliminated.
  • If we had to do an X-axis calculation:
  • For example, when I touch the X axis, I read 230, but the point I clicked is actually 48. (see the table at the beginning)
    Put your place in the form;
  • I have seen that the point to be touched in the calculations made according to the deviation values I have found should be 48. The point I already touched was the 48 axes on the X axis, that is, the calibration was done correctly.


  • Calibration of the touch panels is done by calculations as described above. Random number determination is unscientific and not true.
  • Regardless of the screen size, the above method takes you to the right conclusion because it deals with the percentiles.
  • When calibrating, the raw “X” and “Y” values of each point touch are substituted in the “Conclusion Formula” and the result is taken.

Be sure to watch the video lesson below for action and other details.

Mathematical Solution of Touch Panel Calibration Video Lesson


Çalışmalarım çocukken başladı kolonyalı kağıtları yakmak, ilaçları birbirine katmak gibi değişik deneylerim vardı. Kimya kitabında elektroliz ile suyun hidrojen ve oksijene ayrıldığı ve hidrojenin yandığını yazıyordu, o zamanlarda aklım almıyordu sudan nasıl yanan….Devamını okumak için tıklayınız ;)