ILI9341 and XPT2046 for Teensy Touchscreen 320x240 display

Status
Not open for further replies.
Thats working, when I take the teensy off the audioboard and set that up using breadboard/wiring it works as planned with XPT-CS on pin 8. Thanks thusfar I will report back
 
Hi

I connected pin 8 and pin 2 to allow both CS and IRQ from the XPT. Unfortunately also this does not seem to work in my current setup. It was working fine when using it with the default SPI pins (11,12,13), using those again would mean building a cablejungle directly added to the bottom of the audioboard towards my TFT. Currently it seems I will have to focus on using the TFT without touch and control menu etc using encoders.

FWIW: I get a constant readout of X=1023 and Y=447 (sometimes without touching Y=319)

regards
Cor
 
That sounds very odd. Not sure if a picture could help showing the desired configuration as wired?

When wired as desired - is it the example sketches when updated for those pins that fails as well?

Could you write a sketch to test the pins 27/28/29 and others to work as required for input or output? wire 2<>29 and 27<>28 then write out LOW then toggle HIGH every 2 seconds? Enough time to place a meter on them and read the Serial output showing the expected state to agree with the meter reading? That would perhaps show if there is a short or dead pin #29. If that works then the an example should be made to work on those pins.
 
Hi,

I used the code below, as stated the screen works as planned on 27,28,39 but XPT-CS on 8 and XPT-IRQ on 2 do not respond. I will see if I can disassemble the TFT/XPT and the teensy today and wire everything up again on a breadboard to test this.

Cor


Code:
#include <ILI9341_t3.h>
#include <font_Arial.h> // from ILI9341_t3
#include <XPT2046_Touchscreen.h>
#include <SPI.h>

#define CS_PIN  26
#define TFT_DC  20
#define TFT_CS 21
// MOSI=11, MISO=12, SCK=13

//XPT2046_Touchscreen ts(8);
#define TIRQ_PIN  8
//XPT2046_Touchscreen ts(CS_PIN);  // Param 2 - NULL - No interrupts
XPT2046_Touchscreen ts(8 );  // Param 2 - 255 - No interrupts
//XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN);  // Param 2 - Touch IRQ Pin - interrupt enabled polling

ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC,255,28,27,39);

void setup() {
  Serial.begin(38400);
  tft.begin();
  tft.setRotation(1);
  tft.fillScreen(ILI9341_BLACK);
  ts.begin();
  ts.setRotation(1);
  while (!Serial && (millis() <= 1000));
}

boolean wastouched = true;

void loop() {
  boolean istouched = ts.touched();
  if (istouched) {
    TS_Point p = ts.getPoint();
    if (!wastouched) {
      tft.fillScreen(ILI9341_BLACK);
      tft.setTextColor(ILI9341_YELLOW);
      tft.setFont(Arial_60);
      tft.setCursor(60, 80);
      tft.print("Touch");
    }
    tft.fillRect(100, 150, 140, 60, ILI9341_BLACK);
    tft.setTextColor(ILI9341_GREEN);
    tft.setFont(Arial_24);
    tft.setCursor(100, 150);
    tft.print("X = ");
    tft.print(p.x);
    tft.setCursor(100, 180);
    tft.print("Y = ");
    tft.print(p.y);
    Serial.print(", x = ");
    Serial.print(p.x);
    Serial.print(", y = ");
    Serial.println(p.y);
  } else {
    if (wastouched) {
      tft.fillScreen(ILI9341_BLACK);
      tft.setTextColor(ILI9341_RED);
      tft.setFont(Arial_48);
      tft.setCursor(120, 50);
      tft.print("No");
      tft.setCursor(80, 120);
      tft.print("Touch");
    }
    Serial.println("no touch");
  }
  wastouched = istouched;
  delay(100);
}
 
That doesn't show the right constructor to enable/detect interrupts?

It seems to show this in use?::
XPT2046_Touchscreen ts(8 ); // Param 2 - 255 - No interrupts

This one commented out::
//XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling

Should be used as::
XPT2046_Touchscreen ts(8, 2); // Param 2 - Touch IRQ Pin - interrupt enabled polling

