Post on 07-Oct-2015
description
ALPHABETICAL KEYPAD USING AT89C51
MICROCONTROLLER
A MINI PROJECT REPORT
BY
P.MAHENDRA(07241A0275)
D.M.K.RAYUDU(07241A0276)
E.MANOHAR(07241A0277)
MD.AMER(07241A0278)
DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING
GOKARAJU RANGARAJU INSTITUTE OF ENGINEERING AND TECHNOLOGY
Bachupally,Hyderabad, Andhra Pradesh-500 072
March 2011
0
DISPLAY OF ENGLISH ALPAHBETS USING ALPHA KEYBOARD
ABSTRACT:
This paper explains about how to display the english alphabets using alpha keyboard.The first part of the paper explains about the interfacing of 89C51 with lcd and keyboard i,e which ports of 89C51 are used in interfacing with lcd and and which port is used for keyboard interfacing. The second part of the paper explains about the operation of 89C51 in displaying on the english alphabets using lcd and keyboard. 4x3 matrix keypad and a 16x2 lcd have been used here. Keypad and LCD are very commonly used input & output devices respectively. The 16x2 LCD can display only 16 characters in a line.89C51 microcontroller used in this paper to explain about displaying of english alphabets using lcd and alpha keyboard is a 20 pin device which as four ports in it and we are using only two ports to display english alphabets,one for interfacing lcd and other port to interface keyboard.The application of displaying english alphabets using alpha keyboard is mostly seen in cell phones,security purposes,in laptops to enter the text data on the monitor.
KEY WORDS:
4X3 Matrix keyboard,16x2 lcd,89C51 microcontroller,alpha keyboar,english alphabets.
1
CONTENTS:
INTRODUCTION.1
Keypad.1
Description..1
IMPORTANCE OF KEYPAD.2
IMPORTANCE OF PROTOTYPING2
WHY SO IMPORTANCE??..........................................................................3
WORKING OF KEYPAD4
SCHEMATIC DESIGN7
CIRCUIT DIAGRAM...8
SELECTION OF COMPONENTS..9
PROGRAM CODE.................................................................................11
AT89C51 MICROCONTROLLER 36
Features.....36
Description....36 Pin diagram...37
APPLICATIONS.....37
CONCLUSION.38
2
ALPHABETICAL KEYPAD USING AT89C51
MICROCONTROLLER INTRODUCTION: KEYPAD:
A keypad is a set of buttons arranged in a block or "pad" which usually bear digits and
other symbols and usually a complete set of alphabetical letters.An alphabetic keypad is similar
to a numeric keypad, but it provides the complete set of alphabetical letters instead of numbers 0-
9. This article presents a way to interface a keypad with 8051 microcontroller (AT89C51) to
display alphabetical characters on an LCD module. Such kind of systems is commonly used in
mobile phones to write an SMS and other texts. It can have further applications in displaying
instant messages on other display systems such as LED matrices or other multi-segment displays.
DESCRIPTION:
A 4x3 matrix keypad and a 16x2 LCD have been used here. Keypad and LCD
are very commonly used input & output devices, respectively.
The connections in the circuit are as following: port P2 of microcontroller
AT89C51 is used as data input port which is connected to data pins (7-14) of LCD. P3^0, P3^1
and P3^2 pins of microcontroller are connected to control pins RS, RW and EN of LCD. Port P0
is used to take input from keypad.
3
IMPORTANCE OF KEYPAD: Today's electronic equipment has a wide range of interface options.
Custom keypads allow engineers nearly unlimited possibilities in control design, however those
possibilities can lead to problems if the interface is not carefully examined.
Every individual using computers or laptops understand the
importance of keypads. Many companies are into market providing latest and most updated
version in keypads such as intex, hp and many more. Keypads or keyboards are most useful
gadget as it allows you to feed data or edit data in the computer system as per the requirement.
Simple Example: 10-Digit Keypad
THE IMPORTANCE OF PROTOTYPING: WHY SO IMPORTANCE??
Look at our phone then look at our computer. Both of them use 10-digit keypads and
yet they are upside down in relation to each other. People who use both are almost never
confused. In fact most people who regularly use both telephones and computer numeric keypads
are surprised when someone points out they are different.
That is because we learn very quickly which is which and don't even notice they are
different. If our machine uses a 10-digit keypad, you will need to consider whether users are
going to view it as a phone-like device or a computer-like device. If you put a computer keypad
on a phone device,we will have a lot of angry users.
The example above is a perfect illustration of why custom keypads should always go
through a prototype phase. An interface design that looks great on paper might be a disaster in
real life. Only through in-person, hands-on testing can you be sure your interface design is a
winner.
Prototypes can be produced quickly and easily allowing manufacturers to create a
mockup of the final device. They can quickly see how easy controls are to reach, how convenient
they are to use, if the feel of the keys is right and so on.
Prototypes should be tested internally at first to fix the most glaring flaws, but should always be
tested at some point by potential customers. Your staff already knows how the equipment should
work.
4
A Nearly Tragic Example Of Poor Design
In a May 6, 2004 newsletter of the Institute for Safe Medicine Practices a
glaring example of poorly designed custom keypads was given. They reported problems with IV
pumps that had a decimal point key located near the zero key.
Several cases had been reported of nurses accidentally hitting zero instead
of decimal. For example a dosage of 1.5 ml/hour could become 105 ml/hour! Luckily, the errors
were apparently noticed before any harm came to the patients. A simple design change such as
moving the decimal point away from numeric keys would have made the IV pumps safer.
Even if our equipment doesn't have the potential for harm that a poorly
designed IV pump has, we still need to consider carefully the design of custom keypads. If
nothing else, a confusing interface will lead to frustrated clients who might buy from our
competitor next time.
5
WORKING OF KEYPAD: The alphabetic pattern or letter mapping used in this system is depicted in the following figure:
Every key is assigned with a variable to count the number of times it has been pressed. The count
is set to zero initially and increases by one when the same key is pressed again. On first count,
the first alphabet of the key from its letter map is displayed on LCD. For example, if Key1 is
pressed when its count is 0, then a appears on the LCD screen. After this operation, the count
increases to 1.
6
The second letter of the alphabetic pattern is shown on the display module when the same key is
pressed again. This time the count increases again to 2 and second alphabet is displayed at same
position. Thus, we get b on display if Key1 is used twice
When the same key is pressed third time, its count value changes to 3. This time the third
alphabet of the letter pattern gets displayed on screen replacing the previous alphabet. For the
considered case, c appears on the LCD screen when Key1 is pressed thrice in a row.
7
The count is reset to zero after it reaches to a value of 3. After this execution, the position on
LCD is shifted to right to allow the second letter to be printed there.
Therefore, pressing the same key four times consecutively, the first alphabet from its letter map
reappears in succession to the last letter. Here, a gets displayed on LCD after c when Key1 is
used four times.
In other words, if a key is pressed more than thrice in a row, the count resets to zero and itll
behave as a new alphabetic key. Thus the same modes of operations continue on repeated access
of the keypad buttons.
8
SCHEMATIC DESIGN:
Key0 of this keypad is set for to provide a blank space
while Key* provides the functionality of backward movement while writing a text on
LCD. Key# of the keypad is configured for forward movement.
The 16x2 LCD can display only 16 characters in a line. Therefore, after 16th letter appears
on screen, the cursor position is moved and 17th letter gets displayed on the first position of 2nd
line of LCD. Similarly, 23rd letter appears back on the first line and so on.
9
CIRCUIT DIAGRAM:
10
SELECTION OF COMPONENTS:
PRESET:
A preset is a three legged electronic component which can be made to offer varying resistance in
a circuit. The resistance is varied by adjusting the rotary control over it. The adjustment can be
done by using a small screw driver or a similar tool. The resistance does not vary linearly but
rather varies in exponential or log...
AT89C51 OR 89C51 MICROCONTROLLER:
AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. AT89C51 has 4KB of
Flash programmable and erasable read only memory (PEROM) ...
11
LCD:
LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of
applications. A 16x2 LCD display is very basic module and is very commonly used in various
devices and circuits. These modules are preferred over seven segments and other multi
segment...
12
PROGRAM CODE:
#include
#define port P1
#define dataportP2 //Data port for LCD
#define key P0 // Port for Keypad
#define sec 100
sbitrs = port^1;
sbitrw = port^2;
sbit en = port^3;
sbit col1=key^4;
sbit col2=key^5;
sbit col3=key^6;
sbit row1=key^0;
sbit row2=key^1;
sbit row3=key^2;
sbit row4=key^3;
unsigned char position=128,i=0;
intcheck_again[10]={0,0,0,0,0,0,0,0,0,0};
void delay(unsigned intmsec) // Time delay function
{
inti,j ;
13
delay(1);
en=0;
return;
}
voidnum_check(int a , int b) //Check function
{
int j;
for(j=0;j
switch(b)
{
case 1:
{
switch(a)
{
case 1:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('a');
delay(5);
num_check(1 ,check_again[1]);
break;
}
case 2:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('d');
delay(5);
16
num_check(2 ,check_again[2]);
break;
}
case 3: {
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('g');
delay(5);
num_check(3 ,check_again[3]);
break;
}
case 4:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('j');
delay(5);
num_check(4 ,check_again[4]);
break;
}
17
case 5:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('m');
delay(5);
num_check(5 ,check_again[5]);
break;
}
case 6:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('p');
delay(5);
num_check(6 ,check_again[6]);
break;
}
case 7:{
if(check_again[a]>1)
i--;
18
lcd_cmd(position+i);
lcd_data('s');
delay(5);
num_check(7 ,check_again[7]);
break;
}
case 8:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('v');
delay(5);
num_check(8 ,check_again[8]);
break;
}
case 9:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('y');
delay(5);
19
num_check(9 ,check_again[9]);
break;
}
case 0:{
lcd_cmd(position+i);
lcd_data(' ');
delay(5);
num_check(10 ,check_again[10]);
break;
}
case 11:{
if((position+i)>129)
{
i=i-2;
delay(5);
lcd_cmd(position+i+1);
num_check(11 ,check_again[11]);;
delay(5);
}
break;
}
20
case 12:{
delay(5);
lcd_cmd(position+i);
num_check(12 ,check_again[12]);
delay(5);
break;
}
}
break;
}
case 2:
{
switch(a)
{
case 1:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('b');
delay(5);
num_check(1 ,check_again[1]);
21
break;
}
case 2:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('e');
delay(5);
num_check(2 ,check_again[2]);
break;
}
case 3: {
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('h');
delay(5);
num_check(3 ,check_again[3]);
break;
}
case 4:{
22
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('k');
delay(5);
num_check(4 ,check_again[4]);
break;
}
case 5:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('n');
delay(5);
num_check(5 ,check_again[5]);
break;
}
case 6:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
23
lcd_data('q');
delay(5);
num_check(6 ,check_again[6]);
break;
}
case 7:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('t');
delay(5);
num_check(7 ,check_again[7]);
break;
}
case 8:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('w');
delay(5);
num_check(8 ,check_again[8]);
24
break;
}
case 9:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('z');
delay(5);
num_check(9 ,check_again[9]);
break;
}
case 0:{
lcd_cmd(position+i);
lcd_data('-');
num_check(10 ,check_again[10]);
break;
}
case 11:{
i--;
lcd_cmd(0x10);
delay(5);
25
break;
}
}
break;
}
case 3:
{
switch(a)
{
case 1:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('c');
delay(5);
num_check(1 ,check_again[1]);
break;
}
case 2:{
if(check_again[a]>1)
i--;
26
lcd_cmd(position+i);
lcd_data('f');
delay(5);
num_check(2 ,check_again[2]);
break;
}
case 3: {
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('i');
delay(5);
num_check(3 ,check_again[3]);
break;
}
case 4:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('l');
delay(5);
27
num_check(4 ,check_again[4]);
break;
}
case 5:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('o');
delay(5);
num_check(5 ,check_again[5]);
break;
}
case 6:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('r');
delay(5);
num_check(6 ,check_again[6]);
break;
}
28
case 7:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('u');
delay(5);
num_check(7 ,check_again[7]);
break;
}
case 8:{
if(check_again[a]>1)
i--;
lcd_cmd(position+i);
lcd_data('x');
delay(5);
num_check(8 ,check_again[8]);
break;
}
case 9:{
if(check_again[a]>1)
i--;
29
lcd_cmd(position+i);
lcd_data('z');
delay(5);
num_check(9 ,check_again[9]);
break;
}
case 0:{ lcd_cmd(position+i);
lcd_data('-');
num_check(10 ,check_again[10]);
break;
}
case 11:{
i=i-2;
lcd_cmd(position+i);
delay(5);
break;
}
}
break;
}
}
30
}
void check_col1() //Check column one
{
row1=row2=row3=row4=1;
row1=0;
if(col1==0)
{
delay(10);
check_again[1]++;
display(1,check_again[1]);
}
row1=1;
row2=0;
if(col1==0)
{
delay(10);
check_again[4]++;
display(4,check_again[4]);
}
row2=1;
31
row3=0;
if(col1==0)
{
delay(10);
check_again[7]++;
display(7,check_again[7]);
}
row3=1;
row4=0;
if(col1==0)
{
delay(10);
display(11,1); //FOR *
}
row4=1;
}
void check_col2() //Check column two
{
row1=row2=row3=row4=1;
row1=0;
32
if(col2==0)
{
delay(10);
check_again[2]++;
display(2,check_again[2]);
}
row1=1;
row2=0;
if(col2==0)
{
check_again[5]++;
display(5,check_again[5]);
}
row2=1;
row3=0;
if(col2==0)
{
delay(10);
check_again[8]++;
display(8,check_again[8]);
}
33
row3=1;
row4=0;
if(col2==0)
{
delay(10);
check_again[0]++;
display(0,1);
}
row4=1;
}
void check_col3() //check column three
{
row1=row2=row3=row4=1;
row1=0;
if(col3==0)
{
delay(10);
check_again[3]++;
display(3,check_again[3]);
}
34
row1=1;
row2=0;
if(col3==0)
{
delay(10);
check_again[6]++;
display(6,check_again[6]);
}
row2=1;
row3=0;
if(col3==0)
{
delay(10);
check_again[9]++;
display(9,check_again[9]);
}
row3=1;
row4=0;
if(col3==0)
{
delay(10);
35
display(12,1); //FOR #
}
row4=1;
}
void keypad1()
{
if((position+i)>144 && i>16)
{
position=192;
i=0;
}
if((position+i)>203 && i>12 )
{
lcd_cmd(0X01);
i=0;
position=128;
}
i++;
lcd_cmd(position+i);
if(col1==0)
check_col1();
36
else
if(col2==0)
check_col2();
else
if(col3==0)
check_col3();
delay(10);
}
void main()
{
col1=col2=col3=1;
lcd_cmd(0x38);
lcd_cmd(0x0e);
lcd_cmd(0x01);
delay(sec);
while(1)
{
row1=row2=row3=row4=0;
while(col1==1 && col2==1 && col3==1);
{
keypad1();
37
}
}
}
AT89C51 MICROCONTROLLER:
FEATURES:
Compatible with MCS-51 Products 4K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz Three-level Program Memory Lock 128 x 8-bit Internal RAM 32 Programmable I/O Lines Two 16-bit Timer/Counters Six Interrupt Sources Programmable Serial Channel Low-power Idle and Power-down Modes
DESCRIPTION:
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K
bytes of Flash programmable and erasable read only memory (PEROM). The deviceis
manufactured using Atmels high-density nonvolatile memory technology and is
compatible with the industry-standard MCS-51 instruction set and pinout. The on-chip
Flash allows the program memory to be reprogrammed in-system or by a conventional
nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash
on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides
a highly-flexible and cost-effective solution to many embedded control applications.
The AT89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM,
32 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt architecture,a full duplex
serial port, on-chip oscillator and clock circuitry.In addition, the AT89C51 is designed with static
logicfor operation down to zero frequency and supports two software power saving modes.
38
PIN DIAGRAM:
APPLICATIONS:
Text messaging in mobiles and computers
For extra safety in login systems to increase the security
Can be used as input module in programmable logic controllers(PLC)
39
Keypad can find applications in medical,defence,technological,security,software,automobile fields
CONCLUSION:
This report describes a simple but very useful programmable coding for
implementing ALPHABETICAL KEYPAD using AT89C51 Microcontroller .
40