A button long and short press identification and power on / off control circuit
By designing a circuit including a button reset circuit, an RC charge and discharge circuit, a comparator circuit and a D flip-flop, it is possible to accurately identify the length and short buttons without software participation, and is suitable for low-power scenarios, which solves the problem that the prior art cannot be applied to MCU or CPU devices.
Patent Information
- Application Number
- CN202111304108.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-05
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2041-11-05
AI Technical Summary
The prior art cannot realize accurate identification of button length and short presses without an MCU or CPU, and is not suitable for low-power scenarios.
A circuit including a button reset circuit, an RC charge and discharge circuit, a comparator circuit and a D flip-flop was designed. Through the cooperation of the comparator circuit and the RC charge and discharge circuit, precise control of the button duration is achieved without the participation of software.
It realizes the precise identification of the length and short buttons of buttons without software participation, and is suitable for low-power scenarios, solving the problem that the existing technology cannot be applied to MCU or CPU devices.
Smart Images

Figure CN114024537B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic technology, and in particular to a key long-short press identification and power on / off control circuit. Background Art
[0002] Existing electronic devices usually require key operations to turn on and off the whole machine or the motherboard. In order to prevent shutdown caused by accidental key touches, some terminal devices need to identify short presses and long presses of keys to control power on and off respectively. For example, a short press of the key can turn on the machine, and a key press of more than 5 seconds can turn off the machine. The existing technical solution is to use software to detect the key press time, such as a method for identifying long presses and short presses of reset keys with the existing patent number CN108153402B. The software of the processor chip (MCU or CPU) is used to judge the key press duration, which is the most conventional key recognition solution. The disadvantages are: it must involve software and cannot be applied to scenarios without MCU or CPU; moreover, it must work under the premise that the main control part is already working, and it is not suitable for low-power scenarios. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a button long and short press recognition and power on / off control circuit, which can realize accurate recognition of long and short presses without the involvement of software and is suitable for low power consumption scenarios.
[0004] In order to solve the above problems, the solution adopted by the present invention is:
[0005] A key long-short press identification and power on / off control circuit, comprising a key reset circuit, an RC charge and discharge circuit, a comparator circuit, a D trigger and an external power supply;
[0006] The voltage output end of the key reset circuit is respectively connected to the voltage input end of the RC charge and discharge circuit and the clock signal input end of the D flip-flop, the voltage output end of the RC charge and discharge circuit is connected to the voltage input end to be compared of the comparator circuit, the voltage output end of the comparator circuit is connected to the D input end and the reset signal input end of the D flip-flop, and the voltage output end of the D flip-flop is used to enable other power supplies at the subsequent stage;
[0007] The external power supply is respectively connected to the power input terminal of the key reset circuit, the reference voltage input terminal of the comparator circuit and the set terminal of the D flip-flop.
[0008] In summary, the beneficial effects of the present invention are as follows: a key long-short press identification and power on / off control circuit is provided, when the external power supply is powered on and the key of the key reset circuit is not pressed, the RC charge-discharge circuit is charged, the output of the D flip-flop is low level, and the external device is not turned on; when the key is pressed, the key reset circuit outputs a low level, the RC charge-discharge circuit discharges but its output is not lower than the threshold value of the comparator circuit, so that the output of the comparator circuit maintains a high level, and when the key is released, the key reset circuit gives the D flip-flop a clock signal with a rising edge, the output state of the D flip-flop becomes a high level, and the external device is turned on. The external device is turned on by a short press; when the button is long pressed, the RC charge and discharge circuit discharges and the output is lower than the threshold value of the comparator circuit, so that the output of the comparator circuit is low, that is, the output state of the D flip-flop becomes low, and the external device is turned off. After releasing the button, although the button reset circuit gives the D flip-flop a clock signal at the rising edge, the output of the comparator circuit remains low, so the external device will not turn on, that is, the function of long button shutdown is realized; the implementation process does not require software participation, and relies on the comparator circuit and the RC charge and discharge circuit to achieve precise button time control, which is suitable for low power consumption scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 A circuit connection diagram of a first solution of a key long and short press identification and power on / off control circuit according to an embodiment of the present invention;
[0010] Figure 2 A waveform diagram of working voltages of various nodes of a first solution of a key long-short press identification and power on / off control circuit according to an embodiment of the present invention;
[0011] Figure 3 The present invention is a circuit connection diagram of a second solution of a button long and short press identification and power on / off control circuit according to an embodiment of the present invention.
[0012] Description of labels:
[0013] 1. Button reset circuit; 2. RC charge and discharge circuit; 3. Comparator circuit;
[0014] C1, capacitor;
[0015] D1, first diode; D2, second diode;
[0016] K1, control button;
[0017] R1, first resistor; R2, second resistor; R3, third resistor; R4, fourth resistor; R5, fifth resistor; R6, sixth resistor; R7, seventh resistor; R8, eighth resistor;
[0018] T1, MOS tube;
[0019] U1, reference source; U2, operational amplifier; U3, D flip-flop. DETAILED DESCRIPTION
[0020] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0021] Please refer to Figures 1 to 3 , a key long and short press identification and power on / off control circuit, key reset circuit 1, RC charge and discharge circuit 2, comparator circuit 3, D flip-flop U3 and external power supply;
[0022] The voltage output end of the button reset circuit 1 is respectively connected to the voltage input end of the RC charge and discharge circuit 2 and the clock signal input end of the D flip-flop U3, the voltage output end of the RC charge and discharge circuit 2 is connected to the voltage input end to be compared of the comparator circuit 3, the voltage output end of the comparator circuit 3 is connected to the D input end and the reset signal input end of the D flip-flop U3, and the voltage output end of the D flip-flop U3 is used to enable other power supplies in the subsequent stage.
[0023] The external power supply is respectively connected to the power input terminal of the key reset circuit 1, the reference voltage input terminal of the comparator circuit 3 and the set terminal of the D flip-flop U3.
[0024] From the above description, it can be seen that the beneficial effects of the present invention are: providing a key long and short press identification and power on / off control circuit, when the external power supply is powered on and the key of the key reset circuit 1 is not pressed, the RC charge and discharge circuit 2 is charged, the output of the D flip-flop U3 is low level, and the external device is not turned on; when the key is pressed, the key reset circuit 1 outputs a low level, the RC charge and discharge circuit 2 discharges but its output is not lower than the threshold value of the comparator circuit 3, so that the output of the comparator circuit 3 maintains a high level, and when the key is released, the key reset circuit 1 gives the D flip-flop U3 a rising edge clock signal, and the output state of the D flip-flop U3 becomes a high level , the external device is turned on, and the short press to turn on is realized; when the button is long pressed, the RC charge and discharge circuit 2 discharges and the output is lower than the threshold value of the comparator circuit 3, so that the output of the comparator circuit 3 is low level, that is, the output state of the D flip-flop U3 becomes low level, and the external device is turned off. After releasing the button, although the button reset circuit 1 gives the D flip-flop U3 a rising edge clock signal, the output of the comparator circuit 3 remains low level, so the external device will not turn on, that is, the long press shutdown function is realized; its implementation process does not require software participation, and relies on the comparator circuit 3 and the RC charge and discharge circuit 2 to achieve precise button time control, which is suitable for low power consumption scenarios.
[0025] Furthermore, the button reset circuit 1 includes a control button K1 and a first resistor R1;
[0026] One end of the control button K1 is simultaneously connected to one end of the first resistor R1, the voltage input end of the RC charge and discharge circuit 2 and the clock signal input end of the D trigger U3, the other end of the first resistor R1 is connected to the external power supply, and the other end of the control button K1 is grounded.
[0027] From the above description, it can be seen that the key reset circuit 1 is composed of a first pull-up resistor R1 and a control key K1 connected in series. When the control key K1 is not pressed, the output of the circuit is pulled up to a high level; when the control key K1 is pressed, the output of the circuit is grounded to a low level.
[0028] Further, the RC charge and discharge circuit 2 includes a capacitor C1, a first diode D1, a second resistor R2 and a third resistor R3;
[0029] One end of the second resistor R2 is connected to the voltage output end of the key reset circuit 1 and the positive electrode of the first diode D1, the negative electrode of the first diode D1 is connected to one end of the third resistor R3, the other end of the third resistor R3 is connected to the other end of the second resistor R2, one end of the capacitor C1 and the voltage input end to be compared of the comparator circuit 3, and the other end of the capacitor C1 is grounded.
[0030] From the above description, it can be seen that the RC charging and discharging circuit 2 is mainly composed of a capacitor and a resistor. When charging, the current charges the capacitor C1 through the first diode D1 and the third resistor R3; when discharging, the current discharges to the ground through the second resistor R2 and the control button K1; by adjusting the resistance values of the second resistor R2 and the third resistor R3, different charging and discharging effects can be obtained, thereby conveniently and accurately adjusting the key pressing time of the control button K1.
[0031] Furthermore, the comparator circuit 3 includes a reference source U1, a MOS transistor T1, a fourth resistor R4 and a fifth resistor R5;
[0032] The anode of the reference source U1 is connected to the voltage output terminal of the RC charge and discharge circuit 2, the reference electrode of the reference source U1 is simultaneously connected to one end of the fourth resistor R4 and the gate of the MOS transistor T1, and the drain of the MOS transistor T1 is simultaneously connected to one end of the fifth resistor R5 and the D input terminal and reset signal input terminal of the D trigger U3;
[0033] The other end of the fourth resistor R4 and the other end of the fifth resistor R5 are both connected to the external power supply, and the cathode of the reference source U1 and the source of the MOS transistor T1 are both grounded.
[0034] From the above description, it can be seen that the comparator circuit 3 uses the reference source U1 as the comparison device, cooperates with the output of the RC charge and discharge circuit 2, and then controls the output of signals of different levels at different time lengths. No software control is required, and the MOS tube T1 is used as the shutdown device for level change, which is stable and reliable.
[0035] Further, the comparator circuit 3 includes an operational amplifier U2, a sixth resistor R6 and a seventh resistor R7;
[0036] The first voltage input terminal of the operational amplifier U2 is connected to the voltage output terminal of the RC charge and discharge circuit 2, the second voltage input terminal of the operational amplifier U2 is simultaneously connected to one end of the sixth resistor R6 and one end of the seventh resistor R7, and the voltage output terminal of the operational amplifier U2 is simultaneously connected to the D input terminal and the reset signal input terminal of the D flip-flop U3;
[0037] The other end of the sixth resistor R6 is connected to the external power supply, and the other end of the seventh resistor R7 is grounded.
[0038] From the above description, it can be seen that the comparator circuit 3 can also use the operational amplifier U2 as a comparison device, and its circuit composition is simpler. The voltage divider circuit composed of the sixth resistor R6 and the seventh resistor R7 is used to control the size of the reference voltage to adjust the key pressing time of the control key K1, and the comparison result is more accurate.
[0039] Furthermore, an eighth resistor R8 is included;
[0040] The external power source is connected to the set terminal of the D flip-flop U3 through the eighth resistor R8.
[0041] From the above description, it can be known that the eighth resistor R8 is a current limiting resistor connected to the set terminal of the D flip-flop U3, so that the external power supply generates a suitable input signal to be connected to the set terminal of the D flip-flop U3.
[0042] Furthermore, it also includes a second diode D2;
[0043] The anode of the second diode D2 is connected to the reset signal input terminal of the D flip-flop U3, and the cathode of the second diode D2 is used for an external controller.
[0044] From the above description, it can be seen that the second diode D2 is forward-conducted during the protection period and reverse-cutoff, and is used to connect the control signal of the controller to the reset signal input terminal of the D flip-flop U3 to realize software control, so that the circuit is also suitable for a soft environment.
[0045] Furthermore, the reference source U1 is a TL431 reference source.
[0046] From the above description, it can be seen that the threshold value of the TL431 reference source U1 is very precise and is not easily affected by the increase in the external ambient temperature, which is beneficial to increasing the stability of the circuit.
[0047] A key long and short press identification and power on / off control circuit of the present invention is suitable for application scenarios such as power on / off control of some complete electronic devices, and is specifically described below in conjunction with specific embodiments:
[0048] Please refer to Figure 1 , Embodiment 1 of the present invention is:
[0049] A key long and short press identification and power on / off control circuit, such as Figure 1 As shown, a key reset circuit 1, an RC charge and discharge circuit 2, a comparator circuit 3, a D flip-flop U3 and an external power supply. Among them, the voltage output end of the key reset circuit 1 is respectively connected to the voltage input end of the RC charge and discharge circuit 2 and the clock signal input end of the D flip-flop U3, the voltage output end of the RC charge and discharge circuit 2 is connected to the voltage input end to be compared of the comparator circuit 3, the voltage output end of the comparator circuit 3 is connected to the D input end and the reset signal input end of the D flip-flop U3, and the voltage output end of the D flip-flop U3 is used to enable other power supplies in the subsequent stage. The external power supply is respectively connected to the power input end of the key reset circuit 1, the reference voltage input end of the comparator circuit 3 and the set end of the D flip-flop U3.
[0050] In this embodiment, the selected model of the D flip-flop U3 is 74HC74. In other equivalent embodiments, other models of D flip-flops may also be selected.
[0051] Please refer to Figure 1 to Figure 2 , Embodiment 2 of the present invention is:
[0052] A key long and short press identification and power on / off control circuit, such as Figure 1 As shown, based on the above-mentioned embodiment 1, the key reset circuit 1 includes a control key K1 and a first resistor R1. One end of the control key K1 is simultaneously connected to one end of the first resistor R1, the voltage input end of the RC charge and discharge circuit 2, and the clock signal input end of the D trigger U3, the other end of the first resistor R1 is connected to an external power supply, and the other end of the control key K1 is grounded.
[0053] like Figure 1As shown, the RC charge and discharge circuit 2 includes a capacitor C1, a first diode D1, a second resistor R2 and a third resistor R3. Among them, one end of the second resistor R2 is simultaneously connected to the voltage output end of the key reset circuit 1 and the positive electrode of the first diode D1, the negative electrode of the first diode D1 is connected to one end of the third resistor R3, the other end of the third resistor R3 is simultaneously connected to the other end of the second resistor R2, one end of the capacitor C1 and the input end of the voltage to be compared of the comparator circuit 3, and the other end of the capacitor C1 is grounded. In addition, the value of the third resistor R3 is relatively small, such as 1KΩ; the second resistor R2 takes a relatively large value, such as 1MΩ, then the "fast charge and discharge" effect of the capacitor C1 can be achieved.
[0054] like Figure 1 As shown, the comparator circuit 3 includes a reference source U1, a MOS transistor T1, a fourth resistor R4 and a fifth resistor R5. The anode of the reference source U1 is connected to the voltage output end of the RC charge and discharge circuit 2, the reference electrode of the reference source U1 is simultaneously connected to one end of the fourth resistor R4 and the gate of the MOS transistor T1, and the drain of the MOS transistor T1 is simultaneously connected to one end of the fifth resistor R5 and the D input end and the reset signal input end of the D trigger U3. The other end of the fourth resistor R4 and the other end of the fifth resistor R5 are both connected to an external power supply, and the cathode of the reference source U1 and the source of the MOS transistor T1 are both grounded.
[0055] In addition, the D flip-flop U3 also includes an eighth resistor R8 and a second diode D2. The external power supply is connected to the set terminal of the D flip-flop U3 through the eighth resistor R8. The anode of the second diode D2 is connected to the reset signal input terminal of the D flip-flop U3, and the cathode of the second diode D2 is used for the external controller.
[0056] In an embodiment, Figure 1 and Figure 2 As shown, Vkey, Vcap and V_Long correspond to the voltage output terminals of the key reset circuit 1, the RC charge and discharge circuit 2 and the comparator circuit 3 respectively, and Vg is a node voltage in the comparator circuit 3.
[0057] In this embodiment, the process of controlling the key K1 from the initial state to the short-press power-on state is as follows:
[0058] At time t0, the external power supply is connected, and then the Vkey voltage rises rapidly. However, due to the existence of the third resistor R3, the capacitor C1 voltage Vcap rises slower than Vkey. Therefore, Vg is high, V_Long is low, and the voltage output terminal POWER_EN triggered by D is low. The subsequent main circuit is not powered on, that is, the device does not start up.
[0059] At time t1, the Vcap voltage rises to the threshold voltage of the reference source U1 in the comparator circuit 3, Vg becomes a low level, and V_Long becomes a high level. However, since Vkey has no rising edge at this time, POWER_EN maintains its original low level.
[0060] At time t2, the control button K1 is pressed, Vkey becomes low level, the capacitor C1 is slowly discharged through the second resistor R2, and Vcap starts to decrease. Before Vcap decreases to the threshold value, V_Long continues to maintain a high level.
[0061] At t3, the control button K1 is released, Vkey generates a rising edge, and the output level of D flip-flop U3 is the same as V_Long, that is, POWER_EN is high, and the subsequent system is powered on. The time from t2 to t3 is short, which realizes the "short press power-on function".
[0062] In this embodiment, if Figure 1 and Figure 2 As shown, the process of long pressing the control button K1 to shut down is as follows:
[0063] At a certain moment t4 during the boot process, the control button K1 is pressed, Vkey becomes low level, and Vcap starts to discharge slowly; when Vcap drops to the threshold value, that is, at moment t5, Vg outputs a high level, V_Long becomes a low level, thereby pulling POWER_EN low, and the subsequent system is powered off.
[0064] At the next moment t6, the control button K1 is released, and Vkey generates a rising edge, but since V_Long is at a low level at this time, the rising edge of Vkey has no effect on the D flip-flop U3. Then the Vcap voltage rises, V_Long becomes a high level, and the output POWER_EN of the D flip-flop U3 maintains the original low level unchanged. The time from t4 to t6 is relatively long, that is, the "long press shutdown function" is realized.
[0065] Please refer to Figure 3 , Embodiment 3 of the present invention is:
[0066] A key long and short press identification and power on / off control circuit, based on the above-mentioned embodiment 1 or 2, such as Figure 3As shown, the above-mentioned comparator circuit is replaced by an operational amplifier U2, a sixth resistor R6 and a seventh resistor R7. The first voltage input terminal of the operational amplifier U2 is connected to the voltage output terminal of the RC charge-discharge circuit 2, the second voltage input terminal of the operational amplifier U2 is simultaneously connected to one end of the sixth resistor R6 and one end of the seventh resistor R7, and the voltage output terminal of the operational amplifier U2 is simultaneously connected to the D input terminal and the reset signal input terminal of the D flip-flop U3. The other end of the sixth resistor R6 is connected to the external power supply, and the other end of the seventh resistor R7 is grounded.
[0067] In summary, the present invention discloses a key long-short press identification and power on / off control circuit. When the external power supply is powered on and the key of the key reset circuit is not pressed, the RC charge-discharge circuit is charged, the output of the D flip-flop is low level, and the external device is not turned on; when the key is pressed, the key reset circuit outputs a low level, the RC charge-discharge circuit discharges but its output is not lower than the threshold value of the comparator circuit, so that the output of the comparator circuit maintains a high level, and when the key is released, the key reset circuit gives the D flip-flop a clock signal with a rising edge, the output state of the D flip-flop changes to a high level, the external device is turned on, and short-press power on is achieved; When the button is long pressed, the RC charge and discharge circuit discharges and the output is lower than the threshold value of the comparator circuit, so that the output of the comparator circuit is low level, that is, the output state of the D flip-flop becomes low level, and the external device is turned off. After releasing the button, although the button reset circuit gives the D flip-flop a clock signal of the rising edge, the output of the comparator circuit remains low level, so the external device will not turn on, that is, the long button shutdown function is realized; the implementation process does not require software participation, and relies on the comparator circuit and the RC charge and discharge circuit to achieve precise button time control. Different comparator circuits also correspond to two different solutions, which are suitable for low power consumption scenarios.
[0068] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A button long and short press identification and power on / off control circuit, characterized in that: Push-button reset circuit, RC charge and discharge circuit, comparator circuit, D flip-flop and external power supply; The voltage output end of the key reset circuit is respectively connected to the voltage input end of the RC charge and discharge circuit and the clock signal input end of the D flip-flop, the voltage output end of the RC charge and discharge circuit is connected to the voltage input end to be compared of the comparator circuit, the voltage output end of the comparator circuit is connected to the D input end and the reset signal input end of the D flip-flop, and the voltage output end of the D flip-flop is used to enable other power supplies at the subsequent stage; The external power supply is respectively connected to the power input terminal of the key reset circuit, the reference voltage input terminal of the comparator circuit and the set terminal of the D flip-flop; The key reset circuit includes a control key and a first resistor; One end of the control button is simultaneously connected to one end of the first resistor, the voltage input end of the RC charge-discharge circuit and the clock signal input end of the D flip-flop, the other end of the first resistor is connected to the external power supply, and the other end of the control button is grounded; The RC charging and discharging circuit includes a capacitor, a first diode, a second resistor and a third resistor; One end of the second resistor is connected to the voltage output end of the button reset circuit and the positive electrode of the first diode at the same time, the negative electrode of the first diode is connected to one end of the third resistor, the other end of the third resistor is connected to the other end of the second resistor, one end of the capacitor and the voltage input end to be compared of the comparator circuit at the same time, and the other end of the capacitor is grounded.
2. A button long-short press identification and power on / off control circuit according to claim 1, characterized in that: The comparator circuit includes a reference source, a MOS tube, a fourth resistor and a fifth resistor; The anode of the reference source is connected to the voltage output end of the RC charge and discharge circuit, the reference electrode of the reference source is simultaneously connected to one end of the fourth resistor and the gate of the MOS tube, and the drain of the MOS tube is simultaneously connected to one end of the fifth resistor and the D input end and the reset signal input end of the D flip-flop; The other end of the fourth resistor and the other end of the fifth resistor are both connected to the external power supply, and the cathode of the reference source and the source of the MOS tube are both grounded.
3. A button long-short press identification and power on / off control circuit according to claim 1, characterized in that: The comparator circuit includes an operational amplifier, a sixth resistor and a seventh resistor; The first voltage input terminal of the operational amplifier is connected to the voltage output terminal of the RC charge and discharge circuit, the second voltage input terminal of the operational amplifier is simultaneously connected to one end of the sixth resistor and one end of the seventh resistor, and the voltage output terminal of the operational amplifier is simultaneously connected to the D input terminal and the reset signal input terminal of the D flip-flop; The other end of the sixth resistor is connected to the external power supply, and the other end of the seventh resistor is grounded.
4. A button long-short press identification and power on / off control circuit according to claim 1, characterized in that: Also including an eighth resistor; The external power source is connected to the set terminal of the D flip-flop through the eighth resistor.
5. A button long-short press identification and power on / off control circuit according to claim 1, characterized in that: Also including a second diode; The anode of the second diode is connected to the reset signal input terminal of the D flip-flop, and the cathode of the second diode is used for an external controller.
6. A button long-short press identification and power on / off control circuit according to claim 2, characterized in that: The reference source is a TL431 reference source.
Citation Information
Patent Citations
A method for identifying long press and short press of the reset button
CN108153402B
Startup and shutdown control circuit
CN109327215A
Hardware startup and shutdown circuit and electronic equipment
CN110806792A