EMBEDDED HARDWARE DESIGN. Tutorial Interfacing LCD with Microcontroller /I

Similar documents
Character Based LCD Module Interface.

Lab Experiment 9: LCD Display

LCD. Configuration and Programming

LCDs. Embedded Systems Interfacing. 20 September 2011

Product Information. Features. Table of Contents EA DIP162 DN3LW EA DIP162 DHNLED EA DIP162 DNLED EA DIP162J DN3LW

Chapter 4. Address. data. Input / Output Programming. Simplified Z80 System Architecture. Memory. program. data. Z80 I/O Programming

Laboratory 3 Working with the LCD shield and the interrupt system

Embedded Systems and Software. LCD Displays

Lab-3: LCDs Serial Communication Analog Inputs Temperature Measurement System

ARM HOW-TO GUIDE Interfacing GLCD with LPC2148 ARM

INTERFACING 16 2 LCD WITH 8051

Liquid Crystal Displays

Dragon12 LCD Displays Hantronix_CLD.PDF data sheet (Dragon12 CD-ROM) Dragon12 LCD Display. The Dragon12 board has a 16 character x 2 line display

Lecture (09) PIC16F84A LCD interface LCD. Dr. Ahmed M. ElShafee

SC1602LC 16x2 Large Characters RS232 LCD Module. User s Manual. Large Viewing Area 99mm x 24mm. Large Character Size. 4.84mm x 9.66mm.

Dragon12 LCD Displays Huang Sections 7.8 Hantronix_CLD.PDF data sheet (Dragon12 CD-ROM) ATD_10B8C Block User Guide. Dragon12 LCD Display

Dragon12 LCD Displays Hantronix_CLD.PDF data sheet (Dragon12 CD-ROM) Dragon12 LCD Display. The Dragon12 board has a 16 character x 2 line display

Application Note. Connecting standard LCD modules to. the MB90670/5 series. History 01 th Feb. 97 MM V1.0 started 28 th June 00 TKa V1.

LCM NHD-0440CI-YTBL. User s Guide. (Liquid Crystal Display Module) RoHS Compliant. For product support, contact NHD CI- Y- T- B- L-

SWITCH 10 KILOHM RESISTOR 220 OHM RESISTOR POTENTIOMETER LCD SCREEN INGREDIENTS

DOT MATRIX CHARACTER LCD MODULE USER S MANUAL

LABORATORY MANUAL Interfacing LCD 16x2, Keypad 4x4 and 7Segment Display to PIC18F4580

Character LCD Interface for ez80acclaim! MCUs

FPGA Interfacing of HD44780 Based LCD Using Delayed Finite State Machine (FSM)

SC1602LCPro-YG ( Yellow Green Backlight ) SC1602LCPro-B ( Blue Backlight ) Large Character Size ( 4.88x9.66 mm )

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interfacing External Devices using Embedded C Module No: CS/ES/22

Cab Bus Communications Protocol

Item Symbol Standard Unit Power voltage VDD-VSS Input voltage VIN VSS - VDD

Lab 5: LCD and A/D: Digital Voltmeter

中显液晶 技术资料 中显控制器使用说明书 2009年3月15日 北京市海淀区中关村大街32号和盛大厦811室 电话 86 010 52926620 传真 86 010 52926621 企业网站.zxlcd.com

LCM NHD-0440AZ-FSW -FBW. User s Guide. (Liquid Crystal Display Character Module) RoHS Compliant FEATURES

16COM / 40SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD

melabs Serial LCD Firmware Version 1.0 2/7/07

Interfacing GLCD(128x64) with PIC16F877A

Fujitsu Microelectronics Europe Application Note MCU-AN E-V11 F²MC-16FX FAMILY 16-BIT MICROCONTROLLER MB96380 LC-DISPLAY APPLICATION NOTE

KNJN I2C bus development boards

MOPS/386A (P389) MOPS/MZ and MOPSlcdMZ (PMZ1) MOPS/520 (P489) DOT Matrix Display on PC/104 Products

16COM/40SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD

AUTOMATIC RESTAURANT ORDER SYSTEM USING ZIGBEE

6.1. EE 109 Unit 6. LCD Interfacing

ATMEGA32 MUSIC PLAYER

LCD MODULE 1x mm INCL. CONTROLLER HD 44780

AVR Intermediate Development Board. Product Manual. Contents. 1) Overview 2) Features 3) Using the board 4) Troubleshooting and getting help

