Power failure detection method, device and equipment of commercial power and storage medium

By obtaining the voltage sampling value of the mains power supply and calculating the phase difference, and performing point-by-point detection, the problem of slow power outage detection speed of the mains power supply is solved, and the fast and accurate detection effect is achieved, improving the safety and user experience of the equipment.

CN119064666APending Publication Date: 2024-12-03SHENZHEN SKYWORTH INT TRADE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411170376.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

The existing mains power outage detection methods and equipment are slow to respond, resulting in a long detection time, reducing the equipment's user experience and bringing safety hazards.

Method used

By obtaining the voltage sampling value of the mains power, determining the target phase difference, and performing point-by-point power-down detection when the phase difference meets the preset conditions, achieving fast and accurate power-down detection. The method includes initializing the configuration on the microprocessor, obtaining the voltage sample value of the mains power, calculating the phase difference, and performing point-by-point comparisons when the phase difference is zero to judge the power-down state.

Benefits of technology

Real-time rapid detection of power outage of mains power is realized, reducing detection costs, improving detection response time and accuracy, and enhancing application value and popularization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119064666A_ABST
    Figure CN119064666A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to a power failure detection method and device for commercial power, equipment and a storage medium. The method comprises the following steps: acquiring a voltage sampling value corresponding to the commercial power; determining a target phase difference according to the voltage sampling value; and when the target phase difference satisfies a preset condition, carrying out power failure detection. Through commercial power voltage sampling, when a microprocessor detects an effective voltage value, the phase difference between the commercial power and a set internal reference signal is calculated, point-by-point detection of the voltage value of voltage sampling is started by judging the phase difference, when it is detected that the voltage requirement is met, it is determined that the commercial power is powered off, and real-time rapid detection of the commercial power is achieved through point-by-point detection. Therefore, the detection cost is reduced by selecting a simple circuit structure, the purposes of short response time and high accuracy of mains supply power failure detection are achieved, and the technical effects of improving the practical application value and generalizability can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the technical field of power failure detection of equipment, and more particularly to a method, device, equipment and storage medium for detecting power failure of a mains power supply. Background Art

[0002] In many cases, the electronic devices we commonly use need to detect AC power failure, such as inverters, UPS, portable energy storage power supplies, industrial and commercial energy storage devices, etc., and the AC power failure detection response speed is required to be high.

[0003] However, the current testing equipment is relatively complex and the response time is long, which brings greater resistance to the testing process, reduces the user experience of the equipment, and poses a safety hazard to the safety of the equipment. Summary of the invention

[0004] In view of this, in order to solve the above-mentioned technical problems of slow detection of AC power failure and long response time, the embodiments of the present application provide a method, device, equipment and storage medium for detecting AC power failure.

[0005] In a first aspect, an embodiment of the present application provides a method for detecting a power failure of a mains power supply, comprising:

[0006] Get the voltage sampling value corresponding to the mains power;

[0007] Determine a target phase difference according to the voltage sampling value;

[0008] When the target phase difference meets a preset condition, a power failure detection is performed point by point on the voltage sampling value to obtain a corresponding power failure detection result.

[0009] In a possible implementation, before performing the step of obtaining the voltage sampling value corresponding to the mains power supply, the method includes:

[0010] Initialization processing is performed after the microprocessor is powered on;

[0011] Configure and process the universal interface, AC and DC sampling equipment, internal reference signal and phase-locked loop respectively;

[0012] A threshold voltage array corresponding to the microprocessor is configured, and the threshold voltage array is used to store reference voltage value data for determining whether a power failure occurs in the mains power.

[0013] In a possible implementation manner, obtaining a voltage sampling value corresponding to the mains power includes:

[0014] After connecting to the mains, sampling the voltage of the branch where the neutral line of the mains is located by using an AC voltage sampling device to obtain a corresponding first voltage sampling value;

[0015] The AC voltage sampling device is used to sample the voltage of the branch where the live wire of the mains is located to obtain a corresponding second voltage sampling value.

[0016] In a possible implementation manner, determining the target phase difference according to the voltage sampling value includes:

[0017] Obtaining a target effective electrical signal of the microprocessor according to the first voltage sampling value and the second voltage sampling value;

