PCB Heaven

General Category => Digital discussion => Topic started by: _pike on November 09, 2012, 00:14:46 AM

Title: tft lcd touch screen module interface?
Post by: _pike on November 09, 2012, 00:14:46 AM
Hello to all....
I am wondering if anyone knows how to control this type of tft touch screen with a microcontroller.

http://www.ebay.ie/itm/3-2-TFT-LCD-Module-Display-Touch-Panel-PCB-adapter-/200706722313?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item2ebb0d8a09

Thanks in advance!.
Title: Re: tft lcd touch screen module interface?
Post by: kam on November 09, 2012, 09:37:19 AM
i think i may know one... Who works on a project to convert it into serial interface??? 8) 8)
Title: Re: tft lcd touch screen module interface?
Post by: _pike on November 09, 2012, 10:58:39 AM
And may i ask who???
Title: Re: tft lcd touch screen module interface?
Post by: cheerio on November 10, 2012, 02:18:15 AM
I am currently not working on the parallel/serial adapter. I decided to do this with CPLD or FPGA but do not have enough spare time.
If you have enough I/O you can use this display pretty easy. I can help you if you need help.
Title: Re: tft lcd touch screen module interface?
Post by: George on November 10, 2012, 16:30:40 PM
@_pike
mikroelektronika sell touchscreen/LCD combos for their development systems

mikroe.com

 they should have some info re resistive touch screens and sample code, it may be of some help
Title: Re: tft lcd touch screen module interface?
Post by: _pike on November 10, 2012, 21:16:04 PM
Cheerio of course i will need your help!!!!!!! hope not to bother you a lot........ :-[
George With a fast glance i looked it and it seems quiet promising....Have you ever played with them???As for the libraries i don't know if they can help me because i use assembly language programming and most of their examples are in C....

Cheerio i will use a pic16lf1939 which has 40 pins 36 available for interfacing hope to be enough.If i buy this tft do you think that we will make it work?

George if you can also help it would be great!!!!

Appeciated from both!!!!!!!
Title: Re: tft lcd touch screen module interface?
Post by: cheerio on November 10, 2012, 22:51:56 PM
I use AVR but as a matter of fact the example code that is delivered with this LCD is for PIC.
You basically just read and write via SPI. Pretty straight forward.
Title: Re: tft lcd touch screen module interface?
Post by: George on November 11, 2012, 01:26:41 AM
Texas has a guide to 4-wire touchscreen (on msp launchpad ) worth a read

and here is what I think you are looking for

http://electronics.stackexchange.com/questions/21475/resistive-touch-screens

cheers
Title: Re: tft lcd touch screen module interface?
Post by: cheerio on November 11, 2012, 02:54:54 AM
I use AVR but as a matter of fact the example code that is delivered with this LCD is for PIC.
You basically just read and write via SPI. Pretty straight forward.
I was talking about the Touch controller communication. The display communication is a parallel communication. You can simply port my functions to Pic. I will post them later here. For starting the display etc. you might need to change the sequence as your display controller might be a different one. Just give it a shot w/o a change.
Title: Re: tft lcd touch screen module interface?
Post by: George on November 11, 2012, 06:21:48 AM
here's the Texas reference

http://www.ti.com/mcu/docs/litabsmultiplefilelist.tsp?sectionId=96&tabId=1502&literatureNumber=slaa384a&docCategoryId=1&familyId=342
Title: Re: tft lcd touch screen module interface?
Post by: cheerio on November 11, 2012, 14:49:43 PM
lcd.h
Code: [Select]
#include <stdint.h>
#include <stdbool.h>
#include "globals.h"

//LCD stuff
void setData(uint16_t DH);
void Lcd_Write_Com( uint16_t  DH);
void Lcd_Write_DATA(uint16_t DH);
void Lcd_Write_Com_Data( uint16_t com1, uint16_t dat1);
void Address_set(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2);
void Lcd_Init(void);


lcd.c
Code: [Select]
#include <avr/io.h>
#include "misc.h"
#include "config.h"



void setData(uint16_t DH){
PORTD = (DH>>8); //high byte
PORTF = (DH&0xFF);

}

void Lcd_Write_Com( uint16_t  DH)
{
    CLEAR_LCD_RS
CLEAR_LCD_CS
setData(DH);
CLEAR_LCD_WR
SET_LCD_WR
SET_LCD_CS
}


void Lcd_Write_DATA(uint16_t DH)
    SET_LCD_RS
CLEAR_LCD_CS  
setData(DH);
CLEAR_LCD_WR
SET_LCD_WR
SET_LCD_CS
}