Mega128-Net Mega128-Net Mega128 AVR Boot Loader Mega128-Net

Display Real Time Clock (RTC) On LCD. Version 1.2. Aug Cytron Technologies Sdn. Bhd.

CAN / RS485. Product Description. Technical Reference Note. Interface Adapter. Special Features

ELCT501 Digital System Design Winter Tutorial #11 FPGA Complete Design Flow with LCD Example

Interfacing Z8 Encore! XP MCUs with an I 2 C-Based Character LCD

ECE 4510/5530 Microcontroller Applications Week 9

Application Note. Interfacing to a Graphics LCD from PSoC. Summary This Application Note describes how to control a graphic LCD in a PSoC application.

melabs Serial LCD Firmware Version 1.1 3/5/07

The EE 109 LCD Shield

Keywords Digital IC tester, Microcontroller AT89S52

Lab 5: LCD and A/D: Digital Voltmeter

Kpad. Technical Manual

Application Note. Title: Incorporating HMT050CC-C as a Digital Scale Display by: A.S. Date:

AXE131 OLED/LCD DRIVER KIT

16COM/80SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD

CONTENTS. dspicpro4 KEY FEATURES 4 CONNECTING THE SYSTEM 5 INTRODUCTION 6

Page 1 of 7. Samtron/Samsung 20S204DA2

Graphical LCD Display Datasheet EB

Parallel Display Specifications Revision 1.0

Sample F4T 32-bit Modbus RTU Packet

EMBED2000+ Data Sheet

17. Serial communication - I 2 C

The modules in this lab room are 4 line by 16 character display modules. The data sheet/users manual for the module is posted on My.Seneca.

KNJN I2C bus development boards

17. I 2 C communication channel

Micro RWD Quad-Tag Reader

OLED DISPLAY MODULE. Application Notes. DD-12833YW-1A with EVK board PRODUCT NUMBER

SSD1803. Product Preview. 100 x 34 STN LCD Segment / Common Mono Driver with Controller

Module 2: Introduction to AVR ATmega 32 Architecture

UNIT 6 LCD (LIQUID CRISTAL DISPLAY) SCREENS

Lab 3 LCD Mar

BV4218. I2C-LCD & Keypad. Product specification. December 2008 V0.a. ByVac 2006 ByVac Page 1 of 9

Dual Interface LCD Display Controller

The EE 109 LCD Shield

JE-AN ELECTRONICS CO.,LTD. Spec. No: WG240128A

TN-192. Bar Graph shows analog trends on a dot-matrix character LCD module. Introduction. LCD Module Basics. Custom Characters

Chapter 9. Input/Output (I/O) Ports and Interfacing. Updated: 3/13/12

LCD Module with I2C / Serial Interface and Keypad Control «LCD I2C/Serial» User s Guide. Copyright 2008 IMS

A LCD display with ethernet interface

CONTENTS BIGAVR2 KEY FEATURES 4 CONNECTING THE SYSTEM 5 INTRODUCTION 6

1602 SMART LCD DISPLAY MODULE HCMODU0122

LAMPIRAN I (LISTING PROGRAM)

8051 Training Kit Lab Book

LCD2041 Technical Manual. Revision: 2.1

Locus Engineering Inc

// sets the position of cursor in row and column

TL0313. LCD driver IC. Apr VER 0.0. lsi. ( 5.5V Specification ) 65COM / 132SEG DRIVER & CONTROLLER FOR STN LCD. TOMATO LSI Inc.

SPECIFICATIONS FOR LIQUID CRYSTAL DISPLAY

34COM/60SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD

8051 Intermidiate Development Board. Product Manual. Contents. 1) Overview 2) Features 3) Using the board 4) Troubleshooting and getting help

16COM / 80SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD

USER S GUIDE ATM4004A

Serial communications with SPI

LCD MODULE 4x mm INCL. CONTROLLER SSD1803

Golander Peristaltic Pump MODBUS Communication Instruction

E-Module: GLCD+RTC Combo Datasheet

Hitachi Europe Ltd. ISSUE : app026/1.0 APPLICATION NOTE DATE : 20/9/94

Transcription:

EMBEDDED HARDWARE DESIGN Tutorial Interfacing LCD with Microcontroller 2009-10/I LCD (Liquid Crystal Display) has become very popular option for displaying in Embedded Applications. Since they are very cheap and easy to interface with microcontrollers, they are widely found in devices like telephones, vending machines, washing machines, toys etc. LCD comes in several varieties i.e. 16*2, 20*2, 20*4 etc. These different LCD varieties can display different number of characters i.e. 16*2 can display 32 characters at a time. Introduction The LCD module that we will be using is 16*2 JHD162A. This model has 2 lines and 16 rows of display blocks. Each block can be used to display 1 character. So there are total 32 such blocks. One block has 8*5 pixels. Depending on which pixel is ON and which is OFF we can display several Alpha-Numeric characters. This model also has a green backlight, which helps us to see the display even in dark. In reality this module consists of a controller chip, a segment driver chip, LCD display and some passive components. There are total 16 pins in the LCD module. Pin Number Pin Name Pin Function Connection to ATMega16 1 Vss GND Supply 2 Vcc +5V LCD Power 3 Vee Contrast Adjustment 4 RS Register Signal Select(Command/Data) PC7 5 R/W Read/Write Select PC6 6 E Enable (read/write enable) PC5 7 DB0 Data pin - 8 DB1 Data pin - 9 DB2 Data pin - 10 DB3 Data pin - 11 DB4 Data pin PC0 12 DB5 Data pin PC1 13 DB6 Data pin PC2 14 DB7 Data pin PC3 15 LED+ Backlight Power +5V 16 LED- Backlight Power GND These connections have already been made to the USB BootLoader Kit so when you insert the LCD module properly, the connections are made as mentioned in the Table.

While using LCD, we can think a simple analogy for its operation. Each of the 32 blocks is a memory, as soon as we write an ASCII number into one of these 32 memory locations the corresponding character is displayed on that block. The function of displaying the character after decoding the data is done by an onboard controller chip. Block Diagram of LCD Module In reality the LCD module consists of several memory locations apart from the 32 dedicated for the display. Since LCD module can be used in several ways we need to select one of these modes and configure the LCD for this mode. The various operations that we need to perform are:- 1. Write to LCD memory to display data 2. Configure LCD module by writing commands to memory location 3. Read data in Memory locations 4. Perform some special operations like Clear Screen, Bring Cursor to starting position etc The various pins that are provided like RS, R/W etc acts as a way to do all these operations.the 3 control pins have important functions 1. RS The LCD has 2 modes of operation Character and Instruction. Depending on its value the data on the data line (DB0-DB7) is treated as either command or character. If RS is LOW then the data on DB0-DB7 is an Instruction and if RS is HIGH then data on data line is character 2. Enable The pin acts like a clock for the LCD module, when there is a falling clock edge then the data on the data lines is taken in by the LCD module and processed. 3. R/W - This pin identifies if the operation to be performed is a read or write. If R/W = 0 write operation R/W = 1 read operation RS = 0 Command RS = 1 Character E -> falling edge, data processed by LCD Module To be able to correctly perform an operation we have to assign the values of these 3 control pins and data lines in a proper sequence.

Let s look at one example i.e. displaying a character by writing to its memory location. The steps are:- 1. Set the data on the data lines i.e. the 8 bits of data are assigned to each of the 8 pins (DB0-DB7) like LSB -> DB0 and MSB ->DB7. 2. Set RS pin i.e. make RS pin HIGH. 3. Clear RW pin i.e. make RW pin LOW. 4. Toggle E i.e. make E high, wait for some time, make E low. Another example, if we want to write a command, the steps are:- 1. Set command on the data lines i.e. the 8 bits of data are assigned to each of the 8 pins (DB0- DB7) like LSB -> DB0 and MSB ->DB7. 2. Clear RS pin i.e. make RS pin LOW. 3. Clear RW pin i.e. make RW pin LOW. 4. Toggle E pin i.e. make E high, wait for some time, make E low. A very important point to note is that the sequence of these steps can be done manually using toggle switches only and the microcontroller is only used because the repetitive steps need not be performed manually again and again. In the above examples we used 8 data pins and 3 pins for control signal i.e. total 11 pins of the microcontrollers are used. An efficient way is to use 4 data pins instead of 8. In case we are using 4 data lines, the higher nibble is send on these 4 data lines first and then we send the lower nibble on the 4 data lines. In this case we are using 7 lines of the microcontroller. This mode is called the 4-bit transfer mode. By default when we are using 4-bit mode the data transfer happens only through DB4-DB7 (the LCD pins) whereas DB0-DB3 are unconnected. In the datasheet of LCD module we find a table shown below. This is the Instruction set of the LCD Module JHD 162A. Let s look at first row - SCREEN CLEAR. This Instruction tells the LCD module to return the cursor to the starting position i.e. (1, 1) and also to clear the screen of any characters. The code for this instruction is 0x01. If we want the LCD module to clear the screen, then we should write the command 0x01 to the LCD Module. Similarly we have DISPLAY SWITCH instruction. It selects options for the display like Turning the display on/off, turning the cursor on/off, turn blinking of cursor on/off. If we want to turn display on we set D (DB2) to 1, to turn cursor on we make C (DB1) 1 and to select blinking cursor B (DB0) is set to 1. Hence the final code of Display switch is 0x0F. If we write a command 0x0F, then the LCD module will perform the above mentioned 3 actions.

