KEMBAR78
Appendix 1 - LCD Notes | PDF | Liquid Crystal Display | Pixel
0% found this document useful (0 votes)
38 views7 pages

Appendix 1 - LCD Notes

The document describes the structure and operation of liquid crystal displays (LCDs). LCDs use liquid crystals and pixels arranged in a matrix to display characters or images. Character LCDs typically use a 5x7 or 5x8 pixel format to display text and are controlled via an interface chip.

Uploaded by

kamupata
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views7 pages

Appendix 1 - LCD Notes

The document describes the structure and operation of liquid crystal displays (LCDs). LCDs use liquid crystals and pixels arranged in a matrix to display characters or images. Character LCDs typically use a 5x7 or 5x8 pixel format to display text and are controlled via an interface chip.

Uploaded by

kamupata
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Liquid Crystal Display

Introduction
A Liquid Crystal Display (LCD) uses some liquid crystals that block light when current passes through them. The
liquid crystals are arranged into small display units called pixels. The resulting assembly of pixels is placed in front
of a light source. Current is then selectively passed through the pixels. The pixels that carry a current will block
light while those that do not carry any current will allow light to pass through. Consequently, dark and light spots
are created that displaying an image or character. Figure B1.1 shows the structure of an LCD.

Figure B1.1

Character LCDs
Character LCDs are used to display characters (ASCII and others). Each character is displayed on a 5x7 pixel matrix
or a 5x8 pixel matrix. Figure B1.2 shows the structure of a display matrix. Selectively passing light through the
pixels results in display of different characters using the available pixels.

Figure B1.2

ii
The whole display is made up of lines. Each line has a specified number of display matrices. The number of display
matrices per line and the number of lines is used to describe the size of the display screen. As an example, a 20x4
LCD displays up to 16 characters per line and has four lines of characters. Figure B1.3 shows a 20x4 character LCD.

Figure B1.3 A 16x4 character LCD.

It can be noted that the number of pixels is high and hence the number of control lines needed to control all the
pixels will also be high. This would make directly controlling an LCD from a microcontroller a hectic task. LCDs, are
therefore built into units that contain the display screen and an interface IC. The role of the interface IC is to
handle the selection and control of the pixels.

The interface IC has two registers to control operation of the display. These are:
 A command register that is used as an interface for command instructions given to the LCD.
 A data register that is used as an interface for exchange of data between the LCD and a microcontroller.

Pin Out
The pin out is shown in figure B1.4

Figure B1.4

 VCC and GND are the power supply connections for the LCD.
 VEE is the contrast adjustment pin. It is used to adjust the level of the backlight through a variable resistor.
 DB0 to DB7 are data pins. They allow a microcontroller (or a microprocessor) and the LCD to exchange
data and commands.
 RS is the control/data select line. When it is driven low, the data on the data pins is interpreted as a control
command, that is, is written to the control register. When it is driven high, the data on the data pins is
interpreted as the ASCII code of the character to be displayed, that is, is written to the data register.

iii
 R/W is the read/write control line. When it is driven low, the selected register is written to. When it is
driven high, the register is read.
 EN is the enable pin. A high to low pulse on the pin effects the data transfer.
 LED+ and LED- are power supply connections for the backlight.

The sequences of voltage levels sent to the pins control and operate the functions of the LCD. The physical
identification of the pins is found in the datasheets for the particular LCD. Table B1.1 shows a typical pinout for a
16x2 character LCD.

Table B1.1
Pin No Name
1 Ground
2 Vcc
3 VEE
4 Register Select
5 Read/write
6 Enable
7 DB0
8 DB1
9 DB2
10 DB3
11 DB4
12 DB5
13 DB6
14 DB7
15 Led+
16 Led-

8-bit and 4-bit operation


Data and commands can be transferred between the LCD and the microcontroller as 8-bit words or 4-bit words.
In 8-bit mode, all the data pins DB0 to DB7 form an 8-bit data bus. Characters are exchanged in one cycle. In 4-bit
mode, data pin DB4 to DB7 form the data bus while DB0 to DB3 are left free. The rest of the pins retain their
functions. Data and commands are transferred in two cycles.

Control and Operation of the Character LCD


The combinations of bits written to RS, R/W and data lines build various instructions that can be used to control
and operate the LCD. Table B1.2 summarizes typical instructions.

Table B1.2 Typical LCD instructions


Instruction Instruction Code Description
RS R/W DB7 DB6 DB5 DB4 DB3 DB4 DB1 DB0
Write ‘space’ to all display units
Clear display 0 0 0 0 0 0 0 0 0 1
Put cursor at home position
Return home 0 0 0 0 0 0 0 0 1 - Put cursor at home position

