Top Banner
EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010 Touch Screen Display Arun G Kumar (09307018) <[email protected]> Rajath P S Bhat (09307R02) < [email protected]> Tushar Vaidya (09307403) < [email protected] > Instructor: Prof. P. C. Pandey Abstract: The trend in consumer electronics is increasing sophistication. Design of devices like mobile phones, iPods and laptops are majorly driven by user interface. The present day technology uses touchscreens as user interface. A touchscreen is an electronic device that can detect the presence and location of a touch within the display area. The report details the implementation of touchscreen display using a graphic LCD and a resistive touchpad. The microcontroller reads the location from the touchpad, performs the appropriate action and displays it on the graphic LCD. I INTRODUCTION A touchscreen is an easy to use input device that allows users to control the system by touching the display screen. A touch system consists of a touch sensor that receives the touch input, a controller, and a display unit. The most commonly used touch technologies are the capacitive and resistive systems. The other technologies used in this field are infrared technology, near field imaging and SAW (surface acoustic wave technology). These technologies are latest in this field but are very much expensive. A little note on resistive and capacitive touchpad is as follows. Resistive: A resistive touch screen panel is coated with a thin metallic electrically conductive and resistive layer that causes a change in the electrical current which is registered as a touch event and sent to the controller for processing. Resistive touch screen panels are generally more affordable but offer only 75% clarity and the layer can be damaged by sharp objects. Resistive touch screen panels are not affected by outside elements such as dust or water. Capacitive: A capacitive touch screen panel is coated with a material that stores electrical charges. When the panel is touched, a small amount of charge is drawn to the point of contact. Circuits located at each corner of the panel measure the charge and send the information to the controller for processing. Capacitive touch screen panels must be touched with a finger
19
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

Touch Screen Display

Arun G Kumar (09307018) <[email protected]>

Rajath P S Bhat (09307R02) < [email protected]>

Tushar Vaidya (09307403) < [email protected] >

Instructor: Prof. P. C. Pandey

Abstract: The trend in consumer electronics is increasing sophistication. Design of devices like

mobile phones, iPods and laptops are majorly driven by user interface. The present day technology

uses touchscreens as user interface. A touchscreen is an electronic device that can detect the

presence and location of a touch within the display area. The report details the implementation of

touchscreen display using a graphic LCD and a resistive touchpad. The microcontroller reads the

location from the touchpad, performs the appropriate action and displays it on the graphic LCD.

I INTRODUCTION

A touchscreen is an easy to use input device that allows users to control the system by touching the display screen. A touch system consists of a touch sensor that receives the touch input, a controller, and a display unit. The most commonly used touch technologies are the capacitive and resistive systems. The other technologies used in this field are infrared technology, near field imaging and SAW (surface acoustic wave technology). These technologies are latest in this field but are very much expensive. A little note on resistive and capacitive touchpad is as follows.

Resistive: A resistive touch screen panel is coated with a thin metallic electrically conductive and resistive layer that causes a change in the electrical current which is registered as a touch event and sent to the controller for processing. Resistive touch screen panels are generally more affordable but offer only 75% clarity and the layer can be damaged by sharp objects. Resistive touch screen panels are not affected by outside elements such as dust or water.

Capacitive: A capacitive touch screen panel is coated with a material that stores electrical charges. When the panel is touched, a small amount of charge is drawn to the point of contact. Circuits located at each corner of the panel measure the charge and send the information to the controller for processing. Capacitive touch screen panels must be touched with a finger

Page 2: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

unlike resistive and surface wave panels that can use fingers and stylus. Capacitive touch screens are not affected by outside elements and have high clarity.

The graphic LCD that we have used here is OMG12864. It is a 126x64 pixel graphic LCD module having inbuilt controller. A LCD consists of a liquid-crystal material that behaves electrically as a capacitor. There is a set of two transparent panels with a liquid crystal solution between them. Light is shined from behind the panels. Each crystal either allows light to pass through or blocks the light. The configuration of the crystals forms the image.

