Switch on-off time detection device and method

通过开关通断时间检测装置,利用模数转换器和充放电电路的组合,解决了开关闭合/断开时间检测误差大的问题,实现了时间的精确检测。

CN115128448BActive Publication Date: 2025-07-08QINGDAO YEELINK INFORMATION TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210832148.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-15
Publication Date
2025-07-08
Estimated Expiration
2042-07-15

AI Technical Summary

Technical Problem

In the prior art, there is a problem that there is a large error in determining the duration of the switch at the closing/disconnection by the high level/low level generated by the switch at the closing/disconnection.

Method used

A switch on-off time detection device is adopted, including a power supply power supply, on-off control circuit, charge and discharge circuit and voltage change circuit. The voltage at the connection point of the voltage change circuit is collected through an analog-to-digital converter. Combined with the slow voltage change of the charge and discharge circuit, the processor determines the switch's turn-off and close time.

Benefits of technology

Improve the detection accuracy of switch opening and closing time, reduce errors, and achieve accurate time detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115128448B_ABST
    Figure CN115128448B_ABST
Patent Text Reader

Abstract

The present application discloses a switch on / off time detection device and method. The switch on / off time detection device includes: a on / off control circuit, connected to a switch and a charge / discharge circuit, for controlling whether to start charging the charge / discharge circuit according to the open state / closed state of the switch; a charge / discharge circuit, connected to a voltage change circuit, for controlling the first triode in the voltage change circuit to be in a cut-off state or a conducting state; a voltage change circuit, when the first triode is in a conducting state, the voltage at the second connection point where the voltage change circuit is connected to the analog-to-digital converter is the difference between the power supply voltage and the voltage divided by the first resistor, and when the first triode is in a cut-off state, the voltage at the second connection point is the power supply voltage; an analog-to-digital converter, for collecting the voltage at the second connection point; a processor, connected to the analog-to-digital converter, for determining the time when the switch is in an open state and / or the time when the switch is in a closed state according to the collected voltage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communications, and more particularly, to a switch on / off time detection device and method. Background Art

[0002] With the intelligence of devices, more and more devices support executing different events according to different closing times of switches. However, currently, the high and low levels output when the switch is closed / opened are used as a judgment for the switch to be opened / closed. And the current method for judging the closing / opening time of the switch is to use the duration of the high level or low level as the closing / opening time of the switch. However, in this case, the error of the detected closing / opening time of the switch will be relatively large.

[0003] In view of the problem in the related art that the error of determining the duration of the switch in the closed / open state by the duration of the high / low level generated when the switch is closed / opened is relatively large, no effective solution has been proposed yet.

[0004] Therefore, it is necessary to improve the related art to overcome the defects in the related art. Summary of the Invention

[0005] Embodiments of the present invention provide a switch on / off time detection device and method to at least solve the problem that the error of determining the duration of the switch in the closed / open state by the duration of the high / low level generated when the switch is closed / opened is relatively large.

[0006] According to an embodiment of the present invention, there is provided a switch on-off time detection device, including: a power supply, which is respectively connected to a switch, a turn-on / off control circuit, a charge-discharge circuit, and a voltage change circuit; the switch is connected to the turn-on / off control circuit; the turn-on / off control circuit is connected to the charge-discharge circuit and is configured to control the charge-discharge circuit to be in an uncharged state when the switch is in an off state, and start charging the charge-discharge circuit when the switch is switched from the off state to an on state; the charge-discharge circuit is connected to the voltage change circuit and is configured to control a first triode in the voltage change circuit to be in a cut-off state when the switch is in an off state; when the switch is switched from the off state to the on state, the charge-discharge circuit starts charging, and when the voltage at a first connection point where the charge-discharge circuit is connected to the first triode reaches the conduction voltage of the first triode, control the first triode to be in a conduction state; in the voltage change circuit, when the first triode is in the cut-off state, the voltage at a second connection point where the voltage change circuit is connected to an analog-to-digital converter is the same as the power supply voltage provided by the power supply, and when the first triode is in the conduction state, the voltage at the second connection point is the difference between the power supply voltage and the voltage division on a first resistor, and the first resistor is connected between the power supply and the second connection point; an analog-to-digital converter is connected to the second connection point in the voltage change circuit and is configured to collect the voltage at the second connection point; a processor is connected to the analog-to-digital converter and is configured to obtain the voltage collected by the analog-to-digital converter and determine the time when the switch is in an off state and / or the time when it is in an on state according to the voltage collected by the analog-to-digital converter.

[0007] In an exemplary embodiment, the turn-on / off control circuit includes: a second triode. Wherein, when the switch is in the off state, the second triode is in a cut-off state, and the second triode is configured to control the charge-discharge circuit to be in an uncharged state when in the cut-off state; when the switch is switched from the off state to an on state, the second triode is in a conduction state, and the second triode is configured to start charging the charge-discharge circuit when in the conduction state.

[0008] In an exemplary embodiment, the second triode is respectively connected to the switch at a third connection point, to the positive pole of the power supply at a fourth connection point, and to the charge and discharge circuit at a fifth connection point. Wherein, when the difference between the voltage at the fourth connection point and the voltage at the third connection point is less than the conduction voltage of the second triode, the second triode is in a cut-off state; when the difference between the voltage at the fourth connection point and the voltage at the third connection point is greater than or equal to the conduction voltage of the second triode, the second triode is in a conduction state; wherein, when the second triode is in a cut-off state, the voltage at the fifth connection point is used to make the voltage difference across the charge and discharge circuit not meet the voltage condition for charging the charge and discharge circuit; when the second triode is in a conduction state, the voltage at the fifth connection point is used to make the voltage difference across the charge and discharge circuit meet the voltage condition for charging the charge and discharge circuit.

[0009] In an exemplary embodiment, the on-off control circuit further includes: a third triode, wherein when the switch is in the off state, the third triode is in a conduction state, and when the switch is switched from the off state to the on state, it is in a cut-off state; the third triode is used to control the charge and discharge circuit to be in a non-charged state when in the conduction state.

[0010] In an exemplary embodiment, the charge and discharge circuit includes: a capacitor, wherein when the switch is in the off state, the capacitor is in a non-charged state, and when the switch is switched from the off state to the on state, the capacitor starts to charge. During the charging process of the capacitor, the voltage at the first connection point changes, and when the voltage at the first connection point reaches the conduction voltage of the first triode, the first triode is controlled to be in a conduction state.

[0011] In an exemplary embodiment, the voltage change circuit includes: the first triode, which is respectively connected to the charge and discharge circuit at the first connection point, to the first resistor at the second connection point, and to the anode of the diode at the sixth connection point. Wherein, when the difference between the voltage at the first connection point and the voltage at the sixth connection point is less than the conduction voltage of the first triode, the first triode is in a cut-off state; when the difference between the voltage at the first connection point and the voltage at the sixth connection point is greater than or equal to the conduction voltage of the first triode, the first triode is in a conduction state; the diode, wherein the cathode of the diode is connected to the negative pole of the power supply.

[0012] In an exemplary embodiment, the switch is respectively connected to the positive electrode of the power supply at the third connection point and to the negative electrode of the power supply at the seventh connection point; the on-off control circuit includes: a second triode and a third triode; wherein, the second triode is respectively connected to the switch at the third connection point, to the positive electrode of the power supply at the fourth connection point, and to a capacitor at the fifth connection point; the third triode is respectively connected to the switch at the third connection point, to the capacitor at the eighth connection point, and to the negative electrode of the power supply at the ninth connection point; the charge-discharge circuit includes: the capacitor, and the capacitor is connected to the first triode at the first connection point; the voltage change circuit includes: the first triode, a diode and a first resistor, wherein, the first triode is connected to the first resistor at the second connection point and to the anode of the diode at the sixth connection point; the diode, wherein, the cathode of the diode is connected to the negative electrode of the power supply.

[0013] In an exemplary embodiment, the switch is respectively connected to the positive electrode of the power supply at the third connection point and to the negative electrode of the power supply at the seventh connection point, and is configured to control the connection between the positive electrode of the power supply and the negative electrode of the power supply through a second resistor when in the closed state, wherein the second resistor is connected between the positive electrode of the power supply and the third connection point.

[0014] In an exemplary embodiment, the processor is further configured to determine at least one of the following: when it is determined that the time for which the switch is in the closed state is a preset time, trigger a preset event corresponding to the preset time; when it is determined according to the voltage collected by the analog-to-digital converter that a voltage change curve, and it is determined according to the voltage change curve that the time for which the switch is in the closed state is a preset time, and the similarity between the voltage change curve and a target voltage change curve is greater than or equal to a preset similarity, trigger a preset event corresponding to the preset time, wherein the voltage change curve is the voltage change curve of the second connection point.

