Commercial power failure detection method and system for uninterruptible power supply
By combining the four-neighbor product method and adaptive morphological filter, the problem of insufficient real-time performance in single-phase mains power failure detection is solved, achieving fast and accurate voltage amplitude estimation, meeting the fast switching requirements of UPS, and simplifying the detection process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-21
- Publication Date
- 2026-04-10
AI Technical Summary
Existing single-phase mains power failure detection methods require a delay to construct three-phase voltage, resulting in insufficient real-time detection and failing to meet the requirements of UPS fast switching.
A detection method based on four-neighbor product and adaptive morphological filtering is adopted. By acquiring single-phase voltage signals in real time, the product term difference is calculated using the voltage signal expressions of four adjacent discrete sampling points. The improved adaptive morphological filter is then used for filtering to achieve rapid estimation of voltage amplitude.
It significantly shortens the detection delay, improves the real-time performance and accuracy of detection, meets the core requirements of rapid UPS detection and switching, simplifies the calculation process, and facilitates engineering implementation.
Smart Images

Figure CN121831241A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power failure detection technology, and in particular to a method and system for detecting mains power failure in an uninterruptible power supply. Background Technology
[0002] Uninterruptible power supplies (UPS) serve as power backup devices for critical loads such as servers, industrial control equipment, or medical instruments. Their core function is to quickly switch to a backup power source (such as batteries) when the mains power fails (especially during voltage dips, where the mains voltage drops sharply to below 70% to 85% of its rated value within a short period), preventing data loss or equipment damage due to power outages. The speed and accuracy of voltage dip detection directly determine the timeliness of UPS switching—the industry typically requires UPSs to complete switching within 10ms of a mains voltage dip; otherwise, there is a risk of power interruption for the load.
[0003] Currently, UPS systems have relatively mature solutions for symmetrical three-phase power failure detection, enabling timely and accurate detection and switching. However, mains power failures are primarily single-phase power outages, and traditional detection methods often fail to identify them correctly. For single-phase power failure detection, existing voltage sag detection algorithms often employ the dq transformation method, constructing a virtual three-phase voltage through delay to achieve effective power failure detection. The detection process is as follows: Figure 1 As shown.
[0004] The single-phase mains power first enters an adaptive composite morphology filter, which preprocesses the noise interference and harmonics it contains. After filtering, the corresponding signal is obtained using the small-angle delay method. u α and u β After that, through ab-dq Transformation and Then, filtering yields a smoother result. u d and u q Finally, the actual amplitude and phase of the power grid are judged to detect whether the mains power has been lost.
[0005] However, this method requires a delay to construct the three-phase voltage, which reduces the real-time performance of the detection. Summary of the Invention
[0006] Based on the shortcomings of the existing technology, the present invention provides a method and system for detecting mains power failure of an uninterruptible power supply, which solves the problem that the existing single-phase mains power failure detection method requires a delay to construct three-phase voltage, thus reducing the real-time performance of the detection.
[0007] The present invention adopts the following technical solution: In a first aspect, the present invention provides a method for detecting mains power failure in an uninterruptible power supply, comprising the following steps: The single-phase voltage signal output from the mains is acquired in real time by an uninterruptible power supply, and the single-phase voltage signal is filtered to obtain a filtered pure voltage signal. The first and second product terms are calculated based on the voltage signal expressions of four adjacent discrete sampling points in the pure voltage signal; where the first product term is the product of the first and fourth discrete sampling points among the four adjacent discrete sampling points, and the second product term is the product of the two middle discrete sampling points. Obtain the difference between the first and second product terms, obtain the real-time amplitude of the single-phase voltage signal through the product term difference, compare the real-time amplitude with the reference amplitude, and output the mains power failure status based on the comparison result.
[0008] Preferably, the first product term and the second product term are specifically as follows: ; In the formula, P 1 is the first product term. P 2 is the second product term. x ( n- 1) is the first n -1 discrete sampling points, x ( n () represents the nth discrete sampling point. x ( n +1) is the first n +1 discrete sampling points, x ( n +2) is the first n +2 discrete sampling points.
[0009] Preferably, the real-time amplitude is as follows: In the formula, A This is the real-time amplitude. oh ω is the angular frequency.
[0010] Preferably, the single-phase voltage signal is filtered by an improved adaptive morphological filter. The improved adaptive morphological filter employs a triangular filter and a sine filter, and the output of the improved adaptive morphological filter is specifically shown below: ; In the formula, E total To improve the output of the adaptive morphological filter, Etri The output of the triangular filter, E sin The output of the sine filter, K 1 represents the output weighting coefficient of the triangular filter.
[0011] Preferably, the optimal filtering parameters are obtained by iteratively applying reinforcement learning to the filtering parameters of the triangular filter and the sine filter. This specifically includes the following steps: Using the parameter adjustment module as the intelligent agent, the power grid voltage signal as the environment, and weighting coefficients as the environment... K 1. Structural element dimensions K 2. Sine element amplitude A sin and the amplitude of the triangle element A tri As decision variables, the current signal-to-noise ratio of the filter, the current... MSE Compared to the previous moment MSE The difference and weighting coefficient K 1. Structural element dimensions K 2. The size-to-period ratio is the state space, the adjustment actions corresponding to the weight coefficients, structural element sizes, sinusoidal element amplitudes and triangular element amplitudes are the action space, and the reward function is constructed using the signal-to-noise ratio (SNR) and the noise mean square error (MSE). The real-time acquired single-phase voltage signal is input to a delta filter and a sine filter to obtain the current output signal, and the state vector is updated based on the current output signal; The corresponding adjustment action is selected from the action space according to the ε-greedy strategy, the selected adjustment action is executed, the filtering parameters of the triangular filter and the sine filter are updated, and the reward value is obtained based on the reward function; the Q value is iteratively optimized by learning the update formula based on the reward value. The above steps are iterated until the iteration converges to obtain the optimal filter parameters.
[0012] Preferably, the reward function is as follows: ; In the formula, R For the reward function, R 0 Basic rewards, l SNR and l MSE They are respectively SNR and MSE Their respective weights, For the penalty item weight, As a penalty item, For the present SNR Compared to the previous moment SNR The difference, For the present MSE Compared to the previous moment MSE The difference.
[0013] Preferably, the amplitude of the triangular element A tri The selected range is {5, 7, 9, 11, 13, 15, 17}, and the amplitude of the sinusoidal element is... A sin The selected range is {11, 13, 15, 17, 19, 21, 23}.
[0014] Preferably, the mains power failure state includes signal 0 and signal 1, where 0 indicates that the mains power is in a normal state and 1 indicates that a power failure has occurred; the working mode of the uninterruptible power supply is controlled according to the mains power failure state number.
[0015] Secondly, the present invention provides a mains power failure detection system for an uninterruptible power supply, comprising: The acquisition module is used to acquire single-phase voltage signals from the mains power output in real time through an uninterruptible power supply, and to filter the single-phase voltage signals to obtain filtered pure voltage signals. The calculation module is used to calculate the corresponding first product term and second product term based on the voltage signal expression of four adjacent discrete sampling points in the pure voltage signal; wherein, the first product term is the product of the first discrete sampling point and the fourth discrete sampling point among the four adjacent discrete sampling points, and the second product term is the product of the two middle discrete sampling points; The acquisition module is used to acquire the product term difference between the first product term and the second product term, obtain the real-time amplitude of the single-phase voltage signal through the product term difference, compare the real-time amplitude with the reference amplitude, and output the mains power failure status based on the comparison result.
[0016] Compared with the prior art, the above-mentioned at least one technical solution adopted by the present invention can achieve the following beneficial effects: This invention calculates the first and second product terms based on the voltage signal expressions of four adjacent discrete sampling points in a pure voltage signal; then, it obtains the difference between the first and second product terms, and uses this difference to obtain the real-time amplitude of the single-phase voltage signal. The proposed four-neighborhood product method utilizes the product combination of four adjacent discrete sampling points in the voltage sinusoidal signal, requiring only a delay of two sampling points to achieve effective voltage amplitude estimation. Compared to the small-angle delay method in existing solutions, this significantly shortens the detection delay, better meeting the industry's core requirements for rapid UPS detection and switching. Furthermore, this method is simple in principle, requires minimal computation, and eliminates the need for complex virtual three-phase voltage construction, facilitating engineering implementation. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of the existing strategy voltage sag detection algorithm; Figure 2 Construct an αβ vector diagram for the small-angle delay method of existing detection algorithms; Figure 3 This is the basic flow chart of the adaptive morphological filter of the present invention; Figure 4 This is a flowchart of a mains power failure detection method for an uninterruptible power supply according to the present invention. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Example 1 Delayed small angle method.
[0021] Since actual voltage drops are mostly single-phase events, for single-phase circuits, a virtual three-phase system can be constructed using the single-phase power supply as a reference voltage, based on the characteristics of a three-phase three-wire circuit. a For example, let u β = u a = Usin ( t+φ ), and then u β Delay a small angle i get u θ , u θ and u β Construct vectors with the same magnitude u 01 and u 02 Relationships such as Figure 2 As shown.
[0022] It is easy to see from the vector relationship that: (1); The three equations can be solved simultaneously. .
[0023] Will u α and u β Transform to dq The coordinate system relationship is: (2); According to direct flow u d and u q This allows you to further determine whether the mains power is working properly.
[0024] Here, angle i With sampling frequency f s The value depends on the frequency of the signal. f ( Hz The system's sampling frequency is f s ( Hz The signal is in one cycle. T The number of sampling points is N ,but: (3); Here, angle i With sampling frequency f s The value depends on the frequency of the signal. f ( Hz The system's sampling frequency is f s ( Hz The signal is in one cycle. T The number of sampling points is N Then the phase difference of the delay.
[0025] (4); The above formula can be used to calculate when the signal frequency is set to 50. Hz When the small delay angle is set to 10°, the sampling frequency is 10. kHz The delay is 5.56 sampling points, and the sampling frequency is 12.8. kHz A delay of 7 sampling points, where the number of delay points is not an integer, cannot meet the requirements of an embedded processor. Therefore, a suitable sampling frequency needs to be selected. f s .
[0026] Adaptive morphological filter.
[0027] Morphological basic operations: Filters based on mathematical morphology are a novel filtering algorithm that obtains the morphological features of a signal through the continuous movement of a "probe" (structuring element). Basic operations include dilation, erosion, opening, and closing. Assuming the input signal... f ( n ) is defined in Discrete functions on, structuring element sequence g ( n )for Discrete function on, and N≥M, but f ( n )about g ( n The corrosion and expansion of ) are defined as follows:
[0028] (5); (6); In the formula, .
[0029] The opening and closing states are defined as follows: (7); (8); By combining the characteristics of opening operations in suppressing peak noise and closing operations in suppressing trough noise, open-close (Oc) and closed-open (Co) filters are formed, as defined below: (9); (10); Both open-to-close and closed-to-open filters exhibit output statistical offset, so this error can be reduced by averaging the results of combining these two filters. This hybrid filter is defined as follows: (11); The adaptive composite morphological filter proposed in the existing detection method adopts this morphological composite operation form.
[0030] The principle of adaptive composite morphological filters: The size of the morphological structuring elements affects the filtering effect to a certain extent. Therefore, adaptive filters must simultaneously achieve optimal selection of both the composite morphological structuring elements and their sizes. The principle for optimal selection of adaptive filters can be measured by noise mean square error and signal-to-noise ratio. The noise mean square error is defined as:
[0031] (12); In the formula: y (n () represents the filtered output signal. u ( n () represents a hypothetical noise-free signal. n The number of sampling points. n= 1, 2, ..., N . y ( n )and u ( n The difference is the sum of the squares of the noise signals divided by 1 / 2. n The noise mean square error is proportional to the noise power; the smaller the noise mean square error, the lower the noise power and the better the filtering effect. The signal-to-noise ratio (SNR) of the filtered signal is defined as:
[0032] (13); In the formula, P s and P n These represent the effective power of the signal and noise, respectively. A higher signal-to-noise ratio (SNR) indicates less noise in the signal, meaning a better filtering effect.
[0033] Existing detection methods use an empirically designed sequence of potential amplitude values for structural elements: {4, 8, 12, 16, 20}. The maximum interference width is unknown. For impulse noise, if the maximum width is... T And the sampling period is T s struct element length L Theoretically, it only needs to be greater than T / T s After multiple sets of data tests, a candidate sequence of lengths that maximized the signal-to-noise ratio was selected, set as {5, 7, 9, 11, 13, 15}. Based on the adaptive composite morphological filter denoising process, the noise mean square error was calculated and statistically analyzed. y MSE and signal-to-noise ratio y SNR The composite structural element at various amplitudes and lengths y SNR and y MSE The trend of value changes is analyzed, and finally, the optimal scale of the corresponding structural element under this noisy environment is inferred based on the plotted trend curve. A= 16, L= 9.
[0034] Since the method of constructing virtual three-phase voltage with time delay inherently introduces a certain delay, even using a small angle method cannot completely eliminate the impact of this method on real-time performance.
[0035] Existing detection methods only adaptively adjust the morphological amplitude and length of the proposed adaptive morphological filters. They employ equal weights for the composite structure of triangular and sinusoidal morphological filters, failing to fully leverage the advantages of each in more complex noise environments. Essentially, the proposed adaptive morphological filters involve offline traversal of optimal parameters and do not achieve autonomous adaptive adjustment under varying noise conditions.
[0036] Example 2 To address the aforementioned problems, this invention proposes an uninterruptible power supply (UPS) power failure detection method based on four-neighbor product and adaptive morphological filtering. First, Q-learning is used to adaptively select and adjust the morphological filter parameters. Then, adaptive morphological filtering is used to remove noise. Finally, the four-neighbor product method is used to track and detect the mains voltage, further improving the accuracy and speed of detection.
[0037] The basic idea of the four-neighbor product method is to eliminate initial phase interference by using the product combination of four adjacent discrete sample points in the sinusoidal sequence of the voltage signal, thereby achieving effective estimation of the amplitude of the sequence.
[0038] Reference Figure 4 The present invention specifically includes the following steps: S1: The UPS obtains the single-phase voltage signal corresponding to the mains power output through the voltage detection circuit.
[0039] S2: Input the single-phase voltage signal into the improved adaptive morphological filter for processing to obtain the filtered pure voltage signal.
[0040] This invention proposes an adaptive morphological filter design based on Q-learning.
[0041] The basic principles of mathematical morphology have been given in the basic morphological operations of Example 1, and will not be repeated here. This strategy also adopts its composite operation form. Here, we mainly give the basic principles and improvement strategies of the proposed Q-learning-based adaptive morphological filter.
[0042] S21: Introduction of New Weight Definitions and Constraints: Since the triangular morphological filter and the sinusoidal morphological filter emphasize different aspects of filtering effect—the triangular filter is better at filtering impulse noise, while the sinusoidal filter is better at filtering harmonics—defining an adaptive weight composition instead of the traditional averaging enhances the adaptability to noise. Therefore, let the filtering output of the triangular structuring element be... E tri The filtered output of the sinusoidal structuring element is E sin The weights of the two are defined as follows:K 1 and K 1comp It satisfies the normalization constraint.
[0043] The final output of the composite structural element (denoted as) E total The formula is obtained by weighted summation of the two, and can be defined as follows: (14); By adjusting K This allows for the adjustment of the proportions of various shapes within the composite morphological filter, thereby regulating... E total Size.
[0044] S22: Independent Amplitude Range Design for Two Morphological Filters: Compared to existing detection methods that use the same amplitude, this invention sets independent ranges for the amplitudes of triangular and sinusoidal morphological filters. Based on previous literature and experience, the amplitude of the triangular morphological filter is designed... A tri The selected range is {5, 7, 9, 11, 13, 15, 17}, with sinusoidal amplitude values. A sin The selected range is {11, 13, 15, 17, 19, 21, 23}. Then, a three-dimensional Q-learning model of "state-action-reward" is constructed. By continuously optimizing and iterating according to the penalty function, the weights, magnitudes, and structuring element lengths can be adaptively adjusted.
[0045] S23: Adaptive adjustment mechanism based on Q-learning.
[0046] This mechanism is essentially a reinforcement learning model for agent-environment interaction, in which: Intelligent agent: The parameter adjustment module of the composite morphological filter, with weight coefficients as the decision variables. K 1. Structural element dimensions K 2. Sine element amplitude A sin Triangle element amplitude A tri ; Environment: The dynamic changes in the voltage signal and noise characteristics of the power grid determine the decision-making environment of the intelligent agent; Core assumptions: 1) Power grid noise has statistical stationarity over a short period of time, ensuring the effectiveness of state perception; 2) The effect of small adjustments to filter parameters on filter performance has a certain linear relationship, providing theoretical support for the continuity of action decisions.
[0047] State space design: Based on the filtering effect metrics and the existing parameters that need adaptive adjustment, a five-dimensional state vector is theoretically selected to construct the state vector: (15); In the formula, SNR cur The signal-to-noise ratio of the current filter. DMSE For the present MSE Compared to the previous moment MSE The difference, K 1. K 2 represents the weighting factor and the size factor, respectively. c K2 The relative period ratio of dimensions: (16); In the formula, N cycle This represents the number of sampling points per cycle.
[0048] To balance state resolution and computational complexity, an equal-interval discretization strategy is adopted, and the theoretical design of the discretization intervals for each dimension is shown in Table 1.
[0049] Table 1 Discretization Design of State Dimension After discretization, the 5-dimensional state is mapped to a 1-dimensional Q-table index using row-major indexing. The theoretical derivation of the index formula is as follows: (17); In the formula s 1~ s 5 represents the discretized state values for each dimension. N 1~ N 5 represents the length of the discrete interval for each dimension. The theoretical rationale behind this formula lies in the fact that "row-major storage" maximizes the utilization of... Q Tablespaces avoid state redundancy and, at the same time, through max ( minutes ( s i , N i ) , 1) Constrain the index range to ensure project robustness.
[0050] Motion space design: The design of the motion space must balance parameter sensitivity and performance synergy to avoid performance deviations caused by adjusting a single parameter. Based on morphological filtering theory, nine sets of motion vectors are designed:
[0051] (18); In the formula, DK1 represents the weight adjustment action. DK 2 refers to morphological scale adjustment movements. A sin and A tri These are the adjustment actions corresponding to the amplitudes of the sine and triangle shapes, respectively.
[0052] The theoretical design logic of each action group is shown in Table 2. Actions 5 to 9 are independent adjustment actions, which are aimed at the precise optimization of a single parameter and are suitable for scenarios where "one parameter deviates from the optimal range while other parameters are already optimal". Actions 1 to 4 are coordinated adjustment actions, which avoid the side effects of adjusting a single parameter based on the coupling relationship between parameters.
[0053] Table 2 Action Space Design Logic of Q-Learning Reward Function Design: The reward function is the core link between action and performance. Here, an incentive-penalty mechanism is constructed based on the dual metrics of SNR and MSE to avoid performance imbalance caused by single-objective optimization. The reward function expression is defined as follows:
[0054] (19); In the formula, R 0 Basic rewards, l SNR and l MSE They are respectively SNR and MSE Their respective weights, The penalty term weight is set to avoid excessively large morphological structure length. This is a penalty item.
[0055] Considering that adaptive regulation relies on an internally provided ideal voltage reference signal, regulation failure may occur during voltage drop. Therefore, the adaptive regulation mechanism can be set up during UPS initialization or manually activated, followed by parameter locking. This ensures optimal parameter adjustment while preventing power outages from affecting filter parameters. The adaptive regulation process of the proposed adaptive morphological filter is as follows: Figure 3 As shown, when the adaptive parameters (weighting coefficients of the two filters) are received... K 1. Structural element dimensions K 2. Sine element amplitude A sin Triangle element amplitude A tri When adjusting the signal, first, a set of initial values is given to initialize the parameters, and then, based on the initialization results, combined with... Q-learning Algorithm, using e-A greedy strategy is used to learn and iterate the parameters; here, we select... e =0.1, meaning a 90% probability of choosing Q The optimal action with the highest value has a 10% probability of exploring a new action.
[0056] S24: The basic process of adaptive morphological filters is as follows Figure 3 As shown, in the adaptive phase, an iterative optimization is performed at each sampling point. First, the state is acquired using the results of the morphological filter, and the current signal is calculated in real time. SNR cur , DMSE Wait, update status S Then according to e- Greedy strategy from action space A Select the corresponding adjustment action; after executing the action, calculate the new state. ΔSNR cur , DMSE Substituting into equation (20) yields the reward value. R ; Receive reward points R Later, the classic approach was adopted. Q Learning, updating formulas, and iterative optimization Q Value, to ensure better subsequent actions:
[0057] (20); In the formula, Represents the updated optimization Q The value is the result of iterative adjustments in the current state. S Next action A The optimal expected cumulative reward, its core function is to provide guidance for subsequent action selection. Original before the update Q The value reflects the current state. S Next action A The corresponding expected cumulative reward. or The learning rate is fixed at 0.1. This value is a typical setting determined after engineering optimization, and its main function is to control... Q The update range of the value can avoid convergence oscillations caused by updating too quickly, and also prevent the algorithm efficiency from being affected by updating too slowly, thus effectively balancing convergence speed and stability. l As a discount factor, its function is to weigh immediate rewards. R With regard to the importance of long-term rewards in the future, when l The closer it is to 1, the more the algorithm values the cumulative reward of future actions, and when... l As the algorithm approaches zero, it places greater emphasis on immediate rewards to mitigate the impact of future uncertainties. Representing the optimal futureQ Value, specifically, refers to the action performed. A Later transferred to the new state S′ At that time, from all 9 candidate actions in the action space A′ Select the corresponding Q The maximum value represents the optimal expected long-term reward obtainable in the new state, where the new state... S′ Is performing an action A Afterwards, based on the new SNR cur , DMSE The state vector is obtained by recalculating the indicators.
[0058] Finally, when 5 consecutive frames of signal... Q Value change | Q new -Q old When |<0.01, the iteration is considered converged, and the final result is output. K 1. K 2. A sin and A tri As a real-time parameter of the composite filter; if it does not converge, repeat until it converges.
[0059] S3: Calculate the product term based on the filtered signal. P 1 , P 2 and difference D Through the difference D Further calculation of amplitude A .
[0060] S31: The expression for the pure voltage signal is as follows: (twenty one); The expressions for the other three neighboring sampling points of the corresponding sampling point are: (twenty two); In the formula, ω=2πf 0 / f s ; f 0 For the fundamental frequency; f s The sampling frequency; A The signal amplitude; Phase angle; x ( n ) is the corresponding number n One sampled signal.
[0061] S32: Calculate the first and second product terms based on the voltage signal expressions of four adjacent discrete sampling points in the pure voltage signal.
[0062] Define two sets of product terms P 1. P The expression is as follows: (twenty three); Substituting equation (22) into equation (23), the specific derivation using trigonometric formulas is as follows: Substitute the specific expression P 1. P After 2, we get: (twenty four); S33: Obtain the product term difference between the first product term and the second product term, and obtain the real-time amplitude of the single-phase voltage signal through the product term difference.
[0063] make α=nω+ ,β=nω+ +oh Using the trigonometric sum-to-product formula, we have: (25); make γ=nω+ -ω,δ=nω+ +2h Then we have: (26); To eliminate the initial phase angle Interference, defining the difference of product terms D : (27); Therefore, it can be seen that when the amplitude changes slightly, the product term difference D This will result in significant changes. Therefore, when the voltage signal is disturbed, the difference in the product terms is used... D This enables accurate detection of the moment of power failure.
[0064] The amplitude can be obtained from equation (27). A The expression: (28); From equation (28), we can see that the amplitude A The difference can be obtained through the product of four neighboring points, and only requires a delay of two sampling points. Compared with the small-angle delay method, the four-neighbor product method further improves the real-time performance of detection.
[0065] S4: Calculate the amplitude AThe UPS operating mode is switched by comparing the voltage with a reference mains voltage to determine the mains power failure status.
[0066] Based on this, when the voltage signal is disturbed, the difference in the product terms is used. D This allows the timing of disturbances to be detected. The basic process of implementing the power-down detection algorithm is as follows: Figure 4 As shown, the UPS system monitors the voltage signal output by the mains power in real time through a corresponding detection circuit and transmits it to the processor. Based on the detected voltage signal, the processor calculates the product and difference of the two terms, and then uses equation (28) to effectively estimate the mains power amplitude and outputs a power failure status signal. The status signal includes 0 and 1, where 0 indicates that the mains power is in a normal state and 1 indicates that a power failure has occurred. The power failure status signal is used to control whether the load is powered by the UPS or by the mains power. When the mains power is normal, it is powered by the mains power (corresponding to state 0), and when the mains power fails, it switches to the UPS for power supply through a switch (corresponding to state 1).
[0067] The four-neighbor product method proposed in this invention utilizes the product of four adjacent discrete sampling points in the voltage sinusoidal signal (requiring only a delay of two sampling points to achieve effective estimation of the voltage amplitude). Compared to the existing "small-angle delay method" (which requires a delay of seven sampling points for a 50Hz power grid, a 12.8kHz sampling frequency, and a 10° small-angle delay), this method significantly shortens the detection delay, better meeting the industry's core requirements for rapid UPS detection and switching. Furthermore, this method is simple and straightforward in principle, requires minimal computation, and eliminates the need for complex virtual three-phase voltage construction, making it easy to implement in engineering projects.
[0068] The adaptive morphological filter based on Q-learning designed in this invention achieves multiple optimizations to address the shortcomings of existing filtering schemes, with the following specific effects: Adapting to complex noise scenarios: Breaking through the limitations of the original solution where the triangular and sinusoidal morphological filters have equal weights, amplitudes, and lengths, this solution adjusts the proportions of the two filters by defining an adaptive weighting factor and setting independent amplitude ranges for both, thus better meeting the filtering needs of different noise types in principle.
[0069] Achieving online parameter adaptation: Introducing the Q-learning reinforcement learning mechanism, by constructing a three-dimensional model of state-action-reward, combined with... e - The greedy strategy iteratively optimizes the parameters, enabling the filter to autonomously adapt to the dynamically changing noise environment in the power grid and output the optimal filtering parameters without manual intervention.
[0070] The original scheme, with its fixed ratio of sinusoidal and triangular morphological filters, is modified by selecting an adaptive proportional weighting factor to adjust their proportions. While maintaining the same amplitude and length for both filters, the sinusoidal and triangular morphological filters are now independently adjusted within different amplitude ranges. This approach is more adaptable to noisy environments in principle and enhances the morphological filtering effect compared to the original scheme. Furthermore, the introduction of a Q-learning mechanism transforms the offline optimal parameter selection into true adaptive adjustment, enabling the filter to autonomously select optimal morphological filtering parameters under varying noise conditions, thus improving its adaptability to different environments.
[0071] This invention excels in real-time performance, meeting the core requirement of rapid UPS switching; it boasts strong filtering adaptability, with Q-learning-driven adaptive morphological filtering that can optimize parameters such as weights, amplitudes, and structure lengths online, adapting to complex noise environments such as pulses and harmonics, and providing stable filtering results; it also exhibits high engineering feasibility, with a simple overall algorithm calculation logic that eliminates the need for complex wavelet transforms and other complex operations, thus requiring lower embedded processor performance and facilitating deployment in industrial scenarios.
[0072] Based on the same concept, the present invention also provides an uninterruptible power supply mains power failure detection system, including a data acquisition module, a calculation module and an acquisition module.
[0073] The acquisition module is used to acquire single-phase voltage signals from the mains power supply in real time through an uninterruptible power supply, and to filter the single-phase voltage signals to obtain filtered pure voltage signals.
[0074] The calculation module is used to calculate the corresponding first product term and second product term based on the voltage signal expression of four adjacent discrete sampling points in the pure voltage signal; wherein, the first product term is the product of the first and fourth discrete sampling points among the four adjacent discrete sampling points, and the second product term is the product of the two middle discrete sampling points.
[0075] The acquisition module is used to obtain the difference between the first and second product terms, obtain the real-time amplitude of the single-phase voltage signal through the difference between the product terms, compare the real-time amplitude with the reference amplitude, and output the mains power failure status based on the comparison result.
[0076] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0077] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for detecting mains power failure in an uninterruptible power supply, characterized in that, Includes the following steps: The single-phase voltage signal output from the mains is acquired in real time by an uninterruptible power supply, and the single-phase voltage signal is filtered to obtain a filtered pure voltage signal. The first and second product terms are calculated based on the voltage signal expressions of four adjacent discrete sampling points in the pure voltage signal; where the first product term is the product of the first and fourth discrete sampling points among the four adjacent discrete sampling points, and the second product term is the product of the two middle discrete sampling points. Obtain the difference between the first and second product terms, obtain the real-time amplitude of the single-phase voltage signal through the product term difference, compare the real-time amplitude with the reference amplitude, and output the mains power failure status based on the comparison result.
2. The method for detecting mains power failure in an uninterruptible power supply as described in claim 1, characterized in that, The first and second product terms are shown below: ; In the formula, P 1 is the first product term. P 2 is the second product term. x ( n- 1) is the first n -1 discrete sampling points, x ( n () represents the nth discrete sampling point. x ( n +1) is the first n +1 discrete sampling points, x ( n +2) is the first n +2 discrete sampling points.
3. The method for detecting mains power failure in an uninterruptible power supply as described in claim 2, characterized in that, The specific real-time amplitude is as follows: ; In the formula, A This is the real-time amplitude. ω ω is the angular frequency.
4. The method for detecting mains power failure in an uninterruptible power supply as described in claim 1, characterized in that, A single-phase voltage signal is filtered by an improved adaptive morphological filter, which employs a triangular filter and a sine filter. The output of the improved adaptive morphological filter is shown below: ; In the formula, E total To improve the output of the adaptive morphological filter, E tri The output of the triangular filter, E sin The output of the sine filter, K 1 represents the output weighting coefficient of the triangular filter.
5. The method for detecting mains power failure in an uninterruptible power supply as described in claim 4, characterized in that, The optimal filtering parameters are obtained by iterating through the parameters of the triangular filter and the sine filter using reinforcement learning. The specific steps include: Using the parameter adjustment module as the intelligent agent, the power grid voltage signal as the environment, and weighting coefficients as the environment... K 1. Structural element dimensions K 2. Sine element amplitude A sin and the amplitude of the triangle element A tri As decision variables, the current signal-to-noise ratio of the filter, the current... MSE Compared to the previous moment MSE The difference and weighting coefficient K 1. Structural element dimensions K 2. The size-to-period ratio is the state space, the adjustment actions corresponding to the weight coefficients, structural element sizes, sinusoidal element amplitudes and triangular element amplitudes are the action space, and the reward function is constructed using the signal-to-noise ratio (SNR) and the noise mean square error (MSE). The real-time acquired single-phase voltage signal is input to a delta filter and a sine filter to obtain the current output signal, and the state vector is updated based on the current output signal; The corresponding adjustment action is selected from the action space according to the ε-greedy strategy, the selected adjustment action is executed, the filtering parameters of the triangular filter and the sine filter are updated, and the reward value is obtained based on the reward function; the Q value is iteratively optimized by learning the update formula based on the reward value. The above steps are iterated until the iteration converges to obtain the optimal filter parameters.
6. The method for detecting mains power failure in an uninterruptible power supply as described in claim 5, characterized in that, The reward function is as follows: ; In the formula, R For the reward function, R 0 Basic rewards, λ SNR and λ MSE They are respectively SNR and MSE Their respective weights, For the penalty item weight, As a penalty item, For the present SNR Compared to the previous moment SNR The difference, For the present MSE Compared to the previous moment MSE The difference.
7. The method for detecting mains power failure in an uninterruptible power supply as described in claim 5, characterized in that, The amplitude of the triangle element A tri The selected range is {5, 7, 9, 11, 13, 15, 17}, and the amplitude of the sinusoidal element is... A sin The selected range is {11, 13, 15, 17, 19, 21, 23}.
8. The method for detecting mains power failure in an uninterruptible power supply as described in claim 1, characterized in that, The mains power failure status includes signal 0 and signal 1, where 0 indicates that the mains power is in a normal state and 1 indicates that a power failure has occurred; the working mode of the uninterruptible power supply is controlled according to the mains power failure status number.
9. A mains power failure detection system for an uninterruptible power supply, characterized in that, include: The acquisition module is used to acquire single-phase voltage signals from the mains power output in real time through an uninterruptible power supply, and to filter the single-phase voltage signals to obtain filtered pure voltage signals. The calculation module is used to calculate the corresponding first product term and second product term based on the voltage signal expression of four adjacent discrete sampling points in the pure voltage signal; wherein, the first product term is the product of the first discrete sampling point and the fourth discrete sampling point among the four adjacent discrete sampling points, and the second product term is the product of the two middle discrete sampling points; The acquisition module is used to acquire the product term difference between the first product term and the second product term, obtain the real-time amplitude of the single-phase voltage signal through the product term difference, compare the real-time amplitude with the reference amplitude, and output the mains power failure status based on the comparison result.