KEMBAR78
04 Input and Output Device Interfacing | PDF | Switch | Input/Output
100% found this document useful (1 vote)
7 views35 pages

04 Input and Output Device Interfacing

Keypads and leds plus lcds

Uploaded by

remoteplayjones
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
7 views35 pages

04 Input and Output Device Interfacing

Keypads and leds plus lcds

Uploaded by

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

Input devices

• Keypad
• Switch

I/O device Interfacing


Output devices
• LEDs
• 7 SEG Display
• LCD

I/O device Interfacing


I/O devices (Peripherals)
• Examples: switches, LED, LCD, printers, keyboard,
keypad
• Interface chips
• are needed to resolve the speed problem
• synchronizes data transfer between CPU and I/O device
• Connection of Interface and CPU
• Data pins are connected to CPU data bus
• I/O port pins are connected to I/O device
• CPU may be connected to multiple interface
• IO ports are simplest interface
Switch On I/O Ports

• Case-1:
• Gives a logic 0 on switch close
• Current is 0.5ma on switch close

• Case-2:
• Gives a logic 1 on switch close
• High current on switch close
• Case-3:
• Can damage port if 0 is output

I/O device Interfacing


Simple input devices
• DIP switches usually have 8 switches
• Use the case-1 from previous page
• Sequence of instructions to read is:

I/O device Interfacing


Bouncing contacts
• Contact:
• Push-button switches
• Toggle switches
• Electromechanical relays
• Make and break Contact normally open switch
• The effect is called "contact bounce" or, in a switch,
"switch bounce”.

• If used as edge-triggered input (as INT0), several


interrupt is accorded

I/O device Interfacing


Hardware Solution
• An RC time constant to suppress the bounce
• The time constant has to be larger than the switch bounce

Vcc

OUT
Software Solution

• Read the new state of switch N time

• Wait-and-see technique
• When the input drops
• an “appropriate” delay is executed (10 ms)
• then the value of the line is checked again to make sure the
line has stopped bouncing

I/O device Interfacing


Interfacing a Keypad
16 keys arranged as a 4X4 matrix
• Place a 0 on R0 port
• Read C port
• If there is a 0 bit F E D C
then the button R1
at the column/row B A 9 8 R2
R3
intersection has R4
7 6 5 4
been pressed.
• Otherwise, try next row 3 2 1 0

• Repeat constantly C1
C2
C3
C4

I/O device Interfacing


Simple output devices
• Case-1
• LED is ON if output=zero
• Most LEDs drop 1.7 volts and need about 10ma
• Current is (5-1.7)/470
• Case-2
• Too much current
• Failure of Port or LED
• Case-3
• Not enough drive (1ma)
• LED is too dim

I/O device Interfacing


The 7-Segment Display

• 7 LEDs arranged to form the number 8.


• By turning on and off (LEDs), different combinations can
be produced.
• useful for displaying the digits 0 through 9, and some
characters.

I/O device Interfacing


The 7-segment Display (Cont.)

• 7-segment displays come in 2 configurations:

Common Anode Common Cathode


Connect cathode to the output Connect cathode to the output

• Therefore, the common anode variety would be better


for our interfacing needs.

I/O device Interfacing


Interfacing a 7-segment display
• Two ways
• Connecting the 7 data lines to the microcontroller pin
• Using a decoder – (4-8 decoder ) e.g. 7447
• Common cathode – requires a 1 to light LED and 0 to switch off –
Active high
• Common anode – requires a 0 to light and 1 to switch off- Active
Low

I/O device Interfacing


Connecting using a decoder

I/O device Interfacing


BCD to 7_Seg lookup table
BCD pgfedcba he
7_seg x
0000 001111 11 3f
0001 00110000 30
0010 0101101 1 5b
0011 010011 11 4f
0100 011001 10 66
0101 01101101 6d
0110 01111101 7d
0111 00000111 07
1000 01111111 7f
1001 01101111 6f
a a a a a a a a
f b f b b f b f f b f b f b
g g g g g g g
e c e e c c c e c c e c c
d d d d d d d
LCD Interfacing
• Liquid Crystal Displays (LCDs)
• Cheap and easy way to display text
• Various configurations (1 line by 20 X char up to 8 lines X 80)
• Integrated controller
• The display has two register
• command register
• data register

• By RS you can select register


• Data lines (DB7-DB0) used to transfer data and commands

I/O device Interfacing


I/O device Interfacing
Specification of
LCD16x2
• Display Type: Alphanumeric character display
• Character Format: 5x8 dots matrix format
• Display Size: 16 characters x 2 lines
• Display Color: Blue or Green
• Backlight: LED backlight
• Voltage Supply: 5V DC
• Interface: 4-bit or 8-bit mode
• Dimension: 84.0 x 44.0 x 13.0 mm

