Grid-connected and off-grid seamless switching control method based on adaptive sliding mode observer

Through the seamless switching control method of grid-connected and off-grid using an adaptive sliding mode observer, the equivalent grid-side impedance is estimated in real time and the sliding mode error signal and adaptive boundary layer width are constructed, which solves the problems of misjudgment of grid status and discontinuous control process in inverter control, realizes smooth switching of the inverter between grid-connected and islanding modes, and improves the stability and power quality of the system.

CN120675159AActive Publication Date: 2025-09-19SHANNENG NEW ENERGY (DONGYING) CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing inverter control methods are sensitive to misjudgment in grid status judgment, have discontinuous control processes, and have fixed parameters that cannot adapt to external disturbances, resulting in 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. By estimating the equivalent grid-side impedance in real time, constructing a sliding mode error signal and an adaptive boundary layer width, highly robust identification of the grid state and continuous reconstruction of control instructions are achieved, thus avoiding sudden changes in voltage, current and power during the switching process.

Benefits of technology

It achieves seamless switching of the inverter between grid-connected and island modes, improves the system's operating stability and power quality, enhances the ability to quickly respond to grid disturbances, prevents misjudgment and chattering, and is suitable for distributed power generation and energy storage systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120675159A_ABST
    Figure CN120675159A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of micro-grids, further relates to the technical field of data acquisition control systems, and discloses a grid-connected and off-grid seamless switching control method based on a self-adaptive sliding-mode observer. The method comprises the following steps of: 1, continuously updating an equivalent network side impedance real-time estimation value through power difference iterative logic; 2, forming a unique sliding mode error signal by taking an instantaneous error between the output bus voltage of the inverter and the reference voltage of the phase-locked loop as a reference; 3, based on the voltage and current sensor noise amplitude calibrated in advance, performing linear weighting according to a fixed proportion to obtain the boundary layer width; and 4, calling the real-time estimated value of the equivalent grid-side impedance to be compared with the nominal grid-side impedance to obtain an impedance variable quantity, distinguishing a grid-connected mode and an island mode, and keeping effective in the current control period. The method has the advantages of being easy to implement, high in real-time performance, high in anti-disturbance capacity and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of microgrids, and in particular to the technical field of data acquisition and control systems, and specifically to a seamless on-grid and off-grid switching control method based on an adaptive sliding mode observer. Background Art

[0002] With the increasing popularity of renewable energy and distributed power generation systems, the inverter, as the core power electronic device connecting the power source and the grid, has become a key factor affecting power quality and system reliability. In particular, in applications such as microgrids, household photovoltaic systems, and energy storage converters, the inverter must not only operate stably under normal grid-connected conditions but also quickly and accurately enter islanded operation in the event of a grid failure or disconnection, and seamlessly connect to the grid after the grid is restored. To achieve this, the inverter control system must be able to determine the grid status in real time and continuously switch between on-grid and off-grid modes. This places higher demands on traditional control strategies and exposes a series of limitations in existing technologies.

[0003] Currently, mainstream inverter on-grid and off-grid control methods mostly employ switching control strategies based on switch logic. In this approach, the controller monitors sudden changes in grid voltage amplitude, frequency deviation, or grid impedance, and uses predefined threshold logic to determine grid availability and switch control logic accordingly. For example, if the controller detects a grid voltage drop exceeding a predefined threshold, it identifies a grid interruption and initiates island control mode. Once the grid returns to within the permitted range and maintains this for a period of time, it switches back to grid-connected control. Due to its simple implementation, this approach can meet basic functional requirements within traditional grid structures. However, it has several significant drawbacks.

[0004] First, existing switching control methods mostly rely on a single or small number of parameters, such as voltage amplitude, current phase, and grid frequency. This judgment mechanism is highly sensitive to short-term disturbances and measurement noise, making it prone to misjudgment during minor grid fluctuations or transient disturbances. This can lead to frequent and unnecessary inverter switching between grid and off-grid conditions, increasing system operational uncertainty and potentially causing controller overload or even power device failure. Second, during actual switching, current control strategies generally employ a "logic switching" approach. Upon detecting a grid state change, the current control flow is immediately interrupted and a different control logic (e.g., switching from a grid-connected controller to an island controller) is applied. Because the grid-connected and island controllers are typically designed as independent structures with different current commands, voltage regulation methods, and reference parameters, the switching moment often causes jumps in the output voltage or current trajectory. In severe cases, this can even cause spikes or dips, impacting power quality and potentially damaging load equipment. This transient discontinuity is particularly unacceptable in medical, telecommunications, and military load systems, which have stringent power quality requirements. Thirdly, some studies have attempted to introduce observers or filtering mechanisms to improve the robustness of system identification. For example, methods such as Kalman filtering, voltage sliding average, and frequency locked loops are used to smoothly identify grid states. However, most of these methods are based on the assumption of linear systems and have difficulty maintaining identification accuracy under conditions of strong nonlinearity, sudden changes in grid parameters, or drastic load changes. In addition, traditional observers have fixed parameters and cannot respond adaptively to external disturbances or changes in grid topology, resulting in identification delays or increased probability of misjudgment. Summary of the Invention

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

[0006] In order to solve the above problems, the technical solution of the present invention is achieved as follows:

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

[0008] Step 1: Synchronously collect the grid-connected voltage signal and the filter inductor current signal during each control cycle. Use the power difference iteration logic to continuously update the real-time estimated value of the equivalent grid-side impedance. Implement upper and lower limit protection on the estimated result. Once updated, write the result to the shared memory.

[0009] Step 2: Using the instantaneous error between the inverter output bus voltage and the phase-locked loop reference voltage as a benchmark, the real-time estimated value of the equivalent grid-side impedance and the impedance compensation value generated by the grid-connected voltage signal and the filtered inductor current signal are superimposed. This is then combined with the long-term accumulated error in the bus voltage to form a unique sliding mode error signal.

[0010] Step 3: Based on the pre-calibrated voltage and current sensor noise amplitudes, the absolute value of the inverter output bus voltage and the absolute value of the filter inductor current derivative are taken in real time during operation, and linearly weighted according to a fixed ratio to obtain the boundary layer width;

[0011] Step 4: Call the real-time estimated value of the equivalent grid-side impedance and compare it 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 discriminant function logic value through fixed weight combination and judgment tolerance comparison; convert the logic value into a mode flag to distinguish between grid-connected mode and island mode, and keep it valid during the current control cycle.

[0012] Furthermore, in step 1, in each sampling cycle, the grid-connected voltage signal and the filtered inductor current signal are synchronously sampled and ensured to share the same timestamp; the instantaneous power deviation is written into the circular buffer, a power memory window is set, and compared with the historical power deviation of the previous sampling cycle to obtain the power recursive difference; the power recursive difference is used to drive the iterative update logic, and the real-time estimated value of the equivalent grid-side impedance is monotonically recursively corrected, and the upper and lower 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 the update completion flag of the real-time estimated value of the equivalent grid-side impedance is output.

[0013] Furthermore, step 2 specifically includes: 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 real-time estimated value of the equivalent grid-side impedance from the global shared memory, and generating an impedance compensation error signal by combining the real-time sampled grid-connected voltage signal and the filtered inductor current signal; adding the instantaneous voltage error signal, the impedance compensation error signal and the long-term deviation of the bus voltage accumulated through the integral channel to generate a unique sliding mode error signal; then, writing the sliding mode error signal into a register unit, which maintains the same access address in the grid-connected mode and the island mode, so that there is no need to rebuild the memory mapping table when switching states; and outputting a sliding mode error signal update completion flag.

[0014] Furthermore, step 3 specifically includes: 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 an experimental calibration process, and storing them in a non-volatile memory in a read-only form; secondly, during operation, synchronously reading the absolute value of the inverter output bus voltage and the absolute value of the filter inductor current derivative in each control cycle, and multiplying the absolute value of the bus voltage with the root mean square amplitude of the voltage sensor noise, and multiplying the absolute value of the inductor current derivative with the root mean square amplitude of the current sensor noise to obtain two noise weighted quantities; linearly weighting the two noise weighted quantities according to a fixed ratio to generate a boundary layer width corresponding to the current control cycle, and storing it in a register unit in a cyclic write manner; outputting a boundary layer width update completion flag.

[0015] Furthermore, step 4 specifically includes: reading the real-time estimated value of the equivalent grid-side impedance, and performing a difference comparison with the nominal grid-side impedance measured when entering the grid-connected operation to form a relative impedance change; synchronously reading the grid-connected terminal voltage signal and the inverter output bus voltage signal, calculating the amplitude deviation between the two, and using it to characterize the voltage synchronization state of the grid-connected point; linearly combining the relative impedance change and the voltage amplitude deviation according to a fixed weight, and comparing them with the judgment tolerance 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, and when the discriminant function logic value meets the The grid-connected flag is output when the grid-connected conditions are met, and the island flag is output when the discriminant function logic value meets the island condition; after the grid-connected flag is output, the following safety actions are performed synchronously: keep the inverter output frequency and phase consistent with the grid-connected voltage amplitude, lock the closed state of the grid-connected relay, continuously monitor the changes in the discriminant function logic value and prohibit any unauthorized instructions from modifying the drive voltage instruction; after the island flag is output, the following safety actions are performed synchronously: disconnect the grid-connected relay within one control cycle, cut off the physical connection between the inverter and the public power grid, enable the island operation protection logic, maintain the bus voltage stable and start the local load power supply.

[0016] Furthermore, when the logic value of the discriminant function is less than or equal to zero and the logic value of the discriminant function remains unchanged within a preset number of continuous control cycles, it is determined that the grid-connected condition is met and a grid-connected flag is output; when the logic value of the discriminant function is greater than zero and the logic value of the discriminant function remains unchanged within a preset number of continuous control cycles, it is determined that the island condition is met and an island flag is output; when the logic value of the discriminant function produces any invalid jump within the preset number of continuous control cycles, the current judgment process is cleared and the count is re-counted 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, the boundary layer width, and the mode flag, selecting the corresponding current command generation logic according to whether the mode flag is currently a grid-connected flag or an island flag, and calculating the drive voltage command in combination with the sliding mode compensation channel; 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 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 synchronously read. The corresponding current command generation logic is selected based on the mode flag. If the flag is a grid-connected flag, 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 island flag, the island mode current command generation logic is called, and the island current reference is obtained by superimposing the proportional channel, the derivative channel, and the 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 drive voltage command is obtained by modulating the power stage current inner loop. At the same time, the sliding mode compensation channel is used to suppress chattering. The drive voltage command is issued to the power driver board in a timed triggering manner to ensure that the drive voltage command amplitude is continuous and the phase is coherent at the moment of state transition. Before the end of the current sampling cycle, the command issuance completion flag is written to achieve a seamless transition of the inverter output voltage, current, and power, and maintain the integrity and stability of the data flow and timing flow of the entire adaptive sliding mode observer control closed loop.

[0020] A seamless grid-connected and off-grid switching control method based on an adaptive sliding mode observer has the following beneficial effects: 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 states and continuous reconstruction of inverter control instructions. Compared with traditional control strategies based on logic switches, this method does not require interrupting the control flow or switching the control structure between grid-connected and islanded modes, avoiding transient changes in output voltage, current, and power during the switching process, significantly improving system operational stability and power quality. By using a real-time updated equivalent grid-side impedance estimate, the system accurately reflects external grid impedance changes and rapidly responds to grid structure disturbances. The boundary layer width is adaptively adjusted based on system noise and dynamic conditions, enabling the sliding mode approach to maintain convergence while effectively suppressing high-frequency chattering, addressing the oscillation problem present in conventional sliding mode control methods. The method utilizes a continuous control cycle criterion and an invalid transition clearing mechanism to improve the accuracy of grid state identification and prevent misjudgments caused by short-term glitches or transient disturbances. Drive voltage commands are continuously generated within a complete closed-loop structure, ensuring smooth control trajectories and seamless output responses during state transitions. This overall solution, which relies on no additional hardware or communication support, boasts a unified structure, simple implementation, strong real-time performance, and robust anti-disturbance capabilities. It is suitable for inverter control in high-reliability distributed generation, microgrids, and energy storage systems, demonstrating promising application prospects and engineering value. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A schematic diagram of a method flow chart of a method for seamless on-grid and 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 a curve showing a change in the real-time estimated value of the equivalent grid-side impedance during the switching process from grid connection to islanding provided by an embodiment of the present invention;

[0023] Figure 3 A schematic diagram of the response characteristics of the sliding mode error signal and the adaptive boundary layer width during the switching process provided by an embodiment of the present invention;

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

[0025] Figure 5 Schematic diagram of seamless transition waveform of inverter output bus voltage during on-grid and off-grid switching. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

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

[0028] Step 1: Synchronously collect the grid-connected voltage signal and the filter inductor current signal during each control cycle. Use the power difference iteration logic to continuously update the real-time estimated value of the equivalent grid-side impedance. Implement upper and lower limit protection on the estimated result. Once updated, write the result to the shared memory.

[0029] Step 2: Using the instantaneous error between the inverter output bus voltage and the phase-locked loop reference voltage as a benchmark, the real-time estimated value of the equivalent grid-side impedance and the impedance compensation value generated by the grid-connected voltage signal and the filtered inductor current signal are superimposed. This is then combined with the long-term accumulated error in the bus voltage to form a unique sliding mode error signal.

[0030] Step 3: Based on the pre-calibrated voltage and current sensor noise amplitudes, the absolute value of the inverter output bus voltage and the absolute value of the filter inductor current derivative are taken in real time during operation, and linearly weighted according to a fixed ratio to obtain the boundary layer width;

[0031] Step 4: Call the real-time estimated value of the equivalent grid-side impedance and compare it 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 discriminant function logic value through fixed weight combination and judgment tolerance comparison; convert the logic value into a mode flag to distinguish between grid-connected mode and island mode, and keep it valid during the current control cycle.

[0032] The power difference iteration logic is essentially a self-correction process under the constraint of energy conservation: when the actual grid-connected energy differs from the energy predicted by the current real-time estimate of the equivalent grid-side impedance, the sign and magnitude of the difference are immediately fed back to the iteration channel, generating a correction in the opposite direction of the error, thereby converging to the true impedance level cycle by cycle. This self-correction mechanism enables the inverter to maintain synchronous adaptation to the external system under conditions of frequent grid structure changes, severe load fluctuations, or measurement noise interference, without the need for manual retuning of controller gains. Leveraging this highly reliable real-time estimate of the equivalent grid-side impedance, the sliding mode surface construction process eliminates the direct impact of external uncertainties. By using the instantaneous error between the inverter output bus voltage and the phase-locked loop reference voltage as a reference, and introducing impedance compensation and long-term accumulated error, the three physically distinct and complementary information streams are combined into a single sliding mode error signal.

[0033] The unique sliding-mode error signal not only provides a balanced error metric for both transient and steady-state conditions but also mathematically ensures seamless integration between grid-connected and islanded modes. This is because the physical quantities in the error expression maintain the same source and meaning in both operating environments, avoiding "error disconnection" during state switching. To suppress the high-frequency chattering inherent in sliding-mode control while maintaining convergence speed, the boundary layer width is adaptively generated based on the known voltage and current sensor noise amplitudes. The absolute value of the inverter output bus voltage and the absolute value of the filter inductor current derivative are read in real time. A linear weighting mechanism is used to couple the sensor noise with the system dynamics, dynamically adjusting the size of the convergence zone. When grid disturbances increase the voltage amplitude and current derivative, the boundary layer width increases to limit high-frequency components. When operation stabilizes, the boundary layer width automatically converges to restore fast response. This bidirectional adaptive capability ensures that sliding-mode control maintains an optimal compromise throughout the entire operating range.

[0034] The grid-connection and off-grid determination phase compares the real-time estimate of the equivalent grid-side impedance with the nominal grid-side impedance to obtain the impedance change. It also 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 the judgment tolerance to generate a unique discriminant function logic value. Because the impedance change is sensitive to sudden changes in grid topology, and the voltage amplitude deviation is sensitive to energy flow imbalance, the fusion of these two allows the discriminant function to quickly respond to grid faults such as tripping, grounding, and short circuits while avoiding misjudgments caused by short-term harmonics or measurement glitches. The discriminant function logic value is decoded into a mode flag, ensuring that only one of the two options, grid-connected or island-connected, is generated within a control cycle. A minimum continuous threshold is used to prevent critical point oscillation. The final control command reconstruction phase invokes either the grid-connected mode current command generation logic or the island-connected mode current command generation logic based on the mode flag.

[0035] The grid-connected mode current command generation logic generates baseline active and reactive current components using the target power provided by the power outer loop and the phase-locked loop synchronization angle. It then uses the real-time estimated equivalent grid-side impedance for impedance feedforward decoupling to actively offset the distortion effects of grid inductance and resistance on the command current. Simultaneously, a sliding-mode approaching current component derived from a unique sliding-mode error signal is superimposed, ensuring that the actual grid-connected current quickly conforms to the ideal sinusoidal curve with low harmonic content under the triple constraints. The island mode current command generation logic constructs an island baseline current component based on the estimated local load power and output impedance coefficient. It also incorporates 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 island current reference, thereby maintaining a constant bus voltage even in the absence of public grid support.

[0036] The two logics 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 the impedance processing order are rearranged, the sliding mode part remains continuous, and the drive voltage instruction is also continuous. This integrated synchronous switching of hardware and algorithm ensures that the inverter output voltage and current waveforms are step-free, spike-free, and interrupted at the moment of grid-connected and off-grid conversion. Through the above-mentioned chain collaboration, the present invention not only completes the real-time adaptation of multi-source uncertainty, but also opens up the full-link closed loop from energy perception, error measurement, vibration suppression to mode judgment and instruction reconstruction, and finally realizes seamless switching of the inverter on and off the grid without relying on external bypass or manual intervention, significantly improving the operational reliability and dynamic stability of the distributed power supply system in smart microgrids and weak grid scenarios.

[0037] refer to Figure 2 Furthermore, in step 1, in each sampling period, the grid-connected voltage signal and the filter inductor current signal are synchronously sampled and ensured to share the same timestamp; the instantaneous power deviation is written into the circular buffer, a power memory window is set, and 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, and the equivalent grid-side impedance real-time estimation value is monotonically recursively corrected, 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.

[0038] The rate of change of the real-time estimated value of the equivalent grid-side impedance at time t for:

[0039]

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

[0041] refer to Figure 3 Furthermore, step 2 specifically includes: 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 real-time estimated value of the equivalent grid-side impedance from the global shared memory, and generating an impedance compensation error signal by combining the real-time sampled grid-connected voltage signal and the filtered inductor current signal; adding the instantaneous voltage error signal, the impedance compensation error signal, and the long-term deviation of the bus voltage accumulated through the integral channel to generate a unique sliding mode error signal; then, writing the sliding mode error signal into a register unit, which maintains the same access address in the grid-connected mode and the island mode, so that there is no need to rebuild the memory mapping table when the state is switched; and outputting a sliding mode error signal update completion flag.

[0042] When the controller clock reaches the start of a new control cycle, the two voltage data points are latched to the same timestamp via a double-buffered sampling register. A differential operation is then immediately performed to generate 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 provides the most direct quantitative means of assessing the degree of output deviation. The controller then reads the latest real-time estimate of the equivalent grid-side impedance from the global shared memory and uses the grid-connected voltage signal and the filtered inductor current signal within the current sampling window to generate the impedance compensation error signal through a hardware multiplier and adder combination.

[0043] The impedance compensation error signal dynamically offsets the additional error introduced by external grid impedance variations, enabling the sliding mode observer to maintain high sensitivity to internal system variables despite structural uncertainty. Simultaneously, a long-term integration channel continuously accumulates historical deviations in the inverter's output bus voltage, generating a long-term bus voltage deviation. This deviation is then processed by a digital integrator and maintained in the same dimension as the previous two error signals. The instantaneous voltage error signal, the impedance compensation error signal, and the long-term bus voltage deviation are then summed in a fixed order in an adder network to output a unique sliding mode error signal. This unique sliding mode error signal incorporates both high-speed transient and low-speed steady-state information, while also adaptively compensating for external grid impedance disturbances in real time. Therefore, it can be directly used by the sliding mode reaching law in both grid-connected and islanded modes without switching formulas or channels, fundamentally ensuring algorithm consistency during on-grid and off-grid switching. The controller writes the sliding mode error signal to a dedicated register unit, which uses the same physical address at the hardware address mapping level for both grid-connected and islanded modes, eliminating the additional latency and potential data misreading 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) is the real-time sampling value of the bus voltage at the inverter output end; v * (t) is the reference voltage output by the phase-locked loop; C f is the output filter capacitor; L f is the filter inductor; 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 the two ideas of energy conservation and dynamic compensation. It couples the instantaneous, impedance-related and long-term deviations between the inverter output and the phase-locked loop reference into a single error signal through three complementary information flows. In a high-speed path, Reflects the charge response of the output filter capacitor to voltage changes, C f This is equivalent to mapping the instantaneous voltage difference into a proportional factor of the current. The controller uses a first-order forward difference to approximate the differential operator in the digital domain, supplemented by a bandpass filter to suppress high-frequency noise in the measurement. This makes this channel extremely sensitive to sharp disturbances and can capture the smallest sudden changes in bus voltage at the early stage of grid-connected and off-grid switching. In the second medium-speed path, Through the filter inductor L f Establish voltage-current coupling, It is updated in real time by the adaptive sliding mode observer, in conjunction with the grid-connected voltage v g(t) and the inductor current i f (t) Generates an impedance compensation term that offsets the phase lag and amplitude distortion caused by the external grid impedance and line impedance, thereby maintaining the same amplitude error standard between grid-connected mode and island mode. The controller uses a hardware multiplier to calculate Then with v o (t) and v g (t) Complete the addition and subtraction, and the results are uniformly scaled by the shift register to ensure that the calculation delay is less than half of the sampling period. Through the virtual damping resistor R v Integral memory for voltage balancing is introduced. η is integrated from system startup to the current moment, using a recursive summation accumulator for numerical integration. The accumulator periodically performs anti-overflow scaling to ensure distortion-free long-term operation. The three paths are added together within the arithmetic logic unit (ALU) at a fixed timing and written simultaneously to a unified register to generate a unique σ(t). The register address is identical in grid-connected and island modes, and hardware decoding does not rely on mode flags, avoiding address remapping delays during state switching. The generated σ(t) triggers an update completion flag, which is broadcast via an event chain to the boundary layer width adaptation submodule and the control instruction reconstruction 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 registration path in different modes, achieving algorithm-level "seamless" characteristics; the instantaneous differential component provides rapid disturbance response capability, the impedance compensation component provides external uncertainty isolation capability, and the integral component provides steady-state zero-difference correction capability. The three work together to enable 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 a truly seamless dynamic transition in the presence of sudden grid impedance changes, load shocks and measurement noise.

