KEYBOARD LOGIC
What is a keyboard?
The keyboard is an input device.
It generates all 128 characters in ASCII.
It also generates special symbols &
graphics shapes.
The keyboard can provide a total 256
characters, shapes and symbols.
IBM PC KEYBOARD
It is like a typewriter keyboard & is most commonly used as an
input device.
The 3 primary keyboard types created by IBM are:
83 key PC and XT keyboard
84 key AT keyboard
101 key enhanced keyboard
The various types of keyswitches used for keyboard are :
Mechanical keyswitch
Capacitive keyswitch
Hall effect keyswitch
Principle of operation of keyboard
The keyboard hardware interface consists
of following sections:
A> Shift register (Serial to parallel
converter).
B>Logic for interrupt generation
C>Port for scanning the code
Scanning hardware for a 4X4
keyboard matrix :-
A four bit scan counter is used.
The MSB of scan counter S3 and S4 are input to a decoder.
At a time only 1 row will be low and the others will be high.
The LSB of scan counter S1 and S0 are select signals of a 4X1 multiplexer.
Whenever the status of Y is low, it indicates a key is pressed and the
scan code of the key is present in the counter.
Let us consider key pressed is 1.
Initially the counter outputs 0000 so row 0 is activated.
The status of columns is C0 =1, C1 = 0, C2= 1, C3= 1.
Now S1= 0, S0 = 0.
Therefore Y = C0 = 1 so the key pressed is not detected.
Now the counter is advanced by 1, the counter produces a count of 0001,
again row 0 is activated, the status of columns is C0=1, C1=0,C2=1,C3=1.
As S1=0 & S0=1 therefore Y=C1 =0, a zero is detected on Y so the Status
of counter is scan code of key
So now an interrupt is generated by the system and the status of the
counter is read.
The various scan codes for the various keys
in the above figure are :
KEY DEBOUNCING CIRCUIT :
When matrix is scan there are chances, that wrong status of key
is sensed due to the bouncing effect.
When a key is pressed it bounces for a few milliseconds.
This results in making & breaking the contact. This is called
bouncing.
The ckt. that takes care of the bouncing effect is called as a
“debouncing ckt.”
The keybouncing effect can be taken care by means of
hardware or a software.
The keyswitches are connected in a matrix of rows and columns
Each keyswitch has a fixed set of co-ordinates: row number and column number
The functions to be performed by the keyboard electronics are :
1. Sensing a key depression.
2. Encoding.
3. Sending the code to computer.
The rows are used as inputs to the matrix.
The columns are used as outputs from the matrix.
The column lines are sensed by the electronic circuits.
TYPES OF KEYBOARD :
Two types of classification :
Classification based on type of interface :
1. Serial Keyboard.
2. Parallel Keyboard.
Classification based on the construction of keyboard :
1. Membrane Keyboard.
2. Mechanical keyboard.
SERIAL KEYBOARD
A serial keyboard sends the data , bit by bit ,in a serial fashion as shown below.
The computer converts the data into a parallel byte.
PARALLEL KEYBOARD
It sense the data as a byte in parallel form.
All the bits are sent simultaneously on different lines (wires).
The Cable between the keyboard and the computer should have more wires in a
Parallel keyboard as shown below.
MEMBRANE KEYBOARD :
It consists of specially designed membrane switches.
It is often available for low cost.
It is used for standard commercial applications.
This keyboard uses rubber membrane for making and braking the
contacts.
Due to this, after certain number of key depressions this rubber
membrane tends to loose its elasticity.
Therefore, the keyboard develops contact problems.
MECHANICAL KEYBOARD :
All the keys are separate entities, soldered on a PCB.
Every key is a mechanical keyswitch having phosphor-bronze as the
contact material.
It is more rugged as compared to the membrane keyboard.
It is easy to replace a key if it develops a problem.
It is highly repairable & reliable & costlier as compared to membrane
keyboard.
It has 2 small metal plates
TYPES OF KEYSWITCHES on the PCB and another
metal plate on the bottom
of a piece of foam
CAPACITIVE KEYSWITCH
When you press the key
the movable plate is pushed
closer to the fixed plate
This changes the
capacitance between the
fixed plates.
Sense amplifier circuitry
detects this change in
capacitance & produces a
logic level signal that
indicates key has been
pressed.
(contd…)
The big advantage of a capacitive switch is that it has no
mechanical contacts to become oxidized or dirty
A small disadvantage is the specialized circuitry needed to
detect the change in capacitance
Capacitive keyswitches typically have a rated lifetime of about 20
million keystrokes.
HALL EFFECT KEYSWITCH
It has no mechanical
contact
It takes advantage of the
deflection of a moving
charge by a magnetic
field
A ref. current is passed
through a semi conductor
crystal between 2
opposing faces.
When a key is pressed,
the crystal is moved
through a magnetic field
which has its flux lines
perpendicular to the
direction of the current
flow in the crystal.
Contd…
• Moving the crystal through the magnetic field causes a small
voltage to be developed between two of the other opposing
faces of the crystal.
• This voltage is amplified and used to indicate that a key is
pressed.
• Hall effect keyboards are more expensive because of the
more complex switch mechanism, but they are very
dependable, and have typical rated lifetimes of 100 million or
more keystrokes.
OPTO ELECTRONIC SWITCH
• This type of switches have an LED
which generates light when proper
electric power is applied.
• Opposite to the LED, a photo transistor
is used.
• The property of photo transistor is such
that it allows the current flow in the ckt.,
as long as light is applied to it.
• When the light following to the photo
transistor is removed, it will no longer
allow the current to pass through it.
• In this type of switch, when the key is
not pressed, the light from LED falls onto
the photo transistor.
• This makes the current flow through the
photo transistor and produces a very low
voltage at the output Vout.
•When the key is depressed, the light
emitted from LED is blocked.
Contd…
• This will stop the current flow through the photo transistor and
forces the photo transistor to a cut off condition .
•In this condition, the current cannot flow through the photo
transistor & the different value will be produced at the output V out.
•These two V out values are interpreted by the keyboard ckt as two
different logical conditions key being open & key being closed.
MEMBRANE KEYSWITCH
• These switches are really just a
special type of mechanical switch.
• They consist of a three layer
plastic or rubber sandwich as
shown in fig.
•The middle layer has a hole under
each key position.
•The bottom layer has a conductive
line of silver ink running under
each column of keys.
•When you press a key, you push
the top ink line through the hole to
contact the bottom ink line.
• The advantages of membrane
keyboard is that they can be made
as very thin, sealed instruments &
in other messy applications.
•Lifetime of membrane keyboards
varies over a wide range.
MECHANICAL KEYSWITCH
• In mechanical switch keys, two
pieces of metal are pushed when
you press the key.
• The actual switch elements are
often made of a phosphor-bronze
alloy with gold plating on the
contact areas.
• The keyswitch usually contains a
spring to return the key to the non
pressed position and perhaps a
small piece of foam to help damp
out bouncing.
• Mechanical switches are relatively
inexpensive.
• But they suffer from contact
bounce.
Contd…
•A pressed key may make & break contact several times before it makes
a solid contact.
• Second, the contacts may become oxidized or dirty with age so they
no longer make a dependable connection.
• Higher quality mechanical switches typically have a rated lifetime of
about 1 million key switches.
FUNCTIONS OF KEYS ON THE KEYBOARD
A TO Z Used for entering the alphabets.
0 to 9 Used for entering the digits.
F1,F2,… These are function keys performing special
functions like F1 for file,F2 for edit etc.
Up, down, left Used for moving the cursor up, down left or right by
one and right arrow position .
+,-,*,/ Used for performing mathematical functions like
addition & subtraction.
Pgup / Pgdown Used for moving the cursor up or down by one
page.
Caps Lock Used when we want to type something in capital or
small letters.
Num Lock If the number lock key is on then numeric pad on
right hand side of keyboard works as numeric pad
else it does another function written below the
number on the key.