Author Topic: Capacitive touch problems under linux (FT5x06)  (Read 20005 times)

vpd

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
    • View Profile
Capacitive touch problems under linux (FT5x06)
« on: July 02, 2014, 04:46:12 PM »
Hi,

now we are prototyping couple of devices using TI AM3358 Starter Kit. (http://www.ti.com/tool/tmdssk3358)
Original kit goes with resistive touch but we purchased couple of displays with capacitive touch from digikey:
1) NHD-7.0-800480EF-ATXL#-CTP
2) NHD-4.3-480272EF-ATXL#-CTP

Then we tried several FT5x06 drivers found on internet. One driver was good enough to work with touch screen. Most of them failed due to firmware version mismatch. However, several problems still exist.

1) Now driver works only with 7" display. 4.3" does not. Driver recognizes both displays via I2C, handshakes, etc. but in case of 4.3" there are no interrupts from FT5x06 during touch activity. We tried 3 different 4.3" displays from one purchase and result is the same. Then we supposed that driver has set touch threasholds too high so it does not recognize events. We tried to write different values of amplifier via the linux driver but this does not help. So, 4.3" touch does not work even without any glass.

2) Display of 7" works if direct touched but does not when placed beyond 4mm glass. Similar to item 1 we could not find solution how to improve sensivity.  We see in linux kernel log that 7" and 4.3" displays report slightly different descriptors during handshake. Now I cannot remember exact phrase but something about different number of rows in matrix.

Is there any guide how to set up touch controller settings to force it to work? We actually need it to be placed beyong glass as thick as 2 mm (or even 4 mm).

Best regards.

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #1 on: July 03, 2014, 09:11:37 AM »
The 4.3" TFT uses the FT5306, and the 7.0" TFT uses the FT5406.  There are a different number of rows between the two touch panels.
The controller IC has various registers that can be set to custom values, such as touch threshold.  Below is a link to the FT5x06 application note, which shows these registers:
http://www.newhavendisplay.com/app_notes/FT5x06_registers.pdf
You can see the table of registers on pages 4-7, and more detail about the threshold registers on pages 9 & 10.

vpd

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #2 on: July 04, 2014, 10:08:46 AM »
Michael,

We could set up 7" sensivity and now it works with 4 mm glass cover. However, for this case threshold is too close to sensor noise margin. Spontaneous cursor movement can be seen with a threshold of 3 and glass strart to work at threshold 5. So, 7" touch screen works OK.

The most urgent problem remains with 4.3" display. As we discovered it does not work as described. In fact, it is present on i2c bus but it allways reads ad last byte written to it. For example, if we write in u-boot i2c tool:
i2c read 38 80.1 2 80200000
it reads two bytes: 80 80
if we asked it to read 5 bytes it would read 5 times the same byte, 80. The byte is always equal to register number being written.

7" display reads correctly: reading 5 bytes gives us 5 consecutive registers starting from given register number.

We tried both 400kHz and 100kHz bus speed. The rresults are the same.

So we still have problem with it.


Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #3 on: July 08, 2014, 09:37:01 AM »
The I2C protocol between the two displays should be the same.  Do you have another 4.3" TFT with capacitive touch panel to try?

vpd

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #4 on: July 08, 2014, 09:41:30 AM »
We have three displays with the same behavior.

We tried to write to mode register hoping that it will hear and exit test mode but that didn't help.
« Last Edit: July 08, 2014, 09:43:32 AM by vpd »

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #5 on: July 08, 2014, 09:45:02 AM »
In that case, it is most likely something with your driver/code.  Please verify this and try the display again.  I have used all of our TFT's capacitive touch panels with the same code and they have all been proven to work.

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #6 on: July 08, 2014, 10:11:38 AM »
I have just confirmed what I have said above, with the below code:

Code: [Select]
//---------------------------------------------------------
/*
CTP_Register_Test_mega.ino
Program for writing/reading to/from Newhaven Display Capacitive Touch Panel with FocalTech FT5x06 controller
Please refer to the below URLs for the touch panel controller documentation:
http://www.newhavendisplay.com/app_notes/FT5x06.pdf
http://www.newhavendisplay.com/app_notes/FT5x06_registers.pdf

(c)2014 Mike LaVine - Newhaven Display International, LLC.

        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
*/
//---------------------------------------------------------
#include <Wire.h>

int WAKE = 14;    //WAKE signal is connected to digital pin 14 on the Arduino Mega2560
int INT = 15;     //INT signal is connected to digital pin 15 on the Arduino Mega2560

//SDA line is connected to digital pin 20 (SDA) on the Arduino Mega2560
//SCL line is connected to digital pin 21 (SCL) on the Arduino Mega2560

unsigned char dummy, gesture, numpoints, t1xh, t1xl, t1yh, t1yl;
unsigned char x, read1, read2, read3, read4;
unsigned int t1x, t1y;

const char slave = 0x38;    //slave address of 0x70 shifted over 1 bit
const char slave_read = 0x39;

