A parallel and off-grid seamless switching control method based on adaptive sliding mode observer

By using an adaptive sliding mode observer to seamlessly switch between grid-connected and off-grid modes, the equivalent grid-side impedance is estimated in real time, and a sliding mode error signal and adaptive boundary layer width are constructed. This solves the problems of misjudgment and process discontinuity in inverter control methods, realizes smooth switching of the inverter between grid-connected and islanded modes, and improves the stability and power quality of the system.

CN120675159BActive Publication Date: 2025-12-30SHANNENG NEW ENERGY (DONGYING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510823093.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-19
Publication Date
2025-12-30
Estimated Expiration
2045-06-19

AI Technical Summary

Technical Problem

Existing inverter control methods suffer from problems such as sensitivity to misjudgment in grid status assessment, discontinuous control flow, and fixed parameters that cannot adapt to external disturbances, leading to frequent switching and degraded power supply quality, which is particularly difficult to meet in application scenarios with high reliability requirements.

Method used

A seamless switching control method based on an adaptive sliding mode observer is adopted to achieve seamless switching between grid-connected and islanded modes of the inverter by estimating the equivalent grid-side impedance in real time, constructing the sliding mode error signal and the adaptive boundary layer width, thereby avoiding control flow interruption and sudden changes in output voltage and current.

Benefits of technology

It improves the accuracy of inverter identification of grid conditions and system stability, ensures the continuity of power quality and the smooth transition of inverter output, and is suitable for distributed generation and microgrid systems with high reliability requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120675159B_ABST
    Figure CN120675159B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of micro-grid, and further to the technical field of data acquisition control system, and discloses a parallel and off-grid seamless switching control method based on adaptive sliding mode observer.The method comprises the following steps: step 1: continuously updating the real-time estimation value of equivalent grid-side impedance by power difference value iteration logic; step 2: taking the instantaneous error between inverter output bus voltage and phase-locked loop reference voltage as the reference, forming a unique sliding mode error signal; step 3: based on the noise amplitude of voltage and current sensors calibrated in advance, obtaining the boundary layer width by fixed proportion linear weighting; step 4: calling the real-time estimation value of equivalent grid-side impedance and comparing it with the nominal grid-side impedance to obtain the impedance change, distinguishing the grid-connected mode and island mode, and keeping effective in the current control period.The present application has the advantages of simple realization, strong real-time performance, strong anti-disturbance ability and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of microgrid technology, and particularly relates to the field of data acquisition and control systems, specifically to a seamless switching control method for grid connection and off-grid operation based on an adaptive sliding mode observer. Background Technology

[0002] With the increasing prevalence of new energy and distributed generation systems, inverters, as core power electronic devices connecting the power supply side and the grid side, have become a key factor affecting power quality and system reliability due to their operational stability and switching control performance. Especially in applications such as microgrids, residential photovoltaic systems, and energy storage converters, inverters must not only operate stably under normal grid-connected conditions but also quickly and accurately enter islanded operation when the grid fails or disconnects, and seamlessly reconnect to the grid after restoration. To achieve this, the inverter control system must possess the ability to judge the grid status in real time and continuously switch between grid-connected and off-grid modes. This places higher demands on traditional control strategies and exposes a series of limitations in existing technologies.

[0003] Currently, most mainstream inverter grid-connected / off-grid control methods employ switching control strategies based on switching logic. In this approach, the controller monitors grid voltage amplitude, frequency deviation, or sudden changes in grid impedance, and combines this with predefined threshold logic to determine grid availability, switching control logic accordingly. For example, if the controller detects a grid voltage drop exceeding a set threshold, it determines a grid connection interruption and initiates islanded control mode; once the grid recovers to within acceptable limits and remains so for a period, it switches back to grid-connected control logic. This method is simple to implement and can meet basic functional requirements under traditional grid structures. However, it suffers from several significant drawbacks.

[0004] First, most existing switching control methods rely on a single or limited number of parameters for judgment, such as voltage amplitude, current phase, and grid frequency. This judgment mechanism is highly sensitive to short-term disturbances and measurement noise, and is prone to misjudgment under minor grid fluctuations or transient disturbances. This leads to frequent and unnecessary grid-connection / off-grid switching by the inverter, increasing the uncertainty of system operation and potentially causing controller overload or even power equipment failure. Second, in actual switching processes, current control strategies generally adopt a "logic switching" approach. Once a change in grid status is detected, the current control flow is immediately interrupted, and a different control logic is applied (e.g., switching from a grid-connected controller to an islanded controller). Since grid-connected and islanded controllers are typically designed as two independent structures with inconsistent current commands, voltage regulation methods, and reference parameters, jumps in output voltage or current trajectories often occur during switching. In severe cases, spikes or droops may even occur, affecting power quality and potentially damaging load equipment. This instantaneous discontinuity is unacceptable, especially in medical, telecommunications, and military load systems with stringent power quality requirements. Furthermore, some studies have attempted to introduce observers or filtering mechanisms to improve the robustness of system discrimination, such as using Kalman filtering, voltage moving average, and frequency-locked loops to smoothly identify grid conditions. However, most of these methods are based on the assumption of a linear system, making it difficult to maintain identification accuracy under conditions of strong nonlinearity, sudden changes in grid parameters, or drastic load variations. In addition, traditional observers have fixed parameters and cannot adaptively respond to external disturbances or changes in grid topology, resulting in discrimination delays or an increased probability of misjudgment. Summary of the Invention

[0005] The main objective of this invention is to provide a seamless on-grid / off-grid switching control method based on an adaptive sliding mode observer. This invention has the advantages of simple implementation, strong real-time performance, and strong anti-disturbance capability.

[0006] To solve the above problems, the technical solution of the present invention is implemented as follows:

[0007] A seamless on-grid / off-grid switching control method based on an adaptive sliding mode observer, the method comprising:

[0008] Step 1: Synchronously acquire grid-connected voltage signal and filter inductor current signal in each control cycle, continuously update the real-time estimated value of equivalent grid-side impedance through power difference iteration logic, implement upper and lower limit protection for the estimation results, and write to shared memory after the update is completed;

[0009] Step 2: Based on the instantaneous error between the inverter output bus voltage and the phase-locked loop reference voltage, add the real-time estimated value of the equivalent grid-side impedance and the impedance compensation amount generated by the grid-connected voltage signal and the filter inductor current signal, and combine it with the long-term accumulated error of the bus voltage to form a unique sliding mode error signal.

[0010] Step 3: Based on the pre-calibrated noise amplitude of the voltage and current sensors, the absolute value of the inverter output bus voltage and the absolute value of the derivative of the filter inductor current are taken in real time during operation, and the boundary layer width is obtained by linear weighting according to a fixed ratio.

[0011] Step 4: Compare the real-time estimated value of the equivalent grid-side impedance with the nominal grid-side impedance to obtain the impedance change. At the same time, calculate the amplitude deviation between the grid-connected voltage and the bus voltage. Then, generate a unique discrimination function logic value by comparing the fixed weight combination with the decision tolerance. Convert the logic value into a mode flag bit to distinguish between grid-connected mode and islanded mode, and keep it valid within the current control cycle.

[0012] Furthermore, in step 1, during each sampling period, the grid-connected voltage signal and the filter inductor current signal are sampled synchronously, ensuring that they share the same timestamp; the instantaneous power deviation is written into a circular buffer, a power memory window is set, and it is compared with the historical power deviation of the previous sampling period to obtain the power recursive difference; the power recursive difference is used to drive the iterative update logic to perform monotonically recursive correction on the real-time estimated value of the equivalent grid-side impedance, and upper and lower limit thresholds are set to prevent numerical divergence; the updated real-time estimated value of the equivalent grid-side impedance is written into the global shared memory; and a flag indicating that the real-time estimated value of the equivalent grid-side impedance has been updated is output.

[0013] Further, step 2 specifically includes: at the beginning of each control cycle, reading the inverter output bus voltage signal and the phase-locked loop reference voltage signal, calculating the difference between the two to obtain the instantaneous voltage error signal; calling the real-time estimated value of the equivalent grid-side impedance from the global shared memory, and combining it with the real-time sampled grid-connected voltage signal and the filter inductor current signal to generate an impedance compensation error signal; adding the instantaneous voltage error signal, the impedance compensation error signal, and the long-term deviation of the bus voltage accumulated through the integration channel to generate a unique sliding mode error signal; subsequently, writing the sliding mode error signal into a register unit, which maintains the same access address in grid-connected mode and islanded mode, so that the memory mapping table does not need to be rebuilt during state switching; and outputting a sliding mode error signal update completion flag.

[0014] Furthermore, step 3 specifically includes: during the power-on self-test phase, the root mean square amplitude of the voltage sensor noise and the root mean square amplitude of the current sensor noise are obtained through an experimental calibration process and stored in non-volatile memory in read-only form; secondly, during operation, the absolute value of the inverter output bus voltage and the absolute value of the derivative of the filter inductor current are read synchronously in each control cycle, and the absolute value of the bus voltage is multiplied by the root mean square amplitude of the voltage sensor noise, and the absolute value of the derivative of the inductor current is multiplied by the root mean square amplitude of the current sensor noise to obtain two noise weighted values; the two noise weighted values ​​are linearly weighted and synthesized according to a fixed ratio to generate the boundary layer width corresponding to the current control cycle, and stored in the register unit in a cyclic writing manner; and the boundary layer width update completion flag is output.

[0015] Further, step 4 specifically includes: reading the real-time estimated value of the equivalent grid-side impedance and comparing it with the nominal grid-side impedance measured during grid-connected operation to form a relative impedance change; synchronously reading the grid-connected voltage signal and the inverter output bus voltage signal, calculating their amplitude deviation to characterize the grid-connected point voltage synchronization state; linearly combining the relative impedance change and voltage amplitude deviation according to fixed weights, and comparing it with the decision tolerance pre-stored in non-volatile memory to obtain a unique discrimination function logic value; generating a mode flag bit based on the discrimination function logic value, and when the discrimination function logic value satisfies... When the grid connection condition is met, a grid connection flag is output. When the discrimination function logic value meets the islanding condition, an islanding flag is output. After outputting the grid connection flag, the following safety actions are performed synchronously: maintain the inverter output frequency and phase consistent with the grid connection voltage amplitude, lock the grid connection relay in the closed state, continuously monitor the changes in the discrimination function logic value and prohibit any unauthorized instructions from modifying the drive voltage instruction. After outputting the islanding flag, the following safety actions are performed synchronously: disconnect the grid connection relay within one control cycle, cut off the physical connection between the inverter and the public power grid, enable the islanding operation protection logic, maintain the bus voltage stability and start the local load power supply.

[0016] Furthermore, when the logic value of the discrimination function is less than or equal to zero and remains unchanged within a preset number of continuous control cycles, the grid connection condition is met, and a grid connection flag is output. When the logic value of the discrimination function is greater than zero and remains unchanged within a preset number of continuous control cycles, the islanding condition is met, and an islanding flag is output. If the logic value of the discrimination function experiences any invalid transition within a preset number of continuous control cycles, the current judgment process is cleared and the count is restarted to prevent misjudgment caused by transient disturbances or measurement noise.

[0017] Furthermore, the preset number of continuous control cycles is not less than two control cycles and not more than ten control cycles.

[0018] Furthermore, after step 4, the method further includes: synchronously reading the sliding mode error signal, boundary layer width, and mode flag bit; selecting the corresponding current command generation logic based on whether the mode flag bit is currently a grid-connected identifier or an islanded identifier; and calculating the drive voltage command in conjunction with the sliding mode compensation channel; and sending the drive voltage command to the power drive board at the end of each sampling period to ensure the continuity of voltage, current, and power at the moment of state transition.

[0019] Furthermore, at the beginning of each control cycle, the sliding mode error signal, boundary layer width, and mode flag are read synchronously. Based on the mode flag, the corresponding current command generation logic is selected. If the flag is a grid-connected identifier, the grid-connected mode current command generation logic is called, and the grid-connected current reference is obtained by superimposing the proportional channel and the sliding mode compensation channel. If the flag is an islanding identifier, the islanding mode current command generation logic is called, and the islanding current reference is obtained by superimposing the proportional channel, derivative channel, and sliding mode compensation channel. The current reference output by the selected logic is subtracted from the real-time sampled value of the inverter output current, and the result is modulated by the power stage current inner loop to obtain the drive voltage command. Simultaneously, a saturation function and boundary layer width are used to suppress chattering in the sliding mode compensation channel. The drive voltage command is sent to the power drive board in a timed trigger mode to ensure continuous amplitude and phase continuity of the drive voltage command at the moment of state transition. Before the end of the current sampling cycle, a command issuance completion flag is written to achieve seamless transition of inverter output voltage, current, and power, and to maintain the integrity and stability of the data flow and timing flow of the entire adaptive sliding mode observer control closed loop.

[0020] This invention presents a seamless grid-connected / off-grid switching control method based on an adaptive sliding mode observer, which offers the following advantages: By constructing a unified sliding mode error signal, introducing real-time estimation of equivalent grid-side impedance, and employing an adaptive boundary layer width mechanism, it achieves highly robust identification of grid conditions and continuous reconfiguration of inverter control commands. Compared with traditional logic switch-based control strategies, this invention eliminates the need to interrupt the control flow or switch control structures between grid-connected and islanded modes, avoiding instantaneous changes in output voltage, current, and power during switching, and significantly improving system stability and power quality. Through real-time updated equivalent grid-side impedance estimates, the system accurately reflects changes in external grid impedance, enabling rapid response to grid structural disturbances. The boundary layer width is adaptively adjusted according to system noise and dynamic conditions, effectively suppressing high-frequency chattering while maintaining convergence in the sliding mode approach process, thus solving the oscillation problem present in conventional sliding mode control methods. This invention employs a continuous control cycle criterion and an invalid transition clearing mechanism, improving the accuracy of grid condition identification and preventing misjudgments caused by short-term spikes or transient disturbances. The drive voltage command is continuously generated within a complete closed-loop structure, ensuring smooth control trajectory and seamless output response during state transitions. The overall solution does not rely on additional hardware or communication assistance, and boasts advantages such as unified structure, simple implementation, strong real-time performance, and strong anti-disturbance capability. It is suitable for inverter control in distributed generation, microgrids, and energy storage systems with high reliability requirements, and has promising prospects for widespread application and practical engineering value. Attached Figure Description

[0021] Figure 1 This is a schematic flowchart of a method for seamless on-grid / off-grid switching control based on an adaptive sliding mode observer, provided by an embodiment of the present invention.

[0022] Figure 2 A schematic diagram of the change curve of the real-time estimated equivalent grid-side impedance during the grid-to-island switching process provided in this embodiment of the invention;

[0023] Figure 3 This is a schematic diagram illustrating the response characteristics of the sliding mode error signal and the adaptive boundary layer width during the switching process, as provided in an embodiment of the present invention.

[0024] Figure 4 A schematic diagram illustrating the timing relationship between the logic value of the discrimination function and the mode flag bit switching;

[0025] Figure 5 This is a schematic diagram of the seamless transition waveform of the inverter output bus voltage during the grid-connected / off-grid switching process. Detailed Implementation

[0026] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0027] refer to Figure 1 A seamless on-grid / off-grid switching control method based on an adaptive sliding mode observer, the method comprising:

[0028] Step 1: Synchronously acquire grid-connected voltage signal and filter inductor current signal in each control cycle, continuously update the real-time estimated value of equivalent grid-side impedance through power difference iteration logic, implement upper and lower limit protection for the estimation results, and write to shared memory after the update is completed;

[0029] Step 2: Based on the instantaneous error between the inverter output bus voltage and the phase-locked loop reference voltage, add the real-time estimated value of the equivalent grid-side impedance and the impedance compensation amount generated by the grid-connected voltage signal and the filter inductor current signal, and combine it with the long-term accumulated error of the bus voltage to form a unique sliding mode error signal.

[0030] Step 3: Based on the pre-calibrated noise amplitude of the voltage and current sensors, the absolute value of the inverter output bus voltage and the absolute value of the derivative of the filter inductor current are taken in real time during operation, and the boundary layer width is obtained by linear weighting according to a fixed ratio.

[0031] Step 4: Compare the real-time estimated value of the equivalent grid-side impedance with the nominal grid-side impedance to obtain the impedance change. At the same time, calculate the amplitude deviation between the grid-connected voltage and the bus voltage. Then, generate a unique discrimination function logic value by comparing the fixed weight combination with the decision tolerance. Convert the logic value into a mode flag bit to distinguish between grid-connected mode and islanded mode, and keep it valid within the current control cycle.

[0032] The power difference iterative logic is essentially a self-correcting process under the constraint of energy conservation: when the actual grid-connected energy is inconsistent with the energy predicted by the real-time estimate of the current equivalent grid-side impedance, the sign and magnitude of the difference are immediately fed back to the iterative channel, thereby generating a correction amount opposite to the error direction, thus converging to the true impedance level cycle by cycle. Thanks to this self-correcting mechanism, the inverter can maintain synchronous adaptation to the external system under conditions of frequent changes in grid structure, severe load fluctuations, or measurement noise interference, without the need for manual readjustment of the controller gain. Utilizing this highly reliable real-time estimate of the equivalent grid-side impedance, the sliding mode surface construction process eliminates the direct influence of external uncertainties. By using the instantaneous error between the inverter output bus voltage and the phase-locked loop reference voltage as a benchmark, and then introducing impedance compensation and long-term accumulated error, three physically distinct and complementary information flows are synthesized into a unique sliding mode error signal.

[0033] The unique sliding mode error signal not only provides a comprehensive error metric that considers both transient and steady-state conditions, but also ensures seamless integration between grid-connected and islanded modes in its mathematical structure. This is because, under both operating environments, the physical quantities in the error expression remain synonymous and consistent, avoiding the "error disconnection" phenomenon during state transitions. To suppress the inherent high-frequency chattering of sliding mode control while maintaining convergence speed, the boundary layer width adaptive generation process is based on known voltage and current sensor noise amplitudes. During real-time operation, it reads the absolute value of the inverter output bus voltage and the absolute value of the filter inductor current derivative, and uses a linear weighting mechanism to dynamically couple sensor noise with the system, thereby dynamically adjusting the approach region size. When grid disturbances cause an increase in voltage amplitude and current derivative, the boundary layer width widens accordingly to limit high-frequency components; when operation stabilizes, the boundary layer width automatically converges to restore rapid response. This bidirectional adaptive capability ensures that sliding mode control maintains the optimal trade-off across the entire operating range.

[0034] The grid connection / disconnection criterion determination stage obtains the impedance change by comparing the real-time estimated value of the equivalent grid-side impedance with the nominal grid-side impedance. Simultaneously, it compares the grid-connected voltage with the inverter output bus voltage to obtain the amplitude deviation. These two deviations are then fused with a fixed weight and compared with a decision tolerance to generate a unique discriminant function logic value. Since the impedance change is sensitive to grid topology changes and the voltage amplitude deviation is sensitive to energy loss imbalance, the fusion of these two factors allows the discriminant function to quickly respond to grid faults such as tripping, grounding, and short circuits, while avoiding misjudgments caused by short-time harmonics or measurement glitches. The discriminant function logic value is decoded into a mode flag bit, ensuring that only one of two results—grid-connected or islanded—is generated within a control cycle, and preventing critical point oscillations through a minimum duration threshold. In the final control command reconfiguration stage, the grid-connected mode current command generation logic or the islanded mode current command generation logic is invoked based on the mode flag bit.

[0035] The grid-connected mode current command generation logic generates baseline active and reactive current components based on the target power given by the power outer loop and the synchronization angle of the phase-locked loop. It then uses a real-time estimate of the equivalent grid-side impedance for impedance feedforward decoupling to actively offset the distortion effects of grid inductive reactance and resistance on the command current. Simultaneously, it superimposes a sliding mode approach current component derived from a unique sliding mode error signal, ensuring the actual grid-connected current quickly conforms to the ideal sine curve under triple constraints with low harmonic content. The islanded mode current command generation logic constructs the islanded baseline current component based on the estimated power of the local load and the output impedance coefficient. It introduces the instantaneous rate of change of the bus voltage to generate a virtual inertia current component to improve frequency stability. This is then superimposed with the sliding mode equivalent current component to form the islanded current reference, thus maintaining a constant bus voltage even in the absence of public grid support.

[0036] The two logic circuits share the same sliding mode compensation channel and the same boundary layer width. Therefore, within the same control cycle when the mode flag changes, only the baseline current construction path and impedance processing order are rearranged, while the sliding mode remains continuous. Consequently, the drive voltage command remains continuous. This integrated hardware and algorithm synchronous switching ensures that the inverter output voltage and current waveforms are free of step jumps, spikes, and interruptions during grid-connected / off-grid transitions. Through the aforementioned chain-like collaboration, this invention not only achieves real-time adaptation to multi-source uncertainties but also establishes a complete closed-loop system from energy sensing, error measurement, chatter suppression to mode determination and command reconstruction. Ultimately, it achieves seamless grid-connected / off-grid switching of the inverter without relying on external bypasses or manual intervention, significantly improving the operational reliability and dynamic stability of distributed power systems in smart microgrids and weak grid scenarios.

[0037] refer to Figure 2 Furthermore, in step 1, during each sampling period, the grid-connected voltage signal and the filter inductor current signal are sampled synchronously, ensuring that they share the same timestamp; the instantaneous power deviation is written into a circular buffer, a power memory window is set, and it is compared with the historical power deviation of the previous sampling period to obtain the power recursive difference; the power recursive difference is used to drive the iterative update logic to perform monotonically recursive correction on the real-time estimated value of the equivalent grid-side impedance, and upper and lower limit thresholds are set to prevent numerical divergence; the updated real-time estimated value of the equivalent grid-side impedance is written into the global shared memory; and a flag indicating that the real-time estimated value of the equivalent grid-side impedance has been updated is output.

[0038] Rate of change of real-time estimated equivalent network-side impedance at time t for:

[0039]

[0040] Where T is the sampling period; v g (t) represents the grid-connected terminal voltage signal at time t; i f(t) represents the filtered inductor current signal at time t; τ is the real-time estimate of the equivalent grid-side impedance at time t; τ is the power memory window; ξ is the integration time variable; v g (ξ) represents the grid-connected terminal voltage signal at time ξ; i f (ξ) represents the filtered inductor current signal at time ξ.

[0041] refer to Figure 3 Furthermore, step 2 specifically includes: at the beginning of each control cycle, reading the inverter output bus voltage signal and the phase-locked loop reference voltage signal, calculating the difference between the two to obtain the instantaneous voltage error signal; calling the real-time estimated value of the equivalent grid-side impedance from the global shared memory, and combining it with the real-time sampled grid-connected voltage signal and the filter inductor current signal to generate an impedance compensation error signal; adding the instantaneous voltage error signal, the impedance compensation error signal, and the long-term deviation of the bus voltage accumulated through the integration channel to generate a unique sliding mode error signal; subsequently, writing the sliding mode error signal into a register unit, which maintains the same access address in grid-connected mode and islanded mode, so that the memory mapping table does not need to be rebuilt during state switching; and outputting a sliding mode error signal update completion flag.

[0042] When the controller clock reaches the start edge of a new control cycle, it latches the two voltage data streams to the same timestamp via a double-buffered sampling register, and then immediately performs differential calculations to obtain the instantaneous voltage error signal. Since the inverter output bus voltage signal directly reflects the actual power stage voltage while the phase-locked loop reference voltage signal represents the ideal synchronization trajectory, the difference between the two becomes the most direct quantitative means of assessing the degree of output deviation. Next, the controller reads the latest real-time estimate of the equivalent grid-side impedance from the global shared memory and calls upon the grid-connected voltage signal and the filter inductor current signal within the current sampling window, using a combination of hardware multipliers and adders to generate an impedance compensation error signal.

[0043] The impedance compensation error signal dynamically offsets the additional errors introduced by changes in external grid impedance, enabling the sliding mode observer to maintain high sensitivity to internal system variables even under structural uncertainty. Simultaneously, the long-term operating integral channel continuously accumulates the historical deviation of the inverter output bus voltage, forming a long-term bus voltage deviation. This deviation is processed by a digital integrator and maintains the same dimensions as the previous two error information types. The instantaneous voltage error signal, impedance compensation error signal, and long-term bus voltage deviation are then added in a fixed order in the adder network, outputting a unique sliding mode error signal. This unique sliding mode error signal contains both high-speed transient information and low-speed steady-state information, and adaptively compensates for external grid impedance disturbances in real time. Therefore, it can be directly used for the sliding mode reaching law in both grid-connected and islanded modes without switching formulas or channels, fundamentally ensuring the consistency of the algorithm during grid-connected / off-grid switching. The controller writes the sliding mode error signal into a dedicated register unit. This register unit uses the same physical address for both grid-connected and islanded modes at the hardware address mapping level to eliminate the additional latency and potential data misreading risks caused by address remapping during mode switching.

[0044] The sliding mode error signal σ(t) at time t is:

[0045]

[0046] Among them, v o (t) represents the real-time sampled value of the inverter output bus voltage; v * (t) represents the reference voltage for the synchronous output of the phase-locked loop; C f For output filter capacitor; L f For filter inductance; R v η is the virtual damping resistor used to construct the voltage integral control channel; η is the historical time variable in the integral channel.

[0047] The construction principle of σ(t) is based on two ideas: energy conservation and dynamic compensation. It couples the instantaneous, impedance correlation, and long-term deviation between the inverter output and the PLL reference into a single error signal through three complementary information flows. In a high-speed path, The output filter capacitor's charge response to voltage changes is represented by C. f Equivalently, this is a scaling factor that maps instantaneous voltage differences to current. The controller approximates the differential operator in the digital domain using a first-order forward differential approach, supplemented by a bandpass filter to suppress high-frequency noise in the measurement. This makes this channel extremely sensitive to sharp disturbances, enabling it to capture even the smallest sudden changes in bus voltage during early grid-connected / off-grid switching. In the second medium-speed path... Through the filter inductor L f Establish voltage-current coupling, Updated in real time by an adaptive sliding mode observer, in conjunction with the grid-connected voltage v g(t) and inductor current i f (t) An impedance compensation term is generated, which offsets the phase lag and amplitude distortion caused by external grid impedance and line impedance, thereby maintaining the same phase error standard between grid-connected and islanded modes. The controller uses a hardware multiplier to calculate... Then with v o (t) and v g (t) Perform addition and subtraction, and the result is proportionally scaled by the shift register to ensure that the calculation delay is less than half of the sampling period. Third low-speed path Through virtual damping resistor R v Integral memory for voltage balancing is introduced. η integrates from system startup to the current time using a recursive summation accumulator. The accumulator periodically performs anti-overflow scaling to ensure distortion-free operation over long periods. The three paths are added in a fixed timing sequence within the arithmetic logic unit and simultaneously written to a unified register to generate a unique σ(t). The register address is completely consistent in both grid-connected and islanded modes; hardware decoding does not depend on the mode flag, avoiding address remapping delays during state transitions. The generated σ(t) triggers an update completion flag, which is broadcast via an event chain to the boundary layer width adaptive submodule and the control instruction reconstructing submodule, ensuring that subsequent control laws read the latest error information within the same sampling window. Through the above implementation, the sliding surface shares the same structure and register path in different modes, achieving algorithm-level "seamless" characteristics; the instantaneous differential component provides fast disturbance response capability, the impedance compensation component provides external uncertainty isolation capability, and the integral component provides steady-state zero-difference correction capability. The synergy of these three components enables the grid-connected and off-grid seamless switching control method based on the adaptive sliding mode observer to maintain the smoothness of the inverter output voltage and current curves, avoid spikes and steps, and achieve truly seamless dynamic transition even when grid impedance changes, load impacts, and measurement noise coexist.

[0048] refer to Figure 4 Furthermore, step 3 specifically includes: during the power-on self-test phase, the root mean square amplitude of the voltage sensor noise and the root mean square amplitude of the current sensor noise are obtained through an experimental calibration process and stored in non-volatile memory in read-only form; secondly, during operation, the absolute value of the inverter output bus voltage and the absolute value of the derivative of the filter inductor current are read synchronously in each control cycle, and the absolute value of the bus voltage is multiplied by the root mean square amplitude of the voltage sensor noise, and the absolute value of the derivative of the inductor current is multiplied by the root mean square amplitude of the current sensor noise to obtain two noise weighted values; the two noise weighted values ​​are linearly weighted and synthesized according to a fixed ratio to generate the boundary layer width corresponding to the current control cycle, and stored in the register unit in a cyclic writing manner; and the boundary layer width update completion flag is output.

[0049] The controller keeps the power stage bridge arm off and injects a stable reference voltage into the inverter's DC bus through the bypass voltage regulator module. Then, under static conditions with no load and no grid-side disturbances, it continuously acquires the output waveforms of the voltage sensor and current sensor. The root mean square amplitude of the voltage sensor noise and the root mean square amplitude of the current sensor noise are calculated using window accumulation and square averaging algorithms, respectively. To prevent the loss of calibration results due to debugging or power outage restarts, the controller immediately stores the two noise characteristic data points in read-only format in non-volatile memory after completing the calculations. Verification and write protection logic ensure that no subsequent program can overwrite or tamper with this static data. After the system enters normal operation, the sampling logic is synchronously triggered by a time-base interrupt in each control cycle. At the same time, the absolute value of the inverter output bus voltage and the absolute value of the filter inductor current derivative are latched to ensure data consistency and timestamp uniformity.

[0050] Subsequent multiplication operations are performed in parallel within the hardware multiplier. The absolute value of the bus voltage is multiplied by the root mean square amplitude of the voltage sensor noise to generate the first noise weighting value, while the absolute value of the inductor current derivative is multiplied by the root mean square amplitude of the current sensor noise to generate the second noise weighting value. Since the two noise weighting values ​​have the same dimensions and meaning, the controller uses a fixed-point multiplier to output a data frame in a unified format for easy access in subsequent calculations. Addressing the fact that the weights of voltage and current on chattering vary under different operating conditions, the controller presets a set of fixed proportional coefficients in the configuration area. Through adders and shifters, it performs linear weighted synthesis of the two noise weighting values, thereby adaptively obtaining the boundary layer width for the current control cycle. When load changes or grid-side disturbances cause an increase in the absolute value of the bus voltage, the boundary layer width increases accordingly to mitigate high-frequency oscillations in the sliding mode compensation term. When the inverter operates in the steady-state low-noise region, the boundary layer width automatically shrinks, making the sliding mode approach the ideal switching surface more closely and improving the error convergence speed. The synthesized boundary layer width is stored in the register unit through a cyclic write method. To avoid differences in address mapping between the grid-connected mode and the islanded mode, the register unit adopts an on-chip dual-port storage structure in the hardware design. The two ports correspond to the grid-connected logic and the islanded logic, but share the same physical storage bit, ensuring that the two modes obtain consistent content when reading the boundary layer width.

[0051] The circular write strategy utilizes a write pointer that increments in a fixed-depth circular queue, automatically making the previously written content a backup for the next read. This saves refresh time and ensures that the write can be rolled back to the previous valid value in case of abnormalities. Once the register cell write is complete, the controller sets a boundary layer width update completion flag. This flag is broadcast to the sliding mode approach module and the control command reconfiguration module via the on-chip event chain bus. The boundary layer width read by both modules within the same control cycle is the latest value, thus eliminating the need for additional synchronization. If the downstream module does not detect the update completion flag within a specified time limit, the system safety monitoring unit will trigger a degradation mode to prevent chattering malfunctions caused by boundary layer width stagnation due to register cell failure or bus congestion. Through this process, the boundary layer width adaptive generation stage embeds the root mean square amplitude of the voltage sensor noise and the root mean square amplitude of the current sensor noise obtained from static calibration into the real-time operating path, instantaneously coupling the noise characteristics with the system dynamics, achieving an optimal trade-off for chattering in sliding mode control across the entire time scale.

[0052] The boundary layer width Δ(t) at time t is:

[0053]

[0054] Where, N v The root mean square noise amplitude of the voltage sensor was obtained through experimental calibration; N i The root mean square noise amplitude of the current sensor was obtained through experimental calibration.

[0055] refer to Figure 5 Furthermore, step 4 specifically includes: reading the real-time estimated value of the equivalent grid-side impedance and comparing it with the nominal grid-side impedance measured during grid-connected operation to form a relative impedance change; synchronously reading the grid-connected voltage signal and the inverter output bus voltage signal, calculating their amplitude deviation to characterize the grid-connected point voltage synchronization state; linearly combining the relative impedance change and voltage amplitude deviation according to fixed weights, and comparing it with the decision tolerance pre-stored in non-volatile memory to obtain a unique discrimination function logic value; generating a mode flag bit based on the discrimination function logic value, and when the discrimination function logic value is satisfied... When the grid connection conditions are met, a grid connection flag is output. When the discrimination function logic value meets the islanding conditions, an islanding flag is output. After outputting the grid connection flag, the following safety actions are performed synchronously: maintain the inverter output frequency and phase consistent with the grid connection voltage amplitude, lock the grid connection relay in the closed state, continuously monitor the changes in the discrimination function logic value and prohibit any unauthorized instructions from modifying the drive voltage instruction. After outputting the islanding flag, the following safety actions are performed synchronously: disconnect the grid connection relay within one control cycle, cut off the physical connection between the inverter and the public power grid, enable the islanding operation protection logic, maintain the bus voltage stability and start the local load power supply.

[0056] In the seamless switching control method for grid connection and off-grid operation based on an adaptive sliding mode observer, the mode determination thread executes dual-channel data acquisition from the moment the system clock is triggered. First, it synchronously reads the real-time estimated value of the equivalent grid-side impedance in a dedicated bus. Then, it retrieves the nominal grid-side impedance recorded during the power-on calibration phase from the non-volatile memory. The two values ​​are then differentially divided by a subtractor and scaled to obtain the relative impedance change. This change reflects the dynamic fluctuations of the external grid impedance as a percentage, quickly revealing anomalies such as rising public grid line impedance, cable faults, or grid connection point disconnections. Next, the sampling controller latches the grid-connected voltage signal and the inverter output bus voltage signal in the same time slot. After the amplitude calculation unit extracts the effective values, the two signals undergo absolute difference calculation, outputting the voltage amplitude deviation, which measures the grid connection point voltage synchronization status with millimeter-volt precision.

[0057] The relative change in impedance and the voltage amplitude deviation are then fed into a linear combiner, where they are normalized and superimposed according to fixed weights to form a comprehensive deviation index on a single scale. The weight values ​​are set during the overall commissioning phase based on grid characteristics and load sensitivity, and written to a readable but not writable configuration register to ensure they are not tampered with during operation. The comprehensive deviation index enters a comparator, which compares it with a decision tolerance, outputting a unique discriminant function logic value. The decision tolerance is also stored in non-volatile memory, its value determined by the upper limit of impedance and voltage deviation allowed by the grid connection standard, balancing error detection sensitivity and the risk of misjudgment. When the discriminant function logic value is less than or equal to zero, the decoder interprets it as meeting the grid connection conditions and immediately writes a grid connection flag into the mode register; if the discriminant function logic value is greater than zero, the decoder writes an islanding flag. The mode register has a single-write exclusive lock, allowing only one flag to exist at any given time, supplemented by a hardware anti-jitter delay window, allowing the flag to flip only after verifying the same discrimination result for multiple consecutive sampling cycles, fundamentally avoiding high-frequency jitter near the threshold.

[0058] Once the system outputs a grid-connected flag, the synchronous safety action logic immediately freezes the inverter's internal phase-locked loop gain, aligning the output frequency with the grid-connected voltage amplitude. The hardware daemon locks the grid-connected relay in its closed state and simultaneously enables a dynamic permission table to prevent any unauthorized process from modifying the drive voltage command until the discrimination function logic value changes and is confirmed through the debouncing window. If an islanding flag is output, the grid-connected relay is opened by a hardware interrupt within the current control cycle, physically isolating the inverter from the public grid. Subsequently, the power outer loop is quickly switched to the islanding operation protection logic. The power is estimated based on the local load, and the current reference is used to maintain bus voltage stability. Simultaneously, the energy storage management interface is activated to supply local loads, ensuring continuous power supply. To avoid energy backflow or bus voltage drop during switching, the islanding operation protection logic preloads virtual inertia support and pre-biases the inverter output phase before the relay opens, minimizing the voltage difference between the inverter and the grid at the moment of disconnection. The entire mode determination and safety action process is completed in a single-cycle closed loop. The relative impedance change and voltage amplitude deviation are updated based on real-time data, ensuring that the discrimination function logic value reflects the instantaneous operating conditions. Through multiple measures such as hardware latching, read-only parameters, weight solidification, and anti-jitter delay, this solution achieves unique constraint on the mode flag bit, enabling the inverter to smoothly transition between grid-connected and islanded states without ambiguous judgment. It not only maintains the continuity of output voltage waveform and phase, but also avoids the propagation of external faults to the local system through rapid isolation and virtual inertia support, thus comprehensively improving the operational safety level and dynamic stability performance of distributed power sources.

[0059] The discriminant function χ(t) at time t is:

[0060]

[0061] Among them, Z g,nom The nominal grid-side impedance measured under normal grid-connected operating conditions; V sync This is the synchronization tolerance voltage amplitude, used to normalize voltage deviation, and is generally set according to power grid standards; ε c The preset discrimination tolerance is used to set the switching sensitivity threshold; t is the current control time; when χ(t)≤0, it is determined to be in grid-connected mode; when χ(t)>0, it is determined to be in islanded mode.

[0062] Furthermore, when the logic value of the discrimination function is less than or equal to zero and remains unchanged within a preset number of continuous control cycles, the grid connection condition is met, and a grid connection flag is output. When the logic value of the discrimination function is greater than zero and remains unchanged within a preset number of continuous control cycles, the islanding condition is met, and an islanding flag is output. If the logic value of the discrimination function experiences any invalid transition within a preset number of continuous control cycles, the current judgment process is cleared and the count is restarted to prevent misjudgment caused by transient disturbances or measurement noise.

[0063] To avoid misjudgments caused by transient disturbances or measurement noise affecting the discriminant function logic value near the threshold, the controller employs a dual-counting window mechanism in the hardware decision-making link. First, the discriminant function logic value is written to the decision register immediately after calculation, simultaneously triggering a counter to record the number of consecutive holding times of this result in subsequent sampling. If the discriminant function logic value is less than or equal to zero, counter A enters an incrementing state; if the discriminant function logic value is greater than zero, counter B enters an incrementing state. The two counters operate mutually exclusively, allowing only one counter to increment within the same control cycle. When the value of any counter reaches the preset number of consecutive control cycles, the controller immediately determines that the current operating state meets the corresponding condition: if counter A reaches the threshold, it outputs a grid-connected flag; if counter B reaches the threshold, it outputs an islanding flag. To prevent incorrect accumulation of reverse transitions in the discriminant function logic value introduced by short-term glitches or sudden harmonics, the system configures a monitoring threshold for each counter. Once an invalid transition of reverse direction or excessive amplitude of the discriminant function logic value is detected during counting, a clearing logic is immediately triggered, clearing the current decision-making process and re-counting. This reset logic not only resets the counter itself but also delays and locks the decision register for several sampling cycles to ensure that the new counting process restarts on a completely stable data basis. The preset number of continuous control cycles is obtained through whole-machine testing, taking into account both detection sensitivity and false judgment probability, and is written to a read-only configuration register, prohibiting modification during runtime. Relying on this dual-counting window and invalid transition clearing strategy, the logic value of the discrimination function must remain consistent within a sufficiently long continuous time window to trigger the grid connection flag or islanding flag output. Any invalid transition will cause the counter to return to zero and start counting again, thus effectively filtering out errors caused by transient disturbances and measurement noise. The entire process is implemented in a hardware state machine. The comparator output, counter accumulation, reset logic, and mode register write operation are all completed in a single cycle without increasing the decision delay. At the same time, the mode register is still protected by a single-write exclusive lock to ensure that the grid connection flag and islanding flag exist mutually exclusively. With the help of this mechanism, this method realizes soft transition determination in the edge range between grid-connected mode and islanded mode. Even if the logic value of the discrimination function hovers near the threshold for a long time, frequent switching can be avoided by recounting, ensuring the continuous stability of inverter output voltage and current, and further improving the reliability and safety margin of seamless switching between grid and off-grid.

[0064] Furthermore, the preset number of continuous control cycles is not less than two control cycles and not more than ten control cycles.

[0065] When the number of continuous control cycles is less than two, the discrimination function logic value only needs to be sampled twice in a very short time to trigger mode switching. However, transient glitches caused by grid harmonics, electromagnetic interference, and sampling jitter can often cause reverse jumps within one control cycle. If real-time counting is performed without delay, the probability of misjudgment will be significantly increased. When the number of continuous control cycles is greater than ten, counter A or counter B must increase in one direction for a longer time window to trigger the grid connection flag or islanding flag. This will directly delay the grid-off switching response, causing the inverter to lose its advantage in the early stages of external fault propagation. Through experimental statistics, when the value is between two and ten, the dual requirements of sensitive response and anti-glitch capability can be met simultaneously. Therefore, this range has been solidified as a product-level parameter. The preset number of continuous control cycles is written to the read-only configuration register by the configuration script in the factory debugging software. It is automatically loaded after the firmware is powered on and cannot be modified during runtime. If the field application has special requirements for grid fluctuation characteristics and load disturbance frequency, it can be reprogrammed in maintenance mode through an authorized encrypted interface, but it is still subject to the boundary limit of two to ten to prevent it from being set to extreme values ​​that could cause system instability. After reading this parameter, the hardware counter logic initializes the increment limit in a synchronous reset manner. Whenever the counter increments to the limit, a mode register write operation is triggered. If a reverse jump in the discrimination function logic value is captured midway, it will immediately trigger a reset and start counting from zero again, ensuring that the grid connection flag or islanding flag is only truly output when the discrimination function logic value continuously maintains the same sign within the stable window. This design makes the preset number of continuous control cycles a quantifiable adjustment handle between judgment sensitivity and safety margin, while boundary constraints ensure that the adjustment space is not compromised and that the speed and reliability required for seamless off-grid switching are achieved.

[0066] Furthermore, after step 4, the method further includes: synchronously reading the sliding mode error signal, boundary layer width, and mode flag bit; selecting the corresponding current command generation logic based on whether the mode flag bit is currently a grid-connected identifier or an islanded identifier; and calculating the drive voltage command in conjunction with the sliding mode compensation channel; and sending the drive voltage command to the power drive board at the end of each sampling period to ensure the continuity of voltage, current, and power at the moment of state transition.

