Control method for grid-connected and off-grid switching of energy storage batteries, and energy storage battery system

By using decision tree and isolated forest models to monitor the grid status in real time and automatically control the grid-connected and off-grid switching of the energy storage battery system, the problem of intelligent control of the energy storage battery system during grid outages is solved, and the continuity and stability of household power supply are achieved.

WO2026098711A1PCT designated stage Publication Date: 2026-05-15GUANGZHOU RIMSEA TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
GUANGZHOU RIMSEA TECH CO LTD
Filing Date
2025-11-11
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing energy storage battery systems lack intelligent control when the grid is down, and cannot switch to off-grid mode in a timely manner, affecting the continuity and stability of household power supply.

Method used

The system employs decision tree and isolated forest models to monitor the power grid status in real time. Combined with control units, switching modules, and energy storage units in the energy storage battery system, it automatically determines the power grid supply status, realizes on-grid and off-grid switching control, and ensures the continuity and stability of household power supply.

Benefits of technology

Through real-time monitoring and automatic judgment, the energy storage battery system can intelligently switch over when the power grid is interrupted, ensuring the continuity and stability of household power supply, making full use of solar energy and battery energy storage systems, managing household load devices, and guaranteeing power demand.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025134147_15052026_PF_FP_ABST
    Figure CN2025134147_15052026_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present application are a control method for grid-connected and off-grid switching of energy storage batteries, and an energy storage battery system. The method is applied to the system. The energy storage battery system comprises a control unit, a first energy storage unit and a second energy storage unit, wherein the control unit comprises a mains supply detection module, a switch module and a control module; the first energy storage unit comprises a photovoltaic power generation module, a grid-connected module and a first energy storage battery; and the second energy storage unit comprises an off-grid module and a second energy storage battery. The method comprises: a control unit acquiring real-time monitoring data of a power grid, the state of charge of a first energy storage battery and the state of charge of a second energy storage battery; on the basis of the real-time monitoring data, determining a stability detection result of the power grid; respectively inputting the real-time monitoring data, the stability detection result, the state of charge of the first energy storage battery and the state of charge of the second energy storage battery into a decision tree model; and outputting a switching control result and an operation control result, and controlling an energy storage battery system to perform grid-connected and off-grid switching and load operation. Therefore, grid-connected and off-grid switching is intelligently performed, thereby ensuring a stable power supply for households.
Need to check novelty before this filing date? Find Prior Art

Description

A method for switching control between grid-connected and off-grid energy storage batteries and an energy storage battery system

[0001] Cross-reference to related applications

[0002] This application claims priority to Chinese Patent Application No. 202411597232X, filed on November 11, 2024, entitled “A Switching Control Method for On-Grid and Off-Grid Energy Storage Batteries and an Energy Storage Battery System”, the entire contents of which are incorporated herein by reference. Technical Field

[0003] This disclosure relates to the field of energy storage battery system technology, and more specifically, to a method for switching control between grid-connected and off-grid energy storage batteries and an energy storage battery system. Background Technology

[0004] With the rapid development and widespread adoption of clean energy, energy storage battery systems are playing an increasingly important role in home and industrial applications. These systems can utilize renewable energy sources, such as solar and wind power, for charging and release electrical energy to meet demand when needed. Their use not only improves the flexibility and stability of the power system but also helps reduce energy costs and carbon emissions, thus attracting significant attention.

[0005] However, current energy storage battery systems still face some challenges in practical applications. One of the most prominent problems is their insufficient responsiveness during grid outages. Traditional energy storage battery systems typically require manual intervention to switch to off-grid mode, lacking intelligent control and automated management. This results in the system's inability to respond promptly to grid outages, thus affecting the continuity and stability of household power supply.

[0006] Application content

[0007] In view of this, the purpose of this application is to provide a method and system for switching between grid-connected and off-grid energy storage batteries, which can intelligently switch between grid-connected and off-grid based on the real-time status of the grid and the mains power supply, so as to ensure the continuity and stability of household power supply.

[0008] The first objective of this application is to provide a method for switching between grid-connected and off-grid energy storage batteries, applied to an energy storage battery system. The energy storage battery system includes a control unit, a first energy storage unit, and a second energy storage unit. The first and second energy storage units are respectively connected to the control unit, which is connected to the mains power grid. The control unit includes a mains power detection module, a switching module, and a control module. The first energy storage unit includes a photovoltaic power generation module, a grid-connected module, and a first energy storage battery. The second energy storage unit includes an off-grid module and a second energy storage battery. The method includes:

[0009] The control unit acquires real-time monitoring data during the power grid supply process, the power level of the first energy storage battery in the first energy storage unit, and the power level of the second energy storage battery in the second energy storage unit.

[0010] Based on the real-time monitoring data, the stability test result of the power grid supply status is determined;

[0011] The real-time monitoring data, stability test results, and the power of the first energy storage battery, the power of the first energy storage battery, and the power of the second energy storage battery are respectively input into the nodes corresponding to the pre-constructed decision tree model.

[0012] The decision tree model processes the real-time monitoring data, stability detection results, the power levels of the first and second energy storage batteries, and outputs switching control results for the energy storage battery system and operation control results for the load. Based on the switching control results, it controls the switching module in the control unit, the grid-connected module in the first energy storage unit, and the off-grid module in the second energy storage unit to switch, and controls the operation of the load based on the operation control results.

[0013] In conjunction with the first objective, in some embodiments, the on-grid / off-grid energy storage battery switching control method, based on the real-time monitoring data, determines the stability detection result of the grid power supply state, including:

[0014] The real-time monitoring data is preprocessed to obtain preprocessed real-time monitoring data;

[0015] Based on the preprocessed real-time monitoring data, various mains power characteristics characterizing the mains power supply status are obtained; the mains power characteristics include real-time monitoring data directly used as mains power characteristics, and mains power characteristics obtained after processing at least one type of real-time monitoring data;

[0016] The various mains power features are input into a pre-trained isolated forest model, which processes each mains power feature and calculates the anomaly score of the data points in each mains power feature.

[0017] Based on the anomaly scores of data points in each mains power characteristic, it is determined whether there are abnormal data points in the mains power characteristic, so as to determine the stability detection result of the power grid power supply status.

[0018] In conjunction with the first objective, in the aforementioned on-grid and off-grid energy storage battery switching control method, the isolated forest model processes each type of mains power characteristic and calculates the anomaly score of data points in each type of mains power characteristic, including:

[0019] The isolated forest model processes each mains power feature and constructs a tree structure until the number of mains power feature data points included in each leaf node of the isolated forest model is less than a first preset threshold, or the isolated forest model reaches the maximum depth of the tree.

[0020] For each data point of each mains power characteristic, calculate the path length of the data point in the isolated forest model; the path length is the number of edges traversed from the root node to the data point.

[0021] Based on the path length of the data points, calculate the anomaly score for each type of mains power characteristic; the shorter the path length, the lower the anomaly score; the longer the path length, the higher the anomaly score.

[0022] In conjunction with the first objective, in some embodiments, the grid-connected / off-grid energy storage battery switching control method includes preprocessing the real-time monitoring data to obtain preprocessed real-time monitoring data; including:

[0023] Normalize different types of real-time monitoring data to obtain normalized real-time monitoring data;

[0024] Outliers in the normalized real-time monitoring data are filtered out to obtain preprocessed real-time monitoring data.

[0025] In conjunction with the first objective, in some embodiments, the grid-connected / off-grid energy storage battery switching control method comprises a decision tree model that processes the real-time monitoring data, stability detection results, the power levels of the first and second energy storage batteries, and outputs switching control results for the energy storage battery system and operation control results for the load, including:

[0026] The decision tree model determines whether the real-time monitoring data is normal.

[0027] If yes, then record the real-time monitoring data normally; if no, then determine whether the power grid supply status is stable based on the stability test results.

[0028] To determine whether the power grid supply status is stable, if yes, the switch module in the control unit is closed to maintain the grid-connected operation of the energy storage battery system and the grid; if no, the switch module is opened to switch to the off-grid operation of the energy storage battery system and the grid.

[0029] For off-grid operation, based on the charge levels of the first and second energy storage batteries in the energy storage battery system, the switching control results for the grid-connected module in the first energy storage unit and the off-grid module in the second energy storage unit, as well as the operation control results for the load, are determined.

[0030] In conjunction with the first objective, in some embodiments, the on-grid / off-grid energy storage battery switching control method, for the off-grid operation state, determines the switching control result for the grid-connected module in the first energy storage unit and the off-grid module in the second energy storage unit, and the operation control result for the load, based on the charge levels of the first and second energy storage batteries in the energy storage battery system. This includes:

[0031] For off-grid operation, determine the power assessment result of the first energy storage battery of the first energy storage unit and the power assessment result of the second energy storage battery of the second energy storage unit. Based on the power assessment results of the first and second energy storage batteries, determine the switching control result for the grid-connected module in the first energy storage unit and the off-grid module in the second energy storage unit, and the operation control result for the load.

[0032] The switching control result is either controlling the first energy storage unit to operate independently off-grid, or controlling the first energy storage unit and the second energy storage unit to operate jointly off-grid; the load operation control result is either the load operates normally or some loads are shut down.

[0033] In conjunction with the first objective, in some embodiments, the on-grid / off-grid energy storage battery switching control method includes, for the off-grid operation state, determining the power assessment result of the first energy storage battery of the first energy storage unit and the power assessment result of the second energy storage battery of the second energy storage unit, and based on the power assessment results of the first and second energy storage batteries, determining the switching control result for the grid-connected module in the first energy storage unit and the off-grid module in the second energy storage unit, and the operation control result for the load; including:

[0034] For off-grid operation, determine whether the charge of the first energy storage battery in the first energy storage unit is greater than a second preset threshold.

[0035] If the charge of the first energy storage battery is greater than the second preset threshold, the grid-connected module in the first energy storage unit is activated, and the charge of the first energy storage battery in the first energy storage unit in the off-grid operation state is monitored in real time to see if it is greater than the third preset threshold.

[0036] When the charge of the first energy storage battery is greater than the third preset threshold, it is determined that the first energy storage unit is independently powered, and the operation control result of the load is determined to maintain the normal operation of the load;

[0037] If the power of the first energy storage battery is less than or equal to the second preset threshold, or the power of the first energy storage battery is greater than the third preset threshold, then the off-grid module in the second energy storage unit is activated simultaneously, and the power of the second energy storage battery in the second energy storage unit is monitored in real time to see if it is greater than the fourth preset threshold.

[0038] When the charge of the second energy storage battery is greater than the fourth preset threshold, the operation control result of the load is determined to maintain the normal operation of the load.

[0039] When the charge of the second energy storage battery is less than or equal to the fourth preset threshold, the load operation control result is determined to keep the first preset load running and shut down other loads.

[0040] In conjunction with the first objective, in some embodiments, the on-grid and off-grid energy storage battery switching control method is based on the UDP local communication protocol to realize real-time communication between the control unit, the first energy storage unit, the second energy storage unit and the load of the energy storage battery system.

[0041] A second objective of this application is to provide an energy storage battery system, comprising a control unit, a first energy storage unit, and a second energy storage unit, wherein the first energy storage unit and the second energy storage unit are respectively connected to the control unit, and the control unit is connected to the mains power grid; the control unit includes a mains power detection module, a switching module, and a control module; the first energy storage unit includes a photovoltaic power generation module, a grid-connected module, and a first energy storage battery; the second energy storage unit includes an off-grid module and a second energy storage battery;

[0042] The control unit is used to acquire real-time monitoring data during the power grid supply process, the power of the first energy storage battery in the first energy storage unit, and the power of the second energy storage battery in the second energy storage unit.

[0043] It is also used to determine the stability detection result of the power grid supply status based on the real-time monitoring data;

[0044] It is also used to input the real-time monitoring data, stability test results, power of the first energy storage battery, power of the second energy storage battery, and power of the second energy storage battery into the nodes corresponding to the pre-constructed decision tree model, respectively.

[0045] It is also used in the decision tree model to process the real-time monitoring data, stability detection results, the power of the first energy storage battery and the power of the second energy storage battery, output the switching control results for the energy storage battery system and the operation control results for the load, and control the switching module in the control unit, the grid-connected module in the first energy storage unit and the off-grid module in the second energy storage unit to switch based on the switching control results, and control the operation of the load based on the operation control results.

[0046] In conjunction with the second objective, in some embodiments, in the energy storage battery system, the switching module of the control unit is disposed between the power grid and the control module, so that the energy storage battery system supplies power to the control module after the switching module is disconnected.

[0047] This application provides a method for switching control between grid-connected and off-grid energy storage batteries and an energy storage battery system, applied to an energy storage battery system. The energy storage battery system includes a control unit, a first energy storage unit, and a second energy storage unit. The first energy storage unit and the second energy storage unit are respectively connected to the control unit, which is connected to the mains power grid. The control unit includes a mains power detection module, a switching module, and a control module. The first energy storage unit includes a photovoltaic power generation module, a grid-connected module, and a first energy storage battery. The second energy storage unit includes an off-grid module and a second energy storage battery. The method includes: the control unit acquiring real-time monitoring data during grid power supply, the charge level of the first energy storage battery in the first energy storage unit, and the charge level of the second energy storage battery in the second energy storage unit; determining the stability detection result of the grid power supply state based on the real-time monitoring data; and processing the real-time monitoring data, the stability detection result, the charge level of the first energy storage battery, and the charge level of the second energy storage battery through a policy tree model. The system determines the switching control results for the energy storage battery system and the operation control results for the load based on the battery charge level. Based on the switching control results, it controls the switching module in the control unit, the grid-connected module in the first energy storage unit, and the off-grid module in the second energy storage unit to switch. Based on the operation control results, it controls the operation of the load. Thus, based on real-time monitoring of the grid status and mains power supply, it automatically judges and responds to grid outages and instability. Furthermore, it controls the switching of the first and / or second energy storage units in the energy storage battery system and informs other household load devices to perform corresponding operations. Through the cooperation of the control module, off-grid module, and grid-connected module in the energy storage battery system, the system ensures the continuity and stability of household power supply. The system can manage power supply more intelligently, fully utilize solar energy and battery storage systems, and, combined with the management of household loads, ensure the household's power needs in the event of unstable or interrupted mains power. Attached Figure Description

[0048] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0049] Figure 1 shows a flowchart of the on-grid and off-grid energy storage battery switching control method according to an embodiment of this application;

[0050] Figure 2 shows a schematic diagram of the energy storage battery system according to an embodiment of this application;

[0051] Figure 3 shows a flowchart of the method for determining the stability detection result of the power grid supply state according to an embodiment of this application;

[0052] Figure 4 illustrates the process by which the isolated forest model described in this embodiment processes each mains power characteristic.

[0053] Figure 5 shows a flowchart of the decision tree model described in this application processing the real-time monitoring data, stability detection results, the power of the first energy storage battery, and the power of the second energy storage battery. Detailed Implementation

[0054] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.

[0055] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0056] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.

[0057] With the rapid development and widespread adoption of clean energy, energy storage battery systems are playing an increasingly important role in home and industrial applications. These systems can utilize renewable energy sources, such as solar and wind power, for charging and release electrical energy to meet demand when needed. Their use not only improves the flexibility and stability of the power system but also helps reduce energy costs and carbon emissions, thus attracting significant attention.

[0058] However, current energy storage battery systems still face some challenges in practical applications. One of the most prominent problems is their insufficient responsiveness during grid outages. Traditional energy storage battery systems typically require manual intervention to switch to off-grid mode, lacking intelligent control and automated management. This results in the system's inability to respond promptly to grid outages, thus affecting the continuity and stability of household power supply.

[0059] Currently, although some control methods and system designs exist for grid-connected and off-grid energy storage battery systems, they still have some limitations. For example, some systems employ timer- or threshold-based control strategies, lacking real-time monitoring of grid status and mains power supply, thus failing to automatically assess and respond to grid outages. Additionally, some systems use remote monitoring and control methods, but this relies on internet connectivity, posing security and reliability risks.

[0060] Based on this, this application provides a method and system for switching control between grid-connected and off-grid energy storage batteries, applied to an energy storage battery system. The energy storage battery system includes a control unit, a first energy storage unit, and a second energy storage unit. The first energy storage unit and the second energy storage unit are respectively connected to the control unit, which is connected to the mains power grid. The control unit includes a mains power detection module, a switching module, and a control module. The first energy storage unit includes a photovoltaic power generation module, a grid-connected module, and a first energy storage battery. The second energy storage unit includes an off-grid module and a second energy storage battery. The method includes: the control unit acquiring real-time monitoring data during grid power supply, the charge of the first energy storage battery in the first energy storage unit, and the charge of the second energy storage battery in the second energy storage unit; determining the stability detection result of the grid power supply state based on the real-time monitoring data; and inputting the real-time monitoring data, the stability detection result, the charge of the first energy storage battery, the charge of the first energy storage battery, and the charge of the second energy storage battery into the nodes corresponding to a pre-constructed decision tree model. The policy tree model processes the real-time monitoring data, stability test results, and the power levels of the first and second energy storage batteries. It outputs switching control results for the energy storage battery system and operation control results for the load. Based on the switching control results, it controls the switching module in the control unit, the grid-connected module in the first energy storage unit, and the off-grid module in the second energy storage unit to switch. Based on the operation control results, it controls the operation of the load. Thus, based on real-time monitoring of the grid status and mains power supply, it automatically judges and responds to grid outages and instability. Furthermore, it controls the switching of the first and / or second energy storage units in the energy storage battery system and informs other household load devices to perform corresponding operations. Through the cooperation of the control module, off-grid module, and grid-connected module in the energy storage battery system, it ensures the continuity and stability of household power supply. The system can manage power supply more intelligently, fully utilize solar energy and battery storage systems, and, combined with the management of household loads, guarantee the household's power needs in the event of unstable or interrupted mains power.

[0061] Please refer to Figures 1 and 2. Figure 1 shows a flowchart of the grid-connected / off-grid energy storage battery switching control method according to an embodiment of this application; Figure 2 shows a structural schematic diagram of the energy storage battery system according to an embodiment of this application. The energy storage battery system includes a control unit, a first energy storage unit, and a second energy storage unit. The first energy storage unit and the second energy storage unit are respectively connected to the control unit, and the control unit is connected to the mains power grid. The control unit includes a mains power detection module 205, a switch module 204, and a control module 201. The first energy storage unit includes a photovoltaic power generation module 208, a grid-connected module 202, and a first energy storage battery 206. The second energy storage unit includes an off-grid module 203 and a second energy storage battery 207. Please refer to Figure 1. The method includes the following steps S101-S104:

[0062] S101, the control module 201 acquires real-time monitoring data during the power grid supply process, the power of the first energy storage battery 206 in the energy storage battery system connected to the grid-connected module 202, and the power of the second energy storage battery 207 in the energy storage battery system connected to the off-grid module 203.

[0063] S102. Based on the real-time monitoring data, determine the stability detection result of the power grid power supply status;

[0064] S103. Input the real-time monitoring data, stability test results, power of the first energy storage battery 206 and power of the second energy storage battery 207 into the nodes corresponding to the pre-built decision tree model respectively.

[0065] S104. The decision tree model processes the real-time monitoring data, stability detection results, the power of the first energy storage battery 206, and the power of the second energy storage battery 207, outputs the switching control results for the energy storage battery system and the operation control results for the load, and controls the grid-connected module 202, the off-grid module 203, and the switching module 204 to switch based on the switching control results, and controls the operation of the load based on the operation control results.

[0066] In step S101, the control module 201 acquires real-time monitoring data during the power grid supply process, the power of the first energy storage battery 206 in the energy storage battery system connected to the grid-connected module 202, and the power of the second energy storage battery 207 in the energy storage battery system connected to the off-grid module 203.

[0067] Referring to Figure 2, the mains power grid is connected to the household power grid to supply power to the load devices of the household power grid. The energy storage battery system also includes a mains power detection module 205; the mains power detection module 205 is located between the mains power grid and the switch module 204; the first energy storage unit includes a photovoltaic power generation module 208, a grid-connected module 202, and a first energy storage battery 206, the grid-connected module 202 is connected to the photovoltaic power generation module 208 and the energy storage battery, and the grid-connected module 202 is connected to the control module 201 of the control unit; the second energy storage unit includes an off-grid module 203 and a second energy storage battery 207, the off-grid module 203 is connected to the second energy storage battery 207, and the off-grid module 203 is connected to the control module 201.

[0068] The grid-connected module 202 is used to control the power supply of the first energy storage unit; the off-grid module 203 is used to control the power supply of the second energy storage unit.

[0069] Both the grid-connected module 202 and the off-grid module 203 are connected to the household power grid to control the first energy storage unit and the second energy storage unit to supply power to the household power grid. Simultaneously, the output of the grid-connected module 202 is also connected to the power grid, directly transmitting the electrical energy from the first energy storage unit to the grid. The main function of the first energy storage unit is to convert solar energy into electrical energy and transmit the converted electrical energy to the mains power grid for use by other users; or input electrical energy into the household power grid for use by household loads; or draw power from the grid and store it in the energy storage battery; or store the converted electrical energy in the first energy storage battery 206. The grid-connected module 202 mainly consists of a grid-connected inverter, etc., and controls the power supply of the first energy storage unit, directly transmitting excess electrical energy to the mains power grid, the household power grid, or storing it in the first energy storage battery 206.

[0070] The off-grid module 203, the second energy storage unit, is independent of the power grid. It is equipped with energy storage batteries to store the electrical energy generated by the solar array, so as to supply power to the load when needed. It should be noted that the second energy storage unit operates in islanded mode and has no grid connection function, therefore it cannot sell electricity.

[0071] However, as shown in Figure 2, if the mains power grid fails, but the mains power grid and the household power grid are connected, the second energy storage battery 207 connected to the off-grid module 203 or the first energy storage battery 206 connected to the grid-connected module 202 will also supply power to the grid while supplying power to the household load. That is, the power flows back to the grid, so the energy storage battery will be quickly depleted in a short time.

[0072] It should be noted that in the battery energy storage system, the second energy storage battery 207 connected to the off-grid module 203 and the first energy storage battery 206 connected to the grid-connected module 202 are distinguished based on their functions. In fact, they can be the same or independent.

[0073] When the same energy storage battery is connected to both the off-grid module 203 and the grid-connected module 202, space can be saved and the entire energy storage system can be made more compact because there is no need to purchase and maintain two independent battery systems. At the same time, the control system in the energy storage battery system enables it to operate efficiently and safely in different modes.

[0074] Based on this, in this embodiment of the application, it is necessary to monitor the status of the mains power grid in real time. When the mains power grid is unstable and it is determined that there is a possibility of power outage, the switch module 204 is instructed to disconnect the connection between the mains power grid and the household power grid, so that the energy storage battery system is in off-grid operation mode, preventing the power in the household power grid from flowing back into the grid and ensuring the power demand of the household power grid.

[0075] In other words, the mains power detection module 205 in the control unit collects real-time monitoring data during the power grid supply process and sends the real-time monitoring data to the control module 201, thereby enabling the control module 201 to obtain real-time monitoring data during the power grid supply process.

[0076] In this embodiment, the switch module 204 is specifically a smart knife switch, which receives the switching control signal from the control module 201 and responds to the switching control signal to disconnect or connect, thereby disconnecting or connecting the mains power grid and the household power grid. When the mains power grid and the household power grid are disconnected, the energy storage battery system is in an off-grid operation state; when the mains power grid and the household power grid are connected, the energy storage battery system is in a grid-connected operation state. It is worth noting that the smart knife switch is normally in a closed state, in which the mains power grid and the household power grid are connected.

[0077] Off-grid operation refers to the state in which the household power grid (or local power grid) operates independently when the grid and the household power grid are disconnected through a smart switch. The household power grid no longer relies on the grid for power supply, but instead relies on other energy sources, such as energy storage battery systems and solar power generation systems. At this time, the household power grid can independently regulate itself according to its own needs and energy supply. However, since it does not rely on a stable grid, the power supply of the household power grid may be affected by factors such as the status of the energy storage system and weather, resulting in a certain degree of instability.

[0078] Grid-connected operation refers to the state in which the household power grid and the mains power grid operate together when they are connected through a smart switch. The power supply of the household power grid is jointly guaranteed by the mains power grid and any existing local energy systems (such as energy storage battery systems), and it has high stability.

[0079] The mains power detection module 205 is used to collect real-time monitoring data during the process of the mains power grid supplying power to the household power grid. The real-time monitoring data includes voltage, current, current frequency, etc.

[0080] In this embodiment of the application, for example, the mains power detection module 205 can be integrated into the smart knife switch, which facilitates installation and spatial arrangement.

[0081] The control module 201 is a local control module 201, which includes a processor, a memory, and an input / output interface, thereby realizing local control of the energy storage battery off-grid, with higher real-time performance and greater stability.

[0082] The control module 201 can be set up independently or integrated into the smart knife switch.

[0083] In step S102, the stability detection result of the power grid power supply status is determined based on the real-time monitoring data.

[0084] Specifically, the control module 201 determines the stability detection result of the power grid power supply status based on the real-time monitoring data.

[0085] In this embodiment, the stability test results of the power grid supply status are specifically determined using an isolated forest model.

[0086] Please refer to Figure 3, which shows a flowchart of the method for determining the stability detection result of the power grid supply state according to an embodiment of this application; the step of determining the stability detection result of the power grid supply state based on the real-time monitoring data includes steps S301-S304:

[0087] S301. Preprocess the real-time monitoring data to obtain preprocessed real-time monitoring data;

[0088] S302. Based on the preprocessed real-time monitoring data, various mains power characteristics characterizing the mains power supply status are obtained; the mains power characteristics include real-time monitoring data directly used as mains power characteristics, and mains power characteristics obtained after processing at least one type of real-time monitoring data;

[0089] S303. Input the various mains power features into a pre-trained isolated forest model. The isolated forest model processes each mains power feature and calculates the anomaly score of the data points in each mains power feature.

[0090] S304. Based on the anomaly score of the data points in each mains power feature, determine whether there are abnormal data points in the mains power feature, so as to determine the stability detection result of the power grid power supply status.

[0091] In step S301, the real-time monitoring data is preprocessed to obtain preprocessed real-time monitoring data, including:

[0092] Normalize different types of real-time monitoring data to obtain normalized real-time monitoring data;

[0093] Outliers in the normalized real-time monitoring data are filtered out to obtain preprocessed real-time monitoring data.

[0094] Data with different characteristics are normalized. For example, voltage and frequency data can be scaled to the same range to avoid certain features having too much impact on the training of the local model.

[0095] By utilizing local communication protocols to monitor data in real time, outliers can be quickly detected and processed, ensuring the accuracy and reliability of the data.

[0096] Outliers in the normalized real-time monitoring data are filtered out. Specifically, the outliers are determined based on historical monitoring data of the power grid status.

[0097] For example, based on historical monitoring data of the power grid status, a preset threshold range is determined for each type of real-time monitoring data, and data exceeding the preset threshold range is regarded as outliers.

[0098] In step S302, based on the characteristics of the mains power, more features are extracted, such as voltage and frequency fluctuation deviation rate, peak and valley values, total harmonic distortion (THD), etc., to enhance the expressive and discriminative capabilities of the isolated forest model.

[0099] In other words, the mains power features input into the isolated forest model include real-time monitoring data that are directly used as mains power features, such as voltage data and current data.

[0100] Additionally, it includes mains characteristics obtained after processing at least one real-time monitoring data, such as voltage and frequency fluctuation deviation rates, peak-to-valley values, total harmonic distortion (THD), and statistical characteristics.

[0101] Specifically, the statistical characteristics of the mains power characteristics include average value, variance, kurtosis, skewness, extreme values, etc. Data is monitored and collected in real time using a local communication protocol, and the statistical characteristics are calculated.

[0102] The following details the statistical calculation method for the statistical characteristics in voltage characteristics.

[0103] Mean: The sum of all data divided by the number of data points.

[0104] Example: Suppose there is a set of mains voltage data [220,225,218,230,222], then the average value is calculated as: average value = (220+225+218+230+222) / 5 = 223V.

[0105] Variance: The average of the squares of the differences between the data and the mean.

[0106] Example: Continuing with the mains voltage data above, the steps to calculate the variance are as follows:

[0107] First, calculate the average value: average value = 223V.

[0108] Then calculate the square of the difference between each data point and the mean: (220-223)^2, (225-223)^2, (218-223)^2, (230-223)^2, (222-223)^2; sum the squares and divide by the number of data points to get the variance.

[0109] Kurtosis: The peak shape of a data distribution, describing how steep or flat the data distribution is.

[0110] Skewness: The degree of skewness in the distribution of data, describing the asymmetry of the data distribution.

[0111] Extreme values: The maximum and minimum values ​​in the data.

[0112] Example: For mains voltage data, find the maximum and minimum values.

[0113] Periodic characteristics: including fluctuation cycle, peak-to-valley ratio, etc., are calculated by real-time monitoring and data collection through local communication protocols.

[0114] Fluctuation period: The fluctuation period is the periodic variation of voltage data over a time series. It can be calculated by identifying the periodic repetition patterns in the data.

[0115] Peak-to-valley ratio: The peak-to-valley ratio is the ratio between the peak value and the valley value, used to describe the amplitude variation of data.

[0116] Example: For the voltage array data above, the peak and valley values ​​can be found, and the ratio between them can be calculated.

[0117] Specifically, the isolated forest model processes each mains power feature and calculates the anomaly score for data points in each mains power feature, including:

[0118] The isolated forest model processes each mains power feature and constructs a tree structure until the number of mains power feature data points included in each leaf node of the isolated forest model is less than a first preset threshold, or the isolated forest model reaches the maximum depth of the tree.

[0119] For each data point of each mains power characteristic, calculate the path length of the data point in the isolated forest model; the path length is the number of edges traversed from the root node to the data point.

[0120] Based on the path length of the data points, calculate the anomaly score for each type of mains power characteristic; the shorter the path length, the lower the anomaly score; the longer the path length, the higher the anomaly score.

[0121] Please refer to Figure 4, which shows a schematic diagram of the process of the isolated forest model processing each mains power feature according to the embodiment of this application; firstly, the mains power feature is used as a dataset and input into the isolated forest model; multiple subsampling is performed to construct multiple isolated trees; the specific process of constructing a single isolated tree includes feature selection and data partitioning until the growth cessation condition is met.

[0122] Feature selection includes randomly selecting features and cut values, randomly selecting feature subsets, and randomly selecting cut features; data partitioning includes randomly selecting cut values.

[0123] Randomly select features and cut values: For each isolated tree in the isolated forest model, at each node, randomly select a feature and a cut value to split the data into two parts;

[0124] Randomly select a subset of features: At each node, instead of selecting from all features, a subset is randomly selected. This helps reduce the selection space at each node and increases the diversity of the model.

[0125] Feature subset size: The size of the feature subset can be set according to specific circumstances. In general, a smaller subset size can be selected to increase randomness at each node.

[0126] Randomly select a cut feature: Randomly select a feature from the chosen feature subset as the cut feature. This ensures that the cut for each node is not fixed, increasing the diversity of the model;

[0127] Randomly select a cut value: For a given cut feature, randomly select a cut value to divide the data into two parts. The cut value is usually randomly selected within the range of feature values.

[0128] Establishing a tree structure: Repeat the above process to recursively establish the tree structure of the isolated tree until the growth stopping condition is met, thus establishing an isolated tree: The growth stopping condition is: the number of data points of the mains power feature included in each leaf node is less than a first preset threshold, or the isolated forest model has reached the maximum depth of the tree.

[0129] Establish isolated tree 1...isolated tree n, thereby creating an isolated forest.

[0130] For each data point representing the mains voltage characteristics, calculate its path length in each tree. The path length is the number of edges traversed from the root node to that data point. For example, suppose there is a set of mains voltage data [220, 225, 218, 230, 222], and construct an isolated forest model, which consists of multiple randomly generated decision trees (isolated trees).

[0131] First, insert this set of data into each tree and record the path length of each data point in each tree. The path length is the number of edges traversed from the root node to the data point.

[0132] Suppose we have a simple isolated forest model containing two trees:

[0133] First tree: The root node's cut feature is voltage; the cut value is 222; left subtree node: data point [220, 218]; right subtree node: data point [225, 230].

[0134] In this tree, the path lengths of data points [220, 225, 218, 230, 222] are as follows:

[0135] For data point 220: the path length from the root node to data point 220 is 2 (from the root node to the left subtree node, and then to data point 220).

[0136] For data point 225: the path length from the root node to data point 225 is 3 (from the root node to the right subtree node, and then to data point 225).

[0137] For data points 218, 230, and 222: these data points will not be cut in the tree, so the path length is the height of the tree. In this example, the height of the tree is 1, so the path length is 1.

[0138] The second tree: the root node selects voltage as the cutting feature; the cutting value is 225; the left subtree node: data points [220, 225, 218, 222]; the right subtree node: data points

[0230] .

[0139] In this tree, the path lengths for data points [220, 225, 218, 230, 222] are as follows: For data points 220, 225, 218, and 222: these data points will not be cut in the tree, so the path length is the height of the tree. In this example, the height of the tree is 2, so the path length is 2.

[0140] For data point 230: the path length from the root node to data point 230 is 2 (from the root node to the right subtree node, and then to data point 230).

[0141] Therefore, the path length of each data point in each tree can be obtained by calculating the number of edges traversed from the root node to that data point.

[0142] Calculate the anomaly score: Based on the path length, calculate the anomaly score for each data point. Generally, the shorter the path (the faster it is isolated in the tree), the lower the anomaly score, indicating that the data point is more normal; conversely, the longer the path, the higher the anomaly score, indicating that the data point is more anomalous.

[0143] Based on the anomaly scores of data points in each mains power characteristic, it is determined whether there are abnormal data points in the mains power characteristic, thereby determining the stability detection result of the power grid supply state. For example, a threshold can be set based on the anomaly scores to determine whether a data point is abnormal. Typically, data points exceeding the threshold are considered abnormal data points.

[0144] For better normalization and comparison, Isolation Forests typically use an outlier function S(x, n) to measure whether a data point x is an outlier.

[0145] Given a dataset containing n samples, the average path length of the tree is c(n): c(n) = 2H(n-1) - 2(n-1)*(1 / n); c(n) = 2H(n-1) - 2(n-1)*(1 / n) = 2[ln(n-1) + 0.57721] - 2(n-1)*(1 / n);

[0146] H refers to the Harmonic Number, which is the sum of the reciprocals of all natural numbers from 1 to n.

[0147] In the Isolation Forest algorithm, the harmonic number is used to estimate the average search depth of a balanced binary tree. Intuitively, the larger the harmonic number, the greater the average depth of the tree.

[0148] H(n) = ∑(1 / i), (i from 1 to n); H(n) = ln(n) + Euler's constant (0.57721) is used instead, which simplifies the calculation process, reduces the calculation time, and improves scalability.

[0149] Specifically, the precise calculation of the harmonic number (H(n)) requires summing the reciprocals of every number from 1 to (n), which is computationally intensive. The approximate formula, however, only requires calculating the logarithm and the constant, significantly reducing the computational load. When performing anomaly detection on large datasets, the efficiency of constructing and calculating isolated forests is crucial. Using the approximate formula can greatly reduce the time spent calculating the path length normalization factor, thereby improving the overall algorithm efficiency. When the data volume is large, calculating the precise value of the harmonic number may become impractical. The calculation of the logarithmic function and the constant is highly efficient and stable in modern computers, making it suitable for processing large-scale data.

[0150] The outlier function formula in isolated forests is: S(x,n)=2^(-h(x) / (c(n)*ln(2))).

[0151] For example, suppose we have a dataset containing 10 samples, where the path length of one data point is h(x) = 5. The steps for calculating outliers are as follows:

[0152] Step 1: Calculate the harmonic number H(9), H(9)=1+1 / 2+1 / 3+1 / 4+1 / 5+1 / 6+1 / 7+1 / 8+1 / 9≈2.82897

[0153] H(9)=ln(9)+0.57721=2.77443;

[0154] Step 2: Calculate the average path length c(10):

[0155] c(10)=2*2.82897-2*9 / 10≈3.85794

[0156] c(10)=2*2.77443-2*9 / 10≈3.74886

[0157] Step 3: Calculate the anomaly score S(x,10):

[0158] S(x,10)=2^(-5 / (3.85794*ln(2)))≈0.2736

[0159] S(x,10)=2^(-5 / (3.74886*ln(2)))≈0.2635

[0160] In summary, the difference in anomaly scores between H(n)=∑(1 / i) and H(n)=ln(n)+Euler's constant (0.57721) is not significant, but H(n) has an advantage in computation speed on the machine.

[0161] c(n) = 2H(n-1) - 2(n-1) * 1 / n; where the Euler constant e is referenced. In actual calculations, to avoid the overhead of calculating ln(2), an approximate value of Euler constant e, 2.71828, is used instead. Therefore, the outlier function S(x,n) can be rewritten as:

[0162] S(x,n)=2^(-h(x) / (c(n)*2.71828)).

[0163] Therefore, the meaning of the outlier function S(x, n) is as follows:

[0164] The path length of normal data points is usually short, so the value of S(x,n) is close to 1.

[0165] The path length of outlier data points is usually quite long, so the value of S(x,n) is close to 0.

[0166] Optimization of the Isolation Forest model: parameter tuning, specifically by real-time monitoring of the model's cross-validation results through a local communication protocol, adjusting model parameters to improve the model's generalization ability and prediction accuracy.

[0167] The stability test result is determined based on abnormal data points. Specifically, when abnormal data points meet preset abnormal conditions, the stability test result is determined to be unstable.

[0168] For example, the preset abnormal condition is that the number of abnormal data points exceeds a fifth preset threshold.

[0169] In step S103, the real-time monitoring data, stability test results, power of the first energy storage battery 206, power of the first energy storage battery 206, and power of the second energy storage battery 207 are respectively input into the nodes corresponding to the pre-constructed decision tree model.

[0170] The stability test result is the stability test result output by the isolated forest model.

[0171] Here, the real-time monitoring data also needs to be preprocessed to obtain preprocessed real-time monitoring data; then, based on the preprocessed real-time monitoring data, various mains power characteristics representing the mains power supply status are obtained; the mains power characteristics include real-time monitoring data that is directly used as mains power characteristics, and mains power characteristics obtained after processing at least one real-time monitoring data. The processing of real-time monitoring data and the preprocessing process of real-time monitoring data before inputting it into the isolated forest module are the same, and will not be described again.

[0172] In this application, there are four features: real-time monitoring data, stability test results, the power of the first energy storage battery 206, and the power of the second energy storage battery 207. Based on these four features, branches and nodes of the decision tree model are constructed to establish the decision tree model, so that the decision tree model can intelligently determine the switching control strategy for the smart switch, the off-grid module 203, the grid-connected module 202, and the load according to these four features.

[0173] The decision tree algorithm was chosen as the core algorithm for the intelligent switching strategy for the following reasons:

[0174] Highly interpretable: Decision tree models can intuitively explain the decision-making process and judgment criteria, making them easy to understand and interpret, and suitable for decision-making logic in embedded device environments.

[0175] Wide adaptability: The decision tree algorithm is well adaptable to various data types and feature types. It can handle numerical, categorical and mixed features and is suitable for various mains power and battery data.

[0176] High computational efficiency: The decision tree algorithm has relatively low computational complexity and fast training speed, making it suitable for scenarios with limited computing resources in embedded devices.

[0177] When constructing a decision tree model based on four features—real-time monitoring data, stability test results, the power level of the first energy storage battery 206, and the power level of the second energy storage battery 207—the design principles for nodes and branches are as follows:

[0178] The system detects whether the power grid is in normal condition based on real-time monitoring data. If the data is normal, the real-time monitoring is recorded; otherwise, it proceeds to the mains power stability judgment node. Specifically, the system determines whether the power grid is in normal condition based on a comparison between real-time monitoring data and historical monitoring data.

[0179] When judging the stability of the mains power, the stability detection results output by the isolated forest model are used to determine whether the grid is stable. If it is stable, the energy storage battery system is kept in grid-connected state, and the grid-connected module 202 is operating normally. Otherwise, the smart switch is activated to disconnect the mains power grid and the household power grid to prevent the energy of the energy storage battery in the household power grid from flowing back into the grid, and the off-grid operation state of the energy storage battery system is activated.

[0180] The off-grid operation status of the energy storage battery system is activated. The battery charge of the first energy storage battery 206 of the first energy storage unit is determined. If the first energy storage battery 206 has sufficient charge, the grid-connected module 202 is activated. The overall power supply of the household is mainly based on the first energy storage unit and supplemented by the second energy storage unit. Priority is given to using solar power generation to maintain the normal operation of household equipment load. Otherwise, the charge of the second energy storage battery 207 in the second energy storage unit is determined.

[0181] If the second energy storage battery 207 in the second energy unit has sufficient power, the first energy storage unit and the second energy storage unit work together to supply power and maintain the normal operation of household equipment loads; otherwise, the necessary household electrical loads are retained while other electrical equipment is turned off.

[0182] The training and optimization process of the decision tree model is as follows: historical data (i.e., mains power stability judgment) is used to train and optimize the constructed decision tree model. Parameters and thresholds are adjusted according to different scenarios and operating conditions to improve the accuracy and stability of the model.

[0183] Please refer to Figure 5, which shows a flowchart of the decision tree model described in this embodiment processing the real-time monitoring data, stability detection results, the power level of the first energy storage battery 206, and the power level of the second energy storage battery 207; as shown in Figure 5.

[0184] The decision tree model processes the real-time monitoring data, stability detection results, the power level of the first energy storage battery 206, and the power level of the second energy storage battery 207, and outputs switching control results for the energy storage battery system and operation control results for the load, including:

[0185] The decision tree model determines whether the real-time monitoring data is normal.

[0186] If yes, then record the real-time monitoring data normally; if no, then determine whether the power grid supply status is stable based on the stability test results.

[0187] To determine whether the power grid supply status is stable, if yes, the switch module 204 in the control unit is closed to maintain the grid-connected operation of the energy storage battery system and the grid; if no, the switch module 204 is opened to switch to the off-grid operation of the energy storage battery system and the grid.

[0188] For off-grid operation, based on the charge of the first energy storage battery 206 and the charge of the second energy storage battery 207 in the energy storage battery system, the switching control results for the grid-connected module 202 in the first energy storage unit and the off-grid module 203 in the second energy storage unit, and the operation control results for the load are determined in the off-grid operation state.

[0189] For the off-grid operation state, based on the charge levels of the first energy storage battery 206 and the second energy storage battery 207 in the energy storage battery system, the switching control results for the grid-connected module 202 in the first energy storage unit and the off-grid module 203 in the second energy storage unit, and the operation control results for the load are determined, including:

[0190] For off-grid operation, the power assessment result of the first energy storage battery 206 of the first energy storage unit and the power assessment result of the second energy storage battery 207 of the second energy storage unit are determined. Based on the power assessment results of the first energy storage battery 206 and the second energy storage battery 207, the switching control results for the grid-connected module 202 in the first energy storage unit and the off-grid module 203 in the second energy storage unit and the operation control results for the load are determined.

[0191] The switching control result is either controlling the first energy storage unit to operate independently off-grid, or controlling the first energy storage unit and the second energy storage unit to operate jointly off-grid; the load operation control result is either the load operates normally or some loads are shut down.

[0192] The power assessment results indicate whether the energy storage battery has sufficient power.

[0193] Specifically, for the off-grid operation state, the process involves determining the power assessment result of the first energy storage battery 206 of the first energy storage unit and the power assessment result of the second energy storage battery 207 of the second energy storage unit. Based on the power assessment results of the first energy storage battery 206 and the second energy storage battery 207, the process also involves determining the switching control results for the grid-connected module 202 in the first energy storage unit and the off-grid module 203 in the second energy storage unit, as well as the operation control results for the load.

[0194] For off-grid operation, determine whether the charge of the first energy storage battery 206 in the first energy storage unit is greater than the second preset threshold.

[0195] If the charge of the first energy storage battery 206 is greater than the second preset threshold, the grid-connected module 202 in the first energy storage unit is activated, and the charge of the first energy storage battery 206 in the first energy storage unit in the off-grid operation state is monitored in real time to see if it is greater than the third preset threshold.

[0196] When the charge of the first energy storage battery 206 is greater than the third preset threshold, it is determined that the first energy storage unit is independently powered, and the operation control result of the load is determined to maintain the normal operation of the load.

[0197] If the charge of the first energy storage battery 206 is less than or equal to the second preset threshold, or the charge of the first energy storage battery 206 is greater than the third preset threshold, then the off-grid module 203 in the second energy storage unit is activated simultaneously, and the charge of the second energy storage battery 207 in the second energy storage unit is monitored in real time to see if it is greater than the fourth preset threshold.

[0198] When the charge of the second energy storage battery 207 is greater than the fourth preset threshold, the operation control result of the load is determined to maintain the normal operation of the load.

[0199] When the power of the second energy storage battery 207 is less than or equal to the fourth preset threshold, it is determined that the operation control result of the load is to maintain the operation of the first preset load and turn off other loads.

[0200] The other loads are loads other than the first preset load.

[0201] It should be noted that during the off-grid operation, it is necessary to determine the power evaluation results of the first energy storage battery 206 of the first energy storage unit and the power evaluation results of the second energy storage battery 207 of the second energy storage unit in real time, so as to determine the switching control result and the operation control result according to the two real-time power evaluation results.

[0202] Exemplarily, when a power supply fault occurs in the power grid during the day and the home power grid switches to the off-grid state, due to sufficient sunlight, the switching control result remains that the first energy storage unit supplies power independently off-grid; if the sunlight is insufficient, after the first energy storage unit supplies power independently off-grid and the power stored in the first energy storage unit drops below the third preset threshold, the first energy storage unit and the second energy storage unit supply power jointly off-grid; when the power of the second energy storage unit drops below the fourth preset threshold, the first preset load is controlled to operate and other loads are turned off.

[0203] When the first energy storage unit and the second energy storage unit supply power jointly off-grid, the control module controls the first energy storage unit to supply power preferentially. Therefore, it is only necessary to detect whether the power of the second energy storage unit drops below the fourth preset threshold to determine whether to turn off other loads except the first preset load.

[0204] When the control module 201 collects the real-time monitoring data of the mains power grid, the data of the off-grid module 203 and the grid-connected module 202, the data is input into the decision tree model for prediction and judgment, and it is intelligently switched to the grid-connected or off-grid mode according to the model output result, and other devices are notified to perform corresponding operations through local communication broadcast information, so as to ensure the continuity and stability of the home power supply.

[0205] In the embodiment of the present application, the real-time communication between the control unit of the energy storage battery system, the first energy storage unit, the second energy storage unit and the load is realized based on the UDP local communication protocol.

[0206] Specifically, the real-time data interaction between the control module 201 and the mains power detection module 205, the intelligent knife switch, the grid-connected module 202 and the off-grid module 203, and the home load in the energy storage battery system is realized. When the state of one device changes, it broadcasts a notice to other devices to ensure that all devices can timely obtain the latest state information, so as to realize the real-time state update. Broadcast messages are triggered according to specific conditions or events to realize the linkage control between devices, such as triggering off-grid switching when the power grid is powered off, so that the home power grid is independent of the mains power grid.

[0207] The data frames transmitted by the UDP local communication protocol include, as shown in Table 1 below, a frame start symbol, a frame type, a frame content, a frame check field, and a frame end symbol.

[0208] Table 1

[0209] Start of frame character: AA55-2 bytes, used as the start identifier of the frame to identify the beginning of the frame.

[0210] Protocol version: 1 byte - used to identify the version number of the protocol so that the receiver can recognize and process frames of different versions.

[0211] Frame type: 1 byte - used to distinguish different types of frames, such as data frames, control frames, and broadcast frames.

[0212] Frame content: Encoded using Protobuf, this frame stores the actual data content. Protobuf is a lightweight data serialization protocol that can efficiently serialize and deserialize structured data.

[0213] Frame check field: Based on the CRC32 algorithm, the frame check field is 2 bytes long and is used to verify the frame content to ensure the integrity and reliability of the data.

[0214] End-of-frame marker: CC33 (2 bytes) - Used as an end-of-frame identifier to identify the end of a frame.

[0215] Frame types include data frames, control frames, and broadcast frames;

[0216] Data frame: Used to transmit actual data content.

[0217] Control frames: used to transmit control commands or control information.

[0218] Broadcast frame: Used to broadcast notifications or messages.

[0219] The contents of Protobuf are explained as follows:

[0220] Data structuring: Protobuf allows you to define structured data and communicate using predefined message formats, which ensures that the data structure is clear, easy to understand and maintain.

[0221] Data serialization: Protobuf can serialize structured data into binary format, which can reduce the size of data transmission and improve transmission efficiency, especially suitable for network transmission or storage.

[0222] The message classes generated by Protobuf support cross-language communication and can be used in multiple programming languages, thus enabling data exchange and communication between different systems and providing excellent cross-platform and cross-language compatibility.

[0223] Version control: Protobuf allows you to specify field numbers in the message definition, so that even if the message structure changes, compatibility can be maintained by field numbers without breaking the existing data format.

[0224] The CRC32 algorithm can perform data integrity verification, offering advantages such as high efficiency, low collision rate, and simple implementation.

[0225] Data integrity verification: The CRC32 algorithm can verify data, detecting whether the data has changed during transmission, thereby ensuring data integrity. This is crucial for data transmission or storage over a network, preventing data corruption or tampering.

[0226] High performance: The CRC32 algorithm is a fast and efficient verification algorithm that can verify a large amount of data in a short time, making it suitable for real-time data transmission and processing scenarios.

[0227] Low collision rate: The CRC32 algorithm has a very low hash collision rate, which can maintain high verification accuracy even when processing large amounts of data, effectively protecting the integrity of the data.

[0228] Simple Implementation: The CRC32 algorithm is relatively simple to implement and can be easily implemented in various programming languages. It also consumes relatively few computational resources, making it suitable for various embedded systems and high-performance computing environments. When using CRC-16-IBM, the polynomial is X¹⁶ + X¹⁵ + X² + 1.

[0229] The CRC32 algorithm performs the verification process as follows: The verification content is: ABCDEF; the initial value 0xFFFF is represented in binary as: 1111111111111111; each byte and the initial value are input into the CRC algorithm in the bit sequence; finally, the CRC check code is obtained: FC64.

[0230] Communication flow of the UDP local communication protocol:

[0231] The data sender constructs and sends the frame; Constructing the frame: Encode the data to be sent according to the Protobuf protocol, then add the start-of-frame character AA55, protocol version number, frame type before the data, add the frame check field CRC32 after the data, and finally add the end-of-frame character CC33 to obtain the complete frame; Sending the frame: Send the constructed frame to the target device via the UDP protocol.

[0232] The data processing flow of the receiver is as follows: Receive data: Listen to the UDP port and receive data frames; Parse frames: Extract the frame start character, protocol version number, frame type, frame content and frame check field, and verify the integrity of the frame; Extract data: If the frame verification passes, parse the frame content and obtain the actual data.

[0233] To achieve coordinated control between devices, this application introduces a UDP broadcast function, allowing related devices in the grid-connected / off-grid energy storage battery switching control method to notify other devices in real time via broadcast messages, thereby enabling collaborative operation between devices. The specific design is as follows:

[0234] UDP broadcast message content definition:

[0235] Broadcast messages include information such as device status updates, event notifications, and control commands to ensure information synchronization and real-time response between devices.

[0236] Broadcast message sending and receiving mechanism:

[0237] Sender: When a device needs to send a broadcast message to other devices, it encapsulates the message according to the broadcast message format and sends it to all devices in the local area network via the UDP broadcast address.

[0238] Receiver: All devices listen to the UDP broadcast address. Upon receiving a broadcast message, they parse the message content and process it accordingly. Different operations can be performed based on the message type and content, such as updating status or executing commands.

[0239] The grid-connected / off-grid energy storage battery switching control method described in this application embodiment can monitor the grid status and mains power supply in real time, and make automatic judgments and responses to grid outages, instabilities, and other situations. The first level controls whether the energy storage battery system is in grid-connected or off-grid operation mode relative to the grid. The second level controls the first and second energy storage modules in the energy storage battery system based on their battery power, thereby achieving fine control over the grid-connected / off-grid switching of the energy storage battery system at a finer granularity, making the energy of the energy storage battery system more rational. The third level informs other household load devices to perform corresponding operations based on the battery power of the off-grid module 203 and the grid-connected module 202, so as to ensure that the power supply meets the household needs when the energy storage battery system is operating off-grid.

[0240] Based on the same application concept, this application also provides an energy storage battery system corresponding to the grid-connected and off-grid energy storage battery switching control method. Since the principle of solving the problem by the energy storage battery system in this application is similar to the grid-connected and off-grid energy storage battery switching control method described above in this application, the implementation of the system can refer to the implementation of the method, and the repeated parts will not be described again.

[0241] Please refer to Figure 2, which shows a schematic diagram of the structure of the energy storage battery system according to an embodiment of this application.

[0242] The energy storage battery system includes a control unit, a first energy storage unit, and a second energy storage unit. The first energy storage unit and the second energy storage unit are respectively connected to the control unit, which is connected to the mains power grid. The control unit includes a mains power detection module 205, a switch module 204, and a control module 201. The first energy storage unit includes a photovoltaic power generation module 208, a grid-connected module 202, and a first energy storage battery 206. The second energy storage unit includes an off-grid module 203 and a second energy storage battery 207.

[0243] The control unit is used to acquire real-time monitoring data during the power grid supply process, the power of the first energy storage battery 206 in the first energy storage unit, and the power of the second energy storage battery 207 in the second energy storage unit.

[0244] It is also used to determine the stability detection result of the power grid supply status based on the real-time monitoring data;

[0245] It is also used to input the real-time monitoring data, stability test results, power of the first energy storage battery 206, power of the first energy storage battery 206, power of the second energy storage battery 207, and power of the second energy storage battery 207 into the nodes corresponding to the pre-constructed decision tree model, respectively.

[0246] It is also used to process the real-time monitoring data, stability detection results, power levels of the first energy storage battery 206 and the second energy storage battery 207 through the decision tree model, output switching control results for the energy storage battery system and operation control results for the load, and control the switching module 204 in the control unit, the grid-connected module 202 in the first energy storage unit, and the off-grid module 203 in the second energy storage unit to switch based on the switching control results, and control the operation of the load based on the operation control results.

[0247] In some embodiments, in the energy storage battery system, the switching module 204 of the control unit is disposed between the power grid and the control module 201, so that after the switching module 204 is disconnected, the energy storage battery system supplies power to the control module 201, the off-grid module 203 and the grid-connected module 202.

[0248] In some embodiments, the control module 201, when determining the stability detection result of the power grid supply state based on the real-time monitoring data, is specifically used for:

[0249] The real-time monitoring data is preprocessed to obtain preprocessed real-time monitoring data;

[0250] Based on the preprocessed real-time monitoring data, various mains power characteristics characterizing the mains power supply status are obtained; the mains power characteristics include real-time monitoring data directly used as mains power characteristics, and mains power characteristics obtained after processing at least one type of real-time monitoring data;

[0251] The various mains power features are input into a pre-trained isolated forest model, which processes each mains power feature and calculates the anomaly score of the data points in each mains power feature.

[0252] Based on the anomaly scores of data points in each mains power characteristic, it is determined whether there are abnormal data points in the mains power characteristic, so as to determine the stability detection result of the power grid power supply status.

[0253] In some embodiments, the control unit of the energy storage battery system, when processing each mains power characteristic using the isolated forest model and calculating the anomaly score of data points in each mains power characteristic, is specifically used for:

[0254] The isolated forest model processes each mains power feature and constructs a tree structure until the number of mains power feature data points included in each leaf node of the isolated forest model is less than a first preset threshold, or the isolated forest model reaches the maximum depth of the tree.

[0255] For each data point of each mains power characteristic, calculate the path length of the data point in the isolated forest model; the path length is the number of edges traversed from the root node to the data point.

[0256] Based on the path length of the data points, calculate the anomaly score for each type of mains power characteristic; the shorter the path length, the lower the anomaly score; the longer the path length, the higher the anomaly score.

[0257] In some embodiments, when the control unit of the energy storage battery system preprocesses the real-time monitoring data to obtain preprocessed real-time monitoring data, it specifically performs the following:

[0258] Normalize different types of real-time monitoring data to obtain normalized real-time monitoring data;

[0259] Outliers in the normalized real-time monitoring data are filtered out to obtain preprocessed real-time monitoring data.

[0260] In some embodiments, when the control unit of the energy storage battery system processes the real-time monitoring data, stability detection results, the power level of the first energy storage battery 206, and the power level of the second energy storage battery 207 through the decision tree model, and outputs switching control results for the energy storage battery system and operation control results for the load, it is specifically used for:

[0261] The decision tree model determines whether the real-time monitoring data is normal.

[0262] If yes, then record the real-time monitoring data normally; if no, then determine whether the power grid supply status is stable based on the stability test results.

[0263] To determine whether the power grid supply status is stable, if yes, the switch module 204 in the control unit is closed to maintain the grid-connected operation of the energy storage battery system and the grid; if no, the switch module 204 is opened to switch to the off-grid operation of the energy storage battery system and the grid.

[0264] For off-grid operation, based on the charge of the first energy storage battery 206 and the charge of the second energy storage battery 207 in the energy storage battery system, the switching control results for the grid-connected module 202 in the first energy storage unit and the off-grid module 203 in the second energy storage unit, and the operation control results for the load are determined in the off-grid operation state.

[0265] In some embodiments, when the control unit of the energy storage battery system determines the switching control result for the grid-connected module 202 in the first energy storage unit and the off-grid module 203 in the second energy storage unit, and the operation control result for the load in the off-grid operation state, based on the charge levels of the first energy storage battery 206 and the second energy storage battery 207 in the energy storage battery system, the control unit is specifically used for:

[0266] For off-grid operation, the power assessment result of the first energy storage battery 206 of the first energy storage unit and the power assessment result of the second energy storage battery 207 of the second energy storage unit are determined. Based on the power assessment results of the first energy storage battery 206 and the second energy storage battery 207, the switching control results for the grid-connected module 202 in the first energy storage unit and the off-grid module 203 in the second energy storage unit and the operation control results for the load are determined.

[0267] The switching control result is either controlling the first energy storage unit to operate independently off-grid, or controlling the first energy storage unit and the second energy storage unit to operate jointly off-grid; the load operation control result is either the load operates normally or some loads are shut down.

[0268] In some embodiments, the control unit of the energy storage battery system, when determining the charge assessment result of the first energy storage battery 206 of the first energy storage unit and the charge assessment result of the second energy storage battery 207 of the second energy storage unit for off-grid operation, and based on the charge assessment results of the first energy storage battery 206 and the second energy storage battery 207, determines the switching control result for the grid-connected module 202 in the first energy storage unit and the off-grid module 203 of the second energy storage unit, and the operation control result for the load, is specifically used for:

[0269] For off-grid operation, determine whether the charge of the first energy storage battery 206 in the first energy storage unit is greater than the second preset threshold.

[0270] If the charge of the first energy storage battery 206 is greater than the second preset threshold, the grid-connected module 202 in the first energy storage unit is activated, and the charge of the first energy storage battery 206 in the first energy storage unit in the off-grid operation state is monitored in real time to see if it is greater than the third preset threshold.

[0271] When the charge of the first energy storage battery 206 is greater than the third preset threshold, it is determined that the first energy storage unit is independently powered, and the operation control result of the load is determined to maintain the normal operation of the load.

[0272] If the charge of the first energy storage battery 206 is less than or equal to the second preset threshold, or the charge of the first energy storage battery 206 is greater than the third preset threshold, then the off-grid module 203 in the second energy storage unit is activated simultaneously, and the charge of the second energy storage battery 207 in the second energy storage unit is monitored in real time to see if it is greater than the fourth preset threshold.

[0273] When the charge of the second energy storage battery 207 is greater than the fourth preset threshold, the operation control result of the load is determined to maintain the normal operation of the load.