IIRC correctly that should still work - as I wrote it when no TIRQ_PIN is supplied it just seems as though the INT was always there.
 
As expected - it defaults to original behavior with no INT pin. About to log off … you have seen touch work - just not on those pins? I thought #29 was touch CS - I'd do the noted check sketch with pin 8 as output and pin 2 as input - and wire them together - write 8 and read 2 and print and delay the 2 secs and hold a meter on it and have the code repeat. Check there isn't a solder bridge on Touch CS? It should stay high with example sketch - except during touch read.
 
Indeed I had the original sketch working with default SPI pins and without the audio-board. I havent seen#29 mentioned as Touch_CS, ill see if pin 8 stays high when i start the sketch
 
It should not matter what pin you use for the TS cs, as this does not use any of the hardware CS capabilities. It simply uses PinMode(csPin, OUTPUT); and digitalWrite(csPin, LOW)...

I would double check your wiring and make sure that everything is connected properly...
Sometimes I have seen logic SPI begin functions of other devices interfering. So in some cases I force all of the CS pins high before the first begin is called....

Code:
...
#define CS_TS 8
#define TIRQ_PIN  2
XPT2046_Touchscreen ts(CS_TS, TIRQ_PIN);  // Param 2 - Touch IRQ Pin - interrupt enabled polling
...
#define 
void setup() {
  Serial.begin(38400);
  pinMode(CS_TS, OUTPUT);  // initialize it as output
  digitalWrite(CS_TS, HIGH);  // make sure TS is not selected before tft begin...

  tft.begin();
  tft.setRotation(1);
  tft.fillScreen(ILI9341_BLACK);
  ts.begin();
  ts.setRotation(1);
  while (!Serial && (millis() <= 1000));
}

But it would really help to see the actual wiring... That is personally the first thing I would look at. That is: assuming PJRC touch screen: https://www.pjrc.com/store/display_ili9341_touch.html
You moved the SPI to some alternate SPI pins for SPI which is fine. But did you move it for both sets of SPI pins going to the display? That is the display has separate SPI pins for both the actual display and for the touch screen controller.
 
Hi,

I took the teensy out of my batdetector-prototype. Then connected the ILI9341 to the default setup (CLK=13,MOSI/MISO=11/12, DC=20, CS=21). The ILI works as planned. My XPT/ILI use the same SPIbus on the board I am using. The TFT was originally used on a TexasInstrument MSP430 launchpad and was designed for the 2x10pin connectors on those boards.
pinout TFT.png
In the schematic of the connector CS3 is the CS for the XPT, PENIRQ is the IRQ for the XPT.
Ive connected CS3 to pin 8 on the Teensy ... measured the connecting with the multimeter-OK. Measured the voltage after startup using the default sketch, close to 0V. So I adjusted the sketch by setting TS_CSPIN to OUTPUT and HIGH and I see now 3.3V as planned. However no change in the readout, 319Y1023X, BTW when I connect TS_CSPIN to 3.3V ... the values change to 8191Y8191X

Everything is directly connected to a breadboard ilibreadboard.jpg
 
Ive decided to forget about the interactive screen for the moment being. The TFT was responsive when I had set it up for the first time just following the "rules" for an ILI9341 plus XPT. Ive now set it up exactly like that and it does not work. My logic tells me that something most have changed between my initial test and the current test. Maybe the resistive screen part isnt connected properly anymore ... I cant test that, ive tested the 4 lines coming fro the edge-connector on the FFT from the connective screen towards the ILI9431 chip. Those lines are connected ... puzzled what I can be. Takes too much time at the moment to stop development on my batdetector. Sometimes you dont win ;)
 
I don't see anything obvious... I am assuming that you are using the constructor that does not specify the IRQ pin? If so a couple of things I would do if it were me.

Try it with the IRQ pin specified. Make sure the right pin is specified, your define in first post showed pin 8, which as your CS pin...

Try it without IRQ pin AND don't connect the IRQ pin to the display...

Make sure your breadboard stuff is working. That is I have chased down problems before, which turned out an issue, like maybe cold solder joint on one of the new IO pins you are using. Or maybe the jumper wire was not making proper contact or...
 
Hi Kurt,