Finally we will look at FUNCTION SET- this Instruction selects the 4-bit/8-bit mode (DL =0 means 4-bit transfer mode selected whereas DL=1 means 8-bit mode selected), N selects the number of lines in LCD (N=1 means a 2-line display), F select font type (in our case we have 5*7 type font which means F=0). Hence to select a 4-bit mode, 2-line display and 5*7 font the value of FUNCTION SET becomes 0x28. If Instruction INPUT SET is not given then by default after every character write, the cursor moved to next block. [But this does not implies that after writing to (16, 1) the cursor will automatically come to (1, 2)!!! you will have to set the address of cursor to (1,2) yourself.] Instruction Set of LCD Module

0x80 0x81 0x82 0x83 0x8D 0x8E 0x8F 0xC0 0xC1 0xC2 0xCD 0xCE 0xCF Memory Address of Display Block on the LCD Module The Memory addresses of blocks on LCD display are as shown above. So if you send a Command say 0x80, then the cursor will reach to the first block i.e. (1,1) similarly if you send a command 0xC5, then cursor will reach location (5,2) and so on. In this way you can move cursor to any position. To make the LCD work with microcontroller you will proceed in this way:- 1. All the functions of the LCD will be written in a separate file named lcd.h, so that whenever you need to use the LCD functionalities, you will just include this header file lcd.h, and call the functions written in lcd.h to display or configure LCD module. 2. In the lcd.h you should have the following functions:- (a) LCD_init(void) (b) LCD_Send(char c, unsigned char DC) (c) LCD_Send_String(char *s) (d) LCD_GotoXY(unsigned int x, unsigned int y) (e) LCD_Print(int data, unsigned int x, unsigned int y) LCD_init This function initializes the LCD module by setting 4-bit data transfer mode, turning the display on, turning the cursor on and setting the cursor to blink. LCD_Send This function takes two arguments c, DC. Here c is the data which we want to write and DC identifies this data to be a command or character (data) i.e. if DC=1 => Data if DC=0 => Command LCD_Send_String This function takes a string as input and after parsing it,send character by character to LCD_Send() function, to print the character on by one on the display. LCD_GotoXY This function takes the cursor to position (X, Y) in the display. LCD_Print This function takes 3 argument i.e. data (a numeric value), and x, y coordinate of the starting position of the printing of the data. First this function calls LCD_GotoXY to move cursor to (x, y). Then the function calls itoa() function and send the resultant string to LCD_Send_String().

The Pseudo code of the functions are written as follows:- LCD_init(void) Clear RS pin, clear RW pin. Write a command to clear the screen Write a command to turn display on, turn cursor on, turn blinking of cursor on. Write a command to select 4-bit mode, 2 line display, 5*7 font. // when we say write a command it means that the function LCD_Send is called. LCD_Send(char c, unsigned char DC) Break the 8 bit value of char c into 2 parts, upper nibble and lower nibble. If it is command Write upper nibble on data line Clear RS pin, clear RW pin Write lower nibble on data line Clear RS, clear RW pin If it is Data Write upper nibble on data line Set RS pin, Clear RW pin Write lower nibble on data line Set RS pin, Clear RW pin // you will need to put delay while toggling E i.e. Set E, put 1 ms delay, Clear E. LCD_Send_String(char *s) Break string s into characters, say c1, c2, c3 LCD_Send(c1), LCD_Send(c2),..

LCD_GotoXY(unsigned int x, unsigned int y) If it is line 1, send the command corresponding to address of 1 st line. If it is line 2, send the command corresponding to address of 2 nd line LCD_Print(int data, unsigned int x, unsigned int y) Call LCD_GotoXY(x,y) Break integer data into character and call LCD_Send_String().