Key detection circuit and key detection method

By designing a combined structure of the first and second key detection modules, utilizing pull-up and pull-down branches, and combining processor level signal acquisition, the problem of low I/O port utilization in the key detection circuit is solved, multi-key detection is realized, and the overall cost of the device is reduced.

CN116643159BActive Publication Date: 2026-05-05DEEPAL AUTOMOBILE TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DEEPAL AUTOMOBILE TECH CO LTD
Filing Date
2023-05-26
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

Existing button detection circuits require a large number of controller I/O ports when there are many buttons, resulting in low I/O port utilization and an inability to effectively detect the open/closed state of multiple buttons.

Method used

The system employs a combination of a first button detection module and a second button detection module. Through the design of pull-up and pull-down branches, it utilizes pull-up and pull-down buttons and a second diode to connect the input/output interface. Combined with the processor's level signal acquisition and judgment, it realizes the detection of multiple buttons.

Benefits of technology

It improves the utilization efficiency of input/output ports, reduces the resource requirements of processor input/output ports, and lowers the overall cost of the machine.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116643159B_ABST
    Figure CN116643159B_ABST
Patent Text Reader

Abstract

This invention proposes a key detection circuit and a key detection method. The circuit includes: a first key detection module, comprising m pull-up / pull-down branches and one pull-down branch, with the m pull-up / pull-down branches connected in parallel. Each pull-up / pull-down branch has an input / output interface, and the input / output interface is connected to the pull-down button in the pull-down branch via a series-connected first diode; and a second key detection module, comprising N key detection units, each key detection unit being connected to one of the q input / output interfaces in the first key detection module via q input / output terminals, with each key detection unit having a different connection method to the first key detection module. This key detection circuit allows for the connection of multiple buttons, diodes, and pull-up resistors with fewer input / output ports, thereby improving the efficiency of input / output port utilization, reducing the resource requirements of the processor's input / output ports, and lowering the overall cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electronic technology, specifically to a key detection circuit and a key detection method. Background Technology

[0002] Key detection circuits are widely used in electronic products. The most common existing key detection circuit is that one key is directly connected to one I / O port (Input / Output) of the controller (i.e., a one-to-one connection). This key detection circuit is simple and direct. However, since one key needs to occupy one I / O port of the controller, when there are many keys, more I / O ports of the controller need to be occupied (the number of I / O ports required is equal to the number of keys), resulting in low utilization of the controller's I / O ports.

[0003] Chinese invention patent application number 201110458536.4 discloses a non-AD (analog to digital) key detection circuit. According to the circuit structure proposed in this invention, six keys can be detected using two non-AD I / O ports, and further, four I / O ports can be used to detect twelve keys. However, this circuit structure cannot detect a larger number of keys when using the same number of non-AD I / O ports. Summary of the Invention

[0004] This invention provides a key detection circuit and a key detection method to solve the technical problem of not being able to detect the open / closed state of keys when there are many keys.

[0005] This invention provides a key detection circuit, comprising: a first key detection module, which includes m pull-up / pull-down branches and one pull-down branch, wherein the m pull-up / pull-down branches are connected in parallel, each pull-up / pull-down branch includes a pull-up / pull-down button, and each pull-up / pull-down branch has an input / output interface. In each pull-up / pull-down branch, the input / output interface is pulled up or pulled down by the pull-up / pull-down button, and the input / output interface is connected to the pull-down button in the pull-down branch through a series first diode, thereby pulling down the input / output interface; and a second key detection module, which includes N key detection units, each key detection unit including n second diodes. The system comprises a tube and n buttons. Each button detection unit has q input / output terminals. Each button detection unit is connected one-to-one with q input / output interfaces in the first button detection module through the q input / output terminals, and the connection methods between each button detection unit and the first button detection module are different. M of the input / output interfaces are connected to a processor, which is configured to: acquire the level signals of the m input / output interfaces, or output fixed level signals to some of the input / output interfaces and acquire the level signals of the remaining input / output interfaces, and then determine the open / closed state of the pull-up / down buttons, the pull-down button, and the buttons based on the level signals of the m input / output interfaces; where m, n, N, and q are all positive integers.

[0006] In one embodiment of the present invention, each pull-up / pull-down branch includes a pull-up resistor and a pull-up / pull-down button. One end of the pull-up resistor is connected to the power supply, and the other end is connected to one end of the pull-up / pull-down button. The other end of the pull-up / pull-down button is grounded.

[0007] In one embodiment of the present invention, the pull-down branch includes a first diode and a pull-down button. One end of the first diode is connected to the input / output interface, and the other end of the first diode is connected to one end of the pull-down button, and the other end of the pull-down button is grounded.

