LCD display with ILI9341 driver on Arduino

Hi Ironic,
read my message here :
http://forum.arduino.cc/index.php?topic=241891.msg1742065#msg1742065

Work perfectly with adafruit library and without any 4050, only 10 resistors.
Jacques

??? ironic ?
5 lines must be converted from 5V to 3,3V, so a simple "voltage divider" is sufficient.
5 lines, x 2 resistors (voltage divider) = 10 resistors :smiley:

nid69ita:
??? ironic ?
5 lines must be converted from 5V to 3,3V, so a simple "voltage divider" is sufficient.
5 lines, x 2 resistors (voltage divider) = 10 resistors :smiley:

Or, simply use a 3.3V 8MHz Pro Mini:

Or, build a flat-duino at 8MHz:
http://www.hackster.io/rayburne/flat-duino

Or, use a 3.3V 8MHz Pro Micro:

Or, try your hand at running a 16MHz Pro Mini at 3.3V knowing this is outside the published specifications.

Ray

Ironic62:
Hi all !

3 days i read, i read and i read.
3 days i try, i try and i try.

I do Many things but i am disappointed

I have a ILI9341 LCD TFT, the same as most people here.
I have a CD4050.
i have a 3.3v power supply.
And i have un Arduino uno and a nano (328).

Arduino -> CD4050 -> ILI9341
sclk= 13
miso = 12 (direct arduino TFT)
mosi = 11
cd= 6
cs = 5
reset = 4

I Power LCD and CD4050 with 3.3v from power supply (grounded to arduino GND).
I Use a cap near TFT and CD4050.

All is ok, i can run libraries (ILI9341/SeeedTFTv2/AdaFruit9341/UTFT/Ucglib/MultiLCD).

But : I can't run Fast SPI (HW SPI) on AdaFruit, UTFT and Ugclib.

MultiLCD is probably the most speed, it run HW SPI (i think) but it's very limited functions.
ILI9341/SeeedTFTv2 run fast but no landscape possibility.

  • Adafruit is very slow with :
    Adafruit_ILI9341 tft = Adafruit_ILI9341(5, 6, 11, 13, 4, 12); : WORKS
    Adafruit_ILI9341 tft = Adafruit_ILI9341(5, 6, 4); WHITE SCREEN

  • Ucglib is very slow too :
    Ucglib_ILI9341_18x240x320_SWSPI ucg(/sclk=/ 13, /data=/ 11, /cd=/ 6 , /cs=/ 5, /reset=/ 4); WORKS
    Ucglib_ILI9341_18x240x320_HWSPI ucg(/cd=/ 6 , /cs=/ 5, /reset=/ 4); WHITE SCREEN

  • UTFT is SW SPI Only (i Think).

ILI9341/SeeedTFTv2/MultiLCD are probably *10 faster.

SD Card isn't wired.
I tried it and it works (so HW SPI WORKS ?) Show directoty/read/write/infos... from serial monitor
BUT it doesnt' work if i try to use TFT together (SW and HW mode)

I Tried with Uno and Nano, same result.
CD5040 isn't bad, FAST SPI works with some libraries.

I read someone have the same issue in this topic (i think).
I don't know where is the problem.
Anyone have an idea ?
(Sorry for my english).

Seems to me you only have the software SPI working?
I know it may sound a bit obvious but when you have

Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 6 , /*cs=*/ 5, /*reset=*/ 4); [b]WHITE SCREEN[/b]

you also have to connect pin 13 to SCK and pin 11 to MOSI on the display. In addition to CD, CS and RST. So this gives you 5 wires for the LCD, plus Power, Backlight (trough a 10Ohm resistor @ 3V3) and GND.

Just a note: Using the suggestions somewhere on this post i got an error initializing the card (something along the lines of wrong display, looking for ILI 9141 found 0x0000). This is because some displays don't report the serial number. Avoid using such library

I personally tried a bunch of displays yesterday using both Adafruit and UCGLIB and they both worked, so i advise you to try again. Perhaps power your arduino from 3V3 to avoid the CD4050 just until you find a combination that works and then put the CD4050 back and fire it up with 5V.

I find UCGLIB slower and more memory intensive than the Adafruit librar, but both work. I only use the HW SPI.

Thanks all for answers.

