Energy storage grid-connected and off-grid switching control method under household micro-grid scene and related equipment

By collecting multi-source data in home microgrids, using a lightweight decision tree model and a digital phase-locked loop frequency composite state output switching command, combined with time-division pre-synchronization of phase angle and amplitude and virtual impedance parameters, the problem of misjudgment and inrush current caused by single parameter judgment in existing technologies is solved, and more reliable energy storage system switching and home power stability are achieved.

CN121618588APending Publication Date: 2026-03-06GUANGDONG LVDA NEW ENERGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511736993.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-25
Publication Date
2026-03-06

AI Technical Summary

Technical Problem

Existing grid-connected and off-grid switching control methods for household microgrids rely on a single grid parameter, which can easily lead to misjudgments or delays under complex operating conditions. They cannot adapt to random fluctuations in photovoltaic output and user load, resulting in switching failures or inrush currents, endangering equipment safety, and failing to meet household electricity needs.

Method used

Multi-source data is collected, and a lightweight decision tree model is used to analyze and combine the voltage difference and digital phase-locked loop frequency to output switching commands. Time-division pre-synchronization of phase angle and amplitude is executed, and virtual impedance parameters are dynamically calculated to form closed-loop control and optimize the switching between dual energy storage units and grid load.

Benefits of technology

It significantly improves the accuracy of the system's judgment of the power grid status and the reliability of switching decisions, reduces voltage and current surges during switching, ensures the safety of energy storage devices and household appliances, and achieves adaptability to complex operating conditions and meets electricity demand.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121618588A_ABST
    Figure CN121618588A_ABST
Patent Text Reader

Abstract

The invention discloses an energy storage grid-connected and off-grid switching control method in a household micro-grid scene and related equipment, which can effectively overcome the defect that a traditional scheme depends on a single parameter and is easy to misjudge, so that a system can more intelligently cope with complex operation conditions in the household scene and can better meet the electricity demand of a family. The method comprises the following steps: collecting multi-source data, preprocessing the multi-source data, and uploading the preprocessed multi-source data to a real-time database; data of a real-time database is analyzed through a lightweight decision tree model, a grid-connected and off-grid switching instruction is output in combination with the composite state of a voltage difference value and the digital phase-locked loop frequency, and the voltage difference value is the voltage difference value of the power grid voltage and the double energy storage units; the digital phase-locked loop frequency is used for keeping the same frequency rhythm of the voltage and current frequency and the current frequency of the dual energy storage unit; and controlling time-sharing pre-synchronization of phase angle pre-synchronization and amplitude pre-synchronization according to the grid-connected and off-grid switching instruction, and dynamically calculating a virtual impedance parameter so as to realize switching between the double energy storage units and a power grid load.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of energy storage technology, and in particular to an energy storage and off-grid switching control method and related equipment in a home microgrid scenario. Background Technology

[0002] With the popularization of distributed photovoltaics, home microgrids, as a form of integrating distributed energy, are receiving widespread attention. Currently, in home microgrids, energy storage systems are the main equipment for energy operation, while grid-connected and off-grid switching control methods are used as power supply switching methods.

[0003] Existing traditional grid-connected / off-grid switching control methods largely rely on threshold detection of single grid parameters. Switching is executed when a grid anomaly is detected. However, relying on a single parameter is prone to misjudgment or delays when facing complex operating conditions such as voltage sags and frequency fluctuations, leading to switching failures or system shocks. Furthermore, at the moment of switching, if there are differences in voltage amplitude and phase between the microgrid and the main grid, it can trigger a huge inrush current, endangering the safety of power electronic converters and energy storage devices. Therefore, current control methods are ill-suited to the random fluctuations in photovoltaic output and user load in residential scenarios, thus failing to meet household electricity demands. Summary of the Invention

[0004] To address the aforementioned technical issues, this application provides a method and related equipment for energy storage and off-grid switching control in a home microgrid scenario.

[0005] The technical solution provided in this application is described below: The first aspect of this application provides a method for energy storage and off-grid switching control in a home microgrid scenario, the method comprising: Collect multi-source data, including grid parameters, photovoltaic data, dual energy storage unit operation data, and user electricity consumption data; The multi-source data is preprocessed and then uploaded to the real-time database; The data in the real-time database is analyzed by a lightweight decision tree model, and the combined state output of voltage difference and digital phase-locked loop frequency is combined with the off-grid switching command. The voltage difference is the difference between the grid voltage and the voltage of the dual energy storage unit. The digital phase-locked loop frequency is used to keep the voltage and current frequency and the current frequency of the dual energy storage unit at the same frequency rhythm. According to the on-grid and off-grid switching command, the phase angle pre-synchronization and amplitude pre-synchronization are controlled in a time-division pre-synchronization manner, and the virtual impedance parameters are dynamically calculated to realize the switching between the dual energy storage unit and the grid load. Collect the operating parameters after the switch, including the energy storage parameters of the dual energy storage unit, the current balance parameters of the dual energy storage unit, and the grid load stability parameters. The parameters of the lightweight decision tree model and the virtual impedance coefficient are modified based on the operating parameters to form a closed-loop control.

[0006] Optionally, the data in the real-time database is analyzed using a lightweight decision tree model, and a combined state output of voltage difference and digital phase-locked loop frequency is generated, along with an off-grid switching command, including: Extract grid data, including grid voltage, dual energy storage unit output voltage, grid current frequency, and dual energy storage unit output current frequency, from the real-time database. Based on the power grid data, the voltage difference between the power grid and the dual energy storage unit and the digital phase-locked loop frequency are calculated to form composite state parameters; The composite state parameters are input into a lightweight decision tree model, which determines the off-grid handover conditions based on the composite state parameters and generates the determination results. Based on the judgment result, generate and output an offline switching instruction.

[0007] Optionally, according to the grid-connected / off-grid switching command, time-division pre-synchronization of phase angle and amplitude is performed, and virtual impedance parameters are dynamically calculated to realize the switching between the dual energy storage unit and the grid load, including: Receive and disconnect from the network; The handover type and direction are obtained according to the on-grid / off-grid handover command, and the target phase angle and amplitude reference are determined. Based on the target phase angle, the output voltage phase angle of the dual energy storage unit is adjusted to match the target phase angle to complete phase angle pre-synchronization; After the phase angle pre-synchronization is determined, the output voltage amplitude of the dual energy storage unit is adjusted to match the amplitude reference according to the target amplitude to complete the time-division pre-synchronization. The virtual impedance parameters are dynamically calculated based on the grid current data after time-sharing pre-synchronization and the current demand of the dual energy storage units. The switching between the dual energy storage unit and the grid load is controlled based on the time-sharing pre-synchronization state and the virtual impedance parameters.

[0008] Optionally, the lightweight decision tree model parameters and the virtual impedance coefficient are modified based on the operating parameters to form closed-loop control, including: Collect operating parameters after switching; Obtain the deviation values ​​between the operating parameters and the target operating parameters; The decision parameters and virtual impedance coefficient of the lightweight decision tree model are corrected based on the deviation value. The corrected judgment parameters and virtual impedance coefficients are verified to check the deviation and iterated to form a closed-loop control.

[0009] Optionally, the multi-source data is preprocessed and then uploaded to a real-time database, including: The collected multi-source data is preprocessed to obtain preprocessed data; The preprocessed data is classified according to preset rules to obtain classification numbers; The sorted data is obtained by sorting the classification numbers from largest to smallest; The sorted data is uploaded to a real-time database for storage.

[0010] Optionally, based on the grid data, the voltage difference between the grid and the dual energy storage unit and the digital phase-locked loop frequency are calculated to form composite state parameters. The method further includes: Align the sampling timestamps of the grid voltage and the output voltage of the dual energy storage units; The voltage difference between the dual energy storage unit and the power grid is obtained based on the sampling timestamp, and the target voltage difference parameter is determined. The initial frequency deviation is calculated based on the grid current frequency and the output current frequency of the dual energy storage unit. The initial frequency deviation is input into the digital phase-locked loop, and the convergence deviation is adjusted to a threshold by PI to obtain the synchronized digital phase-locked loop frequency. The target voltage difference parameter is integrated with the digital phase-locked loop frequency to form a composite state parameter.

[0011] Optionally, the composite state parameters are input into a lightweight decision tree model, which determines the off-grid handover conditions based on the composite state parameters and generates a determination result, including: The composite state parameters are normalized. Determine the preset and offline handover threshold; The normalized composite state parameters are processed using the lightweight decision tree model to obtain the target threshold. The target threshold is compared with the preset on-grid / off-grid handover threshold to obtain the comparison result; A judgment result is generated based on the comparison results, and the judgment result includes meeting the requirements for grid connection, meeting the requirements for off-grid connection, or not switching for the time being. A second aspect of this application provides an energy storage and off-grid switching control device for a home microgrid scenario, the device comprising: The first acquisition unit is used to acquire multi-source data, including grid parameters, photovoltaic data, dual energy storage unit operation data, and user electricity consumption data. The uploading unit is used to preprocess the multi-source data and then upload it to the real-time database; The output unit is used to analyze the data in the real-time database through a lightweight decision tree model, and output the combined state of voltage difference and digital phase-locked loop frequency, and send off-grid switching instructions. The voltage difference is the difference between the grid voltage and the voltage of the dual energy storage unit. The digital phase-locked loop frequency is used to keep the voltage and current frequencies at the same frequency rhythm as the current frequency of the dual energy storage unit. The switching unit is used to control the time-division pre-synchronization of phase angle pre-synchronization and amplitude pre-synchronization according to the grid-connected / off-grid switching command, and dynamically calculate the virtual impedance parameters to realize the switching between the dual energy storage unit and the grid load. The second acquisition unit is used to acquire the operating parameters after the switch, including the energy storage parameters of the dual energy storage unit, the current balance parameters of the dual energy storage unit, and the grid load stability parameters. The control unit modifies the parameters of the lightweight decision tree model and the virtual impedance coefficient based on the operating parameters to form closed-loop control.

[0012] A third aspect of this application provides an energy storage and off-grid switching control device for a home microgrid scenario, the device comprising: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor invokes to perform the method as described in the first aspect and any one of the first aspects.

[0013] A fourth aspect of this application provides a computer-readable storage medium on which a program is stored, which, when executed on a computer, performs the methods described in the first aspect and any one of the first aspects.

[0014] As can be seen from the above technical solutions, this application has the following beneficial effects: 1. This application significantly improves the accuracy of the system's judgment on the power grid status and the reliability of switching decisions by collecting multi-source data and using a lightweight decision tree model for intelligent analysis. This effectively overcomes the shortcomings of traditional solutions that rely on a single parameter and are prone to misjudgment, enabling the system to more intelligently cope with complex operating conditions in home scenarios and better meet the electricity needs of households.

[0015] 2. During the switching process, this application triggers time-sharing pre-synchronization control through composite state judgment, and then adjusts the phase and amplitude independently in sequence, thereby greatly reducing the voltage and current surges that may occur during mode switching. This smooth switching process not only protects equipment such as energy storage converters, but also ensures the power supply continuity of electrical loads in the home, improving the user experience.

[0016] 3. This application automatically optimizes the power distribution between the two energy storage units during off-grid operation by dynamically calculating virtual impedance parameters. This effectively suppresses circulating current problems between units, ensures current balance, and enables the two energy storage units to work together stably to support the local microgrid, thereby enhancing the voltage and frequency stability of the system in off-grid mode.

[0017] 4. This application constructs a closed-loop optimization mechanism, which continuously corrects the decision tree model and virtual impedance coefficient by collecting the actual operating parameters after switching, thereby enabling the system to have adaptive capabilities and continuously optimize its performance as the running time accumulates, maintaining a high-efficiency and reliable operating state in the long term. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a schematic diagram of an embodiment of the energy storage and off-grid switching control method for a residential microgrid scenario according to this application; Figure 2 This is a schematic diagram of another embodiment of the energy storage and off-grid switching control method in the home microgrid scenario of this application; Figure 3 This is a schematic diagram of another embodiment of the energy storage and off-grid switching control method in the home microgrid scenario of this application; Figure 4 This is a schematic diagram of another embodiment of the energy storage and off-grid switching control method in the home microgrid scenario of this application; Figure 5 This is a schematic diagram of another embodiment of the energy storage and off-grid switching control method in the home microgrid scenario of this application; Figure 6 This is a schematic diagram of another embodiment of the energy storage and off-grid switching control method in the home microgrid scenario of this application; Figure 7 This is a schematic diagram of another embodiment of the energy storage and off-grid switching control method in the home microgrid scenario of this application; Figure 8 This is a schematic diagram of an embodiment of the energy storage and off-grid switching control device for a home microgrid scenario according to this application; Figure 9 This is a schematic diagram of another embodiment of the energy storage and off-grid switching control device in the home microgrid scenario of this application. Detailed Implementation

[0020] Existing traditional grid-connected / off-grid switching control methods largely rely on threshold detection of single grid parameters. Switching is executed when a grid anomaly is detected. However, relying on a single parameter is prone to misjudgment or delays when facing complex operating conditions such as voltage sags and frequency fluctuations, leading to switching failures or system shocks. Furthermore, at the moment of switching, if there are differences in voltage amplitude and phase between the microgrid and the main grid, it can trigger a huge inrush current, endangering the safety of power electronic converters and energy storage devices. Therefore, current control methods are ill-suited to the random fluctuations in photovoltaic output and user load in residential scenarios, thus failing to meet household electricity demands.

[0021] Based on this, this application provides an energy storage and off-grid switching control method and related equipment in a home microgrid scenario. It can effectively overcome the shortcomings of traditional solutions that rely on a single parameter and are prone to misjudgment, enabling the system to cope more intelligently with the complex operating conditions in the home scenario and better meet the electricity needs of the home.

[0022] Please see Figure 1 The first aspect of this application provides a method for energy storage and off-grid switching control in a residential microgrid scenario, the method comprising: 101. Collect multi-source data, including grid parameters, photovoltaic data, dual energy storage unit operation data, and user electricity consumption data; 102. The multi-source data is preprocessed and then uploaded to the real-time database; 103. Analyze the data in the real-time database through a lightweight decision tree model, and output the combined state of voltage difference and digital phase-locked loop frequency, and issue an off-grid switching command. The voltage difference is the difference between the grid voltage and the voltage of the dual energy storage unit. The digital phase-locked loop frequency is used to keep the voltage and current frequencies at the same frequency rhythm as the current frequency of the dual energy storage unit. 104. Control the phase angle pre-synchronization and amplitude pre-synchronization according to the grid-connected / off-grid switching command, and dynamically calculate the virtual impedance parameters to realize the switching between the dual energy storage unit and the grid load; 105. Collect the operating parameters after the switch, including the energy storage parameters of the dual energy storage unit, the current balance parameters of the dual energy storage unit, and the grid load stability parameters. 106. Based on the operating parameters, modify the parameters of the lightweight decision tree model and the virtual impedance coefficient to form a closed-loop control.

[0023] In this embodiment, multi-source data is first collected, including grid parameters, photovoltaic data, dual energy storage unit operation data, and user electricity consumption data. The multi-source data is then preprocessed and uploaded to a real-time database. A lightweight decision tree model analyzes the data in the real-time database and outputs a grid-connected switching command based on the combined state of the voltage difference and the digital phase-locked loop (PLL) frequency. The voltage difference is the difference between the grid voltage and the voltage of the dual energy storage unit. The PLL frequency is used to maintain the voltage and current frequencies at the same frequency as the current frequency of the dual energy storage unit. Furthermore, based on the grid-connected / off-grid switching command, time-division pre-synchronization of phase angle and amplitude is controlled, and virtual impedance parameters are dynamically calculated to achieve the switching between the dual energy storage unit and the grid load. After the switching, operating parameters are collected, including the energy storage parameters of the dual energy storage unit, the current balance parameters of the dual energy storage unit, and the grid load stability parameters. Finally, the lightweight decision tree model parameters and virtual impedance coefficients are corrected based on the operating parameters to form a closed-loop control.

[0024] Specifically, in step 101, multi-source data is first collected. Grid parameters include real-time grid voltages such as line voltage, phase voltage, operating frequency, active power, reactive power, and harmonic content on the grid side. These parameters directly reflect the current operating status of the grid and are important references for determining whether grid-connected / off-grid switching is suitable. Photovoltaic data includes solar irradiance, output voltage and current of the photovoltaic array, real-time power, and operating temperature of the photovoltaic panels. Since photovoltaic output fluctuates significantly due to natural conditions, this data can support the assessment of the overall power balance of the system. Dual energy storage unit operating data includes the state of charge (SOC), charging and discharging current, charging and discharging voltage, individual cell voltage balance of the energy storage batteries, and the operating temperature of the battery pack for each energy storage unit. This data relates to the operational safety and power output capacity of the energy storage units themselves and is an important reference for controlling the participation of energy storage units in the switching process. User electricity consumption data includes real-time load power on the user side, power change curves during typical electricity consumption periods, and the proportion of different types of loads. This data helps assess the impact of load demand on system stability during the switching process, ensuring that user electricity demand is met after the switch.

[0025] In step 102, after collecting multi-source data, the collected data undergoes preprocessing. Since the raw data may contain missing values ​​(e.g., data interruptions due to brief sensor malfunctions), outliers (e.g., sudden voltage spikes and drops caused by external interference), and inconsistent units (e.g., voltage in volts and power in kilowatts), directly using these data could affect the accuracy of subsequent analysis. The preprocessing process first involves data cleaning, filling missing values ​​with linear interpolation and filtering outliers using the 3σ principle or thresholds based on the rated parameters of the power grid and energy storage equipment. Next, data standardization is performed, converting parameters with different units into a unified range of 0-1 or -1-1 to avoid model analysis bias due to differences in numerical ranges. Finally, data timestamp alignment is performed. Since the collection frequencies of power grid, photovoltaic, energy storage, and user data may differ (e.g., power grid data collected 10 times per second, photovoltaic data collected 5 times per second), interpolation or sampling is needed to unify all data to the same time interval to ensure data temporal consistency. The preprocessed dataset is uploaded to a real-time database in real time, which must have high read / write speeds and data caching capabilities.

[0026] In step 103, after uploading the preprocessed data to the real-time database, the lightweight decision tree model reads the preprocessed multi-source data from the real-time database. This model is obtained by removing redundant branches and retaining grid voltage, energy storage SOC and load power on the basis of traditional decision trees. It has the characteristics of low computational load and fast response speed, and can meet the real-time requirements of grid-connected and off-grid switching.

[0027] During model analysis, the focus is on the combined state formed by voltage difference and digital phase-locked loop (PLL) frequency. Voltage difference is the real-time calculated difference between the grid voltage and the output voltage of the dual energy storage units. For example, when the grid line voltage is 380V and the energy storage unit output line voltage is 375V, the difference is 5V. This difference directly affects the magnitude of the inrush current during switching; an excessively large difference can easily lead to damage to the switching equipment or power outages. The PLL frequency, on the other hand, tracks the grid voltage and current frequency in real-time through the PLL circuit and adjusts the output current frequency of the dual energy storage units to maintain the same frequency rhythm. For example, if the grid frequency is 50Hz, the energy storage unit output current frequency needs to be stable at 50±0.2Hz to avoid power oscillations caused by frequency deviation.

[0028] The model then determines that the grid connection conditions are met based on preset decision rules, such as a voltage difference ≤ ±5% of the rated voltage and a digital phase-locked loop frequency deviation ≤ ±0.2Hz. When the grid voltage drops below 80% of the rated value, it determines that off-grid operation is required. The model combines multi-source data and composite states to make logical judgments and finally outputs a clear grid connection / off-grid switching instruction, such as "execute grid connection switching in 0.5 seconds" or "execute off-grid switching immediately". This instruction will be directly transmitted to the subsequent control module to guide the switching operation.

[0029] In step 104, after receiving the grid-connected / off-grid switching command, the control module first performs time-sharing pre-synchronization control of phase angle pre-synchronization and amplitude pre-synchronization. Considering that simultaneous adjustment of phase angle and amplitude could easily lead to excessive fluctuations in the output voltage of the energy storage unit, a time-sharing strategy is adopted. That is, amplitude pre-synchronization is performed first. By adjusting the duty cycle of the charging and discharging PWM signals of the dual energy storage units, the output voltage amplitude of the energy storage unit is gradually adjusted to match the grid voltage amplitude. This process requires real-time reference to the grid voltage data in the real-time database.

[0030] After amplitude pre-synchronization is completed, phase angle pre-synchronization is performed. By adjusting the output phase of the energy storage unit inverter, the phase difference between the output voltage of the energy storage unit and the grid voltage is reduced to ≤±5°. During the adjustment process, the phase signal output by the digital phase-locked loop is used as a reference to avoid circulating current during switching due to excessive phase difference. At the same time, virtual impedance parameters are dynamically calculated. The virtual impedance is not the actual physical impedance, but the impedance characteristics simulated in the inverter control loop through the control algorithm. Its function is to suppress circulating current between the two energy storage units and inrush current during switching.

[0031] During the calculation process, the output current and load current data of the dual energy storage units are collected in real time. The impedance coefficient is dynamically adjusted according to the formula: Virtual impedance value = (energy storage unit voltage difference - load voltage drop) / circulating current. For example, when the current difference between the dual energy storage units is detected to exceed 10% of the rated current, the virtual impedance coefficient is increased to weaken the circulating current, ensuring a smooth switching process between the dual energy storage units and the grid load, and avoiding impact on the load and equipment.

[0032] In step 105, after the switching operation is completed, it is necessary to further collect the system's operating parameters to evaluate the switching effect and provide data for subsequent optimization. The energy storage parameters of the dual energy storage units include the real-time SOC, charging and discharging power, the highest and lowest single-cell voltage of the battery pack, and the battery pack temperature for each unit. The current balance parameters of the dual energy storage units include the real-time current difference between the two units, the current balance error rate, and the current balance fluctuation range over a continuous 5-minute period. This parameter directly reflects the consistency of the dual energy storage units' operation. The grid load stability parameters include the maximum fluctuation of the grid voltage and frequency within one minute after the switching, the rate of change of load power, and whether a load power outage occurred. These parameters are the core indicators for judging whether the switching was successful. The collected operating parameters are fed back to the data processing module in real time and compared with preset standard thresholds to identify deviations in the current system operation.

[0033] In step 106, based on the collected operating parameters and deviation analysis results, the parameters of the lightweight decision tree model and the virtual impedance coefficient are corrected to form closed-loop control. Specifically, for the lightweight decision tree model, if the grid voltage fluctuations frequently exceed the threshold after switching, it indicates that the voltage difference threshold for judging the switching timing in the model may be too large, and the threshold needs to be adjusted, while optimizing the model's feature weights. If frequent load power outages occur during off-grid switching, the judgment logic for the "load power surge" feature needs to be added to the model. For the virtual impedance coefficient, if the current balancing error rate of the dual energy storage units continuously exceeds the preset value, it indicates that the original virtual impedance coefficient is too small, and a dynamic correction coefficient of 20% needs to be increased based on the ratio of the current difference to the rated current, for example, when the current difference reaches 15% of the rated current, to ensure effective suppression of circulating current.

[0034] If the inrush current is too large during switching, the influence factor of "voltage difference at the switching moment" needs to be added to the virtual impedance calculation. The corrected parameters will be updated to the lightweight decision tree model and control module, and will take effect in the next data acquisition, preprocessing, analysis, control, and parameter acquisition process. Through continuous closed-loop correction, the stability and reliability of the switching between the dual energy storage unit and the grid load are continuously improved.

[0035] Please refer to Figure 2 According to some embodiments of the present invention, step 103, which analyzes the data in the real-time database using a lightweight decision tree model and combines the composite state output of voltage difference and digital phase-locked loop frequency with the off-grid switching command, may specifically include, but is not limited to, the following: 201. Extract grid data, including grid voltage, dual energy storage unit output voltage, grid current frequency, and dual energy storage unit output current frequency, from the real-time database; 202. Calculate the voltage difference between the power grid and the dual energy storage unit and the digital phase-locked loop frequency based on the power grid data to form composite state parameters; 203. Input the composite state parameters into the lightweight decision tree model. The model determines the off-grid handover conditions based on the composite state parameters and generates the determination results. 204. Generate and output a network off-grid switching command based on the judgment result.

[0036] In this embodiment, the power grid data extracted from the real-time database serves as the direct basis for subsequent analysis. This data must accurately reflect the electrical state of the power grid and the dual energy storage unit, specifically including the grid voltage, the output voltage of the dual energy storage unit, the grid current frequency, and the output current frequency of the dual energy storage unit. This data is filtered from pre-processed multi-source data uploaded to the real-time database, ensuring the temporal consistency and accuracy of the data.

[0037] Based on the extracted grid data, the voltage difference between the grid and the dual energy storage unit is first calculated. Specifically, the effective value of the grid voltage is compared with the effective value of the output voltage of the dual energy storage unit one by one to obtain the voltage difference of each phase. For example, if the grid voltage of phase A is 220V and the energy storage output voltage of phase A is 218V, then the voltage difference of phase A is 2V. The maximum value of the three-phase difference is taken as the final voltage difference parameter. This value directly reflects the degree of matching between the voltage amplitudes of the two. The smaller the difference, the closer it is to the voltage conditions required for switching.

[0038] Simultaneously, the digital phase-locked loop (PLL) frequency is calculated. This process is implemented through a PLL algorithm, which tracks the grid current frequency in real time and compares the output current frequency of the dual energy storage units with the grid current frequency to obtain the frequency deviation value. For example, if the grid frequency is 50.02Hz and the energy storage output frequency is 49.98Hz, the frequency deviation is 0.04Hz. This deviation value is used as the PLL frequency parameter to measure the synchronization degree between the two frequencies. It should be noted that the voltage difference and the PLL frequency together constitute a composite state parameter. This composite state parameter comprehensively reflects the matching state between the grid and the dual energy storage units in terms of voltage amplitude and frequency, providing a primary basis for determining switching conditions.

[0039] The composite state parameters are then input into the lightweight decision tree model. The model will analyze and judge according to the preset decision logic. This lightweight model is optimized and only retains key decision nodes related to voltage difference and digital phase-locked loop frequency. For example, when the voltage difference is set to ≤3V and the digital phase-locked loop frequency deviation is set to ≤0.05Hz, it is determined that the grid connection switching conditions are met. When the grid voltage difference suddenly increases to more than 10V or the frequency deviation exceeds 0.5Hz, it is determined that off-grid switching needs to be performed.

[0040] During the judgment process, the model will combine the real-time changing trend of composite state parameters, such as whether the voltage difference continues to shrink or suddenly expands, to avoid misjudgment due to instantaneous fluctuations, and finally generate clear judgment results, such as "meets grid connection conditions", "needs to disconnect from the grid immediately" or "do not switch for the time being". These results directly correspond to subsequent operation instructions.

[0041] Based on the model's output, the system generates and outputs specific grid connection / off-grid switching commands. If the grid connection conditions are met, the command includes the switching execution time and the pre-synchronization module to be activated during the switching process. If the result indicates grid disconnection is required, the command will immediately disconnect the grid connection and activate the independent power supply mode of the dual energy storage units, while specifying the protection parameters during the switching process. If the result indicates no switching for the time being, the command will trigger a continuous monitoring mechanism, requiring the grid data to be retrieved again and the judgment process to be repeated periodically. These switching commands are transmitted to the control module, directly guiding subsequent phase angle and amplitude pre-synchronization and virtual impedance adjustment operations to ensure accurate execution of grid connection / off-grid switching.

[0042] Please refer to Figure 3 According to some embodiments of the present invention, step 104, which involves performing time-division pre-synchronization of phase angle and amplitude according to the grid-connected / off-grid switching command and dynamically calculating virtual impedance parameters to achieve the switching between the dual energy storage unit and the grid load, may specifically include, but is not limited to, the following: 301. Receive and disconnect from the network as instructed; 302. Obtain the switching type and direction according to the on-grid / off-grid switching instruction, and determine the target phase angle and amplitude reference; 303. Based on the target phase angle, adjust the output voltage phase angle of the dual energy storage unit to match the target phase angle to complete phase angle pre-synchronization; 304. After determining the phase angle pre-synchronization, adjust the output voltage amplitude of the dual energy storage unit to match the amplitude reference according to the target amplitude to complete the time-sharing pre-synchronization; 305. Calculate the virtual impedance parameters dynamically based on the grid current data after time-sharing pre-synchronization and the current demand of the dual energy storage units; 306. Based on the time-sharing pre-synchronization state and the virtual impedance parameters, control the switching between the dual energy storage unit and the grid load.

[0043] In this embodiment, upon receiving an instruction, the switching type and direction need to be determined based on the instruction, such as switching from off-grid to grid-connected or from grid-connected to off-grid. Different switching types and directions correspond to different target phase angles and amplitude references: when performing grid-connected switching, the target phase angle must be consistent with the real-time phase angle of the grid voltage, and the amplitude reference is based on the real-time amplitude of the grid voltage. This ensures that when the dual energy storage units are connected to the grid, there will be no excessive impact due to differences in phase angle and amplitude.

[0044] When switching off-grid, the target phase angle and amplitude reference need to be set according to the stable operation requirements of the load, usually referring to the voltage phase angle and amplitude range when the load is working normally in the off-grid state.

[0045] After determining the target phase angle, the output voltage phase angle of the dual energy storage unit needs to be further adjusted to match the target phase angle to complete phase angle pre-synchronization. During this process, a digital phase-locked loop (PLL) monitors the target phase angle in real time. If the system is grid-connected, the grid voltage phase angle is monitored; if it is off-grid, a preset load phase angle reference is used, and the current output voltage phase angle of the dual energy storage unit is compared with the target phase angle to calculate the phase angle difference. Subsequently, by adjusting the control signal of the dual energy storage unit inverter, this phase angle difference is gradually reduced until the deviation is controlled within a very small range, such as ±2°. At this point, phase angle pre-synchronization is completed, establishing a basis for amplitude regulation and preventing circulating current or power fluctuations caused by phase angle differences during switching.

[0046] After confirming phase angle pre-synchronization, the output voltage amplitude of the dual energy storage unit can be adjusted according to the target amplitude to match the amplitude reference, thus completing time-sharing pre-synchronization. The time-sharing method is used to avoid mutual interference when adjusting phase angle and amplitude simultaneously, which could lead to excessive voltage fluctuations. During amplitude adjustment, the current output voltage amplitude of the dual energy storage unit is collected in real time and compared with the target amplitude. When connected to the grid, the grid voltage amplitude is used; when off-grid, the voltage amplitude required by the load is used. The output voltage amplitude is changed by adjusting the inverter's pulse width modulation signal until the amplitude deviation is controlled within the allowable range. After this step, the output voltage of the dual energy storage unit meets the basic switching conditions in terms of both phase angle and amplitude.

[0047] Next, the virtual impedance parameters are dynamically calculated based on the grid current data after time-sharing pre-synchronization and the current demand of the dual energy storage units. Specifically, after time-sharing pre-synchronization, the electrical state between the grid and the dual energy storage units is relatively close, but there may still be slight current differences or potential surge risks. Grid current data reflects the current carrying capacity and current change trend of the grid, while the current demand of the dual energy storage units is related to their own state of charge and the power demand of the load. For example, when the load power suddenly increases, the dual energy storage units need to output a larger current. The calculation of virtual impedance parameters takes these factors into account and adjusts them in real time through algorithms to suppress possible circulating currents, such as current imbalances between the dual energy storage units and surge currents during switching, ensuring smooth current changes.

[0048] Finally, the switching between the dual energy storage units and the grid load is controlled based on the time-sharing pre-synchronization state and the calculated virtual impedance parameters. The time-sharing pre-synchronization state ensures that the voltage phase angle and amplitude meet the switching requirements, providing a stable voltage foundation for switching; while the virtual impedance parameters further optimize the current distribution and changes by simulating appropriate impedance characteristics. In actual switching operations, the system will precisely control the timing and speed of the relevant switching devices according to these states and parameters, enabling the dual energy storage units to smoothly connect or disconnect from the grid load. Throughout the process, the impact on the grid and load must be minimized to ensure the stable operation of the system.

[0049] Please refer to Figure 4 According to some embodiments of the present invention, step 106, which involves modifying the lightweight decision tree model parameters and the virtual impedance coefficient based on the operating parameters to form closed-loop control, may specifically include, but is not limited to, the following: 401. Collect operating parameters after switching; 402. Obtain the deviation values ​​between the operating parameters and the target operating parameters; 403. Correct the judgment parameters and virtual impedance coefficient of the lightweight decision tree model based on the aforementioned deviation value; 404. Verify the deviation of the corrected judgment parameters and virtual impedance coefficients and iterate to form a closed-loop control.

[0050] In this embodiment, after switching between the dual energy storage units and the grid load, it is first necessary to collect the operating parameters after the switch. These parameters are the basis for evaluating the switching effect and realizing closed-loop control. Specifically, the operating parameters include the real-time state of charge, charging and discharging current and voltage of the dual energy storage units, the voltage equalization of individual cells, and the operating temperature. These data reflect the output capacity and safety of the energy storage units after the switch. They also include current equalization parameters of the dual energy storage units, such as the current difference between the two units and the current equalization error rate, used to determine the consistency of the energy storage unit operation. In addition, there are grid load stability parameters, such as the fluctuation range of grid voltage, frequency deviation, rate of change of load power, and whether load interruption occurs after the switch, which directly reflect the impact of the switch on system stability. The acquisition frequency of these parameters needs to be synchronized with the previous multi-source data acquisition to ensure temporal continuity.

[0051] After collecting the operating parameters, it is necessary to calculate the deviation between these parameters and the target operating parameters. This step is crucial for evaluating the switching effect and correcting the parameters. The target operating parameters are preset thresholds based on system design requirements and safe operation standards. For example, the target SOC range for dual energy storage units is set at 20%-80%, the current balancing error rate must be controlled within 5%, grid voltage fluctuations should not exceed ±3% of the rated value, and frequency deviations must be maintained within ±0.1Hz. When calculating the deviation, each parameter needs to be quantified. For instance, if the actual SOC of a certain energy storage unit is 15%, the deviation from the target lower limit of 20% is -5%; if the actual current balancing error rate of the two units is 8%, the deviation from the target value of 5% is +3%. Through this quantified deviation analysis, it is possible to clearly identify which system indicators did not meet expectations after the switch, providing direction for subsequent parameter corrections.

[0052] Based on the aforementioned deviation values, the next step is to correct the judgment parameters and virtual impedance coefficient of the lightweight decision tree model. For the lightweight decision tree model, its judgment parameters include voltage difference threshold, frequency deviation threshold, and the critical value of the energy storage unit's State of Charge (SOC). These parameters directly affect the generation of grid-connected / off-grid switching commands. For example, if grid voltage fluctuations exceed the target range multiple times after switching, and deviation analysis shows that this is due to excessive voltage difference during switching, then the voltage difference judgment threshold in the model needs to be lowered, for example, from ±5% of the rated voltage to ±3%, to trigger switching preparation earlier and reduce the impact.

[0053] If it is found that when the SOC of the energy storage unit is low, such as below 20%, insufficient output is likely to occur after switching, resulting in large fluctuations in load power. In this case, the critical SOC judgment value in the model needs to be increased to ensure that the energy storage unit has sufficient support capacity during switching. The virtual impedance coefficient is used to suppress circulating current and inrush current. If the deviation value shows that the current balancing error rate of the two energy storage units continues to exceed the standard, it indicates that the current virtual impedance coefficient is insufficient to balance the current of the two units. The coefficient needs to be increased according to the degree of deviation; for example, when the error rate deviation is +3%, the coefficient should be increased by 10%.

[0054] If the inrush current during switching causes excessive deviation in the grid frequency, a weighting factor for the frequency deviation needs to be introduced into the calculation of the virtual impedance so that the coefficient can dynamically respond to frequency changes and enhance the suppression effect.

[0055] The corrected judgment parameters and virtual impedance coefficients are not directly applied to the system. Their effectiveness needs to be ensured through verification of deviations and iteration, ultimately forming closed-loop control.

[0056] Specifically, the corrected parameters are applied to the control process of the next grid-connected / off-grid switchover. The operating parameters after the switchover are re-acquired, and the deviation from the target operating parameters is recalculated and compared with the deviation before correction. If the new deviation value is significantly reduced, the correction measures are effective, and the current parameters can be used as a benchmark. If the deviation value does not improve or even increases, the cause needs to be analyzed, such as whether the parameter correction was too large, leading to new fluctuations. In this case, the judgment parameters and virtual impedance coefficient need to be adjusted again. This verification and iteration process is repeated continuously as the system runs. Each iteration optimizes the parameters based on the previous deviation data, making the lightweight decision tree model's judgment more accurate and the virtual impedance adjustment more suitable for the actual operating state of the system. Ultimately, this achieves dynamic balance between the dual energy storage units and the grid load switchover, ensuring stable operation of the entire system under various operating conditions.

[0057] Please refer to Figure 5 According to some embodiments of the present invention, the step 102 of preprocessing the multi-source data and uploading it to the real-time database may specifically include, but is not limited to, the following: 501. Preprocess the collected multi-source data to obtain preprocessed data; 502. Classify the preprocessed data according to preset rules to obtain classification numbers; 503. Sort the classification numbers from largest to smallest to obtain sorted data; 504. Upload the sorted data to a real-time database for storage.

[0058] In this embodiment, firstly, when preprocessing the collected multi-source data to obtain preprocessed data, the multi-source data includes grid parameters, photovoltaic data, dual energy storage unit operation data, and user electricity consumption data, which are consistent with the data sources collected in the previous step 101. The preprocessing process continues the previous data cleaning, standardization, and timestamp alignment operations. After such preprocessing, the obtained preprocessed data can more accurately reflect the actual operating status of each link.

[0059] Next, the preprocessed data is classified according to preset rules to obtain classification numbers. These preset rules need to be formulated based on the characteristics of the data and the needs of system operation. For example, the data can be classified according to the urgency of the system status it reflects. Critical data related to system safety, such as significant drops in grid voltage and low SOC of energy storage units, can be classified into high-priority categories, corresponding to smaller classification numbers (such as 1 and 2). Non-urgent data, such as gradual changes in photovoltaic irradiance and normal fluctuations in user electricity consumption, are classified into low-priority categories, corresponding to larger classification numbers (such as 5 and 6). Alternatively, the data can be classified according to data type, for example, all grid parameter-related data can be classified into one category (classification number 3), and photovoltaic data into another category (classification number 4), etc.

[0060] Through this classification, each preprocessed data point is assigned a unique classification number, allowing the attributes and importance of the data to be intuitively reflected through the classification number.

[0061] Then, the classification numbers are sorted from largest to smallest to obtain sorted data. The purpose of sorting is to optimize the priority of data upload and storage. Since the importance of the data has already been reflected by the classification numbers, sorting by classification number from largest to smallest will place lower priority data first and higher priority data last. This sorting method can be combined with the storage strategy of real-time databases. For example, when database storage resources are limited, priority can be given to ensuring the real-time storage and access speed of high-priority data, while low-priority data can be stored sequentially to avoid the processing of critical data being affected by a large amount of low-priority data consuming resources.

[0062] Finally, the sorted data is uploaded to a real-time database for storage. The sorted data stream enters the real-time database in descending order of classification number. The database allocates storage resources and access permissions based on the sorting results, ensuring that high-priority data can be written and read quickly, meeting the needs of subsequent real-time analysis by the lightweight decision tree model. This ordered storage also facilitates data management and retrieval by the database. When the model needs to access data of a specific type or priority, it can quickly locate the data based on the classification number and sorting order, improving the overall data processing efficiency of the system.

[0063] Please refer to Figure 6 According to some embodiments of the present invention, the calculation of the voltage difference between the power grid and the dual energy storage unit and the digital phase-locked loop frequency based on the power grid data in step 202 to form composite state parameters may specifically include, but is not limited to, the following: 601. Align the sampling timestamps of the grid voltage and the output voltage of the dual energy storage units; 602. Based on the sampling timestamp, obtain the voltage difference between the dual energy storage unit and the power grid, and determine the target voltage difference parameter; 603. Calculate the initial frequency deviation based on the grid current frequency and the output current frequency of the dual energy storage unit; 604. Input the initial frequency deviation into the digital phase-locked loop, and adjust the convergence deviation to a threshold through PI to obtain the synchronized digital phase-locked loop frequency; 605. Integrate the target voltage difference parameter with the digital phase-locked loop frequency to form a composite state parameter.

[0064] In this embodiment, before analyzing and controlling the grid-connected / off-grid switching, it is necessary to ensure the consistency of voltage and frequency data between the grid and the dual energy storage unit in terms of time and value. First, the sampling timestamps of the grid voltage and the dual energy storage unit output voltage must be aligned. This is because the grid voltage and the dual energy storage unit output voltage are typically acquired by different sensors, and due to differences in sensor response speed and data transmission paths, there may be slight deviations in their sampling times. This time deviation will cause the subsequently calculated voltage difference to lose its actual physical meaning and fail to accurately reflect the voltage relationship between the two at the same moment. Therefore, it is necessary to use a unified clock signal as a reference and, through GPS-based time synchronization, adjust the timestamps of the grid voltage sampling data and the dual energy storage unit output voltage sampling data to the same moment, ensuring that each set of compared voltage data corresponds to the same time point, providing a prerequisite for calculating the voltage difference.

[0065] After completing the sampling timestamp alignment, based on these synchronized timestamps, the values ​​of the output voltage of the dual energy storage units and the grid voltage at the same moment can be accurately obtained, and then the voltage difference between the two can be calculated.

[0066] Specifically, for a three-phase system, the voltage difference of each phase needs to be calculated separately, and then the overall voltage difference is obtained using the root mean square or average value method. The calculated real-time voltage difference is compared with a preset safety threshold to determine the target voltage difference parameter. If the real-time voltage difference is within the safety threshold range, the target voltage difference parameter can be set to the current real-time difference, indicating that the voltage conditions are close to synchronization. If the real-time voltage difference exceeds the safety threshold, the target voltage difference parameter needs to be set to a target value that converges to the safety threshold.

[0067] Simultaneously, frequency synchronization-related data needs to be processed. First, the initial frequency deviation is calculated based on the grid current frequency and the output current frequency of the dual energy storage unit. The grid current frequency is a key indicator of grid stability, while the output current frequency of the dual energy storage unit may deviate from that of the grid due to its own control strategy or load fluctuations. The calculation of the initial frequency deviation is based on synchronously sampled current data. The current frequencies of the grid and the energy storage unit are extracted separately using Fourier transform or zero-crossing detection methods, and then the difference is calculated. This deviation value directly reflects the degree of frequency asynchrony between the two.

