3.5 TFT LCD mcufriend instability and inverted colors

You can't change the DS3231 address. It is always 0x68.

It is wise to wire for a USE_SPECIAL, USE_MEGA_8BIT_PROTOSHIELD:

LCD_D0 >>> 22
LCD_D1 >>> 23
LCD_D2 >>> 24
LCD_D3 >>> 25
LCD_D4 >>> 26
LCD_D5 >>> 27
LCD_D6 >>> 28
LCD_D7 >>> 29

LCD_RD >>> A0
LCD_WR >>> A1
LCD_RS >>> A2
LCD_CS >>> A3
LCD_RST >>> A4

LCD_GND >>> GND
LCD_3V3 >>> 3V3
LCD_5V >>> 5V

David.

Edit. Added the two symbols that you must uncomment in utility/mcufriend_shield.h and utility/mcufriend_special.h

Hello David,
Thank you for your advice and your patience
I am at home, so I can test your proposal …

1. Chinese TouchScreen MCUFRIEND n°Y11: doesn’t work
I just received an additional Touchscreen from China: MCUFRIEND
(it was sent by my Supplier YCT ShenZhen, who assembled my 10 parts)
This screen is exactly the same than the previous 10 screens:
• No regulator
• ID : 0x99
• XP 6 – XM 56 – YP 55 – YM 7
• All the registers are the same (by using LDC-ID_readreg)
• BLINKS at each second when I ask the clock DS3231

2. TouchScreen Hong Kong Feng Tai n°10: works
I restarted from the beginning by using:
• New MEGA 2560 PRO
• An old clock DS3231
• New TouchScreen 3.5 from Hong Kong Feng Tai /bought with AliExpress (0x6814)

TEST WITHOUT ANY WELDING
I perform all tests by comparison between the 2 TouchScreen :
• MCUFRIEND n°Y11 (called Y11) : which BLINKS
• Honk Kong Feng Tai n°10 (called n°10) : which is OK with my Poka Yoke software

I followed exactly the proposal of connexion:
LCD_D0 >> 22
LCD_D1 >> 23
LCD_D2 >> 24
LCD_D3 >> 25
LCD_D4 >> 26
LCD_D5 >> 27
LCD_D6 >> 28
LCD_D7 >> 29

LCD_RD >> A0
LCD_WR >> A1
LCD_RS >> A2
LCD_CS >> A3
LCD_RST >> A4

LCD_GND >> GND
LCD_3V3 >> 3V3
LCD_5V >> 5V

1. WHITE SCREEN
I was able to correct that issue, because you already had explained to me previously to connect LCD-RST to RESET (and not to A4)

After that it is OK for n°10
The n°Y11 continues to blink

2. DATA BUS D22, D23 … D29 INSTEAD OF D2, D3 … D9
The connection is more logical, because it doesn’t content any INT pins !!!
… BUT the screen cannot communicate with MEGA (n°10 and n°Y11)

TouchScreen_Calibr_nativ displays:

BROKEN TOUCHSCREEN
ID = 0xD3D3
I don’t know how to continue …
Is it possible to change the pins to connect the databus ?

Thank you
Michel

  1. HX8357-D has ID = 0x0099

  2. RM68140 has ID = 0x6814

  3. The Red 0x6814 shield on my desk takes a massive current. The bottom of the screen is very warm to the touch.

  4. I do not approve of any pcb with empty SOIC-8 footprint and without LDO.

  5. I suspect that your 0x6814 has that style of pcb.

  6. LCD_ID_readreg should be different for 0x0099 and 0x6814

  7. XP 6 - XM 56 - YP 55 - YM 7 implies XM=A2, YP=A1. Since you have moved the data bus, XP=28, YM=29

  8. tft.readID() should read the ID correctly.

  9. Touchscreen should work ok when you specify the correct pins.

Seriously. You should run the Library examples. Report any problems. I know the sketches. I know the code that you are using. (obviously you would say what your Touch Calibration is)

