Keyboard circuit with multiple keys

By building a multi-bit key circuit through the I/O port expansion circuit and the expansion chip D2, the problems of high CPU resource usage and slow response of the existing keyboard circuit are solved, and efficient key value reading is achieved.

CN223348655UActive Publication Date: 2025-09-16WILLFAR INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202422347696.7
Authority / Receiving Office
CN · China
Patent Type
Utility models(China)
Current Assignee / Owner
Filing Date
2024-09-25
Publication Date
2025-09-16
Estimated Expiration
2034-09-25

AI Technical Summary

Technical Problem

The existing keyboard circuit CPU has high I/O port resource usage and slow key value reading response, especially in the case of multiple keys, which causes serious resource waste.

Method used

The I/O port expansion circuit is combined with the key circuit and the external interface circuit. The I/O port expansion is realized through the expansion chip D2, and the key value of the key is read in real time using the interrupt signal to construct a multi-bit key circuit.

Benefits of technology

It significantly reduces the number of CPU I/O ports, shortens key response time, improves key value reading efficiency, and reduces CPU resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN223348655U_ABST
    Figure CN223348655U_ABST
Patent Text Reader

Abstract

The utility model discloses a keyboard circuit with multiple keys. The keyboard circuit comprises an I / O port expansion circuit, a key circuit and an external interface circuit, the I / O port expansion circuit is respectively connected with the key circuit and the external interface circuit; the I / O port expansion circuit is also connected with the I / O port of the CPU; the I / O port expansion circuit is used for expanding an I / O port of the CPU, acquiring a key signal of the key circuit and transmitting the key signal to the CPU through the I / O port; the key circuit is used for collecting key signals and transmitting the key signals to the I / O port expansion circuit. The keyboard circuit solves the technical problems of high I / O (input / output) port resource occupation and slow key value reading response of the existing keyboard circuit CPU.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The utility model relates to the technical field of keys, in particular to a keyboard circuit with multiple keys. Background Art

[0002] Simple buttons are generally designed directly using the I / O port. When the button is pressed, the level of the I / O port changes. For example, all I / O ports are pulled up, and one end of the button is grounded. When the button is pressed, the level of the I / O port can be pulled from a high level to a low level. The CPU can read the corresponding I / O port level by scanning the I / O port and confirm which button is pressed.

[0003] At present, since the number of buttons on power products is relatively small, there are generally two ways to achieve it. The first way is to use AD sampling to read the button value. The keyboard uses the principle of AD sampling. Every time a button is pressed, the voltage of the AD sample will be different, so as to distinguish which button is pressed. The characteristic of this method is that the number of buttons is determined by the accuracy of AD sampling, that is, the number of AD bits carried by the CPU; the second way is to use the I / O port to directly press the button. Pressing the button changes the level of the I / O port, and the CPU reads the value of the I / O port. This method is simple and direct, but it occupies more I / O port resources. One button occupies one I / O port. For example, the patent document with application number 201721685645.9 discloses a capacitive sensing button circuit. Currently, a large number of keys are used in the second method, which reads key values ​​through I / O ports. Using several keys requires designing the same number of I / O ports. The CPU periodically scans each I / O port to read the key values. When using a large number of keys, such as 20 keys, a large number of I / O ports will be occupied, that is, 20 I / O port resources will be used, which greatly wastes the CPU's I / O port resources. At the same time, the scanning method uses a long scanning time and a long key response time, which also greatly wastes CPU resources. Therefore, it is urgent to propose a keyboard circuit with multiple keys to solve the technical problems of the existing keyboard circuits, such as the high CPU I / O port resource occupation and slow key value reading response. Utility Model Content

[0004] The main purpose of the utility model is to provide a keyboard circuit with multiple keys, aiming to solve the technical problems of high I / O port resource occupation of CPU and slow key value reading response of existing keyboard circuits.

[0005] To achieve the above object, the present invention provides a multi-key keyboard circuit, wherein the multi-key keyboard circuit includes:

[0006] I / O port expansion circuit, key circuit and external interface circuit;

[0007] The I / O port expansion circuit is connected to the key circuit and the external interface circuit respectively; the I / O port expansion circuit is also connected to the I / O port of the CPU;

[0008] The I / O port expansion circuit is used to expand the I / O port of the CPU, and to obtain the key signal of the key circuit, and transmit the key signal to the CPU through the I / O port;