void init_CTP()
{
digitalWrite(WAKE, HIGH);
        delay(100);
digitalWrite(INT, HIGH);
delay(100);
        digitalWrite(WAKE, LOW);
        delay(200);
        digitalWrite(WAKE, HIGH);
        delay(200);
}
     
void i2c_read(char addr, unsigned char reg)                  //function for reading a specified register
{
  unsigned char x;
  Wire.beginTransmission(addr);
  Wire.write(reg);
  Wire.endTransmission();
  Wire.requestFrom(addr, 1);
  while(Wire.available())
  {
    x = Wire.read();
    Serial.println(x, DEC);
  }
}

void i2c_read4times(char addr, unsigned char reg)           //function for reading 4 registers in a row, starting from specified register
{
  unsigned char x;
  Wire.beginTransmission(addr);
  Wire.write(reg);
  Wire.endTransmission();
  Wire.requestFrom(addr, 4);
  while(Wire.available())
  {
    read1 = Wire.read();
    read2 = Wire.read();
    read3 = Wire.read();
    read4 = Wire.read();
  }
}
/*****************************************************/
/*****************************************************/
void setup()
{
        pinMode(WAKE, OUTPUT);
        pinMode(INT, INPUT);
        init_CTP();
        Wire.begin();
        Serial.begin(9600);       
}
void loop()
{

   
    while((digitalRead(INT)) == LOW)
    {
        i2c_read4times(slave, 0x00);
        dummy = read1;                               //dummy read
        gesture = read2;                             //which gesture register read
        numpoints = read3;                           //how many touch points register read
        t1xh = read4;                                //upper 8 bits of X-axis touch location
        i2c_read4times(slave, 0x04);
        t1xl = read1;                                //lower 8 bits of X-axis touch location
        t1yh = read2;                                //upper 8 bits of Y-axis touch location
        t1yl = read3;                                //lower 8 bits of X-axis touch location
        dummy = read4;                               //dummy read
        t1x = t1xl | (t1xh << 8);                    //get the 16 bit X-axis touch location
        t1y = t1yl | (t1yh << 8);                    //get the 16 bit Y-axis touch location*/
       
       
       
        i2c_read4times(slave, 0x80);
        dummy = read1;
       
    //****************************************************************************//
    //  UNCOMMENT THE LINE BELOW THAT YOU WANT TO BE SHOWN ON THE SERIAL MONITOR  //
    //****************************************************************************//
       
        //Serial.println(gesture, HEX);delay(25);    //show gesture value
        //Serial.println(numpoints, HEX);delay(25);  //show how many touch points
        //Serial.println(t1x, HEX);delay(25);        //show 16 bit X-axis touch location
        //Serial.println(t1y, HEX);delay(25);        //show 16 bit Y-axis touch location
        Serial.println(dummy, DEC);delay(25);       
       
        //delays are only used here to slow down scrolling in the serial monitor
        //********************************************************************//
    }   
}


I get decimal 25 from the HEX 80 register with the 4.3" display.

vpd

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #7 on: July 08, 2014, 10:13:02 AM »
Michael,

1) We use the same code to work with both displays. As you understand this code is either linux or u-boot (based on the same linux) i2c bus framework that has been testing for many years.

2) We used an oscilloscope to inspect the signals on the bus. We didn't see any artefacts on signal timings. Also, we saw the display responds with an ACK so this behavior cannot be thought as just undefined bus.

We need some advice from you what can we check to solve this issue. Probably, there are some issues with an /WAKE signal that works differently for 7" and 4.3" display. This signal is tied to ARM GPIO and goes between pulled up, pulled down and undefined state sereval times during linux boot.

Best regards, Vladimir
« Last Edit: July 08, 2014, 10:17:47 AM by vpd »

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #8 on: July 08, 2014, 10:18:06 AM »
I have not heard of this issue before, and have posted code I have just used confirming the register read does work.  I very highly doubt you have defective displays, but if you would like to send them back to us for analysis, you may email nhtech@newhavendisplay.com with the part number, requesting an RMA form.

You may be correct, since the WAKE signal operates as you have described.  As you will see from my code, I have it set HIGH, then LOW, then kept HIGH (to initialize it) and I am able to read the registers from all sizes of our capacitive touch panels.
« Last Edit: July 08, 2014, 10:21:30 AM by Michael_L »

vpd

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #9 on: July 08, 2014, 10:55:22 AM »
Michael,

Unfortunately, the WAKE signal is poorly documented. As I could understand, it is either interrupt to Touch MCU or just a reset. It is called /WAKE in datasheet but actually on the ribbon pcb of display is marked as RST so we are confused. There is a period during boot when this signal has about 2V, not 3.3 and not 0. Moreover, this voltage is strong enough - when we tried to short /WAKE to adjacent INT pin on the connector (being 3.3V and that time) we got just 2.3V, not 3.3. I suspect that all this issues could force FT5x06 to hang. So, do you know the way to get it back to initial state? Will the one ground pulse of 100ms to WAKE signal be enough?

