Arduino with 3M Capacitive Touchscreen EXII 7720SC

Trying to get this touchscreen working with my Arduino i come across with this http://hades.mech.northwestern.edu/wiki/index.php/Interfacing_with_a_touchscreen, yah i know is for a PIC, but i tried to get this working in the Arduino, here’s the code:

#include <LiquidCrystal.h>

unsigned int xPos;
unsigned int yPos;
void get_xPos_yPos(unsigned int& xPos, unsigned int& yPos);
LiquidCrystal lcd(2, 3, 4, 5, 6, 7, 8);

void setup()
{
lcd.clear();
Serial.begin(9600);
//sends the string FT to the EXII 7720SC
Serial.print(0x01,BYTE);
Serial.print(0x46,BYTE);
Serial.print(0x54,BYTE);
Serial.print(0x0D,BYTE);
}

void loop()
{
//get the position of the touch and display it on the lcd.
get_xPos_yPos(xPos, yPos);
lcd.clear();
lcd.print("X: " + xPos);
lcd.setCursor(0,1);
lcd.print("Y: " + yPos);
}

//this is how you get the x and y coords
void get_xPos_yPos(unsigned int& xPos, unsigned int& yPos)
{
int j;
int i;
int gotD8;
byte touchRX[20];
byte pos[5];
byte high;
byte low;
unsigned int xtot;
unsigned int ytot;
unsigned int temp4;
unsigned int tot8;
high = 0;
low = 0;
xtot = 0;
ytot = 0;
temp4 = 0;
tot8 = 0;
//get 10 bytes from the EXII 7720SC
for (i=1;i<=10;++i)
{
if(Serial.available())
{
touchRX = Serial.read();

  • }*
  • }*
  • //find the 0xD8 byte*
  • gotD8 = 0;*
  • j = 1;*
  • while(gotD8 == 0)*
  • {*
  • if((touchRX[j] == 0xD8))*
  • {*
  • gotD8 = 1;*
  • }*
  • else*
  • {*
  • j = j+1;*
  • }*
  • if(j == 9)*
  • {*
  • gotD8 = 1;*
  • }*
  • }*
    *//once you have the position of the 0xD8 save the rest of the stream in the array of position *
  • pos[1]=touchRX[j+1];*
  • pos[2]=touchRX[j+2];*
  • pos[3]=touchRX[j+3];*
  • pos[4]=touchRX[j+4];*

//get each of the coords in a 16-bit format

I’ve been working with this, it seems it doesn’t work at all, any idea why? I’ve been reading the controller’s output with a the hyperterminal and i never get the 3FFF that it’s supposed to receive when you touch the farest corner, instead i have a 7F7F.

I would guess the screen needs to be calibrated. Check out page 21-23 of the doc you linked too. Seems to cover exactly that. If that’s not the trick, check and see if you’re getting negative values at 0000 and offset accordingly (that might be hard to do on an arduino… but if you suspect that’s what’s happening I believe you can ground the data pin and read the ground pin which will result in negative values becoming positive, I’ve done that before to read true RS-232 logic which is negative logic, I’m unsure of the other possible side effects at the moment). I believe proper calibration will have you up and running in no time though, so good luck!