I can run a sketch on a regular Mega2560 clone. i.e. A0-A4 2-9
Or I can run a sketch on my Mega2560 clone with "USE_MEGA_8BIT_PROTOSHIELD" i.e. A0-A4 22-29.

I can't help you with your custom sketch if I do not know your code or if I need some unusual hardware.
I have a DS3231 module. I do not have RFID. I could use a NRF24L01 if I have to.

David.

Hello David
Thank you very much for the time you spend with me 
Thank you for identification of the 2 circuits

I confirm the observations and the doubts you have; I continue the comparison:
• No 10 (works well) – ID 0x6814 /RM68140 >>> 450 mA /5V
• No Y11 (blinks with poka yoke software) – ID 0x0099 /HX8357-D >>> 300 mA /5V

I simplified the conditions of the test to 3 components:
• MEGA 2560 PRO
• TouchScreen 3.5” (connexion with simple wires)
• DS3231 (connexion I2C)
I didn’t assemble the other components (of the global poka yoke application)
The software doesn't work for rfid and nrf24l01
• Rfid MC522
• NRF24L01
• 5V supply from 24V

OLD CONFIGURATION: databus = D2, D3, D4, D5, D6, D7, D8, D9
The programs of the library work well :
LCD-ID-readreg : works … N°10 and N°Y11 (attached pdf)
diagnose_TFT_support :
o N° 10 : ID 0x6814 – mcufriend 2.9.9 – portrait 320x480
 Colors : OK
 Orientation : OK
o N° Y11 : ID 0x99
 Colors : NOT OK (“blue” is yellow, “green” is purple, “red” is blue, only “gray” is gray)
 Orientation : OK
TouchScreen_Calibr_native :
o N°10 : ID 0x6814
 XP 7 – XM A1 – YP A2 – YM 6
 L 264 – R 818 – T 260 – B 893
o N°Y11 : ID 0x0099
 XP 6 – XM A2 – YP A1 – YM 7
 L 886 – R 249 – T 925 – B 209
aspect_kbv :
o N°10 : ID 0x6814 – Orientation : OK – Inversion : OK
o N°Y11 : ID 0x99 - Orientation : OK - Inversion : NOT OK (inverted)
graphictest_kbv :
o N° 10 : ID 0x6814 – 0ms to start
 Grade : OK - scroll : OK – graphics : OK
 Colors : OK
o N° Y11 : ID 0x99 – 0ms to start
 Grade : OK - scroll : OK – graphics : OK
 Colors : NOT OK, as already said

NEW CONFIGURATION OF DATABUS = 22, 23, 24, 25, 26, 27, 28, 29
graphictest_kbv
o N° 10 : NOK
 ID 0xD3D3
 White screen …
o N° Y11 : NOK
 ID 0xD3D3
 White screen …
TouchScreen_Calibr_native
o N° 10 : NOK
 ID 0xD3D3
 BROKEN TOUCHSCREEN
 White screen …
o N° Y11 : NOK
 ID 0xD3D3
 BROKEN TOUCHSCREEN
 White screen …

POKA YOKE SOFTWARE
I am sorry, but the poka yoke software :
• Is very long : I wrote it during many years
• Contents a lot of comments : story of each sub-program
• Is completely written in French (mother tongue)

LCD-ID_readreg_n10_nY11.pdf (128 KB)

Poka-Yoke-v300-20190305.ino (179 KB)

  1. Inverted colours are quite normal. Different screen modules from different makes can have different characteristics.

  2. Just use tft.invertDisplay(1) to invert the colours back again.

  3. Both screens take more backlight current than I would like.

  4. Both pcb have similar component placement and traces.

  5. I do not like this pcb with no LDO regulator.

  6. your photo shows a DS3231 module with 4 wires.

  7. it is not possible for the DS3231 to sink lots of current (upset VCC and blink display)

  8. I have not got the energy to read 178kB of Poka-Yoke sketch.

  9. apart from the inverted colours, both screens work 100% with every MCUFRIEND_kbv library example.

David.

Hello David
Thank you for your message
I understand: the single problem we can detect in that way in the colour inversion for the N°Y11

