Touch Screen Not working on 3.2" TFT LCD & Mega 2560-r3

I am attempting to connect a 3.2 TFT LCD to a Mega 2560-r3 through itead ITDB02v1.1 shield.

The LCD and mega are both cheap Chinese models.

Board - http://www.gearbest.com/development-boards/pp_18651.html

Shield - http://imall.iteadstudio.com/prototyping/kits/im120717001.html

LCD - http://www.ebay.com/itm/3-2-inch-TFT-LCD-module-Display-with-touch-panel-SD-card-240x320-than-128x64-lcd-/200908823757?

I have been able to get the screen to display every sketch I try, but the display is not acknowledging any touch input.
I am trying to use the UTFT and UTouch libraries.
I am not able to draw in either the quick draw or quick paint sketches, nor am I able to calibrate or press any buttons in those sketches.

I contacted the seller to see if they had any code I could test, and the only answer I got was to try Googleing the problem...wow why didnt I think of that?!?! ::slight_smile:

I havent been able to find much for others with the similar problem with this setup. That along with >2000 of these screens being sold by the vendor makes me think I may have a non functioning unit.

Any help would be greatly appreciated.
Thanks

Ryan

// UTouch_QuickPaint (C)2013-2014 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program is a quick demo of how to use the library.
//
// This program requires the UTFT library and a display
// module with at least 320x240 pixels resolution.
//
// It is assumed that the display module is connected to an
// appropriate shield or that you know how to change the pin 
// numbers in the setup.
//

#include <UTFT.h>
#include <UTouch.h>

// Initialize display
// ------------------
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino Uno/2009 Shield            : <display model>,19,18,17,16
// Standard Arduino Mega/Due shield            : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Due       : <display model>,25,26,27,28
// Teensy 3.x TFT Test Board                   : <display model>,23,22, 3, 4
// ElecHouse TFT LCD/SD Shield for Arduino Due : <display model>,22,23,31,33
//
// Remember to change the model parameter to suit your display module!
UTFT    myGLCD(ITDB32S,38,39,40,41);

// Initialize touchscreen
// ----------------------
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino Uno/2009 Shield            : 15,10,14, 9, 8
// Standard Arduino Mega/Due shield            :  6, 5, 4, 3, 2
// CTE TFT LCD/SD Shield for Arduino Due       :  6, 5, 4, 3, 2
// Teensy 3.x TFT Test Board                   : 26,31,27,28,29
// ElecHouse TFT LCD/SD Shield for Arduino Due : 25,26,27,29,30
//
UTouch  myTouch( 6, 5, 4, 3, 2);

// Declare which fonts we will be using
extern uint8_t BigFont[];

int color = 0;
word colorlist[] = {VGA_WHITE, VGA_BLACK, VGA_RED, VGA_BLUE, VGA_GREEN, VGA_FUCHSIA, VGA_YELLOW, VGA_AQUA};
int  bsize = 4;

