university of tehran 1 interface design keyboard and printer omid fatemi
TRANSCRIPT
University of Tehran 1
Interface DesignKeyboard and Printer
Omid Fatemi
University of Tehran 2
Typical Interface Design
Connect Compute Convey Cooperate
Sense RealityTouch RealityConnectTransform
Embedded SystemsMicrosAssembler, CReal-TimeMemoryPeripheralsTimersDMA
PC interfacesHCI
BussesProtocolsStandardsPCIIEEE488SCSIUSB & FireWireCAN
University of Tehran 3
Outline
• Keyboard design
• Key detection
• Keyboard buffer
• Centronics printer interface
• IO printer ports
• Parallel port types
• Interfacing LPT ports to various devices
University of Tehran 4
Keyboard Layout
• Linear layout– N input ports for N keys
• Matrix layout– 2N ports (N input and N output) for N^2 keys
University of Tehran 5
Scanning and Identifying
• Micro controller
• Rows to output ports
• Columns to input ports
• Grounding rows
• Reading the columns
• Grounding one row
• Reading the columns
University of Tehran 6
Detection Algorithm
University of Tehran 7
Assembly Code
University of Tehran 8
PC Keyboard
• Micro controller (8042)– Microprocessor, RAM, EPROM, I/O ports
• Detection by 8042• Scan code assign• Serial communication to motherboard
– One start bit (0)– 8 bits for scan code– Odd-parity bit– One stop bit (1)
• 74LS322 (serial-in-parallel-out SR) in motherboard
• 74322 to port A of 8255 (port 60H)• In AT and later PCs another 8042 in motherboard
University of Tehran 9
PC Scan Codes
Make (0-7FH and break (plus 80H)
University of Tehran 10
Advanced Scan Codes
University of Tehran 11
Status Bytes
0040:0017 H (first) 0040:0018 H (second)
University of Tehran 12
Printer
Printer and Printer Interfacing
University of Tehran 13
Centronics printer interface
• 36-pin
• Grounds to reduce electrical noise (signal has
its own ground return)
• Data lines
• Printer status signals
• Printer control signals
• Ground signals
University of Tehran 14
Pin Layout
University of Tehran 15
University of Tehran 16
Printer Connector
University of Tehran 17
Printer-PC Communication
• PC checks busy
• If not busy, PC puts 8-bit data
• PC activates #STROBE (.5 micro)
• Data must stay (.5 micro after STROBE)
• Printer assert busy
• After reading data printer asserts #ACKNLG (5 micro)
• De-assert busy
University of Tehran 18
I/O Base Address for LPT
• -d 0040:0008
• LPT: 03BC, 0378, 0278
• 3 I/O ports– – LPT data lines
– – LPT status lines
– – LPT control lines
University of Tehran 19
Printer’s Ports
University of Tehran 20
BIOS: INT 17H
• AH=0– Print a character– AL: ASCII– DX: LPT number– AH returns status
• AH=1– Initialize
• AH=2– Get the status
• Printer time out?– 20 seconds (-d 0040:0078)
University of Tehran 21
Special Characters
University of Tehran 22
Inner Working of INT 17
University of Tehran 23
Printer Timing
University of Tehran 24
Buffering Ports
University of Tehran 25
Using Parallel Ports
University of Tehran 26
Stepper Motor
University of Tehran 27
Selected Problems
• 5, 6, 8
• 22, 28, 32, 43
University of Tehran 28
Summary