[0008] In one embodiment of the present invention, n is 5 and q is 3. Each button detection unit is connected to 5 second diodes and 5 buttons. The 5 second diodes include a first second diode, a second second diode, a third second diode, a fourth second diode, and a fifth second diode. The 5 buttons include a first button, a second button, a third button, a fourth button, and a fifth button. The 3 input / output terminals include a first input / output terminal, a second input / output terminal, and a third input / output terminal. In one button detection unit, one end of the first button is connected to the first input / output terminal, the other end of the first button is connected to one end of the first second diode, and the other end of the first second diode is connected to the third input / output terminal. The first input / output terminal connects one end of the second diode to the second input / output terminal. The other end of the second diode is connected to one end of the second button. The other end of the second button is connected to one end of the first second diode. The other end of the first second diode is connected to the third input / output terminal. The first input / output terminal connects one end of the third second diode to the first input / output terminal. The other end of the third second diode is connected to one end of the third button. The other end of the third button is connected to the second input / output terminal. The second input / output terminal connects one end of the fourth second diode to the second button. The other end of the second button is connected to one end of the first second diode. The other end of the first second diode is connected to the third input / output terminal.

[0009] The second input / output terminal is connected to one end of the fourth button, the other end of the fourth button is connected to one end of the first second diode, and the other end of the first second diode is connected to the third input / output terminal; the second input / output terminal is connected to one end of the fifth button, the other end of the fifth button is connected to one end of the fifth second diode, and the other end of the fifth second diode is connected to the first input / output terminal.

[0010] In one embodiment of the present invention, by Calculate the maximum number of button detection units, and the number of button detection units. indivual.

[0011] This invention provides a key detection method, applied to the key detection circuit described in any of the above claims, characterized in that it includes: all m input / output interfaces are configured as first output interfaces; the processor collects the level signals of the m input / output interfaces and determines the open / closed state of the pull-up / pull-down buttons and the pull-down button based on the level signals of the m first output interfaces; a portion of the m input / output interfaces is configured as second output interfaces, and another portion is configured as input interfaces; the processor outputs the fixed level signal to the input interface; the processor collects the level signal of the second output interface and determines the open / closed state of the key based on the level signal of the second output interface and the level signal of the input interface.

[0012] In one embodiment of the present invention, m is 3. The m input / output interfaces are configured partly as second output interfaces and partly as input interfaces. The processor outputs a fixed-level signal to the input interfaces. The processor acquires the level signal of the second output interface and determines the open / closed state of the button based on the level signal of the second output interface and the level signal of the input interface. This includes: configuring the first input / output interface as the second output interface, configuring the second input / output interface as the second output interface, configuring the third input / output interface as the input interface, configuring the output interface as the button detection circuit outputting a level signal to the microprocessor, and configuring the input interface as the microprocessor inputting a level signal to the button detection circuit; if the input interface is a low-level signal, when the first input / output interface is detected to be low and the second input / output interface is detected to be high, the first button is determined to be closed; when both the first and second input / output interfaces are detected to be low, the second button is determined to be closed; when the first input / output interface is detected to be high and the second input / output interface is detected to be low, the fourth button is determined to be closed.

[0013] In one embodiment of the present invention, m is 3. The m input / output interfaces are configured as second output interfaces and another portion as input interfaces. The processor outputs the fixed-level signal to the input interface. The processor acquires the level signal of the second output interface and determines the open / closed state of the button based on the level signal of the second output interface and the level signal of the input interface. The method further includes: configuring the second input / output interface as an input interface, the first input / output interface as the second output interface, and the third input / output interface as a high-impedance state; if the input interface is a low-level signal, and a low-level output is detected from the first input / output interface, then the third button is determined to be closed.

[0014] In one embodiment of the present invention, m is 3. The m input / output interfaces are configured partly as second output interfaces and partly as input interfaces. The processor outputs the fixed-level signal to the input interface. The processor acquires the level signal of the second output interface and determines the open / closed state of the button based on the level signal of the second output interface and the level signal of the input interface. The method further includes: configuring the first input / output interface as an input interface, the second input / output interface as a second output interface, and the third input / output interface as a high-impedance state; if the input interface is a low-level signal and a low-level signal is detected from the second input / output interface, then the fifth button is determined to be closed.

[0015] In one embodiment of the present invention, m is 3, and all m input / output interfaces are configured as first output interfaces. The processor collects the level signals of the m first output interfaces and determines the open / closed state of the pull-up / down buttons and the pull-down button based on the level signals of the m first output interfaces, including: if the first input / output interface is detected to be low, the second input / output interface is detected to be high, and the third input / output interface is detected to be high, then the sixth button is determined to be closed; if the first input / output interface is detected to be high, the second input / output interface is detected to be low, and the third input / output interface is detected to be high, then the seventh button is determined to be closed; if the first input / output interface is detected to be high, the second input / output interface is detected to be high, and the third input / output interface is detected to be low, then the eighth button is determined to be closed; if the first input / output interface is detected to be low, the second input / output interface is detected to be low, and the third input / output interface is detected to be low, then the ninth button is determined to be closed; if the first input / output interface is detected to be high, the second input / output interface is detected to be high, and the third input / output interface is detected to be high, then all buttons are determined to be open.

[0016] The beneficial effects of this invention are as follows: This invention proposes a key detection circuit and a key detection method. The circuit includes a first key detection module, which comprises m pull-up / pull-down branches and one pull-down branch. The m pull-up / pull-down branches are connected in parallel, and each of the pull-up / pull-down branches has an input / output interface. The input / output interface is connected to the pull-down button in the pull-down branch through a series-connected first diode. The second key detection module includes N key detection units, which are connected one-to-one with the q input / output interfaces in the first key detection module through q input / output terminals. The connection methods between each key detection unit and the first key detection module are different. Through this key detection circuit, multiple buttons, diodes, and pull-up resistors can be connected with fewer input / output ports, thereby improving the utilization efficiency of the input / output ports, reducing the resource requirements of the processor's input / output ports, and lowering the overall cost.

[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings:

[0019] Figure 1 This is a circuit structure diagram of a key detection circuit shown in an exemplary embodiment of the present invention;

[0020] Figure 2 This is a circuit structure diagram of another key detection circuit shown in an exemplary embodiment of the present invention;

[0021] Figure 3a This is a detailed flowchart illustrating a key detection method according to an exemplary embodiment of the present invention;

[0022] Figure 3b This is a detailed flowchart illustrating a key detection method according to an exemplary embodiment of the present invention;

[0023] Figure 4 This is a detailed flowchart illustrating a key detection method according to an exemplary embodiment of the present invention;

[0024] Figure 5 This is a flowchart illustrating a specific embodiment of the key detection method of the present invention. Detailed Implementation

[0025] The embodiments of the present invention will be described below with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention and not for limiting the scope of protection of the present invention.

[0026] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0027] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the invention. However, it will be apparent to those skilled in the art that embodiments of the invention may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the invention.

[0028] It should be noted that the illustrations provided in the embodiments of this invention are merely schematic representations of the basic concept of the invention. Therefore, the drawings only show components relevant to the invention and are not drawn according to the actual number, shape, and size of the components in practice. In actual implementation, the form, quantity, and proportion of each component can be arbitrarily changed, and the component layout may be more complex. The structures, proportions, and sizes shown in the accompanying drawings are only for illustrative purposes and to aid those skilled in the art. They are not intended to limit the implementation of the invention and therefore have no substantial technical significance. Any modifications to the structure, changes in proportions, or adjustments to the size, without affecting the effects and objectives of the invention, should still fall within the scope of the technical content disclosed in this invention.

[0029] This invention proposes a key detection circuit, comprising: a first key detection module, which includes m pull-up / pull-down branches and one pull-down branch, wherein the m pull-up / pull-down branches are connected in parallel, each pull-up / pull-down branch includes a pull-up / pull-down button, and each pull-up / pull-down branch has an input / output interface. In each pull-up / pull-down branch, the input / output interface is pulled up or pulled down by the pull-up / pull-down button, and the input / output interface is connected to the pull-down button in the pull-down branch through a series-connected first diode, thereby pulling down the input / output interface; and a second key detection module, which includes N key detection units, each key detection unit including n second diodes and n... Each button detection unit has q input / output terminals. Each button detection unit is connected one-to-one with q input / output interfaces in the first button detection module via these q input / output terminals, and the connection methods between each button detection unit and the first button detection module are different. M input / output interfaces are connected to a processor, which is configured to: acquire the level signals of the m input / output interfaces, or output fixed level signals to some input / output interfaces and acquire the level signals of the remaining input / output interfaces, and then determine the open / closed state of the pull-up / down buttons, the drop-down button, and the button based on the level signals of the m input / output interfaces; where m, n, N, and q are all positive integers.

[0030] In one embodiment of this application, each pull-up / pull-down branch includes a pull-up resistor and a pull-up / pull-down button. One end of the pull-up resistor is connected to the power supply, and the other end is connected to one end of the pull-up / pull-down button. The other end of the pull-up / pull-down button is grounded.

[0031] In one embodiment of this application, the processor is a microcontroller without an AD port. The input / output interface is a non-AD port. Since microcontrollers with AD ports are more expensive, and the more buttons are detected, the higher the resolution of the AD port needs to be, thus increasing development costs, the button detection circuit proposed in this invention can detect a larger number of buttons using fewer non-AD ports. This improves the efficiency of the input / output interface, reduces the resource requirements of the processor's input / output interface, and reduces the overall cost by enabling button on / off state detection via a microcontroller without an AD port.

[0032] In one embodiment of this application, the pull-down branch includes a first diode and a pull-down button. One end of the first diode is connected to an input / output interface, and the other end of the first diode is connected to one end of the pull-down button, which is grounded. In this embodiment, the input / output interface is connected to a microcontroller. This allows the microcontroller to process the output signal of the button detection circuit to determine the open / closed state of the button. Furthermore, the microcontroller can output a fixed-level signal to the button detection circuit, and the open / closed state of the button can be determined based on the output fixed-level signal.

[0033] In one embodiment of this application, n is 5, meaning each button detection unit is connected to 5 second diodes and 5 buttons. The 5 second diodes include a first second diode, a second second diode, a third second diode, a fourth second diode, and a fifth second diode. The 5 buttons include a first button, a second button, a third button, a fourth button, and a fifth button. The 3 input / output terminals include a first input / output terminal, a second input / output terminal, and a third input / output terminal. The method includes: in one button detection unit, one end of the first button is connected to the first input / output terminal; the other end of the first button is connected to one end of the first second diode; the other end of the first second diode is connected to the third input / output terminal; one end of the second second diode is connected to the first input / output terminal; the other end of the second second diode is connected to one end of the second button; the other end of the second button is connected to one end of the first second diode; and so on. One end of a second diode is connected to a third input / output terminal; one end of a third second diode is connected to a first input / output terminal, the other end of the third second diode is connected to a third button, and the other end of the third button is connected to a second input / output terminal; one end of a fourth second diode is connected to a second input / output terminal, the other end of the fourth second diode is connected to a second button, the other end of the second button is connected to a first second diode, and the other end of the first second diode is connected to a third input / output terminal; one end of a fourth button is connected to a second input / output terminal, the other end of the fourth button is connected to a first second diode, and the other end of the first second diode is connected to a third input / output terminal; one end of a fifth button is connected to a second input / output terminal, the other end of the fifth button is connected to a fifth second diode, and the other end of the fifth second diode is connected to a first input / output terminal.