[0015] According to another embodiment of the present invention, there is also provided a method for detecting the on / off time of a switch, which is applied to the switch on / off time detection device described in any one of the above, and includes: controlling whether to start charging the charge-discharge circuit through the switch control on / off control circuit, wherein, when the switch is in the off state, the on / off control circuit controls the charge-discharge circuit to be in an uncharged state, and when the switch is switched from the off state to the closed state, the on / off control circuit starts charging the charge-discharge circuit; controlling whether the first triode of the voltage change circuit is turned on through the charge-discharge circuit, wherein, when the charge-discharge circuit is in an uncharged state, the charge-discharge circuit controls the first triode in the voltage change circuit to be in a cut-off state; when the switch is switched from the off state to the closed state, the charge-discharge circuit starts charging, and when the voltage at the first connection point where the charge-discharge circuit is connected to the first triode reaches the conduction voltage of the first triode, controlling the first triode to be in a conducting state; collecting the voltage at the second connection point where the analog-to-digital converter is connected to the voltage change circuit through the analog-to-digital converter; wherein, when the first triode is in the cut-off state, the voltage at the second connection point is the same as the power supply voltage provided by the power supply, and when the first triode is in the conducting state, the voltage at the second connection point is the difference between the power supply voltage and the voltage division on the first resistor, and the first resistor is connected between the power supply and the second connection point; obtaining the voltage collected by the analog-to-digital converter through the processor, and determining the time when the switch is in the off state, and / or, the time when it is in the closed state according to the voltage collected by the analog-to-digital converter; wherein, the power supply is respectively connected to the switch, the on / off control circuit, the charge-discharge circuit, and the voltage change circuit; the switch is connected to the on / off control circuit; the on / off control circuit is connected to the charge-discharge circuit; the charge-discharge circuit is connected to the voltage change circuit; the analog-to-digital converter is connected to the voltage change circuit; the processor is connected to the analog-to-digital converter.

[0016] Through the present invention, when the switch is closed / opened, the voltage at the connection point where the analog-to-digital converter is connected to the voltage change circuit is different. Further, the processor can determine the time when the switch is in the off state, and / or, the time when it is in the closed state according to the voltage at the connection point where the analog-to-digital converter is connected to the voltage change circuit. And due to the presence of the charge-discharge circuit, the change of the voltage of the analog-to-digital converter is slow, so that the time detected by the processor is accurate. By adopting the above technical solution, the accuracy of detecting the time when the switch is in the off state, and / or, the time when it is in the closed state is improved. It solves the problem that the error of determining the duration of the switch in the closed / open state by the duration of the high level / low level generated by the switch in the closed / open state is relatively large. Brief Description of the Drawings

[0017] The drawings herein are incorporated into and form a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.

[0018] To more clearly illustrate the technical solutions in the embodiments of the present application 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, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0019] Figure 1 is the structure diagram (1) of the switch on-off time detection device according to an embodiment of the present invention;

[0020] Figure 2 is the structure diagram (2) of the switch on-off time detection device according to an embodiment of the present invention;

[0021] Figure 3 is the schematic diagram of the voltage change curve according to an embodiment of the present invention;

[0022] Figure 4 is the structure diagram (3) of the switch on-off time detection device according to an embodiment of the present invention;

[0023] Figure 5 is the flowchart of the switch on-off time detection method according to an embodiment of the present invention; Detailed Embodiments

[0024] The present invention will be described in detail below with reference to the drawings and in conjunction with the embodiments. It should be noted that, without conflict, the embodiments and features in the present application can be combined with each other.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence.

[0026] In this embodiment, a switch on-off time detection device is provided, including but not limited to being applied in a curtain motor, Figure 1 is the structure diagram (1) of the switch on-off time detection device according to an embodiment of the present invention, as Figure 1 shown, including:

[0027] A power supply 10, which is respectively connected to a switch 20, a turn-on / off control circuit 30, a charge-discharge circuit 40, and a voltage change circuit 50;

[0028] The switch 20 is connected to the turn-on / off control circuit.

[0029] In an exemplary embodiment, the switch is connected to the positive electrode of the power supply at the third connection point and to the negative electrode of the power supply at the seventh connection point, and is configured to control the connection of the positive electrode of the power supply to the negative electrode of the power supply through the second resistor when in the closed state, wherein the second resistor is connected between the positive electrode of the power supply and the third connection point.

[0030] Specifically, Figure 2 is the structural diagram (II) of the switch on-off time detection device according to an embodiment of the present invention, as Figure 2 shown, the above-mentioned switch 20 is equivalent to Figure 2 K1 in Figure 2 the positive electrode of the above-mentioned power supply is equivalent to Figure 2 VCC in Figure 2 the negative electrode of the above-mentioned power supply is equivalent to Figure 2 GND in Figure 2 the above-mentioned second resistor is equivalent to

[0031] R1 in

[0032] The on-off control circuit 30 is connected to the charge and discharge circuit and is configured to control the charge and discharge circuit to be in an uncharged state when the switch is in the open state, and to start charging the charge and discharge circuit when the switch is switched from the open state to the closed state;

[0033] Specifically, the above-mentioned second diode is equivalent to Figure 2 Q1 in

[0034] In an exemplary embodiment, the second triode is connected to the switch at a third connection point, to the positive pole of the power supply at a fourth connection point, and to the charge and discharge circuit at a fifth connection point. Wherein, when the difference between the voltage at the fourth connection point and the voltage at the third connection point is less than the conduction voltage of the second triode, the second triode is in a cut-off state; when the difference between the voltage at the fourth connection point and the voltage at the third connection point is greater than or equal to the conduction voltage of the second triode, the second triode is in a conduction state; wherein, when the second triode is in a cut-off state, the voltage at the fifth connection point is used to make the voltage difference across the charge and discharge circuit not satisfy the voltage condition for charging the charge and discharge circuit; when the second triode is in a conduction state, the voltage at the fifth connection point is used to make the voltage difference across the charge and discharge circuit satisfy the voltage condition for charging the charge and discharge circuit.

[0035] It should be noted that the above-mentioned fourth connection point corresponds to Figure 2 the emitter of Q1 in

[0036] In an exemplary example, the on-off control circuit 30 further includes: a third triode, wherein when the switch is in the off state, the third triode is in a conduction state, and when the switch is switched from the off state to the on state, it is in a cut-off state; the third triode is used to control the charge and discharge circuit to be in an uncharged state when it is in the conduction state.

[0037] Specifically, as Figure 2 shown, the above-mentioned third triode corresponds to Figure 2 Q2 in

[0038] The charge and discharge circuit 40 is connected to the voltage change circuit, and is used to control the first triode in the voltage change circuit to be in a cut-off state when the switch is in the off state; when the switch is switched from the off state to the on state, the charge and discharge circuit starts to charge, and when the voltage at the first connection point where the charge and discharge circuit is connected to the first triode reaches the conduction voltage of the first triode, it controls the first triode to be in a conduction state;

[0039] In an exemplary embodiment, the charge and discharge circuit 40 includes a capacitor. When the switch is in the open state, the capacitor is in an uncharged state. When the switch is switched from the open state to the closed state, the capacitor starts to charge. During the charging process of the capacitor, the voltage at the first connection point changes. When the voltage at the first connection point reaches the conduction voltage of the first triode, the first triode is controlled to be in the conduction state.

[0040] Optionally, the above capacitor includes one or more capacitors. As Figure 2 shown, the above capacitor is equivalent to Figure 2 C1 and C2 in Figure 2 The above first triode is equivalent to

[0041] It should be noted that in this embodiment, by forming a charge and discharge circuit with capacitors, the time of voltage change of the analog-to-digital converter is changed. Then, the processor (such as an MCU) connected to the analog-to-digital converter can determine the time of the switch closed state by reading the analog voltage value of the input pin of the analog-to-digital converter. The voltage change of the analog-to-digital converter occurs slowly and is not a signal starting to count with a rising edge or a falling edge, and does not require a pulse to trigger. Therefore, by directly reading the voltage value of the analog-to-digital converter, the time can be determined, the detection time is accurate, and the processor does not need to count, so the power consumption is low.

[0042] For the voltage change circuit 50, when the first triode is in the cut-off state, the voltage at the second connection point where the voltage change circuit is connected to the analog-to-digital converter is the same as the power supply voltage provided by the power supply. When the first triode is in the conduction state, the voltage at the second connection point is the difference between the power supply voltage and the voltage division on the first resistor. The first resistor is connected between the power supply and the second connection point;

[0043] In an exemplary embodiment, the voltage change circuit 50 includes: the first triode, which is respectively connected to the charge and discharge circuit at the first connection point, connected to the first resistor at the second connection point, and connected to the anode of the diode at the sixth connection point. Wherein, when the difference between the voltage at the first connection point and the voltage at the sixth connection point is less than the conduction voltage of the first triode, the first triode is in the cut-off state. When the difference between the voltage at the first connection point and the voltage at the sixth connection point is greater than or equal to the conduction voltage of the first triode, the first triode is in the conduction state; the diode, wherein the cathode of the diode is connected to the negative pole of the power supply.

[0044] Specifically, the above first resistor is equivalent toFigure 2 R6 shown in, the above-mentioned analog-to-digital converter is equivalent to Figure 2 the ADC described in, the above-mentioned second connection point is equivalent to the collector of Q3. The above-mentioned sixth connection point is equivalent to the emitter of Q3, and the above-mentioned diode is equivalent to Figure 2 D1 in.

[0045] An analog-to-digital converter 60, connected to the second connection point in the voltage change circuit, is used to collect the voltage on the second connection point;

[0046] A processor 70, connected to the analog-to-digital converter 60, is used to obtain the voltage collected by the analog-to-digital converter, and determine the time when the switch is in the off state and / or the time when it is in the on state according to the voltage collected by the analog-to-digital converter.