iv
Assign cursor moving direction
and shifting of display when a
new character is entered:
Set entry
0 0 0 0 0 0 0 1 I/D SH I/D=0 – cursor moves to left
mode
I/D=1 – cursor moves to right
SH=0 – entire display shifts left
SH=1 – entire display shifts right
Set display, cursor and cursor
blinking on or off:
D=0 – turn off display
Display
D=1 – turn on display
ON/OFF 0 0 0 0 0 0 1 D C B
C=0 – cursor disappears
control
C=1 – cursor appears
B=0 – cursor does not blink
B=1 – cursor blinks
Shift display or move cursor
without changing display
contents (S/C:R/L):
Cursor and
0 0 0 0 0 1 S/C R/L - - 00 – shift cursor left
display shift
01 – shift cursor right
10 – shift whole display left
11 – shift whole display right
Set interface data length:
DL=0 – 8-bit interface
DL=1 – 4-bit interface
Function set 0 0 0 0 1 DL N F - - N=0 – one-line display
N=1 – 2-line display
F=0 – 5×8 dots type
F=1 – 5×11 dots type
Set CGRAM address in the
Set CGRAM
0 0 0 1 AC5 AC4 AC3 AC2 AC1 AC0 address counter
address
AC5:AC0 form the address
Set DDRAM address in the
Set DDRAM
0 0 1 AC6 AC4 AC3 AC2 AC1 AC0 AC0 address counter
address
AC6:AC0 form the address
Reads state of internal
operation and address in
address counter
BF and AC:AC0 are values read
from LCD unit:
Read busy flag
0 1 BF AC6 AC4 AC3 AC2 AC1 AC0 AC0 BF=0 – no internal operation in
and address
progress
BF=1 – internal operation in
progress
AC6:AC0 – address value in
address counter
Write data into internal RAM
Write data to
1 0 D7 D6 D5 D4 D3 D2 D1 D0 (DDRAM/CGRAM)
address
D7:D0 is the data
Read data from internal RAM
Read data
1 0 D7 D6 D5 D4 D3 D2 D1 D0 (DDRAM/CGRAM)
from address
D7:D0 is the data

v
Mikro C LCD Library
The Mikro LCD Library supports 4-bit interfaces for character LCDs. The LCD pins used in the 4-bit interface
supported by the library are RS, EN and DB4 – DB7. The R/W line has been left out, presumably because the LCD
will be used for writing only. The R/W pin is physically grounded to keep it at low logic. If there is need to read and
write, then the line is connected to a port pin. Figure B1.5 shows typical connection for the 4-bit interface between
a microcontroller and an LCD.

Figure B1.5

The library routines use 6 global variables to identify the six pins and 6 global variables to identify the respective
corresponding TRIS bits. The variables are of the external sfr bit type and are declared in the library.

The variables for pins are:


 LCD_RS – register select line
 LCD_EN – enable line
 LCD_D7 – data line 7
 LCD_D6 – data line 6
 LCD_D5 – data line 5
 LCD_D4 – data line 4

The variables for the TRIS bits are:


 LCD_RS_Direction – register select pin tris bit
 LCD_EN_Direction – enable pin tris bit
 LCD_D7_Direction – data line 7 pin tris bit

vi
 LCD_D6_Direction – data line 6 pin tris bit
 LCD_D5_Direction – data line 5 pin tris bit
 LCD_D4_Direction – data line 4 pin tris bit

These 12 variables need to be defined before the library routines can be used. They are defined using the at
keyword. For the circuit shown in figure B1.5, the definitions will be as follows:
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;

The Library Functions


void Lcd_Init()
It initializes the LCD

void Lcd_Out(char row, char column, char *text)


it prints text on an LCD starting from specified position. Both string variables and literals can be passed as a text.
Parameters are:
 row: starting position row number
 column: starting position column number
 text: text to be written

void Lcd_Out_Cp(char *text)


It prints text on an LCD at the current cursor position. Both string variables and literals can be passed as a text.
Parameters are:
 text: text to be written

void Lcd_Chr(char row, char column, char out_char)


It prints a character on an LCD at specified position. Both variables and literals can be passed as a character.
Parameters are:
 row: writing position row number
 column: writing position column number
 out_char: character to be written

void Lcd_Chr_Cp(char out_char)


It prints a character on LCD at the current cursor position. Both variables and literals can be passed as a character.
Parameters are:
 out_char: character to be written

void Lcd_Cmd(char out_char)


It sends a command to the LCD.

vii
Parameters are:
 out_char: command to be sent

The characters that are used for commands are defined as constants in the LCD library. The commands used are:
 _LCD_FIRST_ROW – move cursor to the 1st row
 _LCD_SECOND_ROW – move cursor to the 2nd row
 _LCD_THIRD_ROW – move cursor to the 3rd row
 _LCD_FOURTH_ROW – move cursor to the 4th row
 _LCD_CLEAR – clear display
 _LCD_RETURN_HOME – return cursor to home position; display data RAM is unaffected.
 _LCD_CURSOR_OFF – turn off cursor
 _LCD_UNDERLINE_ON – underline cursor on
 _LCD_BLINK_CURSOR_ON – blink cursor on
 _LCD_MOVE_CURSOR_LEFT – move cursor left without changing display data RAM
 _LCD_MOVE_CURSOR_RIGHT – move cursor right without changing display data RAM

viii

You might also like