Vladimir
« Last Edit: July 08, 2014, 10:56:56 AM by vpd »

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #10 on: July 08, 2014, 01:05:14 PM »
The marking on the ribbon PCB should say WAKE, not RST.  Regardless, they are the same function.
To get back to the initial state you would need to power cycle it, although there shouldn't be any hanging if you are initializing it as shown in the code I've posted.
(This part):

void init_CTP()
{
   digitalWrite(WAKE, HIGH);
        delay(100);
   digitalWrite(INT, HIGH);
   delay(100);
        digitalWrite(WAKE, LOW);
        delay(200);
        digitalWrite(WAKE, HIGH);
        delay(200);
}
The delay values are in milliseconds.

vpd

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #11 on: July 08, 2014, 01:51:37 PM »
To say trouth, the marking on PCB is as follows:
1) 4.3" - WAKE
2) 7" - RST
However, i see /WAKE signal in both datasheets. That's why I was confused.

Ok, we will try to issue a reset to wake signal. Actually, we did it manually by wire (sporadic pulse, not equal 100ms) but this didn't help. Probably we need something else?

vpd

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #12 on: July 10, 2014, 06:17:00 AM »
Michael,

It seems we found a reason of the strange behavior. The problem is how fast I2C host goes to reading stage of I2C transfer after finishing its write state. FocalTech chip in 4.3" display is slow so it is not ready with data when the ARM processor starts read part of transaction. Now I tested it with another host which can wait for 1 ms between writing register address and issuing next start condition. In this case display works.

I think you should also test this and add this information into display datasheet. It is TOO IMPORTANT to be in NHD datasheet, not in an application note. Also, you should clearly state in datasheet what chip is used for each display.

I looked through FT chip datasheet and there is no information of this issue. All the delays reported in the spec are about 4-5 mks that is about 2 bit intervals on 400KHz bus and half bit interval of 100 kHz bus. I saw using the scope that we actually have reading delay not less then 2-3 byte intervals but this doesn't work. I think that FT5306 processes its I2C interrupt too slow to update the I2C transmit register so we get the value that has been written in write stage of the transaction.

We will try to play with reading delay on ARM processor to clarify the typical value of delay that works. Now we see that 5406 and 5306 have different delays, possibly because they have different clock frequencies, 5406' being higher that one of 5306.

« Last Edit: July 10, 2014, 06:18:36 AM by vpd »

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #13 on: July 10, 2014, 08:38:47 AM »
Thank you for sharing your findings, I'm sure it will help others that run into the same issue.  I had not run into this issue before using our testers, but it seems it is highly dependent on which processor is being used.

We will of course keep your suggestion for the datasheets in mind for any future revisions.

Thanks again!

vpd

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
    • View Profile
Re: Capacitive touch problems under linux (FT5x06)
« Reply #14 on: July 11, 2014, 05:54:45 AM »
Michael,

Ops! Sorry, that was a graceful explanation but it's not true  ;) I made a conclusion comparing two different timings but once programmers added delays on ARM linux nothing actually changed.

But! Then I proposed to pull the flat cable out of connector and push it back while the u-boot is running. And it started to work properly!
The difference between these two cases is that when it is a 'cold' start processor has undefined state on GPIO pins. Most probably they are tri-stated. And there are no pull-up resistors on INT and WAKE, so they float. But then u-boot starts and places GPIO pins in a known state. When we re-plug the cable we power up FT5306 with WAKE being high, not undefinied. And it works.

Now we patched the starter kit by adding 10K pull-up to WAKE. And it works now.

It seems that FT5306 monitors WAKE during its startup and enters some test mode if WAKE is low. Probably, you can ask FocalTech what do they know about this? And what do they think?

Please, check this issue with your displays if possible. If so, this 'feature' must be documented.

Vladimir
« Last Edit: July 11, 2014, 05:58:39 AM by vpd »

 

NHD‐3.5‐320240MF‐ATXL#‐T‐1 Touch Signal

Started by jmasamotoBoard TFTs

Replies: 1
Views: 2093
Last post February 05, 2016, 08:05:40 AM
by Paul_B
NHD‐2.4‐240320SF‐CTXL#‐FTN1 touch-screen problem

Started by hbcelebiBoard TFTs

Replies: 5
Views: 4158
Last post December 10, 2014, 11:19:05 AM
by Michael_L
Problems with a NHD‐0420H1Z‐FL‐GBW‐3V3

Started by c2hollowBoard Character LCDs

Replies: 8
Views: 4311
Last post October 27, 2017, 11:51:46 AM
by NoellEagan
NHD-5.0-800480TF-ATXL#-T and NHD-5.0-800480TF-20 Controller Board No Touch?

Started by dfanslerBoard TFTs

Replies: 5
Views: 874
Last post May 26, 2017, 11:10:57 AM
by Saurabh_B
NHD-4.3-480272EF-ASXN#-CTP touch controller interrupt signal

Started by Chris ElectronicsBoard TFTs

Replies: 2
Views: 2364
Last post May 20, 2016, 07:38:45 AM
by Chris Electronics