The two transparent panels are polarized, which means they will only pass light waves in one plane. These two polarized panels are at 90 degrees to each other so that light filtered from one plane cannot get through the other panel because it only lets light through in a plane at 90 degrees to the first plane. So the panel appears to be black or very dark. However, when electricity is applied to one of the segments of liquid crystals, the crystals line up in such a way as to make the light turn through 90 degrees in between the two panels, hence forming the image.

2 HARDWARE DISCRIPTION

The circuit diagram of the touchscreen display is shown in Appendix A. The circuit can be divided in to following parts

1. TouchpadThe touchpad used here is a 4 wire resistive type. The touchpad controller used is TSC2046 controller.

2. Graphic LCDOMG12864, a 126x64 pixel graphic LCD. It has a inbuilt LCD controller.

3. MicrocontrollerThe microcontroller TMS320F2812 is used. It is a 32bit microcontroller with maximum operating speed of 150 MHz.

2 WORKING PRINCIPLE

The touchpad is pasted on graphics LCD and is connected to microcontroller through touchpad controller. The touchpad controller is programmed through the SPI port of the microcontroller. Once programmed, the location is read each time

Page 3: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

Figure 1: Typical configuration of a 4 wire touch panel

the user touches the screen. The received location value (x, y) point is compared with required locations and the appropriate action is performed. The details of how touchpad controller works is given bellow.

A 4-wire Touch Panel usually has the set up as shown in figure 1. At the bottom layer, the bus bars are on the left side and on the right side. The left connection is called X Left (XL) and the right connection is called X Right (XR). The top layer is rotated 90° horizontally. It has its bus bars on the upper side and on the down side – the Y Upper (YU) and the Y Down (YD). With this configuration, the bottom Layer is called X-Layer and the Top Layer is called Y-Layer.

If there is a press on the touch panel a contact is made between the two conductive layers. When a voltage is applied to one layer the system behaves like a voltage divider. If for example the XLayer has voltage applied, this voltage can be measured at a bus bar of the Y-Layer. (the actual bus bar does not matter). This voltage value represents the actual X-Position. Of course, the measurement at the Y-Layer Bus Bar must be taken with a high resistance connection to keep reduce the impact to the voltage. Together with this voltage and some calibration data the X-Position can be calculated using an A-to-D converter. To get the Y-Position, the voltage must then be switched from the X-Layer to the Y-Layer and the same measurement procedure must be done at the X-Layer.

The graphic LCD is connected the parallel port of the microcontroller.

OGM12864:Description:

Page 4: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

Oriole Graphic LCD Module consists of a LCD panel with CMOS LSIs for LCD driving. Since this module has a full dot matrix graphic display, it is possible to display graphics as well as characters. LCD Module 12864S has 128 x 64 dots. Features:1. CMOS LSI’s specifically designed to drive LCDs. 2. Large Capacity Graphics type capable of displaying numerics, alphabets, special characters, graphs, charts and patterns. 3. 8 Bits parallel micro controller interface. 4. Super twisted nemantic LCD. 5. Positive Display. 6. 1/64 duty, 1/9 Bias. 7. High contrast, wide viewing range.

Super Twisted Nematic LCD's used here have a twist angle equal to 180 degrees. In this type of display, the LC material undergoes a twist of 180 . The polarizers in this case are not mounted parallel to the LC at the surface but rather at some angle. The cell, therefore, does not work on a light "guiding" principle, as in Twisted Nematic LCDs, but instead on a birefringence principle. The position of the polarizers, the cell thickness, and the birefringence of the LC are carefully chosen to result in a particular color in the "off" state. Usually, this is a yellow-green to maximize the contrast ratio. The viewsing angle of this LCD panel is 10o with bias or offset to 0o with frame frequency equal to 64Hz. The 128x64 LCD is divided in to two segments of size 64x64 which have separate drivers. The segements are driven by the corresponding drivers.. The parallel port of the microcontroller configured for the LCD controller.The operating voltage of OGM 12864 is 5 volts. The output of the microcontrollers at logic levels corresponding to 3.3volts. Hence two level translators HC244 (unidirectional) buffers are used for two segment drivers. The data to be displayed are written to the display data RAM of the LCD module.

?????????????????????? FLOW CHART would be better ?????????????

Start

Page 5: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

RST LCD

Configure LCD

Set Y Page (Y address)

(

(

Write data

Set X Page (X address)

(

(

RST Touchpad controller

Configure touchpad

Display LCD data

(

(

Is touchpad pressed?

Perform required operation

Page 6: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

No Yes Yes

TMS320F2812:

FeaturesHigh Performance CMOS Technology.

Core at 150MHz ,3.3V I/O design

High performance 32bit CPU.

Serial Peripheral interface(SPI)

Page 7: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

Upto 56 General Purpose I/O (GPIO) pins.

Flash Devices: Up to 128K x 16 Flash

(Four 8K x 16 and Six 16K x 16 Sectors)

-ROM Devices: Up to 128K x 16 ROM

The General Purpose I/O (GPIO) pins are configured for LCD display. The outputs pins to connected to LCD module using HC244 level translators for logic level conversion from 3.3V to 5V. Since no feedback is taken from the LCD all the buffers are unidirection. The Touch Panel(TSG2046) is interface to the microcontroller through Serial Peripheral Interface. The baud rate of the clock is set to @@@@@@@@@@@@@@@@. The digital values of co-ordinates obtained from the touch panel is processed and the corresponding pixels which to be set on is written to the display data RAM of LCD.

APPENDIX A

Page 8: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

Page 9: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

BILL OF MATERIALS

Item number Part Number Description Value Quantity1 C Capacitor 22UF 62 C capacitor 0.01UF 173 TMS320F2812 Microcontroller - 14 74HC244 Level Translator - 25 OMG12864 LCD with controller - 16 TCS2046 Touchpad controller - 17 Touchpad Touchpad - 1

***************** NEED TO ADD PHOTOS HERE**************************

Page 10: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

SOURCE CODE:

#include "DSP281x_Device.h" // DSP281x Headerfile Include File

#include "DSP281x_Examples.h" // DSP281x Examples Include File

#include "fonts.c"

// Prototype statements for functions found within this file.

// interrupt void ISRTimer2(void);

void delay_loop(void);

void spi_xmit(Uint16 a);

void spi_fifo_init(void);

void spi_init(void);

void error(void);

void touch_pad();//LCD

void init_LCD();//LCD

void delay_loop_1_sec();//LCD

void LCD_write_command(unsigned char section,unsigned char dat);//LCD

void LCD_write_data(unsigned char section,unsigned char dat);//LCD

void animation(char * mptr);//LCD

void clear_screen();//LCD

void refresh();//LCD

void small_delay_loop();//LCD

int gety,getx,y_pos,x_pos;

/*---------------------LCD--------------------*/

//#pragma DATA_SECTION(logo00, "logoFile")

#define RS GpioDataRegs.GPBDAT.bit.GPIOB0

#define RW GpioDataRegs.GPBDAT.bit.GPIOB1

#define EN GpioDataRegs.GPBDAT.bit.GPIOB2

#define CS1 GpioDataRegs.GPBDAT.bit.GPIOB3

#define CS2 GpioDataRegs.GPBDAT.bit.GPIOB4

#define RSTB GpioDataRegs.GPBDAT.bit.GPIOB5

#define LCD_DAT GpioDataRegs.GPADAT.all

#define DPON 0x3F // SETS DISPLAY ON

#define DP_STLN 0xC0 // DISPLAY START LINE

#define SETPG 0xB8 // SET PAGE 0 ( B8 to BF for 0 to 7

pages)

#define SET_YADD 0x40 // SET Y ADDRESS ( 40 - 7F )

#define CHGDP 0x20 // RIGHT = 0FFH, LEFT = 00H

/*-------------------------------------------*/

char vram[1024];

void main(void)

{

Uint16 sdata; // send data

Uint16 rdata; // received data

int k;

long j;

// Step 1. Initialize System Control:

// PLL, WatchDog, enable Peripheral Clocks

Page 11: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

// This example function is found in the DSP281x_SysCtrl.c file.

InitSysCtrl();

// Step 2. Initalize GPIO:

// This example function is found in the DSP281x_Gpio.c file and

// illustrates how to set the GPIO to it's default state.

// InitGpio(); // Skipped for this example

// Setup only the GP I/O only for SPI functionality

EALLOW;

GpioMuxRegs.GPFMUX.all=0x000F; // Select GPIOs to be SPI pins

//

Port F MUX - x000 0000 0000 1111

GpioMuxRegs.GPFDIR.bit.GPIOF7=1;

GpioMuxRegs.GPAMUX.all=0x0000;//LCD

GpioMuxRegs.GPADIR.all=0xFFFF;//LCD

GpioMuxRegs.GPBMUX.all=0x0000;//LCD

GpioMuxRegs.GPBDIR.all=0xFFFF;//LCD

EDIS;

// Step 3. Clear all interrupts and initialize PIE vector table:

// Disable CPU interrupts

DINT;

// Initialize PIE control registers to their default state.

// The default state is all PIE interrupts disabled and flags

// are cleared.

// This function is found in the DSP281x_PieCtrl.c file.

InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:

IER = 0x0000;

IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt

// Service Routines (ISR).

// This will populate the entire table, even if the interrupt

// is not used in this example. This is useful for debug purposes.

// The shell ISR routines are found in DSP281x_DefaultIsr.c.

// This function is found in DSP281x_PieVect.c.

InitPieVectTable();

// Step 4. Initialize all the Device Peripherals:

// This function is found in DSP281x_InitPeripherals.c

// InitPeripherals();

spi_fifo_init(); // Initialize the Spi FIFO

spi_init(); // init SPI

// Step 5. User specific code:

// Interrupts are not used .

gety=0x9B00;

getx=0xDB00;

Page 12: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

sdata = 0x9B00;

init_LCD();

delay_loop();

delay_loop();

clear_screen();

animation(logo00);

delay_loop_1_sec();

delay_loop_1_sec();

delay_loop_1_sec();

clear_screen();

// ----------------------------DISPLAY IIT on LCD----------------------------

// Write data to display RAM for IIT

vram[523]=3;

vram[524]=0x0e;

vram[525]=0x38;

vram[526]=0xe0;

vram[527]=0x80;

vram[528]=0xe0;

vram[529]=0x38;

vram[530]=0x0e;

vram[531]=3;

vram[533]=0x3c;

vram[534]=0x66;

vram[535]=0xc3;

vram[536]=0x81;

vram[537]=0xc3;

vram[538]=0x66;

vram[539]=0x3c;

vram[541]= 0xff;

vram[542]= 0x80;

vram[543]= 0x80;

vram[544]= 0x80;

vram[545]= 0x80;

for(k=224;k<=248;++k)

{

vram[k] = 0XFF;

}

vram[234] = 0Xe7;

vram[235] = 0Xe7;

vram[236] = 0X81;

vram[237] = 0X81;

vram[238] = 0Xe7;

vram[239] = 0Xe7;

Page 13: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

for(k=864;k<=888;++k)

{

vram[k] = 0XFF;

}

vram[874] = 0Xe7;

vram[875] = 0Xe7;

vram[876] = 0Xe7;

vram[877] = 0Xe7;

vram[878] = 0Xe7;

vram[879] = 0Xe7;

k=776;

refresh(); // This function makes the pixels on or off //

// corresponding to data present in data ram

//------------------------VOLUME CONTROL----------------------------

for(;;)

{

for (j = 0; j < 60000; j++) {}

touch_pad();//obtaines the co-ordainates x,y from the touch pad controller

if((x_pos>220)&&(y_pos>210))// check for volume increase

{ if(k<860)k++;

vram[k] = 0XFF; // update the display data ram

refresh(); // increase the volume bar

}

if((x_pos<190)&&(y_pos>210)) // check for volume decrease

{

vram[k] = 0X00; // update the display data ram

if(k>=776)k--;

refresh(); //decrase the volume bar

}

/* if((x_pos<232)&&(y_pos<176)&&(x_pos>200)&&(y_pos>144))

clear_screen();

if((x_pos<160)&&(y_pos<240)&&(x_pos>136)&&(y_pos>216))

animation(logo00);

*/

/*for(k=776;k<=866;++k)

{

for (j = 0; j < 600000; j++) {}

vram[k] = 0XFF;

refresh();

}*/

}

}

Page 14: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

void init_LCD()

{

RW = 0;

delay_loop();

RSTB = 0;

//GpioDataRegs.GPBDAT.bit.GPIOB5 =0;

delay_loop();

//GpioDataRegs.GPBDAT.bit.GPIOB5 =1;

RSTB = 1;

delay_loop_1_sec();

EN = 0;

CS1 = 0;

CS2 = 0;

RS = 0;

LCD_write_command(0,DPON);

small_delay_loop();

LCD_write_command(0,DP_STLN);

small_delay_loop();

LCD_write_command(1,DPON);

small_delay_loop();

LCD_write_command(1,DP_STLN);

small_delay_loop();

}

void LCD_write_command(unsigned char section,unsigned char dat)

{

int i;

RS = 0;

if(section)

{

CS2 = 1;

CS1 = 0;

}

else

{

CS2 = 0;

CS1 = 1;

}

for(i=1;i<=1000;i++);

LCD_DAT = dat;

for(i=1;i<=1000;i++);

EN = 1;

for(i=1;i<=1000;i++);

EN = 0;

delay_loop();

Page 15: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

return;

}

void animation(char *mptr)

{

int i,j;

char ch1;

char * mpt;

mpt = &vram[0];

/* for(i=0;i<128;i++)

{

for(j = 0; j < 8;j++)

{

ch1 = mptr[i+j*128];

vram[i+j*128]= ch1;

}

} */

for(i=136;i<=168;i++)

vram[i]=0xff;

for(i=176;i<=208;i++)

vram[i]=0xff;

for(i=216;i<=248;i++)

vram[i]=0xff;

////////////////////////////////////////////////

for(i=276;i<=284;i++)

vram[i]=0xff;

for(i=316;i<=324;i++)

vram[i]=0xff;

for(i=356;i<=364;i++)

vram[i]=0xff;

///////////////////////////////////////////////////////////

for(i=276+128;i<=284+128;i++)

vram[i]=0xff;

for(i=316+128;i<=324+128;i++)

vram[i]=0xff;

Page 16: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

for(i=356+128;i<=364+128;i++)

vram[i]=0xff;

//////////////////////////////////////////////////////

for(i=276+128+128;i<=284+128+128;i++)

vram[i]=0xff;

for(i=316+128+128;i<=324+128+128;i++)

vram[i]=0xff;

for(i=356+128+128;i<=364+128+128;i++)

vram[i]=0xff;

//////////////////////////////////////////////////////

for(i=276+128+128+128;i<=284+128+128+128;i++)

vram[i]=0xff;

for(i=316+128+128+128;i<=324+128+128+128;i++)

vram[i]=0xff;

for(i=356+128+128+128;i<=364+128+128+128;i++)

vram[i]=0xff;

//////////////////////////////////////////////////////

//////////////////////////////////////////////////////

for(i=136+512;i<=168+512;i++)

vram[i]=0xff;

for(i=176+512;i<=208+512;i++)

vram[i]=0xff;

for(i=356+128+128+128;i<=364+128+128+128;i++)

vram[i]=0xff;

////////////////////////////////////////////////

refresh();

}

Page 17: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

void refresh()

{

char i,pagenum;

char *vramptr,*tempptr;

vramptr = &vram[0];

for(pagenum=0;pagenum<8;pagenum++)

{

LCD_write_command(0,pagenum | SETPG);

small_delay_loop();

LCD_write_command(0,SET_YADD); //setting 0 position

small_delay_loop();

for(i=0;i<64;i++)

{

LCD_write_data(0,*vramptr++);

small_delay_loop();

}

LCD_write_command(1,pagenum | SETPG);

small_delay_loop();

LCD_write_command(1,SET_YADD); //setting 0 position

small_delay_loop();

for(i=0;i<64;i++)

{LCD_write_data(1,*vramptr++);

small_delay_loop();

}

}

}

void LCD_write_data(unsigned char section,unsigned char dat)

{

int i;

RS = 1;

if(section)

{

CS2 = 1;

CS1 = 0;

}

else

{

CS2 = 0;

CS1 = 1;

}

for(i=1;i<=100;i++);

LCD_DAT = dat;

for(i=1;i<=100;i++);

EN = 1;

Page 18: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

for(i=1;i<=1000;i++);

EN = 0;

for(i=1;i<=100;i++);

return;

}

void clear_screen()

{

int i;

char *mpt;

mpt = &vram[0];

for(i=0;i<1024;i++)

*(mpt + i) = 0;

refresh();

}

void touch_pad()

{int i;

GpioDataRegs.GPFDAT.bit.GPIOF7=0;

// Transmit data

spi_xmit(gety);

for(i=1;i<=2000;++i);

y_pos = SpiaRegs.SPIRXBUF;

spi_xmit(getx);

for(i=1;i<=2000;++i);

x_pos = SpiaRegs.SPIRXBUF;

}

// Step 7. Insert all local Interrupt Service Routines (ISRs) and functions

here:

void small_delay_loop()

{

long i;

for (i = 0; i < 100; i++) {}

//GpioDataRegs.GPBTOGGLE.all=0xffff;

}

void delay_loop()

Page 19: ProjectReport1.Doc

EE712 Embedded System Design Course Project Report, EE Dept, IIT Bombay, April 2010

{

long i;

for (i = 0; i < 12000; i++) {}

//GpioDataRegs.GPBTOGGLE.all=0xffff;

}

void delay_loop_1_sec()

{

long i;

for (i = 0; i < 11000000; i++) {}

// GpioDataRegs.GPBTOGGLE.all=0xffff;

}

void error(void)

{

asm(" ESTOP0"); //

Test failed!! Stop!

for (;;);

}

void spi_init()

{

SpiaRegs.SPICCR.all =0x0007; // Reset on, rising

edge, 16-bit char

bits

SpiaRegs.SPICTL.all =0x000E; //0006 // Enable

master mode, normal phase,

// enable talk, and SPI int

disabled.

SpiaRegs.SPIBRR =0x007F;

SpiaRegs.SPICCR.all =0x0087; // Relinquish SPI

from Reset

SpiaRegs.SPIPRI.bit.FREE = 1; // Set so breakpoints don't

disturb

xmission

}

void spi_xmit(Uint16 a)

{

SpiaRegs.SPITXBUF=a;

}

void spi_fifo_init()

{

// Initialize SPI FIFO registers

SpiaRegs.SPIFFTX.all=0xE040;

SpiaRegs.SPIFFRX.all=0x204f;

SpiaRegs.SPIFFCT.all=0x0;

}

//===========================================================================

// No more.

//===========================================================================