I always try to measure resistance directly on the pins that have to be connected, so the pins on TFT and the pins on the TEENSY. That way any issue "en route" should become visible. Tried allready with IRQ ... no difference.

Thanks for the help,

Cor

EDIT: When I disconnect CS from the teensy, the readout changes ... when I connect it goes back to the default. I am now on pin3 and it reads X255Y1020 as default and without a connection (CS=LOW) this becomes X240Y960 ... unfortunately I dont see any logic behind this
 
Last edited:
Again it is hard at times to tell what is going on...

Also hard to really see from the one picture what things are hooked up to what... From what I am seeing
J2 (Brown-GND, NC, NC, NC, NC, Y=11, G=12, Gray=21?, NC, NC)
J1 (PUR-3.3, NC, NC, NC, Green=20?, NC, Yellow=13, NC, White=10?, NC)

Again with the one angle it is hard to see what is actually connected to what... But from the angle it looked like
the White wire, which I think is supposed to be the CS for touch looks like it might be on pin 10 or 9, probably not 8?...

Also if it were me, I would probably hook this up to one of my Saleae logic analyzers and watch the SPI signals including the different CSs...

Also would check the IRQ pin when the finger is touching the screen and when not...
 
Indeed I had the original sketch working with default SPI pins and without the audio-board. I havent seen#29 mentioned as Touch_CS, ill see if pin 8 stays high when i start the sketch

I misread post #95 and saw 39 as 29 when looking at the Card assuming sequential pins.

Have you ever seen that touch work with the XPT2046 library? That board is not the same format as the PJRC with linear pins on one end. Can you breadboard it to another Teensy?

In the time I spent back then this isn't something I managed to encounter with PJRC screen or other ebay units I ordered that looked like them. Other than Frank_B's C64 PCB setup and my time testing it on Beta T_3.6 I have not worked with this unit in some time - and have not gotten any newer/alternate touch display units in the past 2 years.
 
Have you ever seen that touch work with the XPT2046 library? That board is not the same format as the PJRC with linear pins on one end. Can you breadboard it to another Teensy?
.
As stated in #111 it was working a fewdays ago when I started to mount this TFT. I first tried to get the TFT and XPT on a breadboard working before adding it to my project. As it worked I added it to my project, then had trouble reading the XPT and I still do. For the moment this is not limiting me very much so I am moving on with my project
 
Just confirming - saw 'TFT' and wasn't clear on how to read XPT into that. Given it was known to work - unless it got zapped - it really should work on altered pins … ???
 
Again as I mentioned in #114, I wonder if the pins are connected the way you think they are. Again is the CS pin connected to pin #8? Sometimes when things like this are not working, I undo all of the wires and redo them, just to make sure... Likewise in cases like this I might do a simple app that does something like:
Code:
#define PIN 8
void setup() {
  pinMode(PIN, OUTPUT);
}
void loop() {
  digitalWrite(PIN, !digitalRead(PIN));
  delay(500);
}
And then run it, and use something like Logic analyzer, or volt meter or ... simply connect up the ground of the Multimeter and connect up to what you think is pin 8, and see if it changes state every half second. If not probably not hooked up right.

Actually I keep around simple sketch that allows me to choose which pin to blink. Which I call Blink_any_pin
Code:
int current_pin = 13;
int next_pin_number = 0;
void setup() {
    // Blink any pin.  Note: I put pin 13 as input to see if we can
  // jumper to it to see if we can find the pin...
  while (!Serial && millis() < 5000);
  Serial.begin(115200);
  delay (250);
  Serial.println("Find Pin by blinking");
  Serial.println("Enter pin number to blink"); 
  pinMode(13, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available()) {
    int ch;
    while ((ch = Serial.read()) != -1) {
      if ((ch >='0') && (ch <= '9')) {
        next_pin_number = next_pin_number * 10 + (ch-'0');
      } else {
        if (next_pin_number != 0) {
          digitalWrite(current_pin, LOW); // turn the previous pin to low...
          current_pin = next_pin_number;
          pinMode(current_pin, OUTPUT);
          if (current_pin != 13)
            pinMode(13, INPUT);
          digitalWrite(current_pin, HIGH);
          next_pin_number = 0;  // setup to enter next pin
          Serial.printf("Now Blinking pin %d\n\r", current_pin);
        }
      }
    }
    
  } else {
    digitalWrite(current_pin, !digitalRead(current_pin));
    delay(250);
  }
  

}
Which allows me to type in a pin number I wish to blink. It also checks if the pin is not pin #13, it turns pin 13 into Input pin.... So if you jumper your expected pin,example pin 8 to pin 13, then the LED should reflect the state of the current selected pin...