[0067] In the control closed loop of the on-grid / off-grid seamless switching control method based on an adaptive sliding mode observer, after the mode determination phase is completed, the scheduler immediately broadcasts a synchronization trigger to the instruction reconstruction thread, enabling the thread to simultaneously read the sliding mode error signal, boundary layer width, and mode flag within the computation window of the current sampling period. The read operation is completed via the on-chip direct data bus. The sliding mode error signal is written to the register unit early in the same period by the sliding surface construction phase, the boundary layer width is cyclically written to the register unit by the boundary layer width adaptive generation phase, and the mode flag is written to the mode register by the mode determination thread under hardware latching. All three have single-write, multi-read attributes, ensuring data version consistency during reading.

[0068] The instruction refactoring thread first decodes the mode flag. If the mode flag is a grid-connected identifier, the grid-connected mode current command generation logic is scheduled according to the design. If the mode flag is an islanded identifier, the islanded mode current command generation logic is initiated. The grid-connected mode current command generation logic calls the phase-locked loop synchronization angle based on the active and reactive power targets output by the power outer loop. It generates baseline active and reactive current components through the proportional channel. Then, it performs impedance feedforward decoupling using the real-time estimated value of the equivalent grid-side impedance to preemptively offset the impact of grid impedance changes on the current phase and amplitude. The sliding mode error signal is then mapped to a sliding mode compensation current component through the sliding mode compensation channel, and the high-frequency suppression of this component is performed using the boundary layer width. The islanded mode current command generation logic generates the islanded baseline current component based on the estimated power of the local load and the output impedance coefficient. It reads the instantaneous change rate of the bus voltage to construct a virtual inertia current component, and similarly superimposes the sliding mode compensation current component and implements boundary layer width limiting. Both current command generation logics ultimately output a single current reference value. This value enters the inner current loop fast comparator and is subtracted from the real-time sampled current. The difference is then used by the digital controller to generate the modulation duty cycle, which is then synthesized into the drive voltage command. Since the sliding mode compensation channel and boundary layer width maintain the same mathematical structure in both modes, the impact of the switching of the baseline current component on the amplitude and phase continuity of the overall drive voltage command is strictly constrained, ensuring that the inverter output voltage and current do not exhibit a step within the same sampling period of mode switching.

[0069] To further prevent numerical spikes, the drive voltage command undergoes a first-order slack-limiting filter before being issued. This filter's time constant is less than half a sampling period, smoothing out spikes without delaying the main dynamics. After all calculations are completed, the thread calls the isolated communication interface at the end of the sampling period to write the drive voltage command into the power driver board's duty cycle register. The power driver board then updates the pulse width modulation signal in the next carrier cycle and applies it to the inverter bridge arm. If a change in the mode flag is detected within the entire sampling window, the thread immediately reloads the corresponding current command generation logic and recalculates the drive voltage command in the current cycle, achieving instantaneous response to legitimate transitions after hysteresis debouncing. Through this instruction reconstruction mechanism combining synchronous reading, branch selection, sliding mode compensation, and slack-limiting filtering, this invention ensures the continuity and smoothness of voltage, current, and power trajectories during switching between grid-connected and islanded modes in any direction. This avoids energy spikes and inverter instability caused by inconsistent logic switching points or data asynchrony in traditional solutions, ultimately achieving truly seamless grid-connected / off-grid switching.

[0070] The driving voltage command u(t) at time t is:

[0071]

[0072] Wherein, the adaptive sliding mode gain γ(t) at time t is:

[0073]

[0074] The meanings of the parameters in the formula are as follows:

[0075] Among them, v * (t) represents the reference voltage output by the phase-locked loop, which serves as the target for voltage trajectory tracking. γ(t) is the derivative of the reference current, calculated from the outer loop control target; γ(t) is the adaptive gain of the sliding mode approach control term, whose magnitude is dynamically adjusted according to the equivalent network impedance; sat(·) is the saturation function, used to limit the amplitude of the sliding mode approach term and suppress chattering.

[0076] The drive voltage command u(t) achieves real-time modulation of the inverter arm duty cycle through the coordinated action of three variables, enabling the seamless switching control method based on adaptive sliding mode observers to maintain the continuity of voltage, current, and power trajectories when switching between grid-connected and islanded modes. The first term v * (t) The reference voltage signal is directly taken from the output of the phase-locked loop (PLL) to ensure that the voltage waveform at the drive end is synchronized with the power grid or consistent with the virtual synchronization source inside the island; since the phase of the PLL remains continuous during mode switching, v * (t) provides a global phase anchor point for the voltage trajectory. The second term... By filter inductor L fThe difference between the current derivatives constitutes the feedforward compensation for the inductor voltage drop. The real-time current change rate is obtained by taking the difference between adjacent sampled values ​​using numerical differentiation. The reference current change rate is derived for the outer loop control target. The difference between the two represents the instantaneous magnitude of the inner loop current error in the differential domain. This error is multiplied by L. f This is then presented as an inductor-induced voltage that must be canceled out, thereby suppressing high-frequency phase lag in the current closed loop and improving the transient response speed during grid-connected / off-grid switching. (Third item) Let σ(t) be the sliding mode approaching component, where σ(t) originates from the unique sliding mode error signal, and Δ(t) is the boundary layer width. The ratio of σ(t) to Δ(t) forms the approaching term through the saturation function sat(·). The boundary layer width limits the amplitude of the approaching term to suppress chattering. Adaptive sliding mode gain. Real-time estimate of equivalent network side impedance Dynamic changes: When operating in parallel with the grid and the impedance of the public power grid is low, When the value is small, γ(t) decreases accordingly, the approach velocity decreases but the chattering suppression is enhanced; when the system enters islanding mode or the grid impedance increases, As the value increases, γ(t) is enhanced to maintain rapid error convergence, while the filter capacitor C... f The equivalent voltage support capability is obtained through the denominator. The gain is further adjusted to ensure energy consistency across different filter configurations. The instruction generation thread performs the above three calculations at the beginning of each control cycle and summarizes the results into a single u(t) value. Then, a limiter checks if the drive voltage instruction is out of bounds. If it is, it is truncated according to the maximum hardware duty cycle limit to prevent power stage saturation. The verified u(t) is written to the duty cycle register of the power drive board at the end of the sampling cycle. The power drive board refreshes the pulse width modulation pulse in the next carrier cycle, ensuring that the inverter arm voltage physically conforms to the new target. Since v * (t), σ(t), Δ(t) and All parameters are updated synchronously within the same cycle, and the sliding mode compensation channel and boundary layer width adaptive mechanism remain completely consistent between grid-connected and islanded modes. When the mode flag flips, the drive voltage command only changes the baseline current derivation path and gain value without causing amplitude-phase discontinuity, thus ensuring the continuity and smoothness of the inverter output voltage, current, and power. The entire set of formulas is implemented using hardware parallel arithmetic logic, with a single-cycle delay of no more than one-third of the master clock cycle, providing sufficient time budget for rapid switching. At the same time, all parameters are stored in register mapping mode and can be read in real time by the diagnostic interface, facilitating closed-loop performance evaluation and fault analysis during field operation.

[0077] Furthermore, at the beginning of each control cycle, the sliding mode error signal, boundary layer width, and mode flag are read synchronously. Based on the mode flag, the corresponding current command generation logic is selected. If the flag is a grid-connected identifier, the grid-connected mode current command generation logic is called, and the grid-connected current reference is obtained by superimposing the proportional channel and the sliding mode compensation channel. If the flag is an islanding identifier, the islanding mode current command generation logic is called, and the islanding current reference is obtained by superimposing the proportional channel, derivative channel, and sliding mode compensation channel. The current reference output by the selected logic is subtracted from the real-time sampled value of the inverter output current, and the result is modulated by the power stage current inner loop to obtain the drive voltage command. Simultaneously, a saturation function and boundary layer width are used to suppress chattering in the sliding mode compensation channel. The drive voltage command is sent to the power drive board in a timed trigger mode to ensure continuous amplitude and phase continuity of the drive voltage command at the moment of state transition. Before the end of the current sampling cycle, a command issuance completion flag is written to achieve seamless transition of inverter output voltage, current, and power, and to maintain the integrity and stability of the data flow and timing flow of the entire adaptive sliding mode observer control closed loop.

[0078] In the on-grid / off-grid seamless switching control method based on adaptive sliding mode observers, to ensure the continuous stability of the control link during state switching, the system controller is triggered by the master clock to synchronously sample at the beginning of each control cycle. First, it simultaneously reads the sliding mode error signal, boundary layer width, and mode flag from the registered resources. This synchronous reading is coordinated by the bus scheduler. The three sets of data physically originate from the sliding surface construction module, the boundary layer width adaptive generation module, and the mode determination module, respectively, and are connected to a unified data buffer through independent channels. This ensures that the processing results of each submodule are consistent within the same control cycle, avoiding logical confusion in instruction generation due to inconsistent reading timing. After acquiring the mode flag, the controller immediately performs a branch judgment. If the current mode flag is the grid-connected identifier, the scheduler starts the grid-connected mode current command generation logic, calls the active and reactive current targets output by the proportional channel, and simultaneously draws the compensation current component from the sliding mode compensation channel. The two are numerically superimposed in the mixer to form the grid-connected current reference. This grid-connected current reference reflects the power outer loop target, bus voltage error compensation, and adaptive response capability to external impedance disturbances. It is the only basis for the ideal output current trajectory of the inverter under grid-connected conditions.

[0079] If the current mode flag is an islanding flag, the controller switches to scheduling the islanding mode current command generation logic. It calls the proportional channel to calculate the local load matching current component, introduces the derivative channel to generate the virtual inertia support component, and then calls the sliding mode compensation channel to obtain the error correction component. These three are combined into an islanding current reference for use in islanded operation. Subsequently, the controller subtracts the generated current reference from the real-time sampled value of the inverter output current, and the result is fed into the power stage current inner loop controller for modulation. The current inner loop outputs the drive voltage command based on sampling delay and the filter inductor model, for use in the next stage. In the sliding mode compensation channel, the error signal is normalized to the boundary layer width constraint region, and the maximum compensation amplitude is limited by a saturation function to avoid high-frequency jitter causing a step effect on the drive voltage. The drive voltage command is not immediately issued after generation; instead, it is uniformly written to the duty cycle register of the power drive board at the end of the current sampling period by the timing trigger logic. The power drive board updates it in the next pulse width modulation cycle, ensuring that the drive voltage command always lags behind the controller output by less than half a sampling period, guaranteeing continuous duty cycle changes and phase consistency in the drive link. After the instruction is written, the controller writes an instruction delivery completion flag to the status register. This flag is used in the next cycle for the diagnostic channel and safety watchdog system to prevent instruction delays, blocking, or duplicate delivery. Because this method consistently reuses the unified sliding mode compensation structure and boundary layer width adjustment mechanism during mode switching, only switching the current instruction generation logic branch, and strictly limiting the reading, calculation, and delivery order within the time axis for all control paths, it ultimately achieves a seamless and smooth transition of inverter output voltage, current, and power between grid-connected and islanded states. Simultaneously, there are no breakpoints between the sliding mode compensation channel and the control instruction generation process; the data flow forms a complete loop in the hardware structure, with each link driven by the status update flag. Combined with a hardware-level interrupt protection mechanism, this ensures that the entire adaptive sliding mode observer control closed loop maintains data consistency, timing stability, and rapid response during long-term operation, unaffected by external disturbances and structural changes caused by mode switching, comprehensively improving system control performance and dynamic stability.

[0080] The following is a specific example of a scheme for implementing a seamless grid-connected / off-grid switching control method based on an adaptive sliding mode observer. This example applies to a 5kW single-phase inverter system connected to a 220V / 50Hz grid. The inverter uses an LCL filter structure and has grid-connected / off-grid switching capability. The controller uses a 10kHz sampling frequency. The system parameters are set as follows:

[0081] Filter inductor: L f =2.2mH; Filter capacitor: C f =20μF; Virtual resistance: R v =5Ω; Nominal grid-side impedance: Z g,nom=0.5Ω; Sampling period: T = 0.0001s; Control period: T c =T=0.0001s; Preset number of continuous control cycles: 5; Voltage sensor noise RMS amplitude: N v =0.5V; Current sensor noise RMS amplitude: N i =0.1A.

[0082] Let t be the time of a certain control cycle. The system is operating in grid-connected mode, and the real-time sampled values ​​are as follows: Inverter output voltage: v o (t) = 223V; Phase-locked loop reference voltage: v * (t) = 220V; Grid-connected voltage: v g (t) = 221V; Filter inductor current: i f (t) = 7.8A; Estimated current derivative: Reference current derivative: Sliding mode error signal: σ(t) = 15; Equivalent network-side impedance estimate:

[0083] According to the boundary layer width calculation formula:

[0084]

[0085] Substitute the data into the calculation:

[0086]

[0087] Next, calculate the input of the sliding mode approach term saturation function:

[0088]

[0089] Let the saturation function sat(x) be linearly saturated with a unit slope, then

[0090]

[0091] Calculate sliding mode gain:

[0092]

[0093] Calculate the sliding mode approaching term:

[0094]

[0095] Next, calculate the inductor feedforward compensation term:

[0096]

[0097] Let the current reference voltage be v. * (t) = 220V, then the drive voltage command is:

[0098] u(t)=220-0·88-0.00398=219.116V;

[0099] Finally, the drive voltage command u(t) is digitally sent to the PWM duty cycle control channel of the power drive board. Since the system operates in grid-connected mode, the current command generation logic selects the grid-connected path within the current control cycle, and the inner current loop uses i... * (t) and i f (t) After comparing and obtaining the error, modulation control is completed. If the system detects that the logic value of the discrimination function is greater than zero and remains so for 5 consecutive control cycles, the state will switch to islanded mode, and the controller will automatically switch to the islanded mode current command generation logic and recalculate i. * (t), but the sliding mode compensation path and boundary layer width remain continuous, so the output command is still continuous at the moment of state switching, achieving a seamless transition.

[0100] Figure 2 The curves showing the change of the real-time estimated equivalent grid-side impedance during the grid-to-island switching process are illustrated. Figure 2 As shown, the horizontal axis represents the time axis, and the vertical axis represents the amplitude of the real-time estimated equivalent grid-side impedance. During grid-connected operation, the real-time estimated equivalent grid-side impedance remains near the nominal impedance level, exhibiting a relatively stable value. When the system detects a grid fault and initiates the switching procedure, at the switching moment, the real-time estimated equivalent grid-side impedance undergoes a significant jump, rapidly rising from the nominal impedance level to the high impedance region, reflecting the transition from a low-impedance grid environment to a high-impedance islanded environment. The figure also shows the upper and lower protection limits, used to prevent the real-time estimated equivalent grid-side impedance from exceeding a reasonable range due to algorithm divergence. The entire change process demonstrates the rapid response capability of the power difference iterative logic to changes in grid-side impedance.

[0101] Figure 3 The figure illustrates the response characteristics of the sliding mode error signal and the adaptive boundary layer width during the switching process. Two curves are included: the solid line represents the time-domain variation of the sliding mode error signal, and the dashed line represents the adaptive adjustment process of the boundary layer width. In grid-connected mode, the sliding mode error signal fluctuates slightly around the zero line, while the boundary layer width remains relatively stable. During grid-connected / off-grid switching, the sliding mode error signal exhibits significant abrupt changes and oscillations. Simultaneously, the boundary layer width is adjusted accordingly based on the real-time weighted calculation of the noise amplitudes from the voltage and current sensors to adapt to the disturbances during switching. After switching, the sliding mode error signal gradually converges, and the boundary layer width also tends towards a new stable value, indicating that the adaptive boundary layer can effectively suppress chattering during the switching process.

[0102] Figure 4 The timing relationship between the logic value of the discrimination function and the switching of the mode flag bit is shown. Figure 4 The system is divided into two parts: the upper part displays the continuous change of the discriminant function logic value over time, and the lower part displays the discrete switching status of the mode flag. During grid-connected operation, the discriminant function logic value remains in the negative region below the decision tolerance, and the corresponding mode flag outputs the grid-connected flag. When the weighted combination of the difference between the real-time estimated equivalent grid-side impedance and the nominal grid-side impedance, and the amplitude deviation between the grid-connected terminal voltage and the bus voltage exceeds the decision tolerance, the discriminant function logic value turns positive. To prevent misjudgments caused by transient disturbances, the system requires the discriminant function logic value to remain stable within a preset number of continuous control cycles. Only after this condition is met will the mode flag switch from the grid-connected flag to the islanded flag, ensuring the reliability of the switching decision.

[0103] Figure 5 This paper describes the seamless transition waveform of the inverter output bus voltage during grid-connected / off-grid switching. The solid line in the figure represents the instantaneous waveform of the inverter output bus voltage, while the dashed line represents the grid-connected voltage signal as a reference. In grid-connected mode, the inverter output bus voltage maintains good amplitude and phase synchronization with the grid-connected voltage signal. When the switching moment arrives, through coordinated control of the sliding mode error signal, boundary layer width, and mode flag, the inverter output bus voltage achieves a seamless transition from grid-connected to islanded mode. The voltage waveforms before and after the switch show good amplitude continuity and phase consistency, without voltage jumps or phase abrupt changes. This indicates that the control method of this invention can ensure continuous amplitude and phase consistency of the drive voltage command at the moment of state transition, achieving a smooth transition of inverter output voltage, current, and power, and verifying the effectiveness of the seamless switching control strategy.

[0104] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A control method for grid-connected and off-grid seamless switching based on adaptive sliding mode observer, characterized in that, The method comprises: Step 1: synchronously collect grid-connected end voltage signal and filtered inductance current signal in each control cycle, continuously update equivalent grid-side impedance real-time estimation value through power difference iteration logic, and implement upper and lower limit protection on the estimation result, and write the updated value into shared memory after the update is completed; Step 2: take the instantaneous error between inverter output bus voltage and phase-locked loop reference voltage as a reference, superimpose the impedance compensation quantity generated by the equivalent grid-side impedance real-time estimation value and the grid-connected end voltage signal and the filtered inductance current signal, and combine the long-term cumulative error of the bus voltage to form a unique sliding mode error signal; Step 3: based on the voltage and current sensor noise amplitude calibrated in advance, the absolute value of the inverter output bus voltage and the absolute value of the derivative of the filtered inductance current are taken in real time during operation, and the boundary layer width is obtained by linear weighting according to a fixed proportion; Step 4: call the comparison between the equivalent grid-side impedance real-time estimation value and the nominal grid-side impedance to obtain the impedance change quantity, and calculate the amplitude deviation between the grid-connected end voltage and the bus voltage, and then combine them through a fixed weight and compare them with the decision tolerance to generate a unique discriminant function logic value; the logic value is converted into a mode flag bit to distinguish between the grid-connected mode and the islanded mode, and the mode flag bit is kept valid in the current control cycle; After step 4, the method further comprises: synchronously reading the sliding mode error signal, the boundary layer width and the mode flag bit, selecting the corresponding current command generation logic according to whether the mode flag bit is currently a grid-connected identifier or an islanded identifier, and combining the sliding mode compensation channel to calculate the drive voltage command; at the end of each sampling cycle, the drive voltage command is sent to the power drive board to ensure the continuity of voltage, current and power at the state transition moment; time drive voltage command is: ; The meanings of the parameters in the formula are as follows: wherein, is the reference voltage output by the phase-locked loop, as the voltage trajectory tracking target; is the derivative of the reference current, calculated from the outer loop control target; is the adaptive gain of the sliding mode reaching control term, which dynamically adjusts its size with the equivalent grid-side impedance; is the saturation function, used to limit the amplitude of the sliding mode reaching term to suppress chattering; is the filter inductance; is the real-time inductance current rate of change; originates from the unique sliding mode error signal; is the boundary layer width.

2. The adaptive sliding mode observer based grid-connected and off-grid seamless transition control method of claim 1, wherein, In step 1, in each sampling cycle, the grid-connected end voltage signal and the filtered inductance current signal are synchronously sampled, and the same time stamp is ensured; the instantaneous power deviation is written into a ring buffer, a power memory window is set, and the power recursive difference value is obtained by comparing the historical power deviation with that of the last sampling cycle; the power recursive difference value is used to drive the iteration update logic to monotonically recursively correct the equivalent grid-side impedance real-time estimation value, and the upper and lower limit thresholds are set to prevent the value from diverging; the updated equivalent grid-side impedance real-time estimation value is written into the global shared memory; and the equivalent grid-side impedance real-time estimation value update completion flag is output.

3. The adaptive sliding mode observer based grid-connected and off-grid seamless transition control method of claim 2, wherein, Step 2 specifically comprises: reading the inverter output bus voltage signal and the phase-locked loop reference voltage signal at the beginning of each control cycle, calculating the difference between the two to obtain an instantaneous voltage error signal; calling the equivalent grid-side impedance real-time estimation value from the global shared memory, and generating an impedance compensation error signal in combination with the real-time sampled grid-connected end voltage signal and the filtered inductance current signal; adding the instantaneous voltage error signal, the impedance compensation error signal and the long-term bus voltage deviation accumulated through the integral channel to generate a unique sliding mode error signal; then, the sliding mode error signal is written into a register unit, which maintains the same access address in the grid-connected mode and the islanded mode, so that the memory mapping table does not need to be rebuilt when the state is switched; and the sliding mode error signal update completion flag is output.

4. The adaptive sliding mode observer based grid-connected and off-grid seamless transition control method of claim 3, wherein, The step 3 specifically comprises: in the power-on self-test stage, obtaining the root mean square amplitude of the voltage sensor noise and the root mean square amplitude of the current sensor noise respectively through the experimental calibration process, and storing them in the non-volatile memory in a read-only form; secondly, during the operation, the absolute value of the inverter output bus voltage and the absolute value of the filtered inductance current derivative are read synchronously in each control cycle, the absolute value of the bus voltage is multiplied by the root mean square amplitude of the voltage sensor noise, and the absolute value of the inductance current derivative is multiplied by the root mean square amplitude of the current sensor noise, to obtain two noise weighted quantities; the two noise weighted quantities are linearly weighted and synthesized according to a fixed proportion to generate the boundary layer width corresponding to the current control cycle, and are stored in the register unit in a cyclic writing manner; and an output boundary layer width update completion flag is output.

5. The adaptive sliding mode observer based grid-connected and off-grid seamless transition control method of claim 4, wherein, The step 4 specifically comprises: reading the real-time estimated value of the equivalent grid-side impedance, and comparing it with the nominal grid-side impedance measured when entering the grid-connected operation to form an impedance relative change quantity; synchronously reading the grid-connected end voltage signal and the inverter output bus voltage signal, and calculating the amplitude deviation therebetween to represent the voltage synchronization state of the grid-connected point; linearly combining the impedance relative change quantity and the voltage amplitude deviation according to a fixed weight, and comparing the combination with a decision margin pre-stored in the non-volatile memory to obtain a unique discriminant function logic value; generating a mode flag bit according to the discriminant function logic value, outputting a grid-connected flag when the discriminant function logic value meets the grid-connected condition, and outputting an island flag when the discriminant function logic value meets the island condition; after outputting the grid-connected flag, the following safety actions are synchronously performed: keeping the inverter output frequency, phase and grid-connected end voltage amplitude consistent, locking the grid-connected relay closed state, continuously monitoring the discriminant function logic value change and prohibiting any unauthorized instruction to modify the drive voltage instruction; after outputting the island flag, the following safety actions are synchronously performed: disconnecting the grid-connected relay within one control cycle, cutting off the physical connection between the inverter and the public grid, enabling the island operation protection logic, maintaining the bus voltage stability and starting the local load power supply.

6. The adaptive sliding mode observer based grid-connected and off-grid seamless transition control method of claim 5, wherein, When the discriminant function logic value is less than or equal to zero and the discriminant function logic value remains unchanged within a preset number of consecutive control cycles, it is determined that the grid-connected condition is met, and a grid-connected flag is output; When the discriminant function logic value is greater than zero and the discriminant function logic value remains unchanged within a preset number of consecutive control cycles, it is determined that the island condition is met, and an island flag is output; When the discriminant function logic value produces any invalid jump within a preset number of consecutive control cycles, the current determination process is cleared and re-counted to prevent misjudgment caused by transient disturbance or measurement noise.

7. The adaptive sliding mode observer based grid-connected and off-grid seamless transition control method of claim 6, wherein, The preset number of consecutive control cycles is not less than two control cycles and not more than ten control cycles.

8. The adaptive sliding mode observer based grid-connected and off-grid seamless transition control method of claim 7, wherein, At the beginning of each control cycle, the sliding mode error signal, the boundary layer width and the mode flag bit are synchronously read; the corresponding current instruction generation logic is selected according to the mode flag bit, if the flag bit is the grid-connected flag, the grid-connected mode current instruction generation logic is called, and the grid-connected current reference is obtained through the superposition of the proportional channel and the sliding mode compensation channel; If the flag is island identifier, the island mode current instruction generation logic is called, and the island current reference is obtained by superposition of proportional channel, derivative channel and sliding mode compensation channel; The current reference outputted by the selected logic is subtracted from the real-time sampling value of the inverter output current, and the driving voltage instruction is obtained by modulation of the power stage current inner loop. Meanwhile, the chattering suppression is implemented on the sliding mode compensation channel by using saturation function and boundary layer width. The driving voltage instruction is issued to the power drive board in a timing trigger mode, so as to ensure the continuity of the driving voltage instruction amplitude and the coherence of the phase at the state transition moment. The instruction issuing completion flag is written before the end of the current sampling period, so as to realize seamless transition of the inverter output voltage, current and power, and maintain the integrity and stability of the data flow and time sequence flow of the entire adaptive sliding mode observer control closed loop.

Citation Information

Patent Citations

  • Seamless switching control strategy for micro-grid inverter

    CN113517716A

  • Photovoltaic grid-connected inverter control method based on sliding mode control

    CN116316866A