Go Down

Topic: LCD display with ILI9341 driver on Arduino (Read 65444 times) previous topic - next topic

micol

#180
Aug 16, 2014, 07:26 am Last Edit: Aug 16, 2014, 08:27 am by micol Reason: 1
Hello Casemod.

I followed all links. I have a raw picture made with ImageConverter 565. I installed UTFT library, too big for ProMini so I now use my MEGA2560. The program SDImageViewer seems to have some bugs so I begin with a smaller program : UTFT_TextRotation_Demo.

I wander about pins for the prototype UTFT(Byte model, RD, WR, CS, RST, SER=0)  whose name are not familiar for me.
I keep my old wirings so WR=51, CS=53, RST=48, but what are RS and SER ?
Now, I'm about trying one after each other "ILI_9341_S4P" and "ILI_9341_S5P" for Byte model and 49 or 52 as RS.

I read all pdf without finding which Henning Karlsen's pin names correspond to SPI current pin names.

*** Micol *** resolutly politically NOT correct

micol

To use 5 V ProMini, I followed what MrBurnett said on another page : I did as if it were a 3.3 Volts.

I had like to show you the 2 ProMini working together, but amongst all my SD-cards, one only works well with ILI9340 card reader. Other card are sometimes recognised and their files listed, but pictures are never shown.




*** Micol *** resolutly politically NOT correct

casemod


Amongst all my SD-cards, one only works well with ILI9340 card reader. Other card are sometimes recognised and their files listed, but pictures are never shown.


Now that you are running at 3.3V short the three resistors for the SD card under the display.
In most cases the SD card works correctly thereafter.

micol

Hello,

I shunt resistors on the card-reader and it does not works, even with the "good" Sd-card.

Then, I tried and work with UTFT and Mega2560.
I spend much time and finaly find the declaration to write in every example :

UTFT myGLCD(ILI9341_S5P, 51, 52, 53, 48, 49);

Now, I can execute all the demo given in the library and I have to write my own programms.

*** Micol *** resolutly politically NOT correct

micol

#184
Aug 23, 2014, 11:31 am Last Edit: Aug 23, 2014, 02:21 pm by micol Reason: 1
Hello,

I tried several ILI9340 libraries with ProMini 3.3 volts.

For text or geometrical drawing, all are OK.
When reading picture from SD-card, it is different :

Adafruit_ILI9340 works sometimes well, and sometimes does not find the card, or find it not formatted, or find not any file on it.
It seems to me that the card-reader behind ILI9340/41 is not very reliable.

UCGlib : has no fonction for reading SD-card.

UTFT : works only for pictures of 1 KO max, not for 320x240 whose size is 698 Ko when converted into file.C

On post 177, Casemod gave a link to a nice slideshow. I studied it and discovered another library. But this library is not for ILI9340 but for ILI9325. (or ST7781 or SD1963).

EDIT> a glance at ebay tells me that these TFT have 40 pins. They are not SPI. It is why they are so fast.

*** Micol *** resolutly politically NOT correct

amp625

Just to kind of clarify some unknowns a little back in the post i'd like to share my problems/solutions.

I wanted to get SPI hardware working on the UNO to obviously ILI9341.  I used the adafruit library the whole time.  However, I could only get software SPI to work.  I was using a CD4050 to step the 5v signal from the digital pins to 3.3 for the LCD.   The problem with the 4050 is that it's a buffer and not a driver. The current coming out of it is too damn small for the inputs of the  ILI9341.  I'm not certain why the 4050 let software work but the hardware mode.  However, when i went to using voltage dividers with resistors I tried two different sets of values.  The first set of values were close to 100k.  So i got the right voltage but in the micros for current.  With this setup software mode DID work, but still not hardware.  then i went way down to a reasonable current, and finally hardware worked.

So if you are having problems getting hardware to work, I think the signal current has a significant part to play.

casemod

#186
Aug 28, 2014, 02:44 pm Last Edit: Aug 28, 2014, 02:47 pm by casemod Reason: 1

Just to kind of clarify some unknowns a little back in the post i'd like to share my problems/solutions.