[0009] The key circuit is used to collect key signals and transmit the key signals to the I / O port expansion circuit.

[0010] In one preferred embodiment, the I / O port expansion circuit includes an expansion chip D2;

[0011] Pin 1 of the expansion chip D2 is connected to the interrupt interface of the CPU;

[0012] Pins 2, 3, 12, and 21 of the expansion chip D2 are grounded;

[0013] Pins 4, 5, 6, and 7 of the expansion chip D2 are connected to the output end of the keyboard circuit;

[0014] Pins 16, 17, 18, 19, and 20 of the expansion chip D2 are connected to the input end of the keyboard circuit;

[0015] Pins 22 and 23 of the expansion chip D2 are connected to the second pull-up circuit and the external interface circuit respectively;

[0016] Pin 24 of the expansion chip D2 is connected to the first protection circuit.

[0017] In one preferred solution, the first protection circuit includes a capacitor C1, a TVS tube V1, and a bidirectional anti-static tube D1;

[0018] One end of the capacitor C1 is connected to the 24-pin of the expansion chip D2 and the power supply end respectively, and the other end of the capacitor C1 is connected to the bidirectional anti-static tube D1, the TVS tube V1 and the ground end respectively, and the other ends of the bidirectional anti-static tube D1 and the TVS tube V1 are connected to the power supply end.

[0019] In one of the preferred embodiments, the second pull-up circuit includes a resistor R6 and a resistor R7; one end of the resistor R6 is connected to the resistor R7 and the power supply end respectively, the other end of the resistor R6 is connected to pin 23 of the extension chip D2, and the other end of the resistor R7 is connected to pin 22 of the extension chip D2.

[0020] In one of the preferred embodiments, the key circuit includes a first pull-up circuit, a multi-bit key circuit and a third protection circuit; one end of the first pull-up circuit is connected to the power supply end, the other end of the first pull-up circuit is connected to the multi-bit key circuit, the multi-bit key circuit is respectively connected to the I / O port expansion circuit and the third protection circuit, and the other end of the third protection circuit is grounded.

[0021] In one of the preferred solutions, the multi-bit key circuit adopts an M×N matrix multi-bit key circuit; wherein, M is the number of rows of keys in the key circuit, 1<M≤8, and N is the number of columns of keys in the key circuit, 1<N≤8.

[0022] In one preferred solution, the multi-bit key circuit adopts a 5×4 matrix multi-bit key circuit;

[0023] The 5×4 matrix multi-bit key circuit includes a key K1, a key K2, ..., a key K20;

[0024] Pins 1 and 3 of the button K1, button K2, ..., button K20 are respectively connected to the first pull-up circuit, the third protection circuit and the I / O port expansion circuit, and pins 2 and 4 of the button K1, button K2, ..., button K20 are connected to the I / O port expansion circuit.

[0025] In one preferred solution, the third protection circuit includes a capacitor C2; one end of the capacitor C2 is connected to the I / O port expansion circuit and the multi-bit key circuit respectively, and the other end of the capacitor C2 is grounded.

[0026] In one preferred solution, the first pull-up circuit includes a resistor R1; one end of the resistor R1 is connected to the power supply end, and the other end of the resistor R1 is connected to the multi-bit key circuits.

[0027] In one preferred embodiment, the external interface circuit includes a plug XS29;

[0028] Pin 1 of the plug XS29 is connected to a second protection circuit; the second protection circuit includes a capacitor C6, a TVS tube V2 and a bidirectional anti-static tube D3;

[0029] One end of the capacitor C6 is connected to pin 1 of the plug XS29, the power supply terminal, the bidirectional anti-static tube D3, and the TVS tube V2, respectively. The other ends of the bidirectional anti-static tube D3, the capacitor C6, and the TVS tube V2 are grounded.

[0030] Pins 2, 3, and 4 of the plug XS29 are connected to the I / O port expansion circuit;

[0031] Pin 5 of the XS29 plug is grounded.

[0032] In the above technical solution of the present invention, the multi-key keyboard circuit includes: an I / O port expansion circuit, a key circuit, and an external interface circuit; the I / O port expansion circuit is respectively connected to the key circuit and the external interface circuit; the I / O port expansion circuit is also connected to the I / O port of the CPU; the I / O port expansion circuit is used to expand the I / O port of the CPU, and is used to obtain key signals from the key circuit and transmit the key signals to the CPU through the I / O port; the key circuit is used to collect key signals and transmit the key signals to the I / O port expansion circuit. The utility model solves the technical problems of the existing keyboard circuit, such as high CPU I / O port resource usage and slow key value reading response.

