chapter 7 intelligent lcd display

27
Chapter 7: Intelligent LCD Display LCD displays are widely used in many applications like mobile phones, robotics, DVD players, Measurement instruments etc. Intelligent LCD displays complete ASCII character set and even graphics. These are easily connected with micro controllers and microprocessors. LCD displays are complete embedded system in them, because it include micro controller, RAM and ROM. The intelligent displays are of two types a) Text Display b) Graphics Display Text display can display all character set. And graphics display can show any graphics display can show any graphics because they are interfaced pixel wise. In recent your the LCD is finding widespread use replacing LEDs (seven segment LEDs or other multi segment LEDs). This is due to the following reasons: a. The declining prices of LCDs b. The ability to display the numbers, characters and graphics. This not possible in LEDs, which can display numbers and few characters. c. Incorporation of a refreshing controller into LCD, Thereby relieving the CPU of the task of refreshing the LCD. In contract the LED must be refreshed by the CPU (or in same other way) to keep displaying the data.

Upload: pikeshjain

Post on 16-Apr-2017

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Chapter 7 Intelligent LCD Display

Chapter 7: Intelligent LCD Display

LCD displays are widely used in many applications like mobile phones, robotics, DVD players, Measurement instruments etc. Intelligent LCD displays complete ASCII character set and even graphics. These are easily connected with micro controllers and microprocessors. LCD displays are complete embedded system in them, because it include micro controller, RAM and ROM. The intelligent displays are of two types

a) Text Display b) Graphics Display

Text display can display all character set. And graphics display can show any graphics display can show any graphics because they are interfaced pixel wise.In recent your the LCD is finding widespread use replacing LEDs (seven segment LEDs or other multi segment LEDs). This is due to the following reasons:

a. The declining prices of LCDsb. The ability to display the numbers, characters and graphics. This

not possible in LEDs, which can display numbers and few characters.

c. Incorporation of a refreshing controller into LCD, Thereby relieving the CPU of the task of refreshing the LCD. In contract the LED must be refreshed by the CPU (or in same other way) to keep displaying the data.

The interfacing of LCD is quite difficult. But we will try to make it simple and let us explain it for you.

We will learn how to interface the text intelligent LCD display. These displays are available in the market of 16 column and one Row and more than one Row displays.

Here is the block diagram of a LCD display.

Micro controller: it is the brain of LCD display. This is handling the all working of the LCD.

Data RAM: This RAM is storing the ASCII values of corresponding characters will be displayed on the LCD. For each column there is one

Page 2: Chapter 7 Intelligent LCD Display

location in the RAM. When we will store the ASCII value at that location than it’s corresponding character will be displayed on the screen.

Code RAM: This store the binary pattern according to the Character. ROM: This RAM store the binary pattern which is according to the Pixels of LCD. The ASCII values of Characters will be given to the data register.BF (Busy Flag): It indicate the internal working of the LCD. It show whether LCD is busy in any operation or not. If BF =0 (LCD is idle we can proceed for next operation)If BF=1 (LCD is busy we can’t proceed for next operation and we have to wait unless operation completes).

Description of PINs is given below.

Vcc, Vss and Vee

While Vcc and Vss provide +5V and ground, respectively, Vee is used for controlling LCD contract.

]RS (Register Select): The RS pin is used to select DR or CR. If RS=CR register is selected, allowing the user to send a command such as clear display, curser at home etc. If RS=1, DR resister is selected, allowing the user to data be display on the LCD.

R/W (Read/Write): When R/W =0, Read operation.

EN (Enable): The enable pin is used by the LCD to latch binary bits available on its data pins. When data is supplied to data pins, a negative edge is applied to this pin so that the LCD latches in the data present at the data pins. This pulse must be a minimum of 450 ns wide.There should be positive edge at EN pin when read operation is required. D7 –D0:

This is 8-bit pins. D7-D0 are used to send information to the LCD or read the contents of the LCD‘s internal registers. BK-LED: These pins are used to give the supply to the backlight of the LCD display. So, that content of the LCD display can be viewed in the dark.

Page 3: Chapter 7 Intelligent LCD Display

Pin Diagram is shown below 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16GND Vcc C RS R/W EN D0 D1 D2 D3 D4 D5 D6 D5 LED+LED-

The List of Commands is shown in the:

Page 4: Chapter 7 Intelligent LCD Display

Action Rs RW D7 D6 D5 D4 D3 D2 D1 D0 Description

