Key on-off detection circuit
By designing a key switch detection circuit in the switch circuit, using a low dropout linear regulator and switch tube, the problem of data loss when the button is disconnected is solved, and the safety and logic of the circuit are improved.
Patent Information
- Application Number
- CN202421737515.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2034-07-22
AI Technical Summary
The existing power switch-off circuit turns off the power immediately when the key is disconnected, resulting in the inability to store MCU data, which can easily lead to loss of important data and corruption of the file system.
A button switch detection circuit is designed to detect the disconnection of the buttons through the MCU, and a low dropout linear regulator and switch tube are used to ensure that the MCU is powered off after data is saved.
It avoids the risk of MCU data loss, prevents power loss immediately after shutdown, and enhances the logic and security of the circuit.
Smart Images

Figure CN222926832U_ABST
Abstract
Description
Technical Field
[0001] The utility model relates to the technical field of detection circuits, and particularly relates to a key power-on and power-off detection circuit. Background Technique
[0002] At present, the design idea of a part of the power-on and power-off circuits is to control the power-on and power-off by hardware, that is, to control the opening or closing of the system power supply by pressing and disconnecting the power button. Its implementation principle is very simple. After power-off, the system power supply can be completely cut off, and the standby current is very small.
[0003] However, this circuit design still has the following problems in use: when the key is disconnected, the power supply will be immediately turned off. If there is an MCU in the circuit, the data of the MCU will not be stored. If the key is pressed when the MCU is processing a key program or storing key data, and the system power supply is turned off, it is easy to cause the loss of important data and the damage of the file system; when the key is disconnected, the circuit can also be used normally after being charged and activated, resulting in chaotic circuit logic. Summary of the Utility Model
[0004] The main purpose of the utility model is to provide a key power-on and power-off detection circuit, aiming to detect the key, not immediately cut off the power when the key is pressed, so that the MCU can save the data before power-off, avoiding the risk of data loss.
[0005] To achieve the above purpose, a key power-on and power-off detection circuit proposed by the utility model includes:
[0006] An input unit, the input unit at least includes an MCU and a first input port, and the first input port is connected to a power supply;
[0007] A key unit, the key unit is electrically connected to the input unit, and the key unit is provided with a control key for outputting a control signal to the MCU;
[0008] A control unit, the control unit is electrically connected to the key unit, and the control unit at least includes a low dropout linear regulator, a first switching tube and a second switching tube;
[0009] Wherein, when the control key is disconnected, the MCU detects the removal of the power supply at the first input port, the low dropout linear regulator maintains a high level to drive the first switching tube and the second switching tube to open. After the MCU saves the data, the low dropout linear regulator changes to a low level, the first switching tube and the second switching tube close, and the MCU is powered off.
[0010] In an embodiment of the utility model, the input unit further includes a second input port, the second input port is connected to a power supply, and the second input port is electrically connected to the key unit.
[0011] In an embodiment of the present utility model, a DC power supply is connected to the first input port, and a storage battery is connected to the second input port.
[0012] In an embodiment of the present utility model, the control unit further includes a MOS transistor, and the MOS transistor is electrically connected to the control button.
[0013] In an embodiment of the present utility model, the first switching transistor is a triode, and the second switching transistor is a diode.
[0014] In an embodiment of the present utility model, the control button is a rocker switch.
[0015] In the technical solution of the present utility model, a low dropout linear regulator and a switching transistor are arranged in the control unit. The MCU detects the control button. When the button is disconnected, the MCU detects that the input is removed. First, the low dropout linear regulator continues to maintain a high level to drive the first switching transistor to turn on, locking the second switching transistor to turn on. After the MCU saves the data, the low dropout linear regulator changes to a low level, the switching transistor turns off, the circuit is powered off, and the MCU enters the shutdown state, so that the power does not immediately drop after shutdown, avoiding the risk of MCU data loss. And through button detection, after the MCU is charged and activated, if it detects that the control button is disconnected, the MCU does not allow other functions except charging, enhancing the logic of the circuit and being relatively safe. Description of the Drawings
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present utility model or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present utility model. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on the structures shown in these drawings.
[0017] Figure 1 It is the circuit diagram of the button power-on / off detection circuit of the present utility model.
[0018] Explanation of the reference numerals in the drawings:
[0019] 1. Input unit; 2. Button unit; 3. Control unit; CH_EN, First input port; BAT+, Second input port; SW1, Control button; LDO_EN, Low dropout linear regulator; Q1, First switching transistor; D1, Second switching transistor; Q2, MOS transistor.
[0020] The realization, functional characteristics and advantages of the object of the present utility model will be further described with reference to the embodiments and the drawings. Detailed Embodiments
[0021] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0022] Refer to Figure 1 , the present utility model provides a key power-on / off detection circuit, which includes an input unit 1, a key unit 2 and a control unit 3. The input unit 1 at least includes an MCU and a first input port CH_EN, and the first input port CH_EN is connected to a power supply; the key unit 2 is electrically connected to the input unit 1, and the key unit 2 is provided with a control key SW1 for outputting a control signal to the MCU; the control unit 3 is electrically connected to the key unit 2, and the control unit 3 at least includes a low dropout regulator LDO_EN, a first switching tube Q1 and a second switching tube D1; wherein, when the control key SW1 is turned off, the MCU detects the removal of the power supply at the first input port, the low dropout regulator LDO_EN maintains a high level to drive the first switching tube Q1 and the second switching tube D1 to turn on. After the MCU saves the data, the low dropout regulator LDO_EN changes to a low level, the first switching tube Q1 and the second switching tube D1 turn off, and the MCU is powered off.
[0023] It can be understood that the low dropout regulator LDO_EN (Low Dropout Regulator) is a voltage stabilizer, which is mainly used to provide a stable output voltage from a relatively high input voltage (usually slightly higher than the required output voltage), and the voltage difference (voltage difference or voltage differential) between the input voltage and the output voltage is very small (usually a few hundred mV or less), so it is called "low dropout". Its working principle is to achieve voltage stability by controlling the current from the input to the output. It adjusts the conduction state of the control element (such as a transistor or a power MOSFET) through a feedback mechanism to keep the output voltage stable, independent of the fluctuation of the input voltage.
[0024] In this example, when the power supply is connected to the first input port CH_EN, the MCU is normally activated. After the MCU is activated, the first switching tube Q1 is turned on by the high level of the low dropout regulator LDO_EN, thereby locking the second switching tube D1 to turn on. Since the control key SW1 is in the off state, the internal pull-up high level will be maintained, so that the MCU detects that the key is not used, and the MCU does not allow other functions except charging. When the power supply at the first input port CH_EN is removed, the MCU detects the input removal, first continues to maintain the high level of the low dropout regulator LDO_EN to drive the first switching tube Q1 to turn on, locking the second switching tube D1 to turn on. After the MCU saves the data, the low dropout regulator LDO_EN changes to a low level, the first switching tube Q1 turns off, the second switching tube D1 turns off, the circuit is powered off, and the MCU enters the shutdown state.
[0025] With the above settings, on the one hand, the power does not immediately drop after shutdown, avoiding the risk of MCU data loss. On the other hand, through key detection, after the MCU is charged and activated, if it is detected that the control key SW1 is disconnected, the MCU is not allowed to use other functions except charging, enhancing the logic of the circuit and being relatively safe.
[0026] Refer to Figure 1 , in an embodiment of the present application, the input unit 1 further includes a second input port BAT+, the second input port BAT+ is connected to a power supply, and the second input port BAT+ is electrically connected to the key unit 2.
[0027] It can be understood that the power supply connected to the second input port BAT+ is used to provide power for the control key SW1 in the closed state. When the control key SW1 is closed, the circuit is powered by the power supply of the second input port BAT+, and the MCU is activated. After the MCU is activated, the low-dropout linear regulator LDO_EN maintains a high level to drive the first switching transistor Q1 to turn on, thereby locking the second switching transistor D1 to turn on. When a control key SW1 interruption event occurs and the MCU detects that the control key SW1 is normally closed, functions are allowed to be used at this time. When the control key SW1 is disconnected, the interruption event is removed. The MCU detects that the control key SW1 is disconnected, first continues to keep the low-dropout linear regulator LDO_EN at a high level to drive the first switching transistor Q1 to turn on, locking the second switching transistor D1 to turn on. After the MCU saves the data, then both are turned off, the circuit is powered off, and the MCU enters the shutdown mode.
[0028] Refer to Figure 1 , in an embodiment of the present application, the first input port CH_EN is connected to a DC power supply, and the second input port BAT+ is connected to a storage battery.
[0029] It can be understood that the power supply of the second input port BAT+ is to supply power to the circuit when there is no external power supply. Therefore, it is undoubtedly more appropriate to use a storage battery, which has a certain degree of flexibility and convenience; while the power supply of the first input port CH_EN is to charge the storage battery and supply power to the circuit after the power of the storage battery is exhausted. Therefore, the first input port CH_EN is used to connect to a DC power supply, which has stability and can also meet high-power requirements.
[0030] Refer to Figure 1 , in an embodiment of the present application, the control unit 3 further includes a MOS transistor Q2, and the MOS transistor Q2 is electrically connected to the control key SW1.
[0031] Understandably, since the control button SW1 is on the loop of driving MOS transistor Q2, and the driving MOS transistor Q2 usually only requires a current of several hundred microamperes or a dozen milliamperes, no large current will flow into the control button SW1, thereby greatly improving the lifespan of the control button SW1.
[0032] Referring to Figure 1 , in an embodiment of the present application, the first switching transistor Q1 is a triode, and the second switching transistor D1 is a diode.
[0033] Understandably, both diodes and triodes can be used to control the flow of current. A diode, as a simple switch, can prevent reverse current, while a triode can turn on or off a circuit by controlling its base current. In this example, the base current output from the low-dropout linear regulator LDO_EN to the triode can control the current magnitude on the diode, thereby controlling the conduction state of the diode. At the same time, by controlling the conversion between the saturation region and the cut-off region of the triode, a fast switching operation of the diode can be achieved.
[0034] Referring to Figure 1 , in an embodiment of the present application, the control button SW1 is a rocker switch.
[0035] Understandably, using a rocker switch as the control button SW1 has the following advantages: easy to operate. The design of the rocker switch makes it easy to operate manually. Users can control the on / off state of the circuit through easy pressing or switching operations without additional tools or complex steps; durable. Rocker switches usually have a long service life and good durability, suitable for long-term and frequent use environments; reliable. Due to their simple mechanical structure, rocker switches are usually very reliable. They are not prone to failures during switch operations and can still work properly under harsh environmental conditions (such as humidity, dust, vibration, etc.); visibility and easy identification. Rocker switches usually have obvious switch state indicators, such as the position of the switch or color indicator lights. This allows users to easily identify the current state of the switch, thereby reducing the possibility of misoperation.
[0036] In the technical solution of the present utility model, a low dropout linear regulator LDO_EN and a switching tube are arranged in the control unit 3. The MCU detects the control button SW1. When the button is disconnected, the MCU detects the removal of the input. First, the high level of the low dropout linear regulator LDO_EN is continued to drive the first switching tube Q1 to open, and the second switching tube D1 is locked to open. After the MCU saves the data, the low dropout linear regulator LDO_EN changes to a low level, the switching tube is turned off, the circuit is powered off, and the MCU enters the shutdown state, so that the power will not drop immediately after shutdown, avoiding the risk of MCU data loss. And through button detection, after the MCU is charged and activated, if the control button SW1 is detected to be disconnected, the MCU does not allow other functions except charging, enhancing the logic of the circuit and being relatively safe.
[0037] In the attached drawings of this embodiment, the same or similar reference numerals correspond to the same or similar components; in the description of the present application, it should be understood that if there are terms such as "upper", "lower", "left", "right", etc. indicating the orientation or positional relationship, it is based on the orientation or positional relationship shown in the attached drawings. It is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, the terms describing the positional relationship in the attached drawings are only used for illustrative purposes and cannot be understood as a limitation of this patent. For those of ordinary skill in the art, the specific meanings of the above terms can be understood according to specific circumstances.
[0038] The above is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, and improvements made within the spirit and principle of the present application shall be included within the protection scope of the present application.
Claims
1. A key switch detection circuit, characterized in that: include: An input unit, the input unit at least comprising an MCU and a first input port, wherein the first input port is connected to a power source; A key unit, the key unit is electrically connected to the input unit, and the key unit is provided with a control key for outputting a control signal to the MCU; A control unit, the control unit is electrically connected to the key unit, and the control unit at least includes a low voltage drop linear regulator, a first switch tube and a second switch tube; Among them, when the control button is disconnected, the MCU detects that the power supply of the first input port is removed, and the low-voltage difference linear regulator maintains a high level to drive the first switch tube and the second switch tube to turn on. After the MCU saves the data, the low-voltage difference linear regulator changes to a low level, the first switch tube and the second switch tube are turned off, and the MCU is powered off.
2. The key switch detection circuit according to claim 1, characterized in that: The input unit further includes a second input port, the second input port is connected to a power source, and the second input port is electrically connected to the key unit.
3. The key switch detection circuit according to claim 2, characterized in that: The first input port is connected to a DC power source, and the second input port is connected to a battery.
4. The key switch detection circuit according to claim 3, characterized in that: The control unit further includes a MOS tube, and the MOS tube is electrically connected to the control button.
5. The key switch detection circuit according to claim 4, characterized in that: The first switch tube is a triode, and the second switch tube is a diode.
6. The key switch detection circuit according to any one of claims 1 to 5, characterized in that: The control button is a rocker switch.