I try to replace CD4050 by resistors like this:

Everything works as with CD4050 but now :
- Ucglib works with HWSPI (10 times faster).

  • Adafruit_ILI9341 doesn't work, White screen again.
  • UTFT always slow (SWSPI).

Very strange, Ucglib works and not Adafruit9341 !!
I would like to use Adafruit ou Ucglib so now i can.

But i want to know WHY Hardware SPI doesn't work with Adadruit (last release).

  • I think CD4050 was probably bad but.... not sure.
  • Wires are good, 3 libraries work in HW SPI very fast, no bug.
  • 5V Arduino is USB power, 3.3V is LM317+caps

Ucglib works so i will try it.

Hi Ironic62,
did you modify some #define values to match your wiring in Adafruit demo code ?

my modifications :

#define _cs 5 // 10
#define _dc 6 // 9
#define _rst 4 // 8

Jacques

Hi

I think Adafruit works like :

To use Software SPI, set :
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

For me is :
Adafruit_ILI9341 tft = Adafruit_ILI9341(5, 6, 11, 13, 4, 12);

  • This works but very slow.

To use Hardware SPI, set :
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

#define TFT_DC 6
#define TFT_CS 5
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); or Adafruit_ILI9341 tft = Adafruit_ILI9341(5,6);

  • This doesn't work, i get a white screen.

Since few hours i use Ucglib (HWSPI )and i like this lib.

I want to know who use what lib and why ?

UTFT is ONLY Sorfware SPI, so very slow, is it true ?

Hi
i used graphictest.ino, democ ode in Adafruit library

first line of the code i use :

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9340.h"

#define _sclk 13
#define _miso 12
#define _mosi 11
#define _cs 5 //10
#define _dc 6 //9
#define _rst 4 //8

Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _rst);  // Use hardware SPI

fast and work perfectly
Jacques

I open "graphicstest.ino" from Adafruit_9341 and i see :

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

// For the Adafruit shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// If using the breakout, change pins as desired
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

No "TFT_RST" ... strange...

I paste your code in my sketch but i replace ILI9340 by ILI9341

AND...

IT WORKS !!! as fast as others HWSPI Libraries.

Thanks a lot, why i don't try this before :0

Nice to have Adafruit library running fast now.

In most cases reset is a waste of a pin. Just wire it to 3.3V or to the arduino reset with a resistor.
If the display has an internal pull up you can leave it unconected.

Just a last question.

For driving this screen, 6 wires are needed.

  • sclk - miso - mosi - cs - dc - rst

[sclk] is needed and must be pin 13 for Hardware SPI.
[miso] is unneeded and can be unwire disconnect. (communication TFT => Arduino)
[mosi] is needed and must be pin 11 for Hardware SPI.

```cs
**[/b] is needed and can be any other output pin.
[dc] is needed and can be any other output pin.
[rst] is unneeded and can be wired to 3.3v or arduino reset with a resistor.

So Can i use Hardware SPI and use pin 12 for [cs] or [dc].

I try it but not working.**
```

Ironic62:
Just a last question.

For driving this screen, 6 wires are needed.

  • sclk - miso - mosi - cs - dc - rst

[sclk] is needed and must be pin 13 for Hardware SPI.
[miso] is unneeded and can be unwire disconnect. (communication TFT => Arduino)
[mosi] is needed and must be pin 11 for Hardware SPI.

```cs
**[/b] is needed and can be any other output pin.
[dc] is needed and can be any other output pin.
[rst] is unneeded and can be wired to 3.3v or arduino reset with a resistor.

So Can i use Hardware SPI and use pin 12 for [cs] or [dc].

I try it but not working.

[/quote]

No. You cant define two functions to a single PIN. Either you set it to HWSPI or to Digital Output.
Assuming you are not using the TFT you could ground the CS Pin to save a digital I/O. You have to change the library tough, otherwise it will give you an error if you dont define it.**

```

No. You cant define two functions to a single PIN. Either you set it to HWSPI or to Digital Output.

Correct, it is a hardware restriction of the ATMega controller.

Assuming you are not using the TFT you could ground the CS Pin to save a digital I/O. You have to change the library tough, otherwise it will give you an error if you dont define it.

