Today interactive devices are not only complex hardware devices, the complexity of the relevant data also greatly increased.
Common human-computer interaction input devices, including buttons, touch screen, microphone and other types of user-controlled input sensor. With the development of science and technology, not only our common interactive input device appeared new form, but also appeared a lot of new interactive input mode. For example, now the phone in the capacitive key and the gravity sensor, distance sensor.
Now the interactive device is not only reflected in the complexity of hardware devices, but also in the complexity of the relevant data has also been a large increase in the past. For example, the microphone can be used for voice input and can be used for face recognition of the camera, in order to complete these interactive input, in addition to the hardware input device for information collection, but also need to carry out a lot of data processing background to help the system " Get " user ‘s “input information".
The keyboard is one of the common external devices for embedded applications. The keyboard is a switch matrix consisting of several keys, which is the simplest digital input device. On the system, the keyboard keys on behalf of different meanings (in general, the meaning of the keys can be defined by software). User presses the keyboard's key, input data or the order, realizes the simple man-machine interaction.
First, the basic circuit of the keyboard
The basic circuit of the keyboard is a contact switch, and the two states of logic are "0" and "1", respectively. When the switch is open, the processor detects the corresponding pin is high, said the logic "1"; When closed, the processor detects the corresponding pin is low, said the logic "0".
Second, the classification of the keyboard
Key arrangement, the keyboard can be divided into independent keypad keyboard and matrix keys; press the key into the way, can be divided into direct reading and scanning; by coding, can be divided into non-coding and Hardware coding; According to the microprocessor response mode can be divided into interrupt mode and query mode. Combination of the above methods can constitute a different hardware structure and interface of the keyboard. The following describes the more commonly used in two ways.
1, the independent type
The independent keypad means each individual key is pressed one-on-one directly to the I / O input port of the microprocessor. Read the key value, the processor can detect the corresponding I / O input port status, determine the input level, determine the logic value of the input. Keys in the hardware and read on the way are independent of each other, so used to call this button for the independent button. This approach is relatively simple to achieve in the hardware and software, but each button occupies an I / O port, the resources occupied by more generally small number of keys, the microprocessor I / O resources are sufficient.
2, matrix type
Matrix keyboard is composed of n I / O lines line input port, m I / O line composed of column output, at the intersection of row and column at each intersection to set a button. Matrix keyboard read key commonly used progressive scan mode, that is, the output port by bit rotation output low, and then read from the input port information, and finally calculate the input from the mouth to read the information, access to key code.
For example, the row0 ~ 3 configuration for the output mode, col0 ~ 3 configured for the input mode; Now row0 output low, row1 ~ 3 output high, read col0 ~ 3; If the 0 line 0 Pressing the key, col0 detects the input is low, the other as high. This way occupies less I / O lines, more applications in the key to use more.
Design of the keyboard, usually less than 4 key applications, you can use the stand-alone interface. If more keys, in order to reduce the microprocessor I / O port occupancy, you can use the matrix keyboard.
In addition, if the use of processor I / O directly connected with the matrix keyboard interface, the matrix keyboard detection method requires the processor to continuously scan the interface detection. For the faster processors, this detection method is a great waste of the processor. Therefore, the practical application of the proposed use of specialized matrix keyboard driver chip or I / O expansion chip, to achieve the matrix keyboard detection, such as ZLG7290, CAT9555 and other expansion chips.
Using a driver or I / O extension chip, the processor can be freed from simple but frequent keyboard scanning. ZLG7290 chip supports 2 × 8 I / O expansion, the use of I2C interface and processor connections, and supports interrupt output, the largest scalable 8 × 8 matrix keyboard.