[0068] Next, the calculated initial frequency deviation is input into the digital phase-locked loop (PLL). A PI controller brings the deviation within a set threshold range, thus obtaining the synchronized PLL frequency. The core function of the PLL is to track the grid frequency and adjust the output frequency of the energy storage units to maintain consistency. When the initial frequency deviation is input, the PI controller outputs an adjustment signal based on the magnitude and direction of the deviation: the proportional element immediately generates an adjustment amount based on the current deviation, quickly reducing the deviation; the integral element accumulates historical deviations, eliminating static errors and ensuring the deviation eventually stabilizes within the threshold. During the adjustment process, the PLL outputs the current frequency tracking value in real time. When the deviation between this value and the grid frequency remains within the threshold, frequency synchronization is considered achieved. The output frequency at this point is the synchronized PLL frequency, which will serve as the reference for the output current frequency of the dual energy storage units.

[0069] Finally, the target voltage difference parameter is integrated with the synchronized digital phase-locked loop (PLL) frequency to form a composite state parameter. During integration, the target voltage difference parameter and the PLL frequency need to be converted into standardized parameters with unified dimensions, and then weighted and fused to form a comprehensive index, i.e., the composite state parameter. This parameter comprehensively reflects the synchronization status of the grid and the dual energy storage unit in terms of voltage and frequency, providing crucial judgment criteria for subsequent lightweight decision tree model analysis and output of grid-connected switching commands.

[0070] Please refer to Figure 7 According to some embodiments of the present invention, in step 203, the composite state parameters are input into a lightweight decision tree model. The model determines the off-grid handover conditions based on the composite state parameters and generates a determination result, which may include, but is not limited to, the following: 701. Normalize the composite state parameters; 702. Determine the preset and offline handover threshold; 703. The normalized composite state parameters are processed using the lightweight decision tree model to obtain the target threshold; 704. Compare the target threshold with the preset on / off network handover threshold to obtain the comparison result; 705. Generate a judgment result based on the comparison result, the judgment result including meeting the grid connection requirement, meeting the off-grid requirement, or temporarily not switching. In this embodiment, after obtaining the composite state parameters of the voltage difference and the digital phase-locked loop frequency, these parameters are normalized. The normalization process converts these composite state parameters to the same numerical range, typically 0 to 1 or -1 to 1.

[0071] After normalization, it is necessary to further determine the preset grid connection / off-grid switching thresholds. These thresholds are baseline values ​​pre-set based on system safety operation requirements, equipment rated parameters, and past operating experience, used to define the boundary conditions for grid connection / off-grid switching. For example, in a grid-connected scenario, the preset voltage difference threshold might be set to 0.1 after normalization, corresponding to an actual voltage difference ≤ ±5V, and the preset digital phase-locked loop frequency deviation threshold might be set to 0.05 after normalization, corresponding to an actual frequency deviation ≤ ±0.2Hz. Only when both thresholds are simultaneously less than or equal to their respective preset thresholds can the basic grid connection conditions be met.

[0072] The preset thresholds for off-grid scenarios are even stricter. For example, if the grid voltage drops below 80% of its rated value, and the corresponding normalized voltage difference parameter is ≥0.8, the off-grid trigger condition is met. These preset thresholds are stored in the system as a reference benchmark for subsequent comparisons and judgments. Their settings must balance the timeliness of switching with system stability to avoid frequent switching or switching lag.

[0073] Next, the lightweight decision tree model processes the normalized composite state parameters to obtain the target threshold. This model contains multiple decision nodes, each corresponding to a different range of composite state parameters and its corresponding judgment logic. For example, the model first determines whether the normalized voltage difference is within a safe range. If so, it further analyzes the digital phase-locked loop (PLL) frequency deviation parameter. Through the logical judgment of multiple nodes, it finally outputs a target threshold that comprehensively reflects whether the current state is suitable for switching. This target threshold is a dynamic value calculated by the model based on real-time composite state parameters. For example, when the normalized voltage difference is 0.08 and the normalized frequency deviation is 0.03, the model might output a target threshold of 0.05. The smaller the target threshold, the closer it is to meeting the switching conditions.

[0074] After obtaining the target threshold, it is compared with the preset grid connection / offline switching threshold to obtain the comparison result. The comparison process needs to distinguish between grid connection and off-grid scenarios: In the grid connection judgment, if the target threshold is less than or equal to the preset grid connection threshold, it means that the current composite state parameters meet the core conditions for grid connection; if the target threshold is greater than the preset grid connection threshold, it means that the grid connection requirements are not met for the time being.

[0075] In the detachment determination, if the target threshold is greater than or equal to the preset detachment threshold, the detachment condition is met; otherwise, it is not. Simultaneously, the comparison results also consider parameter fluctuations. For example, if the target threshold approaches but fails to reach the preset threshold multiple times within a short period, it will be marked as "fluctuating state" to avoid misjudgments due to momentary interference.

[0076] Finally, a judgment result is generated based on the comparison results, including whether grid connection is met, grid disconnection is met, or no switching is required. When the comparison result for the grid connection scenario shows that the target threshold is less than or equal to the preset grid connection threshold, and other parameters in the real-time database are normal, the judgment result is "grid connection met." When the comparison result for the grid disconnection scenario shows that the target threshold is greater than or equal to the preset grid disconnection threshold, and a grid fault signal has been confirmed, the judgment result is "grid disconnection met." If the target threshold is between the preset grid connection and grid disconnection thresholds, or if a certain threshold is reached but other auxiliary parameters do not meet the requirements, a judgment result of "no switching required" is generated, and the system is triggered to continuously monitor changes in composite state parameters until conditions are met before re-judging. These judgment results directly serve as the basis for the lightweight decision tree model to output grid connection / disconnection switching instructions, ensuring the accuracy and reliability of the switching decision.

[0077] Please see Figure 8 The second aspect of this application provides an energy storage and off-grid switching control device for a home microgrid scenario, the device comprising: The first acquisition unit 801 is used to acquire multi-source data, including grid parameters, photovoltaic data, dual energy storage unit operation data and user electricity consumption data. Upload unit 802 is used to preprocess the multi-source data and then upload it to the real-time database; The output unit 803 is used to analyze the data in the real-time database through a lightweight decision tree model, and output a grid-off switching command by combining the composite state of voltage difference and digital phase-locked loop frequency. The voltage difference is the voltage difference between the grid voltage and the voltage of the dual energy storage unit. The digital phase-locked loop frequency is used to keep the voltage and current frequencies at the same frequency rhythm as the current frequency of the dual energy storage unit. The switching unit 804 is used to control the time-division pre-synchronization of phase angle pre-synchronization and amplitude pre-synchronization according to the grid connection and disconnection switching command, and dynamically calculate the virtual impedance parameters to realize the switching between the dual energy storage unit and the grid load. The second acquisition unit 805 is used to acquire the operating parameters after the switch, including the energy storage parameters of the dual energy storage unit, the current balance parameters of the dual energy storage unit, and the grid load stability parameters. The control unit 806 modifies the parameters of the lightweight decision tree model and the virtual impedance coefficient based on the operating parameters to form a closed-loop control.

[0078] Please see Figure 9 This application also provides an energy storage and off-grid switching control device for a home microgrid scenario, the device comprising: Processor 901, memory 902, input / output unit 903, bus 904; The processor 901 is connected to the memory 902, the input / output unit 903, and the bus 904; The memory 902 stores a program, and the processor 901 calls the program to execute any of the methods described above.

[0079] This application also relates to a computer-readable storage medium on which a program is stored, which, when run on a computer, causes the computer to perform any of the methods described above.

[0080] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0081] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between apparatuses or units, and may be electrical, mechanical, or other forms.

[0082] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0083] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0084] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A method for energy storage and off-grid switching control in a home microgrid scenario, characterized in that, The method comprises: Collecting multi-source data, the multi-source data comprising grid parameters, photovoltaic data, dual energy storage unit operation data and user electricity consumption data; Uploading the multi-source data to a real-time database after preprocessing; Analyzing the data of the real-time database through a lightweight decision tree model, and outputting an on-off grid switching instruction in combination with a composite state of a voltage difference and a digital phase-locked loop frequency, the voltage difference being a voltage difference between a grid voltage and a voltage of the dual energy storage unit, and the digital phase-locked loop frequency being used to keep the same frequency rhythm of the voltage and current frequencies and the current frequency of the dual energy storage unit; Controlling time-sharing presynchronization of phase angle presynchronization and amplitude presynchronization according to the on-off grid switching instruction, and dynamically calculating a virtual impedance parameter to realize switching between the dual energy storage unit and a grid load; Collecting operation parameters after switching, the operation parameters comprising energy storage parameters of the dual energy storage unit, current balance degree parameters of the dual energy storage unit and grid load stability parameters; Correcting the lightweight decision tree model parameters and the virtual impedance coefficient based on the operation parameters to form a closed-loop control.

2. The energy storage and off-grid switching control method in the home micro-grid scenario according to claim 1, characterized in that, The analyzing of the data of the real-time database through the lightweight decision tree model and the outputting of the on-off grid switching instruction in combination with the composite state of the voltage difference and the digital phase-locked loop frequency comprise: Extracting grid data of the grid voltage, the dual energy storage unit output voltage, the grid current frequency and the dual energy storage unit output current frequency from the real-time database; Calculating the voltage difference between the grid and the dual energy storage unit and the digital phase-locked loop frequency based on the grid data to form a composite state parameter; Inputting the composite state parameter into a lightweight decision tree model, the model judging the on-off grid switching condition based on the composite state parameter and generating a judgment result; Generating and outputting the on-off grid switching instruction according to the judgment result.

3. The energy storage and off-grid switching control method in the home micro-grid scenario according to claim 1, characterized in that, The execution of the time-sharing presynchronization of the phase angle presynchronization and the amplitude presynchronization according to the on-off grid switching instruction and the dynamic calculation of the virtual impedance parameter to realize the switching between the dual energy storage unit and the grid load comprise: Receiving the on-off grid switching instruction; Obtaining the switching type and direction according to the on-off grid switching instruction, and determining the target phase angle and amplitude reference; Adjusting the dual energy storage unit output voltage phase angle to be consistent with the target phase angle based on the target phase angle to complete the phase angle presynchronization; After determining that the phase angle presynchronization is completed, adjusting the dual energy storage unit output voltage amplitude to match the amplitude reference based on the target amplitude to complete the time-sharing presynchronization; Dynamically calculating the virtual impedance parameter according to the grid current data after the time-sharing presynchronization and the dual energy storage unit current demand; Controlling the switching between the dual energy storage unit and the grid load based on the time-sharing presynchronization state and the virtual impedance parameter.

4. The energy storage and off-grid switching control method in the home micro-grid scenario according to claim 1, characterized in that, The correcting of the lightweight decision tree model parameters and the virtual impedance coefficient based on the operation parameters to form the closed-loop control comprise: Collecting the operation parameters after switching; Obtaining the deviation value of the operation parameters from the target operation parameters; Correcting the judgment parameters of the lightweight decision tree model and the virtual impedance coefficient according to the deviation value; Verifying the deviation of the corrected judgment parameters and the virtual impedance coefficient and iterating to form the closed-loop control.

5. The energy storage and off-grid switching control method in the home micro-grid scenario according to claim 1, characterized in that, The multi-source data is pre-processed and uploaded to a real-time database, including: The collected multi-source data is pre-processed to obtain pre-processed data; The pre-processed data is classified according to a preset rule to obtain a classification number; The classification number is sorted from large to small to obtain sorted data; The sorted data is uploaded to a real-time database for storage.

6. The energy storage and off-grid switching control method in a home micro-grid scenario according to claim 2, characterized in that, Based on the grid data, the voltage difference between the grid and the dual energy storage unit and the digital phase-locked loop frequency are calculated to form a composite state parameter, and the method further includes: Aligning the sampling time stamps of the grid voltage and the output voltage of the dual energy storage unit; Based on the sampling time stamp, the voltage difference between the dual energy storage unit and the grid is obtained and the target voltage difference parameter is determined; According to the grid current frequency and the output current frequency of the dual energy storage unit, the initial frequency deviation is calculated; The initial frequency deviation is input into the digital phase-locked loop, and the PI adjustment is used to converge the deviation to a threshold value to obtain the synchronized digital phase-locked loop frequency; The target voltage difference parameter and the digital phase-locked loop frequency are integrated to form a composite state parameter.

7. The energy storage and off-grid switching control method in a home micro-grid scenario according to claim 2, characterized in that, The composite state parameter is input into a lightweight decision tree model, which judges the off-grid switching condition based on the composite state parameter and generates a judgment result, including: The composite state parameter is normalized; A preset off-grid switching threshold is determined; The normalized composite state parameter is processed by the lightweight decision tree model to obtain a target threshold; The target threshold is compared with the preset off-grid switching threshold to obtain a comparison result; According to the comparison result, a judgment result is generated, including meeting the grid connection, meeting the off-grid or temporarily not switching.

8. An energy storage and off-grid switching control device in a home micro-grid scenario, characterized in that, The device includes: A first acquisition unit for acquiring multi-source data, including grid parameters, photovoltaic data, dual energy storage unit operation data and user power consumption data; An upload unit for pre-processing the multi-source data and uploading it to a real-time database; An output unit for analyzing the data of the real-time database through a lightweight decision tree model, and outputting an off-grid switching instruction based on the composite state of the voltage difference and the digital phase-locked loop frequency, the voltage difference being the voltage difference between the grid voltage and the dual energy storage unit, and the digital phase-locked loop frequency being used to keep the voltage and current frequencies of the dual energy storage unit at the same frequency rhythm; A switching unit for controlling the time-sharing pre-synchronization of phase angle pre-synchronization and amplitude pre-synchronization according to the on-off grid switching instruction, and dynamically calculating a virtual impedance parameter to realize the switching of the dual energy storage unit and the grid load; A second acquisition unit for acquiring the running parameters after switching, including the energy storage parameters of the dual energy storage unit, the current balance degree parameters of the dual energy storage unit and the grid load stability parameters; A control unit for correcting the lightweight decision tree model parameters and the virtual impedance coefficient based on the running parameters to form a closed-loop control.

9. An energy storage and off-grid switching control device under a home micro-grid scenario, characterized in that, The device includes: A processor, a memory, an input / output unit and a bus; The processor is connected with the memory, the input / output unit and the bus; The memory stores a program, and the processor invokes the program to execute the method of any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a program, and the program executes the method of any one of claims 1 to 7 when executed on the computer.