I wanted to get SPI hardware working on the UNO to obviously ILI9341.  I used the adafruit library the whole time.  However, I could only get software SPI to work.  I was using a CD4050 to step the 5v signal from the digital pins to 3.3 for the LCD.   The problem with the 4050 is that it's a buffer and not a driver. The current coming out of it is too damn small for the inputs of the  ILI9341.  I'm not certain why the 4050 let software work but the hardware mode.  However, when i went to using voltage dividers with resistors I tried two different sets of values.  The first set of values were close to 100k.  So i got the right voltage but in the micros for current.  With this setup software mode DID work, but still not hardware.  then i went way down to a reasonable current, and finally hardware worked.

So if you are having problems getting hardware to work, I think the signal current has a significant part to play.


Good point in describing!
This is why I tell people to attach a scope and read the waveform before asking impossible questions.
If they cant afford a second hand unit from ebay then this is the wrong hobby  :smiley-mr-green:


acharis

Maybe my information helps somebody. I tested it on UNO and MEGA.

Display fully works if it is alone connected to the arduino with CD4050 or 4k7 resistors with these libraries:
UTFT
Multi LCD
TFTv2
But if I connected more modules to the arduino (BT, 433 MHz module etc..) it stops working, only with UTFT works fine.

SD card sometimes worked, sometimes not. If it was connected alone without any other modules, there was no problem. If I connected the display, it stops working. But if I turned off the backlight, it was woking always, but as I said, only if no other module was connected to the arduino.

So I think that there is design problem on the display board and is dependent on very clean signals or on very stable power.  But maybe it is problem only of mine unit.

casemod


Maybe my information helps somebody. I tested it on UNO and MEGA.

Display fully works if it is alone connected to the arduino with CD4050 or 4k7 resistors with these libraries:
UTFT
Multi LCD
TFTv2
But if I connected more modules to the arduino (BT, 433 MHz module etc..) it stops working, only with UTFT works fine.

SD card sometimes worked, sometimes not. If it was connected alone without any other modules, there was no problem. If I connected the display, it stops working. But if I turned off the backlight, it was woking always, but as I said, only if no other module was connected to the arduino.

So I think that there is design problem on the display board and is dependent on very clean signals or on very stable power.  But maybe it is problem only of mine unit.


As above, you are not providing a solution.
Clearly some modules are corrupting the signal. Why do you think the manufacturer is to blame? Can you show us a signal going to the TFT to back up your statments? What SPI speed are you using? The UTFT may actually be slower and thats why you get it working.

I have a video shopwing how to dramatically boost UTFT speeds for an SSD1289, that should give you an idea that the library itself is not very efficient. Even with SPI Using digitalWrite functions for the CS line.... is Slow!

I think this kind of posts only confuse people more. If you find a solution post it, dont just say: "my observations led me to believe it does not work, but I dont know why. Probably the display board is to blame as it requires very clean signals".

There are many alternatives to the CD4050. 75LVC245 is an example, HC245 is used in comertial modules, and adafruit sells a TXB0108 breakout board which is bi-directional and avoids issues with wiring od SD cards

acharis



Maybe my information helps somebody. I tested it on UNO and MEGA.

Display fully works if it is alone connected to the arduino with CD4050 or 4k7 resistors with these libraries:
UTFT
Multi LCD
TFTv2
But if I connected more modules to the arduino (BT, 433 MHz module etc..) it stops working, only with UTFT works fine.

SD card sometimes worked, sometimes not. If it was connected alone without any other modules, there was no problem. If I connected the display, it stops working. But if I turned off the backlight, it was woking always, but as I said, only if no other module was connected to the arduino.

So I think that there is design problem on the display board and is dependent on very clean signals or on very stable power.  But maybe it is problem only of mine unit.


As above, you are not providing a solution.
Clearly some modules are corrupting the signal. Why do you think the manufacturer is to blame? Can you show us a signal going to the TFT to back up your statments? What SPI speed are you using? The UTFT may actually be slower and thats why you get it working.

I have a video shopwing how to dramatically boost UTFT speeds for an SSD1289, that should give you an idea that the library itself is not very efficient. Even with SPI Using digitalWrite functions for the CS line.... is Slow!

