Go Down

Topic: [Solved] Mcufriends – distorted picture with Touch_shield_kbv (Read 257 times) previous topic - next topic

zahnd

Dear friends  :)

Regular UNO r3 (from China)
TFT LCD 2.4 (Jin Rong Electronics)
     xx5408
     AliExpress link

Application : Touch_shield_kbv
     #include <Adafruit_GFX.h>                       // Core graphics library
     #include <MCUFRIEND_kbv.h>
     MCUFRIEND_kbv tft;                                 // hard-wired for UNO
     #include <TouchScreen.h>

I get a distorted area (concave shape, depending of the screen) where I can draw, but I cannot draw outside of that borders

Could somebody help me to understand and correct it ?
Thank you very much




david_prentice

I ran your sketch that you posted a few days ago.

I had to make a few corrections.   You had mapped the Touch backwards. 

The screen behaved normally.

What happens with the regular examples?

David.

zahnd

Hello David 
Thank you very much for your answer; I am very pleased

I run again the regular example Touch_shield_kbv without any modification
I got the same defect (excepted that X and Y are inverted)
   Picture Distorsion3-regular

I just modified 3 lines in the Void LOOP, in order to straighten the image:
        //if (SwapXY != (Orientation & 1)) SWAP(tp.x, tp.y);
        SWAP(tp.x, tp.y);
       
        //xpos = map(tp.x, TS_LEFT, TS_RT, 0, tft.width());
        xpos = map(tp.x, TS_LEFT, TS_RT, tft.width(),0);
       
        //ypos = map(tp.y, TS_TOP, TS_BOT, 0, tft.height());
        ypos = map(tp.y, TS_TOP, TS_BOT, tft.height(),0);

   Picture Distorsion4-swapxy

I did a picture of the opposite side of the Touch
   Picture Distorsion5-screen
I twisted pins A4 and A5 for my application:
•   A4: to isolate RESET ... I added a wire between A4 and RST on the side of the screen
•   A5: to use the pin A5 ... I measure and monitor the supply voltage with a divider bridge between VIN and GND

And a picture of UNO
   Picture Distorsion6_uno
•   Additional wire to supply the board in 5V, during the setup
•   Voltage divider bridge (VIN / GND -> A5)

In the beginning of December, when I started to use these components, the screen behaved normally.
In produced the 3 boxes with the same parameters in each programme (it was the best compromise for the 3 boxes):
            uint16_t TS_LEFT = 860;                    // 920 Touch_shield_kbv
            uint16_t TS_RT  = 250;                       // 150 Touch_shield_kbv
            uint16_t TS_TOP = 900;                     // 940 Touch_shield_kbv
            uint16_t TS_BOT = 150;                     // 120 Touch_shield_kbv

In order to use the sketch dedicated for Diane, you have to inactivate the routine "Test-a-tension" in the Void LOOP because it uses the voltage divider bridge …


I don't know what else to do … what to try, what to test …
Thank you very much for your help
Michel

david_prentice

#3
Jan 13, 2018, 11:17 pm Last Edit: Jan 14, 2018, 09:13 am by david_prentice
I don't own an 0x5408.   But I have a "damaged" one on my desk.   (it has visible scan flyback)

I ran the new TouchScreen_Calibr_native sketch
Code: [Select]

TouchScreen.h GFX Calibration
Making all control and bus pins INPUT_PULLUP
Typical 30k Analog pullup with corresponding pin
would read low when digital is written LOW
e.g. reads ~25 for 300R X direction
e.g. reads ~30 for 500R Y direction

Testing : (A1, D7) = 29
Testing : (A2, D6) = 32
Diagnosing as:-
XM,XP:  (A1, D7) = 29
YP,YM:  (A2, D6) = 32
ID = 0x5408

cx=864 cy=929 cz=511
cx=857 cy=568 cz=514
cx=855 cy=220 cz=490
cx=560 cy=916 cz=568
cx=560 cy=221 cz=484
cx=243 cy=919 cz=664
cx=283 cy=573 cz=675
cx=282 cy=225 cz=625
MCUFRIEND_kbv ID=0x5408  240 x 320
const int XP=7,XM=A1,YP=A2,YM=6; //ID=0x5408
const int TS_LEFT=884,TS_RT=242,TS_TOP=944,TS_BOT=198;
PORTRAIT CALIBRATION     240 x 320
x = map(p.x, LEFT=884, RT=242, 0, 240)
y = map(p.y, TOP=944, BOT=198, 0, 320)
Touch Pin Wiring XP=7 XM=A1 YP=A2 YM=6
LANDSCAPE CALIBRATION    320 x 240
x = map(p.y, LEFT=944, RT=198, 0, 320)
y = map(p.x, TOP=242, BOT=884, 0, 240)