[0033] In the present invention, the I / O port on the CPU is directly expanded by an I / O port expansion circuit, so that two groups of I / O ports can be expanded. A key circuit is constructed by the two groups of I / O ports, which only occupies one I / O port and one interrupt interface of the CPU, thereby greatly reducing the number of I / O ports occupied by the CPU, reducing the resource consumption of the CPU, and shortening the response time of the key. At the same time, by reading the key value of the key circuit according to the interrupt signal of the I / O port expansion circuit, it is possible to obtain in real time which key is pressed, thereby reducing the CPU overhead. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the implementation methods of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the implementation methods or the description of the prior art. Obviously, the drawings described below are only some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying any creative work.

[0035] Figure 1 This is a schematic diagram of a keyboard circuit with multiple keys according to an embodiment of the present utility model;

[0036] Figure 2 This is a schematic diagram of an I / O port expansion circuit according to an embodiment of the present invention;

[0037] Figure 3 This is a schematic diagram of a key circuit according to an embodiment of the present utility model;

[0038] Figure 4 This is a schematic diagram of the external interface circuit of an embodiment of the present utility model.

[0039] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0041] In addition, in this utility model, the terms "first," "second," etc. are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of technical features indicated. Therefore, features specified as "first" or "second" may explicitly or implicitly include at least one of such features.

[0042] Moreover, the technical solutions between the various embodiments of the present invention can be combined with each other, but this must be based on the fact that ordinary technicians in this field can implement it. When the combination of technical solutions is mutually contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.

[0043] See also Figure 1-Figure 4 According to one aspect of the present invention, the present invention provides a keyboard circuit with multiple keys, wherein the keyboard circuit with multiple keys includes:

[0044] I / O port expansion circuit, key circuit and external interface circuit;

[0045] The I / O port expansion circuit is connected to the key circuit and the external interface circuit respectively; the I / O port expansion circuit is also connected to the I / O port of the CPU; wherein the CPU is a control module of the device used by the multi-key keyboard circuit, which is not specifically limited in the present invention;

[0046] The I / O port expansion circuit is used to expand the I / O port of the CPU, and to obtain the key signal of the key circuit, and transmit the key signal to the CPU through the I / O port;

[0047] The key circuit is used to collect key signals and transmit the key signals to the I / O port expansion circuit.

[0048] Specifically, in this embodiment, the I / O port expansion circuit includes an expansion chip D2;

[0049] Pin 1 of the expansion chip D2 is connected to the interrupt interface of the CPU and the resistor R5 respectively, and the other end of the resistor R5 is connected to the power supply end;

[0050] Pins 2, 3, 12, and 21 of the expansion chip D2 are grounded; the I / O port expansion circuit can determine the address of the IIC bus through pins 2, 3, and 21 of the expansion chip D2. When multiple IIC devices are mounted on the IIC bus of the CPU, the address of the device can be determined through pins 2, 3, and 21 of the expansion chip D2, which is convenient for the CPU to access. When multiple identical I / O expansion circuits are mounted on the IIC bus, the address of the device is determined by different pull-up and pull-down functions of pins 2, 3, and 21 of the expansion chip D2. Different addresses are set for the same devices mounted on the same bus. In the present invention, only one expansion chip is used, so the address is set to 000, that is, pins 2, 3, 12, and 21 of the expansion chip D2 are grounded.

[0051] Pins 4, 5, 6, and 7 of the expansion chip D2 are connected to the output end of the keyboard circuit;

[0052] Pins 16, 17, 18, 19, and 20 of the expansion chip D2 are connected to the input end of the keyboard circuit;

[0053] Pins 22 and 23 of the expansion chip D2 are respectively connected to the second pull-up circuit and the external interface circuit; pins 22 and 23 of the expansion chip D2 are also respectively connected to the clock TCK pin and data TWD pin of the IIC port of the CPU;

[0054] Pin 24 of the expansion chip D2 is connected to the first protection circuit, and pin 24 of the expansion chip D2 is connected to the power supply terminal through the first protection circuit, thereby providing power for the expansion chip D2 to work normally;

[0055] Specifically, in this embodiment, the expansion chip D2 adopts a nano-core microelectronic chip of model NCA9555. The present invention does not make any specific restrictions. Specifically, it only needs to have an IIC interface that can expand two or more I / O ports and have an interrupt signal.

