A circuit for detecting multiple keys based on one IO

CN224721874UActive Publication Date: 2026-09-04FOSHAN CHENHAO INTELLIGENT ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202522241016.8
Authority / Receiving Office
CN · China
Patent Type
Utility models(China)
Current Assignee / Owner
Filing Date
2025-10-23
Publication Date
2026-09-04
Estimated Expiration
2035-10-23

AI Technical Summary

Technical Problem

现有技术中,微处理器一般是一个按键对应一个IO口,如果按键数量过多,就会占用较多的IO口资源,还有一种方式是使用矩阵扫描的方式,矩阵扫描的方式就是在键盘中设置多个按键,将按键排列成矩阵形式,采用逐行或逐列的扫描就可以读出任何位置按键的状态,使用矩阵扫描的方式虽然比通过一个按键对应一个IO口的方式减少IO口的占用,但是仍然需要占用芯片的多个IO口

Benefits of technology

[0009] Compared with the prior art, the beneficial effects of this utility model are as follows: The circuit based on one IO to detect multiple buttons includes a button signal detection terminal, a charging/discharging terminal, and a ground terminal. The button signal detection terminal is electrically connected to the charging/discharging terminal through a current-limiting resistor. The charging/discharging terminal is electrically connected to the ground terminal through a charging/discharging capacitor. The charging/discharging terminal is also electrically connected to the ground terminal through multiple discharge circuits connected in parallel. Each discharge circuit includes a button and a discharge resistor connected in series. The resistance value of the discharge resistor in each discharge circuit is different, so that multiple buttons can be scanned and identified using only one ordinary IO port of the MCU, saving the occupation of the MCU's IO port resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN224721874U_ABST
    Figure CN224721874U_ABST
Patent Text Reader

Abstract

The utility model belongs to signal detection circuit technical field especially for a kind of circuit based on one IO detection multiple key, this based on one IO detection multiple key circuit includes key signal detection terminal, charge-discharge terminal and ground terminal, key signal detection terminal is electrically connected to charge-discharge terminal by current-limiting resistance, charge-discharge terminal is electrically connected to ground terminal by charge-discharge capacitor, charge-discharge terminal is also electrically connected to ground terminal by multiple discharge circuits in parallel respectively, including the key and discharge resistance in series in each discharge circuit respectively, the resistance value of discharge resistance in each discharge circuit is different, so that only using the ordinary IO port of MCU can realize the scanning identification to multiple key, saves the occupation of IO port resource to MCU.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This utility model belongs to the field of signal detection circuit technology, specifically relating to a circuit that detects multiple buttons based on one IO. Background Technology

[0002] Microprocessors can identify different input signals by connecting different buttons, and then control the corresponding device actions to perform tasks or control the operating state of the corresponding device based on these input signals. In existing technology, microprocessors typically use one I / O port per button. If there are too many buttons, this will consume a significant amount of I / O port resources. Another approach is to use matrix scanning. Matrix scanning involves setting multiple buttons on the keyboard and arranging them in a matrix. By scanning row by row or column by column, the state of any button can be read. While matrix scanning reduces I / O port usage compared to one button per I / O port, it still requires multiple I / O ports on the chip. Utility Model Content

[0003] The present invention aims to provide a circuit that detects multiple buttons based on one IO, so that the controller can detect the on / off state of multiple buttons through one IO, thereby reducing the occupation of chip IO ports.

[0004] To achieve the above objectives, the present invention adopts the following technical solution: A circuit for detecting multiple buttons based on a single I / O pin is provided, including a button signal detection terminal, a charging / discharging terminal, and a ground terminal. The button signal detection terminal is electrically connected to the charging / discharging terminal via a current-limiting resistor, and the charging / discharging terminal is electrically connected to the ground terminal via a charging / discharging capacitor. The charging / discharging terminal is also electrically connected to the ground terminal via a first discharge circuit and a second discharge circuit connected in parallel. The first discharge circuit includes a first button and a first discharge resistor connected in series, and the second discharge circuit includes a second button and a second discharge resistor connected in series. The resistance values ​​of the first discharge resistor and the second discharge resistor are different.

[0005] Preferably, the charging / discharging terminal is also electrically connected to the grounding terminal through a third discharge circuit connected in parallel with the first and second discharge circuits. The third discharge circuit includes a third button and a third discharge resistor connected in series. The resistance values ​​of the third discharge resistor are different from those of the first and second discharge resistors.

[0006] Preferably, the charging and discharging terminal is also electrically connected to the grounding terminal through a fourth discharge circuit connected in parallel with the first discharge circuit, the second discharge circuit, and the third discharge circuit. The fourth discharge circuit includes a fourth button and a fourth discharge resistor connected in series. The resistance value of the fourth discharge resistor is different from that of the first discharge resistor, the second discharge resistor, and the third discharge resistor.

[0007] Preferably, the capacitance of the charging / discharging capacitor is 0.1μF, and the resistance of the current-limiting resistor is 100Ω.

[0008] Preferably, the first discharge resistor has a resistance of 2kΩ, the second discharge resistor has a resistance of 4.7kΩ, the third discharge resistor has a resistance of 10kΩ, and the fourth discharge resistor has a resistance of 20kΩ.

[0009] Compared with the prior art, the beneficial effects of this utility model are as follows: The circuit based on one IO to detect multiple buttons includes a button signal detection terminal, a charging / discharging terminal, and a ground terminal. The button signal detection terminal is electrically connected to the charging / discharging terminal through a current-limiting resistor. The charging / discharging terminal is electrically connected to the ground terminal through a charging / discharging capacitor. The charging / discharging terminal is also electrically connected to the ground terminal through multiple discharge circuits connected in parallel. Each discharge circuit includes a button and a discharge resistor connected in series. The resistance value of the discharge resistor in each discharge circuit is different, so that multiple buttons can be scanned and identified using only one ordinary IO port of the MCU, saving the occupation of the MCU's IO port resources. Attached Figure Description

[0010] The accompanying drawings are provided to further illustrate the present invention and form part of the specification. They are used together with the embodiments of the present invention to explain the present invention, but do not constitute a limitation thereof. In the drawings: Figure 1 This is a circuit schematic diagram of one embodiment of the present invention, which uses an I / O circuit to detect multiple buttons. Detailed Implementation

[0011] The technical solutions of the present utility model will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present utility model, and not all embodiments. Based on the embodiments of the present utility model, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of the present utility model.

[0012] In one embodiment, a circuit is provided for detecting multiple buttons based on a single I / O, such as... Figure 1As shown, the circuit for detecting multiple buttons based on one IO includes a button signal detection terminal B, a charging / discharging terminal A, and a ground terminal GND. The button signal detection terminal B is used to electrically connect to the MCU (microcontroller). The MCU identifies which button is in the conducting state by sensing the signal state of the button signal detection terminal B.

[0013] The button signal detection terminal B is electrically connected to the charging / discharging terminal A through the current-limiting resistor RX1. The current-limiting resistor RX1 is used to protect the safety of the corresponding terminal of the MCU. The charging / discharging terminal A is electrically connected to the ground terminal GND through the charging / discharging capacitor C1. The charging / discharging capacitor C1 is used to charge the corresponding button through the MCU and then discharge it to the corresponding button's discharge circuit.

[0014] The charging / discharging terminal A is electrically connected to the grounding terminal GND through a first discharge circuit and a second discharge circuit connected in parallel. All grounding terminals GND can share a single grounding terminal. Figure 1 As shown, the first discharge circuit includes a first button K1 and a first discharge resistor R1 connected in series, and the second discharge circuit includes a second button K2 and a second discharge resistor R2 connected in series. The resistance values ​​of the first discharge resistor R1 and the second discharge resistor R2 are different. Because the resistance values ​​of the first discharge resistor R1 and the second discharge resistor R2 are different, the discharge duration of the first discharge circuit and the second discharge circuit are different after the first button K1 or the second button K2 is turned on, providing a basis for the MCU to determine which button is closed.

[0015] In this embodiment, the charging / discharging terminal A is also electrically connected to the ground terminal through a third discharge circuit connected in parallel with the first and second discharge circuits. The third discharge circuit includes a third button K3 and a third discharge resistor R3 connected in series. The resistance value of the third discharge resistor R3 is different from that of the first discharge resistor R1 and the second discharge resistor R2. Additionally, the charging / discharging terminal A is also electrically connected to the ground terminal through a fourth discharge circuit connected in parallel with the first, second, and third discharge circuits. The fourth discharge circuit includes a fourth button K4 and a fourth discharge resistor R4 connected in series. The resistance value of the fourth discharge resistor R4 is different from that of the first, second, and third discharge resistors R1, R2, and R3.

[0016] The third and fourth discharge circuits here operate on the same principle as the first and second discharge circuits mentioned earlier, with the aim of providing a greater number of buttons. Depending on the required number of buttons, even more discharge circuits consisting of buttons and resistors can be added.

[0017] In this embodiment, the capacitance of the charging / discharging capacitor C1 is 0.1μF (a 105 capacitor is a capacitor with a capacitance of 0.1μF), the resistance of the current-limiting resistor RX1 is 100Ω (a 100R resistor is a resistor with a resistance of 100Ω), the resistance of the first discharge resistor R1 is 2kΩ, the resistance of the second discharge resistor R2 is 4.7kΩ, the resistance of the third discharge resistor R3 is 10kΩ, and the resistance of the fourth discharge resistor R4 is 20kΩ. Because the resistance values ​​of the first discharge resistor R1, the second discharge resistor R2, the third discharge resistor R3, and the fourth discharge resistor R4 differ significantly, the discharge time varies considerably, which helps ensure the accuracy of the MCU's judgment.

[0018] The working principle of this circuit, which detects multiple buttons using a single I / O pin, is as follows: First, configure the MCU's IO1 port to output a high level. The MCU's IO1 port charges the charging and discharging capacitor C1 through the current-limiting resistor RX1. The charging time is maintained for 2 milliseconds. After the charging time is completed, the MCU sets its IO1 port to a high-impedance input. The MCU can determine which button is closed by detecting the discharge time T1 when its IO1 port becomes a low level threshold.

[0019] If none of the buttons are pressed, the discharge time T1 will be very long. For example, if T1 > a certain value, it means that none of the buttons are pressed. This is because when the buttons are not pressed, the previously fully charged charging and discharging capacitor C1 has no path to release its charge and can remain at a high level (parasitic discharge does not need to be considered because its impact is too small).

[0020] If a button is pressed, the charging and discharging capacitor C1 has a discharge circuit, and the discharge time T1 becomes much shorter, which can distinguish whether a button has been pressed.

[0021] Since the resistance value of the resistor connected in series with each button is different, the discharge resistance after each button is closed is different, which will also lead to different discharge times. Therefore, the discharge time T1 is different for different buttons, so the MCU can distinguish which button is pressed.

[0022] This circuit, which detects multiple buttons using a single IO port, utilizes only one ordinary IO port of the MCU and does not require a dedicated AD port (analog-to-digital converter interface) to scan and identify multiple buttons, thus saving the MCU's IO port resources.

[0023] It should be noted that, unless otherwise defined, all terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure pertains, and terms such as those defined in a common dictionary should be interpreted as having a meaning consistent with their meaning in the context of the relevant art. It should also be understood that the above is a description of this disclosure and should not be considered as a limitation thereof. Although several exemplary embodiments of this disclosure have been described, those skilled in the art will readily understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of this invention. Therefore, all such modifications are intended to be included within the scope of this disclosure as defined in the claims, and will not be detailed here.

Claims

1. A circuit for detecting multiple buttons based on a single I / O, characterized in that, The device includes a button signal detection terminal, a charging / discharging terminal, and a ground terminal. The button signal detection terminal is electrically connected to the charging / discharging terminal via a current-limiting resistor. The charging / discharging terminal is electrically connected to the ground terminal via a charging / discharging capacitor. The charging / discharging terminal is also electrically connected to the ground terminal via a first discharge circuit and a second discharge circuit connected in parallel. The first discharge circuit includes a first button and a first discharge resistor connected in series. The second discharge circuit includes a second button and a second discharge resistor connected in series. The resistance values ​​of the first discharge resistor and the second discharge resistor are different.

2. The circuit for detecting multiple buttons based on one I / O as described in claim 1, characterized in that: The charging and discharging terminal is also electrically connected to the grounding terminal through a third discharge circuit connected in parallel with the first and second discharge circuits. The third discharge circuit includes a third button and a third discharge resistor connected in series. The resistance values ​​of the third discharge resistor are different from those of the first and second discharge resistors.

3. The circuit for detecting multiple buttons based on one I / O as described in claim 2, characterized in that: The charging and discharging terminal is also electrically connected to the grounding terminal through a fourth discharge circuit that is connected in parallel with the first discharge circuit, the second discharge circuit, and the third discharge circuit. The fourth discharge circuit includes a fourth button and a fourth discharge resistor connected in series. The resistance value of the fourth discharge resistor is different from that of the first discharge resistor, the second discharge resistor, and the third discharge resistor.

4. The circuit for detecting multiple buttons based on one I / O as described in claim 3, characterized in that: The capacitance of the charging / discharging capacitor is 0.1μF, and the resistance of the current-limiting resistor is 100Ω.

5. The circuit for detecting multiple buttons based on one I / O as described in claim 4, characterized in that: The first discharge resistor has a resistance of 2kΩ, the second discharge resistor has a resistance of 4.7kΩ, the third discharge resistor has a resistance of 10kΩ, and the fourth discharge resistor has a resistance of 20kΩ.