Clear 0 0 0 0 0 0 0 0 0 0 1 Clear complete display, sets RAM address counter at 0

Return 0 0 0 0 0 0 0 0 1 X Home cursor, shift string to the original position, but do not cler RAM contents.

Entry mode set 0 0 0 0 0 0 0 1 1/D S Sets cursor move direction and specifies shift of display. These operation are performed during data write and read S=0, cursor S =1, screen I/D =1 increment (right shift) I/D =0, decrement (left shift)

Display on /off control 0 0 0 0 0 0 1 D C B Set on /off of entire display (D) , cursor on/off ©, and blink of cursor position character (B) D=1, Display ON =0 , Display OFF C=1, Cursor ON =0, Cursor OFF B=1, Blinking ON =0 Blinking OFF Cursor or Display Shift 0 0 0 0 0 1 S/C R/L - - Moves cursor and shift display without changing DD RAM contents

Function set 0 0 0 0 1 DL N F - - Sets interface data length (DL) number of display lines (L) and character from (F) DL =1,8 buts/Char DL-0, 4 bits /Char N=1,2 line display N=0, 1 line display F==1 Big Font (10*5) F=0, Small font (7*5)

Set CG RAM Address 0 0 0 1 AGC Sets Code RAM address

Set DD RAM 0 0 1 A6 A5 A4 A3 A2 A1 A0 Sets Data RAM address.

Read Busy Flag & Address 0 1 BF A6 A5 A4 A3 A2 A1 A0 Reads busy flag (BF) indicating internal operation is being performed and read address counter content.

Page 5: Chapter 7 Intelligent LCD Display

Programme: No0 EQU 0COH NO1 EQU 0F9H…NO9 EQU 90H; Main Programme ORG 0LOOP: MOV P1No0ACALL DELAYONEMOV p1,NO1ACALL DELAYONE

Page 6: Chapter 7 Intelligent LCD Display

SJMP LOOP DELAYONEE: MOV R0,#0EHLOOPR:MOV A ,#0FFHLOOPB:NOP NOPMOV B,#0FFHLOOPA:DJNZ B, LOOPADJNZ R0 0E0H, LOOPBDJNZ R0, LOOPRRETEND

Experiment 5: Interfacing of 8 keys and 7-Segment LED Display with microcontroller 8051

Objective: In this experiment we will learn how to use more then one key and how to identify each key stroke. Here according to pressed key corresponding no will be displayed on the LED display connected with microcontroller.

Circuit: The circuit is shown in the figure. Here we are interfacing the 7 segment LED display with Port 1. The Let Display is given Vcc form pin no 3 and 8, which are anode pins. For keys we are using push button keys which

Page 7: Chapter 7 Intelligent LCD Display

are connected with port 2. Here we are using resistors of 220 with each key. When user will press any key then that particular pin become LOW and we will identify it. If not writing the software in such a way that until any key is pressed because of previous action control will not move ahead. And when it is confirm that all keys are open then scanning of keys will starts.

The content of the P2 is copied to the accumulator, after that each bits of the accumulator is checked in a sequence starting form bit 0 to bit7. The flow chart indicate this thing. Programme: The programme is given below; in this coding we are equating the Pattern for nos 0 to 9 as given in the previous experiment.

Coding: ; Coding for 8 Keys Dip Switch Led Display Interfacing NO0 EQU 0C9HNO7 EQU 0F8HKEY EQU P2DATA EQU P1KEY0 EQU P2.0KEY1 EQU P2.1KEY2 EQU P2.2KEY3 EQU P2.3 KEY4 EQU P2.4KEY5 EQU P2.5KEY6 EQU P2.6KEY7 EQU P2.7KEY8 EQU P2.8

Page 8: Chapter 7 Intelligent LCD Display

KEY9 EQU P2.9ORG 0000H MOV KEY,#0FFH ;configuring input MOV DATA,#0FFH ;default displayLOOP:MOV A, KEY Read keysCJNE A , #0FFH,LOOP;WAIT UNTILL USER DO NOT PRESS THE KEYWAIT.MOV A, KEYCJNE A, #0FFH, NEXTSJMP WAITNEXTACALL DELAY20MMOV A, KEY CJNE A, #0FFH.NEXT1SJMP WAITNEXT1:JB ACC.0 SKEY1MOV DATA,#No0AJMP LOOP SKEY1:JB ACC.1, SKEY2MOV DATA, #NO1AJMP LOOPSKEY2:JB ACC.2,SKEY3MOV DATA,#NO2AJMP LOOP SKEYS3;JB ACC.3, SK1;Y4MOV DATA, #NO3AJMP LOOPSKEY4; JB ACC,4, SKEYSMOV DATA,#NO4AJMP LOOP