I think this kind of posts only confuse people more. If you find a solution post it, dont just say: "my observations led me to believe it does not work, but I dont know why. Probably the display board is to blame as it requires very clean signals".

There are many alternatives to the CD4050. 75LVC245 is an example, HC245 is used in comertial modules, and adafruit sells a TXB0108 breakout board which is bi-directional and avoids issues with wiring od SD cards


You are right, this is no final solution. But it is very strange, that if I connect other modules, for example BT module HC-05 to the RX, TX pins and power, the example codes provided by TFTv2 and multiLCD libraries stops working and UTFT no. The module is only wire connected, with no code for it. So therefore I think that "mine cheap chinese copy"  (and maybe others too) has some HW problems. BTW I have too another chinese copy of the other LCD shield and there is no wire connection to the CS pin of SD card and shield was selling with library for old arduino version (working on 0.8). Seller send me step by step 5 new libraries, saying directly from manufacturer, but none was good. So I think that someone from Chineses comrades makes mystake. And I know, that UTFT is very slow, because multiLCD is based on UTFT and one of the objectives was speed it up.
P.S. If I have time, I will try connect oscilloscope and find out, If I am right or no.

casemod

I never received any faulty screen from china.
In my experience most of the problems are related to the fact that the manufacturer just trows whatever display they can get a best deal. mcufriend.com are number one doing that! You get a screen from them today and I can guarantee you next month you'll get a different controller and the seller has has no software or even knows about this change.

Add to this that some sellers get more stock than others so you are likely to find several sellers all selling different versions!

Then, there are software issues.
I had a project that has some strange bug. I could not find the problem! It was actually a TFT driver that was causing the issue!

I like to advise people to plug the arduino at 3.3V and go from there. That clears any hardware issues right away. Working with a buffer on a breadboard and assuming poor decoupling is away from ideal and only makes matters worse for beginners.

Here is a good example of a 3.3/5V selectable arduino mini
http://www.ebay.co.uk/itm/230795578198?_trksid=p2059210.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT although this can be easily made on any arduino board.

Not wishing to do so the other option is to get a REAL buffer from adafruit or whatever. Anyone who values their time will soon realize paying $10 or $15 for a proper buffer will save more than enough hassle in the long term.

Anything else is not even worth to bother with. Its the typical: it works for me, but its likely not to work for you approach.

And after we have all this things sorted we can start worrying about software issues, which in my opinion are much less severe than hardware issues. I can replicate x problem using a 'y' IDE version with a 'z' library running on a 'n' operating system, but I can assure you I wont be able to replicate anyone's hardware problem.

casemod

#191
Sep 25, 2014, 05:56 pm Last Edit: Oct 30, 2014, 06:29 pm by casemod
To make it easier on the folks here I modified the adafruit library.
The result is not as drastic as the parallel displays, but I managed to score a 2.40x speed increase.

The pins are defaulted to the hardware SPI.
9 and 10 are DC and CS. 13 is SCLK and 11 is MOSI. Simple

THE RESET PIN SHOULD BE ATTACHED TO 3.3V OR VCC TROUGH A 10K PULL-UP

The SD card library can be used as usual, with the default pinouts.

https://www.youtube.com/watch?v=9RIKzXANbOY

Modified Library:

Code: [Select]

ILI9341 Test!
Display Power Mode: 0x0
MADCTL Mode: 0x0
Pixel Format: 0x0
Image Format: 0x0
Self Diagnostic: 0x0
Benchmark                Time (microseconds)
Screen fill              1522152
Text                     121600
Lines                    921592
Horiz/Vert Lines         126996
Rectangles (outline)     81808
Rectangles (filled)      3160352
Circles (filled)         501916
Circles (outline)        396440
Triangles (outline)      293484
Triangles (filled)       1163048
Rounded rects (outline)  183788
Rounded rects (filled)   3473156
Done!



Sketch uses 19,358 bytes (60%) of program storage space.
Global variables use 596 bytes (29%) of dynamic memory.


Default Library:

Code: [Select]

