16/03/2019
Alphanumeric Dot Matrix LCDS
Microcontroller Applications
The alphanumeric dot matrix liquid crystal display
can be considered to be an intelligent peripheral.
These displays can be either one, two or four line
modules which utilise a 5x7 or 5x10 dot matrix
display format.
LCD Display Back lit versions are available for low light viewing.
These LCD modules are capable of displaying the
printable ASCII character set.
Alphanumeric Dot Matrix LCDS Alphanumeric Dot Matrix LCDS
The peripheral’s processor does all the necessary
house keeping.
Displays stored characters.
Appends any new characters.
Scrolls the display.
Pushes old characters out of the display buffer when
full.
This house keeping is an advantage, as these are
processes that the host processer (ATmega Micro)
doesn’t need to service.
3 4
Hitachi HD44780
The Hitachi HD44780 is the LCD we will be
using in our classes.
This LCD is the most common type available
on the market.
Manufacturers who build LCD displays, often
build them following the specifications set by
the HD44780.
5 6
1
16/03/2019
LCD Micro Integration LCD Commands
An LCD Display will be connected to a The LCD Display consist of a command set.
microcontroller’s data ports. – Home the Cursor
– Home the Cursor and clear the display
– Move the Cursor
Eg PORTA or PORTH – Scroll Characters
– Blank Display
It needs a number of data lines and a – Set Cursor Type
number of control lines. – Blink Cursor
– Data Lines: Can either send ASCII characters to – Number of Lines
be displayed, or LCD operational commands. – Font Type
7 8
LCD Control Lines LCD Control Lines
The control lines are used to drive the LCD. The control lines are used to drive the LCD.
– RS (Register Select Input) – R/W (Read / Write Input)
Determines whether the data lines are read as ASCII Determines the data direction.
characters or as operational commands. – Writing data to the LCD is basically sending characters to
– In command mode, the LCD in a state where it’s waiting the display.
to receive commands to set the conditions of the display – LCDs can also Read data from the display. So if there
- In ASCII mode, the LCD in a state where it’s going to already is data on the screen, it can be read back into
send characters to display on the screen. the microcontroller. (This feature is rarely used).
9 10
LCD Control Lines Pinouts
The control lines are used to drive the LCD. Pin number Name Function Description
1 VSS power GND CHECK FIRST!!!
– E (Clock / Enable) 2 VDD power +5 V CHECK FIRST!!!
3 VO power contrast
4 RS input register select
Synchronises the data. 5 R/W’ input read / write
6 E input enable
– Enables the clock of the LCD to be triggered so that the
7 D0 I/O data (LSB)
display can execute the instructions that have been given 8 D1 I/O data
to it. 9 D2 I/O data
10 D2 I/O data
11 D4 I/O data
12 D5 I/O data
13 D6 I/O data
14 D7 I/O data (MSB)
15 A power back light anode
11 12 16 k power back light cathode
2
16/03/2019
4 or 8 Bit Modes
The LCD Display can be used in either 4 or 8 bit
modes.
This represents the amount of Data Lines you wish
to connect from the LCD display to the
Microcontroller.
– Eg: 8 Bit Mode will use all 8 Pins on a PORT on the Micro.
– 4 Bit Mode will use only the high nibble 4 Pins on a PORT
Why have 4 and 8 Bit Modes?
13 14
4 or 8 Bit Modes Sending 8 Bit Data
8 Bit Mode is easy to setup. The entire 8 pin Command / Instruction
PORT from the micro is connected up to the – D7-0 needs to have the value of the command.
LCD display. 0x01 for Clear Display
4 Bit Mode is more complex and consumes – RS needs to be ‘0’
more operational time. However, it only – R/W needs to be ‘0’
uses 4 Pins from an 8 Bit PORT. – E needs to be pulsed on ‘1’ for a minimum of
450ns.
So in 4 Bit Mode, we have another spare 4
pins on the micro which we can still use!
15 16
Sending 8 Bit Data 8 Bit Connection
PA0 D0
Write an ASCII Character PA1 D1
– D7-0 needs to have the value of the command. PA2 D2
0x31 for the character ‘1’ PA3 D3
PA4 D4
– RS needs to be ‘1’ PA5 D5
– R/W needs to be ‘0’ PA6 D6
PA7 D7
– E needs to be pulsed on ‘1’ for a minimum of
450ns. PH6 E
Wired to GND already RW
PH5 RS
17 18
3
16/03/2019
Sending 4 Bit Data Sending 4 Bit Data
Command / Instruction Write and ASCII Character
– In 4 Bit mode, only the most significant 4 data bits are – RS needs to be ‘1’
used. – R/W needs to be ‘0’
– RS needs to be ‘0’ – DA7-4 needs to have the high nibble of the ASCII Character.
– R/W needs to be ‘0’ Letter ‘J’ = 0x4A
– D7-4 needs to have the high nibble of the command. 0x4X for ‘J’
Clear Display = 0x01 – E needs to be pulsed on ‘1’ for a minimum of 450ns.
0x0X for Clear Display – DA7-4 needs to have the low nibble of the ASCII Character.
– E needs to be pulsed on ‘1’ for a minimum of 450ns. Letter ‘J’ = 0x4A
– D7-4 needs to have the low nibble of the command. Shift Register Left 4 Bits.
Shift left the register by 4 bits. 0xAX for ‘J’
0x1X for Clear Display – E needs to be pulsed on ‘1’ for a minimum of 450ns.
– E needs to be pulsed on ‘1’ for a minimum of 450ns.
19 20
D0 to D3 (8 Bit)
4 Bit Connection Shield Setup
PH6 E
Wired to GND already RW
PH5 RS Soldier Terminal Pins onto LCD
PA4 D4 Board
D0 to D3
PA5 D5 These are the 8 Bit Pins
PA6 D6
PA7 D7
D4 to D7 (8 & 4 Bit)
Use connections labelled ‘S’ for
Signal.
21 22
4 Bit Instability 4 Bit Instability Instructions
Start
Due to the timing delays required for initialising the Initialise Micro
LCD Display in 4 Bit mode, the microcontroller boots Delay for 20ms
and sends commands too early for the display. Clear RS, RW and E
Set LCD to 8 Bit mode
We need to ‘delay’ the micro to allow the LCD Delay for 10ms
Set LCD to 8 Bit mode
Display to complete it’s boot sequence. Delay for 10ms
Also, a set of commands is required to ‘trick’ and Set LCD to 8 Bit mode
Delay for 1ms
then ‘tell’ the LCD to display to change from 8 Bit Set LCD to 4 Bit mode
mode to 4 Bit. Now Send 4 Bit commands. Eg Function Set. Cursor. Clear Display
End
Instability issues do occur quite often with this
problem.
23 24
4
16/03/2019
Next Lecture: Using External Interrupts
We will look into using external peripherals
which will signal the microcontroller that an
event has occurred.
25