Zero-cross detection method and device based on micro-control unit and computer equipment

Through the zero-crossing detection method based on the microcontroller unit, the problem of insufficient accuracy of mains zero-crossing detection is solved by utilizing low-pass filtering, phase hysteresis processing, orthogonal signal decomposition and time delay compensation, and high-precision and low-error zero-crossing point detection is achieved.

CN120652160APending Publication Date: 2025-09-16SHENZHEN SINONE CHIP ELECTRONIC CO. LTD.
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510802767.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-16
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

The existing mains zero-crossing detection method has a complex structure and poor anti-interference ability, resulting in insufficient zero-crossing detection accuracy and a high false trigger rate, making it difficult to adapt to the power grid environment under complex working conditions.

Method used

A zero-crossing detection method based on a microcontroller unit is adopted to achieve high-precision zero-crossing detection of the mains signal through low-pass filtering, phase hysteresis processing, orthogonal signal decomposition, weighted error correction and time delay compensation.

Benefits of technology

High-precision, low-error zero-crossing point detection is achieved by integrating it into the microcontroller unit, which improves the circuit's anti-interference ability and detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120652160A_ABST
    Figure CN120652160A_ABST
Patent Text Reader

Abstract

The invention relates to a zero-cross detection method and device based on a micro-control unit and computer equipment. The method comprises the following steps: performing low-pass filtering processing on a mains supply signal to obtain a filtered signal; performing phase hysteresis processing on the filtered signal to obtain an orthogonal signal, and performing dynamic orthogonal decomposition and angle estimation processing on an orthogonal waveform obtained by combining the filtered signal and the orthogonal signal to obtain an orthogonal decomposition quantity and an angle estimation quantity; in the weighted error correction mechanism, based on the minimum phase hysteresis error, performing optimization operation on the orthogonal decomposition quantity and the angle estimation quantity to obtain an error correction value; performing calibration processing on the phase of the orthogonal signal according to the error correction value to obtain a calibrated orthogonal signal, and performing time delay compensation processing on the calibrated orthogonal signal based on the filtering time delay to obtain a target signal; and obtaining a zero-crossing point detection result according to the zero-crossing point waveform corresponding to the target signal. By adopting the method, high-precision and low-error zero crossing point detection of the mains supply signal can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of mains zero-crossing detection, and in particular to a zero-crossing detection method, device and computer equipment based on a microcontroller unit. Background Art

[0002] In the field of mains zero-crossing detection technology, it involves identifying and processing the zero-crossing moment of the AC voltage signal, thereby achieving high-precision synchronous control and signal triggering.

[0003] Related zero-crossing detection methods usually use separate components to construct RC filtering and comparison circuits, or use integrated zero-crossing detection ICs to implement level comparison or threshold judgment. However, these methods generally have disadvantages such as complex structure, poor anti-interference ability, and poor real-time performance, resulting in insufficient zero-crossing detection accuracy, high false trigger rate, and difficulty in adapting to the power grid environment under complex working conditions, limiting their actual application effect in high-stability control scenarios. Summary of the Invention

[0004] Based on this, it is necessary to provide a zero-crossing detection method, device, computer equipment and computer-readable storage medium based on a microcontroller unit to address the above technical problems, so as to achieve high-precision and low-error zero-crossing point detection of the mains signal.

[0005] In a first aspect, the present application provides a zero-crossing detection method based on a microcontroller unit, which is applied to the microcontroller unit, comprising: Performing low-pass filtering on the collected mains power signal to obtain a filtered signal corresponding to the mains power signal; performing phase lag processing on the filtered signal to obtain an orthogonal signal corresponding to the filtered signal, and performing dynamic orthogonal decomposition and angle estimation processing on an orthogonal waveform obtained by combining the filtered signal and the orthogonal signal to obtain an orthogonal decomposition amount and an angle estimation amount; In a preset weighted error correction mechanism, based on minimizing the phase lag error generated during the phase lag processing, the orthogonal decomposition amount and the angle estimation amount are optimized to obtain an error correction value; Calibrate the phase of the orthogonal signal according to the error correction value to obtain a calibrated orthogonal signal, and perform delay compensation on the calibrated orthogonal signal based on a filtering delay generated in a low-pass filtering process to obtain a target signal; A zero-crossing detection result of the mains signal is obtained according to the zero-crossing waveform corresponding to the target signal.

[0006] In a second aspect, the present application further provides a zero-crossing detection device based on a microcontroller unit, which is applied to the microcontroller unit, comprising: A filtering module is used to perform low-pass filtering on the collected mains power signal to obtain a filtered signal corresponding to the mains power signal; an orthogonal analysis module, configured to perform phase lag processing on the filtered signal to obtain an orthogonal signal corresponding to the filtered signal, and perform dynamic orthogonal decomposition and angle estimation processing on an orthogonal waveform obtained by combining the filtered signal and the orthogonal signal to obtain an orthogonal decomposition amount and an angle estimation amount; an error analysis module configured to optimize the orthogonal decomposition amount and the angle estimation amount based on minimizing the phase lag error generated during the phase lag processing in a preset weighted error correction mechanism to obtain an error correction value; a calibration module, configured to calibrate the phase of the orthogonal signal according to the error correction value to obtain a calibrated orthogonal signal, and perform delay compensation on the calibrated orthogonal signal based on a filtering delay generated during a low-pass filtering process to obtain a target signal; The detection module is used to obtain a zero-crossing detection result of the mains signal according to the zero-crossing waveform corresponding to the target signal.

[0007] In a third aspect, the present application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the above steps when executing the computer program.

[0008] In a fourth aspect, the present application also provides a computer-readable storage medium on which a computer program is stored, and the computer program implements the above steps when executed by a processor.

[0009] The above-mentioned zero-crossing detection method, device, computer equipment and computer-readable storage medium based on the microcontroller unit first perform low-pass filtering on the mains signal to obtain a filtered signal, thereby removing high-frequency interference components and retaining stable fundamental information; secondly, constructing an orthogonal signal corresponding to the filtered signal, and performing analysis based on the orthogonal waveform obtained by combining the filtered signal and the orthogonal signal, thereby accurately obtaining the orthogonal decomposition amount and the angle estimation amount through the two-dimensional time series signal set constructed on the same time axis; thirdly, in the weighted error correction mechanism, weighted error correction and optimization processing are performed based on the orthogonal decomposition amount and the angle estimation amount to obtain the error correction value, thereby eliminating the system error introduced by phase lag. The invention relates to a method for detecting the zero-crossing moment of the mains power signal by using a phase-corrected orthogonal signal and a delay-compensated method for the calibrated orthogonal signal according to the filtering delay, thereby ensuring the accurate correspondence of the target signal in the time domain and the phase domain. The invention also relates to a method for detecting the zero-crossing moment of the mains power signal by using a phase-corrected orthogonal signal and a delay-compensated method for the calibrated orthogonal signal according to the filtering delay ..., thereby ensuring the accurate correspondence of the target signal in the time domain and the phase domain. The invention also relates to a method for detecting the zero-crossing moment of the mains power signal by using a phase-corrected orthogonal signal and a delay-compensated method for the calibrated orthogonal signal. The invention also relates to a method for detecting the zero-crossing moment of the mains power signal by using a phase-corrected orthogonal signal and a delay-compensated method for the calibrated orthogonal signal. The invention also relates to a method for detecting the zero-crossing moment of the mains power signal by using a phase-corrected orthogonal signal and a delay-compensated method for the calibrated orthogonal signal. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0011] Figure 1 1 is a flow chart of a zero-crossing detection method based on a microcontroller unit in one embodiment; Figure 2 Schematic diagram of waveforms of various signals in a zero-crossing detection method based on a microcontroller unit in one embodiment; Figure 3 is a structural block diagram of a micro control unit in one embodiment; Figure 4 1 is a flow chart of a zero-crossing detection method based on a microcontroller unit in another embodiment; Figure 5 FIG. 4 is a structural block diagram of a zero-crossing detection device based on a microcontroller unit in one embodiment. DETAILED DESCRIPTION

[0012] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0013] In one embodiment, Figure 1 As shown, a zero-crossing detection method based on a micro control unit is provided. This embodiment takes the method applied to a micro control unit as an example for explanation. The method includes the following steps S101 to S105.

[0014] Among them, the microcontroller unit (MCU) refers to a single-chip controller that integrates functional modules such as a processor core, memory, and input and output interfaces. It is used to collect external sensor signals, perform logical processing, and control the operation of peripherals. For example, during the zero-crossing detection process, the microcontroller unit can be used to collect the mains signal and calculate the zero-crossing point and generate the control signal based on the sampled data.

[0015] Step S101 : performing low-pass filtering on the collected mains power signal to obtain a filtered signal corresponding to the mains power signal.

[0016] For example, in the AC power signal, a low-pass filtering method is used to remove interference components higher than the AC power base frequency. Specifically, the corresponding low-pass filter can be constructed by digital implementation, for example, using a sliding average algorithm of a certain order or a digital filtering structure to achieve it, so that the high-frequency components in the signal spectrum of the AC power signal are effectively weakened, thereby obtaining a signal that mainly retains the base frequency components, that is, the filtered signal; the filtered signal retains the basic form of the original AC power signal and has a relatively smooth zero-crossing transition process, which is helpful for subsequent phase analysis and error correction and other processing.

[0017] In step S102 , the filtered signal is subjected to phase lag processing to obtain an orthogonal signal corresponding to the filtered signal, and an orthogonal waveform obtained by combining the filtered signal and the orthogonal signal is subjected to dynamic orthogonal decomposition and angle estimation processing to obtain an orthogonal decomposition amount and an angle estimation amount.

[0018] The orthogonal signal represents an auxiliary signal that has a 90-degree phase difference with the filtered signal in mathematical construction, and is used to characterize the phase and amplitude characteristics of the mains signal in the time domain from a two-dimensional perspective.