Note that the X and Y resistances are closer in value than I would expect.   After all,  the screen is 320 pixels in the Y direction plus another 20 for the icon area at the bottom of the screen.

And the LEFT and RT values are closer than normal.

Anyway,  I will plug my Calibration into the TouchShield example and leave it running overnight.
Code: [Select]

    } else if (identifier == 0x5408) {  //from doctorNick
        name = "SPFD5408 Dr Nick";
        XP=7,XM=A1,YP=A2,YM=6; //ID=0x5408
        TS_LEFT=884,TS_RT=242,TS_TOP=944,TS_BOT=198;


The Calibration works perfectly.   The coloured line follows my stylus exactly.

Note that the new Calibration sketch diagnoses XM, YP and does not need a SwapXY because it has determined the long side is Y.

I suggest that you run the Calibration with a cold shield.   Copy-paste from Serial to a text file.
Then run the Calibration again after your screen has started to misbehave.   Copy-paste to the text file.

Report back.

David.

Edit.   The Touch_shield_kbv sketch is still working fine Sunday 08.00 GMT.

zahnd

Dear David
Today, I just checked my stock and found 2 pcs 0x5408 from Jin Rong Electronics:
* one from the same batch but which does not work anymore,
* one from another batch but that works very well.

With the part that almost does not work, it seems to me that the problem is an accelerated aging of the screen

The part that was still not used, everything works perfectly ...
Here is the picture with the standard program Touch_shield_kbv

Tomorrow, I will continue the tests that you have very kindly indicated and report back to you
Thank you for your help

david_prentice

Your symptoms would be nothing to do with the TFT or SPFD5408.

I suspect that the Touch Panel is ageing / damaged / going wrong.
It is returning different values for X, Y.

You can run any non-Touch program.   Do your graphics get distorted?
Your own Touch program draws a white rectangle in the drawing area.

If the SPFD scan was distorted the rectangle would distort.

I am constantly amazed by all these obsolete TFT panels coming on the market.   I presume that the raw panels were "new replacement screens" for mobile phones which have since gone out of fashion.
They appear on the surplus market.  Get mounted on a Mcufriend universal pcb.  And sold through Ebay.

They all work pretty well.   They are so cheap,  you can just buy another one.
All the same.  It would be nice to know what the problem is.   I don't see why a resistive Touch Panel should "age" in a few days.   Unless your granddaughters are especially brutal.

The Calibration report might offer a few clues.

David.

zahnd

Dear David,

DAMAGE
You are right with my grand-daughters, but I love them, that's why I continue …
… but maybe it's me who have damaged the TFT …

Externally, the difference between OK and NOK is the welded wire between A4 and RESET
In order to use the I2C communication, I had twisted the A4 pin and I soldered this wire on the top of the PCB. I noticed that this wire is very close from the screen and the heating could have damaged it…
photo NOK = Distorsion4 (with a wire between A4>RESET)
photo OK = Distorsion7 (without any electronic modification)

CALIBRATION
•   TouchScreen_Calibr_new
Doesn't work on UNO, because it needs too much memory
Program : 26 780 octets (83%) on 32 256 octets.
Variable : 1 932 octets (94%) on 2 048 octets.
Risk of instability …

•   Utouch_Calibr_kbv
Works perfectly on the OK and on the NOK TFT
I measured 2 series of 5 measurements on each TFT

picture Distorsion8-calibration
Summary, from OK to NOK :
•   Lose of width (in average) : 375
•   Increase of dispersion : 21 and 24
Maybe, these values could characterize the "aging" of the TFT
I will test that procedure with the 2 other sick TFT (Manny and Victoire)


david_prentice

#7
Jan 15, 2018, 09:27 pm Last Edit: Jan 15, 2018, 09:31 pm by david_prentice
I do not understand why you "run out of memory" with the TouchScreen_Calibr_native sketch.   I get :
Code: [Select]

Using library Adafruit_GFX_Library at version 1.2.2 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_GFX_Library
Using library Mcufriend_kbv at version 2.9.8-Beta in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Mcufriend_kbv
Sketch uses 25190 bytes (78%) of program storage space. Maximum is 32256 bytes.
Global variables use 1022 bytes (49%) of dynamic memory, leaving 1026 bytes for local variables. Maximum is 2048 bytes.


Ok,  I am using the Beta library but the Beta uses the same amount of SRAM as the v2.9.7 Release you get from the Library Manager.   Note that the  TouchScreen_Calibr_native from the Beta can be found attached here i.e. message #0 in the main library thread.

I would really like to see the Serial Output from  TouchScreen_Calibr_native


Ah-ha.   I have just realised that you were using TouchScreen_Calibr_new which is not what I asked for.

David.



zahnd

CALIBRATION of the 3
Sorry, I finished the measurements with Utouch_Calibr_kbv
(I called the screens with the name of their owners)
Summary of these measurements, with an NOK TFT we have…
•   Decreasing of the width (RT - LEFT)
•   Increasing of the height (BOT - TOP)
•   Increasing of dispersion on TOP and BOT
Distorsion8-calibration: is the Excel file with values and summary

TOUCH PANEL
I agree with you:
•   There is NO problem of DISPLAY
•   There is only a problem of TOUCH, to catch the correct coordinates X, Y
Many instructions used in "non-touch" program are not affected:
… print … println … text IS NOT distored
… drawLine … fillRect … drawRect … rectangle IS NOT distored

The problem is hardware, and make the sequence below not working correctly:
    uint16_t xpos, ypos;        //screen coordinates
    tp = ts.getPoint();            //tp.x, tp.y are ADC values
    //
    SWAP(tp.x, tp.y);
    xpos = map(tp.x, TS_LEFT, TS_RT, tft.width(),0);
    ypos = map(tp.y, TS_TOP, TS_BOT, tft.height(),0);
    //
    tft.fillCircle(xpos, ypos, PENRADIUS, currentcolor);


TOUCHSCREEN CALIBRATION NATIVE
Thank you to gave me the link to upload the new program for calibration
I did the calibration with the 4 screens: OK and the 3 NOK (Diane, Victoire and Manny)
Distorsion9-native: is the Text file containing all reports

Thank you again for the time you spend for me
Michel

david_prentice

#9
Jan 17, 2018, 12:28 am Last Edit: Jan 17, 2018, 12:31 am by david_prentice
Your "Screeen OK"
1.  has similar ADC resistance values :  28, 29.   25, 30 is normal
2.  Calibration values look normal

Your "Diane NOK"
1.  has very unusual ADC resistance values :  31, 48.   25, 30 is normal
2.  Point cy values look inconsistent.
3.  Calibration results are very unusual for LEFT, RT

Your "Victoire NOK"
1.  has normal ADC resistance values :  24, 34.   25, 30 is normal
2.  Calibration values look normal
3.  YP, XM pins are different to all the others

Your "Manny NOK"
1.  has slightly unusual ADC resistance values :  28, 30.   25, 30 is normal
2.  Point cy values look crazy.
3.  Calibration results are very unusual for LEFT, RT


Did you buy all four screens at the same time?
Did you buy them from the same Vendor?

Although Ebay has described the 2.4 inch screens as SPFD5408,   no geneuine 0x5408 IDs were detected until recently.

Obviously a batch of SPFD5408 screens have just come onto the Ebay market.

Someone else reported "similar" resistance values for X, Y on her 0x5408 screen.
All the other rectangular screens give different resistance values i.e. ~25, ~30.

I suggest that you just buy four new screens and put it down to bad luck.
You can always use the duff Touch Screens for non-Touch projects.

David.

zahnd

Dear David

Thank you very much for all your analysis and explanations

The 4 screens came from the same supplier: Jin rong electronics co., LTD
•   The 3 NOK come from the same batch (5 parts)
   o   ordered 11/9/2017 - delivered 29/9/2017
   o   no logo under the screen
•   The screen OK come from another batch (1 part)
   o   ordered 29/10/2017 - delivered 6/12/2017
   o   5 logos at the bottom of the screen

I found another supplier for 0x5408 … IC-atmega Franchise stores
I ordered to him only 1 part, and that part is OK !!!
I did a synthesis of what I bought during the last year

Finally, you are right, I will order new screens to build again my magic slates !!!
… maybe in the little shop near my home, even if the prices are very, very high ;)

Thank you for all your messages and all the advice
With pleasure
Michel

david_prentice

You have had bad luck.   I think that all my 2.4 inch shields arrived with intact glass.   One had a missing X direction on the Touch.

Most 3.5 inch Uno Shields arrived with broken glass.   One with bad controller.

The important thing.   Whinge to Ebay / AliExpress if you have a broken / bad item.    They will refund your money.

David.

Go Up