Page 9: Chapter 7 Intelligent LCD Display

So, there are following combinations of certain functions

Command Code (HEX) Description 01H Clear display screen 02H Return home 04H Decrement cursor (shift cursor to left) 06H Increment cursor (shift cursor to left)05H Shift display right07H Shift display left08H Display off, cursor off0AH Display off, cursor on 0CH Display on, cursor off 0EH Display on, cursor not blinking 0FH Display on, cursor blinking 10H Shift cursor position to left 14H Shift cursor position to right18H Shift the entire display to the leftICH Shift the entire display to the right 80H Force cursor to beginning of 1st line C0H Force cursor to beginning of 2nd line 38H 2 lines and 5*7 matrix

Page 10: Chapter 7 Intelligent LCD Display

Interfacing of LCD can be easily interfaced with the MC. For that we connect port lines this example RS of LCD is RW of LCD is connected with P3.3 EN of LCD is connected with P3.4 Data line of LCD is connected with P1 of MC. In the experiment of LCD we will show you how to display any character on the LCD. We are using 2 line LCD display.The detail of experiment is shown on the next page.

Experiment Interfacing of Intelligent LCD Display with microcontroller 8051Objective: In this experiment we will learn how to use LCD display and how to write Command and Display routines to send command Byte and Character byte on the LCD. We will display “Hello World “on the LCD. Circuit: The idea is for shown is that previous chapter. Flow Chart: The idea is for program is that first we have to do settings of the LCD and then we will send each character on the LCD.

StartLCD Setting: No of Lines, Data Length and Font Size

LCD Setting: Display On, Cursor On/Off and Blinking On. Off

LCD Setting: Cursor Movement Setting

LCD Setting: Clear LCD

Send starting Address

Send Characters

Page 11: Chapter 7 Intelligent LCD Display

End

Command DATA<= Command Bvte

RS <=0

RW <=0EN <=-‘ive EdgeCheck Busy Flag BF=0return DataCommand DATA<= Command Bvte

RS <=1

RW <=0

EN <=-‘ive EdgeCheck Busy Flag BF =1=0return

Page 12: Chapter 7 Intelligent LCD Display

Org 0000hlcdisp:mov a, #38h;mov a, #30hacall command mov a,#0ehacall a, #06h acall command mov a, #01h acall command mov a, #80hacall command mov a,#Wacall display mov a, #’e’acall display mov a,#’1’ acall displaymov a,#’c’ acall display mov a, #’o’ acall displaymov a, #’m’mov a, #’e’acall display;mov a, #0c0hmov a, #88h acall commandmov a,#’T’acall display

Page 13: Chapter 7 Intelligent LCD Display

mov a, #’o’ acall display acall of; Next Line

mov a ,#38hacall command mov a, #0ehacall command mov a,#01hacall commandmov a,#0c0hacall command mov a,#06hacall commandmov a,#’C’acall displayacall offmov a,#’E’acall displayacall off mov a, Tacall offmov a,#’P’acall displayacall offmov a,#A’acall displayacall off;mov a,#86h;mov a, #0c6h; acall commandmov a,#’’acall displayacall offmov a,#’S’acall displayacall off

Page 14: Chapter 7 Intelligent LCD Display

mov a’#Y’acall displayacall off mov a, #’S’acall display

acall off mov a,#Tacall display acall offmov a, #Eacall displayacall offmov a,#Macall display acall offmov a, #`S`acall display acall off

here: sjmp here ;************************Delay subroutine off;mov b, #0ffhloopb:mov a, #0ffhloopa:dec a nopnopnopnopnopnopjnz loopa djnz 0f0h, loopbret;LCD strobe subroutines

command:acall ready

Page 15: Chapter 7 Intelligent LCD Display

mov pl,aclr p3.2clr p3.3setb p3.4clr p3.4ret

Page 16: Chapter 7 Intelligent LCD Display

display:acall readymov p1,asetb p3,2clr p3.3setbp3.4clr p3.4retready:clr p3.4mov p1,#0ffhclr p3.2setb p3.3wait:clr p3.4setb p3.4jb p1.7,wait clr p3.4retend

