Home     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
   
 Home     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   

Author Topic: tft lcd touch screen module interface?  (Read 8288 times)

0 Members and 1 Guest are viewing this topic.

_pike

  • Administrator
  • Full Member
  • *****
  • Posts: 182
tft lcd touch screen module interface?
« 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!.

kam

  • Administrator
  • Hero Member
  • *****
  • Posts: 1849
Re: tft lcd touch screen module interface?
« Reply #1 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)

_pike

  • Administrator
  • Full Member
  • *****
  • Posts: 182
Re: tft lcd touch screen module interface?
« Reply #2 on: November 09, 2012, 10:58:39 AM »
And may i ask who???

cheerio

  • Sr. Member
  • ****
  • Posts: 306
Re: tft lcd touch screen module interface?
« Reply #3 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.

George

  • Jr. Member
  • **
  • Posts: 73
Re: tft lcd touch screen module interface?
« Reply #4 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

_pike

  • Administrator
  • Full Member
  • *****
  • Posts: 182
Re: tft lcd touch screen module interface?
« Reply #5 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!!!!!!!

cheerio

  • Sr. Member
  • ****
  • Posts: 306
Re: tft lcd touch screen module interface?
« Reply #6 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.

George

  • Jr. Member
  • **
  • Posts: 73
Re: tft lcd touch screen module interface?
« Reply #7 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

cheerio

  • Sr. Member
  • ****
  • Posts: 306
Re: tft lcd touch screen module interface?
« Reply #8 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.


cheerio

  • Sr. Member
  • ****
  • Posts: 306
Re: tft lcd touch screen module interface?
« Reply #10 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.

_pike

  • Administrator
  • Full Member
  • *****
  • Posts: 182
Re: tft lcd touch screen module interface?
« Reply #11 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?


cheerio

  • Sr. Member
  • ****
  • Posts: 306
Re: tft lcd touch screen module interface?
« Reply #12 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.

_pike

  • Administrator
  • Full Member
  • *****
  • Posts: 182
Re: tft lcd touch screen module interface?
« Reply #13 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....

cheerio

  • Sr. Member
  • ****
  • Posts: 306
Re: tft lcd touch screen module interface?
« Reply #14 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.