0% found this document useful (0 votes)
120 views29 pages

CH 4. Standard Single Purpose Processors: Peripherals: Part E: Display & Keyboard Interface

This document discusses interfaces for displays and keyboards in embedded systems. It covers keyboard interfaces including switch debouncing, telephone keyboard grids, and keypad controllers. It also covers touchscreen position sensing and display interfaces including seven-segment, multiple digit, and driver ICs. Algorithms are presented for scanning keyboard grids and multiplexing digit displays.

Uploaded by

Maha Soe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views29 pages

CH 4. Standard Single Purpose Processors: Peripherals: Part E: Display & Keyboard Interface

This document discusses interfaces for displays and keyboards in embedded systems. It covers keyboard interfaces including switch debouncing, telephone keyboard grids, and keypad controllers. It also covers touchscreen position sensing and display interfaces including seven-segment, multiple digit, and driver ICs. Algorithms are presented for scanning keyboard grids and multiplexing digit displays.

Uploaded by

Maha Soe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

EE414 Embedded Systems

Ch 4. Standard Single Purpose


Processors: Peripherals
Part E: Display & Keyboard Interface

Byung Kook Kim


Dept of EECS
Korea Advanced Institute of Science and Technology
Overview

Part E: Display & Keyboard Interface


„ 4.41 Keyboard Interface
„ 4 42 Touchscreen
4.42
„ 4.43 Display
p y Interface
„ 4.44 LCD Display
„ 4.45 Bit Manipulation

Embedded Systems, KAIST 2


4.41 Keyboard Interface
„ A. Switch
„ Two-position switch
„ Common device: Alone,, in groups,
g p , and keyboards
y
„ Interfacing with pull-up resistor
„ Switch open: Out = Vcc
„ S i h closed:
Switch l d Out
O = GND

„ Three-position switch
„ Common, Normally open, Normally closed.

Embedded Systems, KAIST 3


Switch Debouncing
„ Switch bounce
„ Just after the contact position is changed, there is a
brief period during which the position of the switch is
indefinite.
„ If the contacts are coming together,
together they may contact
and then separate several times.
„ A switch must be debounced to multiple contacts
caused by mechanical bouncing:

Embedded Systems, KAIST 4


Switch Debouncing (II)
„ Debouncing solution (I)
„ Delay
„ Test the switch both before and after the delay
delay.
„ If they disagree, the switch is moving.
„ If they agree, the switch is probably in a stable position.
„ This delay is generally from 1 to about 20 ms.
„ Depending on the switch structure.
„ D l routine:
Delay ti

delay: sub #1,


#1 R7 ; Enter with delay count in R7
bne delay ; Keep counting until 0
rts ; Return from subroutine

Embedded Systems, KAIST 5


Switch Debouncing (III)
„ Debouncing solution (II)
„ Hardware debouncing ->
„ Set-reset flip-flop
p p with two NOR gates
g
„ Three-position switch
„ Assume that the bounces are not so terrible that the switch
recontacts the side it already has left.
left

Embedded Systems, KAIST 6


B. Telephone Keyboard
„ Standard telephone pushbutton keyboard ->
>
„ 12 buttons: 0 – 9, *, #
„ 12 parallel
ll l input
i t bits
bit are required.
i d

Embedded Systems, KAIST 7


C. Telephone Keyboard Grid
„ Reduce wires: m*n switches using only m+n wires
„ 12 switches with 4+3=7 wires
„ 80 switches with 10+8=18
10 8 18 or 9+9=18
9 9 18 wires!

Embedded Systems, KAIST 8


Program for Keyboard Grid
„ Notes
„ Read one column at a time
„ Force vertical line to be low & read horizontal lines.
„ Al ith
Algorithm
„ Make PA2-0 = 011
„ Read horizontal lines. If there is a zero, a key is down in this column.
„ If not, PA2-0 = 101. If there is a zero, a key is down in this column.
„ If not, PA2-0 = 110. If there is a zero, a key is down in this column.
„ D b
Debouncing
i : If a kkey iis found
f dddown, save the
th code,
d delay,
d l and
d
repeat the reading process.
„ False Key: If the newly-read code does not match the old code,
save the
h new coded as the h old
ld code
d andd go back
b k to Step 1 for
f
another try.
„ If the newly-read code does match the old code, go on to
search table for the value of the key.
Embedded Systems, KAIST 9
Program for Keyboard Grid (II)
„ Codes for the keyboard grid (Search table)
Key PA6 - 0 Hex
0 0 1 1 1 1 0 1 3D
1 1 1 1 0 1 1 0 76
2 1 1 1 0 1 0 1 75
3 1 1 1 0 0 1 1 73
4 1 1 0 1 1 1 0 6E
5 1 1 0 1 1 0 1 6D
6 1 1 0 1 0 1 1 6B
7 1 0 1 1 1 1 0 5E
8 1 0 1 1 1 0 1 5D
9 1 0 1 1 0 1 1 5B
* 0 1 1 1 1 1 0 3E
# 0 1 1 1 0 1 1 3B
Embedded Systems, KAIST 10
Bidirectional Keyboard Grid
Algorithm
„ Advantages
„ Only two read operations without
column scanning

„ Algorithm
„ Make
M k PA2-0
PA2 0 output andd PA6-3
PA6 3 as input
i
„ Force PA2-0 low and read to x.
„ Make PA6
PA6-33 output and PA2
PA2-0
0 input
„ Force PA6-3 low and read to y.
„ Combine x and y into one byte. The
result is the same code as the table in
slide 9.

Embedded Systems, KAIST 11


Keypad Controller
„ An array of switches is read by an encoder
encoder.
„ N-key rollover remembers multiple key depressions.

N1
N2
N3 k_pressed
N4

M1
M2
M3
M4 4
key_code key_code

keypad controller

N=4, M=4
Embedded Systems, KAIST 12
4.42 Touchscreen
„ Includes input and output device.
„ Input device is a two-dimensional voltmeter:

Embedded Systems, KAIST 13


Touchscreen Position Sensing

ADC

voltage
l

Embedded Systems, KAIST 14


4.43 Display Interface
„ A Display of digits
A.
„ Seven-segment display ->
„ 16-segment
16 segment display
„ Array of dots

„ Types
„ Common anode ->
„ Common cathode

Embedded Systems, KAIST 15


Display Interface (II)
„ Multiple digit seven-segment
Multiple-digit seven segment display
„ Ex: 8 digits ->
„ 7 x 8 = 56 wires
„ 7 + 8 = 15 wires
„ 4 + 3 = 7 wires

Embedded Systems, KAIST 16


Display Interface (III)
„ Algorithm
Given c[i], i=0, 1, …, 7
For digit d=0,
d=0 1,
1 …, 7
Output digit selection d
Output 7-segment display c[d]
Delay
Turn off 7-segment
7 segment display
End of d

„ Ghost elimination
„ Place turn-on and turn-off side by side after the move
„ (Include red lines as above).

Embedded Systems, KAIST 17


Display Interface (IV)
„ Driver ICs - ULN2803
„ 8-bit 50V 500mA TTL-input NPN darlington drivers.
„ The drivers need no power supply; the VDD pin is the common
cathode of the eight integrated protection diodes.
„ The eight NPN Darlington connected transistors in this family of
arrays are ideally suited for interfacing between low logic level
digital circuitry (such as TTL, CMOS or PMOS/NMOS) and the higher
current/voltage requirements of lamps, relays, printer hammers or
other similar loads for a broad range of computer,
computer industrial,
industrial and
consumer applications.
„ All devices feature open
open–
collector outputs and
free wheeling clamp diodes
for transient suppression
suppression.

Embedded Systems, KAIST 18


Display Interface (V)
„ Driver ICs – uDN2981
„ 8-CHANNEL SOURCE DRIVERS
„ Recommended for high-side
high side switching applications that benefit
from separate logic and load grounds, these devices encompass
load supply voltages to 80 V and output currents to -500 mA.
„ These 8-channel source
drivers are useful for
interfacing
g between low-
level logic and high-current
loads.
„ Typical loads include relays,
relays
solenoids, lamps, stepper
and/or servo motors, print
hammers and LEDs.
hammers, LEDs
Embedded Systems, KAIST 19
Display Interface (VI)
„ B. Dot matrix display
„ English 1 x 20 characters
„ 7 x 100 dot matrix display
„ Korean 1 x 20 characters
„ 16 x 320 dot matrix display

Embedded Systems, KAIST 20


Display Interface (VII)
„ C Color display
C.
„ Red & Green LED: red, green,
yellow
„ Color LED: red, green, blue
LEDs

„ 1024 x 768 True color


„ 1024 x 768 x 3 bytes for RGB

Embedded Systems, KAIST 21


4.44 LCD Display
„ LCD (liquid crystal display)
„ Advantages
„ Thinner and lighter
„ Draw much less power than cathode ray tubes (CRTs)
„ LCD History
„ Liquid crystals were first discovered in 1888, by Austrian
botanist Friedrich Reinitzer.
„ Reinitzer observed that when he melted a curious cholesterol-
like substance (cholesteryl benzoate), it first became a
cloudy liquid and then cleared up as its temperature rose.
„ Upon cooling, the liquid turned blue before finally crystallizing.
„ Eighty years passed before RCA made the first experimental
LCD in 1968.
Embedded Systems, KAIST 22
LCD Display (II)
„ Principles on LCD
„ Liquid crystals are closer to a liquid state than a solid.
„ It takes a fair amount of heat to change a suitable substance
f
from a solid
lid into
i t a liquid
li id crystal,
t l and
d it only
l takes
t k a little
littl more
heat to turn that same liquid crystal into a real liquid.
„ Very sensitive to temperature: used to make thermometers
and mood rings
rings.

„ Depending on the temperature and particular nature


off a substance,
b t liliquid
id crystals
t l can be
b in
i one off severall
distinct phases.
„ Nematic phase: Affected by electric current.
„ A particular sort of nematic liquid crystal, called twisted
nematics (TN), is naturally twisted.
„ Applying an electric current to these liquid crystals will untwist
them
h to varying
i degrees,
d depending
d di on the h current's
' voltage.
l
Embedded Systems, KAIST 23
LCD Display (III)
„ LCD Systems
„ Common-plane-based LCDs
„ Good for simple displays that need to show the same information over
and over again.
again
„ Watches and microwave timers
„ Passive-matrix LCDs (TN, STN LCDs)
„ Use a simple
U i l gridid to
t supply
l the
th charge
h to
t a particular
ti l pixel
i l on the
th
display.
„ The liquid crystal material is sandwiched between the two glass
substrates and a polarizing film is added to the outer side of each
substrates,
substrate.
„ The rows or columns are connected to integrated circuits that control
when a charge is sent down a particular column or row.
„ The row and column intersect at the designated pixel, and that
delivers the voltage to untwist the liquid crystals at that pixel.
„ Drawbacks of the passive-matrix
passive matrix system
„ Slow response time and imprecise voltage control.
Embedded Systems, KAIST 24
LCD Display (IV)
„ LCD Systems (II)
„ Active-matrix LCDs
„ Depend on thin film transistors (TFT).
„ TFTs are tiny switching transistors and capacitors.
„ They are arranged in a matrix on a glass substrate.
„ To address a particular pixel, the proper row is switched on, and then a
charge is sent down the correct column
„ Only the capacitor at the designated pixel receives a charge, and holds
the charge until the next refresh cycle
cycle.
„ And if we carefully control the amount of voltage supplied to a crystal,
we can make it untwist only enough to allow some light through.
„ B doing this in very
By e e exact,
act very
e small inc
increments,
ements LCDs can create
c eate a
gray scale.
„ Most displays today offer 256 levels of brightness per pixel.

Embedded Systems, KAIST 25


LCD Display (V)
„ LCD Color
„ Must have three subpixels with red, green and blue color filters to
create each color pixel.
„ Through the careful control and variation of the voltage applied,
applied the
intensity of each subpixel can range over 256 shades.
„ Combining the subpixels produces a possible palette of 16.8 million
colors ((256 shades of red x 256 shades of green
g x 256 shades of blue).
)
„ Enormous number of transistors.
„ Ex: A typical laptop computer supports resolutions up to 1,024x768.
„ 1,024 columns byy 768 rows byy 3 subpixels,
p we gget 2,359,296 transistors
etched onto the glass!
„ If there is a problem with any of these transistors, it creates a "bad pixel" on
the display.

Embedded Systems, KAIST 26


LCD Controller
E void WriteChar(char c){
communications
R/W bus
RS = 1; /* indicate data being sent */
RS
DATA_BUS = c; /* send data to LCD */
DB7–DB0 ( )
EnableLCD(45); /* toggle
gg the LCD with appropriate
pp p delayy */
8
}
microcontroller LCD
controller

CODES RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Description
I/D = 1 cursor moves left DL = 1 8-bit
0 0 0 0 0 0 0 0 0 1 Clears all display, return cursor home
I/D = 0 cursor moves right DL = 0 4-bit
S = 1 with display shift N = 1 2 rows 0 0 0 0 0 0 0 0 1 * Rt
Returns cursor home
h
S/C =1 display shift N = 0 1 row
Sets cursor move direction and/or
0 0 0 0 0 0 0 1 I/D S
S/C = 0 cursor movement F = 1 5x10 dots specifies not to shift display
R/L = 1 shift to right F = 0 5x7 dots ON/OFF of all display(D), cursor
0 0 0 0 0 0 1 D C B
ON/OFF (C), and blink position (B)
R/L = 0 shift to left
0 0 0 0 0 1 S/C R/L * * Move cursor and shifts display

Sets interface data length, number of


0 0 0 0 1 DL N F * *
display lines, and character font

1 0 WRITE DATA Writes Data

Embedded Systems, KAIST 27


4.45 Bit Manipulation
„ Changing i-th
i th bit
„ var = var EOR (1 << i);
„ Clear lower half-byte
half byte
„ var = var & 0xf0;
„ Combine bit groups
„ var = (x & 0xff00) | (y & 0xff);
„ Swap
p half-bytes
y
„ ROL.B #4, R0
„ Binary to BCD (2 digits)
„ Bcd = ((bin/10)<<4) | (bin%10);
„ BCD to binary (2 digits)
„ Bin = (bcd>>4)*10 + (bcd&0x0f);
Embedded Systems, KAIST 28
References
„ Keyboard interface,
interface display interface
interface, and bit
manipulation
„ William Eccles, “Microprocessor
Microprocessor systems – A 16
16-bit
bit approach
approach”,,
Addison Wesley, 1985.

„ Display interface & LCD display


„ Search Internet

Embedded Systems, KAIST 29

You might also like