Page 17: Chapter 7 Intelligent LCD Display

Experiment 7: Interfacing of Matrix Key board microcontroller 8051Objective: The purpose of this experiment is to use a matrix key board and the corresponding character on the LED display.

Circuit:The Matrix keyboard circuit is shown in the Figure. Here we are using the keyboard of 4x4 Keys.

Here Rows are connected with P3 and Columns are connected with P2 as shown in the figure.

Led display is connected with P1 of the microcontroller. The matrix keyboard is interfaced by using the scanning technology. Here we doning this by software.

Flow Chart: The flow chart is shown in the below. First we are sending a default display over to the LED display which is simple ‘-‘. Then we are going to check whether any key is pressed or not? If is so then we are waiting until any one of the key is pressed. The first loop is for this purpose.

In second loop we are going to check whether any key is pressed or not here we wait until any key is pressed. For this we have to send ‘0’ at every row and check the status of the P2.3-P2.0 lines. If these then are at logic HIGH then it means that no any key is pressed otherwise if any key is pressed then we identify the pressed key. For that we start scanning each row. We serially make Rows to level 0 by making other 1.Ex:- we will send FEH at P1 then Row 0 become LOW and then will check the status of the P2.3-P2.0 lines,If P2.0=0 :i.e. Key0 is pressed If P2.1=0 :i.e. Key1 is pressedIf P2.2=0 :i.e. Key2 is pressed If P2.3=0 :i.e. Key3 is pressed

And if all lines are at 1, this means that no any key is pressed then we send FDH at the ROWS, so that ROW2 will become LOW, and scan each column. By this we can get to know about the status of key4 to key 7and so on.

Page 18: Chapter 7 Intelligent LCD Display

The Programme:

; Coding For Matrix key board Interfacing DATA EQU P1ORG 0000HMOV P2, #0FFH ; configuring input MOV DATA,#FDH ;default display MOV P3, #0F0HLOOP:MOV A, P2 Read keys ORL A #0FHCJNE,A, #0FFH,LOOP; WAIT UNTILL USER DO NOT PRESS THE KEYWAIT:MOV A, P2 Read keysORL A, #0F0HCJNE A, #0FFH,NEXTSJMP WAIT NEXT: ACALL DELAT20MMOV A, P2 Read keys ORL A, #0F0HCJNE A, #0FFH, NEXT1SJMP WAITNEXT1:MOV P3,# 11111110BMOV A, P2ORL A, #0F0HCJNE A, #0FFH, ROW1MOV P3,#11111101BMOV A,P2ORL A, #0f0HCJNE A, #0FFH, ROW2MOV P3,#11111011BMOV A, P2ORL A, #0F0HCJNE A, #0FFH, ROW3AJMP ROW4; scanning of row 1ROW1: JB ACC.0, SKEY1MOV DATA, #NO0AJMP LOOP

Page 19: Chapter 7 Intelligent LCD Display

SKEY1:JB ACC.1, SKEY2MOV DATA, #NO1AJMP LOOPSKEY2:JB ACC.2, SKEY3MOV DATA,#NO2AJMP LOOPSKEY3:MOV DATA, #NO3AJMP LOOP

; scanning of row 2JB ACC.0 SKEY5MOV DATA, #NO4AJMP LOOPSKEY5:JB ACC.1 SKEY6MOV DATA, #NO5AJMP LOOPSKEY6:JB ACC.2, SKEY7MOV DATA, #NO6AJMP LOOPSKEY7:MOV DATA, #NO7AJMP LOOP;scanning of row3JB ACC.0,SKEY9MOV DATA, #NO8AJMP LOOPSKEY9:JB ACC.1,SKEYAMOV DATA, #NO9AJMP LOOPSKEYA:JB ACC.2,SKEYBMOV DATA,#NOAAJMP LOOPSKEYB:MOV DATA, #NOBALMP LOOP

Page 20: Chapter 7 Intelligent LCD Display

; scanning of row 4JB ACC.0 SKEYDMOV DATA, #NOCAJMP LOOPSKEYD:JB ACC.1 SKEYEMOV DATA, #NODAJMP LOOPSKEYE:JB ACC.2, SKEYFMOV DATA, #NOEAJMP LOOPSKEYF:MOV DATA, #NOFAJMP LOOP

Page 21: Chapter 7 Intelligent LCD Display