A key detection circuit based on a 3 / 8 decoder
By using a key detection circuit based on a 3/8 decoder, the problems of insufficient microcontroller pins and misidentification of multiple keys in current protection devices are solved, achieving accurate and fast key detection, reducing costs and improving system reliability.
Patent Information
- Application Number
- CN202522597483.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-08
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2035-12-08
AI Technical Summary
In the existing technology, the number of single-chip microcomputer pins in the current protection device is insufficient, which makes button detection difficult. Moreover, multi-button detection is prone to misidentification or high cost. Existing solutions have problems such as increased cost due to pins, poor anti-interference ability, or high risk of misidentification.
A key detection circuit based on a 3/8 decoder is adopted, including an MCU, a switching control circuit, a 3/8 decoder, and first and second group key circuits. Key scanning and anti-bounce processing are realized through the 3/8 decoder and anti-bounce circuit, reducing the MCU pin requirements and improving the accuracy and flexibility of multi-key detection.
It achieves accurate and fast multi-button detection, reduces the number of MCU pins required, lowers costs, improves anti-interference and reliability, and avoids misidentification of multiple buttons.
Smart Images

Figure CN224987429U_ABST
Abstract
Description
Technical Field
[0001] This utility model relates to the field of key detection circuit technology, and in particular to a key detection circuit based on a 3 / 8 decoder. Background Technology
[0002] Current protection devices require buttons to perform functions such as parameter setting and data query. Currently, mainstream current protection devices typically have eight or more buttons, primarily using eight pins of an internal microcontroller chip to detect button presses. However, with the increasing intelligence of current protection devices, the required number of microcontroller pins is gradually increasing, often exceeding the available pin count. Current solutions include: first, replacing the microcontroller signal chip with one with more pins to expand functionality; second, using buttons to switch resistor values to generate different voltages, which are then collected by the microcontroller's ADC pins for button detection; and third, using a dedicated button detection chip. However, these methods introduce new problems. Method one, requiring a microcontroller with more pins, increases product cost, and the larger chip area complicates PCB layout. Method two, while having the fewest pins, uses analog signals, resulting in poor interference resistance; simultaneous button presses can lead to misidentification. Method three, using dedicated chips, is more expensive and suitable for multi-button applications.
[0003] Patent application CN201410461468.0 discloses a key detection circuit. Different resistors are connected in the circuit for each key press; utilizing the voltage divider principle, different key presses generate different voltages. These voltages are then processed by an operational amplifier conditioning circuit and input to the analog signal acquisition channel of a microcontroller for analog-to-digital conversion to achieve key detection. This solution requires only one I / O port to detect multiple keys. However, using analog signals for detection results in a complex conditioning circuit. With more keys, the voltage differences are smaller, making it susceptible to interference. When multiple keys are pressed, the sampled values may fall within the recognition range of other keys, leading to misidentification or failure to recognize the keys. Overall, this solution is unsuitable and carries significant risk in current protection device applications, as misidentification could cause the current protection device to malfunction. Therefore, there is an urgent need to propose a key detection circuit based on a 3 / 8 decoder to solve the technical problem of accurately and quickly acquiring key data and detecting multiple keys. Utility Model Content
[0004] The main purpose of this invention is to propose a key detection circuit based on a 3 / 8 decoder, which aims to solve the technical problem of how to accurately and quickly realize key acquisition and multi-key key detection.
[0005] To achieve the above objectives, this utility model provides a key detection circuit based on a 3 / 8 decoder, wherein the key detection circuit based on the 3 / 8 decoder includes:
[0006] The system comprises an MCU, a switching control circuit, a 3 / 8 decoder, a first set of key circuits, and a second set of key circuits. The output of the MCU is connected to the input of the 3 / 8 decoder and the second set of key circuits, respectively. The output of the 3 / 8 decoder is connected to the input of the first set of key circuits. The outputs of both the first and second sets of key circuits are connected to the input of the MCU. The MCU is connected to the switching control circuit, and the switching control circuit is connected to the 3 / 8 decoder.
[0007] The key detection circuit based on the 3 / 8 decoder includes at least one 3 / 8 decoder, a first set of key circuits, and a second set of key circuits.
[0008] In one preferred embodiment, the switching control circuit includes a transistor V1, a resistor R2, and three sets of resistors R3; the base of the transistor V1 is connected to the resistor R3, the other end of the resistor R3 is connected to the 3 / 8 decoder, the collector of the transistor V1 is connected to the resistor R2 and the MCU respectively, the other end of the resistor R2 is connected to the power supply, and the emitter of the transistor V1 is grounded.
[0009] In one preferred embodiment, the transistor V1 is an NPN transistor.
[0010] In one preferred embodiment, the 3 / 8 decoder includes a 3 / 8 decoder chip U1 and a first filter circuit; the 3 / 8 decoder chip U1 is connected to the MCU, the first set of key circuits, the switching control circuit and the first filter circuit respectively;
[0011] The first filter circuit includes a capacitor C1; one end of the capacitor C1 is connected to the 3 / 8 decoder chip U1 and the power supply terminal respectively, and the other end of the capacitor C1 is grounded.
[0012] One preferred embodiment is that the first group of button circuits includes a maximum of eight identical first button circuits.
[0013] In one preferred embodiment, the first button detection circuit includes a diode D1 and a button K1;
[0014] The cathode of diode D1 is connected to a 3 / 8 decoder, the anode of diode D1 is connected to button K1, and the other end of button K1 is connected to the MCU.
[0015] One preferred embodiment is that the second set of button circuits includes a maximum of eight identical second button circuits.
[0016] In one preferred embodiment, the second button circuit includes a diode D9 and a button K9;
[0017] The cathode of diode D9 is connected to the MCU, the anode of diode D9 is connected to button K9, and the other end of button K9 is connected to the MCU.
[0018] In one preferred embodiment, the key detection circuit based on the 3 / 8 decoder further includes a debounce circuit; the debounce circuit includes an inverted Schmitt trigger U2A, a resistor R1, and a capacitor C3; pin 1 of the inverted Schmitt trigger U2A is connected to the resistor R1, the capacitor C3, the first set of key circuits, and the second set of key circuits, respectively; pin 7 of the inverted Schmitt trigger U2A and the other end of the capacitor C3 are grounded; pin 14 of the inverted Schmitt trigger U2A and the other end of the resistor R1 are connected to the power supply terminal; and pin 2 of the inverted Schmitt trigger U2A is connected to the MCU.
[0019] In one preferred embodiment, the MCU includes a controller U3 and a second filtering circuit; the controller U3 is connected to a second set of key circuits, a second filtering circuit, a 3 / 8 decoder, and a switching control circuit, respectively; the second filtering circuit includes a capacitor C2; one end of the capacitor C2 is connected to the controller U3 and the power supply terminal, respectively, and the other end of the capacitor C2 is grounded.
[0020] In the above technical solution of this utility model, the key detection circuit based on a 3 / 8 decoder includes: an MCU, a switching control circuit, a 3 / 8 decoder, a first set of key circuits, and a second set of key circuits. The output terminal of the MCU is connected to the input terminals of the 3 / 8 decoder and the second set of key circuits, respectively. The output terminal of the 3 / 8 decoder is connected to the input terminal of the first set of key circuits. The output terminals of both the first and second sets of key circuits are connected to the input terminals of the MCU. The MCU is connected to the switching control circuit, and the switching control circuit is connected to the 3 / 8 decoder. The key detection circuit based on the 3 / 8 decoder includes at least one set of 3 / 8 decoders, a first set of key circuits, and a second set of key circuits. This utility model solves the technical problem of how to accurately and quickly realize key acquisition and multi-key key detection. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this utility model or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this utility model. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0022] Figure 1 This is a first schematic diagram of a key detection circuit based on a 3 / 8 decoder according to an embodiment of the present invention;
[0023] Figure 2 This is a second schematic diagram of a key detection circuit based on a 3 / 8 decoder according to an embodiment of the present invention;
[0024] Figure 3 This is a schematic diagram of the 8-bit decoder and the first set of key detection circuits in Embodiment 3 of this utility model;
[0025] Figure 4 This is a schematic diagram of the MCU in an embodiment of the present invention.
[0026] The realization of the purpose, functional features and advantages of this utility model will be further explained in conjunction with the implementation methods and with reference to the accompanying drawings. Detailed Implementation
[0027] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0028] Furthermore, in this utility model, descriptions involving "first," "second," etc., are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include at least one of those features.
[0029] Furthermore, the technical solutions of the various embodiments of this utility model can be combined with each other, but only if they are based on the ability of a person skilled in the art to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such combination of technical solutions does not exist and is not within the scope of protection claimed by this utility model.
[0030] See Figures 1-4 According to one aspect of this utility model, a key detection circuit based on a 3 / 8 decoder is provided. The key detection circuit includes: an MCU, a switching control circuit, a 3 / 8 decoder, a first set of key circuits, and a second set of key circuits. The output terminal of the MCU is connected to the input terminals of the 3 / 8 decoder and the second set of key circuits, respectively. The output terminal of the 3 / 8 decoder is connected to the input terminal of the first set of key circuits. The output terminals of both the first and second sets of key circuits are connected to the input terminal of the MCU. The MCU is connected to the switching control circuit, and the switching control circuit is connected to the 3 / 8 decoder.
[0031] The key detection circuit based on the 3 / 8 decoder includes at least one 3 / 8 decoder, a first set of key circuits, and a second set of key circuits.
[0032] Specifically, in this embodiment, the switching control circuit includes a transistor V1, a resistor R2, and three sets of resistors R3; the base of transistor V1 is connected to resistor R3, the other end of resistor R3 is connected to a 3 / 8 decoder, the collector of transistor V1 is connected to resistor R2 and the MCU respectively, the other end of resistor R2 is connected to the power supply, and the emitter of transistor V1 is grounded; transistor V1 is an NPN transistor; resistor R2 is a pull-up current limiting resistor. R3 is a current-limiting resistor, which adds the HC138_SW switching control signal. When HC138_SW is high, transistor V1 is turned on, pin 3 of transistor V1 is low, the MCU does not work, and the 3 / 8 decoder works to scan buttons K1 to K8 in the first group of button circuits. When HC138_SW is low, transistor V1 is not turned on, pin 3 of transistor V1 is high, the 3 / 8 decoder does not work, and the MCU works to scan buttons K9 to K16.
[0033] Specifically, in this embodiment, the 3 / 8 decoder includes a 3 / 8 decoder chip U1 and a first filtering circuit; the 3 / 8 decoder chip U1 is connected to the MCU, the first set of key circuits, the switching control circuit, and the first filtering circuit; the first filtering circuit includes a capacitor C1; one end of the capacitor C1 is connected to the 3 / 8 decoder chip U1 and the power supply terminal, and the other end of the capacitor C1 is grounded; the capacitor C1 is the VCC pin filtering capacitor of the 3 / 8 decoder, and the capacitor C3 is the key signal filtering capacitor.
[0034] Specifically, in this embodiment, the first group of button circuits includes up to eight identical first button circuits. The first button detection circuit includes a diode D1 and a button K1; the cathode of the diode D1 is connected to a 3 / 8 decoder, the anode of the diode D1 is connected to the button K1, and the other end of the button K1 is connected to the MCU.
[0035] Specifically, in this embodiment, the second set of button circuits includes up to eight identical second button circuits; the second button circuit includes a diode D9 and a button K9; the cathode of the diode D9 is connected to the MCU, the anode of the diode D9 is connected to the button K9, and the other end of the button K9 is connected to the MCU.
[0036] Specifically, in this embodiment, the key detection circuit based on the 3 / 8 decoder further includes a debounce circuit; the debounce circuit includes an inverted Schmitt trigger U2A, a resistor R1, and a capacitor C3; pin 1 of the inverted Schmitt trigger U2A is connected to the resistor R1, the capacitor C3, the first set of key circuits, and the second set of key circuits respectively; pin 7 of the inverted Schmitt trigger U2A and the other end of the capacitor C3 are grounded; pin 14 of the inverted Schmitt trigger U2A and the other end of the resistor R1 are connected to the power supply; pin 2 of the inverted Schmitt trigger U2A is connected to the MCU; the output terminals of keys K1 to K8 of the first key circuit and the output terminals of keys K9 to K16 of the second key circuit are connected together. After debounce processing by the inverted Schmitt trigger U2A, the key detection signal KEY_MCU is output and input to the MCU for key recognition; when no key is pressed, due to the pull-up input of the resistor R1, the KEY_MCU signal remains low after processing by the inverted Schmitt trigger U2A.
[0037] Specifically, in this embodiment, the MCU includes a controller U3 and a second filtering circuit; the controller U3 is connected to the second set of key circuits, the second filtering circuit, the 3-to-8 decoder, and the switching control circuit, respectively; the second filtering circuit includes a capacitor C2; one end of the capacitor C2 is connected to the controller U3 and the power supply terminal, and the other end of the capacitor C2 is grounded; HC138_A, HC138_B, and HC138_C are the encoded signals output by the MCU, which are processed by the 3-to-8 decoder and then have their pins successively change from high level to low level; the encoding logic of the 3-to-8 decoder is shown in Table 1. Encoding HC138_A, HC138_B, and HC138_C causes the Y0-7 pins of the 3-to-8 decoder to cyclically generate low-level pulse signals.
[0038] Table 1 Encoding Logic of the 3 / 8 Decoder
[0039]
[0040] Specifically, in this embodiment, when one of the eight buttons, Kx, is pressed, a low-level pulse is generated by the Yx-1 converter connected to the 3x8 decoder via diodes. Because button Kx is pressed and turned on, the input level of pin 1 of the inverted Schmitt trigger U2A is also pulled low, generating a low-level pulse. After the inverted Schmitt trigger U2A performs inverse debouncing, KEY_MCU generates a high-level pulse input to the MCU. When the MCU detects the high-level pulse, it can determine the pin number of the 3x8 decoder outputting a low level based on the state of the outputs HC138_A, HC138_B, and HC138_C, thus confirming the pressed button number and achieving button detection. When two or more of the eight buttons are pressed, the high-level signal output by pin Y0-7 of the 3x8 decoder is isolated by diodes D1 to D8, and the inverted Schmitt trigger U2A will only recognize the low-level transition. Pressing multiple buttons does not affect the bit-by-bit low-level detection of pin Y0-7.
[0041] Specifically, in this embodiment, the key detection circuit based on the 3 / 8 decoder includes at least one set of 3 / 8 decoders, a first set of key circuits, and a second set of key circuits. That is, this invention can detect at least 16 key buttons. Furthermore, to meet the needs of multiple scenarios, the number of 3 / 8 decoders can be increased to add the first set of key circuits. Using 3 / 8 decoders for key detection reduces the number of MCU pins required, lowers costs, and allows for simultaneous pressing of multiple keys for combined key functions. This method is more reliable than analog signal acquisition, does not require occupying analog signal acquisition channels, and offers more flexible expansion. Additionally, the number of MCU pins can be increased to add the second set of key circuits.
[0042] The above are merely preferred embodiments of this utility model and do not limit the patent scope of this utility model. Any equivalent structural transformations made based on the inventive concept of this utility model and the contents of this utility model specification and drawings, or direct / indirect applications in other related technical fields, are included within the patent protection scope of this utility model.
Claims
1. A key detection circuit based on a tri-octal decoder, characterized in that, include: MCU, switching control circuit, 3-to-8 decoder, first group of key circuit and second group of key circuit; The output terminal of the MCU is connected to the input terminal of the 3-to-8 decoder and the second set of key circuits, respectively. The output terminal of the 3-to-8 decoder is connected to the input terminal of the first set of key circuits. The output terminals of both the first set of key circuits and the second set of key circuits are connected to the input terminal of the MCU. The MCU is connected to the switching control circuit, and the switching control circuit is connected to the 3-to-8 decoder. The key detection circuit based on the 3 / 8 decoder includes at least one 3 / 8 decoder, a first set of key circuits, and a second set of key circuits.
2. The key detection circuit based on a 3 / 8 decoder according to claim 1, characterized in that, The switching control circuit includes a transistor V1, a resistor R2, and three sets of resistors R3. The base of the transistor V1 is connected to the resistor R3, the other end of the resistor R3 is connected to the 3 / 8 decoder, the collector of the transistor V1 is connected to the resistor R2 and the MCU, the other end of the resistor R2 is connected to the power supply, and the emitter of the transistor V1 is grounded.
3. The key detection circuit based on a 3 / 8 decoder according to claim 2, characterized in that, The transistor V1 is an NPN transistor.
4. A key detection circuit based on a 3 / 8 decoder according to any one of claims 1-2, characterized in that, The 3-to-8 decoder includes a 3-to-8 decoder chip U1 and a first filter circuit; the 3-to-8 decoder chip U1 is connected to the MCU, the first set of key circuits, the switching control circuit and the first filter circuit respectively; The first filter circuit includes a capacitor C1; one end of the capacitor C1 is connected to the 3 / 8 decoder chip U1 and the power supply terminal respectively, and the other end of the capacitor C1 is grounded.
5. A key detection circuit based on a 3 / 8 decoder according to any one of claims 1-2, characterized in that, The first set of button circuits includes a maximum of eight identical first button circuits.
6. The key detection circuit based on a 3 / 8 decoder according to claim 5, characterized in that, The first button circuit includes a diode D1 and a button K1; The cathode of diode D1 is connected to a 3 / 8 decoder, the anode of diode D1 is connected to button K1, and the other end of button K1 is connected to the MCU.
7. A key detection circuit based on a 3 / 8 decoder according to any one of claims 1-2, characterized in that, The second set of button circuits includes a maximum of eight identical second button circuits.
8. A key detection circuit based on a 3 / 8 decoder according to claim 7, characterized in that, The second button circuit includes diode D9 and button K9; The cathode of diode D9 is connected to the MCU, the anode of diode D9 is connected to button K9, and the other end of button K9 is connected to the MCU.
9. A key detection circuit based on a 3 / 8 decoder according to any one of claims 1-2, characterized in that, The key detection circuit based on the 3 / 8 decoder also includes a debounce circuit; the debounce circuit includes an inverted Schmitt trigger U2A, a resistor R1, and a capacitor C3; pin 1 of the inverted Schmitt trigger U2A is connected to the resistor R1, the capacitor C3, the first group of key circuits, and the second group of key circuits, respectively; pin 7 of the inverted Schmitt trigger U2A and the other end of the capacitor C3 are grounded; pin 14 of the inverted Schmitt trigger U2A and the other end of the resistor R1 are connected to the power supply terminal; and pin 2 of the inverted Schmitt trigger U2A is connected to the MCU.
10. A key detection circuit based on a 3 / 8 decoder according to any one of claims 1-2, characterized in that, The MCU includes a controller U3 and a second filter circuit. The controller U3 is connected to a second set of key circuits, a second filter circuit, a 3 / 8 decoder, and a switching control circuit. The second filter circuit includes a capacitor C2. One end of the capacitor C2 is connected to the controller U3 and the power supply, and the other end of the capacitor C2 is grounded.
Citation Information
Patent Citations
Key detection circuit
CN105406875A