[0034] In one embodiment of this application, by Calculate the maximum number of key detection units and the total number of key detection units. Here, q represents the number of input / output terminals of the key detection unit in the second key detection module, and m represents the total number of input / output interfaces. In this embodiment, the number of input / output interfaces connected to the input / output terminals of the key detection unit in the second key detection module is also q, and the number of key detection units is... That is, through Calculate N different permutations of the q input / output interfaces of the first key detection module, and then connect the input / output interfaces of the different orders to the q input / output terminals of the key detection units in the second key detection module. In this embodiment, if the value of input / output interface m is 3, and the value of input / output terminal q is 3, then the number of key detection units N is 3, and the number of pull-up / pull-down branches is 3. Please refer to [link / reference]. Figure 1 , Figure 1A key detection circuit according to an embodiment of this application is shown. Figure 1As shown, the first button detection module includes three input / output interfaces I / O1, I / O2, and I / O3, three pull-up / pull-down switches S16, S17, and S18, one pull-down button S19, three first diodes D16, D17, and D18, and three pull-up resistors. One end of the first pull-up resistor is connected to the power supply, and the other end is connected to one end of the pull-up / pull-down button S16, with the other end of the pull-up / pull-down button S16 grounded. One end of the second pull-up resistor is connected to the power supply, and the other end is connected to one end of the pull-up / pull-down button S17, with the other end of the pull-up / pull-down button S17 grounded. One end of the third pull-up resistor is connected to the power supply, and the other end is connected to one end of the pull-up / pull-down button S18, with the other end of the pull-up / pull-down button S18 grounded. The anode of the first diode D16 is connected to I / O1, and the cathode of the first diode D16 is connected to one end of the pull-down button S19, with the other end of the pull-down button S19 grounded. The second diode is connected to I / O2. The anode of diode D17 and the cathode of the second first diode D17 are connected to one end of the pull-down button S19, and the other end of the pull-down button S19 is grounded. The anode of the third first diode D18 is connected via I / O3, and the cathode of the third first diode D18 is connected to one end of the pull-down button S19, and the other end of the pull-down button S19 is grounded. The second button detection module includes three button detection units. In the first button detection unit, one end of the first button S1 is connected via the first input / output terminal, the other end of the first button S1 is connected to the anode of the first second diode D1, and the cathode of the first second diode D1 is connected to the third input / output terminal. The anode of the second diode D2 is connected to the first input / output terminal. The cathode of the second diode D2 is connected to one end of the second button S2, and the other end of the second button S2 is connected to the anode of the first diode D1. The cathode of the first diode D1 is connected to the third input / output terminal. The anode of the third diode D3 is connected to the first input / output terminal. The cathode of the third diode D3 is connected to one end of the third button S3, and the other end of the third button S3 is connected to the second input / output terminal. The anode of the fourth diode D4 is connected to the second input / output terminal. The cathode of the first input / output diode is connected to one end of the second button S2, and the other end of the second button S2 is connected to the anode of the first second diode D1. The cathode of the first second diode D1 is connected to the third input / output terminal. The second input / output terminal is connected to one end of the fourth button S4, and the other end of the fourth button S4 is connected to the anode of the first second diode D1. The cathode of the first second diode D1 is connected to the third input / output terminal. The second input / output terminal is connected to one end of the fifth button S5, and the other end of the fifth button S5 is connected to the anode of the fifth second diode D5. The cathode of the fifth second diode D5 is connected to the first input / output terminal.In this embodiment, the input / output terminals of the remaining button detection units are connected to input / output ports in different sequences. Specifically, in the second button detection unit, one end of the first button S6 is connected via the first input / output terminal, and the other end of the first button S6 is connected to the anode of the first second diode D6. The cathode of the first second diode D6 is connected to the third input / output terminal. The anode of the second second diode D7 is connected via the first input / output terminal, and the cathode of the second second diode D7 is connected to one end of the second button S7. The other end of the second button S7 is connected to the anode of the first second diode D6, and the cathode of the first second diode D6 is connected to the third input / output terminal. The anode of the third second diode D8 is connected via the first input / output terminal, and the cathode of the third second diode D8 is connected to one end of the third button S8. The other end of the third button S8 is connected to the second input / output terminal; the anode of the fourth second diode D9 is connected through the second input / output terminal, the cathode of the fourth second diode D9 is connected to one end of the second button S7, the other end of the second button S7 is connected to the anode of the first second diode D6, and the cathode of the first second diode D6 is connected to the third input / output terminal; the second input / output terminal is connected to one end of the fourth button S9, the other end of the fourth button S9 is connected to the anode of the first second diode D6, and the cathode of the first second diode D6 is connected to the third input / output terminal; the second input / output terminal is connected to one end of the fifth button S10, the other end of the fifth button S10 is connected to the anode of the fifth second diode D10, and the cathode of the fifth second diode D10 is connected to the first input / output terminal.In this embodiment, the third button detection unit is connected to one end of the first button S11 via the first input / output terminal. The other end of the first button S11 is connected to the anode of the first second diode D11, and the cathode of the first second diode D11 is connected to the third input / output terminal. The third button detection unit is also connected to the anode of the second second diode D12 via the first input / output terminal. The cathode of the second second diode D12 is connected to one end of the second button S12, and the other end of the second button S12 is connected to the anode of the first second diode D11. The cathode of the first second diode D11 is connected to the third input / output terminal. Finally, the third button detection unit is connected to the anode of the third second diode D13 via the first input / output terminal. The cathode of the third second diode D13 is connected to one end of the third button S13, and the other end of the third button S13 is connected to the third input / output terminal. Output terminal connection; the anode of the fourth second diode D14 is connected through the second input / output terminal, the cathode of the fourth second diode D14 is connected to one end of the second button S12, the other end of the second button S12 is connected to the anode of the first second diode D11, and the cathode of the first second diode D11 is connected to the third input / output terminal; the second input / output terminal is connected to one end of the fourth button S14, the other end of the fourth button S14 is connected to the anode of the first second diode D11, and the cathode of the first second diode D11 is connected to the third input / output terminal; the second input / output terminal is connected to one end of the fifth button S15, the other end of the fifth button S15 is connected to the anode of the fifth second diode D15, and the cathode of the fifth second diode D15 is connected to the first input / output terminal.