[0047] In an exemplary embodiment, the analog-to-digital converter can determine a voltage change curve according to the collected voltage, and then determine the time when the switch is in the off state and / or the time when it is in the on state according to the voltage change curve. It should be noted that the voltage change curve is the voltage change curve of the second connection point.

[0048] Figure 3 is a schematic diagram of a voltage change curve according to an embodiment of the present invention. In an exemplary embodiment, the above-mentioned voltage change curve is specifically as Figure 3 shown.

[0049] In an exemplary embodiment, the processor 70 is further used to determine at least one of the following: when it is determined that the time when the switch is in the on state is a preset time, trigger a preset event corresponding to the preset time; when a voltage change curve is determined according to the voltage collected by the analog-to-digital converter, the time when the switch is in the on state is determined to be a preset time according to the voltage change curve, and the similarity between the voltage change curve and a target voltage change curve is greater than or equal to a preset similarity, trigger a preset event corresponding to the preset time, where the voltage change curve is the voltage change curve of the second connection point.

[0050] It should be noted that in an exemplary embodiment, in order to avoid the switch being mis-triggered, only when the similarity between the voltage change curve and the target voltage change curve is greater than or equal to the preset similarity, the preset event corresponding to the preset time is triggered. Optionally, the preset similarity can be 90%.

[0051] In an exemplary embodiment, if the long-press time of the current curtain motor switch is < 2S, the current movement stops; if the long-press time is 2S - 15S and then released, the LED flashes quickly and enters the network configuration mode, and the LED flashes quickly for 2 minutes continuously; if the long-press time is 15S - 30S, the LED stays on for 10S - 15S and then goes out, and the software is reset; if the long-press time is > 30S, the LED goes out and the hardware is reset.

[0052] With the above device, when the switch is closed / opened, the voltage at the connection point where the analog-to-digital converter is connected to the voltage change circuit is different. Thus, the processor can determine the time when the switch is in the open state and / or the time when it is in the closed state based on the voltage at the connection point connected to the voltage change circuit collected by the analog-to-digital converter. Moreover, due to the presence of the charge-discharge circuit, the change in the voltage of the analog-to-digital converter is slow, thereby making the detected time accurate. By adopting the above technical solution, the accuracy of detecting the time when the switch is in the open state and / or the time when it is in the closed state is improved. The problem of large errors in determining the duration when the switch is closed / opened by the duration of the high level / low level generated when the switch is closed / opened is solved.

[0053] In an exemplary embodiment, the switch is connected to the positive pole of the power supply at the third connection point and to the negative pole of the power supply at the seventh connection point respectively; the on-off control circuit includes: a second triode and a third triode; wherein, the second triode is connected to the switch at the third connection point, to the positive pole of the power supply at the fourth connection point, and to the capacitor at the fifth connection point; the third triode is connected to the switch at the third connection point, to the capacitor at the eighth connection point, and to the negative pole of the power supply at the ninth connection point; the charge-discharge circuit includes: the capacitor, and the capacitor is connected to the first triode at the first connection point; the voltage change circuit includes: the first triode, a diode and a first resistor, wherein, the first triode is connected to the first resistor at the second connection point and to the anode of the diode at the sixth connection point; for the diode, the cathode of the diode is connected to the negative pole of the power supply.

[0054] Specifically, as Figure 2 shown, the above switch is equivalent to Figure 2 K1 in Figure 2 . The switch being connected to the positive pole of the power supply at the third connection point includes: the switch is directly connected to the positive pole of the power supply at the third connection point, and the switch is directly connected to the positive pole of the power supply through the Figure 2 resistor R1 shown in Figure 2 . The above second triode is equivalent toFigure 2 Q3 in the above, the above capacitor is equivalent to Figure 2 C1 and C2 in the above, the above diode is equivalent to Figure 2 D1 in the above, the above first resistor is equivalent to Figure 2 R6 in the above, specifically, the connection manner of the above components is specifically as Figure 2 shown.

[0055] Obviously, the above-described embodiments are only a part of the embodiments of the present invention, rather than all embodiments. In order to better illustrate the above switch on / off time detection device, the following will describe the above process in conjunction with embodiments, but it is not used to limit the technical solutions of the embodiments of the present invention. Specifically:

[0056] In an alternative embodiment, Figure 4 is the structure diagram (three) of the switch on / off time detection device according to the embodiment of the present invention, specifically as Figure 4 shown. By reading the sampled voltage of the ADC at any time to determine the time when the switch is closed / opened, without continuously calculating the duration of the high and low levels.

[0057] In order to better illustrate the switch on / off time detection device of the present application, the following will be specifically described in conjunction with Figure 2 as follows:

[0058] When the switch K1 is in the off state, at this time, the voltage of the base (pin 1) of Q1 is the same as the VCC voltage, that is, Ve1 = Vb1 (that is, the emitter voltage of Q1 is equal to the base voltage), so the triode Q1 is in the cut-off state and Q1 is not conducting. At this time, the voltage of the base (pin 1) of the triode Q2 is the VCC voltage, and the pin 2 is grounded, so Vb2 - Ve2 > 0.7V for the triode Q2, so the triode Q2 is conducting, and R4 is directly grounded. At this time, the base voltage of Q3 is the voltage of the pull-down resistor R4, but R4 is directly grounded at this time, so Vb3 = 0, so Q3 is in the cut-off state, and thus the voltage of the ADC at this time is the VCC voltage.

[0059] When the switch K1 is in the closed state, it is equivalent to VCC directly grounding through the resistor R1. At this time, the base voltage of Q1 is 0. At this time, Ve1 - Vb1 > 0.7V, so the triode Q1 is conducting (at this time, the base voltage of the triode Q2 is also 0, so the triode Q2 is in the cut-off state). The two capacitors C1 and C2 receive the electric quantity from VCC through R5 for capacitor charging, and the voltage applied across C1 and C2 gradually rises.

[0060] When the voltage Vb3 (the base voltage of Q3) across C1 and C2 rises to Vb3 - Ve3 > 0.7V, the triode Q3 starts to conduct. At this time, the sampled voltage value Vadc of the ADC = VCC - IR6.

[0061] It should be noted that the current value I passing through the resistor R6 is the amplification factor β of the triode Q3 multiplied by the base current Ib3 of Q3. Until I reaches the maximum conduction current of the triode, I will no longer change with the change of Ib3.

[0062] It should be noted that the magnitude of the base current of the triode Q3 is related to the voltage Vb3 applied to the base of the triode and is in a direct proportional relationship. Therefore, the larger Vb3 is, the larger Ib3 is, and the smaller Vadc is. In this way, the closing time of the switch K1 can be judged by the voltage of Vadc. The specific trend of the voltage collected by the ADC is as follows Figure 3 as shown.

[0063] It should be noted that when K1 is released, the voltage value Vadc of the ADC will instantly return to the previous VCC voltage state (the waveform after T3). The time of T1 can be adjusted by D1, R5, C1, and C2. The larger D1 is, the larger R5 is, and the larger C1 and C2 are, the longer the time of T1 is. On the contrary, the time of T1 is shorter; the time of T2 can be adjusted by R5, C1, C2, and Q3. The larger R5, C1, and C2 are, and the larger the maximum conduction current of Q3 is, the gentler the slope between T1 and T2 is, and the longer this period lasts.

[0064] In this embodiment, a method for detecting the on-off time of a switch is further provided. This method is applied to the switch on-off time detection device in the above embodiment. Figure 5 It is a flowchart of the method for detecting the on-off time of a switch according to an embodiment of the present invention. The specific steps are as follows:

[0065] Step S502: Control whether to start charging the charge-discharge circuit through the switch control on-off control circuit. Wherein, when the switch is in the off state, the on-off control circuit controls the charge-discharge circuit to be in an uncharged state. When the switch is switched from the off state to the on state, the on-off control circuit starts to charge the charge-discharge circuit;

[0066] Step S504: Control whether the first triode of the voltage change circuit is turned on through the charge-discharge circuit. Wherein, when the charge-discharge circuit is in an uncharged state, the charge-discharge circuit controls the first triode in the voltage change circuit to be in a cut-off state; when the switch is switched from the off state to the on state, the charge-discharge circuit starts to charge. When the voltage at the first connection point where the charge-discharge circuit is connected to the first triode reaches the conduction voltage of the first triode, control the first triode to be in a conduction state;

[0067] Step S506: Collect the voltage at the second connection point where the analog-to-digital converter is connected to the voltage change circuit through the analog-to-digital converter; wherein, when the first triode is in the cut-off state, the voltage at the second connection point is the same as the power supply voltage provided by the power supply, and when the first triode is in the conduction state, the voltage at the second connection point is the difference between the power supply voltage and the voltage division on the first resistor, and the first resistor is connected between the power supply and the second connection point;

[0068] Step S508: Obtain the voltage collected by the analog-to-digital converter through the processor, and determine the time when the switch is in the off state and / or the time when it is in the on state according to the voltage collected by the analog-to-digital converter; wherein, the power supply is respectively connected to the switch, the on-off control circuit, the charge-discharge circuit, and the voltage change circuit; the switch is connected to the on-off control circuit; the on-off control circuit is connected to the charge-discharge circuit; the charge-discharge circuit is connected to the voltage change circuit; the analog-to-digital converter is connected to the voltage change circuit; the processor is connected to the analog-to-digital converter.

