Translate

Saturday, September 19, 2015

How to use the TFT display 2.2" QVGA with Arduino, Part 1/2

Arduino applications with ILI9341 library (Part 1/2)

By Giovanni Carrera 
Introduction
The main purpose of this project is to build a system based on chip ATMEGA328P, Arduino compatible, and interface it with a 2.2" QVGA TFT display using the library ILI9341. As an alternative to the self-build system you can use an Arduino Pro 3.3 V/ 8 MHz board or similar.
This system works well and can be very useful for many applications, as data-loggers, graphic terminal, etc. A great advantage of this system is to operate at 3.3 V with a modest power (180 mW). It is very suitable to be powered by a lithium 3.6V rechargeable battery. The regulator adopted still works well with a typical drop-out of about 50mV at low currents.
The display
After buying a TFT graphic display for few euros I decided to use it with Arduino. As often happens, the device was not at all documented by the seller neither by the manufacturer. However, the most salient features were screen-printed on the board. The graphics resolution was very good, QVGA means ¼ VGA, i.e. half of the pixels on each side, then 240x320 points to 64K or 256K colors. The interface used is the SPI. On the back of the card it is also a connector for SD card, very suitable to load images or save data. After searching on various forums and sellers in the internet, not without some difficulty, I were able to locate the object, finding a very synthetic scheme, a data sheet of the display and its controller  ILI9341 of Ilitek. By forum came out the link that allowed to download the library Seeed ILI9341 2.2 TFT + SD by Albert Miao, Loovee and Visweswara (https://github.com/gmtii/ili9341-arduino). The next photo shows the look of the TFT display used.
  
The first thing to do was to find out the power supply module, indicated by the abbreviation Vcc. I had to supply the module to 5 or 3.3V? Not even the scheme was to help. On it was indicated only the output voltage of the regulator: 3V, typical supply voltage of the display and the controller, as is apparent from the respective data sheet. On the card was a smd regulator whose name was different from that of the diagram and I did not find its data sheet in the internet. Surely it had to be a low-dropout regulator. I then, decided to supply the module with a voltage of 3.3V as a voltage drop of 0.3V is usually well tolerated by regulators with low drop-out, for currents of relatively modest also the use of 5V could have overheat, if not destroy, the tiny controller.
Hardware
Having already experienced the self-construction on the bread boards using the Arduino chip ATMEGA328P programmed with boot-loader, I decided for a version  powered to 3.3V instead of the classic 5 V. This is possible because the chip ATmega328P works also at lower voltages (1.8V), and has a less consumption. But the quartz in this case should be 8 MHz instead of 16, I have tried to overclock to 16 without having problems. The 3.3 V power supply simplifies interfacing of the display with the CPU, which otherwise require level converters. I programmed the chip with the Arduino bootloader, but it is easy to buy the chips already programmed. To load the sketch I used a USB serial converter module connected to a PC. The following figure shows the prototype and component layout.

To show the details of the card the display module was removed, it is connected to the board via a 9-pin strip connector (TFT interface) and a 4-wire cable and connector (SD interface). The display is fixed to the board by means of two nylon spacers. On the right it can be see the module that provides to convert the signals of the UART to USB. Below you can see the complete scheme of my system.

You can see the three filters RC low-pass anti-aliasing, with values ​​below the pulsation of cut is equal to:  w=1/(RC),  which corresponds to a frequency of about 340Hz. The three diodes act as protection for voltages greater than 3.3V. The low dropout regulator used is a LM3940-3.3, but you can replace it with an equivalent. The current consumption with display on and is about 50mA.
The image below shows the prototype in operation and with the sketch of test loads, which displays the measures of three analog channels.
When using the Arduino IDE to compile the sketch and send it to the system, it must indicate that the board used (Tools menu) is a "Arduino Pro" clocked by 16MHz and ATmega328 processor. This is a card without USB interface very similar to that proposed.
As showed in the scheme, the first three analog channels are wired to the terminal blocks because I want  to use the prototype to show these measurements on the display and store the data on an SD card.

Serial programming.
This little board is used only to program the card. The module serial / USB should work with the signals Tx, Rx and DTR as well as provide the 5V to our regulator. Only for programming you have to disconnect the external power source using the jumper W1 (P position). DTR is used to give the reset. Of course you must know what chip this board uses and load its driver for your Windows. I used the module Pololu USB01A, with the chip CP2101, but you can use similar modules. The following figure shows the wiring between the module and the connector J1, always made with a small board breadboard.

It is obvious that the Tx signal of this module should be connected to the Rx of the Arduino as well as Rx should be linked to the corresponding Tx, as you do with a null modem serial.

TFT wirings.
The module has a 9-pin 0.1 " strip connector already welded. with the comb already welded. The table shows the connections and the pin assignments for Arduino I / O . Continues in Part 2
TFT board
J2  Pin
function
Arduino
Pin I/O
CPU Pin
1
Vcc (+3.3V)


2
Gnd


3
Cs
D5
11
4
Reset
D4
6
5
D/C
D6
12
6
SDI (MOSI)
D11
17
7
Sck
D13
19
8
Led
D7
13
9
SDO (MISO)
D12
18

No comments:

Post a Comment