ILI9341 Test!
Display Power Mode: 0x0
MADCTL Mode: 0x0
Pixel Format: 0x0
Image Format: 0x0
Self Diagnostic: 0x0
Benchmark                Time (microseconds) Performance increase
Screen fill              2561344 1.68x
Text                     319432 2.62x
Lines                    3118828 3.38x
Horiz/Vert Lines         222976 1.75x
Rectangles (outline)     148504 1.81x
Rectangles (filled)      5319692 1.68x
Circles (filled)         1168236 2.32x
Circles (outline)        1357636 3.42x
Triangles (outline)      990332 3.74x
Triangles (filled)       2083636 1.79x
Rounded rects (outline)  511700 2.78x
Rounded rects (filled)   5964712 1.71x

AVERAGE 2.40x faster
Done!


Sketch uses 19,008 bytes (58%) of program storage space.
Global variables use 596 bytes (29%) of dynamic memory.


Loading a BMP file from SD takes about the same time. About 200ms quicker.

The current library only works with arduino UNO, Mini and Nano.
The previous version, posted in May works with the mega. For the Due there is an improved version using DMA.

mrburnette

Quote
The result is not as drastic as the parallel displays, but I managed to score a 2.40x speed increase.


Wow!  Nice improvement.  The for the effort.

Ray

TFTLCDCyg

Amazing results Casemod. Thxs.

My personal ring: Due + HY32D + 2.2 TFT SPI
library modified: Adafruit_ILI9340 for arduino Due

Adafruit_ILI9340.cpp without changes

Code: [Select]
#ifdef __AVR__
   SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!)
#endif
#if defined(__SAM3X8E__)
   SPI.setClockDivider(11); // 85MHz / 11 = 7.6 MHz (full! speed!)



Adafruit_ILI9340.cpp modified for Arduino Due  (amazing!)

Code: [Select]
#ifdef __AVR__
   SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!)
#endif
#if defined(__SAM3X8E__)
   SPI.setClockDivider(3); // 85MHz / 3 = 23.33 MHz (full! speed!)



PD: amazing TFT Casemod, congratulatios.  Wow 2.4" SPI with touch IC!!!  ;)  

NikWing

Hey all :)

I want to make some kind of remote control and I want to use one of these tfts
I don't have any breadboard and such, so I want to make a PCB.
I've read this and other threads, but I don't know if what I've planned will work out, maybe you can tell me if there's any problem I can fix before I order the PCBs.

I want to use a mega328 along with the tft. the tft needs a voltage shifter, I want to use the txb0108.
also, I want to use a nrf24l01p-pa, which is also connected to the SPI
then I might want to use a rotary encoder for input.

my questions are:
the nrf24l01 is connected like this:
D12/MISO
D11/MOSI
D13/SCK
D9(CE)
D10(CSN)
and D2 for IRQ, but I think I can disconnect this one, I never needed the IRQ pin yet

I have to connect the tft using D11-D13. But from what I've seen so far, I also need D9 and D10.
It's correct that I could use D7 and D8 instead of D9 and D10 (since these ports are also in use)?
It's correct that I just have to put the txb0108 between tft and mega328? (of course I have to use the correct sides of the txb)

Doing this allows me to use hardware SPI and I won't run into problems since the NRF is also using the SPI?

Backlight dimming isn't important, so I just connect the LED pin to 5V using a resistor?
(I ask about 5V because I want to use 2 3V3 LDOs, one for the NRF and one for the tft, but draw around  100mA and the LDO can achieve 150 mA. I'm not sure about the current the tft draws, I read about 100mA but I don't know if that includes the backlight, though I would think so.

that's kinda all that troubles me at the moment.
I don't need the SD-Card reader.

Using a rotary encoder probably won't affect anything, but do you know if there's a menu lib that makes selecting submenus easily and also makes entering values easy? For example, I want to change the channel of the NRF transmitter. I would move to the submenu and select it, after that rotating the rotEnc increases/decreases the value on display, pressing the button (or any other button) stores the value I entered.
I have never worked with a graphic menu like that before, but is there any lib that helps?

Thanks so much for a quick feedback! :)
Nik

Go Up