I/O device Interfacing


Alphanumeric LCD Interfacing

• Pinout
• 8 data pins D7:D0
• RS: Data or Command
Register Select
• R/W: Read or Write
• E: Enable (Latch data)

• RS – Register Select
• RS = 0  Command Register
• RS = 1  Data Register
• R/W = 0  Write , R/W = 1  Read
• E – Enable
• Used to latch the data present on the data pins.

• D0 – D7
• Bi-directional data/command pins.
• Alphanumeric characters are sent in ASCII format.

I/O device Interfacing


Pinouts
• VEE- Contrast adjustment;
• E- Sends data to data pins when a high to low pulse
is given; Extra voltage push is required to execute
the instruction and EN(enable) signal is used for
this purpose

I/O device Interfacing


Memory map
• It consist of:
• DD RAM
• CG ROM
• CG RAM
• DD RAM : Display Data RAM
• Stores the character code for each character of LCD Display Extra
locations are used during shifting operations
• CG ROM : Character Generator ROM
• Contains font bitmap for predefined characters that LCD can display
Character code in DD RAM equates to a location in CG ROM Character
code in DD RAM equates to a location in CG ROM e.g. 48H location
refers to character ‘H’ (also 48 is ASCII value of H) Contains English
ASCII characters and Japanese Characters

I/O device Interfacing


• CG RAM : Character Generator RAM  Provides
space for 8 custom characters

I/O device Interfacing


Interfacing LCD

I/O device Interfacing


LCD Commands
• The LCD’s internal controller can accept several commands and
modify the display accordingly. Such as:
• Clear screen
• Return home
• Decrement/Increment cursor

• After writing to the LCD, it takes some time for it to complete


its internal operations. During this time, it will not accept any
new commands or data.
• We need to insert time delay between any two commands or data sent
to LCD

I/O device Interfacing


Pin Description

I/O device Interfacing


Command Set

I/O device Interfacing


Command set
• Clear Display:– Clears the Display– Returns cursor
to top-left position Returns cursor to top left
position– Writes a blank space to all DD RAM
Location– Address counter is reset to 0– Clears all
optional setting
• Return Cursor Home:– Returns cursor to top-left
position– DD RAM content remains unchanged–
Address counter is reset to 0– Display is returned to
original status, if shifted

I/O device Interfacing


Command set
• Entry Mode Set– Set cursor move direction
– Specify whether or not to shift the display Bit DB1
– I/D (Increment/Decrement) ( )
0 - Auto Increment the address counter. Cursor blink/move to left 1
- Auto Decrement the address counter. Cursor blink/move to right
• Bit DB0 – Shift 0
• 0- Shifting Disabled
• 1 – During a DD RAM write operation, shift the entire
display value in the direction controlled by Bit DB1 (I/D).
Appears as though the cursor position remains controlled
by Bit DB1 (I/D). Appears as though the cursor position
remains constant and the display moves
I/O device Interfacing
Display ON/OFF: Display is
turned on/off
• Bit DB2 (D) Display on/off
• 0 – No character displayed. Data stored in DD RAM is
retained
• 1 Display character stored in DD RAM 1 – Display character
stored in DD RAM
• Bit DB1 (C) Cursor on/off
• 0 – No cursor 1 – Display cursor
• Bit DB0 (B) Cursor blink on/off
• 0 – No cursor blinking 11
• 1 – Cursor blinks on/off approx. every half second

I/O device Interfacing


Function set
• Cursor and Display Shift: Moves cursor and shifts display
without changing DD RAM Contents
• Function Set: S t i t f d t l th– Sets interface data length–
Number of display lines– Character font– Starter kit – Value =
28h
• Set DD RAM Address:– Sets initial DD RAM Address–
Subsequent data read/write is performed from DD RAM
• Read Busy Flag and Address:– BF = 1 => Some internal
operation is in progress. Next instruction is not accepted until
the flag clears– Returns present value of the Address Counter
13 Returns present value of the Address Counter
I/O device Interfacing
Command set
• Write Data to CG RAM or DD RAM:– Writes data to CG
RAM / DDRAM if followed by Set CG RAM / DD RAM
Address respectively– Add. Counter automatically inc. or
dec. depending upon I/D bit
• Read Data from CG RAM or DD RAM:– Reads data from
CG RAM / DDRAM if followed by Set CG RAM / DD RAM
Address respectively 14– Add. Counter automatically inc.
or dec. depending upon I/D bit

I/O device Interfacing


LCD Addressing

I/O device Interfacing


LCD Timing

I/O device Interfacing


I/O device Interfacing
Interfacing LCD

I/O device Interfacing

You might also like