[0035] In this embodiment, the input / output terminals of each key detection unit in the second key detection circuit are connected to input / output ports in different sequences. In this embodiment, there are three sets of input / output interfaces in different sequences, and three input / output terminals. These interfaces are connected to the input / output terminals of the three key detection units in the second key detection module according to different sequences. Specifically, as follows... Figure 1As shown, the first input / output terminal of the first button detection unit is connected to the first input / output interface I / O1, the first second input / output terminal of the first button detection unit is connected to the second input / output interface I / O2, and the first third input / output terminal of the first button detection unit is connected to the third input / output interface I / O3; the second first input / output terminal of the second button detection unit is connected to the third input / output interface I / O3, the second second input / output terminal of the second button detection unit is connected to the second input / output interface I / O2, and the second third input / output terminal of the second button detection unit is connected to the first input / output interface I / O1; the third first input / output terminal of the third button detection unit is connected to the first input / output interface I / O1, the third second input / output terminal of the third button detection unit is connected to the third input / output interface I / O3, and the third third input / output terminal of the third button detection unit is connected to the second input / output interface I / O2. Similarly, when an input / output interface is added, it is connected via... Calculate the number of possible combinations of q input / output interfaces. The q input / output terminals of the second detection circuit are connected to the input / output interfaces in different combinations according to their order. This allows for connecting a larger number of buttons with fewer input / output interfaces, i.e., the total number of buttons W:

[0036] Equation (1)

[0037] Where W represents the total number of buttons in the button detection circuit, q represents the number of input / output terminals of the button detection unit in the second button detection module, and m represents the total number of input / output interfaces, where m is greater than or equal to 3. In one embodiment of the application, q is 3, meaning the button detection unit has 3 input / output terminals, and n is 5. This allows 19 buttons to be connected through 3 input / output interfaces, 65 buttons through 4 input / output interfaces, and so on. However, since microcontrollers with AD ports are relatively expensive, and the higher the number of buttons detected, the higher the resolution of the AD port needs to be, the development cost will increase. Therefore, the button detection circuit proposed in this invention can detect 19 buttons through 3 non-AD ports, 65 buttons through 4 non-AD ports, and so on. By extending Equation 1, it can detect the open / closed states of more buttons with fewer input / output interfaces, thereby improving the utilization efficiency of input / output ports, reducing the resource requirements of processor input / output ports, and lowering the overall cost.

[0038] In one embodiment of this application, please refer to Figure 2 , Figure 2A button detection circuit is shown in the figure, where m is 2, N is 1, and n is 2. This button detection circuit includes a first button detection module and a second button detection module. The first button detection module includes two pull-up / pull-down branches. Two pull-up / pull-down buttons and one pull-down button are connected to one end of the first pull-up / pull-down button S1 via a first input / output interface I / O1. The other end of the first pull-up / pull-down button S1 is grounded. A second pull-up / pull-down button S2 is connected to one end of the second pull-up / pull-down button S2 via a second input / output interface I / O2. The other end of the second pull-up / pull-down button S2 is grounded. A first diode D1 is connected to the anode of the first diode D1 via the first input / output interface I / O1. The cathode of the first diode D1 is connected to one end of the pull-down button S3. The other end of the pull-down button S3 is grounded. A second diode D2 is connected to the anode of the second diode D2 via the second input / output interface I / O2. The cathode of diode D2 is connected to one end of the pull-down button S3, and the other end of the pull-down button S3 is grounded. The second button detection module includes two diodes and two buttons. The anode of the first second diode D3 is connected to the first input / output terminal, and the cathode of the first second diode is connected to one end of the first button S4. The other end of the first button S4 is connected to the second input / output interface I / O2. One end of the second button S5 is connected to the second input / output interface I / O2, and the other end of the second button S5 is connected to the anode of the second second diode D4. The cathode of the second second diode D4 is connected to the first input / output interface I / O1. Since microcontrollers with AD ports are relatively expensive, and the more buttons detected, the higher the resolution of the AD port needs to be, which increases development costs, the circuit proposed in this invention can use a non-AD port to connect to the processor to detect the button's closed state, thus saving costs.

