3.2" TFT Resistive Touch Phantom touches

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
grue42
 
Posts: 8
Joined: Thu Jan 27, 2022 3:58 pm

3.2" TFT Resistive Touch Phantom touches

Post by grue42 »

Hello,

I have an ItsyBitsy M0 Express (3727) and a 3.2" TFT LCD with Touchscreen Breakout (1743).
I'm using the breakouttouchpaint example from the Adafruit ILI9341 library and it's working great but

I'm getting a lot of phantom touches on my 3.2" TFT Resistive Touch display.

The time between them varies, but the positions and pressures are pretty consistent:
Timestamp: 13869
(-46, 352) Pressure: 598

Timestamp: 18129
(-46, 352) Pressure: 598

Timestamp: 27168
(-46, 352) Pressure: 299

Timestamp: 29576
(-46, 352) Pressure: 299

Timestamp: 30895
(-46, 302) Pressure: 299
... etc
My hardware is wired like this on a breadboard (I didn't make any other changes to the example):
(CLK, MOSI to SCK, MOSI)

Code: Select all

// These are the four touchscreen analog pins
#define YP A2  // must be an analog pin, use "An" notation!
#define XM A3  // must be an analog pin, use "An" notation!
#define YM 2   // can be a digital pin
#define XP 1   // can be a digital pin

// The display uses hardware SPI, plus #9 & #10
#define TFT_DC 13
#define TFT_CS 12
The display is currently powered from the 3.3V output from the ItsyBitsy, which is powered by USB to the computer. I'm using a lot of jumper wires, but when I mess with them I don't see any difference in the phantom touches.

Any suggestions on how to debug my phantom touch problems? Thanks so much!

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: 3.2" TFT Resistive Touch Phantom touches

Post by adafruit_support_carter »

Did you alter the sketch? Not seeing that output in the sketch code:
https://github.com/adafruit/Adafruit_IL ... hpaint.ino

Please post a photo of your setup showing how everything is connected.

User avatar
grue42
 
Posts: 8
Joined: Thu Jan 27, 2022 3:58 pm

Re: 3.2" TFT Resistive Touch Phantom touches

Post by grue42 »

Hello,

I did uncomment the print statements at line 98 and added a timestamp (millis()) print statement to see if there was a periodicity to the problem.

I've tried 2 itsy bitsys and 2 displays now, interestingly, one display reports phantom touches with much more frequency than the other. The mcu doesn't seem to affect it.
I've also tried changing/reassigning pins one at a time. Also seems to have no effect.

Please find attached a picture of the setup.
Thanks!
Tft and itsy bitsy connection
Tft and itsy bitsy connection
1668542789747431136409654344545.jpg (939.58 KiB) Viewed 600 times
Edit:
Back of TFT breakout
Back of TFT breakout
16685429897223662131966981046784.jpg (1001.06 KiB) Viewed 600 times

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: 3.2" TFT Resistive Touch Phantom touches

Post by adafruit_support_carter »

Thanks for the photos. That all looks perfectly fine.

There is an adjustment that can be made in the sketch here:

Code: Select all

#define MINPRESSURE 10
#define MAXPRESSURE 1000
to change the touch sensitivity.

But your phantom touches are reporting pressure values of several 100's, which seem pretty high.

Did you ever see a change in that pressure value with any of your testing? Like when you tried different pins?

User avatar
grue42
 
Posts: 8
Joined: Thu Jan 27, 2022 3:58 pm

Re: 3.2" TFT Resistive Touch Phantom touches

Post by grue42 »

Hello,
Thanks for the reply.
These are my findings with these pin assignments:

Code: Select all

#define YP A2
#define XM A3
#define YM 10
#define XP 11 

// also MISO/MOSI/SCK
#define TFT_CS 13
#define TFT_DC 12
I tracked the output of phantom touches by timestamp, coordinates and pressure across two IstyBitsys and two TFTs. It seems suspiciously consistent.
Reassigning pins did not have an effect on the pressure.

Image

I can change the touch sensitivity - but as you say it is pretty high and average touches are around 600-800.

Thanks so much for the help and for any guidance.
Attachments
TFT_Phantom_touch_Tracking.png
TFT_Phantom_touch_Tracking.png (37.07 KiB) Viewed 580 times

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: 3.2" TFT Resistive Touch Phantom touches

Post by adafruit_support_carter »

two IstyBitsys and two TFTs
You are seeing the phantom touch behavior on two separate TFTs?

User avatar
grue42
 
Posts: 8
Joined: Thu Jan 27, 2022 3:58 pm

Re: 3.2" TFT Resistive Touch Phantom touches

Post by grue42 »

Hello,

Yes - two different TFTs are demonstrating phantom touch. Those tables I added are showing the phantom touch occurrences for each combination of the two ItsyBitsys (MCU 1 and MCU 2) and two TFTs (TFT 1 and TFT 2).

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: 3.2" TFT Resistive Touch Phantom touches

Post by adafruit_support_carter »

OK, let's make double sure it's not some software thing. Can you post the complete code for the sketch used to generate those numbers.

User avatar
grue42
 
Posts: 8
Joined: Thu Jan 27, 2022 3:58 pm

Re: 3.2" TFT Resistive Touch Phantom touches

Post by grue42 »

Sure, I used the example and the changes were setting the pins for my wiring and added some print statements.
In the serial monitor, I turned on the timestamps - just in case you weren't sure where that came from. It's not in the code.
This happens in the project I'm working on as well.
Thanks

Code: Select all

/***************************************************
  This is our touchscreen painting example for the Adafruit ILI9341 Breakout
  ----> http://www.adafruit.com/products/1770

  Check out the links above for our tutorials and wiring diagrams
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional)
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/

/** NOT FOR USE WITH THE TOUCH SHIELD, ONLY FOR THE BREAKOUT! **/

#include <Adafruit_GFX.h>    // Core graphics library
#include <SPI.h>
#include <Adafruit_ILI9341.h>
#include "TouchScreen.h"

// These are the four touchscreen analog pins
#define YP A2
#define XM A3
#define YM 10
#define XP 11 

// also MISO/MOSI/SCK
#define TFT_CS 13
#define TFT_DC 12

// This is calibration data for the raw touch data to the screen coordinates
#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940

#define MINPRESSURE 10
#define MAXPRESSURE 1000

// The display uses hardware SPI, plus #9 & #10
// #define TFT_CS 10
// #define TFT_DC 9
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

// 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);

// Size of the color selection boxes and the paintbrush size
#define BOXSIZE 40
#define BANNED 3
int oldcolor, currentcolor;

void setup(void) {
 // while (!Serial);     // used for leonardo debugging
 
  Serial.begin(9600);
  Serial.println(F("Touch Paint!"));
  
  tft.begin();
  tft.fillScreen(ILI9341_BLACK);
  
  // make the color selection boxes
  tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
  tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
  tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
  tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN);
  tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
  tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);
 
  // select the current color 'red'
  tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
  currentcolor = ILI9341_RED;
}


void loop()
{
  // Retrieve a point  
  TSPoint p = ts.getPoint();
  
 /*
  Serial.print("X = "); Serial.print(p.x);
  Serial.print("\tY = "); Serial.print(p.y);
  Serial.print("\tPressure = "); Serial.println(p.z);  
 */
  
  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!
  if (p.z < MINPRESSURE || p.z > MAXPRESSURE) {
     return;
  }
  
  // Scale from ~0->1000 to tft.width using the calibration #'s
  p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
  p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());

  Serial.print(millis());
  Serial.print(", "); Serial.print(p.x);
  Serial.print(", "); Serial.print(p.y);
  Serial.print(", "); Serial.println(p.z);


    
  if (p.y < BOXSIZE) {
     oldcolor = currentcolor;

     if (p.x < BOXSIZE) { 
       currentcolor = ILI9341_RED; 
       tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*2) {
       currentcolor = ILI9341_YELLOW;
       tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*3) {
       currentcolor = ILI9341_GREEN;
       tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*4) {
       currentcolor = ILI9341_CYAN;
       tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*5) {
       currentcolor = ILI9341_BLUE;
       tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*6) {
       currentcolor = ILI9341_MAGENTA;
       tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     }

     if (oldcolor != currentcolor) {
        if (oldcolor == ILI9341_RED) 
          tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
        if (oldcolor == ILI9341_YELLOW) 
          tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
        if (oldcolor == ILI9341_GREEN) 
          tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
        if (oldcolor == ILI9341_CYAN) 
          tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN);
        if (oldcolor == ILI9341_BLUE) 
          tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
        if (oldcolor == ILI9341_MAGENTA) 
          tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);
     }
  }
  if (((p.y-BANNED) > BOXSIZE) && ((p.y+BANNED) < tft.height())) {
    tft.fillCircle(p.x, p.y, BANNED, currentcolor);
  }
}
Output after single point touch on fresh start, and then subsequent 'phantom' touches :
(timestamp) -> millis, x, y, pressure

Code: Select all

08:20:20.581 -> 171481, -46, 352, 598
08:20:20.671 -> 171571, -46, 352, 598
08:20:21.008 -> 171922, 68, 182, 614
08:20:21.008 -> 171923, 70, 181, 593
08:20:21.008 -> 171925, 69, 182, 453
08:20:21.008 -> 171926, 71, 184, 338
08:20:21.008 -> 171927, 69, 184, 317
08:20:21.008 -> 171929, 70, 183, 301
08:20:21.008 -> 171930, 71, 182, 323
08:20:21.008 -> 171931, 72, 182, 275
08:20:21.040 -> 171933, 72, 181, 276
08:20:21.040 -> 171934, 72, 181, 274
08:20:21.040 -> 171935, 73, 182, 262
08:20:21.040 -> 171936, 73, 181, 256
08:20:21.040 -> 171938, 74, 181, 250
08:20:21.040 -> 171938, 74, 181, 253
08:20:21.040 -> 171939, 73, 181, 252
08:20:21.040 -> 171940, 73, 181, 254
08:20:21.040 -> 171941, 74, 181, 250
08:20:21.040 -> 171943, 74, 181, 242
08:20:21.040 -> 171944, 72, 180, 234
08:20:21.040 -> 171945, 73, 180, 229
08:20:21.040 -> 171946, 73, 180, 222
08:20:21.040 -> 171947, 73, 180, 223
08:20:21.040 -> 171948, 73, 180, 221
08:20:21.040 -> 171949, 74, 181, 224
08:20:21.040 -> 171950, 74, 180, 241
08:20:21.040 -> 171951, 73, 180, 247
08:20:21.040 -> 171952, 74, 180, 281
08:20:21.040 -> 171953, 73, 181, 272
08:20:21.040 -> 171955, 72, 181, 308
08:20:21.040 -> 171956, 73, 181, 345
08:20:21.040 -> 171958, 71, 183, 411
08:20:21.040 -> 171959, 71, 181, 541
08:20:21.040 -> 171960, 70, 181, 719
08:20:21.040 -> 171962, 71, 181, 692
08:20:21.087 -> 171965, 71, 182, 610
08:20:21.087 -> 171966, 71, 182, 626
08:20:21.087 -> 171967, 70, 181, 741
08:20:21.087 -> 171968, 69, 182, 923
08:20:23.626 -> 174503, -46, 352, 299
08:20:25.810 -> 176700, -46, 352, 299
08:20:25.902 -> 176784, -46, 352, 299
08:20:28.531 -> 179418, -46, 352, 598
08:20:31.487 -> 182397, -46, 298, 598
08:20:34.011 -> 184894, -46, 352, 598
08:20:37.486 -> 188399, -46, 352, 598
08:20:40.364 -> 191253, -46, 297, 299
08:20:40.807 -> 191698, -46, 298, 299
08:20:41.688 -> 192585, -46, 298, 299
08:20:44.851 -> 195737, -46, 352, 598
08:20:46.062 -> 196947, -46, 352, 598
08:20:48.180 -> 199075, -46, 352, 598
08:20:48.788 -> 199678, -46, 298, 598
08:20:49.280 -> 200173, -46, 352, 299
08:20:50.136 -> 201052, -46, 352, 299
08:20:50.960 -> 201863, -46, 352, 598
08:20:51.178 -> 202079, -46, 352, 299
08:20:51.678 -> 202600, -46, 352, 299
08:20:52.304 -> 203218, -46, 352, 299
08:21:02.750 -> 213642, -46, 352, 598
08:21:05.361 -> 216250, -46, 352, 598
08:21:10.795 -> 221708, -46, 297, 598
08:21:12.181 -> 223094, -46, 352, 299
08:21:17.369 -> 228266, -46, 352, 299
08:21:21.452 -> 232345, -46, 352, 598
08:21:22.197 -> 233100, -46, 352, 299
08:21:25.055 -> 235962, -46, 352, 598
08:21:26.739 -> 237649, -46, 352, 598
08:21:28.961 -> 239851, -46, 352, 598
08:21:29.133 -> 240053, -46, 352, 598
08:21:29.584 -> 240468, -46, 352, 299
08:21:30.140 -> 241049, -46, 298, 299
08:21:33.071 -> 243965, -46, 352, 598
08:21:33.982 -> 244887, -46, 352, 598
08:21:36.044 -> 246957, -46, 352, 299
08:21:39.392 -> 250273, -46, 352, 598
08:21:41.186 -> 252086, -46, 299, 299
08:21:42.616 -> 253494, -46, 352, 299
08:21:56.732 -> 267640, -46, 352, 299
08:21:58.808 -> 269701, -46, 298, 299
08:22:01.947 -> 272829, -46, 352, 598
08:22:04.360 -> 275244, -46, 352, 299
08:22:04.501 -> 275398, -46, 352, 299
08:22:07.947 -> 278853, -46, 352, 597
08:22:09.316 -> 280207, -46, 352, 598
08:22:10.689 -> 281568, -46, 352, 598
08:22:15.870 -> 286749, -46, 298, 299
08:22:16.949 -> 287830, -46, 352, 299
08:22:22.131 -> 293013, -46, 352, 598
08:22:22.662 -> 293544, -46, 352, 598
08:22:23.421 -> 294314, -46, 352, 598
08:22:23.686 -> 294573, -46, 352, 598
08:22:25.458 -> 296342, -46, 352, 598
08:22:33.823 -> 304706, -46, 298, 299
08:22:38.225 -> 309109, -46, 352, 598
08:22:39.629 -> 310542, -46, 352, 299
08:22:44.321 -> 315208, -46, 298, 299
08:22:44.964 -> 315866, -46, 352, 598
08:22:45.961 -> 316865, -46, 352, 598
08:22:50.349 -> 321236, -46, 352, 299
08:22:56.107 -> 327017, -46, 352, 598
08:22:57.189 -> 328093, -46, 352, 598
08:23:02.390 -> 333284, -46, 352, 299
08:23:02.514 -> 333436, -46, 352, 299
08:23:04.193 -> 335096, -46, 352, 299
08:23:04.445 -> 335343, -46, 352, 299
08:23:05.670 -> 336562, -46, 352, 598
08:23:06.812 -> 337700, -46, 352, 299
08:23:08.402 -> 339288, -46, 352, 598
08:23:10.690 -> 341583, -46, 352, 598
08:23:13.802 -> 344697, -46, 352, 598
08:23:15.253 -> 346142, -46, 298, 299
08:23:16.452 -> 347344, -46, 352, 598
08:23:20.010 -> 350913, -46, 298, 598
08:23:24.086 -> 354970, -46, 352, 299
08:23:24.337 -> 355221, -46, 352, 299
08:23:27.326 -> 358251, -46, 352, 598
08:23:29.341 -> 360232, -46, 352, 299
08:23:36.493 -> 367380, -46, 352, 299
08:23:40.994 -> 371892, -46, 352, 598
08:23:46.343 -> 377228, -46, 298, 299
08:23:51.597 -> 382494, -46, 352, 598
08:23:54.528 -> 385431, -46, 352, 598
08:23:56.444 -> 387347, -46, 352, 299
08:23:57.130 -> 388021, -46, 352, 299
08:24:02.324 -> 393211, -46, 352, 299
08:24:02.470 -> 393362, -46, 352, 299
08:24:03.987 -> 394874, -46, 352, 299
08:24:10.386 -> 401280, -46, 352, 298
08:24:14.464 -> 405368, -46, 352, 299
08:24:14.759 -> 405665, -46, 352, 299
08:24:21.759 -> 412665, -46, 352, 299
08:24:23.965 -> 414877, -46, 352, 598
08:24:26.199 -> 417101, -46, 352, 299
08:24:30.217 -> 421138, -46, 352, 299
08:24:31.300 -> 422183, -46, 352, 299
08:24:34.138 -> 425036, -46, 352, 598
08:24:34.836 -> 425717, -46, 352, 299
08:24:36.152 -> 427049, -46, 352, 598
08:24:37.116 -> 428018, -46, 299, 598
08:24:41.622 -> 432529, -46, 352, 598
08:24:46.724 -> 437613, -46, 298, 299
08:24:52.201 -> 443090, -46, 352, 598
08:24:53.982 -> 444870, -46, 352, 598
08:24:56.087 -> 446992, -46, 352, 299
08:24:58.674 -> 449554, -46, 298, 598
08:25:03.716 -> 454616, -46, 352, 299
08:25:04.747 -> 455627, -46, 298, 299
08:25:08.868 -> 459751, -46, 352, 299
08:25:11.864 -> 462788, -46, 352, 299
08:25:13.821 -> 464736, -46, 352, 299
08:25:16.233 -> 467124, -46, 352, 299
08:25:17.699 -> 468587, -46, 352, 598
08:25:18.051 -> 468941, -46, 352, 598
08:25:19.217 -> 470103, -46, 352, 299
08:25:20.515 -> 471426, -46, 352, 598
08:25:20.639 -> 471531, -46, 352, 598
08:25:24.269 -> 475173, -46, 297, 299
08:25:25.813 -> 476720, -46, 352, 299
08:25:26.956 -> 477841, -46, 352, 299
08:25:29.318 -> 480215, -46, 298, 299
08:25:29.393 -> 480298, -46, 352, 299
08:25:31.636 -> 482530, -46, 352, 598
08:25:34.454 -> 485358, -46, 352, 299
08:25:38.622 -> 489517, -46, 352, 299
08:25:40.828 -> 491717, -46, 352, 598
08:25:42.021 -> 492912, -46, 352, 598
08:25:42.840 -> 493734, -46, 352, 596
08:25:46.444 -> 497330, -46, 352, 299
08:25:49.565 -> 500457, -46, 297, 598
08:25:50.402 -> 501312, -46, 352, 299
08:25:52.083 -> 502977, -46, 352, 299
08:25:53.075 -> 503955, -46, 352, 598
08:25:58.018 -> 508907, -46, 352, 299
08:25:58.250 -> 509136, -46, 352, 598
08:25:59.993 -> 510907, -46, 352, 598
08:26:01.927 -> 512816, -46, 352, 598
08:26:02.206 -> 513094, -46, 298, 598
08:26:07.168 -> 518062, -46, 352, 299
08:26:09.207 -> 520101, -46, 352, 299


User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: 3.2" TFT Resistive Touch Phantom touches

Post by adafruit_support_bill »

A couple of possible sources other than the displays or MCUs would be external interference or a marginal connection. I don't see any potential sources of electrical interference in the photos. But breadboard connections can be flaky. A marginal connection on the X and/or Y pins could result in spurious values that look like a 'touch'.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”