[0019] Among them, the orthogonal waveform represents a two-dimensional time series signal set composed of the filtered signal and its corresponding orthogonal signal on the same time axis, which is used to represent the mains signal as a two-dimensional vector trajectory that changes with time, thereby facilitating vector decomposition and angle analysis.

[0020] Among them, the orthogonal decomposition quantity represents the amplitude representation obtained after decomposing each vector in the orthogonal waveform into a specific coordinate axis, which is used to describe the changing trend of the orthogonal waveform in different directional components; the angle estimation quantity represents the numerical estimation result obtained based on the actual phase difference between the orthogonal signal and the filtered signal, which is used to describe the actual phase deviation of the orthogonal waveform in the two-dimensional vector trajectory.

[0021] For example, first, a phase lag can be applied to the filtered signal using numerical shifting, integral approximation, or other numerical transformation techniques to generate an orthogonal signal with a fixed phase difference. This orthogonal signal is designed to maintain a theoretical 90-degree phase shift relationship with the filtered signal. Furthermore, the filtered signal and its orthogonal signal form a set of orthogonal waveforms. This set of orthogonal waveforms can be combined into a vector in a two-dimensional plane in the time domain. The signal state at each moment corresponds to a point on the plane, thereby constructing a set of two-dimensional signal representations with a spatial orthogonal relationship, expanding the single-channel time series signal into a two-dimensional vector trajectory representation.

[0022] Furthermore, to further extract the instantaneous amplitude and phase characteristics of the signal, it is necessary to perform a vector decomposition operation on the set of orthogonal waveforms. That is, the signal vector of the orthogonal waveform is decomposed into two amplitude components in a two-dimensional plane, and expanded along the direction of the filtered signal and the direction of the orthogonal signal respectively, thereby obtaining the in-phase component and the orthogonal component. These two components constitute the basic form of the orthogonal decomposition quantity, which is used to describe the projection value of the orthogonal waveform on two perpendicular axes. Furthermore, based on the ratio relationship between the orthogonal component and the in-phase component, combined with the detected fundamental frequency, the instantaneous angular position of the orthogonal waveform is analyzed; specifically, by utilizing the inversion capability of the inverse tangent function, an angle estimate is constructed based on the numerical values ​​of the orthogonal component and the in-phase component at the current moment. This angle estimate is the actual phase difference between the orthogonal signal and the filtered signal at the current moment.

[0023] In step S103 , in a preset weighted error correction mechanism, based on minimizing the phase lag error generated during the phase lag processing, an optimization operation is performed on the orthogonal decomposition amount and the angle estimation amount to obtain an error correction value.

[0024] Among them, the weighted error correction mechanism represents a numerical optimization processing flow that performs weighted control on the degree of influence of different error sources on the estimation results. That is, it is used to correct the systematic errors introduced by the processing method in the orthogonal decomposition and angle estimation, thereby improving the accuracy of the final angle estimation. For example, if a certain error source reflects a greater impact on the phase lag error, a higher weight will be given to this error source, so that the optimization process will focus more on the calibration of this error source.

[0025] The phase hysteresis error refers to the deviation between the actual phase and the theoretical phase caused by a fixed algorithm or structural delay in the process of constructing an orthogonal signal.

[0026] The error correction value represents a numerical value that can be used to compensate for the phase deviation of the orthogonal signal in the weighted error correction mechanism, which is calculated through error analysis and numerical optimization.

[0027] For example, since the phase lag process is essentially a numerical delay process constructed based on specific rules, phase errors are easily generated under certain boundary conditions. For example, near the signal zero crossing point, a small waveform disturbance may cause the phase offset of the orthogonal signal, thereby introducing a systematic deviation in the angle estimation. In order to reduce the phase lag error introduced by the fixed phase delay algorithm, a weighted error correction mechanism is introduced, that is, an algebraic fit is performed on the angle deviation and the orthogonal error based on a preset weighting criterion, and an optimization operation is performed with the goal of minimizing the overall offset. Specifically, in this operation process, the weighted error correction mechanism dynamically adjusts the weighting parameters of the orthogonal decomposition so that the phase lag error gradually converges to a certain stable range. The output of this operation process is an error correction value that can be applied to subsequent phase correction to calibrate the overall phase of the orthogonal signal.

[0028] In step S104 , the phase of the orthogonal signal is calibrated according to the error correction value to obtain a calibrated orthogonal signal, and the calibrated orthogonal signal is subjected to delay compensation based on the filtering delay generated by the low-pass filtering process to obtain a target signal.

[0029] The filtering delay refers to the output response lag time difference caused by the low-pass filter when processing the original signal. It is used to describe the time difference between the actual signal change and the filtered output, and serves as a reference for delay compensation.

[0030] The target signal represents the signal sequence ultimately used for zero-crossing detection after error correction and time delay compensation are completed, that is, it is used as a high-precision representation of the mains signal.

[0031] For example, first, an error correction value is applied to the phase parameters of the original orthogonal signal to compensate for its time-domain representation, resulting in a calibrated orthogonal signal. This eliminates inherent deviations introduced by phase lag and signal construction methods. During this process, the error correction value is added to the phase representation of the orthogonal signal in vector form, ensuring a higher consistency between the phase accuracy and the ideal signal at each time point. The calibrated orthogonal signal exhibits a more accurate overall phase trend, with an angular evolution trend that aligns with actual signal changes. Next, considering that the initial low-pass filtering process itself introduces a fixed filter delay (i.e., the filter requires a certain response period before outputting a signal), further delay compensation is performed on the calibrated signal to compensate for the resulting time offset. This is done by comparing the time difference between the signal sampling time and the filter response time to calculate a fixed delay correction value. This delay correction is then applied to the calibrated signal to align its time base with the actual signal's time-domain progression, thereby generating a target signal with high phase accuracy and time-domain consistency.

[0032] Step S105 , obtaining a zero-crossing detection result of the mains signal according to the zero-crossing waveform corresponding to the target signal.

[0033] Among them, the zero-crossing waveform represents waveform data composed by extracting the zero-crossing features based on the critical points of positive and negative changes in the target signal. The zero-crossing features include the zero-crossing direction, slope, timing position, etc. corresponding to the critical points of positive and negative changes.

[0034] Among them, the zero-crossing point detection result represents the set of timing information corresponding to each signal polarity reversal point identified according to the zero-crossing point waveform table, which is used to characterize the instantaneous position of the mains signal changing from positive to negative or from negative to positive on the time axis, thereby providing an accurate time reference for synchronous control, trigger judgment, etc.

[0035] For example, a zero-crossing waveform analysis is performed on a target signal to obtain the zero-crossing detection result of the mains signal. Specifically, by comparing the values ​​of adjacent sampling points in the target signal, the time interval where the sign change occurs can be identified. Then, combined with interpolation methods or slope information of adjacent points, the zero-crossing point within this time interval can be precisely located. Furthermore, the trend of the target signal at several sampling points before and after the zero-crossing point can be analyzed to determine whether the point is a positive or negative zero-crossing, and the mains frequency can be estimated and tracked based on its variation period. The final zero-crossing detection result is a set of timestamp data or a flag bit sequence that indicates the zero-crossing moment of the mains signal within the sampling period and can serve as a trigger condition for subsequent control logic (such as relay control and inverter control).

[0036] Optionally, Figure 2The waveform diagrams of various signals in this embodiment are shown. The mains signal has significant glitches due to complex interference. To address high-frequency interference in the mains signal, the mains signal is low-pass filtered to obtain a filtered signal. However, this filtered signal still has low-frequency glitches and introduces a filtering delay.

[0037] Furthermore, a digital phase offset algorithm is used to generate an orthogonal signal with an expected 90-degree lag on the filtered signal. Dynamic calibration is performed on a set of orthogonal waveforms composed of the filtered signal and the orthogonal signal to eliminate the phase hysteresis error and obtain a calibrated orthogonal waveform. In this process, the periodic state value from 0 to 2π is a standardized expression of the phase characteristics of the periodic signal, which can uniformly describe, predict, and control the specific position of the AC signal in each cycle.

[0038] Furthermore, the generated calibrated orthogonal signal can, while following the filtered signal, identify and correct low-frequency glitches that cannot be eliminated by the filtering function under large interference; based on this, the calibrated orthogonal signal is filtered and delayed to obtain the target signal, and according to the phase difference relationship between the target signal and the mains signal, a zero-crossing waveform that can reflect the various zero-crossing positions of the mains signal is obtained.

[0039] Optionally, Figure 3 The figure shows a structural block diagram of a micro control unit in an embodiment, wherein the micro control unit integrates an operational amplifier module, an analog-to-digital conversion module, and a zero-crossing detection module.

[0040] The operational amplifier module represents an analog front-end circuit unit in the microcontroller unit for performing gain adjustment processing on the input signal, that is, for converting the original signal into a signal form that is adapted to the processing range of the subsequent analog-to-digital conversion module.

[0041] Among them, the analog-to-digital conversion module refers to a sampling circuit unit in the microcontroller unit for converting analog voltage signals into discrete digital signals, that is, for achieving accurate mapping from analog signals to digital signals for performing filtering, analysis or control logic.

[0042] Among them, the zero-crossing detection module refers to a functional unit in the microcontroller unit for real-time monitoring of signals and identifying the instantaneous point at which the voltage or current changes from positive to negative, or from negative to positive, that is, for providing accurate zero-crossing point judgment information as a signal source for system interruption and control triggering.

[0043] For example, Figure 3As shown, the input mains signal is a 220V sinusoidal signal. This signal is first converted into a small-signal voltage through external modulation (such as a resistor divider or an isolation transformer) and then input into the analog signal interface port of the microcontroller. Furthermore, after receiving this small signal, the operational amplifier module and the analog-to-digital conversion module first perform necessary buffering or adjustments on the small signal, such as level shifting or attenuation enhancement. The analog-to-digital conversion module then periodically samples the signal processed by the operational amplifier module, outputting a set of sampled small-signal waveforms in discrete digital form corresponding to the actual voltage changes. Furthermore, after receiving this sampled small-signal waveform, the zero-crossing detection module automatically identifies the zero-crossing point of the mains signal reflected by the sampled small-signal waveform through its internal hardware circuitry and corresponding algorithm, and outputs a corresponding zero-crossing interrupt flag. Based on this, the microcontroller, in conjunction with the zero-crossing interrupt flag and the corresponding interrupt application, precisely drives the relay on and off.

[0044] In the above-mentioned zero-crossing detection method based on the microcontroller unit, first, the mains signal is low-pass filtered to obtain a filtered signal, thereby removing high-frequency interference components and retaining stable fundamental information; secondly, an orthogonal signal corresponding to the filtered signal is constructed, and the orthogonal waveform obtained by combining the filtered signal and the orthogonal signal is analyzed, so as to accurately obtain the orthogonal decomposition amount and the angle estimation amount through the two-dimensional time series signal set constructed on the same time axis; thirdly, in the weighted error correction mechanism, weighted error correction and optimization processing are performed according to the orthogonal decomposition amount and the angle estimation amount to obtain the error correction value, thereby eliminating the systematic deviation introduced by the phase lag; thirdly, based on The orthogonal signal is phase-calibrated according to the error correction value to obtain a calibrated orthogonal signal, and the calibrated orthogonal signal is subjected to delay compensation processing according to the filtering delay to obtain a target signal, thereby ensuring the accurate correspondence of the target signal in the time domain and the phase domain. Furthermore, the zero-crossing detection result is extracted according to the zero-crossing waveform corresponding to the target signal, thereby achieving accurate positioning of the zero-crossing moment of the mains signal. Based on this, the zero-crossing detection function is integrated into the interior of the microcontroller unit, so as to achieve high-precision and low-error zero-crossing detection of the mains signal through the synergistic effects of signal filtering, waveform modeling, optimization calculation and delay compensation on the basis of high circuit integration and strong anti-interference ability.

[0045] In an exemplary embodiment, after obtaining the calibrated orthogonal signal, the method further includes step S201; based on the filtering delay generated by the low-pass filtering process, delay compensation processing is performed on the calibrated orthogonal signal to obtain the target signal, including step S202.

[0046] In step S201 , the calibrated quadrature signal is used as the quadrature signal for the next adjustment round to perform closed-loop feedback adjustment processing until a target calibrated quadrature signal having a phase lag error that satisfies a preset threshold condition is obtained.

[0047] Among them, the adjustment round refers to the number of iterative processing performed on the phase error correction of the orthogonal signal during the closed-loop feedback adjustment process, which is used to gradually reduce the phase lag error and improve the phase accuracy and timing consistency of the signal. For example, in the first round, the initial orthogonal signal is used as input for error evaluation and correction, and a new orthogonal signal is generated as input for the second round. And so on. Each error correction process is an adjustment round.

[0048] Among them, the preset threshold condition represents the error control standard used to determine whether the current phase lag error has converged to an acceptable range, and is used as a criterion for determining whether to terminate the closed-loop feedback adjustment. For example, when the phase lag error after a round of adjustment is less than the set 0.01 radians, it is considered that the current calibrated orthogonal signal meets the accuracy requirements and will no longer enter the next round of adjustment, thereby terminating the iteration and outputting the final signal result.

[0049] For example, after a preliminary calibrated orthogonal signal has been obtained, in order to further improve the accuracy of phase calibration, the calibrated orthogonal signal needs to be used as the input of the next adjustment round to perform closed-loop feedback adjustment processing, that is, to gradually reduce the phase lag error through iteration, so that the orthogonal signal finally obtained is closer to the instantaneous state of the real AC waveform in the phase dimension. In this process, first, the phase of the orthogonal signal is updated according to the error correction value obtained in the current adjustment round, that is, its phase characteristics are adjusted to make it more consistent with the theoretical orthogonal relationship, so as to obtain the calibrated orthogonal signal output in the current adjustment round; secondly, the phase hysteresis error is recalculated according to the angular relationship between the current calibrated orthogonal signal and the filtered signal, and the phase hysteresis error is used as the basis for closed-loop feedback adjustment; then, the calibrated orthogonal signal output by the current adjustment round is used as the input of the next adjustment round, that is, in the next adjustment round, the calibrated orthogonal signal output by the current adjustment round and the filtered signal are recombined into an orthogonal waveform, and the same calibration calculation and error evaluation process is re-entered to finally obtain the calibrated orthogonal signal output by the next adjustment round and the corresponding phase hysteresis error.

[0050] This process is repeated in a closed-loop fashion, gradually reducing the phase lag error with each adjustment cycle and verifying in real time whether the phase lag error is below a preset threshold corresponding to a preset threshold condition. When the phase lag error drops below the threshold after each iteration, the closed-loop adjustment process is terminated, retaining the orthogonal signal in its current state as the target calibrated orthogonal signal. This feedback control method, therefore, does not rely on external synchronization signals or require the introduction of additional complex phase-locking modules. It performs error compression entirely based on the internal phase geometry of the signal, achieving continuous improvement in accuracy while maintaining a simple system structure. Ultimately, the output target calibrated orthogonal signal is a high-fidelity phase representation signal within the control error range, whose angle and amplitude characteristics meet the timing accuracy requirements required for subsequent zero-crossing detection and control applications.

[0051] Step S202 : Based on the filtering delay generated by the low-pass filtering process, delay compensation is performed on the target calibrated orthogonal signal to obtain a target signal.

[0052] For example, to eliminate the effect of this filtering delay, two delay compensation methods can be used. One method is to select the target calibrated orthogonal signal whose final phase lag error meets the preset threshold condition after completing all adjustment rounds, and then perform a one-time delay compensation on the entire signal; the other method is to perform delay compensation on the calibrated orthogonal signal output in each round immediately after the phase adjustment process of each adjustment round, so as to ensure that the corresponding zero-crossing detection result is generated immediately in each round. Based on this, the signal obtained after delay compensation is the target signal that has restored its original consistency in time reference, eliminating the delay caused by the previous filtering from the entire detection path, so that the subsequent zero-crossing point recognition operation performed on this signal has an accurate time positioning basis, and avoids the zero-crossing moment judgment offset caused by signal lag, ensuring that the timing logic of the detection process is consistent with the control accuracy.

[0053] For example, Figure 4As shown, a low-pass filtering process is performed on the sampled small signal waveform obtained by converting the mains signal to obtain a filtered signal; a phase lag process is performed on the filtered signal to obtain an orthogonal signal; the filtered signal and the orthogonal signal are combined to obtain a set of orthogonal waveforms, and the orthogonal waveforms are subjected to dynamic orthogonal decomposition and angle estimation to obtain orthogonal decomposition quantities and angle estimates; the orthogonal decomposition quantities and angle estimates are optimized according to a weighted error correction mechanism, and the optimization results are converted into error correction values ​​suitable for the orthogonal signal expression form through an orthogonal back projection algorithm; a calibration process is performed on the current adjustment round according to the error correction value to obtain a calibrated orthogonal signal output by the current adjustment round, and the corresponding phase lag error is calculated; the calibrated orthogonal signal output by the current adjustment round is used as the orthogonal signal of the next adjustment round, and the above-mentioned orthogonal analysis and error analysis operations are repeated until a target calibrated orthogonal signal whose phase lag error meets a threshold condition is obtained; a filtering delay compensation process is performed on the target calibrated orthogonal signal to obtain a target signal; and a zero-crossing detection result of the mains signal is obtained according to the zero-crossing waveform corresponding to the target signal.

[0054] In this embodiment, first, the calibrated orthogonal signal output from each adjustment round is fed back for error calibration processing in the next adjustment round, thereby gradually reducing the phase lag error and achieving closed-loop convergence until a target calibrated orthogonal signal with a phase lag error that meets the threshold condition is obtained; secondly, filtering delay compensation processing is performed on the target calibrated orthogonal signal to ensure the synchronization accuracy of the target signal on the time axis; based on this, by introducing an error calibration mechanism based on iterative feedback and a timing compensation mechanism oriented to actual filtering delay, dual control of the phase accuracy and timing consistency of the orthogonal signal can be achieved, thereby improving the reliability of zero-crossing detection and the accuracy of time positioning.

[0055] In an exemplary embodiment, in a preset weighted error correction mechanism, based on minimizing the phase lag error generated during the phase lag processing, the orthogonal decomposition amount and the angle estimation amount are optimized to obtain an error correction value, including steps S301 to S304.

[0056] Step S301 : constructing a coordinate transformation matrix corresponding to the angle estimation value according to a conversion relationship between a preset dynamic coordinate system and a waveform coordinate system of an orthogonal waveform.

[0057] Among them, the dynamic coordinate system represents a two-dimensional rotating coordinate system that can change with time and is constructed with the current angle estimate as a reference. It is used to redefine the main direction and vertical direction of the signal vector at each sampling moment, thereby dynamically expressing the deviation state of the signal relative to the ideal phase. For example, the horizontal axis direction and vertical axis direction constructed with the current angle estimate as the rotation angle constitute the dynamic coordinate system at the current moment, where the horizontal axis direction is the instantaneous phase direction.

[0058] Among them, the waveform coordinate system represents the static Cartesian coordinate system formed by the filtered signal and the orthogonal signal in the original processing state, which is used to describe the amplitude composition relationship of the orthogonal decomposition quantity based on the standard orthogonal quadrature. For example, a two-dimensional coordinate system constructed with the filtered signal as the x-axis and the orthogonal signal as the y-axis is the waveform coordinate system. The vectors in this waveform coordinate system reflect the component relationship of the signal under a fixed phase reference.

[0059] Among them, the coordinate transformation matrix represents a two-dimensional rotation matrix used to realize the vector conversion between the waveform coordinate system and the dynamic coordinate system, and is used to rotate the orthogonal decomposition amount into the dynamic coordinate system according to the current angle estimation amount, so as to extract the error component of the signal deviating from the main phase direction in the main component of the signal.

[0060] For example, in order to achieve a unified expression of the angle estimate and the orthogonal decomposition, it is necessary to establish a dynamic coordinate system that can change with time; wherein, the waveform coordinate system of the orthogonal waveform is usually a static two-dimensional coordinate system, wherein the horizontal axis represents the amplitude of the filtered signal and the vertical axis represents the amplitude of the orthogonal signal; and the dynamic coordinate system is a coordinate system established by rotating around the current angle estimate, wherein the horizontal axis direction represents the direct axis direction and the vertical axis direction represents the quadrature axis direction. Furthermore, in order to realize the transformation of the signal vector between the two coordinate systems, a coordinate transformation matrix for value mapping can be constructed based on the correlation between the waveform coordinate system and the dynamic coordinate system; the coordinate transformation matrix can be generated based on the standard rotation transformation formula. Specifically, if the current angle estimate is θ, the corresponding coordinate transformation matrix is ​​used to linearly transform any two-dimensional vector in the waveform coordinate system according to the rotation angle θ, thereby mapping the vector to the dynamic coordinate system with θ as the direct axis direction.

[0061] This transformation essentially transfers the signal's projection from a fixed coordinate system to a new coordinate system with the current phase as the reference direction. This allows for clear geometric directional distinctions in the subsequent signal error analysis. The components along the direct axis are used to preserve the signal's principal components, while the components along the quadrature axis represent the vertical deviation between the current signal and the principal phase, i.e., the error component. The construction of this coordinate transformation matrix provides a unified measurement system based on a dynamic phase reference for subsequent steps, allowing the signal state at each moment to be measured as a deviation from the instantaneous principal direction, enabling error control to be performed accordingly. This coordinate transformation matrix is ​​updated in real time during each sampling cycle based on the recalculated angle estimate, ensuring that the coordinate transformation remains consistent with the current signal phase throughout the entire processing process, forming the geometric foundation for phase error correction.

[0062] Step S302 : Mapping the orthogonal decomposition amount to the dynamic coordinate system through the coordinate transformation matrix to obtain the coordinate axis components of the orthogonal decomposition amount in the dynamic coordinate system.

[0063] For example, the orthogonal decomposition is used as the vector to be analyzed and mapped to the dynamic coordinate system through the constructed coordinate transformation matrix. Specifically, the process is implemented by representing the current orthogonal decomposition as a two-dimensional vector in the original waveform coordinate system, and then substituting the vector into the coordinate transformation matrix for linear transformation, thereby obtaining its representation in the dynamic coordinate system. After the transformation is completed, the orthogonal decomposition is decomposed into two components in the dynamic coordinate system, one distributed along the direct axis and the other distributed along the quadrature axis. The error component in the quadrature axis direction directly reflects the degree of deviation of the current signal from the theoretical phase state, so this component can be used to characterize the current phase lag error.

[0064] Step S303 : In the weighted error correction mechanism, based on minimizing the phase lag error generated during the phase lag processing, the coordinate axis component is converged to near zero, and a weighted adjustment coefficient of the coordinate axis component is obtained.

[0065] Among them, the weighted adjustment coefficient represents a numerical factor used to adjust the weight of the error component in the dynamic coordinate system. It is used to perform differentiated correction control according to the location and phase sensitivity of the error component during the error optimization process. For example, a larger weighted adjustment coefficient is set near the zero crossing point to increase the correction strength of the phase error, while a smaller weighted adjustment coefficient is used in the peak and trough areas to reduce interference.

[0066] For example, it is necessary to minimize the phase lag error in the weighted error correction mechanism, that is, to minimize the error component in the cross-axis direction, and calculate the weighted adjustment coefficient of the coordinate axis component. Specifically, the weighted adjustment process is not a simple linear scaling, but different adjustment weights are set according to the degree of deviation of the error component in the dynamic coordinate system relative to the overall signal characteristics; for example, for the coordinate axis component near the zero point, a higher weight should be given for fine adjustment, because this is the most sensitive to phase judgment; while for the coordinate axis component far from the zero point, a lower weight is given to avoid disturbing the overall signal stability. Based on this, through this weighted method, the coordinate axis component can be gradually converged to the vicinity of the zero point during the iterative optimization process, and finally an error correction strategy with time continuity and phase consistency is formed, so that the error source is gradually weakened through weight control, so that its influence on the overall signal calibration process is effectively constrained, thereby achieving the gradual compression of the phase lag error under dynamic expression.

[0067] Step S304 , based on the conversion relationship between the dynamic coordinate system and the waveform coordinate system of the orthogonal waveform, the coordinate axis components are converted into error correction values ​​corresponding to the phase lag error according to the weighted adjustment coefficients.

[0068] For example, the coordinate axis components and their corresponding weighted adjustment coefficients obtained in the dynamic coordinate system are remapped back to the waveform coordinate system of the original orthogonal waveform and converted into an error correction value directly corresponding to the phase hysteresis error. Specifically, this process can be implemented by the inverse coordinate transformation corresponding to the orthogonal back-projection algorithm, that is, applying the opposite angle on the basis of the original rotation transformation corresponding to the coordinate transformation matrix to obtain an inverse transformation matrix, and then combining the error components in the dynamic coordinate system with the corresponding weighted adjustment coefficients as an input vector and inputting them into the inverse transformation matrix for inverse transformation processing to obtain an error correction vector in the waveform coordinate system; the direction of the error correction vector represents the phase direction for which the error should be compensated, and the amplitude represents the compensation intensity, thereby obtaining the error correction value corresponding to the phase hysteresis error.

[0069] In this embodiment, first, according to the conversion relationship between the dynamic coordinate system and the waveform coordinate system of the orthogonal waveform, a coordinate transformation matrix corresponding to the angle estimation amount is constructed, thereby realizing the rotational expression of the orthogonal waveform in the dynamic coordinate system; secondly, the orthogonal decomposition amount is mapped to the dynamic coordinate system through the coordinate transformation matrix, thereby extracting the coordinate axis components representing the main signal components and the phase error; thirdly, based on minimizing the phase lag error, the coordinate axis components are converged to near the zero point, and the weighted adjustment coefficients of the coordinate axis components are obtained, thereby realizing controllable convergence of the error components in the spatial direction; thirdly, according to the orthogonal back projection algorithm, the coordinate axis components are mapped back to the waveform coordinate system according to the corresponding weighted adjustment coefficients, thereby obtaining an error correction value with directional consistency; based on this, by constructing a dynamic coordinate axis component relationship based on the angle estimation amount to realize error accuracy control at the spatial level, it can be ensured that the phase lag error is quantitatively expressed and corrected in a consistent direction, thereby improving the geometric consistency of the signal calibration and the control stability of the error convergence.

[0070] In an exemplary embodiment, the orthogonal decomposition amount is mapped to the dynamic coordinate system through the coordinate transformation matrix to obtain the coordinate axis components of the orthogonal decomposition amount in the dynamic coordinate system, including steps S401 to S402; in the weighted error correction mechanism, based on minimizing the phase lag error generated in the phase lag processing process, the coordinate axis components are converged to near zero point to obtain the weighted adjustment coefficient of the coordinate axis components, including step S403.

[0071] Step S401: determining the in-phase component and the orthogonal component in the orthogonal decomposition.

[0072] Among them, the in-phase component represents the projection component of the orthogonal decomposition in the direction of the filtered signal in the waveform coordinate system, which is used to reflect the amplitude composition of the signal in the main phase direction in the waveform coordinate system; the orthogonal component represents the projection component of the orthogonal decomposition in the direction of the orthogonal signal in the waveform coordinate system, which is used to reflect the amplitude composition of the signal perpendicular to the main phase direction in the waveform coordinate system. For example, in order to realize the geometric transformation processing of the orthogonal decomposition in different coordinate systems, it is first necessary to clarify the two components of the orthogonal decomposition at the current moment, namely the in-phase component and the orthogonal component; among them, the in-phase component represents the amplitude projection of the orthogonal waveform in the direction of the filtered signal in the original waveform coordinate system, and the orthogonal component represents the amplitude projection of the orthogonal waveform in the direction of the orthogonal signal. These two components constitute a complete two-dimensional vector in the waveform coordinate system, which is used to express the composite state of the current orthogonal waveform.

[0073] Step S402 : Map the in-phase component and the orthogonal component to the dynamic coordinate system through a coordinate transformation matrix to obtain the direct axis component of the in-phase component and the quadrature axis component of the orthogonal component in the dynamic coordinate system.

[0074] Among them, the direct-axis component represents the component along the instantaneous phase direction in the dynamic coordinate system after the in-phase component and the orthogonal component are transformed by coordinates, which is used to reflect the main amplitude distribution of the current signal in the instantaneous phase direction; the quadrature-axis component represents the component perpendicular to the instantaneous phase direction in the dynamic coordinate system after the in-phase component and the orthogonal component are transformed by coordinates, which is used to reflect the error magnitude of the current signal deviating from the instantaneous phase direction.

[0075] Exemplarily, the in-phase component and the orthogonal component are rotated and transformed using the constructed coordinate transformation matrix to effectively map them to the dynamic coordinate system defined by the current angle estimate, so that the waveform information in the original waveform coordinate system is re-expressed as coordinate components based on the current phase; wherein the coordinate transformation matrix is ​​constructed based on the rotation angle defined by the current angle estimate, and contains a combination of cosine and sine functions for plane rotation of any vector. After the transformation is completed, the in-phase component is projected onto the direct axis direction in the dynamic coordinate system, and the orthogonal component is projected onto the quadrature axis direction perpendicular to the direct axis direction; wherein the coordinate component projected onto the direct axis direction is the direct axis component, which reflects the amplitude strength of the signal in the main direction, and the coordinate component projected onto the quadrature axis direction is the quadrature axis component, which reflects the degree of deviation of the signal in the current instantaneous phase direction.

[0076] Step S403 , in the weighted error correction mechanism, based on minimizing the phase lag error generated during the phase lag processing, the direct axis component and the quadrature axis component are converged to near zero, and a weighted adjustment coefficient corresponding to the quadrature axis component is obtained.

