You are on page 1of 10

TOUCH SCREEN

INTRODUCTION

Touchscreens or touchscreen panels are display overlays which have the ability to display and receive
information on the same screen.The project aims to develop a user interface for the visitors to access the
college database using a touch screen. This device helps the students to access information about class
timing, location of rooms, fees structures, notices etc and of various departments from the college database.

OBJECTIVE OF THE PROJECT

The project aims to develop a user interface for students/visitors to access the college database using a
touch screen. This device helps the students to access information about the class timing, location of rooms,
notices etc and of various departments from college system database. There by, the college authorities can
provide the correct information to the needed person without any human intervention and can manage
centralized multi user information system. This system can help the students by providing details such as
class room location, class timing, fees structures, dues and marks. This system also includes an area to
announce new information about the college, exams and other activities.

OVERVIEW OF THE PROJECT

The embedded touch screen is used here as input device. The touch sensor/panel is placed over a display
screen so that the responsive area of the panel covers the viewable area of the video screen. The sensor
generally has an electrical current or signal going through it and touching the screen causes a voltage or
signal change. This voltage change is used to determine the location of the touch to the screen. These
voltage changes are detected by the fast microcontroller in the embedded system. The controller determines
the necessary actions and establishes connection with PC using RS232 communication The entries made
by the user through the touch screen is read and interpreted by the microcontroller. The system interprets
the incoming data from the microcontroller and sends back the corresponding data by accessing the data
base. For this purpose we develop application software using VB.NET/ASP.NET.

WORKING PRINCIPLE

We are using a 5 wire resistive touchscreen panel. Out of which the 4 wires are used for providing input
voltage and the 5th wire is used to get the output voltage corresponding to the touch. The four wires
represent the voltages at four sides. First left side is made zero voltage and the right side is made 5 volt by
making the corresponding pins of the microcontroller low and high. By this arrangement there will be
increase in voltage from left to right, this helps in finding the x coordinate of the touch. If a touch is made, the
corresponding voltage changes and this is fed to the PICmicrocontroller.

The ADC converts this analog voltage into digital value. This value is divided by set numbers that
corresponds to the amount of movement in pixels of the mouse. This helps in determining the point of touch
and moves the mouse position. The mouse pointer is moved to the point of touch by sending corresponding
codes to the RS232 port via USART transmission. Now the mouse is moved in x direction.

Similarly for finding the Y coordinate, the top and bottom sides are made 0 and 5v respectively. The voltage
is taken and the steps used for x coordinate are repeated. After moving the mouse to the position the code
for left click is sent to the PC via RS232 port using USART transmission. Then the mouse pointer is moved
to the default position that is left corner of screen. It is to be noted that the touchscreen to be detected as
mouse, the value ‘M’ should be sent to PC during initialization at a baud rate of 9600.

PROGRAM(attachment)

COMPONENTS REQUIRED:

7805 +5V regulator


PIC16F877 microcontroller
MAX232
BC547 npn transistor
4MHz crystal
IN4007 rectifier diode
LED
RESISTOR:22-kilo-ohm
10-kilo-ohm
4.7-kilo-ohm
2.2-kilo-ohm
BC557 pnp transistor
CAPACITOR:4.7microfarad ,electrolytic
0.1 microfarad, ceramic disk
0.1 microfarad, ceramic disk
470microfarad ,electrolytic
1 microfarad , electrolytic

PROGRAM FLOW

/* Microcontroller -- PIC 16 F877 - 40-pin - 8-bit- Clock Frequency is 20 MHz */


/* Driver: Microsoft serial mouse format */

1. Start.
2. Do the basic initializations – ADC(channel 0), USART(1200bps), EXT_INT and Basic variables
3. Configure UART to send “M” on every EXT_INT.
4. Send mouse code to move mouse to default position (0, 0)

5. Set RB3 to scan Y axis. Scan & save ADC value for Y axis.

6. Set RB2 & clear RB3 to scan X axis. Scan & save ADC value for X axis.

7. Send mouse command to move mouse & Left click the saved X,Y location .

8. Now send mouse command to retrace the mouse to default position.

9. Repeat the steps 4-7 for every touch.

Attachments
Code (1501-101551-code.txt)
Coding
PROGRAM

#include<pic.h> //Header File


void default(); //function declarations
void mov1(int m);
void mov2(int m);
void mov3(int m);
void mov4(int m);
void mov5(int m);
void mov6(int m);
void mov7(int m);
void mov8(int m);
void divide1(int p);
void divide2(int q);
void click();
void interrupt ext()
void usartinit()
void ExternalInt()
void adc();
int x,y,u,m,c,p,q;
/**********************************************************************
*/
/*MainFunction */
/**********************************************************************
*/
void main()
{
uartinit(); //call UART transmission
intializing function
ExternalInt(); //call External Interrupt
intializing function
default(); //call Default Condition function
while(1) //infinite loop
{
RB3=1; //Pin 3 of port B is made
high(5v) & Pin 2 is made low
RB2=0; //for making left side 0v and right 5v.
x=adc(); //adc function initialized
for finding x coordinate digital
//value
if(x>90)
{
RB3=0; //Top side is made 0v and bottom 5v
RB2=1;
y=adc(); //adc function initialized
finding y coordinate digital
//value
divide1(x); //divide function called to find
how much movements
//to the right
divide2(y); //divide function called to find
how much movements
//to the bottom
click(); // mouse click function
default(); // function for mouse default
position and check for
//touch
}
}
}
/**********************************************************************
*/
/*Interrupt*/
/**********************************************************************
*/
void interrupt ext()
{
INTF=0; //interrupt enable
TXREG='M'; //to make the PC detect the
touchscreen as mouse
while(TRMT==0) //check whether transmission over
{
}
}
/**********************************************************************
*/
/*Default*/
/**********************************************************************
*/
void default()
{
TXREG=0x43; // move mouse to default position
while(TRMT==0);

TXREG=0x43;
while(TRMT==0);
TXREG=0x43;
while(TRMT==0);
}
/**********************************************************************
*/
/*ADC*/
/**********************************************************************
*/
void adc()
{
TRISA=0XFF; //PORTA initialization ADCON1=0X80;

while(1)
{
ADCON0=0XA1; /*for ADC controlling process*/
ADGO=1; /*A/D convertet
module enable*/
while(ADGO==1)
c=ADRESH; /*loading MSB of ADC
value*/
c=c<<8; /*shifting left 8 bit places */
c=c|ADRESL; /*OR-ing with LSB value*/
return(c); /*return value*/
}}

/**********************************************************************
*/
/*Division for x coordinate. The Adc value is first
divided by set values inorder to obtain mouse commands in Microsoft
format. */
/**********************************************************************
*/

void divide1(p)
{
if(p>=400)
{
m=p%400; // adc value divided with set value 400 and
remainder is found out
p=p/400; //quotient is taken as p
mov1(p); //the quotient is sent to move function
}
if(m>=180)
{
p=m;
m=p%180;
p=p/180;
mov2(p);
}
if(m>=50)
{
p=m;
m=p%50;

p=p/50;

mov3(p);
}
if(m>=10)
{p=m;
m=p%10;
p=p/10;
mov4(p);
}
}

/**********************************************************************
*/
/*Division for y coordinate. The Adc value is first
divided by set values inorder to obtain mouse commands in Microsoft
format. */
/**********************************************************************
*/

void divide2(q)
{
if(q>=400)
{
m=q%400; //adc value divided with set value 400 and
remainder is found out
q=q/400; //quotient is taken as q
mov5(q); //the quotient is sent to move function
}
if(m>=180)
{
q=m;
m=q%180;
q=q/180;
mov6(q);
}
if(m>=50)

{
q=m;
m=q%50;
q=q/50;
mov7(q);
}
if(m>=10)
{
q=m;
m=q%10;
q=q/10;
mov8(q);
}
}

/**********************************************************************
*/
/*Mouse commands in Microsoft format to move 400 pixels
to the right */
/**********************************************************************
*/
void mov1(m)
{
while(m>0)
{
TXREG=0X41;
while(TRMT==0);
TXREG=0X00;
while(TRMT==0);
TXREG=0X3F;
while(TRMT==0);
m=m-1;
}
}
/**********************************************************************
*/
/*Mouse commands in Microsoft format to move 180 pixels
to the right */
/**********************************************************************
*/

void mov2(m)
{
while(m>0)

{
TXREG=0X40;
while(TRMT==0);
TXREG=0X00;
while(TRMT==0);
TXREG=0X3F;
while(TRMT==0);
m=m-1;
}
}
/**********************************************************************
*/
/*Mouse commands in Microsoft format to move 50 pixels
to the right
*//********************************************************************
***/
void mov3(m)
{
while(m>0)
{
TXREG=0X40;
while(TRMT==0);
TXREG=0X00;
while(TRMT==0);

TXREG=0X3F;
while(TRMT==0);
m=m-1;
}
}

/**********************************************************************
*/
/*Mouse commands in Microsoft format to move 10 pixels to the right
*/
/**********************************************************************
*/

void mov4(m)
{
while(m>0)
{
TXREG=0X40;
while(TRMT==0);
TXREG=0X00;
while(TRMT==0);
TXREG=0X3F;
while(TRMT==0);
m=m-1;
}

/**********************************************************************
*/
/*Mouse commands in Microsoft format to move 400 pixels to the bottom */
/**********************************************************************
*/
void mov5(m)
{
while(m>0)
{
TXREG=0X44;
while(TRMT==0);
TXREG=0X3F;
while(TRMT==0);
TXREG=0X00;
while(TRMT==0);
m=m-1;
}
}
/**********************************************************************
*/
/*Mouse commands in Microsoft format to move 180 pixels to the bottom */
/**********************************************************************
*/
void mov6(m)
{
while(m>0)
{

TXREG=0X40;
while(TRMT==0);
TXREG=0X3F;
while(TRMT==0);
TXREG=0X00;
while(TRMT==0);
m=m-1;
}
}

/**********************************************************************
*/
/*Mouse commands in Microsoft format to move 50 pixels to the bottom */
/**********************************************************************
*/
void mov7(m)
{
while(m>0)
{
TXREG=0X40;
while(TRMT==0);
TXREG=0X17;
while(TRMT==0);
TXREG=0X00;

while(TRMT==0);
m=m-1;
}
}
/**********************************************************************
*/
/*Mouse commands in Microsoft format to move 10 pixels to the bottom */
/**********************************************************************
*/
void mov8(m)
{
while(m>0)
{TXREG=0x40;
while(TRMT==0);
TXREG=0x08;
while(TRMT==0);
TXREG=0X00;
while(TRMT==0);
m=m-1;
}
}
/**********************************************************************
*/
/*Mouse commands in Microsoft format to click the point of touch */
/**********************************************************************
*/
void click()
{

TXREG=0X6f;
while(TRMT==0);
TXREG=0X00;
while(TRMT==0);
TXREG=0X00;
while(TRMT==0);
}

/**********************************************************************
*/
/*UART Transmission */
/**********************************************************************
*/

void usartinit()
{
TXEN=1; /*transmission enable*/
BRGH=0; /*low baud rate*/
SYNC=0; /*asynchronous mode*/
SPBRG=255; /* Baude rate set to 1200*/
SPEN=1; /*serial port enable*/
}
/**********************************************************************
*/
/*Interrupt Initialization*/
/**********************************************************************
*/

void ExternalInt()
{
PEIE=1; //peripheral interrupt enable bit: Enabled
GIE=1; //Global interrupt enable bit: Enabled
INTE=1; //External Interrupt Enable bit: Enabled
RBPU=0; //PORTB Pull up enable bit: Enabled
INTEDG=1; // Interrupt edge select: Interrupt on rising
edge
TRISB=0X01; // external interrupt set
}

You might also like