void drawColorMarkerAndBrushSize(int col)
{
  myGLCD.setColor(VGA_BLACK);
  myGLCD.fillRect(25, 0, 31, 239);
  myGLCD.fillRect(myGLCD.getDisplayXSize()-31, 161, myGLCD.getDisplayXSize()-1, 191);
  myGLCD.setColor(VGA_WHITE);
  myGLCD.drawPixel(25, (col*30)+15);
  for (int i=1; i<7; i++)
    myGLCD.drawLine(25+i, ((col*30)+15)-i, 25+i, ((col*30)+15)+i);
  
  if (color==1)
    myGLCD.setColor(VGA_WHITE);
  else
    myGLCD.setColor(colorlist[col]);
  if (bsize==1)
    myGLCD.drawPixel(myGLCD.getDisplayXSize()-15, 177);
  else
    myGLCD.fillCircle(myGLCD.getDisplayXSize()-15, 177, bsize);
    
  myGLCD.setColor(colorlist[col]);
}

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myGLCD.setFont(BigFont);

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_HI);
  
  myGLCD.setColor(VGA_WHITE);
  myGLCD.drawLine(32,0,32,myGLCD.getDisplayYSize()-1);
  myGLCD.drawLine(myGLCD.getDisplayXSize()-32,0,myGLCD.getDisplayXSize()-32,myGLCD.getDisplayYSize()-1);
  myGLCD.print("C", myGLCD.getDisplayXSize()-24, 8);
  myGLCD.print("L", myGLCD.getDisplayXSize()-24, 24);
  myGLCD.print("E", myGLCD.getDisplayXSize()-24, 40);
  myGLCD.print("A", myGLCD.getDisplayXSize()-24, 56);
  myGLCD.print("R", myGLCD.getDisplayXSize()-24, 72);
  myGLCD.print("+", myGLCD.getDisplayXSize()-24, 136);
  myGLCD.print("-", myGLCD.getDisplayXSize()-24, 200);
  myGLCD.fillRect(myGLCD.getDisplayXSize()-32,96,myGLCD.getDisplayXSize()-1,128);
  myGLCD.drawLine(myGLCD.getDisplayXSize()-32,160,myGLCD.getDisplayXSize()-1,160);
  myGLCD.drawLine(myGLCD.getDisplayXSize()-32,192,myGLCD.getDisplayXSize()-1,192);
  myGLCD.drawLine(myGLCD.getDisplayXSize()-32,224,myGLCD.getDisplayXSize()-1,224);
  for (int i=0; i<8; i++)
  {
    myGLCD.setColor(colorlist[i]);
    myGLCD.fillRect(0, (i*30), 24, (((i+1)*30)-1));
  }
  drawColorMarkerAndBrushSize(color);
}

void loop()
{
  long x, y;
  
  while (myTouch.dataAvailable() == true)
  {
    myTouch.read();
    x = myTouch.getX();
    y = myTouch.getY();
    if ((x!=-1) and (y!=-1))
    {
      if (x>(31+bsize) and (x<myGLCD.getDisplayXSize()-(31+bsize)))
      {
        if (bsize==1)
          myGLCD.drawPixel(x, y);
        else
          myGLCD.fillCircle(x, y, bsize);
      }
      else
      {
        if (x<(30+bsize))
        {
          if (y<240)
          {
            color = y / 30;
            drawColorMarkerAndBrushSize(color);
            while (myTouch.dataAvailable()) {};
            delay(50);
         }
        }
        else
        {
          if (y<96)
          {
            myGLCD.setColor(VGA_BLACK);
            myGLCD.fillRect(33, 0, myGLCD.getDisplayXSize()-33, myGLCD.getDisplayYSize()-1);
            myGLCD.setColor(colorlist[color]);
          }
          if ((y>128) and (y<160))
          {
            if (bsize<7)
            {
              bsize++;
              drawColorMarkerAndBrushSize(color);
              while (myTouch.dataAvailable()) {};
              delay(50);
            }
          }
          if ((y>160) and (y<192))
          {
              bsize=4;
              drawColorMarkerAndBrushSize(color);
              while (myTouch.dataAvailable()) {};
              delay(50);
          }
          if ((y>192) and (y<224))
          {
            if (bsize>1)
            {
              bsize--;
              drawColorMarkerAndBrushSize(color);
              while (myTouch.dataAvailable()) {};
              delay(50);
            }
          }
        }
      }
    }
  }
}

It would appear the shield you are using is a general purpose prototyping shield, as such did you configure it to follow the commercial TFT shield scheme? As the Mega is a 5V device and most of the TFT displays operate at 3.3V, you have built in some sort of level translation ( resistors or IC )? A schematic of how you configured your shield would be helpful to at least determine if you stand any chance of getting this to work before you condemn the display.

Funnily enough, the touch functions do not need any form of level translation, so unless you can provide more information about how it is all connected, I wouldn't know where to begin to start to try to help you, there are just too many variables.

Regards,

Graham

My understanding of that shield was that it was designed to be the interface between the LCD and the arduino. There was no option for configuration when assembling the board. It is (in theory) plug and play.
Schematic - ftp://imall.iteadstudio.com/Kit/IM120717001_ITEADB02_Arduino_MEGA_Shield_v1.1/SCH_IM120717001_ITEADB02_Arduino_MEGA_Shield_v1.1.pdf