It is why, I am very interested that you have a look to the poka yoke software …
That program needs a MEGA2560 or a MEGA2560PRO to be read and activated

"The sketch uses 80742 bytes (31%) of the program storage space. The maximum is 253952 bytes.
Global variables use 4241 bytes (51%) of dynamic memory, leaving 3951 bytes for local variables. The maximum is 8192 bytes. "

You just need: MEGA + TouchScreen to test the “BLINK”
Even without DS3231, we can detect that abnormality
The “blink” is not produce by the DS3231 itself, but it is produced by the calling of the clock

With N° Y11, when I remove the DS3231, the screen blinks once and then jump directly to the 2 page and remains white (see the second video I posted few days ago: 10/3/2019)
With N° 10, when I remove the DS3231, the screen just doesn’t display the time!!!

I am very interested that you look to that phenomenon by yourself; I feel that you would have an idea about what is wrong in my design
I believe to your previous diagnostic about the connection of databus, but I don’t know how to make it work (connection 22 to 29 is not recognised)

Hello
I performed a new test with a regular mega 2560
With exactly the same results...
Et
DATA BUS

  1. In the old config d2, d3, D4,... 2 pins are interrupt pins INT4 and INT5
    That could be the reason of resetting the TouchScreen when I ask the time to DS3231 via I2C
    ...

2.The MEGA doesn't recognize 22, 23, 24,...
I think we have to declare this change
I don't know how to declare these pins of PORT A as new data bus
...

I edited #20 to explain how to enable your SPECIAL custom wiring.

Everything should work 100% and much faster. You only need to change the XP, YM pins when you use the Touchscreen,

David.

Hello David,
Again, thank you for your help

I uncommented the 2 lines :

MCUFRIEND_kbv/ utility/mcufriend_shield.h
Line 1 …
//#define USE_SPECIAL //check for custom drivers

MCUFRIEND_kbv/ utility/mcufriend_special.h
Line 3 …
//#define USE_MEGA_8BIT_PROTOSHIELD

The SCREEN works well
But, the TOUCH doesn't works

I don't understand what I have to do to change XP and YM pins ...
Could you still help me ?
Thank you

I strongly recommend that you use the calibration sketch and copy-paste the results from the Serial Terminal. e.g.

const int XP=7,XM=A1,YP=A2,YM=6; //320x480 ID=0x6814
const int TS_LEFT=134,TS_RT=906,TS_TOP=114,TS_BOT=924;

This assumes that you are compiling for a specific screen.

The pins change for your custom wiring e.g:

const int XP=29,XM=A1,YP=A2,YM=28; //320x480 ID=0x6814
const int TS_LEFT=134,TS_RT=906,TS_TOP=114,TS_BOT=924;

You can't alter a const value.

You should run the examples with your custom wiring. Become familiar with how they work.

Your Pokey code would benefit with some tidying up. There are lots of duplicated sequences. Sit down and think about it. Could you write a single helper function that has a single sequence. Call with different arguments to implement your previous duplicated code.

I have not attempted to build your code. It is too long. It requires extra hardware and RFID.

David.

Hello David
Again thank you for your precious advises
I will do what you recommend next weekend
. Calibration and copy/paste serial
. Run the different example to understand how they run
. Start the cleaning of poka software... :confused:

Based on the ID 0x99, previously, you told me that my Touchscreen are HX8357-D but I didn't find the parameters of that driver in MCUFRIEND_kbv.cpp

Thank you, Michel

Hello David

… just a question of RIGOR …

You was absolutely RIGHT in your diagnostic

I thank you for the time and the advises you gave me during all the previous month, when I asked many questions about “INSTABILITY of MY POKA YOKE”

At the end, I decided to start the cleaning-up of my software …

· DOWLOAD the last version of Arduino 1.8.8

· CHOOSE strictly the libraries I needed and DOWNLOAD the latest version

· INCLUDE the exact libraries needed by the functions of the software

· DEFINE precisely each constant, and variable by subprogram