The falling edge of the CS signal will also reset the communication unit on the TFT controller. Without CS it might get out of sync more easier. In fact it might not work at all.

Oliver

olikraus:
The falling edge of the CS signal will also reset the communication unit on the TFT controller. Without CS it might get out of sync more easier.

For that to happen the lines would need to be very noisy and at a very high SPI clock frequency - Possible, but very unlikelly.

olikraus:
In fact it might not work at all.
Oliver

I can assure you it does, as long as the SPI bus is not shared (for example with an SD Card).

Just a pix to show how I am now deploying these inexpensive 2.2" displays with the very inexpensive Pro Mini 328.

Mounting to the back of the TFT display is accomplished with double-sided foam tape from arts/crafts store.
http://6t6t.com/p/harbor-freight-tools-34-x-8-12-ft-double-sided-mounting-tape/B006ZBBLL0
or similar.

Wiring was accomplished using eBay surplus wire-wrap silver wire which is ideal. Depending on environment, you may wish to solder the wirewrap on the header but I have not found this to be needed in normal indoor environments if the wirewrap is accomplished with a proper wirewrap tool.

Ray

Thats quite similar to what i have been doing (Same setup) only I am using the mini straight at 3V3 and as a display controller (Receives values from the serial port and prints them out, adds images from the SD where required, and a few buttons may be added too.

Just as a side note:
I had issues with some SD Cards running at full speed and have found the resistors being the culprits. Essentially for 3V3 operation they may be shorted. For 5V they should read 102 (1K). I have found some displays to come with 103 (10K)

casemod:
Thats quite similar to what i have been doing (Same setup) only I am using the mini straight at 3V3 and as a display controller (Receives values from the serial port and prints them out, adds images from the SD where required, and a few buttons may be added too.

Just as a side note:
I had issues with some SD Cards running at full speed and have found the resistors being the culprits. Essentially for 3V3 operation they may be shorted. For 5V they should read 102 (1K). I have found some displays to come with 103 (10K)

I am not a fan of resistors for voltage level translation... Mainly because it is an inexact art... Every interface must be tested indepently and even some pins may differ in value. It is better IMO to do the engineering correctly.

I run the mini & display both at 3.3V but the fine print must always say that the 328 is out-of-spec at this clock frequency... I have never had an issue, but my projects are "in doors" and climate controlled.

Ray

casemod:
Thats quite similar to what i have been doing (Same setup) only I am using the mini straight at 3V3 and as a display controller (Receives values from the serial port and prints them out, adds images from the SD where required, and a few buttons may be added too.

Casemode, do you mind sharing your connection diagram and sketch that you use for the above ?

mrburnette:
I am not a fan of resistors for voltage level translation... Mainly because it is an inexact art... Every interface must be tested indepently and even some pins may differ in value. It is better IMO to do the engineering correctly.

Completelly agree! It is a bad engineering practice, speacially for an SD Card, since different cards will behave differently.
First time I realized this was on a ST7781 display. It had level shifters for the TFT, but the SD worked with resistors onboard. This was not apparent at a first glance. Only when measuring signals with the scope and tracing down the circuit I realized there was no buffer for the SD, only 3 10K resistors.

tolisn63:
Casemode, do you mind sharing your connection diagram and sketch that you use for the above ?

Cant exactly give you my code, but i can tell you how you do it.

For the images, I load small versions (128x128max) at specific positions on the display (tft.setCursor 50, 128). I create a variable that only loads it once, so the screen is not continuasly refreshed (this eats up time) and this is done only every so often (2-5s), unless the alarm is a very high priority.

Text variables are updated at 0.5 or 1S intervals
You can use the TextFinder function to receive data from the serial port.
For example

Send data in the format

128, 512, 001, 1024

... and create a 4 position (or how many more you need) array to receive this data. Then you need to specity on the display where to print this data. This is basically a serial terminal. Some data may not be printed at all, for example may be used to load a warning image on the display if a value falls bellow or above a certain threshold.

Basically you just print statments trough serial on the master uController, which wont take much time.
The second microcontroller can spend all the time processing fancy graphics and data for the display without slowing the program down. Any data that can not be printed may be skipped (or log into the SD card), in comparison to slowing down the whole program on the master uC.

I guess this could also be archieved trough I2C, releasing the serial port to something else.