void Lcd_Write_Com_Data( uint16_t com1, uint16_t dat1)
{
   Lcd_Write_Com(com1);
   Lcd_Write_DATA(dat1);
}



void Address_set(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2)
{
Lcd_Write_Com_Data(0x0044,(x2<<8)+x1);
Lcd_Write_Com_Data(0x0045,y1);
Lcd_Write_Com_Data(0x0046,y2);
Lcd_Write_Com_Data(0x004e,x1);
Lcd_Write_Com_Data(0x004f,y1);
    Lcd_Write_Com(0x0022);        
   
}

void Lcd_Init(void)
{

    SET_LCD_REST
    delayms(5);
CLEAR_LCD_REST
delayms(10);
SET_LCD_REST
SET_LCD_CS
SET_LCD_RD
SET_LCD_WR
delayms(20);
#define RL 14
#define REV 13
#define CAD 12
#define BGR 11
#define SM 10
#define TB 9


    Lcd_Write_Com_Data(0x0000,0x0001);    delayms(1); 
    Lcd_Write_Com_Data(0x0003,0xA8AE);    delayms(1);   
    Lcd_Write_Com_Data(0x000C,0x0000);    delayms(1);   
    Lcd_Write_Com_Data(0x000D,0x080C);    delayms(1);   
    Lcd_Write_Com_Data(0x000E,0x2B00);    delayms(1);   
    Lcd_Write_Com_Data(0x001E,0x00B0);    delayms(1);   
    Lcd_Write_Com_Data(0x0001,0x2BFF);    delayms(1);   
Lcd_Write_Com_Data(0x0002,0x0600);    delayms(1);
    Lcd_Write_Com_Data(0x0010,0x0000);    delayms(1); //sleep mode
    Lcd_Write_Com_Data(0x0011,0x6070);    delayms(1);                 
    Lcd_Write_Com_Data(0x0005,0x0000);    delayms(1);
    Lcd_Write_Com_Data(0x0006,0x0000);    delayms(1);
    Lcd_Write_Com_Data(0x0016,0xEF1C);    delayms(1);
    Lcd_Write_Com_Data(0x0017,0x0003);    delayms(1);
    Lcd_Write_Com_Data(0x0007,0x0233);    delayms(1);             
    Lcd_Write_Com_Data(0x000B,0x0020);    delayms(1);
    Lcd_Write_Com_Data(0x000F,0x0000);    delayms(1);       
    Lcd_Write_Com_Data(0x0041,0x0000);    delayms(1);
    Lcd_Write_Com_Data(0x0042,0x0000);    delayms(1);
    Lcd_Write_Com_Data(0x0048,0x0000);    delayms(1);
    Lcd_Write_Com_Data(0x0049,0x013F);    delayms(1);
    Lcd_Write_Com_Data(0x004A,0x0000);    delayms(1);
    Lcd_Write_Com_Data(0x004B,0x0000);    delayms(1);
    Lcd_Write_Com_Data(0x0044,0xEF00);    delayms(1);
    Lcd_Write_Com_Data(0x0045,0x0000);    delayms(1);
    Lcd_Write_Com_Data(0x0046,0x013F);    delayms(1);
   /* Lcd_Write_Com_Data(0x0030,0x0707);    delayms(1);
    Lcd_Write_Com_Data(0x0031,0x0204);    delayms(1);
    Lcd_Write_Com_Data(0x0032,0x0204);    delayms(1);
    Lcd_Write_Com_Data(0x0033,0x0502);    delayms(1);
    Lcd_Write_Com_Data(0x0034,0x0507);    delayms(1);
    Lcd_Write_Com_Data(0x0035,0x0204);    delayms(1);
    Lcd_Write_Com_Data(0x0036,0x0204);    delayms(1);
    Lcd_Write_Com_Data(0x0037,0x0502);    delayms(1);
    Lcd_Write_Com_Data(0x003A,0x0302);    delayms(1);
    Lcd_Write_Com_Data(0x003B,0x0302);    delayms(1);*/
    Lcd_Write_Com_Data(0x0023,0x0000);    delayms(1);
    Lcd_Write_Com_Data(0x0024,0x0000);    delayms(1);
Lcd_Write_Com_Data(0x0028,0x0006);    delayms(1); //set to 6 before set R25h or R29h
    Lcd_Write_Com_Data(0x0025,0xF000);    delayms(1); //Frame frequency control (FRC)
    Lcd_Write_Com_Data(0x004f,0);       
    Lcd_Write_Com_Data(0x004e,0);       
Lcd_Write_Com(0x0022);
}