I have used this a few times to verify that my wiring is working and I am connected up to the pins I think I am...
 
Hi Kurt,

I have checked things several times, reassembled etc etc. Measured if the CSpin was high on teensy after starting, measured the CSpin on the TFT board .... everything was as planned but it still did not work. Thats unfortunate but for the moment being I see this as some hardware issue probably on my TFT board. Everything else works as planned and I can develop my application currently without touch.

Cor
 
Hi all,

Just to inform ... it was a usermistake not due to wrong wiring but a simple code-mishap. The library I was using for SPI had a setting for the SPISPEED that was different from the SPISPEED the ILI9341 is using ... it seems that the variable for the SPISPEED of the XPT2046 touch was set to 20Mhz instead of the 2Mhz normally used (according to https://github.com/PaulStoffregen/XPT2046_Touchscreen/blob/master/XPT2046_Touchscreen.cpp). Now things are as planned ... sorry to have bothered anybody.

regards
Cor
 
Hello, I can run all the xpt2046 example and they display beautifully and serial monitor acts as it should HOWEVER, I can not get any touch response. I have it wired as the documentation for the ILI9341 2.8" Color Touch Display indicates to a Teensy 3.6. This is the PJRC display.

I'd appreciate any assistance to get the touch working. Thanks!

Pete
 
Recheck all the too many wires to have a good connection - no shorts - to the proper place and agrees with the software defined values.

Start with a simple touch example. Displays from PJRC are individually checked - not sure if that includes a touch verify. When running a touch example without IRQ pin connected if SPI on pin 13 the LED will flash on each test. And with IRQ - and no display writes - the LED would flash while touching but that just indicates it is trying to pulse the hardware.
 
Ok, I am convinced this PJRC touchscreen is faulty. I inspected the screen to make sure all connection on the pcb were good both ohm and voltage. I used new wires to directly connect the teensy 3.6 pins to the display pins as documented. All graphics display correctly and the Serial Monitor indicates all is working and even get "Touch Screen started" but there is no reaction to "touches" with either finger or stylus that came with it.

I am giving up for now. I have a OSH Park "Purple" board and Teensy 3.2 ordered. If that doesn't get this display to work I will relegate the display to the junk pile. Maybe just use it for a non-touch project. This should not be so difficult to get working! I've spent too many frustrating hours on this which should be spent coding.
 
We do test every single display here. The test involve touching the 2 corners of the screen.

In fact, here's a photo of the test. When the operator touches those yellow squares, each turns green and the screen updates to show the test passed. The green LED on the tester also turns on. This test also reads pixels back from the display's frame buffer and does lots of other checks while it's running. The red light turns on and the whole thing shuts down if any of those checks gives bad data while it's running.

PJRC_Good_Display_web.jpg

Now it's possible your display could be damaged. But the touch portion of the display is very rugged. Damaged displays usually work fine but show physical signs of abuse (like cracks in the glass) or have an all-white screen if the connection to the display gets damaged. Even when the glass display is damaged, the touch portion almost always works. It's all plastic material that's very durable.

Before we conclude this rather rugged hardware got damaged, maybe you could show photos of how it's actually connected? Even if you're double checked and triple checked the wiring, maybe we'll be able to help notice something you've overlooked?
 
It came with a Stylus? None of mine from PJRC did …

PJRC Tester looks nice - good use of the ZIF socket - I knew they were tested, that shows how extensively. Which is good because the ones from eBay or elsewhere are unknown quantities - maybe broken or have the wrong controllers to work with library code.

Was hoping when I saw picture it might make it easy to see wiring - but that is quite a bunch of wires needed.
 
Status
Not open for further replies.
Back
Top