[0077] For example, in order to further control the influence of the quadrature axis component on the error, it is necessary to introduce a weight adjustment strategy into the weighted error correction mechanism so that the quadrature axis component can converge to the vicinity of zero in an orderly manner during the correction process, thereby effectively compressing the error. The core of this mechanism is to set an adaptive weight adjustment coefficient for the quadrature axis component according to the dynamic characteristics such as the distance between the current phase position of the signal and the zero point, the trend of the signal slope change, etc., and then adjust the weight intensity of the quadrature axis component in the subsequent error compensation calculation through the corresponding weight adjustment coefficient. In this way, it can not only strengthen the correction strength of the error in the critical phase area, but also avoid interference with the main amplitude of the signal in the non-critical area, thus forming a differentiated error control strategy. Finally, the output weighted adjustment coefficient is used as a numerical indicator of the relationship between the deviation state of the quantified signal and the adjustment strength, ensuring that the directionality, amplitude control and timing response of the error correction are highly consistent and stable.

[0078] Optionally, first, in a dynamic coordinate system, at each sampling moment, the signal's phase position within a complete cycle is determined based on the current angle estimate, thereby determining its relative distance from the theoretical zero crossing point. The closer the signal is to the zero crossing point, the more significant the impact of the signal phase change on control accuracy, and thus a higher weighted adjustment coefficient should be assigned. Furthermore, in a dynamic coordinate system, by calculating the amplitude difference of the signal at several sampling points before and after the current sampling point, its first-order derivative, i.e., the signal slope, can be estimated. If the signal slope changes significantly, indicating that the signal is in a rapid transition region, stronger error control is required, and thus a higher weighted adjustment coefficient should be assigned. If the slope changes slowly, the error impact is small, and the corresponding adjustment strength can be reduced. On this basis, by integrating the above-mentioned multiple dynamic characteristics, the quadrature axis component is dynamically evaluated to obtain the corresponding weighted adjustment coefficient, achieving refined error correction control based on region and time.

[0079] Optionally, the component mapping relationship between the waveform coordinate system and the dynamic coordinate system can refer to formula (1): (1) in, and Respectively represent the in-phase component and the orthogonal component in the waveform coordinate system, Represents an angle-based estimator The coordinate transformation matrix constructed by the sine and cosine functions, and They represent the direct axis component and the quadrature axis component in the dynamic coordinate system respectively.

[0080] In formula (1), the in-phase component in the waveform coordinate system is With orthogonal components Through the coordinate transformation matrix Mapped to the direct axis component in the dynamic coordinate system and quadrature axis component , and then use the weighted error correction mechanism to Correction is performed to minimize the phase lag error so that the quadrature axis component Converges to the vicinity of zero, and thus obtains the corresponding weighted adjustment coefficient. Then, according to the orthogonal back projection algorithm, the cross axis component And the corresponding weighted adjustment coefficient is converted into an error correction value applicable to the waveform coordinate system, so as to correct the phase of the orthogonal signal according to the error correction value.

[0081] In this embodiment, first, the in-phase component and the quadrature component in the orthogonal decomposition are determined, and the above two components are mapped to the dynamic coordinate system respectively, so as to obtain the direct-axis component and the quadrature-axis component to effectively distinguish the main component and the error component of the signal; secondly, according to the weighted error correction mechanism, the corresponding weighted adjustment coefficient is applied to the quadrature-axis component, so as to achieve differentiated convergence control of the error component in different phase regions; based on this, accurate modeling and dynamic suppression of the phase lag error are achieved, thereby improving the timing adaptability of the signal correction and the spatial targeting of the error control.

[0082] In an exemplary embodiment, the phase of the quadrature signal is calibrated according to the error correction value to obtain a calibrated quadrature signal, including steps S501 to S503.

[0083] Step S501 : calibrate the phase of the quadrature signal according to the error correction value to obtain an initial calibrated quadrature signal.

[0084] Step S502 : obtaining the historical phase variation trend, transient amplitude-phase coupling relationship, and spatial distribution consistency of the orthogonal signal according to the waveform characteristics of the orthogonal signal in each sampling period.

[0085] Among them, the waveform characteristics represent the morphological characteristics of the orthogonal signal in the time domain within a sampling period, including indicators such as amplitude change, phase evolution, and slope trend, which are used to characterize the timing structure of the current orthogonal signal.

[0086] The historical phase change trend represents the continuous evolution trajectory of the phase value of the orthogonal signal over time within a period of time before the current moment. It is used to determine the stability of the orthogonal signal's changes in time and the continuity of its phase trend. For example, if the phase of a signal rises linearly at multiple consecutive sampling points, a stable trend line can be formed.

[0087] The transient amplitude-phase coupling relationship indicates the synchronous or correlated dynamic relationship between the amplitude and phase changes of the orthogonal signal in the region of rapid signal change. It is used to identify whether the orthogonal signal has a nonlinear coupling state with phase mutation accompanied by amplitude abnormality. For example, near the zero crossing point, if the signal amplitude changes rapidly but the phase mutation is not obvious, it indicates that the phase response is lagging and there is a local deviation.

[0088] Among them, spatial distribution consistency indicates whether the geometric structure between the signal vectors composed of multiple sampling points in the complex plane maintains similar direction, consistent amplitude or symmetry characteristics. It is used to evaluate whether the calibrated signal maintains the coherence of the overall distribution structure under two-dimensional representation. For example, if the multiple sampling points after calibration are arranged in a regular circular arc in the complex plane rather than randomly scattered, it means that they have good spatial consistency.

[0089] For example, the phase of the orthogonal signal is calibrated according to the error correction value to obtain an initial calibrated orthogonal signal. At this time, the initial calibrated orthogonal signal has been aligned with the reference angle after error correction in the instantaneous phase direction, but its time continuity and structural consistency have not been uniformly constrained, so further processing is still required to improve the overall calibration accuracy.

[0090] Furthermore, to enhance the contextual coherence of subsequent calibration processing, it is necessary to extract multi-dimensional structural features such as historical phase change trends, transient amplitude-phase coupling relationships, and spatial distribution consistency based on the temporal evolution characteristics reflected by the waveform characteristics of the current orthogonal signal throughout the entire sampling period. The historical phase change trend represents the trajectory of the signal phase evolution over time at multiple consecutive sampling points, which is used to capture the phase evolution law of the signal under normal waveform conditions. The transient amplitude-phase coupling relationship is used to characterize the inherent coupling characteristics between phase and amplitude changes in rapidly changing regions, such as zero crossings or near peaks, for example, whether a sudden phase change is accompanied by a sharp amplitude fluctuation. The spatial distribution consistency refers to whether the phase state of the signal maintains structural symmetry or geometric coherence in the complex plane across different time periods or different processing regions.

[0091] Step S503 , combining the historical phase variation trend, transient amplitude-phase coupling relationship, and spatial distribution consistency of the orthogonal signal, performs multi-constraint collaborative calibration processing on the initial calibration orthogonal signal to obtain a calibrated orthogonal signal.

[0092] For example, in order to further improve the initial calibration orthogonal signal to the final calibrated state with stable structure and consistent timing, it is necessary to integrate the calibration constraints of multiple dimensions to perform multi-constraint collaborative calibration processing, that is, based on the three types of features extracted in the previous stage, namely the historical phase change trend, transient amplitude-phase coupling relationship and spatial distribution consistency, the phase state of each sampling point is comprehensively evaluated and corrected.

[0093] First, using historical phase change trends as a temporal continuity reference, smoothing phase change constraints are introduced between adjacent sampling points to avoid discontinuities or abrupt changes in the current calibration results. Then, based on the transient amplitude-phase coupling relationship, local errors that do not match the amplitude behavior are identified during the phase adjustment process. Angle fine-tuning is preferentially implemented in these areas to maintain a reasonable dynamic coupling between phase and amplitude changes. Furthermore, the vector structure of multiple sampling points is analyzed in the complex plane. By comparing their geometric symmetry and directional consistency, the spatial distribution characteristics of the entire signal are evaluated for stability. If any calibration points deviate from the overall structural trend, fine-tuning is performed through a feedback mechanism to restore their directional and amplitude consistency with surrounding points. Throughout the entire operation, each type of calibration constraint participates in the signal phase adjustment calculation as a separate function, and a unified optimization objective is constructed through weighted fusion, achieving coordinated convergence between the calibration results corresponding to each type of calibration constraint. Finally, the phase state of the initial calibrated orthogonal signal is continuously updated in an iterative manner, while minimizing the local error and taking into account the global structural stability. The output result is the calibrated orthogonal signal, which has the multiple characteristics of time continuity, amplitude and phase coordination, and spatial consistency.

[0094] In this embodiment, first, the phase of the orthogonal signal is adjusted according to the error correction value to obtain an initial calibration orthogonal signal, thereby achieving preliminary correction in the error direction; secondly, the historical phase change trend, transient amplitude-phase coupling relationship and spatial distribution consistency are extracted according to the waveform characteristics of the orthogonal signal within the sampling period, thereby providing a multi-dimensional feature constraint basis for the calibration process; thirdly, based on the multi-dimensional feature constraint basis, multi-constraint collaborative calibration processing is performed on the initial calibration orthogonal signal, so that the calibration result has temporal smoothness, local rationality and overall structural coherence; based on this, high-precision and high-stability orthogonal signal phase calibration processing is achieved, and the calibration result can be directly used as a highly reliable input basis for subsequent zero-crossing point detection and precise control.

[0095] In an exemplary embodiment, based on the filtering delay generated by the low-pass filtering process, delay compensation is performed on the calibrated orthogonal signal to obtain the target signal, including steps S601 and S602.

[0096] Step S601 : pre-constructing a delay evolution trend model for dynamic delay compensation based on the non-uniform delay response of the filter to the mains signal in different sampling periods and combining the spectrum structure characteristics and phase evolution trend of the filtered signal in different sampling periods.

[0097] Among them, non-uniform delay response refers to the filter's response behavior with inconsistent delay amplitudes to input signals with different frequency components or different sampling periods. It is used to reflect the differences in sampling point position offsets caused in the time domain during the filtering process. For example, in a sliding average filter, high-frequency signals are delayed more and low-frequency signals are delayed less, resulting in inconsistencies in the responses of various frequency bands of the signal on the time axis.

[0098] The spectral structure characteristics represent the energy distribution of each frequency component of the filtered signal within different sampling periods. They are used to analyze the frequency sensitivity of the filtering effect and thus guide the priority direction of delay compensation. For example, if the main frequency of the signal is concentrated around 50 Hz and the high-frequency clutter distribution is weak, the compensation process should focus on the main frequency band for delay compensation.

[0099] The phase evolution trend indicates how the phase of the filtered signal changes over time within continuous sampling periods. It is used to determine the phase continuity and rate of change of the signal during its time evolution. For example, if the phase continuously increases linearly, it indicates that the current signal is in a stable evolution stage, which can be used to verify whether the compensated phase maintains a reasonable change trend.

[0100] Among them, the time delay evolution trend model represents a time correction model constructed by integrating the filter structure, the spectral structure characteristics of the filtered signal and the phase evolution trend, which is used to dynamically predict and compensate for the actual time offset corresponding to each sampling point.

[0101] For example, first, when processing continuously changing mains power signals, the filter will not maintain completely consistent response characteristics in each sampling period. In particular, when the filter structure is a sliding window, weighted average or recursive form, the delay of the filter output will appear as a non-uniform time delay under the influence of different frequency components. Therefore, it is necessary to extract the non-uniform delay response reflected by the signal lag time difference caused by the filter in each sampling period based on the amplitude and phase change law of the filter's output response to the mains power signal in different sampling periods. At the same time, taking into account the fact that the spectrum energy in the actual mains power signal fluctuates over time, the amplitude distribution and phase propagation path of different frequency bands should be modeled, that is, based on the spectrum structure characteristics and phase evolution trend of the filtered signal in different sampling periods, a coupling mapping relationship between spectrum and phase is formed. Finally, a delay evolution trend model for dynamic compensation calculation is constructed based on the non-uniform delay response corresponding to the filter and the spectral structure characteristics and phase evolution trend corresponding to the filtered signal. This delay evolution trend model not only reflects the delay pattern of the filter structure in the time domain, but also introduces the coupling mapping relationship between the spectrum and phase in the frequency domain, so that it has the ability to automatically adjust the delay estimation as the signal structure changes, so as to achieve accurate delay compensation for the calibrated orthogonal signal.

[0102] Step S602 : In the delay evolution trend model, based on the filtering delay generated by the low-pass filtering process, dynamic delay compensation is performed on the calibrated orthogonal signal in combination with phase continuity constraint and spectrum weight matching to obtain a target signal.

[0103] The phase continuity constraint represents a continuity control condition introduced when performing delay compensation on the signal. It is used to avoid phase mutations or incoherence and ensure that the compensation process maintains a smooth curve characteristic for the signal phase adjustment. For example, near the zero crossing point, the calibrated signal should maintain a smooth phase transition without angle jumps or reversals.

[0104] Among them, spectrum weight matching refers to the control conditions for setting different compensation priorities for each frequency component of the signal based on the energy proportion of each frequency component. It is used to focus the compensation process on the delay correction of the main frequency or high-energy frequency band. For example, if the main frequency in the signal is 50Hz and accounts for 90%, the compensation strategy should prioritize the time accuracy of this frequency band to ensure the effectiveness of the overall detection timing.

[0105] For example, based on the established delay evolution trend model, dynamic delay compensation is performed on the calibrated orthogonal signal to obtain a target signal that is strictly aligned with the actual mains signal in terms of timing. Specifically, first, the filtering operation will cause non-uniform delay response on different frequency components. Therefore, it is necessary to accurately calculate the time alignment position to be adjusted based on the specific delay characteristics of each sampling point under the current spectrum structure and the instantaneous phase state of the calibrated orthogonal signal at that moment; on this basis, the calibrated orthogonal signal corresponding to each moment is mapped along the time axis to make it consistent with the predicted ideal time point, and the time compensation process is completed by interpolation, resampling or sliding correction. Furthermore, in order to avoid the damage to the phase continuity of the signal caused by this correction operation, a phase continuity constraint mechanism needs to be introduced to perform angle smoothing on the adjacent points before and after calibration so that the path of the phase change over time remains monotonic and consistent, thereby preventing phase jumps or abnormal jitters caused by excessive local compensation. Furthermore, given the varying importance of different frequency components in the signal energy distribution, weighted parameters are assigned to each frequency component based on the spectral amplitude structure. A spectral weight matching mechanism ensures that compensation prioritizes the precise alignment of high-energy components, thereby ensuring greater accuracy in the time domain for key information channels. Consequently, the dynamic delay compensation process ultimately outputs a target signal whose position on the time axis has been corrected to align with the actual mains signal, while preserving phase smoothness and frequency domain principal component alignment.

[0106] In this embodiment, first, based on the non-uniform delay response generated by the filter in different sampling periods, combined with the spectral structure characteristics and phase evolution trend of the filtered signal, a delay evolution trend model for dynamic delay compensation is constructed, thereby achieving accurate modeling of the multi-band delay differences caused by filtering; secondly, based on the phase continuity constraint and spectral weight matching mechanism in the delay evolution trend model, dynamic delay compensation is performed on the calibrated orthogonal signal to obtain the target signal, thereby improving the alignment accuracy and structural coherence of the target signal on the time axis, achieving high-fidelity and high-consistency time domain signal correction, and providing an accurate time basis for subsequent zero-crossing point identification.

[0107] In an exemplary embodiment, before performing low-pass filtering on the collected AC power signal to obtain a filtered signal corresponding to the AC power signal, the method further includes steps S701 to S703; after obtaining the zero-crossing point detection result of the AC power signal based on the zero-crossing point waveform corresponding to the target signal, the method further includes steps S704 to S705.

[0108] Step S701 : constructing a spectrum variation graph of the mains signal based on a time sliding window according to the processing logic of the operational amplifier module and the analog-to-digital conversion module on the mains signal and the time-frequency characteristics of the mains signal.

[0109] Among them, the time-frequency characteristics of the mains signal represent the fluctuation behavior of the mains signal in the time dimension and the energy distribution characteristics in the frequency dimension. They are used to reflect the spectral state of the mains signal at different time points under the influence of load changes, disturbances or harmonics, such as the signal's main frequency, harmonic components, and frequency time-shift characteristics.

[0110] Among them, the spectrum change diagram based on time sliding window represents a two-dimensional time-frequency evolution diagram formed by segmenting the mains signal into time windows of fixed length and performing spectrum analysis. It is used to observe and model the change trend and phase transfer structure of the frequency components of the signal in different time periods.

[0111] For example, during the acquisition of the mains signal, the operational amplifier module's amplitude adjustment and offset conversion characteristics for the original signal, combined with the periodic characteristics of the analog-to-digital conversion module's digital sampling of the analog signal, ensure that subtle disturbances in the mains signal in the time domain can be captured while maintaining sampling accuracy and dynamic range. Furthermore, to further reveal the compositional evolution of the mains signal in the frequency dimension, a time sliding window approach is used to segment the continuously sampled mains signal. The data within each sliding window is treated as a near-stationary signal, and spectral analysis is performed on it to extract the amplitude and phase of each frequency component. Furthermore, as the sliding window progresses along the time axis, a data structure correlating frequency and time is gradually constructed on a two-dimensional plane, forming a spectrum change map. In this spectrum change map, the changes in each frequency component along the time axis are represented as an evolutionary trajectory, and the relative strength, rate of change, and phase shift process between different frequency components are clearly depicted. This not only intuitively reflects the stability and main frequency distribution of the mains signal, but also further reveals the behavioral characteristics of load disturbances, harmonic interference, or nonlinear signal distortion.

[0112] Step S702 : determining a zero-crossing prediction mechanism corresponding to the mains signal according to the slope change rate of the frequency spectrum change graph.

[0113] Among them, the slope change rate of the spectrum change graph represents the derivative value of the amplitude or phase of the main frequency or key frequency component over time in the spectrum change graph constructed based on the time sliding window, which is used to reflect the intensity of the change trend of the frequency characteristics of the mains signal before it approaches the zero crossing point.

[0114] Among them, the zero-crossing prediction mechanism represents a judgment logic model established based on the slope change rate in the spectrum change graph for early identification of the city power signal about to cross zero. It is used to make trend judgments before the zero-crossing point actually occurs, so as to achieve prediction and early response control. For example, when it is detected that the slope of the main frequency amplitude is steadily decreasing, the low-frequency energy is rapidly increasing, and the phase change enters the boundary interval, it can be predicted according to the set rules that the signal is about to enter the zero-crossing section.

[0115] For example, the slope change rate of each frequency component in the spectrum change map is calculated and analyzed to determine whether the mains signal will enter the zero-crossing interval in the future time period. The analysis process mainly extracts the trend line of the frequency principal component changing with time and calculates the change rate of its first-order derivative, that is, the frequency slope, to capture the phase turning signs in the spectrum morphology. Since the zero-crossing point is essentially the instantaneous point where the AC signal crosses from positive to negative or reverse to positive, its spectrum change is often accompanied by characteristic trends before entering this area, such as a stable downward shift of the main frequency peak position, low-frequency energy accumulation or high-frequency component attenuation. By identifying these slope change signals, a corresponding zero-crossing prediction mechanism can be constructed. The zero-crossing prediction mechanism defines multiple state thresholds, judgment intervals and evolution speed matching rules in the spectrum change map, thereby predicting its future trend before the signal crosses zero, providing an early intervention window for real-time control.

[0116] Step S703 : obtaining an expected zero-crossing detection result of the mains signal according to a zero-crossing prediction mechanism corresponding to the mains signal, and generating a delay control path for relay driving according to the expected zero-crossing detection result.

[0117] The expected zero-crossing point detection result represents the predicted value of the time point at which the current mains signal state is about to cross zero based on the zero-crossing prediction mechanism, that is, the expected zero-crossing point.

[0118] Among them, the delay control path of the relay drive represents the control response path involved from the expected zero-crossing point prediction to the actual closing or opening of the relay, including the time control chain composed of signal recognition delay, calculation processing delay, execution circuit response time, etc.

[0119] For example, according to the definition of multiple state thresholds, judgment intervals and evolution speed matching rules in the zero-crossing prediction mechanism, the frequency domain characteristics of the mains power signal are analyzed, that is, the zero-crossing prediction mechanism is applied in real time in the actual signal stream to determine whether the current sampling point is in the prediction interval that is about to cross zero, and then the expected zero-crossing point detection result of the current mains power signal is generated; the expected zero-crossing point detection result represents a high-confidence zero-crossing trend judgment, rather than being equivalent to the actual occurrence time of the physical zero crossing.

[0120] On this basis, the expected zero-crossing detection results are input into the relay control path design logic. Based on the response delays of multiple stages in the time control chain, including signal sampling, data calculation, and driver loading, a delay control path for the relay's driving behavior is constructed. This delay control path is used to ensure that the control signal is synchronized with the predicted zero-crossing point at the time the relay closes or opens, so that the relay's operation falls precisely within the target zero-crossing region. Furthermore, the establishment of this delay control path requires detailed recording of the average processing time or maximum delay of each stage, and based on this, the early trigger point of the control signal is calculated forward to ensure that it is closed and matched with the predicted zero-crossing point on the time axis.

[0121] Step S704 : the zero-crossing detection module outputs a zero-crossing interrupt flag according to the zero-crossing point detection result, and the microcontroller unit generates a relay trigger timing calibration table corresponding to the relay through the zero-crossing interrupt flag.

[0122] Among them, the zero-crossing interrupt flag represents the interrupt trigger signal identifier issued by the zero-crossing detection module when it detects a zero-crossing event. It is used to interrupt the current processing flow at the moment of the zero-crossing point and execute the control logic related to the zero-crossing point. For example, when the zero-crossing point occurs, a level flip or interrupt vector is output for the microcontroller to identify and enter the interrupt processing function to execute the relay control operation.

[0123] Among them, the relay trigger timing calibration table is a time parameter table generated by the microcontroller unit according to the zero-crossing interrupt flag for accurately scheduling the relay control signal, which is used to ensure that the relay drive signal arrives at the right time to complete the closing control action.

[0124] For example, the zero-crossing detection module will perform real-time judgment on the target signal during the subsequent sampling process and generate a zero-crossing interrupt flag based on the final zero-crossing point position. The microcontroller unit uses this zero-crossing interrupt flag as an event trigger signal. By querying the pre-built delay control path and the recorded expected zero-crossing detection results, the actual timestamp of the current trigger point is recorded and compared with the historical zero-crossing record. From this, the stability of the overall system delay and the consistency of the current signal behavior are calculated. In combination with the statistical average of the response processing time, a relay trigger timing calibration table is dynamically generated. This relay trigger timing calibration table arranges the optimal closing time of the relay for multiple future cycles according to the time accuracy level, covering the time nodes and acceptable drive windows for predicting the zero-crossing point in each cycle, so that no recalculation is required during the subsequent closing process, thereby improving the operating efficiency of the control system in high-frequency alternating environments, and ensuring that the relay action has a clear, precise, and traceable timing basis, ensuring the phase consistency and behavioral stability of the control system during the AC load switching process.

[0125] Step S705 : Dynamically lock the relay's turn-on instantaneous phase according to the relay trigger timing calibration table and the timing correlation between the delay control paths to ensure that the relay is closed within the zero-crossing critical window.

[0126] The relay's instantaneous turn-on phase represents the phase position of the mains signal at the moment the relay actually closes, and is used to accurately assess whether the relay closure occurs within the expected zero-crossing phase interval.

[0127] The zero-crossing critical window represents the phase interval range set around the zero-crossing point of the mains signal within which the relay is allowed to close. It is used to limit the relay to conduct only under low-voltage or low-current conditions, thereby reducing arcing, electrical shock, and mechanical wear. For example, the phase range of ±5° from the zero-crossing point is defined as the zero-crossing critical window. The relay conduction must strictly fall within this zero-crossing critical window, otherwise the control is considered invalid or the accuracy is insufficient.

[0128] For example, to ensure that the relay's conduction behavior is strictly synchronized with the zero-crossing point of the mains power signal, it is necessary to further dynamically lock the relay's conduction instantaneous phase based on the stored relay trigger timing calibration table and delay control path, so that the relay completes closing within a small time window close to the zero-crossing point. Specifically, the microcontroller obtains the timestamp of the actual interrupt response based on the current system clock state, and combines it with the ideal trigger time point provided by the stored relay trigger timing calibration table and the delay control path to calculate the difference between the response timing of the current control signal. This difference is used to determine the time error between the relay's current conduction behavior and the ideal zero-crossing point, and the output of the control signal for the next cycle is adjusted accordingly.

[0129] Subsequently, based on the phase error mapped by the time error, the relay control signal is compensated in advance or delay in the real-time control channel of the control system, so that after the propagation, loading and physical driving processes of the control signal are completed, the mechanical contacts of the relay can complete the closing operation within the preset zero-crossing critical window, thereby effectively reducing the voltage stress and arc risk that the contacts bear during operation; based on this, by dynamically matching the prediction logic with the actual response and performing high-precision fine-tuning of the control behavior, the controllability and stability of the relay action phase are achieved, while ensuring that strict phase synchronization between the signal and the action can still be maintained in frequent switching scenarios.

[0130] In this embodiment, first, according to the processing logic of the mains signal by the operational amplifier module and the analog-to-digital conversion module, a spectrum change map is constructed in combination with the time-frequency characteristics of the mains signal in the sliding time window to completely describe the evolution trend of the time-frequency characteristics; secondly, according to the slope change rate of the spectrum change map, a zero-crossing prediction mechanism for predicting the zero-crossing point is accurately established, and the expected zero-crossing point detection result is generated according to the zero-crossing prediction mechanism, and a delay control path for relay drive is constructed, thereby realizing advance planning of the driving behavior; thirdly, a relay trigger timing calibration table is established according to the zero-crossing interrupt flag to realize dynamic optimization management of the closing timing, and then according to the correlation between the relay trigger timing calibration table and the delay control path, the conduction instantaneous phase is dynamically locked to ensure that the relay is closed within the zero-crossing critical window, thereby realizing precise closing control of the relay based on phase synchronization.

[0131] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.

[0132] Based on the same inventive concept, embodiments of the present application further provide a microcontroller-based zero-crossing detection device for implementing the aforementioned microcontroller-based zero-crossing detection method. The implementation solution provided by this device is similar to the implementation solution described in the aforementioned method. Therefore, the specific limitations of one or more microcontroller-based zero-crossing detection device embodiments provided below can be found in the above-mentioned limitations of the microcontroller-based zero-crossing detection method, and will not be repeated here.

[0133] In an exemplary embodiment, Figure 5 As shown, a zero-crossing detection device based on a microcontroller unit is provided, comprising: a filtering module 501, an orthogonal analysis module 502, an error analysis module 503, a calibration module 504 and a detection module 505, wherein: The filtering module 501 is used to perform low-pass filtering on the collected mains signal to obtain a filtered signal corresponding to the mains signal; The orthogonal analysis module 502 is configured to perform phase lag processing on the filtered signal to obtain an orthogonal signal corresponding to the filtered signal, and to perform dynamic orthogonal decomposition and angle estimation processing on the orthogonal waveform obtained by combining the filtered signal and the orthogonal signal to obtain an orthogonal decomposition amount and an angle estimation amount; The error analysis module 503 is configured to optimize the orthogonal decomposition and the angle estimation in a preset weighted error correction mechanism based on minimizing the phase lag error generated during the phase lag processing to obtain an error correction value. a calibration module 504 configured to calibrate the phase of the quadrature signal according to the error correction value to obtain a calibrated quadrature signal, and to perform delay compensation on the calibrated quadrature signal based on the filtering delay generated during the low-pass filtering process to obtain a target signal; The detection module 505 is configured to obtain a zero-crossing detection result of the mains signal according to the zero-crossing waveform corresponding to the target signal.

[0134] In an exemplary embodiment, the device also includes a closed-loop adjustment module, which is used to: use the calibrated orthogonal signal as the orthogonal signal of the next adjustment round to perform closed-loop feedback adjustment processing until a target calibrated orthogonal signal whose phase lag error meets a preset threshold condition is obtained; the calibration module 504 is also used to: based on the filtering delay generated by the low-pass filtering process, perform delay compensation processing on the target calibrated orthogonal signal to obtain the target signal.

[0135] In an exemplary embodiment, the error analysis module 503 is also used to: construct a coordinate transformation matrix corresponding to the angle estimation amount according to the conversion relationship between the preset dynamic coordinate system and the waveform coordinate system of the orthogonal waveform; map the orthogonal decomposition amount to the dynamic coordinate system through the coordinate transformation matrix to obtain the coordinate axis components of the orthogonal decomposition amount in the dynamic coordinate system; in the weighted error correction mechanism, based on minimizing the phase lag error generated in the phase lag processing process, converge the coordinate axis components to near zero point to obtain the weighted adjustment coefficient of the coordinate axis components; according to the conversion relationship between the dynamic coordinate system and the waveform coordinate system of the orthogonal waveform, convert the coordinate axis components into error correction values ​​corresponding to the phase lag error according to the weighted adjustment coefficient.

[0136] In an exemplary embodiment, the error analysis module 503 is also used to: determine the in-phase component and the quadrature component in the orthogonal decomposition; map the in-phase component and the quadrature component to the dynamic coordinate system through the coordinate transformation matrix respectively, to obtain the direct-axis component of the in-phase component in the dynamic coordinate system and the quadrature-axis component of the quadrature component in the dynamic coordinate system; in the weighted error correction mechanism, based on minimizing the phase lag error generated in the phase lag processing process, the direct-axis component and the quadrature-axis component are converged to near zero, to obtain the weighted adjustment coefficient corresponding to the quadrature-axis component.

[0137] In an exemplary embodiment, the calibration module 504 is further used to: calibrate the phase of the orthogonal signal according to the error correction value to obtain an initial calibrated orthogonal signal; obtain the historical phase change trend, transient amplitude-phase coupling relationship, and spatial distribution consistency of the orthogonal signal according to the waveform characteristics of the orthogonal signal in each sampling period; and perform multi-constraint collaborative calibration on the initial calibrated orthogonal signal in combination with the historical phase change trend, transient amplitude-phase coupling relationship, and spatial distribution consistency of the orthogonal signal to obtain a calibrated orthogonal signal.

[0138] In an exemplary embodiment, the calibration module 504 is also used to: pre-construct a delay evolution trend model for dynamic delay compensation based on the non-uniform delay response of the filter to the AC power signal in different sampling periods, combined with the spectral structure characteristics and phase evolution trend of the filtered signal in different sampling periods; in the delay evolution trend model, based on the filtering delay generated by the low-pass filtering process, the calibrated orthogonal signal is dynamically delayed by combining phase continuity constraints and spectral weight matching to obtain the target signal.

[0139] In an exemplary embodiment, the device also includes a prediction module, which is used to: construct a spectrum change map of the mains signal based on a time sliding window according to the processing logic of the mains signal by the operational amplifier module and the analog-to-digital conversion module, combined with the time-frequency characteristics of the mains signal; determine the zero-crossing prediction mechanism corresponding to the mains signal according to the slope change rate of the spectrum change map; obtain the expected zero-crossing point detection result of the mains signal according to the zero-crossing point prediction mechanism corresponding to the mains signal, and generate a delay control path for relay drive according to the expected zero-crossing point detection result; the device also includes a locking module, which is used to: the zero-crossing detection module outputs a zero-crossing interrupt flag according to the zero-crossing point detection result, and the microcontroller unit generates a relay trigger timing calibration table corresponding to the relay through the zero-crossing interrupt flag; dynamically lock the relay's conduction instantaneous phase according to the timing correlation between the relay trigger timing calibration table and the delay control path to ensure that the relay is closed within the zero-crossing critical window.

[0140] Each module in the aforementioned microcontroller-based zero-crossing detection device can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.

[0141] In an exemplary embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in any of the above embodiments when executing the computer program.

[0142] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in any of the above embodiments are implemented.

[0143] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments. In particular, any reference to memory, database, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), data processing logic devices based on quantum computing, and the like.

[0144] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0145] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.

Claims

1. A zero-crossing detection method based on a microcontroller unit, characterized in that: Applied to a microcontroller unit, the method comprises: Performing low-pass filtering on the collected mains power signal to obtain a filtered signal corresponding to the mains power signal; performing phase lag processing on the filtered signal to obtain an orthogonal signal corresponding to the filtered signal, and performing dynamic orthogonal decomposition and angle estimation processing on an orthogonal waveform obtained by combining the filtered signal and the orthogonal signal to obtain an orthogonal decomposition amount and an angle estimation amount; In a preset weighted error correction mechanism, based on minimizing the phase lag error generated during the phase lag processing, the orthogonal decomposition amount and the angle estimation amount are optimized to obtain an error correction value; Calibrate the phase of the orthogonal signal according to the error correction value to obtain a calibrated orthogonal signal, and perform delay compensation on the calibrated orthogonal signal based on a filtering delay generated in a low-pass filtering process to obtain a target signal; A zero-crossing detection result of the mains signal is obtained according to the zero-crossing waveform corresponding to the target signal.

2. The method according to claim 1, characterized in that After obtaining the calibrated orthogonal signal, the method further includes: The calibrated orthogonal signal is used as the orthogonal signal of the next adjustment round to perform closed-loop feedback adjustment processing until a target calibrated orthogonal signal with a phase lag error meeting a preset threshold condition is obtained; The method of performing delay compensation processing on the calibrated orthogonal signal based on the filtering delay generated in the low-pass filtering process to obtain the target signal includes: Based on the filtering delay generated in the low-pass filtering process, the target calibrated orthogonal signal is subjected to delay compensation processing to obtain a target signal.

3. The method according to claim 1, characterized in that In the preset weighted error correction mechanism, based on minimizing the phase lag error generated during the phase lag processing, the orthogonal decomposition amount and the angle estimation amount are optimized to obtain an error correction value, including: Constructing a coordinate transformation matrix corresponding to the angle estimation value according to a conversion relationship between a preset dynamic coordinate system and the waveform coordinate system of the orthogonal waveform; Mapping the orthogonal decomposition amount to the dynamic coordinate system through the coordinate transformation matrix to obtain the coordinate axis components of the orthogonal decomposition amount in the dynamic coordinate system; In the weighted error correction mechanism, based on minimizing the phase lag error generated in the phase lag processing process, the coordinate axis component is converged to the vicinity of zero, and the weighted adjustment coefficient of the coordinate axis component is obtained; According to the conversion relationship between the dynamic coordinate system and the waveform coordinate system of the orthogonal waveform, the coordinate axis component is converted into an error correction value corresponding to the phase lag error according to the weighted adjustment coefficient.

4. The method according to claim 3, characterized in that Mapping the orthogonal decomposition amount to the dynamic coordinate system through the coordinate transformation matrix to obtain the coordinate axis components of the orthogonal decomposition amount in the dynamic coordinate system includes: Determining an in-phase component and a quadrature component in the orthogonal decomposition; Mapping the in-phase component and the orthogonal component to the dynamic coordinate system respectively through the coordinate transformation matrix to obtain the direct axis component of the in-phase component in the dynamic coordinate system and the quadrature axis component of the orthogonal component in the dynamic coordinate system; In the weighted error correction mechanism, based on minimizing the phase lag error generated in the phase lag processing process, the coordinate axis component is converged to the vicinity of zero, and the weighted adjustment coefficient of the coordinate axis component is obtained, including: In the weighted error correction mechanism, based on minimizing the phase lag error generated in the phase lag processing process, the direct axis component and the quadrature axis component are converged to near zero, and the weighted adjustment coefficient corresponding to the quadrature axis component is obtained.

5. The method according to claim 1, wherein The calibrating the phase of the quadrature signal according to the error correction value to obtain a calibrated quadrature signal includes: Calibrate the phase of the quadrature signal according to the error correction value to obtain an initial calibrated quadrature signal; According to the waveform characteristics of the orthogonal signal in each sampling period, the historical phase change trend, transient amplitude-phase coupling relationship and spatial distribution consistency of the orthogonal signal are obtained; Combined with the historical phase change trend, transient amplitude-phase coupling relationship and spatial distribution consistency of the orthogonal signal, a multi-constraint collaborative calibration process is performed on the initial calibration orthogonal signal to obtain a calibrated orthogonal signal.

6. The method according to claim 1, wherein The method of performing delay compensation processing on the calibrated orthogonal signal based on the filtering delay generated in the low-pass filtering process to obtain the target signal includes: Based on the non-uniform delay response of the filter to the mains signal in different sampling periods, combined with the spectral structure characteristics and phase evolution trend of the filtered signal in different sampling periods, a delay evolution trend model for dynamic delay compensation is pre-built; In the delay evolution trend model, based on the filtering delay generated by the low-pass filtering process, dynamic delay compensation combining phase continuity constraint and spectrum weight matching is performed on the calibrated orthogonal signal to obtain the target signal.

7. The method according to claim 1, characterized in that Before performing low-pass filtering on the collected mains power signal to obtain a filtered signal corresponding to the mains power signal, the method further includes: According to the processing logic of the mains signal by the operational amplifier module and the analog-to-digital conversion module, combined with the time-frequency characteristics of the mains signal, a spectrum change map of the mains signal based on a time sliding window is constructed; Determining a zero-crossing prediction mechanism corresponding to the mains power signal according to a slope change rate of the frequency spectrum change graph; Obtaining an expected zero-crossing detection result of the mains signal according to a zero-crossing prediction mechanism corresponding to the mains signal, and generating a delay control path for relay driving according to the expected zero-crossing detection result; After obtaining the zero-crossing detection result of the mains signal according to the zero-crossing waveform corresponding to the target signal, the method further includes: The zero-crossing detection module outputs a zero-crossing interrupt flag according to the zero-crossing point detection result, and the microcontroller unit generates a relay trigger timing calibration table corresponding to the relay through the zero-crossing interrupt flag; According to the relay trigger timing calibration table and the timing correlation between the delay control paths, the conduction instantaneous phase of the relay is dynamically locked to ensure that the relay is closed within the zero-crossing critical window.

8. A zero-crossing detection device based on a microcontroller unit, characterized in that: Applied to a microcontroller unit, the device comprises: A filtering module is used to perform low-pass filtering on the collected mains power signal to obtain a filtered signal corresponding to the mains power signal; an orthogonal analysis module, configured to perform phase lag processing on the filtered signal to obtain an orthogonal signal corresponding to the filtered signal, and perform dynamic orthogonal decomposition and angle estimation processing on an orthogonal waveform obtained by combining the filtered signal and the orthogonal signal to obtain an orthogonal decomposition amount and an angle estimation amount; an error analysis module configured to optimize the orthogonal decomposition amount and the angle estimation amount based on minimizing the phase lag error generated during the phase lag processing in a preset weighted error correction mechanism to obtain an error correction value; a calibration module, configured to calibrate the phase of the orthogonal signal according to the error correction value to obtain a calibrated orthogonal signal, and perform delay compensation on the calibrated orthogonal signal based on a filtering delay generated during a low-pass filtering process to obtain a target signal; The detection module is used to obtain a zero-crossing detection result of the mains signal according to the zero-crossing waveform corresponding to the target signal.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Carrier communication zero crossing point detection method and device, equipment and storage medium

    CN122293249A