This tutorial explains one of the real world application of 8051. Here we are going to explain how a 16×2 LCD is interfaced with AT89S52.
16×2 LCD is used as output by the controller to show any data or any information to user .The name 16×2 LCD means 16 number of data can be can be written on two lines. The data can be numbers(0-9) or letters(A-Z) of any symbol like “$” ,”#”…… or a space ” “.
In recent years the LCD is replacing LEDs or seven segment display due to many factors:
- The ability of LCDs to display numbers, characters and graphics. Where other displaying unit like seven segments are limited only to numbers and few characters
- Due to presence of a controller in the LCD the displaying task gets much more easier for the micro-controller(8051)
- To show a number or alphabet on LCD screen we need to just send the ASCII value to the data pin. Hence its pretty easy to display characters and graphics
- The low price of LCDs.
LCD Pin descriptions:
THE LCD PINOUT
THE PIN DESCRIPTION FOR LCD:
In the above two figures the pin positions and pin description are discussed.The function of each pin is discussed briefly down here:
+5V is provided to Vdd(pin2) and ground is provided to Vss(pin1) to provide power to LCD and its controller. Vee is used to control the contrast of the LCD .If ground is connected directly to this pin the contrast will be so low that the each pixel would get so dark that nothing could be read. If Vcc(+5V) is directly provided to it the contrast will be so high that the pixel wouldn’t glow at all. So connect a resistance to ground in series with the pin.
- RS, Register select
Two important registers are present in the LCD. One is data register and other is instruction command code register. If data is sent at data register the data is considered as data to be displayed on the LCD. If data is sent at instruction command code register the data is considered as command from user like to clear the screen or blink the cursor,etc.
To let the LCD know whether the data on data line is command or a databyte to be displayed, RS is used.
->If RS=0 the instruction code command register is selected and the data on data line is a command.
->If RS=1 the data register is selected and the data on data line is to be displayed on screen.
SOME OF THE COMMAND CODES WHICH ARE ISSUED TO LCD
- R/W, Read/Write
It is an input pin which allows the user to read data from the LCD registers or write data into the LCD registers
->To write data to LCD Register pull down the R/W pin to 0(GND)
->To read data from LCD register provide 1(+5v) to R/W pin
The enable pin is used to latch/hold information presented to its data pins. When is supplied to the data pins,a high to low pulse must be provided to enable pin in order for the LCD to latch in th data present on the data pins.
These 8 data pins are used to read or write data to LCD.To display number,letter we send ASCII codes of that letters or numbers to these data pin.
+5V is provided to LED+ and 0V is applied to LED- to on the green backlight of the LCD.
2) CIRCUIT DIAGRAM:
THE ABOVE PICTURE IS THE CIRCUIT DIAGRAM OF LCD INTERFACING
p3.2=Enable is taken
- Port 2 is used as data port.
P2.7=DB7*PROVIDE A PULL RESISTOR TO THIS PORT IF POSSIBLE
- Power on reset circuit is provided by using 10k ohm and 10uF resistor on RST pin.
- 11.0592Mhz crystal is used alongwith two 33pF capacitors which are grounded.
3) COMPONENTS REQUIRED
- AT89S52-8051 based low cost microcontroller with 8k memory
- 16×2 LCD
- 11.0592 Mhz crystal
- Capacitors: 1 – 10uF , 2 – 33pF
- Resistors: 1 – 10k ohm , 1-1k ohm