I did check the pinout on the LCD vs the shield and follow around through to the arduino. As far as I can tell everything is connected as it should be.
TouchP_CLK 6
TouchP _CS 5
TouchP _DIN 4
TouchP _BUSY NC
TouchP _OUT 3
TouchP _Penirq 2

Thanks

The tft lcd module uses SSD1289 touch panel controller. You may need to read the datasheet of SS1289.

Reading the SSD1289 data sheet, it seems like that is just the controller for the display and not for the touch functions.
I see on the descriptions for some other similar displays like this one a separate touch panel controller listed, though the vendor I purchased from does not list one.
Display-wise everything seems to be functioning well, only the touch is not working.

Looking through some other similar threads I found this one...3.2 Sainsmart TFT touch issues - Displays - Arduino Forum that seemed to have some similar issues
Trying this code

#include <UTFT.h>
#include <ITDB02_Touch.h>

//Declare font types
extern uint8_t BigFont[];

//Gets the screen and touch sensor ready
UTFT myGLCD(ITDB32S,38,39,40,41);
ITDB02_Touch  myTouch(6,5,4,3,2);

//Declare functions
void read_ts();

//Define my variables
float x = 0, y = 0;
int run = 0;

int temp;
bool error = true;
bool changed = true;

void setup()
{
  //Setup the Screen
  myGLCD.InitLCD();
  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM);
  myGLCD.clrScr();
}

void loop()
{
  //reads x and y values of touch sensor
  read_ts();
  //prints these values to the screen
  myGLCD.printNumF(x,3,50,150);
  myGLCD.printNumF(y,3,50,175);
  myGLCD.setFont(BigFont);
  myGLCD.setColor(255, 0, 255);
  myGLCD.print("It got this far.", CENTER, 200);
  myGLCD.printNumF(run,2,50,75);
  //prints how many times it has run onto the screen
  run++;
}

void read_ts()
{
  x = myTouch.getX();
  y = myTouch.getY();
}

I get the attached touch location picture...where the top number increments up, but the other numbers stay the same no matter where I touch.

When I run this code

#include <UTFT.h>
#include <ITDB02_Touch.h>

UTFT myGLCD(ITDB32S,38,39,40,41);
ITDB02_Touch  myTouch(6,5,4,3,2);

void setup()
{
  myGLCD.InitLCD(PORTRAIT);
  myGLCD.clrScr();

  myTouch.InitTouch(PORTRAIT);
  myTouch.setPrecision(PREC_MEDIUM);
}

void loop()
{
    while (myTouch.dataAvailable() == true)
    {
      myTouch.read();
      myGLCD.drawPixel (myTouch.getX(), myTouch.getY());
    }
}

All I get is a lot of rapidly moving vertical white lines, seen in the other picture.

Sorry.I saw the LCD advertisement link ,and made the mistake.
The touch panel controller most likely should be XPT2046.

Correct...at least that is the model of the IC on the back of the display. Also the model number on the back of the screen is TFT_320QVT.

Would that controller be incompatible with the UTFT libraries?

I see other units that use the ADS7843 controller, which I think is supposed to be the same.

Also using this code, all it returns is x=-1 y=-1

#include <UTFT.h>
#include <UTouch.h>

//  ILI9325D_16 , TFT 2.8" 320x240 px
UTFT          myGLCD(ITDB32S,38,39,40,41);
UTouch        myTouch(6,5,4,3,2);

extern uint8_t BigFont[];

int x, y;

void setup() 
{
  Serial.begin(9600);
  
  myGLCD.InitLCD(LANDSCAPE);                   
  myGLCD.clrScr();                             
  myGLCD.fillScr(0,0,0);
  myGLCD.setFont(BigFont);  
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.setColor(0, 255, 0);

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_HI);  
}

