0% found this document useful (0 votes)
38 views

Interfacing Lec7

The document discusses keyboard interfacing and organization. It describes how keyboards use a matrix of key switches and how scanning detects pressed keys. It also outlines different keyboard types, encoders that encode key presses, and interfacing circuits that transfer encoded signals.

Uploaded by

Ninsat 10
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)
38 views

Interfacing Lec7

The document discusses keyboard interfacing and organization. It describes how keyboards use a matrix of key switches and how scanning detects pressed keys. It also outlines different keyboard types, encoders that encode key presses, and interfacing circuits that transfer encoded signals.

Uploaded by

Ninsat 10
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/ 28

CSE 601 – Computer Interfacing

& Microcontrollers
Computer Science & Engineering
University of Chittagong
Lecture 7

Keyboard Interfacing
Outline
• Introduction
• Keyboard organization
• Key Switches
• Keyboard Scanning
• Keyboard Interfacing
Introduction
• The keyboard was one of the first peripherals to be used with
computers
• It is still the primary input device for entering text and numbers
• A standard keyboard includes 100 keys
• Skill of typing is called keyboarding
• It contains keys for
• Alphabets
• Numeric digits
• Special characters
• Controls
• It transfers user commands and data to the system
• Each key sends a different signal to the CPU
First Keyboard
⚫ The invention of the modern computer keyboard began with the
invention of the typewriter
⚫ Christopher Latham Sholes patented the typewriter that we commonly
use today in 1868
⚫ The Remington Company mass marketed the first typewriters starting
in 1877
Keyboard Organization
• Keyboard consists of
• A number of switches organized in a matrix form
• An electronic circuit based on a microcontroller called
Keyboard Encoder
• Keyboard Encoder
• Monitors the status of all switches
• Detects pressing and releasing keys
• Encodes and transfers the information to the system
Arrangement of Key switch on Keyboard

• The switches are arranged in a matrix of rows and


columns
• Each key has a unique row and column number
• The process of finding out the row and column numbers
of key being closed is known as keyboard scanning
Arrangement of Key switch on Keyboard
Key Switches
• When a key on a keyboard is pressed, a switch is
activated to generate signals for communicating the
same to the PC
• Several types of switches
• Mechanical switch
• Capacitive switch
• Membrane switch
• Hall effect switch
Mechanical Switch
• It has a metal contact, which is closed and opened on key action
• When the switch is in the normal position, the contact is open
• When the key is pressed, the contact is closed
• The key contains springs to return back the contact to its original position
when the key is released
• Advantage
• It is cheap
• Disadvantages
• Key Bouncing- make and break the contact several times before establishing
the firm contact on a key action
• The contacts get oxidized over a period of time
Capacitive Switch
• It has two small metal plates
• When the key is pressed
• The two plates are brought close to each other
• The capacitance between two plates is changed
• The change in capacitance is detected and converted to logic level to
indicate the key action
• It requires a special circuit employing
• Oscillator
• Phase Lock Loop
• A comparator
• Advantages
• The plates has metal contacts
• Do not get oxidized
Membrane Switch
• It is special type of mechanical switch, which consists of
• two plastic or rubber sheets called row and column sheets
• These two plastics are separated by another sheet with holes at key positions
• The top layer is the row layer and has a conductive line running under each
row of keys
• The bottom layer is the column layer and has a conductive line running
under each column of keys
• Principle
• When a key is pressed, a top row line touches the bottom line through the
hole
• It is detected and communicated by proper interfacing circuits
Membrane Switch
Hall Effect Switch
• It uses the principle that moving a conductor carrying current perpendicular
to a magnetic field in a direction perpendicular to both the current and the
magnetic field generates a voltage across the conductor
• In a Hall switch
• A reference current is passed through a semiconductor crystal
• The crystal is moved across the magnetic field on key action
• The crystal generates a voltage, which is amplified and used for indicating
the key press
Hall Voltage
• Advantage
• It is reliable
• Disadvantage Key Movement

• It is expensive Crystal Magnetic Field

Ref. Current
Keyboard Types
• Several types of Keyboard
• 83-key PC/PC-XT keyboard - 1983
• 84-key PC-AT keyboard - 1984
• 101-key Enhanced Keyboard
• 104-key Enhanced Keyboard
• PS/2 type keyboard - AT keyboard is renamed as PS/2 port after IBM PS/2 is
debuted in 1987
• USB Keyboard
Key Debouncing
• When a key is pressed
• The switch, before establishing a firm contact, makes and breaks
the contact several times
• This is known as debouncing
• The system should not misinterpret key bouncing as the key is being
pressed and released many times
• There are many hardware and software debouncing methods to
debounce key bouncing
• The simple method is a software delay for 20 ms is introduced
every time a key is pressed or released
Keyboard Encoder
• When a key is pressed, the associated keyboard hardware
• Detects pressing of keys
• Debounces key bouncing
• Determines the row and column numbers associated with the key being
pressed
• Converts the row and column information to a standard code
• Informs the system
• The keyboard's built-in processor
• reads the key matrix,
• debounces the keypress signals,
• converts the keypress to the appropriate scan code, and
• transmits the code to the motherboard.
• The processors built into the keyboard contain their own RAM, possibly
some ROM, and a built-in serial interface
Keyboard Encoder
• The original PC Keyboard used intel 8048 microcontroller as keyboard
encoder
• It consists of
• An 8-bit CPU
• 1KB ROM – stores programs for monitoring the key status, for debouncing
when a key is pressed and for determining the scan code for the key being
pressed
• Three I/O ports
• A programmable timer/ counter
• It transmits the code to the PC through a special serial link
• New keyboard uses 8049 version or other microcontroller compatible with
8048 or 8049
• Motorola 6805 processor
• It can also buffer up to 20 scan codes
Keyboard interface
• Scan Code
• Keyboard assign unique scan code for each key and inform pressing and
releasing of keys by transferring the codes of respective keys
• Make Code - The code is sent by keyboard when a key is pressed
• Break Code – the code is sent by keyboard when a key is released
• 101-key PC-AT enhanced keyboard is
• The break code for a key is two bytes long, where the first byte is F0H and
the second byte is the make code for that key
Keyboard Scanning Process

D0

Output port D1

D2

D3

D3 D2 D3 D0 Input port
Keyboard Scanning Process
• To determine whether a key is pressed or not
• ‘0000’ is written into the output port
• The input port is read
• If all the keys are open, the input port is read ‘1111’
• If a key is pressed the port reads ‘0’ in one of 4 bits
• It gives the information of column number of the key
• After a key debouncing delay period of 20ms, the input port is again read to ensure that
actually a key has been pressed
• To find out which key is pressed
• The LSB of the output port is set to ‘0’ and the remaining bits are set to ‘1’ (i.e. 1110)
• The input port is read
• If it reads ‘1’ in all the 4 bits, it indicates that the key being pressed is not in that key
• Then the next bit is set to ‘0’ keeping the other bits 1 (i.e 1101) and the input port is read
• The process is continued till the input port reads ‘0’ in one of the bits
• The content of the output port provides the information of row number of the key
Keyboard Interface
• PC/PC-XT keyboard interface
• It used 8255 PPI (Programmable Peripheral Interface) on the motherboard to
receive scan code from the keyboard
• This chip is connected to the interrupt controller IRQ1 line
• When a scan code is received, the 8255 generates an interrupt signal on
IRQ1 line to indicate the availability of keyboard data
• The data is then sent from the 8255 to the processor via I/O port address
60h.
• The IRQ1 signal causes the main system processor to run a subroutine (INT
9h) that interprets the keyboard scan code data and decides what to do.
Keyboard Interface
Keyboard Interface
• PC-AT keyboard interface
• In an AT-type keyboard design, the keyboard serial interface is connected to a special
keyboard controller (8042-type microcontroller) on the motherboard
• It has its own 2KB of ROM and 128 bytes of RAM
• An 8742 version that uses erasable programmable read-only memory (EPROM) can be
erased and reprogrammed
• the (8048-type) microcontroller in the keyboard sends data to the (8042-type) keyboard
controller on the motherboard
• When the keyboard controller on the motherboard receives data from the keyboard, it
signals the motherboard with an IRQ1 and sends the data to the main motherboard
processor via I/O port address 60h, just as in the PC/XT
• Acting as an agent between the keyboard and the main system processor, the 8042-type
keyboard controller can translate scan codes and perform several other functions as
well.
• The system can send data to the keyboard via 8042 microcontroller by writing the data
into the port 60H
• When the system needs to send commands to or read the status of the keyboard
controller on the motherboard, it reads or writes through I/O port 64h
Keyboard Interface
Keyboard System
Key Matrix GND

Output Port +5V


KBD Data
8048 KBD Clock 8042
Reset

Input Port

Communication over this interface is accomplished using two signal lines that are designed as
• Keyboard Data (KBD Data) – it carries data bits from keyboard to the system and
commands from the system to the keyboard
• Keyboard Clock (KBD Clock) – this signal is used to synchronize the keyboard and
the system
Keyboard Connectors
• USB connector
• Inside the keyboard a variety of custom controller chips is used by various
keyboard manufacturers
• to receive and interpret keyboard data before sending it to the system via
the USB port
• After the keyboard data reaches the USB port on the system
• the USB port routes the data to the 8042-compatible keyboard controller,
where the data is treated as any other keyboard information
• During the BIOS configuration routine
• USB Legacy support must be enabled in the BIOS

http://geekscomputer.blogspot.com/2008/07/keyboard-interface.html
Keyboard Connectors
• Keyboard communicates with the main system in one of two ways:
• Through a special serial data link if a standard keyboard connector is used
• Through the USB port
• Keyboard Connector
• The standard keyboards are connected to the system through a special type of serial link
• All keyboards use either larger 5-pin DIN (Deutsches Institut für Normung) for PC XT
connector or the 6-pin mini-DIN for PC AT connector for attaching to the motherboard
• Keyboard Data (KBD Data) – Pin 2 for 5-Pin DIN and Pin 1 for 6-Pin DIN
• Keyboard Clock (KBD Clock) - Pin 1 for 5-Pin DIN and Pin 5 for 6-Pin DIN
• In modern motherboards, the two lines are bidirectional
Thank You

Q/A

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy