CN112285550A - Switch power-off detection method and device, computer equipment and readable storage medium - Google Patents

Switch power-off detection method and device, computer equipment and readable storage medium Download PDF

Info

Publication number
CN112285550A
CN112285550A CN202011183283.XA CN202011183283A CN112285550A CN 112285550 A CN112285550 A CN 112285550A CN 202011183283 A CN202011183283 A CN 202011183283A CN 112285550 A CN112285550 A CN 112285550A
Authority
CN
China
Prior art keywords
power
switch
mark
state change
detection signal
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011183283.XA
Other languages
Chinese (zh)
Other versions
CN112285550B (en
Inventor
彭灵
何苏平
娄旭
李涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Tuya Information Technology Co Ltd
Original Assignee
Hangzhou Tuya Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Tuya Information Technology Co Ltd filed Critical Hangzhou Tuya Information Technology Co Ltd
Priority to CN202011183283.XA priority Critical patent/CN112285550B/en
Publication of CN112285550A publication Critical patent/CN112285550A/en
Application granted granted Critical
Publication of CN112285550B publication Critical patent/CN112285550B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01RMEASURING ELECTRIC VARIABLES; MEASURING MAGNETIC VARIABLES
    • G01R31/00Arrangements for testing electric properties; Arrangements for locating electric faults; Arrangements for electrical testing characterised by what is being tested not provided for elsewhere
    • G01R31/327Testing of circuit interrupters, switches or circuit-breakers
    • G01R31/3277Testing of circuit interrupters, switches or circuit-breakers of low voltage devices, e.g. domestic or industrial devices, such as motor protections, relays, rotation switches

Abstract

The application relates to a switch power-off detection method, a system, a device and computer equipment, which comprises the steps of receiving a switch power-off detection signal, wherein the switch power-off detection signal is a square wave signal obtained by rectifying and depressurizing alternating current; setting a power-off mark and a switch state change mark according to the level of the switch power-off detection signal; the power-off mark is used for indicating whether a user triggers power-off action, and the switch state change mark is used for indicating the increase of the power-off triggering times; when the intelligent device is powered on, the power-off mark is set to be a first preset value, the switch state change mark is set to be a fourth preset value, and the power-off triggering frequency is increased by 1. The method judges the switch power-off state by detecting the level of the switch power-off detection signal and judging the dual judgment of the power-off mark and the switch state change mark, and the method can quickly and accurately detect the switch power-off no matter the driving power supply discharges slowly or quickly or slowly.

Description

Switch power-off detection method and device, computer equipment and readable storage medium
Technical Field
The application relates to the technical field of intelligent home, in particular to a switch power-off detection method and device, computer equipment and a readable storage medium.
Background
The power-off switch is widely used in the electronic industry, is only used for switching on and off power at first, and along with the rise and development of intelligent hardware, the power-off switch is endowed with more and more using methods and purposes while being compatible with traditional functions. For example, the color temperature or brightness of the bulb or the light mode is switched by the power-off switch; and the product is restored to factory settings or enters a distribution network state and the like by the continuous triggering times of the switch.
At present, a power-off switch on the market has two implementation modes, one mode is that a product is powered on, and a Flash record is written into a memory once when software starts to run; the other is that the product works normally, and the Flash record is written once when the software detects that the product is powered off in the running process. And each time the computer is electrified, different functions are executed or one state is triggered by reading the record in the Flash. The two modes have requirements on the charging and discharging time of the product hardware driving power supply, and have some defects: in the first mode, if the driving power supply discharges slowly, when the voltage does not drop below the starting voltage of the MCU, the MCU is powered on again, the MCU still runs normally, the running cannot be restarted, and Flash records cannot be written in. In the second mode, if the driving power supply discharges quickly, the voltage drops below the MCU working voltage instantly, the software does not detect the power failure, or the MCU stops working when the power failure trigger operation is not written into the Flash record. From the above analysis, it can be known that the compatibility, reliability and consistency of the current scheme on the market are not good, so that the switch power-off triggering times cannot be accurately detected.
Disclosure of Invention
The application provides a switch power-off detection method, a switch power-off detection device, computer equipment and a readable storage medium, which are used for at least solving the problem of inaccurate switch power-off detection in the related art.
In a first aspect, an embodiment of the present application provides a method for detecting a switch power failure, where the method includes: receiving a switch power-off detection signal, wherein the switch power-off detection signal is a square wave signal obtained by rectifying and depressurizing alternating current; acquiring the level of the switch power-off detection signal; setting a power-off mark and a switch state change mark according to the level of the switch power-off detection signal; the power-off mark is used for indicating whether a user triggers power-off action, and the switch state change mark is used for indicating the increase of the power-off triggering times; and when the intelligent equipment is powered on, setting the power-off mark as a first preset value, setting the switch state change mark as a fourth preset value, and adding 1 to the power-off triggering times.
In some embodiments, the switch power-off detection method further comprises: and acquiring the power-off triggering times, and controlling the working state of the intelligent equipment according to the power-off triggering times.
In some embodiments, the setting the power-off flag and the switch state change flag according to the level of the switch power-off detection signal includes:
if the switch power-off detection signal is at a low level, judging whether the duration time of the low level is longer than a first preset time, and if so, setting the power-off flag to be a second preset value;
if the switch power-off detection signal is at a high level, judging whether the power-off mark is a second preset value;
if the power-off mark is a second preset value, setting the power-off mark to be a first preset value, setting a switch state change mark to be a fourth preset value, and adding 1 to the power-off triggering times;
if the power-off mark is the first preset value, whether the switch state change mark is the fourth preset value or not is judged, if the switch state change mark is the fourth preset value, the switch state change mark is set to be the third preset value, and the power-off triggering frequency is increased by 1.
In some embodiments, the first preset duration is greater than or equal to 2 cycles of the square wave signal.
In some of these embodiments, the method further comprises: recording the duration of the change of the switch state; and if the on-off state change duration is longer than a second preset duration, clearing the previous power-off triggering times and the on-off state change duration.
In some of these embodiments, the smart device comprises a lighting device.
In a second aspect, the present application further provides an intelligent device control system, including: the system comprises an alternating current power supply, a switch, a driving power supply, a switch power-off detection circuit and an Internet of things module; wherein:
the alternating current power supply is used for supplying electric energy to the intelligent equipment control system;
one end of the driving power supply is connected with the alternating current power supply through the switch, and the other end of the driving power supply is connected with the internet of things module and used for converting the alternating current power supply into preset voltage to drive the intelligent equipment and the physical network module;
one end of the switch power-off detection circuit is connected with the driving power supply, and the other end of the switch power-off detection circuit is connected with an IO port of the Internet of things module, and is used for detecting the power-off triggering operation of the switch and outputting a switch power-off detection signal to the Internet of things module;
the physical network module is respectively connected with the switch power-off detection circuit and the intelligent device, and is used for receiving the switch power-off detection signal and setting a power-off mark and a switch state change mark according to the current level of the switch power-off detection signal; the power-off mark is used for indicating whether a user triggers power-off action, and the switch state change mark is used for indicating the increase of the power-off triggering times; when the intelligent equipment is powered on, setting the power-off mark as a first preset value and setting the switch state change mark as a fourth preset value, and adding 1 to the power-off triggering times; and controlling the working state of the intelligent equipment according to the power-off triggering times.
In a third aspect, an embodiment of the present application provides a switch power-off detection apparatus, where the apparatus includes:
the receiving module is used for receiving a switch power-off detection signal, wherein the switch power-off detection signal is a square wave signal obtained by rectifying and depressurizing alternating current;
the acquisition module is used for acquiring the level of the switch power-off detection signal;
the first setting module is used for setting a power-off mark and a switch state change mark according to the current level of the switch power-off detection signal; wherein the power-off flag is used for indicating whether a user triggers power-off action, and the switch state change flag is used for indicating the increase of the power-off triggering times;
and the second setting module is used for setting the power-off mark to be a first preset value and setting the switch state change mark to be a fourth preset value when the intelligent equipment is powered on, and adding 1 to the power-off triggering times.
In a fourth aspect, an embodiment of the present application provides a computer device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the computer program, the method for detecting a switch power failure according to the first aspect is implemented.
In a fifth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method for detecting a switch outage is implemented as described in the first aspect above.
Compared with the related art, the switch power-off detection method, the switch power-off detection device and the computer equipment provided by the embodiment of the application comprise the steps of receiving a switch power-off detection signal, wherein the switch power-off detection signal is a square wave signal obtained by rectifying and reducing voltage of alternating current; acquiring the level of the power-off detection signal; setting a power-off mark and a switch state change mark according to the level of the switch power-off detection signal; the power-off mark is used for indicating whether a user triggers power-off action, and the switch state change mark is used for indicating the increase of the power-off triggering times; when the intelligent device is powered on, the power-off mark is set to be a first preset value, the switch state change mark is set to be a fourth preset value, and the power-off triggering frequency is increased by 1, so that the problem that switch power-off detection in the related technology is inaccurate is solved.
The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below to provide a more thorough understanding of the application.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a flow diagram of a method of switch outage detection provided in one embodiment;
FIG. 2 is a circuit diagram of switch outage detection hardware provided in one embodiment;
FIG. 3 is a flow chart of a preferred embodiment of a switch outage detection method provided herein;
FIG. 4 is a schematic diagram of a power down detection signal upon initial power up provided in one embodiment;
FIG. 5 is a diagram illustrating an embodiment of a power-down detection signal when the driving power supply discharges slowly;
FIG. 6 is a diagram illustrating an embodiment of a power-down detection signal when the driving power is discharged quickly;
FIG. 7 is a block diagram of a switch power-off detection apparatus provided in one embodiment;
FIG. 8 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments provided in the present application without any inventive step are within the scope of protection of the present application.
It is obvious that the drawings in the following description are only examples or embodiments of the present application, and that it is also possible for a person skilled in the art to apply the present application to other similar contexts on the basis of these drawings without inventive effort. Moreover, it should be appreciated that in the development of any such actual implementation, as in any engineering or design project, numerous implementation-specific decisions must be made to achieve the developers' specific goals, such as compliance with system-related and business-related constraints, which may vary from one implementation to another.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the specification. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of ordinary skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments without conflict.
Unless defined otherwise, technical or scientific terms referred to herein shall have the ordinary meaning as understood by those of ordinary skill in the art to which this application belongs. Reference to "a," "an," "the," and similar words throughout this application are not to be construed as limiting in number, and may refer to the singular or the plural. The present application is directed to the use of the terms "including," "comprising," "having," and any variations thereof, which are intended to cover non-exclusive inclusions; for example, a process, method, system, article, or apparatus that comprises a list of steps or modules (elements) is not limited to the listed steps or elements, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. Reference to "connected," "coupled," and the like in this application is not intended to be limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The term "plurality" as referred to herein means two or more. "and/or" describes an association relationship of associated objects, meaning that three relationships may exist, for example, "A and/or B" may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. Reference herein to the terms "first," "second," "third," and the like, are merely to distinguish similar objects and do not denote a particular ordering for the objects.
Various technologies described herein can be applied to the field of smart hardware and internet of things smart homes.
Fig. 1 is a flowchart of a method for detecting a switch outage according to an embodiment, where, as shown in fig. 1, the method for detecting a switch outage includes steps 110 to 140; wherein:
and step 110, receiving a switch power-off detection signal, wherein the switch power-off detection signal is a square wave signal obtained by rectifying and depressurizing the alternating current.
And step 120, acquiring the level of the switch power-off detection signal.
Switch outage detected signal can be high-low level, is the low level when adopting the outage in this application, is the 50HZ square wave during normal power supply. It is understood that the switch de-energizing detection signal can be a square wave of other frequencies.
In addition, the switch power-off detection signal in the application is a square wave signal obtained after rectification and voltage reduction processing is carried out on alternating current. The hardware circuit for obtaining the switch power-off detection signal is shown in fig. 2, that is, one more line is added to the original driving power supply, and the switch power-off detection signal obtained after the AC power supply is rectified and stepped down is input to a single chip or a processor for normal IO.
The self-reset switch is taken as an example for explanation, the self-reset normally-closed switch is closed at ordinary times, namely, the product is powered on at ordinary times, when the self-reset normally-closed switch is pressed down, the product can cut off the power supply of the power supply, the switch power-off detection signal immediately becomes low level, and at the moment, the singlechip, the processor or the Internet of things module immediately detects the switch power-off to execute related actions. It will be appreciated that the solution in the present application also supports other types of switches and is not limited to use only for self-resetting switches.
Step 130, setting a power-off mark and a switch state change mark according to the level of the switch power-off detection signal; the power-off mark is used for indicating whether a user triggers power-off action, and the switch state change mark is used for indicating the increase of the power-off triggering times.
When the switch power-off detection signal is detected to be at a low level and the duration of the low level reaches a preset duration, it indicates that the user triggers the power-off action. When the power-off detection signal is detected to be at a high level, the user may not trigger the power-off action; possibly, the user does the power-off action, but the MCU is not really powered off and is powered on again; or the user does power-off operation and the MCU is powered on and restarted; it may also be that without actually powering down, it is powered up again. Therefore, it is not accurate to determine whether the user triggers the switch to power off according to the MCU power off condition. If the driving power supply discharges slowly, when the voltage does not drop below the starting voltage of the MCU, the MCU is powered on again, the MCU still runs normally and does not restart running, and Flash records cannot be written in, so that the omission of power-off triggering times is caused. If the driving power supply discharges quickly, the voltage drops below the MCU working voltage instantly, the MCU stops working when the software does not detect power failure or the Flash record is not written, and the omission of the power failure triggering times can be caused.
In this application, according to the level height of switch outage detected signal, set up outage sign and switch state and change the sign. The method comprises the following specific steps:
if the switch power-off detection signal is at a low level, judging whether the continuous low-level time is longer than a first preset time, and if so, setting a power-off flag to be a second preset value;
if the switch power-off detection signal is at a high level, judging whether the power-off mark is a second preset value;
if the power-off mark is the second preset value, setting the power-off mark as the first preset value, setting the switch state change mark as the fourth preset value, and adding 1 to the power-off triggering times;
and if the power-off mark is the first preset value, judging whether the switch state change mark is a fourth preset value, if so, setting the switch state change mark to be a third preset value, and adding 1 to the power-off triggering times.
In this embodiment, the first preset value and the third preset value are 0, and the second preset value and the fourth preset value are 1.
Preferably, whether the switch power-off detection signal is a square wave is detected firstly, and the square wave detection mode is as follows: and detecting whether the switch power-off detection signal has a high level or a low level, and if the current detected signal is the high level and the last detected signal is the low level, determining that the signal is a square wave signal. After it is determined that the received square wave is received, the subsequent judgment is started. Specifically, if the switch power-off detection signal is detected to be at a low level, whether the duration of the low level is longer than 200 milliseconds is continuously judged, and if so, the power-off flag is set to be 1.
If the switch power-off detection signal is detected to be high level, two judgments are available: one is to detect whether the power-off flag is set to 1, if the power-off flag is set to 1, it indicates that the user has done power-off operation, but the MCU is powered on again after not being really powered off, at this time, the power-off flag is cleared to 0, and the switch state change flag 1 is set; and secondly, if the power failure flag is 0, judging whether the switch state flag is set to be 1 or not, if the power failure flag is set to be 1, indicating that the user does power failure action, wherein the MCU may be powered on and restarted or powered on again without real power failure, clearing the switch state change flag to be 0 at the moment, starting switch state change timing, and adding 1 to the power failure triggering frequency.
Step 140, when the smart device is powered on, setting the power-off flag to the first preset value and setting the switch state change flag to the fourth preset value, and adding 1 to the power-off triggering times.
Under the condition that the driving power supply discharges quickly, the voltage drops below the MCU working voltage instantly, the software does not detect the power failure, or the Flash record is not written in, the MCU stops working, and the power failure triggering times are missed.
When the intelligent device is powered on, the power-off triggering times are increased by 1 so as to compensate the condition that the last power-off triggering software cannot record the power-off triggering times caused by the last time and the power-off triggering times are missed.
Compared with the prior art, the switch power-off detection method comprises the steps of receiving a switch power-off detection signal, wherein the switch power-off detection signal is a square wave signal obtained by rectifying and reducing voltage of alternating current; acquiring the level of a switch power-off detection signal; setting a power-off mark and a switch state change mark according to the level of the switch power-off detection signal; the power-off mark is used for indicating whether a user triggers power-off action, and the switch state change mark is used for indicating the increase of the power-off triggering times; when the intelligent device is powered on, the power-off mark is set to be a first preset value, the switch state change mark is set to be a fourth preset value, and the power-off triggering frequency is increased by 1. According to the method, the power-off action triggered by the user is recorded through the power-off mark, if the MCU is detected not to be powered off at present, whether the power-off action is triggered by the user is judged according to the power-off mark recorded last time, and the switch state change mark is set, so that the problem that power-off triggering times are missed due to slow discharge of the driving power supply can be solved. In addition, aiming at the problem that the power-off triggering times are missed due to the fact that the driving power supply discharges soon, when the intelligent device is powered on, the power-off triggering times are increased by 1 so as to compensate the situation that the last power-off triggering software cannot record the missed power-off triggering times caused by the fact. The switch power-off triggering times are judged by the level height of the switch power-off detection signal and the dual judgment of the power-off mark and the switch state change mark, so that the accuracy of power-off detection is improved, and the method can well and accurately and quickly detect the power-off of the switch no matter whether the driving power supply discharges slowly or discharges quickly or quickly.
In some embodiments, the switch power-off detection method further comprises: and acquiring the power-off triggering times, and controlling the working state of the intelligent equipment according to the power-off triggering times.
The intelligent device in this application can be door and window sensor, intelligent lock, intelligent doorbell, intelligent camera, intelligent lamps and lanterns, intelligent air conditioner or other intelligent house equipment to can receive the control command that intelligent house controlling means issued and carry out corresponding action. The control device may be a switch, and the control instruction may be the number of times of triggering the switch. Different trigger times correspond to different modes of different intelligent devices. In this embodiment, the intelligent device is taken as an example to explain, for example, if a user continuously triggers the switch three times, the color temperature of the bulb is switched to the first color temperature; if the user triggers the switch for four times continuously, the light mode is switched to be the first mode; and if the user triggers the switch for five times continuously, the intelligent lamp is restored to factory settings, and the like. It should be noted that the number of times of switch triggering and the working state of the matched intelligent device may be preset and stored in the memory, and when the switch power-off triggering is detected, the stored working state corresponding to the intelligent device is queried and the intelligent device is controlled to execute the operation.
Because the switch outage in this application detects fast and accurately, consequently, control smart machine is quick accurate more, the chaotic problem of control can not appear to user experience has been promoted.
In some embodiments, the first preset duration is greater than or equal to 2 cycles of the square wave signal.
Referring to fig. 4, each period of the square wave signal includes a high level and a low level. If the switch power-off detection signal is a 50HZ square wave signal, 20 milliseconds 1 period, 1 period has high and low levels, and 200 milliseconds has 10 periods of square wave signals. It can be understood that 200 milliseconds can be properly adjusted, and theoretically, as long as the continuous low level is ensured within more than 2 cycles, it can be determined that the user has performed the power-off triggering action.
In some embodiments, the switch power-off detection method further comprises: recording the duration of the change of the switch state; and if the on-off state change duration is longer than a second preset duration, clearing the previous power-off triggering times and the on-off state change duration.
The second preset time length can be 5 seconds, 6 seconds or 7 seconds, and a user can set the specific time length according to actual conditions or habits. The present embodiment takes the second preset time period as 5 seconds as an example for explanation. When the on-off state change duration is longer than 5 seconds, namely the on-off state is not changed for more than 5 seconds, the previous continuous pressing times are cleared and stored in the memory, so that misoperation of a user is avoided.
In order to better describe the effectiveness of the switch power-off detection method provided by the present application, the following describes the program operation flow in four situations, as shown in fig. 3. It can be seen from the flow that no matter the driving power supply discharges slowly, discharges fast, or fast and slow, the switch power-off detection method provided by the application can be well compatible with various situations, and the switch power-off can be detected accurately and fast.
The first situation is as follows: first power up (MCU power up restart), refer to fig. 4.
And reading parameters stored in the Flash after the intelligent equipment is powered on, wherein the parameters comprise the power-off triggering times and the equipment state. Then, the power-off flag is cleared to 0, and the switch state change flag is set to 1, and a power-off detection cycle is entered. And judging whether the switch state change flag is set to be 1 or not, if so, indicating that the user does power-off action, the MCU may be powered on and restarted or not and powered on again, clearing the switch state change flag to be 0 at the moment, starting switch state change timing, adding 1 to the number of continuous pressing times, setting the equipment state and storing the equipment state in Flash, and then executing the A related function module which can be understood as the working state of the intelligent equipment corresponding to the power-off times of the switch. (the specific execution number: 0- > 1- > 2- > 3- > 6- > 9- > 10- > A).
And (3) normally running a program:
when the switch power-off detection signal is detected to be at a low level, judging whether the duration of the low level time is more than 200 milliseconds (execution number: 3- > 4- > 3- > 4-);
when detecting that the power-off detection signal is at a high level, judging whether a power-off mark is set to be 1 or not, and judging whether a switch state mark is set to be 1 or not (an execution number is 3- > 6- > 7- > 9- > 3- > 6- > 7- > 9-);
whether the switch state change duration is greater than 5 seconds (execution number: 3- > 6- > 12- > 3- > 6- > 12-);
case two: the drive power supply discharges slowly (power is off during normal operation of the program, and power is powered up again when not discharging below the MCU operating voltage), see fig. 5.
The execution steps of the normal operation of the program are similar to the execution steps of the normal operation of the program in the above case 1, and are not described herein again.
After the power failure is triggered, the MCU is powered on again without real power failure, and the program is not powered on and restarted:
detecting a low level and setting a power-off flag to be 1 when the continuous low level time is more than 200 milliseconds; when the high level is detected and the power-off flag is set to 1, the user is indicated to do power-off triggering action, but the MCU is not really powered off and is powered on again, the power-off flag is cleared to 0, and the switch state change flag is set to 1; and then judging that the switch state change flag is set, if the switch state change flag is set to be 1, indicating that the user does power-off action, but the MCU is not really powered off and is powered on again, clearing the switch state change flag to be 0 at the moment, starting switch state change timing, adding 1 to the number of successive pressing times, setting the equipment state and storing the equipment state in Flash, and executing the A related function module (the execution number is 3- > 4- > 5- > 3- > 6- > 7- > 8- > 9- > 10- > A).
The program runs normally.
Case three: the driving power supply discharges quickly (the power is cut off in the normal running process of the program, the single chip microcomputer stops working after not processing relevant affairs, and then is powered on again), and refer to fig. 6.
The steps for executing the program in normal operation are not described herein again.
And (3) powering off, wherein the MCU is really powered off and is powered on again, and the program is powered on and restarted:
similar to the first power-on execution step, details are not repeated herein.
The steps for executing the program in normal operation are not described herein again.
Case four: the discharge time is critical, or the discharge is rapid in some cases, and the discharge is slow in some cases; referring to cases two and three, the description is omitted here.
It should be understood that although the steps in the flowcharts of fig. 1 and 3 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 1 and 3 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least some of the sub-steps or stages of other steps.
The present embodiment further provides a switch power-off detection apparatus, which is used to implement the foregoing embodiments and preferred embodiments, and the description of the apparatus is omitted here. As used below, the terms "module," "unit," "subunit," and the like may implement a combination of software and/or hardware for a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
The present application further provides an intelligent device control system, referring to fig. 2, the system including: the system comprises an alternating current power supply, a switch, a driving power supply, a switch power-off detection circuit and an Internet of things module; wherein:
the alternating current power supply is used for supplying electric energy to the intelligent equipment control system;
one end of the driving power supply is connected with the alternating current power supply through the switch, and the other end of the driving power supply is connected with the Internet of things module and used for converting the alternating current power supply into preset voltage to drive the intelligent equipment and the physical network module;
one end of the switch power-off detection circuit is connected with the driving power supply, and the other end of the switch power-off detection circuit is connected with an IO port of the Internet of things module and is used for detecting the power-off triggering operation of the switch and outputting a switch power-off detection signal to the Internet of things module;
the physical network module is respectively connected with the switch power-off detection circuit and the intelligent equipment and is used for receiving the switch power-off detection signal and setting a power-off mark and a switch state change mark according to the current level of the switch power-off detection signal; the power-off mark is used for indicating whether a user triggers power-off action, and the switch state change mark is used for indicating the increase of the power-off triggering times; when the intelligent equipment is powered on, setting a power-off mark as a first preset value and setting a switch state change mark as a fourth preset value, and adding 1 to the power-off triggering times; and controlling the working state of the intelligent equipment according to the power-off triggering times.
The intelligent device control system sets the power-off mark and the switch state change mark according to the level of the switch power-off detection signal by detecting the level of the switch power-off detection signal. The switch power-off is detected through dual judgment of the power-off mark and the switch state change mark, and the system can accurately and quickly detect the switch power-off no matter whether the driving power supply discharges slowly or quickly.
The embodiment of the application provides a switch outage detection device, as shown in fig. 7, switch outage detection device includes:
the receiving module 710 is configured to receive a switch power-off detection signal, where the switch power-off detection signal is a square wave signal obtained by performing rectification and voltage reduction processing on alternating current;
an obtaining module 720, configured to obtain a level of the switch power-off detection signal;
the first setting module 730, configured to set a power-off flag and a switch state change flag according to a level of the switch power-off detection signal; the power-off mark is used for indicating whether a user triggers power-off action, and the switch state change mark is used for indicating the increase of the power-off triggering times;
the second setting module 740 is configured to set the power-off flag to the first preset value and set the switch state change flag to the fourth preset value when the smart device is powered on, and add 1 to the power-off triggering frequency.
The device sets the power-off mark and the switch state change mark according to the level of the switch power-off detection signal by acquiring the switch power-off detection signal, and detects the switch power-off by double judgment of the power-off mark and the switch state change mark. No matter the driving power supply discharges slowly, discharges fast or fast, the switch power-off detection method can be well compatible with various situations, and power-off can be detected accurately and fast.
In some embodiments, the switch power-off detection apparatus further includes a control module (not shown in the figure) configured to obtain the number of power-off triggers, and control the operating state of the smart device according to the number of power-off triggers.
In some embodiments, the detecting module 720 is further configured to determine whether the duration of the low level is greater than a first preset duration if the switch power-off detection signal is detected to be a low level, and set the power-off flag to a second preset value if the duration of the low level is greater than the first preset duration; if the power-off detection signal is detected to be in a high level, judging whether the power-off mark is in a second preset value, if so, setting the power-off mark to be in a first preset value, setting a switch state change mark to be in a fourth preset value, and adding 1 to the power-off triggering times; and if the power-off mark is the first preset value, judging whether the switch state change mark is a fourth preset value, if so, setting the switch state change mark to be a third preset value, and adding 1 to the power-off triggering times.
In some embodiments, the first preset duration is greater than or equal to 2 periods of the square wave signal, and each period of the square wave signal includes a high level and a low level.
In some embodiments, the first setting module 730 is further configured to: recording the duration of the change of the switch state; and if the on-off state change duration is longer than a second preset duration, clearing the previous power-off triggering times and the on-off state change duration.
In some of these embodiments, the smart device comprises a lighting device. In other embodiments, the smart device may also be a curtain, a refrigerator, an air conditioner, a door lock, or other smart devices.
For the specific definition of the switch power-off detection device, reference may be made to the above definition of the switch power-off detection method, which is not described herein again. All or part of the modules in the switch power-off detection device can be realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In addition, the switch power-off detection method described in the embodiment of the present application with reference to fig. 1 may be implemented by a computer device. Fig. 8 is a hardware structure diagram of a computer device according to an embodiment of the present application.
The computer device may comprise a processor 81 and a memory 82 in which computer program instructions are stored.
Specifically, the processor 81 may include a Central Processing Unit (CPU), or A Specific Integrated Circuit (ASIC), or may be configured to implement one or more Integrated circuits of the embodiments of the present Application.
Memory 82 may include, among other things, mass storage for data or instructions. By way of example, and not limitation, memory 82 may include a Hard Disk Drive (Hard Disk Drive, abbreviated to HDD), a floppy Disk Drive, a Solid State Drive (SSD), flash memory, an optical Disk, a magneto-optical Disk, tape, or a Universal Serial Bus (USB) Drive or a combination of two or more of these. Memory 82 may include removable or non-removable (or fixed) media, where appropriate. The memory 82 may be internal or external to the data processing apparatus, where appropriate. In a particular embodiment, the memory 82 is a Non-Volatile (Non-Volatile) memory. In particular embodiments, Memory 82 includes Read-Only Memory (ROM) and Random Access Memory (RAM). The ROM may be mask-programmed ROM, Programmable ROM (PROM), Erasable PROM (EPROM), Electrically Erasable PROM (EEPROM), Electrically rewritable ROM (EAROM), or FLASH Memory (FLASH), or a combination of two or more of these, where appropriate. The RAM may be a Static Random-Access Memory (SRAM) or a Dynamic Random-Access Memory (DRAM), where the DRAM may be a Fast Page Mode Dynamic Random-Access Memory (FPMDRAM), an Extended data output Dynamic Random-Access Memory (EDODRAM), a Synchronous Dynamic Random-Access Memory (SDRAM), and the like.
The memory 82 may be used to store or cache various data files for processing and/or communication use, as well as possibly computer program instructions for execution by the processor 82.
The processor 81 implements any of the switch power-off detection methods in the above-described embodiments by reading and executing computer program instructions stored in the memory 82.
In some of these embodiments, the computer device may also include a communication interface 83 and a bus 80. As shown in fig. 8, the processor 81, the memory 82, and the communication interface 83 are connected via the bus 80 to complete communication therebetween.
The communication interface 83 is used for implementing communication between modules, devices, units and/or equipment in the embodiment of the present application. The communication port 83 may also be implemented with other components such as: the data communication is carried out among external equipment, image/data acquisition equipment, a database, external storage, an image/data processing workstation and the like.
Bus 80 includes hardware, software, or both to couple the components of the computer device to each other. Bus 80 includes, but is not limited to, at least one of the following: data Bus (Data Bus), Address Bus (Address Bus), Control Bus (Control Bus), Expansion Bus (Expansion Bus), and Local Bus (Local Bus). By way of example, and not limitation, Bus 80 may include an Accelerated Graphics Port (AGP) or other Graphics Bus, an Enhanced Industry Standard Architecture (EISA) Bus, a Front-Side Bus (FSB), a Hyper Transport (HT) Interconnect, an ISA (ISA) Bus, an InfiniBand (InfiniBand) Interconnect, a Low Pin Count (LPC) Bus, a memory Bus, a microchannel Architecture (MCA) Bus, a PCI (Peripheral Component Interconnect) Bus, a PCI-Express (PCI-X) Bus, a Serial Advanced Technology Attachment (SATA) Bus, a Video Electronics Bus (audio Electronics Association), abbreviated VLB) bus or other suitable bus or a combination of two or more of these. Bus 80 may include one or more buses, where appropriate. Although specific buses are described and shown in the embodiments of the application, any suitable buses or interconnects are contemplated by the application.
The computer device may execute the power outage detection method in the embodiment of the present application based on the obtained program instruction, thereby implementing the switch power outage detection method described in conjunction with fig. 1.
In addition, in combination with the switch power-off detection method in the foregoing embodiment, the embodiment of the present application may provide a computer-readable storage medium to implement. The computer readable storage medium having stored thereon computer program instructions; the computer program instructions, when executed by a processor, implement any of the switch power-off detection methods in the above embodiments.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the claims. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method for detecting a switch outage, the method comprising:
receiving a switch power-off detection signal, wherein the switch power-off detection signal is a square wave signal obtained by rectifying and depressurizing alternating current;
acquiring the level of the switch power-off detection signal;
setting a power-off mark and a switch state change mark according to the level of the switch power-off detection signal; the power-off mark is used for indicating whether a user triggers power-off action, and the switch state change mark is used for indicating the increase of the power-off triggering times;
and when the intelligent equipment is powered on, setting the power-off mark as a first preset value, setting the switch state change mark as a fourth preset value, and adding 1 to the power-off triggering times.
2. The method of claim 1, further comprising:
and acquiring the power-off triggering times, and controlling the working state of the intelligent equipment according to the power-off triggering times.
3. The method of claim 1, wherein setting the power-off flag and the switch state change flag according to the level of the switch power-off detection signal comprises:
if the switch power-off detection signal is at a low level, judging whether the duration time of the low level is longer than a first preset time, and if so, setting the power-off flag to be a second preset value;
if the switch power-off detection signal is at a high level, judging whether the power-off mark is a second preset value;
if the power-off mark is a second preset value, setting the power-off mark to be a first preset value, setting the switch state change mark to be a fourth preset value, and adding 1 to the power-off triggering times;
if the power-off mark is the first preset value, whether the switch state change mark is the fourth preset value or not is judged, if the switch state change mark is the fourth preset value, the switch state change mark is set to be the third preset value, and the power-off triggering frequency is increased by 1.
4. The method of claim 3, wherein the first predetermined duration is greater than or equal to 2 cycles of the square wave signal.
5. The method of claim 3, wherein after setting the switch state change flag to a fourth preset value, the method further comprises:
recording the duration of the change of the switch state;
and if the on-off state change duration is longer than a second preset duration, clearing the previous power-off triggering times and the on-off state change duration.
6. The method of claim 1, wherein the smart device comprises a lighting device.
7. A smart device control system, the system comprising: the system comprises an alternating current power supply, a switch, a driving power supply, a switch power-off detection circuit and an Internet of things module; wherein:
the alternating current power supply is used for supplying electric energy to the intelligent equipment control system;
one end of the driving power supply is connected with the alternating current power supply through the switch, and the other end of the driving power supply is connected with the internet of things module and used for converting the alternating current power supply into preset voltage to drive the intelligent equipment and the physical network module;
one end of the switch power-off detection circuit is connected with the driving power supply, and the other end of the switch power-off detection circuit is connected with an IO port of the Internet of things module, and is used for detecting the power-off triggering operation of the switch and outputting a switch power-off detection signal to the Internet of things module;
the physical network module is respectively connected with the switch power-off detection circuit and the intelligent device, and is used for receiving the switch power-off detection signal and setting a power-off mark and a switch state change mark according to the current level of the switch power-off detection signal; the power-off mark is used for indicating whether a user triggers power-off action, and the switch state change mark is used for indicating the increase of the power-off triggering times; when the intelligent equipment is powered on, setting the power-off mark as a first preset value and setting the switch state change mark as a fourth preset value, and adding 1 to the power-off triggering times; and controlling the working state of the intelligent equipment according to the power-off triggering times.
8. A switch outage detection apparatus, characterized in that the apparatus comprises:
the receiving module is used for receiving a switch power-off detection signal, wherein the switch power-off detection signal is a square wave signal obtained by rectifying and depressurizing alternating current;
the acquisition module is used for acquiring the level of the switch power-off detection signal;
the first setting module is used for setting a power-off mark and a switch state change mark according to the level of the switch power-off detection signal; wherein the power-off flag is used for indicating whether a user triggers power-off action, and the switch state change flag is used for indicating the increase of the power-off triggering times;
and the second setting module is used for setting the power-off mark to be a first preset value and setting the switch state change mark to be a fourth preset value when the intelligent equipment is powered on, and adding 1 to the power-off triggering times.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
CN202011183283.XA 2020-10-29 2020-10-29 Switch power-off detection method and device, computer equipment and readable storage medium Active CN112285550B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011183283.XA CN112285550B (en) 2020-10-29 2020-10-29 Switch power-off detection method and device, computer equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011183283.XA CN112285550B (en) 2020-10-29 2020-10-29 Switch power-off detection method and device, computer equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN112285550A true CN112285550A (en) 2021-01-29
CN112285550B CN112285550B (en) 2022-10-04

