Friday, 14 August 2015

LCD INTERFACE ON 8051


LCD

Stands for Liquid Crystal Display and is definitely an output device. It comes in many popular shapes and sizes but here is the one that you will most probably face at the beginner's level.

COMMON LCD
COMMON LCD
Let's focus on this one. It is basically called 16x2 LCD because it has sixteen columns and two rows thus it can display thirty-two (32) characters at a time (sixteen characters in each row). There are sixteen hardware pins as shown.

LCD HARDWARE PINS
LCD HARDWARE PINS


Number
Pin
Function



1
GND
Ground
2
Vcc
Power Source (+5V)
3
Vee
Contrast Control
4
RS
Register Select
0=Command Register
1=Data Register
5
R/W
Read/Write
0=Write
1=Read
6
E
Enable
7-14
D0 – D7
8-bit data pins
15
BL+
Backlight Control
16
BL-
Ground




PINS

The RS  (Register Select) control pin is used to select either command or data register as described in the pin configuration table. Once selected, all data sent on the 8-bit data lines will be latched to that register.

The R/W (Read/Write) control pin is used to determine the flow of data. You have to select

  • Write Mode when you're sending something to the LCD (data or command)
  • Read Mode when you're reading from the LCD

The E (Enable) control pin acts as a guard to allow exchange of data. This pin is very important in this whole process and must be handled precisely. The following animation explains its function


SENDING DATA TO LCD

 Commands:



LCD INTERFACE CODE:

Naming each pin using #define
Naming each pin using #define
  •  I created two separate functions. As you can see, the only difference is that of using RS pin according to requirement.

LCD Command Function
LCD Command Function
LCD Data Function
LCD Data Function

  • The delay function is a general one and you can use it safely at this stage but remember that it's not accurate. 
Delay Function
Delay Function

  • Here is my main function

LCD Main Function
LCD Main Function


Here is the Proteus Simulation Diagram for LCD interface.:
Proteus Simulation
Proteus Simulation



No comments:

Post a Comment