· ADJUST the format of each variable to the need (uint8_t, uint16_t, char, String, …)

· AVOID confusion between acronyms : Unfortunatly, I used “ts”

o struct ts t DS3231

o TouchScreen ts = TouchScreen(XP,YP,XM,YM)

· UNDERSTAND perfectly how works the functions used in a library

o tft.width() and tft.height() are general dimension of the screen

o I just needed width_fix=320 and height_fix=480

· INITIALIZATION of variables in SET-UP only (not in DEFINITION)

· LOOP : main structure based on calling the main subprogram

· WRITE comments and history in a separate file

o I reduced the software from 5031 lines before to 3747 lines after

· GROUP the subprograms by function (SD card, clock DS3231, …)

· KEEP in comments only the main revisions (not the history)

· GIVE the maximum of readability at each line and each subprogram

I realized systematic and comparative tests:

· I splitted the program in 10 chapters of 5 subprogram per chapter

· I re-wrote the “include/define/set-up/loop” to make the chapter work autonomously

· I tested everytime on the both electronic configurations:

o old TouchScreen 0x6814 (RM68140) which works

o new TouchScreen 0x0099 (HX8357-D, ili 9488) which blinks

Finally, I didn’t find THE root cause, but I corrected a multitude of small mistakes by application of the principles written on the top. I didn’t manage to isolate the dust which stops the program.

Best Regards
Thank you for your patience and your time

ZIP up the "tidy" project and attach it. I will have a look at it.

I can't think of any reason for one controller to behave differently. The HX8357-D behaves "better" than RM68140.

David.

Hello David
At the end, I didn't find a single reason (a single cause) of that instability but a multitude of small errors or mistakes or imprecisions. I wrote that program during 3 years!

Now the tidy program works well with both the 2 controllers : RM68140 and HX8357-D
I keep the old program which works well with RM68140, but blinks every second with HX8357-D

I tried to reproduce the defect to isolate the root cause of the instability, but I didn't manage it, I didn't remember all the "small" corrections that I had done

I am very happy to be able to make works the application with HX8357D to continue the project :slight_smile:

I will send you the 2 versions of the program this weekend with my personnal computer from home
... I am sorry, but I didn't translate it in english

Hello
I try to zip the program with my smartphone...
It contents :
. Old program 2018
. New tidy program 2019 : PYv30x99
. SPY2019, ECRANCAL, POKA YOKE : on SD card
Best Regards

PokaYoke-instability.zip (51.4 KB)

@Michel,

I attempted to build your sketch.
It needs a "ds3231.h" library.

I can only find a ds3231fs library with the Library Manager. This does not have the correct symbols.

I strongly advise people to use "official" libraries that are supported by the Library Manager.

David.

Hello David
Again, I try to send you the library ds3231 with my smartphone
I use that library since about 2 years
I will follow your recommendation and find the official version
Thank you for all your help
Michel

ds3231.zip (10.7 KB)

david_prentice:
Ask them exactly what I asked you. Post a link to the actual item in their invoice from mcufriend.com

They will obviously keep records of items that they purchased for your assembly job.

Personally, I would never buy the current design of mcufriend pcb i.e. with empty SOIC-8 footprint and without AMS1117-3.3

As I said earlier. Your Mega2560 Pro might have a stronger 3.3V regulator.

David.

Hi David,

Just seen your earlier comment in this post, though it may also be covered somewhere in the 190 pages of your main tft thead, so please forgive me if it is.

I recently purchased a MCUfrient 3.5" TFT and to my surprise it seemed to work fine from all but one of your code Examples.

It did not give any rotation or touch problems as seen in some other posts, so thought your current code and perhaps this later board had overcome such problems.

The only problem its giving is that the BMPs display correctly in terms of size but the colours are just washed out, like the example below.

From your comments in this post about the 5V and 3v3 supply current thought of supplying them direct from a bench supply, but first thought it best to ask if you think this is the cause of the colour problem or something else ?