[0048] refer to Figure 4 Furthermore, step 3 specifically includes: in the power-on self-test stage, obtaining the voltage sensor noise root mean square amplitude and the current sensor noise root mean square amplitude respectively through the experimental calibration process, and storing them in a non-volatile memory in a read-only form; secondly, during operation, synchronously reading the inverter output bus voltage absolute value and the filter inductor current derivative absolute value in each control cycle, and multiplying the bus voltage absolute value with the voltage sensor noise root mean square amplitude, and multiplying the inductor current derivative absolute value with the current sensor noise root mean square amplitude to obtain two noise weighted quantities; performing linear weighted synthesis on the two noise weighted quantities according to a fixed ratio to generate the boundary layer width corresponding to the current control cycle, and storing it in the register unit in a cyclic write manner; outputting a boundary layer width update completion flag.

[0049] The controller keeps the power-stage bridge arm off and injects a stable reference voltage into the inverter's DC bus via the bypass voltage regulator module. It then continuously samples the voltage and current sensor output waveforms under no-load, grid-side disturbance-free static conditions. The RMS noise amplitudes of the voltage and current sensors are calculated using a windowed accumulation and square averaging algorithm. To prevent calibration results from being lost during debugging or power outages, the controller immediately stores the two noise signatures in read-only non-volatile memory after calculation. Verification and write protection logic ensure that no subsequent programs can overwrite or tamper with this static data. Once the system enters normal operation, the sampling logic is synchronously triggered by a timebase interrupt during each control cycle, latching the absolute value of the inverter output bus voltage and the absolute value of the filter inductor current derivative at the same time to ensure data homology and consistent timestamps.

[0050] Subsequent multiplication operations are performed in parallel within the hardware multiplier. The absolute value of the bus voltage is multiplied by the RMS amplitude of the voltage sensor noise to generate the first noise-weighted quantity. Simultaneously, the absolute value of the inductor current derivative is multiplied by the RMS amplitude of the current sensor noise to generate the second noise-weighted quantity. Because the two noise-weighted quantities have the same dimension and meaning, the controller uses a fixed-point multiplier to output a data frame in a unified format, facilitating direct access by subsequent operations. To address the fact that the weights of voltage and current on jitter vary under different operating conditions, the controller presets a set of fixed scaling coefficients in the configuration area. Using an adder and shifter, the two noise-weighted quantities are linearly weighted, thus adaptively determining the boundary layer width for the current control cycle. When the absolute value of the bus voltage increases due to load changes or grid-side disturbances, the boundary layer width increases 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 decreases, bringing the sliding-mode approach closer to the ideal switching surface and accelerating error convergence. 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 island 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 island 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 uses a write pointer to increment within a fixed-depth circular queue, automatically making the previously written content a backup for the next read. This saves refresh time and ensures fallback to the last valid value in the event of an anomaly. When a register cell is written, the controller sets a boundary layer width update completion flag. This flag is broadcast via the on-chip event chain bus to the sliding mode approach module and the control instruction reconstruction module. The boundary layer width read by both modules within the same control cycle is the latest value, eliminating the need for additional synchronization. If the downstream module fails to detect the update completion flag within the specified time limit, the system safety monitoring unit triggers a degraded mode to prevent chattering failure 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 RMS noise amplitudes of the voltage and current sensors, obtained through static calibration, into the real-time operation path. This allows for instantaneous coupling of noise characteristics with system dynamics, achieving an optimal trade-off for sliding mode control chattering over the entire timescale.

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

[0053]

[0054] Among them, N v is the RMS noise amplitude of the voltage sensor, obtained through experimental calibration; N i is the RMS noise amplitude of the current sensor, obtained through experimental calibration.

[0055] refer to Figure 5 , further, step 4 specifically includes: reading the real-time estimated value of the equivalent grid-side impedance, and performing a difference comparison with the nominal grid-side impedance measured when entering the grid-connected operation to form a relative impedance change; synchronously reading the grid-connected terminal voltage signal and the inverter output bus voltage signal, calculating the amplitude deviation between the two, and using it to characterize the voltage synchronization state of the grid-connected point; linearly combining the relative impedance change and the voltage amplitude deviation according to a fixed weight, and comparing them with the judgment tolerance 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, and when the discriminant function logic value meets the condition, the mode flag bit is generated. The grid-connected flag is output when the grid-connected conditions are met, and the islanding flag is output when the discriminant function logic value meets the islanding condition; after the grid-connected flag is output, the following safety actions are performed synchronously: keep the inverter output frequency and phase consistent with the grid-connected voltage amplitude, lock the closed state of the grid-connected relay, continuously monitor the changes in the discriminant function logic value and prohibit any unauthorized instructions from modifying the drive voltage instruction; after the islanding flag is output, the following safety actions are performed synchronously: disconnect the grid-connected 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 stable and start the local load power supply.

[0056] In the seamless switching control method for grid connection and off-grid connection based on an adaptive sliding mode observer, the mode determination thread performs dual-channel data acquisition from the moment the system clock is triggered. It first synchronously reads the real-time estimated value of the equivalent grid-side impedance on a dedicated bus, and then calls the nominal grid-side impedance recorded during the power-on calibration phase in the non-volatile memory. The two values ​​enter the subtractor for differentiation and are then used by the scaler to obtain the relative impedance change. This change reflects the dynamic fluctuations of the external grid impedance in percentage form and can quickly reveal anomalies such as increased impedance of the public grid line, cable faults, or disconnection at the grid connection point. Next, the sampling controller latches the grid-connected voltage signal and the inverter output bus voltage signal in the same time slot. The amplitude calculation unit extracts the effective value of the two and then performs an absolute difference operation to output the voltage amplitude deviation, measuring the grid connection point voltage synchronization status with millivolt accuracy.

[0057] The relative impedance change and voltage amplitude deviation are then fed into a linear combiner, where they are normalized and superimposed according to fixed weights to form a single-scale comprehensive deviation indicator. The weights are set during the system commissioning phase based on grid characteristics and load sensitivity and written into a readable, non-writable configuration register to prevent tampering during operation. The comprehensive deviation indicator enters a comparator, where it is compared against the decision tolerance and outputs a unique discriminant function logic value. The decision tolerance is also stored in non-volatile memory and is based on the upper limit of impedance and voltage deviation permitted 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 the grid connection flag to the mode register. If the discriminant function logic value is greater than zero, the decoder writes the island flag. The mode register has a single-write exclusive lock, allowing only one flag to be present at any given time. A hardware anti-jitter delay window is implemented to prevent flag toggling until the same discrimination result has been verified for multiple consecutive sampling cycles, fundamentally preventing high-frequency jitter near the threshold.

[0058] Once the system outputs the grid-connected flag, the synchronized safety action logic immediately freezes the inverter's internal phase-locked loop gain, aligning the output frequency with the grid-connected voltage amplitude. A hardware daemon thread locks the grid-connected relay closed, and a dynamic permission table is activated to prevent any unauthorized process from modifying the drive voltage command until the discriminant function logic value changes and is confirmed through the anti-shake window. If the islanding flag is output, a hardware interrupt triggers the grid-connected relay to open within the current control cycle, physically isolating the inverter from the public grid. The system then rapidly switches to the islanding protection logic, using the local load's estimated power to deliver a current reference to maintain bus voltage stability. The energy storage management interface is simultaneously activated to supply power to local loads, ensuring continuous power supply. To prevent energy recirculation or bus drop during the switching transition, the islanding 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 process. The relative impedance change and voltage amplitude deviation are updated based on real-time data, ensuring that the discriminant function logic value reflects the instantaneous operating conditions. Through multiple measures such as hardware latching, read-only parameters, weight solidification, and anti-shake delay, this solution implements unique constraints on the mode flag, enabling the inverter to smoothly and unambiguously transition between grid-connected and islanded states. This not only maintains the continuity of the output voltage waveform and phase, but also prevents the propagation of external faults to the local system through rapid isolation and virtual inertia support, comprehensively improving the operational safety level and dynamic stability performance of distributed power sources.

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

[0060]

[0061] Among them, Z g,nom is the nominal grid-side impedance measured under normal grid-connected working conditions; V sync is the synchronous tolerance voltage amplitude, which is used to normalize the voltage deviation and is generally set according to the grid standard; c is the preset discrimination tolerance, which 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 island mode.

[0062] Furthermore, when the logic value of the discriminant function is less than or equal to zero and the logic value of the discriminant function remains unchanged within a preset number of continuous control cycles, it is determined that the grid-connected condition is met and a grid-connected flag is output; when the logic value of the discriminant function is greater than zero and the logic value of the discriminant function remains unchanged within a preset number of continuous control cycles, it is determined that the island condition is met and an island flag is output; when the logic value of the discriminant function produces any invalid jump within the preset number of continuous control cycles, the current judgment process is cleared and the count is re-counted to prevent misjudgment caused by transient disturbances or measurement noise.

[0063] To prevent misjudgments caused by transient disturbances or measurement noise near the threshold value of the discriminant function logic, the controller implements a dual-counting window mechanism in the hardware judgment link. First, once the discriminant function logic value is calculated, it is written to the judgment register, simultaneously triggering a counter to begin counting the number of consecutive times the result is maintained in subsequent samples. If the discriminant function logic value is less than or equal to zero, counter A enters the auto-increment state; if the discriminant function logic value is greater than zero, counter B enters the auto-increment state. The two counters operate mutually exclusive, with only one counter incrementing during a control cycle. When the value of either counter reaches a preset number of consecutive control cycles, the controller immediately determines that the current operating state meets the corresponding conditions: Counter A reaches the threshold, outputting a grid-connected flag; Counter B reaches the threshold, outputting an islanding flag. To prevent the erroneous accumulation of reverse transitions in the discriminant function logic value caused by short-term glitches or sudden harmonics, the system configures monitoring thresholds for each counter. If an invalid transition, such as a reversal of direction or an amplitude exceeding the threshold, is detected during the counting process, the reset logic is immediately triggered, clearing the current judgment process and restarting the counting process. This clearing logic not only resets the counter itself but also delays locking the determination register for several sampling cycles to ensure that the new counting process restarts based on completely stable data. The preset number of continuous control cycles is determined through full-machine testing, a compromise between detection sensitivity and false positive probability. This number is written into a read-only configuration register and cannot be modified during runtime. With this dual counting window and invalid transition clearing strategy, the discriminant function logic value must remain consistent within a sufficiently long continuous time window to trigger the grid-connected flag or island flag output. Any invalid transition causes the counter to reset and restart, 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, clearing logic, and mode register write operations are all completed in a single cycle, without increasing the determination delay. Furthermore, the mode register is protected by a single write exclusive lock, ensuring the mutual exclusion of the grid-connected flag and the island flag. With the help of this mechanism, this method realizes soft transition judgment in the boundary area between grid-connected mode and island mode. Even if the logic value of the discriminant function hovers near the threshold for a long time, frequent switching can be avoided by recounting, ensuring the continuous stability of the inverter output voltage and current, and further improving the reliability and safety margin of seamless switching between grid-connected and off-grid mode.

[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 consecutive control cycles is less than two, the discriminant function logic value only needs to be sampled twice in a very short period of time to trigger a mode switch. However, transient glitches caused by grid harmonics, electromagnetic interference, and sampling jitter can often cause a reverse jump within a single control cycle. Real-time counting without delay will significantly increase the probability of misjudgment. When the number of consecutive control cycles exceeds ten, Counter A or Counter B must maintain a single direction increment for a longer time window to trigger the grid-connected or islanding flag. This will directly delay the grid-connected and off-grid switching response, causing the inverter to lose the initiative in the early stages of external fault propagation. Through experimental statistics, a value between two and ten can simultaneously meet the dual requirements of sensitive response and glitch resistance. Therefore, this range has been solidified as a product-level parameter. The preset number of continuous control cycles is written to a read-only configuration register by a configuration script in the factory debugging software. This is automatically loaded upon firmware power-up and cannot be modified at runtime. If the field application has specific requirements for grid fluctuation characteristics and load disturbance frequency, it can be re-programmed through the authorized encrypted interface in maintenance mode. However, it is still subject to a limit of 2 to 10 to prevent extreme values ​​from causing system instability. The hardware counter logic initializes the increment limit with a synchronous reset after reading this parameter. Each time the counter reaches this limit, a mode register write operation is triggered. If a negative transition in the discriminant function logic value is detected during the count, the counter is immediately reset and restarts from zero. This ensures that the grid connection or islanding flag is only output when the discriminant function logic value maintains the same sign continuously within the stability window. This design makes the preset number of continuous control cycles a quantifiable adjustment handle between judgment sensitivity and safety margin. The limit also ensures that the adjustment range does not compromise the speed and reliability required for seamless on-grid and off-grid transitions.

[0066] Furthermore, after step 4, the method further includes: synchronously reading the sliding mode error signal, the boundary layer width, and the mode flag, selecting the corresponding current command generation logic according to whether the mode flag is currently a grid-connected flag or an island flag, and calculating the drive voltage command in combination with the sliding mode compensation channel; 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 moment of state transition.

[0067] In the control loop of the seamless on-grid and off-grid 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, allowing it to simultaneously read the sliding mode error signal, boundary layer width, and mode flag within the calculation window of the current sampling cycle. The read operation is completed via an on-chip direct data bus. The sliding mode error signal is written to the register unit early in the same cycle by the sliding mode 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 functions have a single write-multiple read property, ensuring consistent data versions during reads.

[0068] The instruction reconstruction thread first decodes the mode flag. If the mode flag is a grid-connected flag, the grid-connected mode current command generation logic is dispatched according to the design. If the mode flag is an island flag, the island mode current command generation logic is activated. The grid-connected mode current command generation logic uses the phase-locked loop synchronization angle based on the active power and reactive power targets output by the power outer loop, generates baseline active and reactive current components through the proportional channel, and then uses the real-time estimated value of the equivalent grid-side impedance to perform impedance feedforward decoupling, preemptively offsetting the effects of grid impedance changes on current phase and amplitude. The sliding-mode error signal is then mapped into a sliding-mode compensation current component through the sliding-mode compensation channel, and the boundary layer width is used to suppress the high frequency of this component. The island mode current command generation logic generates the island baseline current component based on the estimated power of the local load and the output impedance coefficient. It reads the instantaneous rate of change of the bus voltage to construct the virtual inertia current component, 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 current inner loop's fast comparator and is subtracted from the real-time sampled current. The digital controller then generates a modulated duty cycle, synthesizing it into the drive voltage command. Because the sliding-mode compensation channel and boundary layer width maintain the same mathematical structure in both modes, the impact of switching 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 experience step changes within the same sampling period when the mode is flipped.

[0069] To further prevent sudden jumps in values, the driving voltage instruction is also passed through a first-order slope-limiting filter before being issued. The time constant of this filter is less than half a sampling period, which can flatten the peak without delaying the main dynamics. After all operations are completed, the thread calls the isolated communication interface at the end of the sampling period to write the driving voltage instruction into the duty cycle register of the power driver board. The power driver board then updates the pulse width modulation signal in the next carrier period and acts on the inverter bridge arm. If a change in the mode flag is detected within the entire sampling window, the thread will immediately reload the corresponding current instruction generation logic and recalculate the driving voltage instruction in the current period to achieve an instantaneous response to the legal conversion after hysteresis and anti-shake. Through this instruction reconstruction mechanism combining synchronous reading, branch selection, sliding mode compensation and slope-limiting filtering, the present invention can ensure the continuity and smoothness of voltage, current and power trajectories at the switching moment of any direction between the grid-connected mode and the island mode, avoiding the energy mutation and inverter instability caused by inconsistent logic switching points or asynchronous data in the traditional scheme, and ultimately achieving a truly seamless switching between grid and off-grid.

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

[0071]

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

[0073]

[0074] The meaning of each parameter in the formula is as follows:

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

[0076] The driving voltage command u(t) realizes the real-time modulation of the inverter bridge arm duty cycle through the coordination of three actions, so that the grid-connected and off-grid seamless switching control method based on the adaptive sliding mode observer can maintain the continuity of voltage, current and power trajectories when switching between grid-connected mode and island mode. * (t) The reference voltage signal is directly taken from the output of the phase-locked loop to ensure that the voltage waveform at the driving end is synchronized with the grid or the virtual synchronization source inside the island. Since the phase of the phase-locked loop remains continuous during the mode switching process, v * (t) provides a global phase anchor point for the voltage trajectory. By the filter inductor L fThe physical meaning of the difference between the current derivative and the inductor voltage drop is the feedforward compensation: is the real-time current change rate, which is obtained by numerically differentiating the adjacent sampling values. The reference current change rate derived from the outer loop control target, the difference between the two represents the instantaneous amplitude of the current inner loop error in the differential domain, the error is multiplied by L f The inductive voltage at the inductor end is then offset, thereby suppressing the high-frequency phase lag of the current closed loop and improving the transient response speed during on-grid and off-grid switching. is the sliding mode approach component, where σ(t) is derived from the unique sliding mode error signal, Δ(t) is the boundary layer width, and the ratio of the two is passed through the saturation function sat(·) to form the approach term. The boundary layer width limits the amplitude of the approach term to suppress chattering. Adaptive sliding mode gain Real-time estimation of equivalent grid-side impedance Dynamic changes: When connected to the grid and the public grid impedance is low, is very small, γ(t) decreases accordingly, the approach speed decreases but the chattering suppression is enhanced; when the system enters the island mode or the grid impedance increases, becomes larger, γ(t) is enhanced to maintain the error convergence quickly, while the filter capacitor C f The equivalent voltage support capability is determined by the denominator The gain is further adjusted to ensure that energy consistency is maintained under different filter shapes. The instruction generation thread completes the above three calculations at the head of each control cycle and summarizes the results into a single u(t) value. The limiter is then used to detect whether the drive voltage instruction is out of bounds. If it is out of bounds, it is truncated according to the hardware maximum duty cycle limit to prevent power stage saturation. The verified u(t) is written into the duty cycle register of the power driver board at the end of the sampling cycle. The power driver board refreshes the pulse width modulation pulse in the next carrier cycle so that the inverter bridge arm voltage follows the new target at the physical level. Since v * (t), σ(t), Δ(t) and All are updated synchronously within the same cycle, and the sliding-mode compensation channel and boundary layer width adaptation mechanism remain fully consistent between grid-connected and island modes. When the mode flag flips, the drive voltage command only changes the baseline current derivation path and gain value, without any amplitude or phase discontinuity, thereby ensuring the continuity and smoothness of the voltage, current, and power at the inverter output. The entire set of formulas is implemented using hardware parallel arithmetic logic, with a single-cycle latency of no more than one-third of the main clock period, providing ample time budget for rapid switching. All parameters are stored in a register-mapped format 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 synchronously read. The corresponding current command generation logic is selected based on the mode flag. If the flag is a grid-connected flag, 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 island flag, the island mode current command generation logic is called, and the island current reference is obtained by superimposing the proportional channel, the derivative channel, and the 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 drive voltage command is obtained by modulating the power stage current inner loop. At the same time, the sliding mode compensation channel is used to suppress chattering. The drive voltage command is issued to the power driver board in a timed triggering manner to ensure that the drive voltage command amplitude is continuous and the phase is coherent at the moment of state transition. Before the end of the current sampling cycle, the command issuance completion flag is written to achieve a seamless transition of the inverter output voltage, current, and power, and maintain the integrity and stability of the data flow and timing flow of the entire adaptive sliding mode observer control closed loop.

[0078] In a seamless on-grid and off-grid switching control method based on an adaptive sliding mode observer, to ensure continuous and stable control links during state switching, the system controller triggers synchronous sampling at the beginning of each control cycle, triggered by a master clock. The system controller first simultaneously reads the sliding mode error signal, boundary layer width, and mode flag from the register resources. This synchronous reading is coordinated by the bus scheduler. The three sets of data are physically derived from the sliding surface construction module, the boundary layer width adaptive generation module, and the mode determination module, respectively. These data are then connected to a unified data buffer via independent channels, ensuring that the processing results of each submodule are consistent within the same control cycle, thus avoiding confusion in the instruction generation logic caused by inconsistent read timing. The controller immediately performs a branch judgment after obtaining the mode flag. 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 a 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, and is the only basis for the ideal output current trajectory of the inverter under grid-connected conditions.

[0079] If the current mode flag is set to "islanding," the controller instead schedules the islanding mode current command generation logic. It uses the proportional channel to calculate the local load matching current component, introduces the derivative channel to generate the virtual inertia support component, and then uses the sliding mode compensation channel to obtain the error correction component. These three components are combined to form the islanding current reference for use in islanding operation. The controller then subtracts the generated current reference from the real-time sampled inverter output current. The result is passed to the power stage current inner loop controller for modulation. The inner loop, taking into account sampling delay and the filter inductance model, outputs the drive voltage command for use in the next stage. In the sliding mode compensation channel, the error signal is normalized to within the boundary layer width constraint. A saturation function is used to limit the maximum compensation amplitude to prevent high-frequency jitter from causing step changes in the drive voltage. Once generated, the drive voltage command is not issued immediately. Instead, it is written to the duty cycle register of the power driver board by a timer trigger logic at the end of the current sampling cycle. The power driver board updates the command during the next pulse width modulation cycle, ensuring that the drive voltage command always lags the controller output by less than half a sampling cycle, ensuring continuous duty cycle variation and phase coherence in the drive chain. After the instruction is written, the controller writes the instruction issuance completion flag through the status register. This flag is used in the diagnostic channel and the safety watchdog system in the next cycle to prevent instruction delays, blocking, or repeated issuance. Since this method always reuses the unified sliding mode compensation structure and boundary layer width adjustment mechanism during the mode switching process, only the current instruction generation logic branch is switched, and all control paths strictly limit the reading, calculation, and issuance sequence within the time axis, ultimately achieving a seamless and smooth transition of the inverter output voltage, current, and power between the grid-connected state and the island state. At the same time, 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. Any link is driven by the status update flag. In conjunction with the hardware-level interrupt protection mechanism, the entire adaptive sliding mode observer control loop is guaranteed to have consistent data, stable timing, and fast response in long-term operation, and is not affected by external disturbances and structural changes caused by mode switching, thereby comprehensively improving the system control performance and dynamic stability.

[0080] The following is a specific implementation example of a seamless on-grid and off-grid switching control method based on an adaptive sliding mode observer. This example applies to a single-phase inverter system with a rated capacity of 5kW, connected to a 220V / 50Hz grid. The inverter uses an LCL filter structure with on-grid and off-grid switching capabilities, and 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 root mean square amplitude: N v =0.5V; Current sensor noise RMS amplitude: N i =0.1A.

[0082] Assume that a certain control cycle time is t, the system is running in the grid-connected state, and the real-time sampling 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 grid-side impedance estimation:

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

[0084]

[0085] Substitute the data and calculate:

[0086]

[0087] Then calculate the sliding mode approaching term saturation function input:

[0088]

[0089] Assume that the saturation function sat(x) is linear saturation with unit slope, then

[0090]

[0091] Calculate the sliding mode gain:

[0092]

[0093] Calculate the sliding mode approach term:

[0094]

[0095] Then calculate the inductor feedforward compensation term:

[0096]

[0097] Assume the current reference voltage is v * (t) = 220V, then the driving voltage command is:

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

[0099] Finally, the driving voltage command u(t) is sent digitally to the PWM duty cycle control channel of the power driver board. Since the system operates in the grid-connected mode, the current command generation logic selects the grid-connected path in the current control cycle, and the current inner loop uses i * (t) and i f (t) After comparing the error, the modulation control is completed. If the system detects that the logic value of the discriminant function is greater than zero and remains for 5 consecutive control cycles, the state will switch to the island mode, and the controller will automatically switch to the island 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 remains continuous at the moment of state switching, achieving seamless transition.

[0100] Figure 2 The figure shows the curve of the change of the real-time estimated value of the equivalent grid-side impedance during the switching process from grid connection to island connection. Figure 2 As shown in the figure, the horizontal axis represents the time axis, and the vertical axis represents the amplitude of the real-time estimated equivalent grid-side impedance. During the grid-connected mode operation phase, the real-time estimated equivalent grid-side impedance remains near the nominal impedance level, showing 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 island environment. The figure also shows the upper and lower protection lines, which are used to prevent the real-time estimated equivalent grid-side impedance from exceeding the reasonable range due to algorithm divergence. The entire change process demonstrates the rapid response of the power difference iteration logic to changes in grid-side impedance.

[0101] Figure 3 The figure shows the response characteristics of the sliding-mode error signal and the adaptive boundary layer width during the switching process. The figure contains two curves: 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 maintains a relatively stable value. When switching between grid and off-grid, the sliding-mode error signal exhibits significant abrupt changes and oscillations. Simultaneously, the boundary layer width is adjusted based on the real-time weighted calculation of the voltage sensor noise amplitude and the current sensor noise amplitude to adapt to the disturbance at the switching moment. After the switching is completed, the sliding-mode error signal gradually converges, and the boundary layer width also tends to the new stable value, indicating that the adaptive boundary layer can effectively suppress chattering during the switching process.

[0102] Figure 4 The relationship between the logic value of the discriminant function and the switching timing of the mode flag is shown. Figure 4 It is divided into two parts: the upper part shows the continuous change of the discriminant function logic value over time, and the lower part shows the discrete switching state of the mode flag. During the grid-connected mode operation, the discriminant function logic value remains in the negative value area below the judgment tolerance, and the corresponding mode flag outputs the grid-connected flag. When the difference between the real-time estimated value of the equivalent grid-side impedance and the nominal grid-side impedance, and the weighted combination of the grid-connected voltage and the bus voltage amplitude deviation exceeds the judgment tolerance, the discriminant function logic value turns positive. In order to prevent misjudgment caused by transient disturbances, the system requires the discriminant function logic value to remain stable within a preset number of continuous control cycles. Only when the conditions are met will the mode flag switch from the grid-connected flag to the island flag to ensure the reliability of the switching decision.

[0103] Figure 5 The seamless transition waveform of the inverter output bus voltage during the grid-connected and off-grid switching process is described. The solid line in the figure represents the instantaneous waveform of the inverter output bus voltage, and the dotted line represents the grid-connected end voltage signal as a reference. In the grid-connected mode, the inverter output bus voltage maintains good amplitude and phase synchronization with the grid-connected end voltage signal. When the switching moment arrives, the inverter output bus voltage achieves a seamless transition from the grid-connected mode to the island mode through the coordinated control of the sliding mode error signal, the boundary layer width and the mode flag. The voltage waveforms before and after the switching show good amplitude continuity and phase coherence, and there is no voltage jump or phase mutation. This shows that the control method of the present invention can ensure that the driving voltage instruction amplitude is continuous and the phase is coherent at the moment of state transition, and achieves a smooth transition of the inverter output voltage, current and power, verifying the effectiveness of the seamless switching control strategy.

[0104] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions described in the above embodiments can still be modified, or some of the technical features thereof can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A seamless switching control method for on-grid and off-grid based on an adaptive sliding mode observer, characterized in that: The method comprises: Step 1: Synchronously collect the grid-connected voltage signal and the filter inductor current signal during each control cycle. Use the power difference iteration logic to continuously update the real-time estimated value of the equivalent grid-side impedance. Implement upper and lower limit protection on the estimated result. Once updated, write the result to the shared memory. Step 2: Using the instantaneous error between the inverter output bus voltage and the phase-locked loop reference voltage as a benchmark, the real-time estimated value of the equivalent grid-side impedance and the impedance compensation value generated by the grid-connected voltage signal and the filtered inductor current signal are superimposed. This is then combined with the long-term accumulated error in the bus voltage to form a unique sliding mode error signal. Step 3: Based on the pre-calibrated voltage and current sensor noise amplitudes, the absolute value of the inverter output bus voltage and the absolute value of the filter inductor current derivative are taken in real time during operation, and linearly weighted according to a fixed ratio to obtain the boundary layer width; Step 4: Call the real-time estimated value of the equivalent grid-side impedance and compare it 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 discriminant function logic value through fixed weight combination and judgment tolerance comparison; convert the logic value into a mode flag to distinguish between grid-connected mode and island mode, and keep it valid during the current control cycle.

2. The method for seamless on-grid and off-grid switching control based on an adaptive sliding mode observer according to claim 1, characterized in that: In step 1, in each sampling cycle, the grid-connected voltage signal and the filter inductor current signal are synchronously sampled and ensured to share the same timestamp; the instantaneous power deviation is written into the circular buffer, a power memory window is set, and compared with the historical power deviation of the previous sampling cycle to obtain the power recursive difference; the power recursive difference is used to drive the iterative update logic, and the equivalent grid-side impedance real-time estimation value is monotonically recursively corrected, and the upper and lower limit thresholds are set to prevent numerical divergence; 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 method for seamless on-grid and off-grid switching control based on an adaptive sliding mode observer according to claim 2, wherein: Step 2 specifically includes: 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 real-time estimated value of the equivalent grid-side impedance from the global shared memory, and generating an impedance compensation error signal by combining the real-time sampled grid-connected voltage signal and the filtered inductor current signal; adding the instantaneous voltage error signal, the impedance compensation error signal and the long-term deviation of the bus voltage accumulated through the integral channel to generate a unique sliding mode error signal; then, writing the sliding mode error signal into a register unit, which maintains the same access address in the grid-connected mode and the island mode, so that there is no need to rebuild the memory mapping table when switching states; and outputting a sliding mode error signal update completion flag.

4. The method for seamless on-grid and off-grid switching control based on an adaptive sliding mode observer according to claim 3, wherein: Step 3 specifically includes: in the power-on self-test phase, obtaining the voltage sensor noise root mean square amplitude and the current sensor noise root mean square amplitude respectively through the experimental calibration process, and storing them in a non-volatile memory in a read-only form; secondly, during operation, synchronously reading the inverter output bus voltage absolute value and the filter inductor current derivative absolute value in each control cycle, and multiplying the bus voltage absolute value with the voltage sensor noise root mean square amplitude, and multiplying the inductor current derivative absolute value with the current sensor noise root mean square amplitude, to obtain two noise weighted quantities; performing linear weighted synthesis on the two noise weighted quantities according to a fixed ratio to generate the boundary layer width corresponding to the current control cycle, and storing it in the register unit in a cyclic write manner; and outputting a boundary layer width update completion flag.

5. The method for seamless on-grid and off-grid switching control based on an adaptive sliding mode observer according to claim 4, characterized in that: Step 4 specifically includes: reading the real-time estimated value of the equivalent grid-side impedance, and performing a difference comparison with the nominal grid-side impedance measured when entering grid-connected operation to form a relative impedance change; synchronously reading the grid-connected terminal voltage signal and the inverter output bus voltage signal, calculating the amplitude deviation between the two, and using it to characterize the voltage synchronization state of the grid-connected point; linearly combining the relative impedance change and the voltage amplitude deviation according to a fixed weight, and comparing them with the judgment tolerance 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, and when the discriminant function logic value meets the grid-connected state, the mode flag bit is generated. The grid-connected flag is output when the condition is met, and the islanding flag is output when the discriminant function logic value meets the islanding condition; after the grid-connected flag is output, the following safety actions are performed synchronously: keep the inverter output frequency and phase consistent with the grid-connected voltage amplitude, lock the closed state of the grid-connected relay, continuously monitor the change of the discriminant function logic value and prohibit any unauthorized instructions from modifying the drive voltage instruction; after the islanding flag is output, the following safety actions are performed synchronously: disconnect the grid-connected 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 stable and start the local load power supply.

6. The method for seamless on-grid and off-grid switching control based on an adaptive sliding mode observer according to claim 5, characterized in that: When the logic value of the discriminant function is less than or equal to zero and the logic value of the discriminant function remains unchanged within a preset number of continuous control cycles, it is determined that the grid connection condition is met and a grid connection flag is output; When the logic value of the discriminant function is greater than zero and the logic value of the discriminant function remains unchanged within a preset number of continuous control cycles, it is determined that the island condition is met and an island flag is output; When the logic value of the discriminant function produces any invalid jump within the 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.

7. The method for seamless on-grid and off-grid switching control based on an adaptive sliding mode observer according to claim 6, characterized in that: The preset number of continuous control cycles is not less than two control cycles and not more than ten control cycles.

8. The method for seamless on-grid and off-grid switching control based on an adaptive sliding mode observer according to claim 7, characterized in that: After step 4, the method further includes: synchronously reading the sliding mode error signal, the boundary layer width, and the mode flag; selecting the corresponding current command generation logic according to whether the mode flag is currently a grid-connected flag or an island flag; and calculating the drive voltage command in combination with the sliding mode compensation channel; and sending the drive voltage command to the power drive board at the end of each sampling cycle to ensure the continuity of voltage, current, and power at the moment of state transition.

9. The method for seamless on-grid and off-grid switching control based on an adaptive sliding mode observer according to claim 8, characterized in that: At the beginning of each control cycle, the sliding mode error signal, boundary layer width, and mode flag are synchronously read; the corresponding current command generation logic is selected according to the mode flag. If the flag is a grid-connected flag, 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 island flag, the island mode current command generation logic is called, and the island current reference is obtained by superimposing the proportional channel, derivative channel and sliding mode compensation channel; The current reference of the selected logic output is subtracted from the real-time sampling value of the inverter output current, and the drive voltage command is obtained through power stage current inner loop modulation. At the same time, the saturation function and boundary layer width are used to suppress the chattering of the sliding mode compensation channel. The drive voltage command is sent to the power driver board in a timed trigger manner to ensure that the drive voltage command amplitude is continuous and the phase is coherent at the moment of state transition. The command issuance completion flag is written before the end of the current sampling cycle to achieve a seamless transition of the inverter output voltage, current and power, and keep the data flow and timing flow of the entire adaptive sliding mode observer control closed loop complete and stable.

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

  • Grid-connected and off-grid smooth switching control system and method for micro-grid inverter

    CN118473012A

  • Complementary sliding mode control method for grid-connected inverter based on cascaded generalized proportional-integral observer

    CN120110191A

  • Standalone and Grid-Tie Power inverter

    US20120057383A1