From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert byte to x-y coordinate

Solved!
Go to solution

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.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 11 of 22
(855 Views)

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)

0 Kudos
Message 12 of 22
(849 Views)

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.

0 Kudos
Message 13 of 22
(845 Views)

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.

 

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 14 of 22
(844 Views)
Solution
Accepted by topic author ciruap

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?

0 Kudos
Message 15 of 22
(834 Views)

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.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 16 of 22
(830 Views)

Thanks a million.

That was a great help

0 Kudos
Message 17 of 22
(818 Views)

Out of interest, why did you mark your incorrect post as the thread solution!?

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 18 of 22
(810 Views)

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?

0 Kudos
Message 19 of 22
(805 Views)

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 Smiley Wink

 

Glad we could help you anyway Smiley Happy

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 20 of 22
(802 Views)