How the keyboard works

Publisher:清新微笑Latest update time:2011-07-31 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The basic working principle of the keyboard is to monitor the keys in real time and send the key information to the computer. The internal design of the keyboard includes a key scanning circuit that locates the key position, an encoding circuit that generates the key code that is pressed, and an interface circuit that sends the generated code to the computer, etc. These circuits are collectively referred to as keyboard control circuits. According to the working principle of the keyboard, computer keyboards can be divided into encoding keyboards and non-encoding keyboards. The function of the keyboard control circuit is completely completed automatically by hardware. This type of keyboard is called an encoding keyboard, which can automatically send the encoding information of the pressed key to the computer. Another type of keyboard, whose keyboard control circuit function depends on both hardware and software, is called a non-encoding keyboard. The response speed of this keyboard is not as fast as that of the encoding keyboard, but it can redefine some of the keyboard keys through software, which provides great convenience for expanding the functions of the keyboard, and thus has been widely used.

Line-by-line scanning method
The program scans the keyboard line by line and determines the closed key by the detected column output state.
One input port and one output port need to be set.

Row-column scanning method
Closed keys are identified by scanning rows and columns in reverse order. When scanning each row, read the column line; then scan the output to the column line in turn and read the row line.
Two programmable bidirectional input/output ports are required.

Assume that there is a 3×4 matrix keyboard connected to a microcomputer via a parallel interface chip 8255A. Port A of 8255A is defined as an output port, connected to the row line of the keyboard; port B is defined as an input port, connected to the column line of the keyboard. Assume that the address of port A of 8255A is 40H, the address of port B is 41H, and the address of the control register is 43H.

MOV AL, 82H
OUT 43H, AL
BEGIN: MOV AL, 0
OUT 40H, AL
WAIT : IN AL, 41H
AND AL, 0FH
CMP AL, 0FH
JZ WAIT
MOV CX, 7FFH
L0: LOOP L0
ST: MOV BL, 3
MOV BH , 4
MOV AL, 0FEH
MOV CL, 0FH
MOV CH, 0FFH
L1: OUT 40H, AL
ROL AL
MOV AH, AL
IN AL, 41H
AND AL, CL
CMP AL, CL
JNZ L2
ADD CH, BH
MOV AL, AH
DEC BL
JNZ L1
JMP BEGIN
L2: INC CH
RCR AL
JC L2
MOV AL, CH
JMP KEYTABLE

Figure 12-1 Non-encoded keyboard interface hardware block diagram

Reference address:How the keyboard works

Previous article:3×4 matrix keyboard circuit diagram and assembly language source program
Next article:How an optical mouse works

Latest Analog Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号