void loop()
{
  while (true)
  {
    if (myTouch.dataAvailable())
    {
      myTouch.read();
      x=myTouch.getX();
      y=myTouch.getY();

// TFT-output
      myGLCD.print("x=       ", 50, 100);
      myGLCD.printNumI(x, 85, 100);
      myGLCD.print("y=       ", 185, 100);  
      myGLCD.printNumI(y, 220, 100);
            
// Serial-output            
      Serial.print("x= ");
      Serial.print(x);    
      Serial.print("   y= ");            
      Serial.print(y);  
      Serial.println("   ");    

    }
  }
}

I too have a Sainsmart TFT_320QVT display with XPT2046 touch controller. It works FINE with Henning's libraries. There are issues with IDE 1.5x. Try IDE 1.0.6.

By the way, reference my previous post, apologies regarding my comments about your ITEAD shield, I didn't bother downloading the PDF or going into it too much, but I do have one comment. Your ITEAD shield appears to have resistors for level translation of the touch signals...... My shield does not.... try shorting out those 4 resistors if IDE 1.0.6 doesn't fix your problems.

Regards,

Graham

Incidentally, I just ran your sketch from your last post. Result from IDE 1.0.6 is :-

x= 350   y= 219   
x= -1   y= -1   
x= 318   y= 268   
x= 219   y= 194   
x= 238   y= 162   
x= 408   y= 222   
x= 484   y= 307   
x= 535   y= 359   
x= 637   y= 370   
x= 616   y= 297   
x= 478   y= 198   
x= 289   y= 142   
x= 200   y= 200   
x= 234   y= 294   
x= 185   y= 326   
x= 175   y= 240   
x= 227   y= 141   
x= 337   y= 137   
x= 402   y= 195   
x= 363   y= 268   
x= 404   y= 350   
x= 559   y= 387   
x= 637   y= 303   
x= 511   y= 180   
x= 345   y= 149   
x= 388   y= 262   
x= 353   y= 331   
x= 259   y= 268   
x= 185   y= 109   
x= 301   y= 99   
x= 449   y= 176   
x= 421   y= 262   
x= 343   y= 326   
x= 478   y= 397   
x= 647   y= 345   
x= 587   y= 223   
x= 374   y= 141   
x= 392   y= 105   
x= 434   y= 125   
x= 594   y= 236   
x= 521   y= 307   
x= 336   y= 332   
x= 248   y= 376   
x= 222   y= 408   
x= 335   y= 429   
x= 530   y= 430   
x= 635   y= 384   
x= 634   y= 283   
x= 621   y= 165   
x= 607   y= 80   
x= 449   y= 31   
x= 202   y= 51   
x= 108   y= 137   
x= 173   y= 253   
x= 236   y= 355   
x= 208   y= 398   
x= 104   y= 287   
x= 129   y= 123   
x= 330   y= 49   
x= 580   y= 95   
x= 651   y= 164   
x= 642   y= 240   
x= 450   y= 252   
x= 119   y= 219   
x= 119   y= 271   
x= 362   y= 329   
x= 595   y= 343   
x= 694   y= 382   
x= 669   y= 457   
x= 400   y= 454   
x= 185   y= 420   
x= 177   y= 377   
x= 350   y= 314   
x= 544   y= 283   
x= 593   y= 182   
x= 527   y= 78   
x= 310   y= 65   
x= 56   y= 112   
x= 214   y= 190   
x= 463   y= 207   
x= 610   y= 278   
x= 580   y= 364   
x= 367   y= 403   
x= 203   y= 409   
x= 191   y= 434   
x= -1   y= -1   
x= 487   y= 449   
x= 499   y= 456   
x= -1   y= -1   
x= -1   y= -1   
x= 426   y= 469   
x= 421   y= 461   
x= 404   y= 456   
x= 388   y= 456   
x= 380   y= 461   
x= 377   y= 463   
x= 376   y= 464   
x= 377   y= 469   
x= -1   y= -1   
x= 375   y= 477   
x= 376   y= 479   
x= -1   y= -1   
x= 376   y= 479   
x= -1   y= -1   
x= 376   y= 479   
x= 376   y= 479   
x= 376   y= 479   
x= -1   y= -1   
x= -1   y= -1   
x= 376   y= 479   
x= 376   y= 473   
x= 358   y= 428   
x= 346   y= 387   
x= 346   y= 343

Same result from IDE 1.5.7 is :-

x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= 25   y= 436   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= 166   y= 467   
x= 19   y= 479   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= 64   y= 479   
x= -1   y= -1   
x= 4   y= 380   
x= -1   y= -1   
x= -1   y= -1   
x= 0   y= 454   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= 167   y= 395   
x= -1   y= -1   
x= 96   y= 479   
x= -1   y= -1   
x= 4   y= 436   
x= 143   y= 470   
x= 89   y= 437   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= 91   y= 437   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= -1   y= -1   
x= 176   y= 479

Hope it helps.

Regards,

Graham

Attached is the pertinent parts of your documentation, and the complete CTE documentation for the MEGA TFT shield, as you see, NO level shifting on the touch signals on the CTE shield (widely considered the best :stuck_out_tongue: ... ). In fairness I can see the attraction of the shield you have, the fun of building it yourself, and the built in RTC, ( and the stress of figuring out why TOUCH is not working).

Best wishes,

Graham

Itead.jpg

MEGA_Shield_schematic.pdf (18.6 KB)

ghlawrence2000:
By the way, reference my previous post, apologies regarding my comments about your ITEAD shield, I didn't bother downloading the PDF or going into it too much, but I do have one comment. Your ITEAD shield appears to have resistors for level translation of the touch signals...... My shield does not.... try shorting out those 4 resistors if IDE 1.0.6 doesn't fix your problems.

Regards,

Graham

Thanks for helping me out with this. I am fairly new to arduino, and this is my first display project. I wanted to be sure that shorting out those resistors will in no way have a possibility of damaging either component (since the screen will output 3.3 ,correct?, and the mega is good up to 5v?
And am I correct that since the display is putting out 3.3 then going through a 10K resistor, than the signal is likely not reading high?

Also, I am using 1.0.6 for this project.

I dont have a good way to short those out at home, so I will have to wait until tomorrow to use my good soldering iron at work, and just remove the resistors and solder in some wire to test with.

Thanks...I just saw your last post.
I did like the integrated RTC, but the main reason I got it was that I am following the Jarduino aquarium controller build.
https://code.google.com/p/jarduino-aquarium-controller/

:stuck_out_tongue: I am HEAVILY involved in a vivarium project at the moment, and the guy I am helping had more than his fair share of TOUCH related problems, ultimately resulting in taking my advice to get a CTE shield. I hope you can figure this out, but him and me spent HOURS with no successful outcome. :sob:

Good luck!

Graham

To reiterate, I just want to be sure that shorting out the 4 touch resistors will not harm the display.
I get that the data out of the display wont matter, but what about the Touch Input (arduino pin4) will that put 5v into the display?
Again, thanks.

Hold off on that for now, I will DOUBLE check.......

Will be tomorrow now before I get back to you.

Regards,

Graham

Looking at the updated version's spec sheet from IteadStudio

ftp://imall.iteadstudio.com/IM120417024_ITDB02_Arduino_MEGA_Shield/SCH_IM120417024_ITDB02ArduinoMEGAShield.pdf

I think the Touch CLK, CS and DIN are run into a 3.3V IC and the DOUT and IRQ are run to a 5V. Am I reading that right, and if so, then I should be ok removing the resistors from the DOUT and IRQ?

Problem: When trying the calibration test in the URTouch Calibration program I cannot get the touch screen to respond at the welcome screen (first screen). I can run other not touch programs without any issues.

My drivers and module selections are all okay. The (ILI6431_16, 38,39,40,41) and (6,5,4,3,2)

"I just cannot get the screen to input the stylus".

The TFT_LCD SCREEN: http://www.elecfreaks.com/estore/3-2-tft-lcd-screen-module-tft01-3-2.html

The Shield: http://www.elecfreaks.com/estore/lcd-tft01-arduino-mega-shield-v2-0-shd10.html

Using the Arduino Mega.

I have worked on this problem for about 72 hours, if not more. I have tried everything. Almost.

Has anybody experienced the same issue? IF so, was there a solution.