[0039] In one embodiment of this application, as shown in FIG3, FIG3 is a flowchart of a key detection circuit method, as shown in FIG3, including... Figure 3a and Figure 3b , Figure 3a Includes the following steps:

[0040] In step S310, all m input / output interfaces are configured as the first output interface.

[0041] In one embodiment of this application, m is 3. In this embodiment, all three input / output interfaces of the first button detection module are configured as the first output interface.

[0042] Step S320: The processor acquires the level signals of m input / output interfaces.

[0043] In one embodiment of this application, the level signal includes a high-level signal and a low-level signal.

[0044] Step S330: Determine the open / closed state of the pull-up / pull-down buttons and the pull-down button based on the level signals of the m first output interfaces.

[0045] Figure 3b Includes the following steps:

[0046] In step S301, some of the m input / output interfaces are configured as second output interfaces, and the other part is configured as input interfaces.

[0047] In one embodiment of this application, m is 3. In this embodiment, part of the input / output interface of the first button detection module is configured as the first output interface, and the other part is configured as the input interface.

[0048] In step S302, the processor outputs a fixed-level signal to the input interface and acquires the level signal of the second output interface.

[0049] Step S303: Determine the open / closed state of the button based on the level signal of the second output interface and the level signal of the input interface.

[0050] In the technical solution shown in Figure 3, by connecting to a processor, the input and output states of the input and output interfaces are set. A level signal is input through the input interface, and the level signal of the output interface is detected to determine the open and closed state of the key in the key detection circuit.

[0051] In one embodiment of this application, based on Figure 3b The button detection method shown here has m set to 3. Figure 4 The specific key detection method is shown. Figure 4 Here is a flowchart of the key detection method, such as Figure 4 As shown, it includes the following steps:

[0052] Step S410: Configure the first input / output interface as the second output interface, configure the second input / output interface as the second output interface, configure the third input / output interface as the input interface, set the input interface to a low-level signal, configure the output interface to output a level signal to the microprocessor via the key detection circuit, and configure the input interface to input a level signal to the key detection circuit via the microprocessor.

[0053] Step S420: When the first input / output interface is detected to be at a low level and the second input / output interface is at a high level, it is determined that the first button is closed.

[0054] Step S430: When both the first input / output interface and the second input / output interface are detected to be at a low level, it is determined that the second button is closed.

[0055] Step S440: When the first input / output interface is detected to be at a high level and the second input / output interface is at a low level, it is determined that the fourth button is closed.

[0056] exist Figure 4 In the technical solution shown, by connecting to a processor and setting the input / output states of the input / output interfaces, an input level signal is input through the input interface, and the output level signal is detected to determine the open / closed state of the button in the button detection circuit. In this way, more button closure states can be detected using fewer input / output interfaces, improving the utilization efficiency of the output interfaces, reducing the resource requirements of the microprocessor output interfaces, and reducing the overall cost of the device.

[0057] In one embodiment of this application, the second input / output interface is configured as an input interface, the first input / output interface is configured as the second output interface, and the third input / output interface is configured as a high-impedance state. If the input interface is a low-level signal, and a low-level output is detected from the first input / output interface, then the third button is determined to be closed. By setting the input signal of the input interface and detecting the output level signal of the output interface, it is possible to detect more button open / closed states using fewer input / output interfaces, thereby improving the utilization rate of input / output interfaces. Furthermore, this invention can use a non-AD port to connect to the processor to detect button open / closed states, which can save costs.

[0058] In one embodiment of this application, the first input / output interface is configured as an input interface, the second input / output interface is configured as a second output interface, and the third input / output interface is configured as a high-impedance state. If the input interface is a low-level signal, and a low-level output is detected from the second input / output interface, then the fifth button is determined to be closed. By setting the input signal of the input interface and detecting the output level signal of the output interface, it is possible to detect more button open / closed states using fewer input / output interfaces, thereby improving the utilization rate of input / output interfaces. Furthermore, this invention can use a non-AD port to connect to the processor to detect button open / closed states, which can save costs.

[0059] In one embodiment of this application, there are 3 input / output interfaces m, and each key detection unit has 5 keys. In this embodiment, refer to... Figure 1 In the first button detection module, the first input / output interface is I / O1, the second input / output interface is I / O2, and the third input / output interface is I / O3. In the first button detection unit of the second button detection module, the first button is S1, the second button is S2, the third button is S3, the fourth button is S4, and the fifth button is S5.

[0060] In one embodiment of this application, there are 3 input / output interfaces m, and each key detection unit has 5 keys. In this embodiment, refer to... Figure 1In the first button detection module, the first input / output interface is I / O2, the second input / output interface is I / O3, and the third input / output interface is I / O1. In the second button unit of the second button detection module, the first button is S6, the second button is S7, the third button is S8, the fourth button is S9, and the fifth button is S10.

[0061] In one embodiment of this application, there are 3 input / output interfaces m, and each key detection unit has 5 keys. In this embodiment, refer to... Figure 1 In the first button detection module, the first input / output interface is I / O1, the second input / output interface is I / O3, and the third input / output interface is I / O2. In the third button unit of the second button detection module, the first button is S11, the second button is S12, the third button is S13, the fourth button is S14, and the fifth button is S15.

[0062] In one embodiment of this application, based on Figure 3a The button detection method shown here has m set to 3. Figure 5 The specific key detection method is shown. Figure 5 Here is a flowchart of the key detection method, such as Figure 5 As shown, it includes the following steps:

[0063] Step S510: If the first input / output interface is detected to be at a low level, the second input / output interface is at a high level, and the third input / output interface is at a high level, then it is determined that the sixth button is closed.

[0064] Step S520: If the first input / output interface is detected to be at a high level, the second input / output interface is at a low level, and the third input / output interface is at a high level, then it is determined that the seventh button is closed.

[0065] Step S530: If the first input / output interface is detected to be at a high level, the second input / output interface is detected to be at a high level, and the third input / output interface is detected to be at a low level, then it is determined that the eighth button is closed.

[0066] In step S540, if the first input / output interface is detected to be at a low level, the second input / output interface is detected to be at a low level, and the third input / output interface is detected to be at a low level, then it is determined that the ninth button is closed.

[0067] Step S550: If the first input / output interface is detected to be at a high level, the second input / output interface is detected to be at a high level, and the third input / output interface is detected to be at a high level, then it is determined that all buttons are disconnected.

[0068] exist Figure 5In the technical solution shown, by connecting to the processor, all input and output interfaces are set as output interfaces. By detecting the level signal of the output interface, the open and closed state of the key in the key detection circuit is determined. Thus, more key closed states are detected with fewer input and output interfaces, improving the utilization efficiency of the output interface, reducing the resource requirements of the microprocessor output interface, and reducing the overall cost.

[0069] In one embodiment of this application, there are three input / output interfaces m, and the first button detection module has three pull-up / pull-down buttons and one pull-down button. In this embodiment, refer to... Figure 1 The sixth button is S16, the seventh button is S17, the eighth button is S18, and the ninth button is S19.

[0070] In summary, based on the key detection circuit proposed in this invention, by connecting to a processor and setting the input / output states of the input / output interfaces, inputting a level signal through the input interface, and detecting the level signal of the output interface, the open / closed state of the key in the key detection circuit can be determined. Alternatively, by setting both input and output interfaces as output interfaces, the open / closed state of the key can be detected by detecting the level signals of the input and output interfaces. This allows for the detection of more open / closed states using fewer input / output interfaces, thereby improving the utilization rate of the input / output interfaces. Furthermore, this invention can use a non-AD port to connect to the processor to detect the open / closed state of the key, thus saving costs.

[0071] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in the present invention should still be covered by the claims of the present invention.

Claims

1. A key detection circuit, characterized in that, The key detection circuit includes: The first button detection module includes m pull-up / pull-down branches and 1 pull-down branch. The m pull-up / pull-down branches are connected in parallel. Each pull-up / pull-down branch includes a pull-up / pull-down button and an input / output interface. In each pull-up / pull-down branch, the input / output interface is pulled up or pulled down by the pull-up / pull-down button. The input / output interface is connected to the pull-down button in the pull-down branch through a first diode in series, and the input / output interface is pulled down by the pull-down button. The second button detection module includes N button detection units. Each button detection unit includes n second diodes and n buttons. Each button detection unit has q input / output terminals. The button detection unit is connected one-to-one with the q input / output interfaces in the first button detection module through the q input / output terminals. The input / output terminals of each button detection unit are connected to input / output interfaces in different sequences. Wherein, m input / output interfaces are connected to a processor, and the processor is configured to: acquire the level signals of the m input / output interfaces, or output fixed level signals to some of the input / output interfaces and acquire the level signals of the remaining input / output interfaces, and then determine the open / closed state of the pull-up / down buttons, the pull-down button, and the button based on the level signals of the m input / output interfaces; wherein m, n, N, and q are all positive integers; n is 5, q is 3, each button detection unit is connected to 5 second diodes and 5 buttons, the 5 second diodes include a first second diode, a second second diode, a third second diode, a fourth second diode, and a fifth second diode, the 5 buttons include a first button, a second button, a third button, a fourth button, and a fifth button, and the 3 input / output terminals include a first input / output terminal, a second input / output terminal, and a third input / output terminal, including: in one button detection unit, one end of the first button is connected to the first input / output terminal, the other end of the first button is connected to one end of the first second diode, and the other end of the first second diode is connected to the third input / output terminal; One end of the second diode is connected to the first input / output terminal, the other end of the second diode is connected to one end of the second button, the other end of the second button is connected to one end of the first second diode, and the other end of the first second diode is connected to the third input / output terminal. One end of the third second diode is connected to the first input / output terminal, the other end of the third second diode is connected to one end of the third button, and the other end of the third button is connected to the second input / output terminal. One end of the fourth second diode is connected to the second input / output terminal, the other end of the fourth second diode is connected to one end of the second button, the other end of the second button is connected to one end of the first second diode, and the other end of the first second diode is connected to the third input / output terminal. The second input / output terminal is connected to one end of the fourth button, the other end of the fourth button is connected to one end of the first second diode, and the other end of the first second diode is connected to the third input / output terminal. The second input / output terminal is connected to one end of the fifth button, the other end of the fifth button is connected to one end of the fifth second diode, and the other end of the fifth second diode is connected to the first input / output terminal.