touch.h
Code: [Select]
#include "misc.h"
#define DELAY delayus(1); //delay between touch clk high/low
void get_tp(volatile short int *x,volatile short int *y);
void touch_init();


touch.c
Code: [Select]
#include "touch.h"
#include "config.h"
#include "misc.h"
void touch_init(void)                                   
{
SET_D_CS
SET_D_CLK
SET_D_IN
}

void WriteCharTo7843(uint8_t num)         
{
int8_t count;
CLEAR_D_CLK
for(count=7;count>=0;count--)
{

if((num& ((uint8_t)(1<<count)) ) == 0)
{
CLEAR_D_IN
}else{
SET_D_IN
}
CLEAR_D_CLK
DELAY               
SET_D_CLK
DELAY
}
}


//**********************************************************
uint8_t ReadFromCharFrom7843(void)           
{
int8_t count;
uint8_t Num=0;
for(count=7;count>=0;count--)
{

SET_D_CLK
DELAY            //ϽµÑØÓÐЧ
CLEAR_D_CLK
DELAY
if(D_OUT) Num |= (uint16_t)(1<<count);
}
return(Num);
}


void get_tp(volatile short int *x,volatile short int *y)             
{
//DELAY                     
//touch_init();                       
//while(D_BUSY != 0);               
CLEAR_D_CS
CLEAR_D_CLK
//while(D_BUSY);
WriteCharTo7843(0x90 | (1<<3));     
DELAY
SET_D_CLK
DELAY
CLEAR_D_CLK
DELAY
//while(D_BUSY);
*x = (uint16_t)ReadFromCharFrom7843();
//*x<<=4;
//*x|=((ReadFromCharFrom7843()&0xF0)>>4);

WriteCharTo7843(0xD0);     
SET_D_CLK
DELAY
CLEAR_D_CLK
DELAY;
//while(D_BUSY);
*y = ReadFromCharFrom7843();
SET_D_CS
}



As you can see the code is still not perfect and debugging was going on. But it was working quite good.
Because the display controller was used as a SPI slave i did software SPI to talk to the touch IC. you should go for hardware SPI here.
Title: Re: tft lcd touch screen module interface?
Post by: _pike on November 11, 2012, 18:10:30 PM
Guys thanks for your replies!!!!!!!!

Well Cheerio my problem is that i cannot completely understand the code above because i don't know C.
So i think that it would be more helpful if you could post a flow chart of how to initialiaze the screen and so on.....

example
1.set high cs for 100ms
2.set low sck for 50ns
3.load value to a temporary register
4.send it through pins DB0 to DB16

Also a simple schematic would be also great.

George i want to have the touchpad on the lcd...not separate.Also nice application note for touchpad using the specific controller.

Also i have in my possesion an lcd with touchpad from an HTC P3300 cell phone.I looked over the net for a datasheet and i found a detailed datasheet here it is...

