ss_blog_claim=726e70d7c87c20ae33aa7a61f06eb8aa

Thursday, June 19, 2008

About LCD interfacing

Previously we have seen how to interface stepper motor using TIP122, now let us see interfacing LCD with PIC16F877A

LCD introduction

LCD’s i.e, Liquid Crystal Displays utilize two sheets of polarizing material with a liquid crystal solution between them. An electric current passed through the liquid causes the crystals to align so that light cannot pass through them. Each, crystal, therefore, is like a shutter, either allowing light to pass through or blocking the light. The most commonly used alphanumeric displays are 1x16 (single line and 16 characters), 2x16 (double line and 16 characters per line) and 4x20 (four lines and twenty characters per line).

In LCD interfacing we are using HY-1602F6 LCD. It is a two line display with 16 characters on each line. Let us see how to interface an LCD with PIC16F877A.

LCD interfacing

LCD interfacing has two modes 8-bit mode and 4-bit mode.The LCD requires 3 control lines (RS, R/W and EN) and 8(or 4) data lines. The number of data lines depends on the mode of operation. If operated in 8-bit mode then 8 data lines + 3 control lines i.e, total 11 lines are required. And if operated in 4-bit mode then 4 data lines + 3 control lines i.e, total 7 lines are required. The 4-bit mode takes twice as more time as compared to 8-bit mode but it requires less number of data lines. The pin details of 16x2 LCD is shown below.
        • pin 1 - vss - ground
        • pin2 - vdd - supply voltage
        • pin3 - vc - contrast setting
        • pin4 - rs - register select
        • pin5 - r/w - read/write select
        • pin6 - en - chip enable signal
        • pin7 to pin 14 - DB0 to DB7 - data lines
        • pin 15 - vcc for backlight
        • pin16 - gnd for backlight
When RS is low (logic 0), the data is to treated as command. When RS is high (logic 1), the data being sent is considered as text data which should be displayed on the screen.

When R/W is low (logic 0), the information on the data bus is being written to the LCD. When R/W is high (logic 1), the program is effectively reading from the LCD. Most of the times there is no need to read data from the LCD so this line can directly be connected to GND thus saving one controller line.

The EN pin is used to latch the data present on the data pins. A HIGH to LOW signal is required to latch the data. The LCD interprets and executes our command at the instant the EN line is brought low. If you never bring EN low, your instruction will never be executed.

Display Data Ram (DDRAM) stores the display data. So when we have to display a character on LCD we basically write it into DDRAM. For a 2x16 LCD the DDRAM address for first line is from 80h to 8fh and for second line is 0c0h to 0cfh. So if we want to display 'H' on the 7th position pf the first line then we will write it at location 87h.

1 comment:

Unknown said...

CAN U TELL ME HOW TO CHECK WHEATHER LCD IS WORKING OR BAD ?