1 A Note on Character LCD Displays There are many display devices used by the hobbyists. LCD displays are one of the most sophisticated display devices used by them. Once you learn how to interface it, it will be the easiest and very reliable output device used by you! More, for micro controller based project, not every time any debugger can be used. So LCD displays can be used to test the outputs. Obviously, for last possibility, you need to know how to use this stuff pretty well. Note 1: We have sub divided this article for easy navigation as s hown below:- 1. Pin Configuration 2. Block Diagram 3. Control and Display Commands 4. LCD Interfacing 5. LCD Initialization Note 2: If you are interested in reading about working of LCD–we have an excellent article for you –Working of Liquid Crystal Displays (LCD) Hitachi has set up a mile stone by its LCD controller IC. All the LCD displays use the same, or any one of the IC s based upon the architecture introduced by Hitachi. Ok, one minute, all I‟m talking about is the character LCD display and not Graphical LCD Display. Most of the LCD Displays available in the market are 16X2 (That means, the LCD displays are capable of displaying 2 lines each having 16 Characters a), 20X4 LCD Displays (4 lines, 20 characters). It has 14 pins. It uses 8lines for parallel data plus 3 control signals, 2 connections to power, one more forcontrast adjustment and two connections for LED back light. Let us have a look to typical pin configurations: Pin Configuration table for a 16X2 LCD character display:- Pin NumberSymbolFunction1Vss Ground Terminal 2Vcc Positive Supply 3Vdd Contrast adjustment 4RS Register Select; 0→Instruction Register, 1→Data Register5R/W Read/write Signal; 1→Read, 0→ Write6E Enable; Falling edge 7DB0 Bi-directional data bus, data transfer is performed once, thru DB0 to DB7, in the case of interface data length is 8-bits; and twice, through DB4 to DB7 in the case of interface data length is 4-bits. Upper fourbits first then lower four bits. 8DB1 9DB2 10DB3 11DB4 12DB5 13DB6 14DB7 15LED-(K) Back light LED cathode terminal 16LED+(A) Back Light LED anode terminal
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
There are many display devices used by the hobbyists. LCD displays are one of the most sophisticateddisplay devices used by them. Once you learn how to interface it, it will be the easiest and very reliableoutput device used by you! More, for micro controller based project, not every time any debugger can beused. So LCD displays can be used to test the outputs. Obviously, for last possibility, you need to knowhow to use this stuff pretty well.
Note 1: We have sub divided this article for easy navigation as shown below:-
1. Pin Configuration 2. Block Diagram 3. Control and Display Commands 4. LCD Interfacing 5. LCDInitialization
Note 2: If you are interested in reading about working of LCD – we have an excellent article for you –Working of Liquid Crystal Displays (LCD)
Hitachi has set up a mile stone by its LCD controller IC. All the LCD displays use the sameor any one of the IC s based upon the architecture introduced by Hitachi.
Ok, one minute, all I‟m talking about is the character LCD display and not Graphical LCD Display.
Most of the LCD Displays available in the market are 16X2 (That means, the LCD displays are capableof displaying 2 lines each having 16 Characters a), 20X4 LCD Displays (4 lines, 20 characters). It has14 pins. It uses 8lines for parallel data plus 3 control signals, 2 connections to power, one more forcontrast adjustment and two connections for LED back light. Let us have a look to typical pinconfigurations:
Pin Configuration table for a 16X2 LCD character display:-
Pin Number Symbol Function 1 Vss Ground Terminal2 Vcc Positive Supply3 Vdd Contrast adjustment4 RS Register Select; 0→Instruction Register, 1→Data Register 5 R/W Read/write Signal; 1→Read, 0→ Write 6 E Enable; Falling edge7 DB0
Bi-directional data bus, data transfer is performed once, thru DB0 to
DB7, in the case of interface data length is 8-bits; and twice, throughDB4 to DB7 in the case of interface data length is 4-bits. Upper four bits first then lower four bits.
8 DB19 DB2
10 DB311 DB412 DB513 DB614 DB715 LED-(K) Back light LED cathode terminal16 LED+(A) Back Light LED anode terminal
Now that was all about the signals and the hardware. Let us come to data, signals and execution.
LCD accepts two types of signals, one is data, and another is control. These signals are recognized bythe LCD module from status of the RS pin. Now data can be read also from the LCD display, by pullingthe R/W pin high. As soon as the E pin is pulsed, LCD display reads data at the falling edge of the pulseand executes it, same for the case of transmission.
LCD display takes a time of 39-43µS to place a character or execute a command. Except forclearing display and to seek cursor to home position it takes 1.53ms to 1.64ms. Any attempt to send anydata before this interval may lead to failure to read data or execution of the current data in some devices.Some devices compensate the speed by storing the incoming data to some temporary registers.
LCD displays have two RAMs, naming DDRAM and CGRAM. DDRAM registers in which position which character in the ASCII chart would be displayed. Each byte of DDRAM represents eachunique position on the LCD display. The LCD controller reads the information from the DDRAM anddisplays it on the LCD screen. CGRAM allows user to define their custom characters. For that purpose,address space for first 16 ASCII characters are reserved for users. After CGRAM has been setup to
display characters, user can easily display their custom characters on the LCD screen.
Now the instruction can be divided mainly in four kinds
1) Function set instructions
2) Address set instructions
3) Data transfer instructions with internal RAM
4) Others
Details of the Instructions
1) Read Data from RAM
RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB
1 1 D7 D6 D5 D4 D3 D2 D1 D0
Read 8bit binary data from DDRAM/CGRAM
The selection of RAM is set by the previous address set instruction. If the address set instruction ofRAM is not performed before this instruction, the data that is read first is invalid, because the directionof AC is not determined. If the RAM data is read several times without RAM address set instruction before read operation, the correct RAM data from the second, but the first data would be incorrect, asthere is no time to transfer RAM data. In case of DDRAM read operation, cursor shift instruction playsthe same role as DDRAM address set instruction; it also transfers RAM data to the output data registers.
After read operation, the data address counter is automatically increased or decreased by 1 according tothe entry mode. After CGRAM read operation, display shift may not be executed properly.
*In case of RAM write operation, AC is increased or decreased by 1 like that of the read operation. Inthis time AC indicates the next address position, but the previous data can only by the read instruction.
Write binary 8bit data to DDRAM/CGRAM. The selection of CGRAM or DRAM is set by the previousaddress set instruction; DDRAM address set, CGRAM address set. RAM set instruction can alsodetermine the AC direction to RAM.
After write operation, the address is automatically increased or decreased by 1 according to the entrymode.
By making this read out operation, it can be determined if the LCD is performing some internaloperation or not. If Busy Flag (BF) is high, some internal operation is going inside the LCD at that particular moment. To perform further operation the data source (e.g. micro controller) must wait for theBF to go low. Here, the address counter value can also be read.
Set DDRAM address to AC, this instruction makes DDRAM data available from MPU. In 1-line displaymode, DDRAM address rangers from “00H” to “4FH”. In 2-line display mode, DDRAM address in thefirst line ranges from “00H” to “27H”, and DDRAM address in the 2nd line is from “40H” to “67H”.
RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 0 0 0 0 1 S/C R/L X X
Without writing or reading the display data, shifting right/left cursor position or display.
This instruction is made to correct or search or display data. During 2-line display mode, cursor movesto the 2nd line after the 40th digit of the 1st line.
When displayed data is shifted repeatedly, each line shifts individually.
When display shift is performed, the contents of the address counter are not changed.
8) Display On/Off Control
RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 0 0 0 0 0 1 D C B
This instruction controls Display, Cursor and cursor blink.
D: Display On/Off control bit
D=‟1‟ means entire display is turned on
D=‟0‟ means entire display is turned off. But Display data remains in DDRAM.
C: cursor On/Off control bit
C=‟1‟ turns on the cursor
C=‟0‟ turns off the cursor. But I/D register retains the data
B: Cursor blink On/Off control bit
B=‟1‟ makes cursor blink periodically.
B=‟0‟ stops the cursor to blink and cursor looks steady if the Cursor is turned on.
This instruction sets the address counter to „00H‟, and returns the cursor to the first column of first line.And if display is shifted previously, this instruction shifts this too. The DDRAM contents don‟t changein this instruction.
Clear all the display data by writing “20H” (ASCII code of „space‟ character) to all DDRAM address,AND set value DDRAM address counter (AC) to “00H”. It returns the cursor to the first column of firstline and sets the entry mode to increment mode (I/D=‟1‟).
8-bit and 4-bit interfacing of LCD
Now the question is how to display data in the LCD or give command to it. There is two modes of data
transfer are supported by LCD displays. One is 4bit mode, another is 8 bit mode. To transfer data In 8 bit mode, first put your data in the 8bit bus, then put command in the command bus and then pulse theenable signal.
To send data in 4bit mode; first put upper 4bit in the 4 bit data bus connected to 4MSB pins ofLCD display, then put control signals in the control bus, then pulse the E pin once. Next put the lower 4 bit in the data bus and pulse the E pin again. Here is a flowchart simply describing it.
We are pretty familiar how to send data. But before displaying characters on the LCD display, it must beconfigured first. To configure an LCD display, four command words must be sent to LCD in either 4 bitmode, or in 8 bit mode. The commands are:
Here is a flow chart of the initialization sequence of LCD display.
LCD Initialization
Displaying Custom Characters
All these character display modules got the feature to create 8 user defined characters (ASCII Codes0…7) in addition to the ROM fixed codes.
1.) The command “CG RAM Address Set” defines the ASCII code (Bit 3, 4, 5) and the dot line (Bit 0, 1,2) of the new character. Example demonstrates creating ASCII code “00H”.
2.) Doing 8 times the write command “Data Write” defines line by line the new character. 8th bytestands for the cursor line.
3.) The new defined character can be used as a “normal” ASCII code (0…7); use with “DD RAMAddress Set” and “Data Write”.
Now let us look up the character set that can be displayed using the LCD Displayed
0×00 0×10 0×20 0×30 0×40 0×50 0×60 0×70 0×80 to 0xd0 0xE0 0xF00×00 CG1 0 @ P ` p
CUSTOMREGIONAL
CHARACHTERS
Α 0×01 CG2 ! 1 A Q a q Ä0×02 CG3 “ 2 B R b r Β θ 0×03 CG4 # 3 C S c s Ε 0×04 CG5 $ 4 D T d t Μ Ω 0×05 CG6 % 5 E U e u Σ ϋ 0×06 CG7 & 6 F V v Ρ Σ 0×07 CG8 7 G W g w G π 0×08 CG1 ( 8 H X h x √
0×09 CG2 ) 9 I Y i y ¯¹ y0x0A CG3 * : J Z j z J0x0B CG4 + ; K [ k {0x0C CG5 , < L ¥ l |0x0D CG6 - = M ] m }0x0E CG7 . > N ^ n → 0x0F CG8 / ? O _ o ← █
CG→ CGRAM User Defined Character
Custom Regional characters vary from manufacturer to manufacturer. The Greek letters may or may notappear. It too depends upon the design.