This is the link I purchased from, and its detected as a ili9486 v 2.9.8.
https://www.ebay.co.uk/itm/3-5-inch-TFT-LCD-Touch-Screen-Display-Module-480X320-for-Arduino-Mega-2560-Board/163631204008?epid=3034455042&_trkparms=ispr%3D1&hash=item26192e06a8:g:OWcAAOSwkCdcpHBk&enc=AQAEAAACQBPxNw%2BVj6nta7CKEs3N0qUtsyk958lb0nakFdQ9FW5FchoYzmFXMMs97QRLU5ftpymn0f45SMU4ABq0J1996dbHipBCjCxpF41oDTWs%2BdHuWSGwvZVYpX8xN39%2FQe9URlAkSPsjxfWxeeZd7lpd92wfxaz2ZpJX0Ad1wDvxqiCbv40%2BcOcswVOnE38sdtcUVvzRx%2FwZPodOM%2FRB570J5F4TumMMpXO%2FnKQ1I0t%2BcE%2FRzWwCyyp5xBGKTORgg%2FQzxjVaXIKxiyaygpqgx82AZQfqh89H%2FwS%2FWfJgy88aKMPqxp6yjGpZJolsfWPgMuJEMEbAVwY%2Bn84NXErZUKKCw8HoSqOFUsp6ZWrqBuHtUvXN9qZYHYx5%2BSryrNJaaTeyDqPf38t0f%2FEE7XBOORbuSu608BxJCAzCOnfmNbsuV2WwqorYKqHOVuOCZUHaEtuCmQ9c2f%2FNpNFC2BW%2F2RJESIyY%2BZ5Fjuzlv7c1h7f%2BYCC%2Bg66T6dlyg%2Bk6PdvS2BVFZ%2FoyFYXgA535k8qq5LO3wOrRqEqLAUXlL%2Fe6VI00xeUNO7VRYiO%2BLptnxLB1BbgAP7vig8Id02B%2BDWmLxdRlr2E3t4RDHCf0eJfwMuEOe8Xzwi8sPKzUI597W3lOpFzJ45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However the PCB received is different to the link given, actual picture attached.

Thanks

000071.jpg

Your pcb has R1. The link does not.
Otherwise you have the "same" components.

First check the current. Or at least feel whether the screen gets warm.

I would not trust your BMP image. Post the BMP files you have a problem with. (put BMP files into a single ZIP file and attach the ZIP)
What do the regular example programs look like? Are the colours vibrant?

Copy-paste the readreg report to your message.

David.

david_prentice:
Your pcb has R1. The link does not.
Otherwise you have the "same" components.

First check the current. Or at least feel whether the screen gets warm.

I would not trust your BMP image. Post the BMP files you have a problem with. (put BMP files into a single ZIP file and attach the ZIP)
What do the regular example programs look like? Are the colours vibrant?

Copy-paste the readreg report to your message.

David.

Hi David,

Thanks for your quick reply.

Attached is the ReadReg report along with the zipped bitmaps including the Tiger one I use on the smaller ili9341 2.8" screen ok.

With the 3.5" screen running for 10 mins it feels just a couple of degrees warmer than ambient (21c).

Normal screen work does not seem Vibrant as I get on the smaller 9341 screen (adafruitgfx etc) but still better than the bitmaps. - pics attached

I have run the screen on two different Unos, one a DIP and one a SMD

I breadboarded the screen and got the images displaying and started current measurents.

The 3v3 line fluctuated between 30 to 70ma during program load or Uno Reset, then 0 ma while displaying.

Then measured the 5V line - nothing at all current wise, but the voltage measures 5.0v ??

Measured the two 0v lines and that showed 114ma being drawn ??

Further tests show all Digital pins running at about 7 ma , so seems it drawing the current from them ??

Wondering if the 5v line has failed and its trying , but failing to draw the full current it needs from the i/o pins to give full colour ?

Edit - forgot to say the TFT pins , 3v to 0v gives 53k ohms, the 5v to 0v - infinity

adafruit_products_adabot.zip (539 KB)

000073.jpg

000074.jpg

000075.jpg