mp lab04 - lcd.pdf

11
Microprocessors Lab Manuals COMSATS Institute of Information Technology, Islamabad 1 Lab 04 Introduction and implementation of LCD interfacing on ATMEGA16 microcontroller Instructor Asma Ramay Department of Electrical Engineering CIIT, Islamabad

Upload: sobia-shakeel

Post on 15-Jul-2016

40 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: MP Lab04 - LCD.pdf

Microprocessors Lab Manuals

COMSATS Institute of Information Technology, Islamabad 1

Lab 04

Introduction and implementation of LCD interfacing on

ATMEGA16 microcontroller

Instructor

Asma Ramay

Department of Electrical Engineering CIIT, Islamabad

Page 2: MP Lab04 - LCD.pdf

Microprocessors Lab Manuals

COMSATS Institute of Information Technology, Islamabad 2

Objectives:

Introduction to LCD interfacing with microcontroller.

Implementation of LCD interfacing with ATMEGA16 microcontroller.

Tools:

VMLab, Winavr, Proteus ISIS . Liquid Crystal Display (LCD) The most commonly used Character based LCDs are based on Hitachi's HD44780 controller or other which are compatible with HD44580. Below given is figure of such an LCD.

Page 3: MP Lab04 - LCD.pdf

Microprocessors Lab Manuals

COMSATS Institute of Information Technology, Islamabad 3

LCD Pinout: The table below provides the description of the pins:

Page 4: MP Lab04 - LCD.pdf

Microprocessors Lab Manuals

COMSATS Institute of Information Technology, Islamabad 4

LCD Interfacing: R/W pin is used select between the read or write operation. You can either send command or either send the required data to display on the LCD. Since same pins from D0 to D7 are used for both command and data, RS pin is used to identify between the command and data. To send command to LCD, we will first set RS pin to zero. If we want to send data to LCD, we will set the RS pin as high. EN is enable pin which is used to synchronize the whole operation of sending data or command to LCD. The LCD will not read any pins for command or data until we give high to low transition to enable pin. This is important because we want to make sure that the data on the LCD pins is right before LCD reads it. By enable pin we can control when LCD should read the data on its pins. The above procedure for reading from or writing to LCD is illustrated with the help of following timing diagrams:

Page 5: MP Lab04 - LCD.pdf

Microprocessors Lab Manuals

COMSATS Institute of Information Technology, Islamabad 5

Page 6: MP Lab04 - LCD.pdf

Microprocessors Lab Manuals

COMSATS Institute of Information Technology, Islamabad 6

LCD Command Set: The table below summarizes command set of Hitachi 44780 based LCDs

The detailed description of some of these commands is given below:

Page 7: MP Lab04 - LCD.pdf

Microprocessors Lab Manuals

COMSATS Institute of Information Technology, Islamabad 7

LCD Initialization: The following initialization procedure is mentioned by the manufacturer of this LCD:

The table below provides address for various display locations on a 16X4 LCD:

Finally ASCII chart containing character code for most commonly used characters is given below:

Page 8: MP Lab04 - LCD.pdf

Microprocessors Lab Manuals

COMSATS Institute of Information Technology, Islamabad 8

Microcontroller coding for LCD interfacing: It is suggested that you make three subroutines in addition to main subroutine in your code. The subroutine for sending command to the LCD will look like:

The subroutine for sending character to the LCD will look like:

Page 9: MP Lab04 - LCD.pdf

Microprocessors Lab Manuals

COMSATS Institute of Information Technology, Islamabad 9

The subroutine for initializing the LCD will look like:

Page 10: MP Lab04 - LCD.pdf

Microprocessors Lab Manuals

COMSATS Institute of Information Technology, Islamabad 10

In Lab Task: Interface a 16X4 LCD to the ATMEGA16 microcontroller and display your name on it.

Page 11: MP Lab04 - LCD.pdf

Microprocessors Lab Manuals

COMSATS Institute of Information Technology, Islamabad 11

Post Lab Task: Interface a keypad and LCD to ATMEGA16. Scan the keypad for pressed key and display it on LCD.