2. The key detection circuit according to claim 1, characterized in that, Each pull-up / pull-down branch includes one pull-up resistor and one pull-up / pull-down button. One end of the pull-up resistor is connected to the power supply, and the other end is connected to one end of the pull-up / pull-down button. The other end of the pull-up / pull-down button is grounded.

3. The key detection circuit according to claim 1, characterized in that, The pull-down branch includes a first diode and a pull-down button. One end of the first diode is connected to the input / output interface, and the other end of the first diode is connected to one end of the pull-down button. The other end of the pull-down button is grounded.

4. The key detection circuit according to claim 1, characterized in that, pass Calculate the maximum number of button detection units, and the number of button detection units. indivual.

5. A key detection method, applied to the key detection circuit according to any one of claims 1 to 4, characterized in that, The button detection method includes: all m input / output interfaces are configured as first output interfaces; the processor collects the level signals of the m input / output interfaces; and determines the open / closed state of the pull-up / pull-down buttons and the pull-down button based on the level signals of the m first output interfaces. The m input / output interfaces are configured as a second output interface and another part is configured as an input interface. The processor outputs the fixed level signal to the input interface. The processor collects the level signal of the second output interface and determines the open / closed state of the button based on the level signal of the second output interface and the level signal of the input interface.

6. The button detection method according to claim 5, characterized in that, The value of m is 3. The m input / output interfaces are configured partly as second output interfaces and partly as input interfaces. The processor outputs a fixed-level signal to the input interfaces. The processor acquires the level signal of the second output interface and determines the open / closed state of the button based on the level signal of the second output interface and the level signal of the input interfaces. This includes: configuring the first input / output interface as the second output interface, configuring the second input / output interface as the second output interface, configuring the third input / output interface as the input interface, configuring the output interfaces as the button detection circuit outputs a level signal to the microprocessor, and configuring the input interfaces as the microprocessor inputs a level signal to the button detection circuit. If the input interface is a low-level signal, when the first input / output interface is detected to be low-level and the second input / output interface is detected to be high-level, it is determined that the first button is closed; If both the first input / output interface and the second input / output interface are detected to be at a low level, it is determined that the second button is closed. When the first input / output interface is detected to be at a high level and the second input / output interface is at a low level, it is determined that the fourth button is closed.

7. The button detection method according to claim 6, characterized in that, The value of m is 3. Some of the m input / output interfaces are configured as second output interfaces, and the other part is configured as input interfaces. The processor outputs the fixed level signal to the input interface. The processor collects the level signal of the second output interface and determines the open / closed state of the button based on the level signal of the second output interface and the level signal of the input interface. The method also includes: configuring the second input / output interface as an input interface, configuring the first input / output interface as the second output interface, and configuring the third input / output interface as a high impedance state. If the input interface is a low-level signal, and the first input / output interface is detected to be outputting a low level, then the third button is determined to be closed.

8. The button detection method according to claim 6, characterized in that, The value of m is 3. The m input / output interfaces are configured as second output interfaces and as input interfaces. The processor outputs the fixed level signal to the input interface. The processor collects the level signal of the second output interface and determines the open / closed state of the button based on the level signal of the second output interface and the level signal of the input interface. The method also includes: configuring the first input / output interface as an input interface, configuring the second input / output interface as a second output interface, and configuring the third input / output interface as a high impedance state. If the input interface is a low-level signal, and the second input / output interface is detected to be outputting a low level, then the fifth button is determined to be closed.

9. The button detection method according to claim 6, characterized in that, The value of m is 3. All m input and output interfaces are configured as first output interfaces. The processor collects the level signals of the m first output interfaces and determines the open and closed state of the pull-up and pull-down buttons based on the level signals of the m first output interfaces. This includes: if the first input and output interface is detected to be at a low level, the second input and output interface is at a high level, and the third input and output interface is at a high level, then the sixth button is determined to be closed. If the first input / output interface is detected to be high, the second input / output interface is detected to be low, and the third input / output interface is detected to be high, then the seventh button is determined to be closed. If the first input / output interface is detected to be high, the second input / output interface is detected to be high, and the third input / output interface is detected to be low, then the eighth button is determined to be closed. If the first input / output interface is detected to be low, the second input / output interface is detected to be low, and the third input / output interface is detected to be low, then the ninth button is determined to be closed. If the first input / output interface is detected to be high, the second input / output interface is detected to be high, and the third input / output interface is detected to be high, then it is determined that all buttons are disconnected.

Citation Information

Patent Citations

  • Non-AD-port key detection circuit and detection method thereof

    CN102565694B

  • Key identifying circuit, key identifying method and STB (Set Top Box)

    CN102611456A

  • Switch key scanning circuit and electric device

    CN107666323A