Pages: [1]   Go Down
Author Topic: Touch screen - inconsistent output  (Read 1687 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 smiley-sad,

Was hoping to get some help regarding a strange issue I'm having with two touch screens I ordered. These are the screens, http://www.dealextreme.com/p/sony-ericsson-x1-replacement-touch-screen-digitizer-module-32335

I ordered a DS connector from sparkfun, created my own breakout board. I've been utilizing this tutorial http://kalshagar.wikispaces.com/Arduino+and+a+Nintendo+DS+touch+screen and the full explanation from the book Practical Arduino: Cool Projects for Open Source Hardware Chapter 8: touch control panel (safari ftw). I've tried the code in the book, the code from kalshagar's site, and ladys touchscreen.h library.

This was originally wired up to a project I am working on that is currently a boarduino. I've tested the code from each of the above references on my original arduino atmega328 and the megas I ordered and burned thinking maybe I did something wrong fuse wise etc...

What is happening is the output readings from both touchscreens on either my boarduino setup or the original arduino aren't true cartesian coordinates. This is sitting on top of a KS0108 GLCD with 8 buttons on it. If I use my stylus and draw horizontally across the screen both x,y change as I move!  smiley-eek-blue smiley-cry  and not like... a little just from natural hand movement. Would post exact output but currently at work. I know for a fact moving horizontally a little over and inch resulted in about a 20-25 in deviation on x and y, almost as though I was actually drawing diagonally. It changes drastically under a full sweep of x or y.

I've adjusted the code from each example thinking it was possibly the touch screens them selves. I've followed this documentation as well for a better understanding http://www.sparkfun.com/datasheets/LCD/HOW%20DOES%20IT%20WORK.pdf and thought maybe the screen needed to read from a specific bar so I tried reading from 1 instead of 3 and 0 instead of 2 (zero indexing the pins to match them on the mega) both end in the same result.

I'm using analog inputs 0-4, I've made sure I reference them as A0-A4 in the code, I'm making sure my digitalWrites correspond to the pin numbers as well since they are different (I ref the pin number directly, e.g. 14 for A0)

Any help would be greatly appreciated, oh I also tried it with and without the pulldowns, same result. I can post all code examples etc when I get home unless someone has seen this strange output before.. or maybe its just me :-)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset





No Touch
Code:
X = 984 Y = 78
X = 984 Y = 79
X = 985 Y = 80
X = 982 Y = 80
X = 982 Y = 80

Output when I make a horizontal line on the top edge of button 1
Code:
X = 981 Y = 79
X = 980 Y = 130
X = 984 Y = 80
X = 981 Y = 146
X = 980 Y = 150
X = 980 Y = 150
X = 980 Y = 147
X = 979 Y = 147
X = 976 Y = 144
X = 976 Y = 142
X = 974 Y = 139
X = 969 Y = 135
X = 966 Y = 133
X = 967 Y = 132
X = 965 Y = 130
X = 963 Y = 130
X = 982 Y = 80
X = 983 Y = 80

Horizontal line across top edge of button8
Code:
X = 985 Y = 80
X = 982 Y = 80
X = 985 Y = 80
X = 956 Y = 89
X = 951 Y = 92
X = 952 Y = 92
X = 949 Y = 90
X = 948 Y = 91
X = 945 Y = 91
X = 943 Y = 91
X = 940 Y = 91
X = 935 Y = 91
X = 929 Y = 90
X = 925 Y = 91
X = 919 Y = 89
X = 914 Y = 90
X = 911 Y = 89
X = 910 Y = 90
X = 910 Y = 90

Code I used for this test... straight up from the touchscreen.h example. This was done using the arduino board and original 328
Code:
// Touch screen library with X Y and Z (pressure) readings as well
// as oversampling to avoid 'bouncing'
// This demo code returns raw readings, public domain

#include <stdint.h>
#include "TouchScreen.h"

#define YP A0  // must be an analog pin, use "An" notation!
#define XM A1  // must be an analog pin, use "An" notation!
#define YM A2   // can be a digital pin
#define XP A3   // can be a digital pin

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

void setup(void) {
  Serial.begin(9600);
}

void loop(void) {
  // a point object holds x y and z coordinates
  Point p = ts.getPoint();
  
  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!
  //if (p.z > ts.pressureThreshhold) {
     Serial.print("X = "); Serial.print(p.x);
     Serial.print("\tY = "); Serial.print(p.y); Serial.print("\n");
     delay(300);
}
smiley-confuse
« Last Edit: August 24, 2011, 07:32:03 am by BMac » Logged

Dubuque, Iowa, USA
Offline Offline
Edison Member
*
Karma: 29
Posts: 2243
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That output looks consistent to me -- although not a whole lot of bits of precision.

You should start out by getting X Y readings for each of the four corners. Well, you only need two corners, really, but it'd be good to make sure that the X values are consistent from top to bottom and that the Y values are consistent from side to side. From there you're going to want to feed it into the map() function so you can translate it into pixel coordinates.

If you can provide those corner coordinate values and the pixel dimensions of your screen I could help out with using map().
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The coords are so off when I do that that they actually overlap. It's what originally stumped me. I'll run through them again and post them when i get home. I'll also post the original mappings that I had penciled out on paper too. I remember button2's bottom right y coord being higher than button1s... but not the upper left coords. The result was my extra debug code resulting in the same coords being output but it was seeing buttons 1 and 2 pressed at the same time if you touched either on their far right side.
Logged

0
Offline Offline
Shannon Member
****
Karma: 160
Posts: 10416
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What's the resistance across one of the resistance layers and what value pull-up/down resistors are you using?
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

490 ohms across one, 260 across the other  smiley-cry on both screens...

I've tried with and without 10k pulldowns... didn't read anywhere about using pullups with a touchscreen... any thoughts?
Logged

0
Offline Offline
Shannon Member
****
Karma: 160
Posts: 10416
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The pull ups are so the input isn't floating when the screen is idle - they need to be much higher in value than the screen resistances, which they are.

Without them there's no way to know if the screen's being pressed or not.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Update on this. I haven't had time to play with this in a while. I decided to order two DS touchscreens from sparkfun.  XY coords are consistent across the board. The touchscreens I ordered from dealextreme were junk, both of them.
Logged

Pages: [1]   Go Up
Jump to: