INTRODUCTION:
Normally
16*2 LCD is used to display numbers, alphabets and some special characters. Each
character has one ASCII value and by sending this value we can
display numbers, alphabets and some special characters on it. But
what if we want to display messages in language other than English. Is this
possible, the answer for this is yes. we can achieve this through custom character. Custom
character uses character generator RAM of LCD Module. The CG RAM is a 64 x 8 bit
RAM in which the user can program custom character patterns. 8 - 5 x 7 character
patterns can be written. The memory locations from 64 to 127 can be used to store the pattern of the user defined character. To write previously programmed characters from
the CG RAM to the DD RAM, character codes 0H through 7H are used. There are 8 symbol locations where a custom
character can be stored as shown in the following right table.
The symbol
locations with their base addresses are given below:
ASCII Code
Base Address
0
64
1
72
2
80
3
88
4
96
5
104
6
112
7
120
Suppose we have to print à¤ारत on LCD then first i need to store the pattern of
ठin the memory. The following pattern is used for this:
ASCII Code
|
Base Address
|
0
|
64
|
1
|
72
|
2
|
80
|
3
|
88
|
4
|
96
|
5
|
104
|
6
|
112
|
7
|
120
|
This is achieved
by first sending the address location (64) to LCD command register. Next, the
bitmap values (0x1D,0x15,0x1D,0x05,0x1F,0x15,0x1D) are sent to the LCD data register. Now
the character gets stored at the first address. Now whenever this symbol is to
be displayed, its location needs to be sent to the command register of LCD. As shown in above table to access this character the ASCII value to be used is 0. Similarly we design pattern for second character and store it at the address location (72).
As this character is stored at address location 72 the ASCII value to be used to access this is 1. similarly we store third and fourth character at the memory locations 80 and 88. And the ASCII values used to access this charecter are 2 and 3. The pattern for both the characters is shoen below:
CIRCUIT DIAGRAM:
CIRCUIT DESCRIPTION:
In above circuit 16*2 LCD is interfaced with AT89C51RD2. LCD is used in 8 bit mode. The controller has a power on reset circuit which is used to reset the controller when it is powered on. The crystal is used to generate clock for microcontroller using inbuilt oscillator and invertor. The pot is connected to pin no 3 of LCD to adjust the brightness of LCD. lesser the voltage at pin 3 more will be the brightness.
PROGRAM:
#include <reg51.h>
sfr ldata = 0xb0;
sbit rs = P2^0;
sbit rw = P2^1;
sbit en = P2^2;
sbit busy = P3^7;
void lcdcmd (unsigned char) ;
void msdelay (unsigned int);
void lcdready ();
void lcddata (unsigned char );
void character();
void main()
{
lcdcmd (0x38);
lcdcmd (0x0c);
lcdcmd (0x01);
character();
while (1);
}
void lcdcmd (unsigned char value)
{
lcdready ();
ldata = value;
rs = 0;
rw = 0;
en = 1;
msdelay (1);
en = 0;
}
void lcddata (unsigned char value)
{
lcdready ();
ldata = value;
rs = 1;
rw = 0;
en =1;
msdelay (1);
en = 0;
}
void lcdready ()
{
busy = 1;
rs = 0;
rw = 1;
while(busy == 1)
{
en = 0;
msdelay (1);
en = 1;
}
}
void msdelay (unsigned int itime)
{
unsigned int i, j;
for (i=0;i<itime;i++)
for (j=0;j<115;j++);
}
void character()
{
lcdcmd(64); //Address where values of the first custom character is stored
lcddata(0x1d);
lcddata(0x15);
lcddata(0x1d);
lcddata(0x05);
lcddata(0x1f);
lcddata(0x15);
lcddata(0x1d);
lcdcmd(0xC0); //Address of the location where the character is to be displayed
lcddata(0x0); // Displaying the character created at address 0x64
msdelay(10);
lcdcmd(72); //Address where values of the first custom character is stored
lcddata(0x1f);
lcddata(0x04);
lcddata(0x04);
lcddata(0x04);
lcddata(0x04);
lcddata(0x04);
lcddata(0x04);
lcdcmd(0xC1); //Address of the location where the character is to be displayed
lcddata(0x1); // Displaying the character created at address 0x64
msdelay(10);
lcdcmd(80); //Address where values of the first custom character is stored
lcddata(0x0e);
lcddata(0x01);
lcddata(0x01);
lcddata(0x0E);
lcddata(0x04);
lcddata(0x02);
lcddata(0x01);
lcdcmd(0xC2); //Address of the location where the character is to be displayed
lcddata(0x2); // Displaying the character created at address 0x64
msdelay(10);
lcdcmd(88); //Address where values of the first custom character is stored
lcddata(0x1F);
lcddata(0x01);
lcddata(0x0F);
lcddata(0x11);
lcddata(0x11);
lcddata(0x11);
lcddata(0x09);
lcdcmd(0xC3); //Address of the location where the character is to be displayed
lcddata(0x3); // Displaying the character created at address 0x64
msdelay(10);
}
OUTPUT DISPLAYED ON LCD:
This was just an example in similar way we can generate our own character and display on 16*2 LCD.
OUTPUT DISPLAYED ON LCD:
This was just an example in similar way we can generate our own character and display on 16*2 LCD.