[0069] Through the above method, when the switch is closed / opened, the voltage at the connection point where the analog-to-digital converter is connected to the voltage change circuit is different. Furthermore, the processor can determine the time when the switch is in the off state and / or the time when it is in the on state according to the voltage at the connection point where the analog-to-digital converter is connected to the voltage change circuit. And due to the existence of the charge-discharge circuit, the change of the voltage of the analog-to-digital converter is slow, thus making the detected time accurate. By adopting the above technical solution, the accuracy of detecting the time when the switch is in the off state and / or the time when it is in the on state is improved. The problem of large error in determining the duration of the switch in the closed / open state by the duration of the high / low level generated when the switch is closed / opened is solved.

[0070] An embodiment of the present invention also provides a storage medium, which includes a stored program. When the above program runs, it executes the method of any one of the above.

[0071] An embodiment of the present invention also provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0072] Optionally, the above electronic device may further include a transmission device and an input / output device. The transmission device is connected to the above processor, and the input / output device is connected to the above processor.

[0073] Optionally, in this embodiment, the above storage medium may include, but is not limited to: various media that can store program codes, such as USB flash drives, read-only memories (ROM), random access memories (RAM), mobile hard disks, magnetic disks, or optical discs.

[0074] Optionally, specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and will not be elaborated herein.

[0075] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present invention can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. Optionally, they can be implemented by program codes executable by the computing device. Thus, they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them can be fabricated into a single integrated circuit module to implement. In this way, the present invention is not limited to any specific combination of hardware and software.

[0076] The foregoing is only the preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A switch on-off time detection device, characterized in that Comprising: A power supply, which is respectively connected to a switch, a on-off control circuit, a charge-discharge circuit, and a voltage change circuit; The switch is connected to the on-off control circuit; The on-off control circuit is connected to the charge-discharge circuit and is configured to control the charge-discharge circuit to be in an uncharged state when the switch is in an off state, and to start charging the charge-discharge circuit when the switch is switched from the off state to an on state; The charge-discharge circuit is connected to the voltage change circuit and is configured to control a first triode in the voltage change circuit to be in a cut-off state when the switch is in an off state; When the switch is switched from the off state to the on state, the charge-discharge circuit starts to charge, and when the voltage at a first connection point where the charge-discharge circuit is connected to the first triode reaches the conduction voltage of the first triode, the first triode is controlled to be in a conduction state; In the voltage change circuit, when the first triode is in the cut-off state, the voltage at a second connection point where the voltage change circuit is connected to an analog-to-digital converter is the same as the power supply voltage provided by the power supply. When the first triode is in the conduction state, the voltage at the second connection point is the difference between the power supply voltage and the voltage division on a first resistor, and the first resistor is connected between the power supply and the second connection point; An analog-to-digital converter is connected to the second connection point in the voltage change circuit and is configured to collect the voltage at the second connection point; A processor is connected to the analog-to-digital converter and is configured to obtain the voltage collected by the analog-to-digital converter and determine the time when the switch is in the off state and / or the time when the switch is in the on state based on the voltage collected by the analog-to-digital converter; Wherein, the charge-discharge circuit is composed of one or more capacitors combined.

2. The device according to claim 1, characterized in that, The on-off control circuit includes: A second triode. When the switch is in the off state, the second triode is in a cut-off state, and the second triode is configured to control the charge-discharge circuit to be in an uncharged state when in the cut-off state; when the switch is switched from the off state to an on state, the second triode is in a conduction state, and the second triode is configured to start charging the charge-discharge circuit when in the conduction state.

3. The device according to claim 2, characterized in that, The second triode is respectively connected to the switch at the third connection point, to the positive electrode of the power supply at the fourth connection point, and to the charge and discharge circuit at the fifth connection point. Wherein, when the difference between the voltage at the fourth connection point and the voltage at the third connection point is less than the conduction voltage of the second triode, the second triode is in the cut-off state; when the difference between the voltage at the fourth connection point and the voltage at the third connection point is greater than or equal to the conduction voltage of the second triode, the second triode is in the conduction state; wherein, when the second triode is in the cut-off state, the voltage at the fifth connection point is used to make the voltage difference between the two ends of the charge and discharge circuit not satisfy the voltage condition for charging the charge and discharge circuit; when the second triode is in the conduction state, the voltage at the fifth connection point is used to make the voltage difference between the two ends of the charge and discharge circuit satisfy the voltage condition for charging the charge and discharge circuit.

4. The device according to claim 2, characterized in that The on-off control circuit further includes: A third triode, wherein, when the switch is in the off state, the third triode is in the conduction state, and when the switch is switched from the off state to the on state, it is in the cut-off state; the third triode is used to control the charge and discharge circuit to be in the uncharged state when in the conduction state.