Family

ID=74352596

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011183283.XA Active CN112285550B (en) 2020-10-29 2020-10-29 Switch power-off detection method and device, computer equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN112285550B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04284323A (en) * 1991-03-13 1992-10-08 Fuji Electric Co Ltd Operating times counter for electric leakage breaker
CN107976626A (en) * 2017-11-16 2018-05-01 湖南工业大学 Relay life detection device
CN110261767A (en) * 2019-07-05 2019-09-20 瑞纳智能设备股份有限公司 A kind of detection device and detection method in on-off switch service life
CN111629504A (en) * 2017-04-01 2020-09-04 广东易百珑智能科技有限公司 Lighting system without control line and application method thereof
CN111679180A (en) * 2020-06-11 2020-09-18 迈拓仪表股份有限公司 Method and device for detecting on-off of magnetic control waterproof button

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04284323A (en) * 1991-03-13 1992-10-08 Fuji Electric Co Ltd Operating times counter for electric leakage breaker
CN111629504A (en) * 2017-04-01 2020-09-04 广东易百珑智能科技有限公司 Lighting system without control line and application method thereof
CN107976626A (en) * 2017-11-16 2018-05-01 湖南工业大学 Relay life detection device
CN110261767A (en) * 2019-07-05 2019-09-20 瑞纳智能设备股份有限公司 A kind of detection device and detection method in on-off switch service life
CN111679180A (en) * 2020-06-11 2020-09-18 迈拓仪表股份有限公司 Method and device for detecting on-off of magnetic control waterproof button

Also Published As

Publication number Publication date
CN112285550B (en) 2022-10-04

Similar Documents

Publication Publication Date Title
EP2993579A1 (en) System and method for automatically configuring bios performance profiles
US8065004B2 (en) Method and apparatus for automatic self-test of medical device
EP2172915A1 (en) Alarm
CN107193555A (en) The method for restarting and device of electric equipment
WO2020059449A1 (en) Person detection system and program
CN108415306B (en) Control method and device of cooking equipment
CN103884079A (en) Work mode switching method of air conditioner and air conditioner
CN109067416A (en) A kind of method and Intelligent hardware for realizing SIM card hot plug and starting
CN112285550B (en) Switch power-off detection method and device, computer equipment and readable storage medium
CN106247527B (en) The method and device of night control is carried out to air-conditioning using night control model
CN108490289B (en) Electronic equipment testing method and device and electronic equipment
CN107013446B (en) Control method of variable frequency compressor, variable frequency control panel and refrigeration equipment
CN107355948B (en) Control method and device of photovoltaic air conditioner
CN111025956B (en) Key recognition circuit of food processor
CN105740662A (en) Information processing method and electronic device
CN214335506U (en) MCU mode control circuit and MCU
CN112033045B (en) Control method and device of heating equipment and controller
CN205427521U (en) Fragrant quick -witted control circuit
CN104197628A (en) Delay detection device and method and refrigerator
CN111005892B (en) Adaptive fan circuit, system, electronic equipment and fan detection method
CN1312581C (en) External starter for pc system
CN104421973B (en) Gas utensil and the pulse ignition device for gas utensil and pulse firing control method
TWI700964B (en) Sensor system, lighting control system, program
CN114816230A (en) Flash data storage method and device and household appliance
CN113377024B (en) Equipment linkage control method and device, computer equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant