04-16-2012 06:09 AM
Hi,
I am taken reading from a touchscreen and want Labveiw to convert this data to an xy coordinate.
The touch screen controller is connected through USB
An example of the output data in the array I am getting is;
1156 7 120 5
from the data sheet it states that (in the example data above) that the values 156 and 7 would represent the x coordinates and 120 and 5 would represent the y-coordinate. It states the the first value is always either 1 or 0 to state if pen is up or down.
my question is how do convert these values to coordinates?.
Solved! Go to Solution.
04-16-2012 07:42 AM
This seems to be a follow-up to your original post about a month back. Why are there 2 values for each coordinate? How are you getting these values? As a string? As an array of integers? As an array of bytes? Morse code?
04-16-2012 09:12 AM
No this is not a follow up as that was a different topic entirely that i was enquiring about.
My appologies i thought it was clear from the opening post that the data was an array of bytes.
This data sheet from the touchscreen controller might help explain why there is 2 values
see page 10
http://docs-europe.electrocomponents.com/webdocs/0e31/0900766b80e31067.pdf
That is my reason for the post, i want to know how do i combine the two bytes to get an x or y coordinate.
Morse code??really??I am only learning here so no need for the sarcasm. Thanks
04-16-2012 09:24 AM
@ciruap wrote:
...
Morse code??really??I am only learning here so no need for the sarcasm. Thanks
dot dot dot .... dash dash dash .... dot dot dot
That is one of the strangest data formats I have seen. THe X and Y values are mixed within the varous bytes.
The simplest solution would use "Number to Boolean array" and then used array indexing and build array to group all of the bits for X and Y seperately and then convert the boolean array back to numbers.
THere are other methods availabel but I'm just mentioning the easy approach.
Ben
04-16-2012 09:36 AM
ciruap wrote:
My appologies i thought it was clear from the opening post that the data was an array of bytes.
1156 is not a byte.
Based on the spec you need to comine bytes 2 and 3 to get a 12-bit value for the X coordinate. You can do this using the Join Numbers function.
I don't have Code Capture Tool operation right now, so all that I can upload right now is a picture.
04-16-2012 11:52 AM
yes i see what you done there!!
thanks for the help
il give it a try and see how i get on
04-19-2012 03:57 AM
ok i have give this solution a few attempts and i dont think it is the correct solution to the problem.
basically all this solution does is as follows.
Array of byte data i get is;
1 133 4 214 10 (obviously this data changes as the position of the ball on the screen moves!)
however the solution given only selects the number 4 and 10 from the array above and classes them as the x-y coordinates.
THIS IS NOT CORRECT as the link to the data sheet shows that;
the bytes (133 and 4) represent the x-coordinate
the bytes (214 and 10) represent the y-coordinate
so therefore you cant disregard the first byte and just class the second byte as the coordinate.
My question is how do i convert the example data above to an x-y coordinate?
04-19-2012 06:24 AM
ciruap wrote: therefore you cant disregard the first byte and just class the second byte as the coordinate.
Your implementation must be wrong, smercurio_fc's code sample doesn't use just one byte for each coordinate, it joins pairs of bytes. The index array function takes the second and third bytes (indices 1 and 2) and joins them to create the X coordinate, and it takes the fourth and fifth bytes (indices 3 and 4) and joins those to create the Y coordinate. Post your code and we can check where you went wrong.
04-19-2012 06:54 AM
ok thanks its working ok now..
do you know if it is possible to scale the output somewhat because the top right coordinate of the screen is now reading (3725, 3725)
would it be possible to scale it to a more user friendly coordinate.
the reason for this is i want the user to be able to select a position on the screen and two motors will control the axis of the chassis that the screen is mounted on to bring the ball to the desired position.
Thanks for your help.
04-19-2012 07:25 AM
Have you considered simply multiplying the values you get?