http://www.kandroid.org/board/data/board/secondapplication/file_in_body/1/TD028TTEB5_Product_Spec_Ver_1.1.pdf

Do you think that we can make it work?

Title: Re: tft lcd touch screen module interface?
Post by: cheerio on November 11, 2012, 19:44:55 PM
you should really learn c. not using c is quite a disadvantage...
The display you got has no touch controller. you need a touch controller or you have to code it yourself which is a pain in the ass.
You have to drive the gates etc. on this display yourself afaik which also is a pain in the ass. I would sell it and buy another one.

The C code i use is very basic you can understand most of it with just a few hours of learning.
Title: Re: tft lcd touch screen module interface?
Post by: _pike on November 12, 2012, 00:27:53 AM
ok shall you propose me a color display with a touchpad enhanced, and "simple" interfacing as it is my first time.
It would be nice if you propose me a display that you would have made a first contact....In order to be much easier to help me out....
Title: Re: tft lcd touch screen module interface?
Post by: cheerio on November 12, 2012, 00:38:29 AM
the one you linked in the 1 post is pretty easy doable. Only disadvantage is that the communication is only parallel.
Title: Re: tft lcd touch screen module interface?
Post by: George on November 12, 2012, 00:52:37 AM
looking at the LCD/touch unit in the 1st post, it has an SSD1289 controller, in section 2 of the SSD1289 controller datasheet , it notes both  parallel interface AND SPI interface

probably need to find a post on the unit to see how easy OR NOT it was to work with.
Title: Re: tft lcd touch screen module interface?
Post by: cheerio on November 12, 2012, 03:27:14 AM
I am pretty certain that the spi interface is not available.
My display has the same Controller and i was not able to get to the SPI pins. They are not available on the Flex Connector and the Controller itself is impossible to access w/o destroying it.
Title: Re: tft lcd touch screen module interface?
Post by: George on November 12, 2012, 10:26:28 AM
Here's a transistor interface for a 4 wire resistive touch screen for your reading pike
http://forum.allaboutcircuits.com/showthread.php?t=54635
Title: Re: tft lcd touch screen module interface?
Post by: _pike on November 12, 2012, 13:59:28 PM
Alright!!!!!!!! Today i will make a purchase of it.....I don't really care if the connection would be paraller....(Since now) So can you provide me a initialization of it?Do you have a video of your working lcd????

George really helpfull i will have it in mind for future projects with touchpad interface!!!!.
Title: Re: tft lcd touch screen module interface?
Post by: cheerio on November 12, 2012, 17:56:24 PM
i did not make a video yet. the init sequence is in the code.
CLEAR_LCD_...   ->   Set the ... Pin low
SET_LCD_...       ->   Set the ... Pin High



   PORTD = (DH>>8);
   PORTF = (DH&0xFF);

        -> Port D and F are 8 pins each. I set the Port D for the high 8bit and the Port F for the low 8bit of the 16bit word.


Lcd_Write_Com_Data(X , Y); -> Write data Y to Register Adress X

Lcd_Write_Com(X);   ->   Write command X

delay_ms(X) -> wait for X ms (you can tweak the wait time but it does not make a big difference in the init stuff)

there is no need for a flowchart.
Check the datasheet. You do not have to init all the registers as i write the default value to some of them. I do this because i was experimenting with other values before.


I have some functions for Drawing as well. But i have to put in some comments before i post them.


Please make sure you use 3.3V VCC the Data pins are NOT 5V tolerant afaik
Title: Re: tft lcd touch screen module interface?
Post by: kam on November 12, 2012, 20:28:22 PM
 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8)
I'M WAITING THE FIRST ONE WHO WILL DEVELOP THE SERIAL TO PARALLEL INTERFACE...
 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8)

Who will be the first and most complete - Place bets, AVR or PIC???
Title: Re: tft lcd touch screen module interface?
Post by: cheerio on November 12, 2012, 20:51:58 PM
dunno. but who will be the best?
CPLD/FPGA ^^
it should have a data buffer that can be filled and then highspeed send to the display. i think you can get the 50hz then ... if the display can handle it