[0018] When the target effective electrical signal corresponding to the microprocessor reaches a set reference value, the difference between the configured internal reference signal and the mains is used as a target phase difference, and the target phase difference represents the magnitude relationship between the mains and the internal reference signal.

[0019] In a possible implementation, when the target phase difference satisfies a preset condition, performing power failure detection on the voltage sampling value point by point to obtain a corresponding power failure detection result includes:

[0020] Determining whether the target phase difference is zero;

[0021] When the target phase difference is zero, it is determined that the target phase difference meets the set condition, and the target effective values ​​corresponding to the first voltage sampling value and the second voltage sampling value are compared point by point with the corresponding reference voltage values ​​on the waveform curve included in the threshold voltage array to obtain a comparison result;

[0022] When there is a target effective value in the waveform curve corresponding to the set time interval that is smaller than the corresponding reference voltage value in the threshold voltage array, the comparison result obtained is a first comparison result;

[0023] When there is a target effective value in the waveform curve corresponding to the set time interval that is greater than the corresponding reference voltage value in the threshold voltage array, the comparison result obtained is a second comparison result;

[0024] A corresponding power-off detection result is obtained according to the first comparison result and the second comparison result.

[0025] In a possible implementation manner, obtaining a corresponding power-off detection result according to the first comparison result and the second comparison result includes:

[0026] According to the second comparison result, the power failure detection result is obtained as the mains power is safe;

[0027] Counting a target number of the first comparison results, and detecting whether the target number exceeds a set power-off number threshold;

[0028] When the target number exceeds the power-off number threshold, the power-off flag is set to 1, and the corresponding power-off detection result is that the mains power is off;

[0029] When the target number does not exceed the power-off number threshold, the power-off flag is set to 0, and the corresponding power-off detection result is that the mains power is safe.

[0030] In a possible implementation, the method further includes:

[0031] Obtaining a sinusoidal wave curve within a set time interval according to the first voltage sampling value and the second voltage sampling value;

[0032] Determine the number of target points within the time interval according to the sine wave curve;

[0033] Counting the number of power failures whose comparison results included in the target number of points are the first comparison results;

[0034] Obtaining the power failure detection accuracy rate according to the percentage of the power failure number to the target number of points;

[0035] The mains power failure rate is verified according to the power failure detection accuracy rate.

[0036] In a second aspect, an embodiment of the present application provides a mains power failure detection device, which is applied to the mains power failure detection method as described in any one of the first aspects, including:

[0037] An acquisition module is used to obtain a voltage sampling value corresponding to the mains power supply;

[0038] A determination module, used to determine a target phase difference according to the voltage sampling value;

[0039] The detection module is used to perform point-by-point power-off detection on the voltage sampling value when the target phase difference meets the preset condition to obtain the corresponding power-off detection result.

[0040] In a third aspect, an embodiment of the present application provides a detection device, comprising: a processor and a memory, wherein the processor is used to execute a mains power failure detection program stored in the memory to implement the mains power failure detection method described in any one of the first aspects.

[0041] In a fourth aspect, an embodiment of the present application provides a storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the mains power failure detection method described in any one of the first aspects.

[0042] The mains power failure detection scheme provided in the embodiment of the present application is achieved by obtaining the voltage sampling value corresponding to the mains power; determining the target phase difference according to the voltage sampling value; and performing point-by-point power failure detection on the voltage sampling value when the target phase difference meets the preset conditions to obtain the corresponding power failure detection result. By sampling the mains voltage, when the microprocessor detects the effective voltage value, the phase difference between the mains power and the set internal reference signal is calculated, and the power failure detection is started by judging the phase difference. By detecting the voltage value of the voltage sampling point by point, when it is detected that the voltage requirement is met, the mains power failure is determined, and the real-time and rapid detection of the mains power failure is achieved through point-by-point detection. According to this scheme, a simple circuit structure is selected to reduce the detection cost, so as to achieve the purpose of fast response time and high accuracy of the mains power failure detection, and the technical effect of improving the practical application value and scalability can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0045] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0046] Figure 1 A schematic diagram of a flow chart of a method for detecting a mains power failure provided in an embodiment of the present application;

[0047] Figure 2 A flowchart of another method for detecting mains power failure provided in an embodiment of the present application;

[0048] Figure 3 A schematic diagram of the structure of a mains power failure detection circuit provided in an embodiment of the present application;

[0049] Figure 4 A schematic diagram of the structure of another mains power failure detection circuit provided in an embodiment of the present application;

[0050] Figure 5 A flowchart of another method for detecting a mains power failure provided in an embodiment of the present application;

[0051] Figure 6A schematic diagram of the structure of a mains power failure detection device provided in an embodiment of the present application;

[0052] Figure 7 A schematic diagram of the structure of a detection device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0054] The terms "including" and "having" in the embodiments of the present application are used to express an open-ended inclusive meaning, and mean that in addition to the listed elements / components / etc., there may be additional elements / components / etc.; the terms "first" and "second" etc. are used only as labels and are not intended to limit the quantity of their objects. In addition, the different elements and regions in the drawings are only schematically shown, so the present application is not limited to the sizes or distances shown in the drawings.

[0055] To facilitate understanding of the embodiments of the present application, further explanation will be given below with reference to specific embodiments in conjunction with the accompanying drawings. The embodiments do not constitute a limitation on the embodiments of the present application.

[0056] Figure 1 A schematic diagram of a method for detecting a mains power failure provided in an embodiment of the present application. Applicable to the mains power failure detection process. Figure 1 According to the diagram provided, the steps of the mains power failure detection method specifically include:

[0057] S101, obtaining a voltage sampling value corresponding to the mains power.

[0058] The present application is applied to the process of rapid power failure detection of the mains. The system is initialized by the microprocessor in the power failure detection circuit system, the initial data is configured, and the threshold voltage array is configured at the same time. The reference voltage value data corresponding to each point of the waveform curve corresponding to the system voltage operation is stored in the configured threshold voltage array. By collecting the voltage value, the difference between the mains and the internal reference voltage is determined. When the difference is zero, the power failure detection is turned on. By comparing each point on the voltage output sine wave curve with the data stored in the threshold voltage array, it is determined whether the current sampled voltage is less than the set value. When the number of voltages less than the set value exceeds the set threshold, it indicates that the power failure phenomenon has been detected, thereby quickly and accurately realizing the mains power failure detection.

[0059] Furthermore, the system is initialized by the microprocessor in the power-off detection circuit system, the initial data is configured, and the voltage sampling values ​​in the system are collected by the AC voltage sampling unit on the system to obtain the voltage sampling values ​​ADC1 and ADC2, providing a basis for judging whether to start the power-off detection in the next step.

[0060] S102: Determine a target phase difference according to the voltage sampling value.

[0061] Furthermore, after obtaining the voltage sampling value, when the AC power is connected and when the microprocessor MCU detects a valid voltage signal, the microprocessor MCU calculates the difference between the AC power and the internal reference signal set during pre-initialization, and uses the difference as the target phase difference between the two. The size of the target phase difference is used to determine whether the internal signal source in the current detection circuit and the AC power sinusoidal signal are of the same frequency and phase, that is, they are phase-locked to the AC power voltage; when the internal signal source and the AC power sinusoidal signal are equal, it indicates that the detection circuit is of the same frequency and phase; when the internal signal source and the AC power sinusoidal signal are not equal, it indicates that the detection circuit is not of the same frequency and phase, which provides a basis for judgment for the next step of power-off detection.

[0062] S103: When the target phase difference meets a preset condition, perform power failure detection on the voltage sampling value point by point to obtain a corresponding power failure detection result.

[0063] Furthermore, when the target phase difference meets the conditions, the power-off detection strategy is started; when the target phase difference cannot meet the set conditions, the difference between the AC power supply and the internal reference voltage is obtained again, and the next judgment is made until the target phase difference meets the conditions, and the power-off detection is started. The target phase difference is used as the basis for judging whether the AC power-off detection is started, so that the power-off phenomenon can be judged more precisely and the detection accuracy can be improved. The collected sampled voltage value is compared with the reference voltage value data stored in the threshold voltage array by using the point-by-point comparison detection method. If the sampled voltage value is less than the reference voltage value data in the threshold voltage array, it means that the AC power supply in the current detection circuit is in a low voltage state and can no longer maintain the power supply state, and then the AC power supply phenomenon is detected to obtain the corresponding detection result; when the sampled voltage value is greater than the reference voltage value data in the threshold voltage array, it means that the AC power supply in the current detection circuit is higher than the minimum voltage value of the circuit operation, and it is detected that the AC power supply of the point-to-point detection circuit maintains a stable power supply state, and then through the point-by-point comparison method, it is more accurately detected whether the AC power supply phenomenon occurs.

[0064] The mains power failure detection method provided in the embodiment of the present application is achieved by obtaining the voltage sampling value corresponding to the mains power; determining the target phase difference according to the voltage sampling value; and performing point-by-point power failure detection on the voltage sampling value when the target phase difference meets the preset conditions to obtain the corresponding power failure detection result. By sampling the mains voltage, when the microprocessor detects the effective voltage value, the phase difference between the mains power and the set internal reference signal is calculated, and the power failure detection is started by judging the phase difference. By detecting the voltage value of the voltage sampling point by point, when it is detected that the voltage requirement is met, the mains power failure is determined, and the real-time and rapid detection of the mains power failure is achieved through point-by-point detection. According to this solution, a simple circuit structure is selected to reduce the detection cost, so as to achieve the purpose of fast response time and high accuracy of the mains power failure detection, and the technical effect of improving the practical application value and scalability can be achieved.

[0065] Figure 2 A flowchart of another method for detecting mains power failure provided in an embodiment of the present application. Figure 2 This is introduced based on the previous embodiment. Figure 2 According to the diagram provided, the steps of the mains power failure detection method specifically include:

[0066] S201, performing initialization processing after the microprocessor is powered on.

[0067] S202, respectively configure the universal interface, AC / DC sampling equipment, internal reference signal and phase-locked loop.

[0068] The present application is applied to the process of rapid power failure detection of the mains. The system is initialized by the microprocessor in the power failure detection circuit system, the initial data is configured, and the threshold voltage array is configured at the same time. The reference voltage value data corresponding to each point of the waveform curve corresponding to the system voltage operation is stored in the configured threshold voltage array. By collecting the voltage value, the difference between the mains and the internal reference voltage is determined. When the difference is zero, the power failure detection is turned on. By comparing each point on the voltage output sine wave curve with the reference voltage value data stored in the threshold voltage array, it is determined whether the current sampled voltage is less than the set value. When the number of voltages less than the set value exceeds the set threshold, it indicates that the power failure phenomenon has been detected, thereby quickly and accurately realizing the mains power failure detection.

[0069] Furthermore, the system is initialized by the microprocessor in the power-off detection circuit system to configure initial data, including GPIO port status configuration, ADC sampling configuration, internal reference signal configuration, phase-locked loop configuration, etc.

[0070] S203, configuring a threshold voltage array corresponding to the microprocessor, where the threshold voltage array is used to store reference voltage value data for determining whether a mains power outage occurs.

[0071] S204: After connecting to the mains, sampling the voltage of the branch where the neutral line of the mains is located is performed by an AC voltage sampling device to obtain a corresponding first voltage sampling value.

[0072] S205 , using an AC voltage sampling device to sample the voltage of the branch where the live wire of the mains is located, to obtain a corresponding second voltage sampling value.

[0073] The threshold voltage array mentioned here stores reference voltage value data corresponding to each point of the waveform curve corresponding to the system voltage operation.

[0074] Furthermore, after the microprocessor MCU initializes the setting data, the threshold voltage array is configured, and the voltage sampling value in the system is collected by the AC voltage sampling unit on the system to obtain the first voltage sampling value ADC1 and the second voltage sampling value ADC2, which provide a basis for judging whether to start the power-off detection in the next step.

[0075] S206: Obtain a target effective electrical signal of a microprocessor according to the first voltage sampling value and the second voltage sampling value.

[0076] S207, when the target effective electrical signal corresponding to the microprocessor reaches the set reference value, the difference between the configured internal reference signal and the mains is used as the target phase difference, and the target phase difference represents the magnitude relationship between the mains and the internal reference signal.

[0077] S208: Determine whether the target phase difference is zero.

[0078] S209, when the target phase difference is zero, determine that the target phase difference meets the set condition, compare the corresponding target effective values ​​in the first voltage sampling value and the second voltage sampling value with the corresponding reference voltage values ​​on the waveform curve contained in the threshold voltage array point by point, and obtain a comparison result.

[0079] Furthermore, the collected voltage values ​​on the neutral line and the live line are compared to obtain an effective voltage value. When the microprocessor MCU detects that the effective voltage value reaches the set reference voltage, the size of the mains power is obtained, and the mains power is compared with the pre-stored internal reference signal. The difference obtained is used as the target phase difference. The target phase difference is judged to determine whether the AC power-off detection circuit of the mains power is turned on. When the target phase difference is zero, it indicates that the internal signal source and the mains power sinusoidal signal are in the same frequency and phase, that is, the phase-locked mains voltage. It is then used as a basis for turning on the AC power-off detection; when the target phase difference is not zero, it indicates that the internal signal source and the mains power sinusoidal signal are not in the same frequency and phase, and the voltage is continued to be sampled and analyzed. After turning on the AC power-off detection, the microprocessor MCU is used to compare each point in the voltage motion sinusoidal curve where the effective value in the first voltage sampling value ADC1 and the second voltage sampling value ADC2 is located with the corresponding value in the set threshold voltage array.

[0080] S210 , when a target effective value in the waveform curve corresponding to the set time interval is smaller than a corresponding reference voltage value in the threshold voltage array, the comparison result obtained is a first comparison result.

[0081] S211 . When a target effective value in a corresponding set time interval in the waveform curve is greater than a corresponding reference voltage value in the threshold voltage array, the comparison result is a second comparison result.

[0082] S212: Obtain a corresponding power-off detection result according to the first comparison result and the second comparison result.

[0083] Furthermore, after the AC power-off detection is turned on, when there is a target effective value in the corresponding period in the waveform curve that is less than the corresponding reference voltage value in the threshold voltage array, it indicates that the AC power in the current detection circuit is lower than the minimum operating voltage value of the circuit, and the comparison result is the first comparison result; when there is a target effective value in the corresponding period in the waveform curve that is greater than the corresponding reference voltage value in the threshold voltage array, it indicates that the AC power in the current detection circuit is higher than the minimum voltage of the circuit, and the comparison result is the second comparison result.

[0084] S213: According to the second comparison result, the power failure detection result is obtained as follows: the mains power is safe.

[0085] S214: Count the target number of the first comparison result, and detect whether the target number exceeds a set power-off number threshold.

[0086] S215. When the target number exceeds the power-off number threshold, the power-off flag is set to 1, and the corresponding power-off detection result is that the mains power is off.

[0087] S216: When the target number does not exceed the power-off number threshold, the power-off flag is set to 0, and the corresponding power-off detection result is that the mains power is safe.

[0088] Furthermore, when there is a target effective value in the corresponding period of the waveform curve that is less than the corresponding reference voltage value in the threshold voltage array, it indicates that the AC power in the current detection circuit is lower than the minimum operating voltage value of the circuit, and a first result is obtained. Then, the number of detection points containing the first result in a sine wave cycle is counted, and the total number of first results is calculated. When the number of first results exceeds the set value, it indicates that the current sine wave curves are all lower than the specified reference value, and then it is determined that the AC mains power has been cut off, and the power-off flag is set to 1; when the target number does not exceed the power-off number threshold, the power-off flag is set to 0, and the corresponding power-off detection result is that the mains power is safe. When the corresponding target effective value in the waveform curve is greater than the reference voltage value, it indicates that the current sine wave curve is higher than the specified reference value, and the corresponding power-off detection result is that the mains power is safe, thereby quickly and accurately realizing the rated power-off detection of the AC mains.

[0089] Optionally, the method for detecting a mains power failure further comprises the following steps:

[0090] Step 1: Obtain a sinusoidal wave curve within a set time interval according to the first voltage sampling value and the second voltage sampling value.

[0091] Step 2: Determine the target number of points within the time interval based on the sine wave curve.

[0092] Step 3: Count the number of power failures whose comparison results included in the target points are the first comparison results.

[0093] Step 4: According to the percentage of power failure number to target number of points, the power failure detection accuracy is obtained.

[0094] Step 5: Verify the AC power failure rate based on the power failure detection accuracy.

[0095] Furthermore, after detecting the AC power failure, the number of points that meet the power failure condition is detected in the voltage sine wave of the AC power supply in the circuit is counted, and then the percentage is counted. For example, within a sine wave cycle of the AC power supply voltage of 20ms, 50 values ​​are set, and then 400 points are obtained by calculation. When 380 points are detected to meet the power failure condition, the corresponding detection accuracy rate = 380 / 400 = 95% is obtained, and then the accuracy rate is 95% to determine that the current detection circuit is in the AC power failure phenomenon.

[0096] In one possible example scenario, Figure 3 A schematic diagram of the structure of a mains power failure detection circuit provided in an embodiment of the present application. Figure 4 A schematic diagram of another mains power failure detection circuit provided in an embodiment of the present application. Figure 3 The diagram provided shows that the detection circuit includes a microprocessor (MCU), an AC voltage sampling unit 40, a power supply 10, a voltage regulator 20, and a voltage network unit 30. The real-time detection of AC mains power failure is realized by a software algorithm, and is composed of a microprocessor (MCU), an AC voltage sampling unit, and an auxiliary power supply circuit. Figure 4 The diagram provided shows that the AC input voltage of the mains is connected to the ADC sampling interface of the microprocessor MCU after passing through the resistor voltage divider network (i.e., the voltage network unit 30), and then the first voltage sampling value ADC1 and the second voltage sampling value ADC2 are obtained in real time. When the microprocessor MCU detects a valid voltage signal, the MCU calculates the phase difference ph between the mains and the internal reference signal. When ph is equal to 0, the internal signal source and the mains sine wave signal achieve the same frequency and phase, i.e., the phase-locked mains voltage. The AC power-off detection function is then turned on, and then the microprocessor MCU compares the first voltage sampling value ADC1 on the neutral line and the second voltage sampling value ADC2 on the live line point by point with the reference voltage value stored in the threshold voltage array. If the preset comparison voltage point value is reached, it is determined that the AC mains has a power-off phenomenon. Real-time and rapid detection of AC power-off is achieved through a software algorithm. The method has a simple circuit and low cost, and can meet the requirements of fast response time and high accuracy of AC power-off detection. The invention has great practical application value and extensibility.

[0097] In one possible example scenario, Figure 5 A flowchart of another method for detecting a power failure of a mains power supply provided in an embodiment of the present application is shown below. Figure 5 The diagram provided shows that the microprocessor MCU is initialized after power-on. The initialization content includes GPIO port status configuration, ADC sampling configuration, internal reference signal configuration and phase-locked loop configuration, etc., and the threshold voltage array is initialized at the same time. When the mains is connected, when the microprocessor MCU detects a valid voltage signal, the microprocessor MCU calculates the phase difference ph between the mains and the internal reference signal. When ph is equal to 0, the internal signal source and the mains sine wave signal are in the same frequency and phase, that is, the phase-locked mains voltage. Then the microprocessor MCU compares the first voltage sampling value ADC1 on the neutral line and the second voltage sampling value ADC2 on the live line point by point with the corresponding reference voltage value in the set threshold voltage array. The ADC1 / ADC2 sampling voltage value is less than the set voltage value. When the preset comparison voltage point value is reached, the AC power-off detection flag is set to 1, and the AC power-off is judged; otherwise, the flag is set to 0, and it is determined that the mains power has not been powered off, thereby achieving the purpose of fast reading power-off detection. The voltage point value can be flexibly set according to actual needs.

[0098] The mains power failure detection method provided in the embodiment of the present application is configured by configuring a threshold voltage array corresponding to the microprocessor, and obtaining a voltage sampling value corresponding to the mains power; determining a target phase difference according to the voltage sampling value; and performing point-by-point power failure detection on the voltage sampling value when the target phase difference meets a preset condition to obtain a corresponding power failure detection result. Through mains power voltage sampling, when the microprocessor detects a valid voltage value, the phase difference between the mains power and the set internal reference signal is calculated, and the power failure detection is started by judging the phase difference. By detecting the voltage value of the voltage sampling point by point, when it is detected that the voltage requirement is met, the mains power failure is determined, and real-time and rapid detection of the mains power failure is achieved through point-by-point detection; this solution uses a simple circuit structure to reduce the detection cost, and achieves the purpose of fast response time and high accuracy of mains power failure detection, which can achieve the technical effect of improving practical application value and scalability.

[0099] Figure 6 The present invention provides a schematic diagram of the structure of a mains power failure detection device provided in an embodiment of the present invention. It is applied to the mains power failure detection method provided in the above embodiment. Figure 6 According to the diagram provided, the structure of the mains power failure detection device includes:

[0100] The acquisition module 61 is used to acquire the voltage sampling value corresponding to the mains power.

[0101] The determination module 62 is used to determine the target phase difference according to the voltage sampling value.

[0102] The detection module 63 is used to perform power failure detection on the voltage sampling value point by point when the target phase difference meets the preset condition to obtain the corresponding power failure detection result.

[0103] The mains power failure detection device provided in this embodiment can be as follows: Figure 6 The mains power failure detection device shown in FIG. 1 can be implemented as follows: Figure 1-5 All steps of the power failure detection method of the city power supply are implemented Figure 1-5 The technical effect of the mains power failure detection method shown in the figure is shown in the figure. Figure 1-5 For the sake of brevity, the relevant description is not repeated here.

[0104] Figure 7 A schematic diagram of the structure of a detection device provided in an embodiment of the present application, Figure 7 The detection device 700 shown includes: at least one processor 701, a memory 702, at least one network interface 704 and other user interfaces 703. The various components in the detection device 700 are coupled together via a bus system 705. It is understood that the bus system 705 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 705 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 705 is not shown in FIG. Figure 7 Various buses are labeled as bus system 705.

[0105] The user interface 703 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touch pad, or a touch screen).

[0106] It can be understood that the memory 702 in the embodiment of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct RAM bus random access memory (DRRAM). The memory 702 described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0107] In some implementations, the memory 702 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 7021 and an application 7022 .

[0108] The operating system 7021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application 7022 includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present application can be included in the application 7022.

[0109] In the embodiment of the present application, by calling the program or instruction stored in the memory 702, specifically, the program or instruction stored in the application 7022, the processor 701 is used to execute the method steps provided by each method embodiment, for example, including:

[0110] Obtain a voltage sampling value corresponding to the mains power supply; determine a target phase difference according to the voltage sampling value; when the target phase difference meets a preset condition, perform a point-by-point power failure detection on the voltage sampling value to obtain a corresponding power failure detection result.

[0111] The method disclosed in the above embodiment of the present application can be applied to the processor 701, or implemented by the processor 701. The processor 701 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 701 or the instruction in the form of software. The above processor 701 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software units in the decoding processor can be executed. The software unit can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 702, and the processor 701 reads the information in the memory 702 and completes the steps of the above method in combination with its hardware.

[0112] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPDevice, DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application, or a combination thereof.

[0113] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.

[0114] The mains power failure detection device provided in this embodiment can be as follows: Figure 7 The detection device shown in FIG. 1 can perform the following steps: Figure 1-5 All steps of the power failure detection method of the city power supply are implemented Figure 1-5 The technical effect of the mains power failure detection method shown in the figure is shown in the figure. Figure 1-5 For the sake of brevity, the relevant description is not repeated here.

[0115] The embodiment of the present application also provides a storage medium (computer-readable storage medium). The storage medium here stores one or more programs. The storage medium may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid-state drive; the memory may also include a combination of the above-mentioned types of memory.

[0116] When one or more programs in the storage medium can be executed by one or more processors, the mains power failure detection method executed on the mains power failure detection device side is implemented.

[0117] The processor is used to execute the mains power failure detection program stored in the memory to implement the following steps of the mains power failure detection method executed on the mains power failure detection device side:

[0118] Obtain a voltage sampling value corresponding to the mains power supply; determine a target phase difference according to the voltage sampling value; when the target phase difference meets a preset condition, perform a point-by-point power failure detection on the voltage sampling value to obtain a corresponding power failure detection result.

[0119] The professionals should also be further aware that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0120] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0121] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above description is only the specific implementation method of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.

Claims

1. A method for detecting a power failure of a mains power supply, characterized in that: include: Get the voltage sampling value corresponding to the mains power; Determine a target phase difference according to the voltage sampling value; When the target phase difference meets a preset condition, a power failure detection is performed point by point on the voltage sampling value to obtain a corresponding power failure detection result.

2. The method according to claim 1, characterized in that Before executing the step of obtaining the voltage sampling value corresponding to the mains power, the method includes: Initialization processing is performed after the microprocessor is powered on; Configure and process the universal interface, AC and DC sampling equipment, internal reference signal and phase-locked loop respectively; A threshold voltage array corresponding to the microprocessor is configured, and the threshold voltage array is used to store reference voltage value data for determining whether a power failure occurs in the mains power.

3. The method according to claim 1, characterized in that The obtaining of a voltage sampling value corresponding to the mains power includes: After connecting to the mains, sampling the voltage of the branch where the neutral line of the mains is located by using an AC voltage sampling device to obtain a corresponding first voltage sampling value; The AC voltage sampling device is used to sample the voltage of the branch where the live wire of the mains is located to obtain a corresponding second voltage sampling value.

4. The method according to claim 2 or 3, characterized in that: The step of determining the target phase difference according to the voltage sampling value comprises: Obtaining a target effective electrical signal of a microprocessor according to the first voltage sampling value and the second voltage sampling value; When the target effective electrical signal corresponding to the microprocessor reaches the set reference value, the difference between the configured internal reference signal and the mains is used as the target phase difference, and the target phase difference represents the magnitude relationship between the mains and the internal reference signal.

5. The method according to claim 4, characterized in that When the target phase difference meets the preset condition, performing power failure detection on the voltage sampling value point by point to obtain a corresponding power failure detection result, including: Determining whether the target phase difference is zero; When the target phase difference is zero, it is determined that the target phase difference meets the set condition, and the target effective values ​​corresponding to the first voltage sampling value and the second voltage sampling value are compared point by point with the reference voltage value corresponding to the waveform curve included in the threshold voltage array to obtain a comparison result; When there is a target effective value in the waveform curve corresponding to the set time interval that is smaller than the corresponding reference voltage value in the threshold voltage array, the comparison result obtained is a first comparison result; When there is a target effective value in the waveform curve corresponding to the set time interval that is greater than the corresponding reference voltage value in the threshold voltage array, the comparison result obtained is a second comparison result; A corresponding power-off detection result is obtained according to the first comparison result and the second comparison result.

6. The method according to claim 5, characterized in that The obtaining a corresponding power-off detection result according to the first comparison result and the second comparison result includes: According to the second comparison result, the power failure detection result is obtained as the mains power is safe; Counting a target number of the first comparison results, and detecting whether the target number exceeds a set power-off number threshold; When the target number exceeds the power-off number threshold, the power-off flag is set to 1, and the corresponding power-off detection result is that the mains power is off; When the target number does not exceed the power-off number threshold, the power-off flag is set to 0, and the corresponding power-off detection result is that the mains power is safe.

7. The method according to claim 6, characterized in that The method further comprises: Obtaining a sinusoidal wave curve within a set time interval according to the first voltage sampling value and the second voltage sampling value; Determine the number of target points within the time interval according to the sine wave curve; Counting the number of power failures whose comparison results included in the target number of points are the first comparison results; Obtaining the power failure detection accuracy rate according to the percentage of the power failure number to the target number of points; The mains power failure rate is verified according to the power failure detection accuracy rate.

8. A mains power failure detection device, applied to the mains power failure detection method as claimed in any one of claims 1 to 7, characterized in that: include: An acquisition module is used to obtain a voltage sampling value corresponding to the mains power supply; A determination module, used to determine a target phase difference according to the voltage sampling value; The detection module is used to perform point-by-point power-off detection on the voltage sampling value when the target phase difference meets the preset condition to obtain the corresponding power-off detection result.

9. A detection device, characterized in that: include: A processor and a memory, wherein the processor is used to execute a mains power failure detection program stored in the memory to implement the mains power failure detection method according to any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the mains power failure detection method according to any one of claims 1 to 7.