[0056] Specifically, in this embodiment, the first protection circuit includes a capacitor C1, a TVS tube V1, and a bidirectional anti-static tube D1; one end of the capacitor C1 is respectively connected to the 24-pin of the expansion chip D2 and the power supply terminal, and the other end of the capacitor C1 is respectively connected to the bidirectional anti-static tube D1, the TVS tube V1, and the ground terminal, and the other ends of the bidirectional anti-static tube D1 and the TVS tube V1 are connected to the power supply terminal; the first protection circuit can suppress instantaneous overvoltage and protect circuit components from damage by instantaneous surge pulse voltage. At the same time, the bidirectional anti-static tube D1 is provided to achieve overvoltage protection of the circuit and prevent damage to sensitive electronic components caused by static electricity by absorbing the large current generated by electrostatic discharge.

[0057] Specifically, in this embodiment, the second pull-up circuit includes a resistor R6 and a resistor R7; one end of the resistor R6 is connected to the resistor R7 and the power supply end respectively, the other end of the resistor R6 is connected to pin 23 of the expansion chip D2, and the other end of the resistor R7 is connected to pin 22 of the expansion chip D2; the pull-up processing is performed by the second pull-up circuit to ensure the stability and reliability of the input signal and improve the anti-interference ability of the circuit.

[0058] Specifically, in this embodiment, the key circuit includes a first pull-up circuit, a multi-bit key circuit and a third protection circuit; one end of the first pull-up circuit is connected to the power supply end, the other end of the first pull-up circuit is connected to the multi-bit key circuit, the multi-bit key circuit is respectively connected to the I / O port expansion circuit and the third protection circuit, and the other end of the third protection circuit is grounded.

[0059] Specifically, in this embodiment, the multi-bit key circuit adopts an M×N matrix multi-bit key circuit; wherein, M is the number of rows of keys in the key circuit, 1<M≤8, and N is the number of columns of keys in the key circuit, 1<N≤8; in the present utility model, the number of keys of the multi-bit key circuit is designed to be a matrix multi-bit key circuit of 8×8 at most, which is not specifically limited in the present utility model and can be set according to needs.

[0060] Specifically, in this embodiment, the multi-bit key circuit adopts a 5×4 matrix multi-bit key circuit; the 5×4 matrix multi-bit key circuit includes a key K1, a key K2, ..., a key K20;

[0061] Pins 1 and 3 of the button K1 are connected to the resistor R1, the capacitor C5 and the pin 4 of the expansion chip D2 respectively, and pins 2 and 4 of the button K1 are connected to the pin 20 of the expansion chip D2;

[0062] Pins 1 and 3 of the button K2 are connected to the resistor R2, the capacitor C4 and the pin 5 of the expansion chip D2 respectively, and pins 2 and 4 of the button K2 are connected to the pin 20 of the expansion chip D2;

[0063] Pins 1 and 3 of the button K3 are connected to the resistor R3, the capacitor C2, and the pin 6 of the expansion chip D2, respectively; pins 2 and 4 of the button K3 are connected to the pin 20 of the expansion chip D2;

[0064] Pins 1 and 3 of the button K4 are connected to the resistor R4, the capacitor C3 and the pin 7 of the expansion chip D2 respectively, and pins 2 and 4 of the button K4 are connected to the pin 20 of the expansion chip D2;

[0065] Pins 1 and 3 of the button K5 are connected to the resistor R1, the capacitor C5, and the pin 4 of the expansion chip D2, respectively; pins 2 and 4 of the button K5 are connected to the pin 19 of the expansion chip D2;

[0066] Pins 1 and 3 of the button K6 are connected to the resistor R2, the capacitor C4 and the pin 5 of the expansion chip D2 respectively, and pins 2 and 4 of the button K6 are connected to the pin 19 of the expansion chip D2;

[0067] Pins 1 and 3 of the button K7 are connected to the resistor R3, the capacitor C2, and the pin 6 of the expansion chip D2, respectively; pins 2 and 4 of the button K7 are connected to the pin 19 of the expansion chip D2;

[0068] Pins 1 and 3 of the button K8 are connected to the resistor R4, the capacitor C3 and the pin 7 of the expansion chip D2 respectively, and pins 2 and 4 of the button K8 are connected to the pin 19 of the expansion chip D2;

[0069] Pins 1 and 3 of the button K9 are connected to the resistor R1, the capacitor C5, and the pin 4 of the expansion chip D2, respectively; pins 2 and 4 of the button K9 are connected to the pin 18 of the expansion chip D2;

[0070] Pins 1 and 3 of the button K10 are connected to the resistor R2, the capacitor C4, and the pin 5 of the expansion chip D2, respectively; pins 2 and 4 of the button K10 are connected to the pin 18 of the expansion chip D2;

[0071] Pins 1 and 3 of the button K11 are connected to the resistor R3, the capacitor C2, and the pin 6 of the expansion chip D2, respectively; and pins 2 and 4 of the button K11 are connected to the pin 18 of the expansion chip D2;

[0072] Pins 1 and 3 of the button K12 are connected to the resistor R4, the capacitor C3, and the pin 7 of the expansion chip D2, respectively; and pins 2 and 4 of the button K12 are connected to the pin 18 of the expansion chip D2;

[0073] Pins 1 and 3 of the button K13 are connected to the resistor R1, the capacitor C5, and the pin 4 of the expansion chip D2, respectively; pins 2 and 4 of the button K13 are connected to the pin 17 of the expansion chip D2;

[0074] Pins 1 and 3 of the button K14 are connected to the resistor R2, the capacitor C4, and the pin 5 of the expansion chip D2, respectively; and pins 2 and 4 of the button K14 are connected to the pin 17 of the expansion chip D2;

[0075] Pins 1 and 3 of the button K15 are connected to the resistor R3, the capacitor C2, and the pin 6 of the expansion chip D2, respectively; pins 2 and 4 of the button K15 are connected to the pin 17 of the expansion chip D2;

[0076] Pins 1 and 3 of the button K16 are connected to the resistor R4, the capacitor C3 and the pin 7 of the expansion chip D2 respectively, and pins 2 and 4 of the button K16 are connected to the pin 17 of the expansion chip D2;

[0077] Pins 1 and 3 of the button K17 are connected to the resistor R1, the capacitor C5, and the pin 4 of the expansion chip D2, respectively; and pins 2 and 4 of the button K17 are connected to the pin 16 of the expansion chip D2;

[0078] Pins 1 and 3 of the button K18 are connected to the resistor R2, the capacitor C4, and the pin 5 of the expansion chip D2, respectively; and pins 2 and 4 of the button K18 are connected to the pin 16 of the expansion chip D2;

[0079] Pins 1 and 3 of the button K19 are connected to the resistor R3, the capacitor C2, and the pin 6 of the expansion chip D2, respectively; and pins 2 and 4 of the button K19 are connected to the pin 16 of the expansion chip D2;

[0080] Pins 1 and 3 of the button K20 are connected to the resistor R4, the capacitor C3, and the pin 7 of the expansion chip D2, respectively; pins 2 and 4 of the button K20 are connected to the pin 16 of the expansion chip D2;

[0081] The keys K1, K2, K3 and K4 are arranged in the same row, the keys K5, K6, K7 and K8 are arranged in the same row, the keys K9, K10, K11 and K12 are arranged in the same row, the keys K13, K14, K15 and K16 are arranged in the same row, the keys K17, K18, K19 and K20 are arranged in the same row; the keys K1, K5, K9, K13 and K17 are arranged in the same column, the keys K2, K6, K10, K14 and K18 are arranged in the same column, the keys K3, K7, K1 1. Key K15 and key K19 are arranged in the same column, and key K4, key K8, key K12, key K16 and key K20 are arranged in the same column; pins 4, 5, 6, and 7 of the expansion chip D2 correspond to network labels COL_0, COL_1, COL_2, and COL_3 as the column coordinates of the keys, and pins 20, 19, 18, 17, and 16 of the expansion chip D2 correspond to network labels ROW_0, ROW_1, ROW_2, ROW_3, and ROW_4 as the row coordinates of the keys, respectively. This dot matrix form of rows and columns can accurately control multiple keys and is easy to expand; the utility model uses 20 keys to form a matrix multi-bit key circuit with 5 rows and 4 columns.

[0082] Specifically, in this embodiment, the third protection circuit includes a capacitor C2; one end of the capacitor C2 is respectively connected to the I / O port expansion circuit and the multi-bit key circuit, and the other end of the capacitor C2 is grounded; in the utility model, the third protection circuit includes a capacitor C3, a capacitor C2, a capacitor C4 and a capacitor C5; one end of the capacitor C3, the capacitor C2, the capacitor C4 and the capacitor C5 is connected to the multi-bit key circuit, and the other end of the capacitor C3, the capacitor C2, the capacitor C4 and the capacitor C5 is grounded; the third protection circuit improves the stability of the circuit and reduces electromagnetic interference.

[0083] Specifically, in this embodiment, the first pull-up circuit includes a resistor R1, a resistor R2, a resistor R3 and a resistor R4; one end of the resistor R1, the resistor R2, the resistor R3 and the resistor R4 is connected to the power supply end, and the other end of the resistor R1, the resistor R2, the resistor R3 and the resistor R4 is connected to the multi-bit key circuit; the stability and reliability of the input signal are ensured by the first pull-up circuit, thereby improving the anti-interference ability of the circuit.

[0084] Specifically, in this embodiment, the external interface circuit includes a plug XS29;

[0085] Pin 1 of the plug XS29 is connected to the second protection circuit; the second protection circuit includes a capacitor C6, a TVS tube V2 and a bidirectional anti-static tube D3; one end of the capacitor C6 is respectively connected to pin 1 of the plug XS29, the power supply end, the bidirectional anti-static tube D3 and the TVS tube V2, and the other ends of the bidirectional anti-static tube D3, the capacitor C6 and the TVS tube V2 are grounded; the capacitor C6 improves the stability of the circuit and reduces electromagnetic interference. The second protection circuit can suppress instantaneous overvoltage and protect circuit components from damage by instantaneous surge pulse voltage. At the same time, the bidirectional anti-static tube D3 is provided to achieve overvoltage protection of the circuit and prevent damage to sensitive electronic components caused by static electricity by absorbing the large current generated by electrostatic discharge.

[0086] Pins 2, 3, and 4 of the plug XS29 are connected to the I / O port expansion circuit;

[0087] Pin 5 of the XS29 plug is grounded.

[0088] Specifically, in this embodiment, the method for reading key values ​​of a keyboard circuit with multiple keys includes the following steps:

[0089] S1, initialize the expansion chip D2 of the I / O port expansion circuit;

[0090] S2. Configure the input and output ports of the expansion chip D2, write the row signals ROW_0, ROW_1, ..., ROW_M-1 of the key circuit to all 0, and periodically read the column signals COL_0, COL_1, ..., COL_N-1 of the key circuit. If a key is pressed, COL_y = 0. At this time, the I / O port expansion circuit outputs the interrupt signal INT_K = 0 and records the value of y in the column signal.

[0091] Configure the input and output ports of the expansion chip D2, specifically:

[0092] Configure pins 4, 5, 6, and 7 of the expansion chip D2 as input ports, and configure pins 20, 19, 18, 17, and 16 of the expansion chip D2 as output ports;

[0093] Wherein, ROW_M-1 is the row signal of the M-th row key, M is the number of rows of keys in the key circuit, 1<M≤8, COL_N-1 is the column signal of the N-th column key, N is the number of columns of keys in the key circuit, 1<N≤8, COL_y is the column signal of the y-th column key, 1<y≤8;

[0094] S3. The CPU enters the interrupt service routine and operates the expansion chip D2. Specifically, the row signals of the key circuit are assigned a value of 1 one by one. At the same time, the value of the column signal COL_y is read. If the value of the column signal COL_y is 1, the row and column numbers of the key at this time are recorded as the coordinates of the pressed key.

[0095] Specifically, in this embodiment, the utility model directly expands the I / O port on the CPU through the I / O port expansion circuit, which can expand two groups of I / O ports, and constructs a key circuit through the two groups of I / O ports, which only occupies one I / O port and one interrupt interface of the CPU, greatly reducing the number of I / O ports occupied by the CPU, reducing the resource consumption of the CPU, and shortening the response time of the key; at the same time, by reading the key value of the key circuit according to the interrupt signal of the I / O port expansion circuit, it is possible to obtain in real time which key is pressed, reducing the CPU overhead and accurately reading the key value of the key.

[0096] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. All equivalent structural transformations made based on the contents of the present invention specification and drawings, or direct / indirect applications in other related technical fields, within the scope of the present invention are included in the patent protection scope of the present invention.

Claims

1. A keyboard circuit with multiple keys, characterized in that: include: I / O port expansion circuit, key circuit and external interface circuit; The I / O port expansion circuit is connected to the key circuit and the external interface circuit respectively; the I / O port expansion circuit is also connected to the I / O port of the CPU; The I / O port expansion circuit is used to expand the I / O port of the CPU, and to obtain the key signal of the key circuit, and transmit the key signal to the CPU through the I / O port; The key circuit is used to collect key signals and transmit the key signals to the I / O port expansion circuit.

2. A multi-key keyboard circuit according to claim 1, characterized in that: The I / O port expansion circuit includes an expansion chip D2; Pin 1 of the expansion chip D2 is connected to the interrupt interface of the CPU; Pins 2, 3, 12, and 21 of the expansion chip D2 are grounded; Pins 4, 5, 6, and 7 of the expansion chip D2 are connected to the output end of the keyboard circuit; Pins 16, 17, 18, 19, and 20 of the expansion chip D2 are connected to the input end of the keyboard circuit; Pins 22 and 23 of the expansion chip D2 are connected to the second pull-up circuit and the external interface circuit respectively; Pin 24 of the expansion chip D2 is connected to the first protection circuit.

3. A keyboard circuit with multiple keys according to claim 2, characterized in that: The first protection circuit includes a capacitor C1, a TVS tube V1, and a bidirectional anti-static tube D1; One end of the capacitor C1 is connected to the 24-pin of the expansion chip D2 and the power supply end respectively, and the other end of the capacitor C1 is connected to the bidirectional anti-static tube D1, the TVS tube V1 and the ground end respectively, and the other ends of the bidirectional anti-static tube D1 and the TVS tube V1 are connected to the power supply end.

4. The multi-key keyboard circuit according to claim 2, characterized in that: The second pull-up circuit includes a resistor R6 and a resistor R7; one end of the resistor R6 is connected to the resistor R7 and the power supply end respectively, the other end of the resistor R6 is connected to pin 23 of the expansion chip D2, and the other end of the resistor R7 is connected to pin 22 of the expansion chip D2.

5. A multi-key keyboard circuit according to any one of claims 1 to 4, characterized in that: The key circuit includes a first pull-up circuit, a multi-bit key circuit and a third protection circuit; one end of the first pull-up circuit is connected to the power supply end, the other end of the first pull-up circuit is connected to the multi-bit key circuit, the multi-bit key circuit is respectively connected to the I / O port expansion circuit and the third protection circuit, and the other end of the third protection circuit is grounded.

6. The multi-key keyboard circuit according to claim 5, characterized in that: The multi-bit key circuit adopts an M×N matrix multi-bit key circuit; wherein M is the number of rows of keys in the key circuit, 1<M≤8, and N is the number of columns of keys in the key circuit, 1<N≤8.

7. The multi-key keyboard circuit according to claim 6, characterized in that: The multi-bit key circuit adopts a 5×4 matrix multi-bit key circuit; The 5×4 matrix multi-bit key circuit includes a key K1, a key K2, ..., a key K20; Pins 1 and 3 of the button K1, button K2, ..., button K20 are respectively connected to the first pull-up circuit, the third protection circuit and the I / O port expansion circuit, and pins 2 and 4 of the button K1, button K2, ..., button K20 are connected to the I / O port expansion circuit.

8. The multi-key keyboard circuit according to claim 5, characterized in that: The third protection circuit includes a capacitor C2; one end of the capacitor C2 is connected to the I / O port expansion circuit and the multi-bit key circuit respectively, and the other end of the capacitor C2 is grounded.

9. The multi-key keyboard circuit according to claim 5, characterized in that: The first pull-up circuit includes a resistor R1; one end of the resistor R1 is connected to the power supply end, and the other end of the resistor R1 is connected to the multi-bit key circuits respectively.

10. A multi-key keyboard circuit according to any one of claims 1 to 4, characterized in that: The external interface circuit includes a plug XS29; Pin 1 of the plug XS29 is connected to a second protection circuit; the second protection circuit includes a capacitor C6, a TVS tube V2, and a bidirectional anti-static tube D3; One end of the capacitor C6 is connected to pin 1 of the plug XS29, the power supply terminal, the bidirectional anti-static tube D3, and the TVS tube V2, respectively. The other ends of the bidirectional anti-static tube D3, the capacitor C6, and the TVS tube V2 are grounded. Pins 2, 3, and 4 of the plug XS29 are connected to the I / O port expansion circuit; Pin 5 of the XS29 plug is grounded.

Citation Information

Patent Citations

  • Capacitanc response keying circuit

    CN207691780U