[0274] When the charge of the second energy storage battery 207 is less than or equal to the fourth preset threshold, the load operation control result is determined to keep the first preset load running and shut down other loads.

[0275] In some embodiments, the energy storage battery system uses the UDP local communication protocol to enable real-time communication between the control unit, the first energy storage unit, the second energy storage unit, and the load.

[0276] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces; the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.

[0277] The modules described as separate components may or may not be physically separate. The components shown as modules 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.

[0278] In addition, 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.

[0279] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, 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 a portion 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, a platform server, or a network device, etc.) to execute all or part of the steps of the methods described in 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, ROM, RAM, magnetic disks, or optical disks.

[0280] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for switching control between grid-connected and off-grid energy storage batteries, wherein, The method is applied to an energy storage battery system, which includes a control unit, a first energy storage unit, and a second energy storage unit. The first energy storage unit and the second energy storage unit are respectively connected to the control unit, which is connected to the mains power grid. The control unit includes a mains power detection module, a switching module, and a control module. The first energy storage unit includes a photovoltaic power generation module, a grid connection module, and a first energy storage battery. The second energy storage unit includes an off-grid module and a second energy storage battery; the method includes: The control unit acquires real-time monitoring data during the power grid supply process, the power level of the first energy storage battery in the first energy storage unit, and the power level of the second energy storage battery in the second energy storage unit. Based on the real-time monitoring data, the stability test result of the power grid supply status is determined; The real-time monitoring data, stability test results, and the power of the first energy storage battery, the power of the first energy storage battery, and the power of the second energy storage battery are respectively input into the nodes corresponding to the pre-constructed decision tree model. The decision tree model processes the real-time monitoring data, stability detection results, the power levels of the first and second energy storage batteries, and outputs switching control results for the energy storage battery system and operation control results for the load. Based on the switching control results, it controls the switching module in the control unit, the grid-connected module in the first energy storage unit, and the off-grid module in the second energy storage unit to switch, and controls the operation of the load based on the operation control results.

2. The method for switching control between grid-connected and off-grid energy storage batteries according to claim 1, wherein, Based on the real-time monitoring data, the stability detection result of the power grid supply status is determined, including: The real-time monitoring data is preprocessed to obtain preprocessed real-time monitoring data; Based on the preprocessed real-time monitoring data, various mains power characteristics characterizing the mains power supply status are obtained; the mains power characteristics include real-time monitoring data directly used as mains power characteristics, and mains power characteristics obtained after processing at least one type of real-time monitoring data; The various mains power features are input into a pre-trained isolated forest model, which processes each mains power feature and calculates the anomaly score of the data points in each mains power feature. Based on the anomaly scores of data points in each mains power characteristic, it is determined whether there are abnormal data points in the mains power characteristic, so as to determine the stability detection result of the power grid power supply status.

3. The method for switching control between grid-connected and off-grid energy storage batteries according to claim 2, wherein, The isolated forest model processes each mains power characteristic and calculates the anomaly score for data points in each mains power characteristic, including: The isolated forest model processes each mains power feature and constructs a tree structure until the number of mains power feature data points included in each leaf node of the isolated forest model is less than a first preset threshold, or the isolated forest model reaches the maximum depth of the tree. For each data point of each mains power characteristic, calculate the path length of the data point in the isolated forest model; the path length is the number of edges traversed from the root node to the data point. Based on the path length of the data points, calculate the anomaly score for each type of mains power characteristic; the shorter the path length, the lower the anomaly score; the longer the path length, the higher the anomaly score.

4. The method for switching between grid-connected and off-grid energy storage batteries according to claim 2 or 3, wherein, The real-time monitoring data is preprocessed to obtain preprocessed real-time monitoring data, including: Normalize different types of real-time monitoring data to obtain normalized real-time monitoring data; Outliers in the normalized real-time monitoring data are filtered out to obtain preprocessed real-time monitoring data.

5. The method for switching between grid-connected and off-grid energy storage batteries according to claim 1, wherein, The decision tree model processes the real-time monitoring data, stability detection results, the power levels of the first and second energy storage batteries, and outputs switching control results for the energy storage battery system and operation control results for the load, including: The decision tree model determines whether the real-time monitoring data is normal. If yes, then record the real-time monitoring data normally; if no, then determine whether the power grid supply status is stable based on the stability test results. To determine whether the power grid supply status is stable, if yes, the switch module in the control unit is closed to maintain the grid-connected operation of the energy storage battery system and the grid; if no, the switch module is opened to switch to the off-grid operation of the energy storage battery system and the grid. For off-grid operation, based on the charge levels of the first and second energy storage batteries in the energy storage battery system, the switching control results for the grid-connected module in the first energy storage unit and the off-grid module in the second energy storage unit, as well as the operation control results for the load, are determined.

6. The method for switching between grid-connected and off-grid energy storage batteries according to claim 5, wherein, For the off-grid operation state, based on the charge levels of the first and second energy storage batteries in the energy storage battery system, the switching control results for the grid-connected module in the first energy storage unit and the off-grid module in the second energy storage unit, and the operation control results for the load are determined, including: For off-grid operation, determine the power assessment result of the first energy storage battery of the first energy storage unit and the power assessment result of the second energy storage battery of the second energy storage unit. Based on the power assessment results of the first and second energy storage batteries, determine the switching control result for the grid-connected module in the first energy storage unit and the off-grid module in the second energy storage unit, and the operation control result for the load. The switching control result is either controlling the first energy storage unit to operate independently off-grid, or controlling the first energy storage unit and the second energy storage unit to operate jointly off-grid; the load operation control result is either the load operates normally or some loads are shut down.

7. The method for switching control between grid-connected and off-grid energy storage batteries according to claim 6, wherein, For off-grid operation, the method involves determining the power assessment result of the first energy storage battery in the first energy storage unit and the power assessment result of the second energy storage battery in the second energy storage unit. Based on the power assessment results of the first and second energy storage batteries, the method determines the switching control results for the grid-connected module in the first energy storage unit and the off-grid module in the second energy storage unit, as well as the operation control results for the load. This includes: For off-grid operation, determine whether the charge of the first energy storage battery in the first energy storage unit is greater than a second preset threshold. If the charge of the first energy storage battery is greater than the second preset threshold, the grid-connected module in the first energy storage unit is activated, and the charge of the first energy storage battery in the first energy storage unit in the off-grid operation state is monitored in real time to see if it is greater than the third preset threshold. When the charge of the first energy storage battery is greater than the third preset threshold, it is determined that the first energy storage unit is independently powered, and the operation control result of the load is determined to maintain the normal operation of the load; If the power of the first energy storage battery is less than or equal to the second preset threshold, or the power of the first energy storage battery is greater than the third preset threshold, then the off-grid module in the second energy storage unit is activated simultaneously, and the power of the second energy storage battery in the second energy storage unit is monitored in real time to see if it is greater than the fourth preset threshold. When the charge of the second energy storage battery is greater than the fourth preset threshold, the operation control result of the load is determined to maintain the normal operation of the load. When the charge of the second energy storage battery is less than or equal to the fourth preset threshold, the load operation control result is determined to keep the first preset load running and shut down other loads.

8. The method for switching between grid-connected and off-grid energy storage batteries according to claim 1, wherein, Real-time communication between the control unit, the first energy storage unit, the second energy storage unit, and the load of the energy storage battery system is achieved based on the UDP local communication protocol.

9. An energy storage battery system, wherein, The energy storage battery system includes a control unit, a first energy storage unit, and a second energy storage unit. The first energy storage unit and the second energy storage unit are respectively connected to the control unit, which is connected to the mains power grid. The control unit includes a mains power detection module, a switching module, and a control module. The first energy storage unit includes a photovoltaic power generation module, a grid-connected module, and a first energy storage battery. The second energy storage unit includes an off-grid module and a second energy storage battery. The control unit is used to acquire real-time monitoring data during the power grid supply process, the power of the first energy storage battery in the first energy storage unit, and the power of the second energy storage battery in the second energy storage unit. It is also used to determine the stability detection result of the power grid supply status based on the real-time monitoring data; It is also used to input the real-time monitoring data, stability test results, power of the first energy storage battery, power of the second energy storage battery, and power of the second energy storage battery into the nodes corresponding to the pre-constructed decision tree model, respectively. It is also used to process the real-time monitoring data, stability detection results, power levels of the first energy storage battery and the second energy storage battery through the decision tree model, output switching control results for the energy storage battery system and operation control results for the load, and control the switching module in the control unit, the grid-connected module in the first energy storage unit, and the off-grid module in the second energy storage unit to switch based on the switching control results, and control the operation of the load based on the operation control results.

10. The energy storage battery system according to claim 9, wherein, The switching module of the control unit is located between the power grid and the control module, so that the energy storage battery system supplies power to the control module after the switching module is disconnected.