5. The device according to claim 1, characterized in that, When the switch is in the off state, the capacitor is in the uncharged state. When the switch is switched from the off state to the on state, the capacitor starts to charge. During the charging process of the capacitor, the voltage at the first connection point changes. When the voltage at the first connection point reaches the conduction voltage of the first triode, the first triode is controlled to be in the conduction state.

6. The device according to claim 1, characterized in that The voltage change circuit includes: The first triode is respectively connected to the charge and discharge circuit at the first connection point, to the first resistor at the second connection point, and to the anode of the diode at the sixth connection point. Wherein, when the difference between the voltage at the first connection point and the voltage at the sixth connection point is less than the conduction voltage of the first triode, the first triode is in the cut-off state; when the difference between the voltage at the first connection point and the voltage at the sixth connection point is greater than or equal to the conduction voltage of the first triode, the first triode is in the conduction state; The diode, wherein the cathode of the diode is connected to the negative electrode of the power supply.

7. The device according to claim 1, wherein The switch is respectively connected to the positive electrode of the power supply at the third connection point and to the negative electrode of the power supply at the seventh connection point; The on-off control circuit includes: a second triode and a third triode; wherein, the second triode is respectively connected to the switch at the third connection point, to the positive electrode of the power supply at the fourth connection point, and to the capacitor at the fifth connection point; the third triode is respectively connected to the switch at the third connection point, to the capacitor at the eighth connection point, and to the negative electrode of the power supply at the ninth connection point; The charge-discharge circuit includes: the capacitor, and the capacitor is connected to the first triode at the first connection point; The voltage change circuit includes: the first triode, a diode and a first resistor, wherein, the first triode is connected to the first resistor at the second connection point and to the anode of the diode at the sixth connection point; for the diode, the cathode of the diode is connected to the negative electrode of the power supply.

8. The device according to claim 1, characterized in that, The switch is respectively connected to the positive electrode of the power supply at the third connection point and to the negative electrode of the power supply at the seventh connection point, and is used for controlling, when in the closed state, the positive electrode of the power supply to be connected to the negative electrode of the power supply through a second resistor, wherein the second resistor is connected between the positive electrode of the power supply and the third connection point.

9. The device according to claim 1, characterized in that, The processor is further configured to determine at least one of the following: When it is determined that the time for the switch to be in the closed state is a preset time, trigger a preset event corresponding to the preset time; When it is determined according to the voltage collected by the analog-to-digital converter that a voltage change curve, according to the voltage change curve that the time for the switch to be in the closed state is a preset time, and the similarity between the voltage change curve and a target voltage change curve is greater than or equal to a preset similarity, trigger a preset event corresponding to the preset time, wherein the voltage change curve is the voltage change curve at the second connection point.

10. A method for detecting the on-off time of a switch, characterized in that, Applied to the switch on-off time detection device according to any one of claims 1 to 9, it includes: Controlling whether to start charging the charge-discharge circuit through the switch, wherein when the switch is in the open state, the on-off control circuit controls the charge-discharge circuit to be in an uncharged state, and when the switch is switched from the open state to the closed state, the on-off control circuit starts charging the charge-discharge circuit; Controlling whether the first triode of the voltage change circuit is turned on through the charge-discharge circuit, wherein when the charge-discharge circuit is in an uncharged state, the charge-discharge circuit controls the first triode in the voltage change circuit to be in a cut-off state; when the switch is switched from the open state to the closed state, the charge-discharge circuit starts charging, and when the voltage at the first connection point where the charge-discharge circuit is connected to the first triode reaches the conduction voltage of the first triode, controls the first triode to be in a conducting state; Collect the voltage at the second connection point where the analog-to-digital converter is connected to the voltage change circuit through the analog-to-digital converter; wherein, when the first triode is in the cut-off state, the voltage at the second connection point is the same as the power supply voltage provided by the power supply, and when the first triode is in the conducting state, the voltage at the second connection point is the difference between the power supply voltage and the voltage division on the first resistor, and the first resistor is connected between the power supply and the second connection point; Obtain the voltage collected by the analog-to-digital converter through the processor, and determine the time when the switch is in the off state and / or the time when it is in the on state according to the voltage collected by the analog-to-digital converter; Wherein, the power supply is respectively connected to the switch, the on-off control circuit, the charge-discharge circuit, and the voltage change circuit; the switch is connected to the on-off control circuit; the on-off control circuit is connected to the charge-discharge circuit; the charge-discharge circuit is connected to the voltage change circuit; the analog-to-digital converter is connected to the voltage change circuit; the processor is connected to the analog-to-digital converter; Wherein, the charge-discharge circuit is composed of one or more capacitors in combination.

Citation Information

Patent Citations

  • Switch signal detection circuit having self-diagnostic function

    CN108107357A

  • Switch control circuit and method and lamp

    CN113905482A