0% found this document useful (0 votes)
33 views4 pages

4.2 8051 - 16x2 Generic LCD Display

The document discusses interfacing an LCD display to an 8051 microcontroller. It provides the pin descriptions of the LCD unit, typical LCD command codes, steps to send commands and data to the LCD, and an example assembly language program to display 'Happy Diwali' on the LCD.
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)
33 views4 pages

4.2 8051 - 16x2 Generic LCD Display

The document discusses interfacing an LCD display to an 8051 microcontroller. It provides the pin descriptions of the LCD unit, typical LCD command codes, steps to send commands and data to the LCD, and an example assembly language program to display 'Happy Diwali' on the LCD.
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/ 4

Microcontrollers & Applications (MU-Sem.

6-E&TC) 4-10 8051 Interfacing & Applications

4.2 8051 | 16x2 Generic LCD Display

Univ. Q. Interface LCD to 8051 and write assembly language program to display message
“HELLO” on it. (MU - Dec. 17, 10 Marks)

Univ. Q. Explain LCD interfacing with 8051 and write assembly language program to display
message “HI” on it. Draw the connection diagram of 8051 with LCD.
(MU - May 19, 10 Marks)
Univ. Q. Interface LCD to 8051 and write a program to display the message “LCD” on it.
Draw the connection diagram of 8051 with LCD. (MU - Dec. 19, 10 Marks)

LCD displays are far more useful than 7 segment LEDs because they can be used to display text adequately.
Complex charecters like W, M, K, Q etc. can be easily displayed using a matrix of pixels .
In most cases 5x7 matrix is used to display one character, 5 columns and 7 rows.
An LCD Unit comes with an LCD display and its own controller. The entire unit is interfaced with 8051 as
shown :

Pin Description of the LCD unit

Pin Number Function


1 Ground
2 Vcc
3 Brightness (Contrast) Adjust
4 Register Select | 0: Command | 1: Data
5 Read Write Select | 0: Write | 1: Read
6 Latch Enable | Falling Edge Latches Command/ Data
7-14 8-bit Command or Data Value

Typical LCD Command Codes

Command Value Function

38 H Initialise 16 character, 2 rows 5x7 matrix display layout

0F H Display ON, Cursor ON, Cursor Blinking

01 H Clear Display (Clears the On-Chip DRAM of the LCD Unit)

06 H Cursor Increment Mode (Moves Cursor from Left to Right)

80 H Cursor Home Command ()

Tech-Neo Publications...........Where Authors inspire innovation .....A SACHIN SHAH Venture


Microcontrollers & Applications (MU-Sem. 6-E&TC) 4-11 8051 Interfacing & Applications

Steps to send Command or Data to the LCD Unit

Steps for sending Command Steps for sending Data

Put out the command on the port (P1) Put out the data on the port (P1)
Make Register Select = 0 (Command) Make Register Select = 1 (Data)
Make R/W = 0 (As we are writing) Make R/W = 0 (As we are writing)
Make Latch Enable = 1 Make Latch Enable = 1
Make Latch Enable = 0 (Falling Edge) Make Latch Enable = 0 (Falling Edge)
Call a delay of 10 milliseconds Call a delay of 10 milliseconds

Interface a 16x2 line LCD Unit to 8051 and hence write a program to display “Happy Diwali”

Interface

Fig. 4.2.1

Algorithm

Create Look up table of ASCII codes of Happy Diwali at say 0400H


Make DPTR point to the table
Initialise LCD unit by sending command codes: 38H, 0FH, 01H, 06H, 80H
Initialise R7 with Loop count of 12 (Happy Diwali has 12 characters including the space)
Initialise R6 with index of 0
Using R6 as index, obtain ASCII code of every character from look up table into A
Send this code as Data to the LCD unit
Tech-Neo Publications...........Where Authors inspire innovation .....A SACHIN SHAH Venture
Microcontrollers & Applications (MU-Sem. 6-E&TC) 4-12 8051 Interfacing & Applications

Increment Index R6
Decrement Loop count R7 and Loop till all characters re displayed

Program : ORG 0400H

Table DB “Happy Diwali”


Initialise : MOV A, #38H
ACALL Command ; Call the “Command” function with the command
; value 38H in A register
MOV A, #0FH
ACALL Command ; Call the “Command” function with the command
; value 0FH in A register
MOV A, #01H
ACALL Command ; Call the “Command” function with the command
; value 01H in A register
MOV A, #06H
ACALL Command ; Call the “Command” function with the command
; value 06H in A register
MOV A, #80H
ACALL Command ; Call the “Command” function with the command
; value 80H in A register
MOV DPTR, #0400H ; Initialise DPTR as a pointer to starting of the
; look up table = 0400H
MOV R7, #0CH ; Initialise R7 with Loop Count of 12
MOV R6, #00H ; Initialise R6 with Index of 0
Display: MOV A, R6 ;A Index from R6
MOVC A, @A+DPTR ;A ASCII code from Look Up Table
ACALL Data ; Call the “Data” function with the ASCII value in A
; register
INC R6 ; Increment the Index
DJNZ R7, Display ; Loop till all 12 characters are displayed
Here: SJMP Here ; End the program
Command : MOV P1, A ; Put Command value in P1 from A Register
CLR P2.0 ; Make Register Select = 0 for Command

Tech-Neo Publications...........Where Authors inspire innovation .....A SACHIN SHAH Venture


Microcontrollers & Applications (MU-Sem. 6-E&TC) 4-13 8051 Interfacing & Applications

CLR P2.1 ; Make Read/Write Select = 0 for Write


SETB P2.2 ; Make Latch Enable = 1
CLR P2.2 ; Make Latch Enable = 0 (This produces a Falling Edge)
RET
Command : MOV P1, A ; Put Command value in P1 from A Register
CLR P2.0 ; Make Register Select = 0 for Command
CLR P2.1 ; Make Read/Write Select = 0 for Write
SETB P2.2 ; Make Latch Enable = 1
CLR P2.2 ; Make Latch Enable = 0 (This produces a Falling Edge)
ACALL Delay ; Call a delay of 10 milliseconds
RET
Data: MOV P1, A ; Put Data value (ASCII Code) in P1 from A Register
SETB P2.0 ; Make Register Select = 1 for Data
CLR P2.1 ; Make Read/Write Select = 0 for Write
SETB P2.2 ; Make Latch Enable = 1
CLR P2.2 ; Make Latch Enable = 0 (This produces a Falling Edge)
ACALL Delay ; Call a delay of 10 milliseconds
RET

4.3 8051 | Relay and DC Motor

Introduction to DC Motor

DC motors are widely used at places where constant speed is required. They are very easy to
interface and program.
Besides, they can easily switch between clockwise and anticlockwise motion. Their typical usage is
in fans, blowers, conveyor belts, pumps, lifts etc.
A DC motor simply requires two pins to control its movements.
By sending a 01 or a 10 on these pins we can move the motor clockwise or anticlockwise. Sending
a 11 or a 00 on the two pins will stop the motor.

Need for a relay – L293D

DC motors are controlled by our µC 8051.


8051 however sources/sinks current around 15mA at voltage 5V.

Tech-Neo Publications...........Where Authors inspire innovation .....A SACHIN SHAH Venture

You might also like