LCD Operations


LCD Unit

The LCD used in this project is a 2-line x 16 characters display which employs Hitachi HD44780A as its dot matrix liquid crystal display driver. By knowing how the driver works, we could do lots of tricks with it. Table I outlines the terminals of the LCD.


TABLE I : LCD 16265 Specifications
SYMBOL PIN # FUNCTION
Vss 1 Ground
Vd 2 +5V Power Supply
Vo 3 Negative voltage supply for LCD driver
RS 4 Register Select: 1 for data; 0 for instruction code
RW 5 Read/Write: 1 to read; 0 to write into module
E 6 State data read/write
DB0 to DB7 7 - 14 bi-directional data bus terminals
A 15 +ve supply for backlight (4.2V)
K 16 -ve supply for backlight


LCD Instructions

Combination of signals to the connections from the printer port will direct different instructions to the unit and hence different displaying effects. Basically the LCD interprets incoming signals either as instructions to perform display clear, text shift, mode set etc., or as data to read/write in memory or display.

When power is turned ON, the LCD will go through a self initialization process. The unit is defaulted as a 1-line display, and 8 bits data length interface. We could however instruct the LCD to perform various functions using command sets defined in TABLE II.



Instruction E RS RW D7 D6 D5 D4 D3 D2 D1 D0
Clear Display Address Counter=0 ^ 0 0 0 0 0 0 0 0 0 1
Return home AC=0 ^ 0 0 0 0 0 0 0 0 1 X
Increment AC display left to right ^ 0 0 0 0 0 0 0 1 1 0
Decrement AC display right to left 0
Display ON control ^ 0 0 0 0 0 0 1 1 0 0
Display OFF 0
Display shift left ^ 0 0 0 0 0 1 1 0 X X
Display shift right 0 1
Set RAM address for data is sent/received ^ 0 0 1 A D D R E S S
Write data to Display RAM ^ 1 0 D D D D D A T A
Read data to Display RAM ^ 1 1 D D D D D A T A
TABLE II (X=1 or 0)

When both RS and RW are OFF, DB0-DB7 represent instructions. On the other hand, DB0-DB7 hold data in ASCII codes to be read/write when RS and RW are not all zero. In order to tell the LCD to clear the display screen, the following codes have to be sent in sequence from the printer ports:


E RS RW D7 D6 D5 D4 D3 D2 D1 D0 LCD pins
1 0 0 =Hex 04 0 0 0 0 0 0 0 1 =Hex 01
0 0 0 =Hex 00 0 0 0 0 0 0 0 1 =Hex 01
C0 C1 C2 A7 A6 A5 A4 A3 A2 A1 A0 Printer Port
Address: hex 37a ...................Address: hex 378....................

The above steps could be easily done by the following BASIC routine.

To write a character 'A' on the screen, the following conditions have to be set:

E RS RW D7 D6 D5 D4 D3 D2 D1 D0 LCD pins
1 1 0 =Hex 06 0 1 0 0 0 0 0 1 =Hex 41
0 1 0 =Hex 02 0 1 0 0 0 0 0 1 =ASCII "A"
C0 C1 C2 A7 A6 A5 A4 A3 A2 A1 A0



These simple examples illustrate how easy it is to program the LCD to display messages. All one has to do is to formulate hexidecimal codes to represent desired LCD operating mode and display data, and then dump them through the printer output ports.
1