Power Point presentations , Simulators are used in the demostrations of the code
1
D714D613D512D411D310D29D18D07
E6RW5RS4
VSS1 VDD2 VEE3
LCD Interfacing with 8051 Microcontroller
TVLNH Prasad
Asst. Professor Dept. Of Physics & Electronics Bhavan’s Vivekananda College, Sainikpuri.
B V C Dept. Of Physics and Electronics 2 Objectives
List of reasons for considering LCD
Functions of the pins of a typical LCD
Command codes for programming LCD
interface LCD to the 8051
Programming techniques
B V C Dept. Of Physics and Electronics 3 Introduction
Alphanumeric displays are used in a wide range of applications, including palmtop computers, word processors, photocopiers, point of sale terminals, medical instruments, cellular phones, etc.
The 16 x 2 intelligent alphanumeric dot matrix display is capable of displaying 224 different characters and symbols. (note these symbols can vary between brand of LCD used).
B V C Dept. Of Physics and Electronics 4 Introduction
(LCD is finding widespread
use replacing
LEDs)
The declining prices of LCD
The ability to display numbers, characters, and graphics
Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the task of refreshing the LCD
Ease of programming for characters and graphics
B V C Dept. Of Physics and Electronics 5 Introduction
(Various LCDs)
D714D613D512D411D310D29D18D07
E6RW5RS4
VSS1 VDD2 VEE3
LCD1
LM020L
16 X 1 ALPHA NUMERIC
D714D613D512D411D310D29D18D07
E6RW5RS4
VSS1 VDD2 VEE3 LCD2 LM016L
16 X 2 ALPHA NUMERIC
D714D613D512D411D310D29D18D07
E6RW5RS4
VSS1 VDD2 VEE3 LCD3 LM017L
32 X 2 ALPHA NUMERIC
B V C Dept. Of Physics and Electronics 6 Introduction
(Various LCDs)
D714D613D512D411D310D29D18D07
E6RW5RS4
VSS1 VDD2 VEE3
LCD4
LM041L
16 X 4 ALPHA NUMERIC
CE15
RD5C/D4
VSS1 VDD2 VO3 WR6 D07 FS119
D18 D29 D310 D411 D512 D613 D714 RST16 MD218 HALT20
VEE17
LM3228
128 x 64 GRAPHICAL LCD
Power Point presentations , Simulators are used in the demostrations of the code
2
B V C Dept. Of Physics and Electronics 7 LCD
pin description
Pin
No Name I / O Function
1 Vss -- Ground (0V)
2 VDD -- Supply voltage; 5V (4.7V – 5.3V) 3 VEE -- Contrast adjustment; through a
variable resistor
4 Register Select I RS = 0 for Command register RS = 1 for Data register
5 Read/write I Low to write to the register; High to read from the register
6 Enable I / O Sends data to data pins when a high to low pulse is given
7 DB0 I / O
8-bit data pins
8 DB1 I / O
9 DB2 I / O
10 DB3 I / O
11 DB4 I / O
12 DB5 I / O
13 DB6 I / O
14 DB7 I / O
15 Led+ -- Backlight VCC(5V)
16 Led- -- Backlight Ground (0V)
D714D613D512D411D310D29D18D07
E6RW5RS4
VSS1VDD2VEE3 LCD2 LM016L
16 X 2 ALPHA NUMERIC
B V C Dept. Of Physics and Electronics 8 LCD pin
description
There are two very important registers inside LCD they are
Instruction Command code register and Data register
The RS pin is used for their selection If RS = 0
Instruction Command code register is selected
If RS = 1 The data register is selected RS (Register Select)
B V C Dept. Of Physics and Electronics 9 LCD pin
description
Input allows the user to write information to the LCD or read information from it.
R/ W = 1 when reading R/W = 0 when writing R/ W , read / write
B V C Dept. Of Physics and Electronics 10 LCD pin
description
A high – to – low pulse must be applied to this pin in order to latch the data present on data pins.
This pulse width must be a min of 450ns wise.
E , Enable
B V C Dept. Of Physics and Electronics 11 LCD
Command codes
Code (Hex) Command to LCD Instruction Register 01 Clear display screen
02 Return home
04 Decrement cursor (shift cursor to left) 06 Increment cursor (shift cursor to right) 05 Shift display right
07 Shift display left 08 Display off, cursor off 0A Display off, cursor on 0C Display on, cursor off 0E Display on, cursor blinking 0F Display on, cursor blinking 10 Shift cursor position to left 14 Shift cursor position to right 18 Shift the entire display to the left 1C Shift the entire display to the right 80 Force cursor to beginning to 1st line C0 Force cursor to beginning to 2nd line 38 2 lines and 5x7 matrix
B V C Dept. Of Physics and Electronics 12 LCD
Command codes
Code (Hex)
Command to LCD Instruction Register
38
2 lines and 5x7 matrix
Power Point presentations , Simulators are used in the demostrations of the code
3
B V C Dept. Of Physics and Electronics 13 LCD
Timing diagram and
Program COMNWRT: ;send command to LCD MOV P1,A ;copy reg A to port 1 CLR P2.0 ;RS=0 for command CLR P2.1 ;R/W=0 for write SETB P2.2 ;E=1 for high pulse LCALL DELAY ;give LCD some time CLR P2.2 ;E=0 for H-to-L pulse RET
P2.0 P2.1 P2.2
B V C Dept. Of Physics and Electronics 14 Circuit
diagram
0 1 2 3 5 4 6 7
01234567D714D613D512D411D310D29D18D07
E6RW5RS4
VSS1 VDD2 VEE3 LCD2 LM016L
XTAL2 18
XTAL1 19
30 ALE 31 EA 29 PSEN
9 RST
P0.0/AD0 39 P0.1/AD1 38 P0.2/AD2 37 P0.3/AD3 36 P0.4/AD4 35 P0.5/AD5 34 P0.6/AD6 33 P0.7/AD7 32
P2.7/A15 28 P2.0/A8 21 P2.1/A9 22 P2.2/A10 23 P2.3/A11 24 P2.4/A12 25 P2.5/A13 26 P2.6/A14 27
1 P1.0 2 P1.1 3 P1.2 4 P1.3 5 P1.4 6 P1.5 7 P1.6 8 P1.7
P3.0/RXD 10 P3.1/TXD 11 P3.2/INT0 12 P3.3/INT1 13 P3.4/T0 14
P3.7/RD 17 P3.6/WRP3.5/T1 1615 U1
80C51
RV1(1) 10K
LCD Interfacing with 8051 Microcontroller
TVLNH Prasad
Dept. Of Physics & Electronics Bhavan’s Vivekananda College, Sainikpuri.
Asst. Professor
B V C Dept. Of Physics and Electronics 15 Programming
LCD (Displaying
Single characters)
;To send any of the commands to the LCD, make pin RS=0. For data,
;make RS=1. Then send a high-to-low pulse to the E pin to enable
;the internal latch of the LCD. This is shown in the code below.
;calls a time delay before sending next data/command
;P1.0-P1.7 are connected to LCD data pins D0-D7
;P2.0 is connected to RS pin of LCD
;P2.1 is connected to R/W pin of LCD
;P2.2 is connected to E pin of LCD
ORG 0H
MOV A,#38H ;initialisation of LCD 2 LINES, 5X7 MATRIX LCALL COMNWRT ;call command subroutine
LCALL DELAY ;give LCD some time MOV A,#0EH ;display on, cursor on LCALL COMNWRT ;call command subroutine LCALL DELAY ;give LCD some time MOV A,#01 ;clear LCD
LCALL COMNWRT ;call command subroutine LCALL DELAY ;give LCD some time MOV A,#06H ;shift cursor right
Contiuation …..
B V C Dept. Of Physics and Electronics 16 Programming
LCD (Displaying
Single characters)
(Delay Program)
LCALL COMNWRT ;call command subroutine LCALL DELAY ;give LCD some time MOV A,#84H ;cursor at line 1, pos. 4 LCALL COMNWRT ;call command subroutine LCALL DELAY ;give LCD some time MOV A,#’B’ ;display letter B LCALL DATAWRT ;call display subroutine LCALL DELAY ;give LCD some time MOV A,#’V’ ;display letter V LCALL DATAWRT
LCALL DELAY
MOV A,#’C’ ;display letter C LCALL DATAWRT
LCALL DELAY
AGAIN: SJMP AGAIN ;stay here
DELAY: MOV R3,#50 ; R3 = 50 HERE2: MOV R4,#255 ;R4 = 255
HERE: DJNZ R4,HERE ;stay until R4 becomes 0 DJNZ R3,HERE2
RET Contiuation …..
B V C Dept. Of Physics and Electronics 17 Programming
LCD (Subroutines)
DATAWRT: ;write data to LCD MOV P1,A ;copy reg A to port 1 SETB P2.0 ;RS=1 for data CLR P2.1 ;R/W=0 for write SETB P2.2 ;E=1 for high pulse LCALL DELAY ;give LCD some time CLR P2.2 ;E=0 for H-to-L pulse
RET
COMNWRT: ;send command to LCD MOV P1,A ;copy reg A to port 1 CLR P2.0 ;RS=0 for command CLR P2.1 ;R/W=0 for write SETB P2.2 ;E=1 for high pulse LCALL DELAY ;give LCD some time CLR P2.2 ;E=0 for H-to-L pulse RET
END
B V C Dept. Of Physics and Electronics 18 Programming
LCD (Output)
0 1 2 3 5 4 6 7
01234567D714D613D512D411D310D29D18D07
E6RW5RS4
VSS1 VDD2 VEE3 LCD2 LM016L
XTAL2 18
XTAL1 19
30 ALE 31 EA 29 PSEN
9 RST
P0.0/AD0 39 P0.1/AD1 38 P0.2/AD2 37 P0.3/AD3 36 P0.4/AD4 35 P0.5/AD5 34 P0.6/AD6 33 P0.7/AD7 32
P2.7/A15 28 P2.0/A8 21 P2.1/A9 22 P2.2/A10 23 P2.3/A11 24 P2.4/A12 25 P2.5/A13 26 P2.6/A14 27
1 P1.0 2 P1.1 3 P1.2 4 P1.3 5 P1.4 6 P1.5 7 P1.6 8 P1.7
P3.0/RXD 10 P3.1/TXD 11 P3.2/INT0 12 P3.3/INT1 13 P3.4/T0 14 P3.7/RD 17 P3.6/WRP3.5/T1 1615 U1
80C51
RV1(1) 10K
LCD Interfacing with 8051 Microcontroller TVLNH Prasad
Dept. Of Physics & Electronics Bhavan’s Vivekananda College, Sainikpuri.
Asst. Professor
Power Point presentations , Simulators are used in the demostrations of the code
4
B V C Dept. Of Physics and Electronics 19 Sending
information to LCD using
MOVC instruction
ORG 300H
MYCOM: DB 38H,0EH,01,06,84H,0 ; commands and null MYDATA: DB “Hello”,0
ORG 00h
AGAIN: MOV DPTR,#MYCOM
C1: CLR A
MOVC A,@A+DPTR
LCALL COMNWRT ;call command subroutine LCALL DELAY ;give LCD some time INC DPTR
JZ SEND_DAT SJMP C1
SEND_DAT: MOV DPTR,#MYDATA
D1: CLR A
MOVC A,@A+DPTR
LCALL DATAWRT ;call command subroutine LCALL DELAY ;give LCD some time INC DPTR
JZ AGAIN SJMP D1
SJMP AGAIN ;stay here
B V C Dept. Of Physics and Electronics 20 Sending
information to LCD using
MOVC instruction
0 1 2 3 5 4 6 7
01234567D714D613D512D411D310D29D18D07
E6RW5RS4
VSS1 VDD2 VEE3 LCD2 LM016L
XTAL2 18
XTAL1 19
30 ALE 31 EA 29 PSEN
9 RST
P0.0/AD0 39 P0.1/AD1 38 P0.2/AD2 37 P0.3/AD3 36 P0.4/AD4 35 P0.5/AD5 34 P0.6/AD6 33 P0.7/AD7 32
P2.7/A15 28 P2.0/A8 21 P2.1/A9 22 P2.2/A10 23 P2.3/A11 24 P2.4/A12 25 P2.5/A13 26 P2.6/A14 27
1 P1.0 2 P1.1 3 P1.2 4 P1.3 5 P1.4 6 P1.5 7 P1.6 8 P1.7
P3.0/RXD 10 P3.1/TXD 11 P3.2/INT0 12 P3.3/INT1 13 P3.4/T0 14
P3.7/RD 17 P3.6/WRP3.5/T1 1615 U1
80C51
RV1(1) 10K
LCD Interfacing with 8051 Microcontroller TVLNH Prasad
Dept. Of Physics & Electronics Bhavan’s Vivekananda College, Sainikpuri.
Asst. Professor
B V C Dept. Of Physics and Electronics 21 Outcome
We learned how to interface real – world devices such as LCD
We described the operation modes of LCD How to program the LCD by sending data or
command to it via its interface to the 8051 We got an idea how to work with Alpha
numeric LCD
B V C Dept. Of Physics and Electronics 22
Thank You
Simulators used in this presentation are
Jubin Mitra 8085 simulator for the lab experiments demonstrations…
Dia0.97.2 is used during the classes which is a program for drawing structured
diagrams….
https://vlab.amrita.edu/index.php
Physics experiments in this tool are used for practice sessions …
http://www.olabs.edu.in/?pg=topMenu&id=40
This is a free version, which contains ads. The full documentation is available at ecstudiosystems.com/help
Electric Circuit Studio is a set of tools used for building electronic circuits, SPICE simulation, and calculation of circuits. These tools are complemented by the information center containing resources, connector pinouts and short interactive book explaining basic electrical theorems, laws and circuits. It is a useful application for all electronics hobbyists, students, or other people
with an interest in electronics.
https://phet.colorado.edu/
this simulator is having windows as well as android versions
https://www.falstad.com/circuit/
https://circuitverse.org/simulator http://eleceng.dit.ie/dsp/elab/