04-19-2012 07:28 AM
The 12-bit converter in the touch-screen will most likely convert the analogue detected position to a digital value, and hence the farthest value will be 4096. To be getting 3725 sounds reasonable for the top right corner. You will need to calibrate the values you read to the screen coordinates to get true position, and you can do this however you please. Take the readings for the four corners and perform simple c=mr+a on both x and y to linearly calibrate to your screen coordinates.
04-19-2012 08:19 AM
Ok.
i have never used C=MR+A formula before.
would it be possible for you to explain what c,m,r and a are equivalant to?
the coordinates i read from the screen are as follows;
position (x,y)
top left (393, 502)
top right (3698, 509)
bottom left (400, 3596)
bottom right (3660, 3581)
centre screen (1999, 2045)
04-19-2012 08:24 AM
He's simply referring to a linear translation formula. y=mx+b, if you're more familiar with that. In other words, remap the values you get to the screen coordinates you want. It's simple math.
04-19-2012 08:24 AM
c=calibrated position
m= multiplier
r = raw reading (your 12-bit value)
a = offset
The equation is a simple linear equation that directly translates from one 1D space to another, see the wikipedia article.
You will need two equations, one for the x coordinate and one for the y coordinate. You will need to determine the constants m and a for correctly calibrating your raw readings into calibrated values.
ie. "calibrated x position" = m1 mulitplied by "raw x coord" + a1
"calibrated y position" = m2 mulitplied by "raw y coord" + a2
The constants m and a can be determined by solving the equations using your known coordinate values for the bottom left and top right.
04-19-2012 09:31 AM
Ok
Can you confirm if i am on the right track here.
BL (400,3596)
TR (3689, 509)
Find m by (y2-y1) / (x2 - x1)
ANS: -0.94
Sub known values into C=MR+A
C = 1 (The value i want the bottom left x-coord to equal??is this correct??)
M = -0.94
R = 400
A = ?
so C=MR+A
1 = (-0.94)(400) + A
1 = -376 + A
377 = A
So M = -.94 and A = 377
Can you correct me if im wrong?
04-19-2012 09:42 AM - edited 04-19-2012 09:43 AM
Not quite. You need to calculate TWO m and TWO a values, one pair for the x calibration, another for the y calibration. Lets call them mx, ax and my, ay
Using (x1,y1) = (400,3596), (x2,y2) = (3689, 509), and (cx1,cy1) = (0,0), (cx2, cy2) = (1,1) - this means the bottom left corner of your screen is (0,0) and the top right is (1,1)
substituting into c=(m times r) +a for:
X coordinate:
0 = mx times 400 + ax
and
1 = mx times 3689 + ax
solves to:
mx = 3.0404e-4
ax = -0.1216
Y coordinate:
0 = my times 3596 + ay
and
1 = my times 509 + ay
solves to:
my = -3.2394e-4
ay = 1.1649
Therefore, to get a calibrated screen position (in the ratio 0 to 1), use
(cx,cy) = (mx times rx + ax, my times ry + ay)
which is now:
(cx,cy) = (3.0404e-4 times rx + -0.1216, -3.2394e-4 times ry + 1.1649)
You can change the (cx2, cy2) = (1,1) to whatever you need the top right calibrated readings to be, such as your screen resolution, for example (cx2, cy2) = (1280,1024), and recalculate the new linear equations.
04-20-2012 07:22 AM
Thanks a million.
That was a great help
04-20-2012 09:05 AM
04-20-2012 09:36 AM
I didnt realise the "accept as solution" button was at the bottom of my post and I thought it was positioned at the top of your post and i clicked it and noticed that it was my post that was highlighted green, it wasnt until then i realised i clicked the wrong one.
I looked for a way to change it but i have no options to change it,
Is there anyway i can change it?
04-20-2012 09:57 AM
I honestly don't know if there's a way to change it. If there is, I expect there would be a new button somewhere near your post that says "Unaccept Solution" perhaps. If it's not obvious then it maybe can't be done.
Don't worry about it. Perhaps if you Kudo our replies instead, and we'll call it even
Glad we could help you anyway