A method for charging multiple types of batteries using a battery swap cabinet
By realizing battery model identification and elliptic curve cryptography encryption in the battery swap cabinet, the charging and swap compatibility problems caused by the differences in lithium batteries of different electric vehicles are solved, and the convenience and safety of use are improved.
Patent Information
- Application Number
- CN202410798576.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-06-20
AI Technical Summary
There are differences in the appearance and charging interface of lithium batteries used in different electric vehicles, which leads to the inability to unified battery data interface, and there is a risk of battery thermal runaway and fire. The existing battery swap cabinet usually only supports one battery and protocol, which causes users to use it. Battery model does not match and cannot be replaced or charged.
By manually or automatically identifying the battery model, encrypting and decrypting using the elliptic curve cryptography algorithm, obtaining battery-related information, judging the battery model and selecting appropriate charging and swapping rules to achieve compatibility with multiple models of batteries.
It improves the compatibility of battery swap cabinets with lithium batteries of different manufacturers and specifications, enhances user convenience, reduces maintenance costs, and effectively avoids battery thermal runaway and fire risks.
Smart Images

Figure CN118618107B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of battery swap cabinets, and in particular relates to a method for charging multiple types of batteries using a battery swap cabinet. Background Art
[0002] As modern society pursues a sustainable environment, electric vehicles have become widely popular due to their convenience, high efficiency and low impact on the environment. Electric bicycles have become the first choice for many commuters due to their ease of use and environmentally friendly characteristics. As a result, the number of electric vehicles has increased rapidly like a tide.
[0003] However, the appearance and charging interface of lithium batteries used in different electric vehicles are different. Due to different battery specifications, it is impossible to unify the battery data interface. Some lithium batteries do not have a communication interface, and it is impossible to obtain lithium battery data information, which is prone to battery thermal runaway, leading to fires and causing great trouble to users. In addition, the battery swap cabinets on the market usually only support one type of battery and protocol. When users use the battery swap cabinet, they will be unable to swap or charge the battery because the battery model does not match. Summary of the invention
[0004] In order to solve the above problems existing in the prior art, a method for charging multiple types of batteries in a battery swap cabinet is provided.
[0005] The technical solution adopted by the present invention to solve the technical problem is:
[0006] This technical solution proposes a method for charging multiple types of batteries using a battery swap cabinet, including the following steps:
[0007] S1: The battery swap cabinet recognizes the battery manually or automatically.
[0008] S2: During battery insertion, the main control board identifies the battery SN code, performs communication detection on the battery, and implements encryption and decryption of the battery based on the elliptic curve cryptography algorithm. The battery swap cabinet obtains battery-related information through handshake communication with the battery.
[0009] S3: Based on the battery-related information, determine whether the battery model is a battery replacement rule or a charging rule. The battery replacement rule is to replace the battery, insert the battery, and then take out another battery. The charging rule is to charge the battery.
[0010] Preferably, in S1, the battery-related information includes battery number, charging condition, placement status, charging voltage, charging current, technical parameters, and remaining power; if the battery is hard-connected, the battery placement status is first determined; if the battery is soft-connected, the placement detection is skipped and the battery information is directly acquired.
[0011] Preferably, in S2, the battery encryption method includes:
[0012] When the battery is inserted into the battery swap cabinet, the cabinet generates a random public key based on a specific point on the elliptic curve. The elliptic curve equation is expressed as
[0013] y 2 =x 3 +ax+b (1)
[0014] Where a and b are curve parameters and satisfy 4a 3 +27b 2 ≠0, the public key is a point P on an elliptic curve equation, whose coordinates satisfy formula (1);
[0015] The battery swap cabinet sends the generated public key P to the battery. After receiving the public key P, the battery uses its built-in private key d to encrypt the public key P, where the private key d is a randomly generated integer;
[0016] The battery decryption methods include:
[0017] Calculate the point multiplication of the base point G and the private key d, Q = d*G, where Q is the encrypted result and Q is the point on the elliptic curve equation;
[0018] The battery returns the encrypted point Q to the battery swap cabinet. After receiving the encrypted data Q, the battery swap cabinet uses its built-in private key e to decrypt it. The decryption process is based on the point multiplication operation on the elliptic curve.
[0019] The battery swap cabinet uses the private key e to perform a point multiplication operation on the received point Q, R = e*Q;
[0020] The battery swap cabinet also knows the generation process of the battery public key P, P = e*G, and the battery swap cabinet verifies the identity of the battery by comparing whether R and P are equal;
[0021] If R is equal to P, it means that the decryption is successful, the battery swap cabinet confirms the identity of the battery, and continues subsequent communications. If R is not equal to P, it means that the decryption fails, and the battery swap cabinet refuses to communicate with the battery.
[0022] Preferably, in S3, the battery replacement rules apply to users who pay a battery deposit, and the information obtained includes: number of replacements, battery replacement fees, battery replacement users, and settlement form; the charging rules apply to users who own batteries, and the information obtained includes: charging voltage, charging current, charging capacity, and charging time.
[0023] Preferably, the battery charging information acquisition method includes:
[0024] S11: Data collection: real-time collection of battery status data, including voltage V, current I, temperature T and remaining power SOC;
[0025] Collect user demand data in real time, record charging demand type, charging time preference and power demand;
[0026] Collect grid condition data in real time, including current electricity price P, grid load rate L, and expected load change trend ΔL.
[0027] S12: Data cleaning, by sorting the data set and comparing whether adjacent rows are exactly the same, to check and remove duplicate records;
[0028] Identify and handle missing values, traverse the data set, check whether there are missing values in each field, and delete the field for missing values in non-key fields;
[0029] For missing values of key fields, if the data is a time series or has an obvious trend, use interpolation to estimate the missing values. If the data has no obvious trend or seasonality, use the mean, median or mode to fill the missing values;
[0030] S13: Identify and handle outliers. Use the statistical method IQR rule or Z-score method to identify outliers. Based on business needs and data characteristics, decide whether to delete outliers, replace them with other values, or keep them but mark them.
[0031] S14: Data standardization: standardize the voltage V, current I, and temperature T in the battery status data, convert them into a distribution with a mean of 0 and a standard deviation of 1, and normalize the remaining power SOC, mapping its value to the interval [0,1];
[0032] S15: data normalization, normalizing the charging time preference and power demand in the user demand data to ensure that their values are within the range of [0,1] or [-1,1];
[0033] Category data processing: For charging demand type data, use one-hot encoding to convert it into a format suitable for machine learning model processing;
[0034] Normalize the current electricity price P, grid load rate L, and expected load change trend ΔL in the grid condition data to ensure that their values are also within the range of [0,1] or [-1,1];
[0035] S16: Data integration: Integrate the cleaned, standardized and normalized battery status data, user demand data and grid condition data into the same dataset to ensure that each record contains all relevant features for subsequent model training.
[0036] Preferably, the model training method includes:
[0037] S21: Data preparation, extracting pre-processed and integrated feature sets from historical data, including battery status data, user demand data, and grid condition data, and determining target variables, charging current, and charging time;
[0038] S22: Dataset partitioning: randomly divide the dataset into training set, validation set and test set. The training set is used for model training, the validation set is used for model selection and parameter tuning, and the test set is used to evaluate the final performance of the model.
[0039] S23: In the model training phase, a machine learning algorithm is selected, and two algorithms, support vector machine and random forest, are used to build a prediction model using the training set data;
[0040] Support vector machine model training:
[0041] Data preparation: preprocessing of training set data;
[0042] Model initialization: Initialize the support vector machine training model and set basic hyperparameters;
[0043] Model training: Call the fit method of the support vector machine object, pass in the features of the training set and the target variable as parameters, and start training the model;
[0044] Training monitoring and optimization: During the training process, monitor the training progress and performance of the model, and adjust hyperparameters as needed to improve the generalization ability of the model;
[0045] Random Forest Model Training:
[0046] Data preparation: preprocessing of training set data;
[0047] Model initialization: Initialize the random forest model and set basic hyperparameters;
[0048] Model training: Train the model by calling the fit method of the random forest object and passing in the features and target variables of the training set;
[0049] Parallelization and optimization: Use multi-core processors to accelerate training during training and optimize the performance and complexity of the model by adjusting hyperparameters;
[0050] S24: Cross-validation and parameter tuning. The k-fold cross-validation technique is used to divide the training set into k subsets. Each time, k-1 subsets are used as training data, and the remaining subset is used as validation data. The hyperparameters of the support vector machine and random forest are adjusted respectively. The Bayesian optimization method is used to find the best hyperparameter combination, and the average performance of each set of hyperparameters in cross-validation is recorded.
[0051] S25: Model selection: Based on the results of cross-validation, select the model with the best performance and its corresponding hyperparameter settings, optimize and revalidate the model, and revalidate the selected best model using the validation set data.
[0052] Preferably, the charging strategy includes:
[0053] Generate the current charging and swapping strategy based on real-time data and trained models;
[0054] Battery charging requirements calculation:
[0055] Charging demand (E_demand) = (target power - current power) × battery capacity;
[0056] Charging current calculation:
[0057] Charging current (Iset) = charging demand (Edemand) / charging time (Tset);
[0058] Among them, the charging current (Iset) should not exceed the maximum charging current Imax of the battery;
[0059] Grid electricity price cost optimization:
[0060] Electricity cost (Cost) = Charged electricity (E_charged) × Electricity price (P)
[0061] Initialization parameters: set the time step and determine the total number of time steps in a day, obtain the electricity price P[t] for each time step, obtain the grid load rate L[t] and the expected load change trend ΔL[t] based on historical data or prediction models;
[0062] Construct the cost matrix: Create a two-dimensional array cost[i][j], where i represents the time step, j represents the battery charge state, and cost[t+1][j next ]=min(cost[t+1][j next ]);
[0063] Dynamic programming solver, traverses each time step t, for each time step t, traverses each possible battery power state j, and calculates the maximum chargeable power ΔE in the current time step according to the maximum charging current I_max of the battery and the charging time of the current time step;
[0064] Calculate the range of power states that may be reached in the next time step. For each possible j_next, calculate the cost of transferring from the current state (t, j) to (t+1, j_next):
[0065] Charging cost = (j_next-j)*battery capacity*P[t], update cost[t+1][j_next] to the currently known minimum cost;
[0066] Backtrack the optimal strategy, starting from cost[T_total-1][target power], backtrack to obtain the optimal power state at each time step, calculate the corresponding charging current and charging time based on the optimal power state at each time step, output the optimal charging and swapping strategy, and output the final optimal charging and swapping strategy to the main control board for execution.
[0067] Preferably, the battery is charged using the PID charging mode:
[0068]
[0069] After discrete conversion:
[0070]
[0071] In the formula, u(t) is the output curve, the PID output value changes with time, Kp is the proportional coefficient, e(t) is the curve of the deviation between the set value and the actual value changing with time, Ti is the integral time, Td is the differential time, and T is the adjustment cycle;
[0072] During the battery charging process, the real-time voltage and current of the battery are read as process feedback values, and the error is calculated with the voltage and current reference values set by the charging strategy. The control output is generated according to the error value, and the voltage and current output of the charger are adjusted. The P term proportionally adjusts the control quantity according to the error, the I term integrates the error, and the D term is adjusted according to the error change rate. By adjusting the PID parameters, precise control of the charging process can be achieved.
[0073] Compared with the prior art, the present invention has the following advantages:
[0074] The present invention uses the software of the battery swap cabinet to automatically communicate with the battery through a preset communication protocol to identify the battery model. The user can also select the battery model by himself through the display screen on the battery swap cabinet or the mobile phone application software. The software can automatically select and output the appropriate charging voltage and current curve. The battery swap cabinet has good compatibility with lithium batteries of different specifications from different manufacturers, which can effectively improve the utilization rate of the battery swap cabinet and effectively increase the convenience of end users. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0076] Figure 1 It is the overall flow chart of the present invention. DETAILED DESCRIPTION
[0077] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0078] like Figure 1 As shown, this embodiment proposes a method for charging multiple types of batteries in a power exchange cabinet, including the following steps:
[0079] S1: The battery swap cabinet recognizes the battery manually or automatically.
[0080] S2: During battery insertion, the main control board identifies the battery SN code, performs communication detection on the battery, and implements encryption and decryption of the battery based on the elliptic curve cryptography algorithm. The battery swap cabinet obtains battery-related information through handshake communication with the battery.
[0081] S3: Based on the battery-related information, determine whether the battery model is a battery replacement rule or a charging rule. The battery replacement rule is to replace the battery, insert the battery, and then take out another battery. The charging rule is to charge the battery.
[0082] The battery compartment of the power swap cabinet can be compatible with the mainstream lithium batteries on the market, avoiding the situation where the lithium battery cannot be placed in the battery compartment. A battery charging cable is reserved in the battery compartment of the power swap cabinet, and an adapter is pre-installed on each charging cable. Each battery compartment can support 2 types of lithium battery specifications. A 10-door power swap cabinet can theoretically support 20 types of lithium batteries.
[0083] Through the software of the battery swap cabinet, it automatically communicates with the battery through the preset communication protocol to identify the battery model. Users can also select the battery model by themselves through the display screen on the battery swap cabinet or the mobile phone application software. The software can automatically select and output the appropriate charging voltage and current curve. The battery swap cabinet has good compatibility with lithium batteries of different specifications from different manufacturers, which can effectively improve the utilization rate of the battery swap cabinet and effectively increase the convenience of end users.
[0084] Compared with conventional battery compartments, the battery compartment of this application has a larger volume and size, which is convenient for storing lithium batteries of different specifications and battery charging cables. Each battery charging cable is equipped with an adapter to support different lithium batteries. The adapter and the battery charging cable are connected by a fixed line to prevent the adapter from being lost. The terminal software communicates with the lithium battery through the charging cable to obtain the battery model and remaining power, and matches the corresponding charging strategy provided by the supplier through 4G and the server. The software controls the charger to start the charging process.
[0085] The difference is that conventional battery swap cabinets only support one type of battery. If manufacturers want to iterate and upgrade the battery, they need to dismantle all the battery swap cabinets and drag them back to the factory to replace the battery compartment. They may even need to scrap the sheet metal of the entire cabinet and incur high renovation costs. Older batteries in the hands of users cannot be used in updated battery swap cabinets.
[0086] The new version of the charging system can support batteries of different specifications. When the manufacturer iterates the battery, it only needs to arrange maintenance personnel to replace the battery charging cable of the battery swap cabinet, without having to transport the entire battery swap cabinet back to the factory for modification, which can effectively reduce the subsequent maintenance costs. At the same time, when the user puts the old version of the battery into the battery swap cabinet for charging, the battery compartment can be locked to prevent the old version of the battery from flowing into the user again. This can accelerate the iteration speed of the new and old versions of the battery.
[0087] At the same time, lithium batteries from other manufacturers can be purchased. By adding charging adapters in the battery swap cabinet and adapting the corresponding lithium battery communication protocol on the software and server, users can be provided with lithium batteries from other manufacturers, which can effectively reduce the cost of battery procurement and equipment operation. Because it is compatible with batteries of different specifications, charging cabinets can be provided to users who need temporary charging, so that ordinary users are not limited to charging in electric vehicle charging sheds. After the battery is full, temporary users are prompted to take the battery away in time to avoid idle charges.
[0088] The core component of the battery swap cabinet is an Android motherboard. The touch screen and display screen serve as the human-computer interaction interface. The communication module generally uses 4G communication as a remote communication module and a remote server. A warehouse control board and a charger are placed in each battery compartment. The warehouse control board connects to the battery and communicates and exchanges data to obtain lithium battery cell parameters and remaining power. The warehouse control board obtains relevant charging strategies by communicating with the motherboard and sends relevant information to the charger. The charger provides the appropriate charging current and voltage for the lithium battery.
[0089] When the user starts the battery replacement process, he first scans the QR code on the charging cabinet through the APP. The main control board obtains the user type as a charging user or a battery replacement user through the remote server, including the previously stored and accessed lithium battery model and the lithium battery charging strategy. The main control board opens the corresponding battery compartment door through the control compartment control board. After the user puts the battery in, it connects the battery to start the charging process.
[0090] If the main control board cannot obtain the user's previous battery information through the server, the user will be prompted on the APP to manually scan the battery's SN code. The APP will send the obtained battery information to the main control board through the server. The main control board opens the corresponding battery compartment door by controlling the compartment control board. After the user puts the battery in, it connects the battery to start the charging process.
[0091] Because the SN code of some batteries may be unable to be obtained by the APP through taking photos due to long-term use, users can choose to manually enter the SN code or manually select the battery model based on the actual battery. If the above cannot be solved, users can make a video call with the manual customer service through the APP to remotely guide users to select the corresponding battery model.
[0092] In S1, the battery related information includes battery number, charging condition, placement status, charging voltage, charging current, technical parameters, and remaining power. If the battery is hard-connected, the battery placement status is first determined. If the battery is soft-connected, the placement detection is skipped and the battery information is directly obtained.
[0093] If the battery is in the form of a hard-connected base, the first step is to determine whether the battery is in place. If it is in place, the battery information will be obtained. If it is not in place, the user will be reminded to re-place it. If it is not in place, the information about the failure to place it in place will be retained and fed back to the manufacturer. The manufacturer can call nearby maintenance personnel to handle it, determine whether the interface is faulty, whether the battery exchange cabinet is damaged, etc., and perform manual repairs. If the battery is in the form of a soft connection, the step of in-place detection is skipped and the battery information is obtained directly.
[0094] In S3, the battery replacement rules apply to users who pay a battery deposit, and the information obtained includes: number of replacements, battery replacement fees, battery replacement users, and settlement methods; the charging rules apply to users who own batteries, and the information obtained includes: charging voltage, charging current, charging capacity, and charging time.
[0095] After determining the corresponding battery specifications based on the acquired battery information, call up the battery replacement rules or charging rules for the corresponding battery model; the battery replacement rules are for the operation of replacing the battery, putting down the battery, and taking away another battery. They are generally applicable to users who pay a battery deposit, and include: number of replacements, battery replacement fees, battery replacement users, and settlement methods.
[0096] The charging rules are for charging the battery and taking it away after it is fully charged. They are generally applicable to users who own their own batteries. They include: charging voltage, charging current, charging capacity, and charging time.
[0097] After the battery enters the battery swap cabinet and is connected to the charging cable, different identification fields need to be defined according to different lithium battery specifications, for example:
[0098] The code for No. 1 lithium battery is 11111, and the code for No. 2 lithium battery is 22222. These fields are entered into the server management system of the charging cabinet. The battery information is stored in the server battery management system. When the battery is connected to the charging cabinet, the battery information can be identified and uploaded to the server based on the communication between the charging cabinet and the battery. The server identifies the supplier through the identification field, thereby retrieving the battery replacement rules or charging rules for lithium batteries of different specifications.
[0099] After obtaining the user's charging and replacement method from the server, match the charging and replacement strategy corresponding to the lithium battery to charge or replace the battery. If the user is a charging user, first read the BMS battery status. If communication is not possible, pre-charge at 0.05C current (some batteries have low voltages, resulting in abnormal communication). If communication is not possible after timeout T1 (1min≤T1≤20min), stop charging and report battery communication abnormality.
[0100] After the battery is in communication, it is charged at a constant current of 0.5C until the SOC reaches 80%, then it is converted to constant voltage charging with a charging current of 0.2C. When SOC ≥ 100 or the current is < 0.02C or the single cell is over-voltage, charging is stopped, indicating that charging is completed here. If abnormal conditions such as excessive cell temperature, large cell pressure difference, high ambient temperature, and rapid temperature rise are detected during the charging process, charging will be stopped and corresponding protection actions will be taken.
[0101] If the user is a battery swap user, when the main control board obtains the battery information, it will send the charging strategy provided by the battery manufacturer through the server and remind the user to close the current battery compartment. After the compartment control board detects that the battery compartment is closed through the door magnetic induction switch, the lithium battery enters the automatic charging process.
[0102] Detection stage: During battery insertion, the main control board detects the battery communication by identifying the battery SN code. In the process of interaction between the battery and the battery swap cabinet, an efficient and secure asymmetric encryption algorithm, the elliptic curve cryptography (ECC) algorithm, is used to ensure the security and integrity of the communication data. The ECC algorithm implements encryption and decryption based on mathematical operations on elliptic curves. With its high strength and short key length, it provides a strong guarantee for data encryption during battery insertion.
[0103] In S2, the battery encryption method includes:
[0104] When the battery is inserted into the battery swap cabinet, the cabinet generates a random public key based on a specific point on the elliptic curve. The elliptic curve equation is expressed as
[0105] y 2 =x 3 +ax+b (1)
[0106] Where a and b are curve parameters and satisfy 4a 3 +27b 2 ≠0, the public key is a point P on an elliptic curve equation, whose coordinates satisfy formula (1);
[0107] The battery swap cabinet sends the generated public key P to the battery. After receiving the public key P, the battery uses its built-in private key d to encrypt the public key P, where the private key d is a randomly generated integer and should be kept confidential. The encryption process involves point multiplication operations on elliptic curves.
[0108] The battery decryption methods include:
[0109] Select a base point G on the elliptic curve, whose coordinates also satisfy the elliptic curve equation, and calculate the point multiplication of the base point G and the private key d, Q = d*G, where Q is the encrypted result and Q is the point on the elliptic curve equation;
[0110] The battery returns the encrypted point Q to the battery swap cabinet. After receiving the encrypted data Q, the battery swap cabinet uses its built-in private key e to decrypt it. The decryption process is based on the point multiplication operation on the elliptic curve.
[0111] The battery swap cabinet uses the private key e to perform a point multiplication operation on the received point Q, R = e*Q;
[0112] The battery swap cabinet also knows the generation process of the battery public key P, P = e*G, and the battery swap cabinet verifies the identity of the battery by comparing whether R and P are equal;
[0113] If R is equal to P, it means that the decryption is successful, the battery swap cabinet confirms the identity of the battery, and continues with subsequent communications. If R is not equal to P, it means that the decryption fails, and the battery swap cabinet refuses to communicate with the battery, thereby preventing unauthorized access and tampering.
[0114] The encryption and decryption process based on the ECC algorithm ensures the security of communication between the battery and the battery swap cabinet. Due to the high strength of the ECC algorithm, even if an attacker intercepts the encrypted data, it is difficult to obtain the private key or decrypt the original data through brute force or mathematical analysis. At the same time, due to the short key length of the ECC algorithm, it also reduces the difficulty of key management and storage, and improves the overall security of the system.
[0115] The battery charging information acquisition method includes:
[0116] S11: Data collection: collect data on battery status, user demand and grid conditions in real time, and perform standardization and normalization to eliminate the impact of different dimensions and ranges on model training. Collect battery status data in real time, including voltage V (unit: volt), current I (unit: ampere), temperature T (unit: Celsius), and remaining power SOC (unit: percentage);
[0117] Collect user demand data in real time, record charging demand type C_type (0 for slow charging, 1 for fast charging), charging time preference T_pref (unit: hour), and power demand E_demand (unit: kWh);
[0118] Collect grid condition data in real time, including current electricity price P (unit: yuan / kWh), grid load rate L (unit: percentage), and expected load change trend ΔL (unit: percentage / hour).
[0119] S12: Data cleaning: Use the pandas library of Python, a data processing software, to load the data set. Then sort the data set and compare whether adjacent rows are exactly the same to check and remove duplicate records. Alternatively, use specific functions such as duplicated() or drop_duplicates() in the pandas library. Once duplicate records are found, decide whether to keep the first record or delete all duplicate records based on business needs.
[0120] Identify and handle missing values. Go through the data set and check whether there are missing values in each field. These values are usually represented by null values, NaN (Not a Number), or other special markers. For missing values in non-key fields, if the missing ratio is high and has little impact on the analysis, delete the field.
[0121] For missing values in key fields, a filling strategy is needed. If the data is a time series or has an obvious trend, use interpolation methods (such as linear interpolation, polynomial interpolation, etc.) to estimate the missing values. If the data has no obvious trend or seasonality, use the mean, median or mode to fill the missing values. For categorical variables, the most common category can be used to fill.
[0122] S13: Identify and handle outliers. Use the statistical method IQR rule or Z-score method to identify outliers. Based on business needs and data characteristics, decide whether to delete outliers, replace them with other values (such as mean, median, etc.), or keep outliers but mark them.
[0123] The IQR rule usually defines values that exceed 1.5 times the interquartile range (IQR, the difference between the third quartile and the first quartile) as outliers. The Z-score method calculates the standard deviation multiple of each data point from the mean, and data that exceeds plus or minus 3 times the standard deviation are usually considered outliers.
[0124] S14: Data standardization: standardize the voltage V, current I, and temperature T in the battery status data, such as using z-score standardization to convert them into a distribution with a mean of 0 and a standard deviation of 1, and normalize the remaining power SOC to map its value to the interval [0,1].
[0125] S15: data normalization, normalizing the charging time preference and power demand in the user demand data to ensure that their values are within the range of [0,1] or [-1,1];
[0126] Category data processing: For charging demand type data, use one-hot encoding to convert it into a format suitable for machine learning model processing;
[0127] Normalize the current electricity price P, grid load rate L, and expected load change trend ΔL in the grid condition data to ensure that their values are also within the range of [0,1] or [-1,1];
[0128] S16: Data integration: Integrate the cleaned, standardized and normalized battery status data, user demand data and grid condition data into the same dataset to ensure that each record contains all relevant features for subsequent model training.
[0129] Extract battery features:
[0130] SOC (remaining capacity): SOC is extracted directly from the preprocessed data as one of the key features. SOC reflects the current state of charge of the battery and is an important parameter in battery management.
[0131] I_max (the maximum acceptable charging current of the battery): This feature needs to be obtained according to the battery specification or through experimental measurement. In practical applications, the maximum acceptable charging current of the battery is related to factors such as the battery SOC and temperature. Therefore, I_max can be estimated based on these factors and extracted as a feature.
[0132] V_max (the maximum acceptable charging voltage of the battery): Similar to I_max, V_max also needs to be obtained according to the battery specification or through experimental measurement. It reflects the maximum voltage that the battery can withstand during the charging process and is an important parameter for protecting battery safety.
[0133] T (temperature): The battery temperature T is directly extracted from the preprocessed data as a feature. Temperature has an important impact on the performance and life of the battery, so it needs to be taken into consideration.
[0134] Extract user features:
[0135] C_type (charging demand type): C_type is directly extracted from the preprocessed data as one of the user features. The charging demand type (slow charging or fast charging) reflects the user's demand for charging speed and is of great significance to the grid load.
[0136] T_pref (charging time preference): Extract the user's charging time preference T_pref from the preprocessed data as a feature. This feature helps optimize the grid load and improve battery utilization.
[0137] E_demand (electricity demand): E_demand is directly extracted from the preprocessed data as one of the user features. The electricity demand reflects the amount of electricity required by the user and plays a guiding role in charging planning and grid scheduling.
[0138] Extracting grid characteristics:
[0139] P (current electricity price): The current electricity price P is extracted from the preprocessed data as one of the grid characteristics. Real-time electricity price information affects the user's charging cost and charging behavior, and is an important consideration in formulating charging strategies.
[0140] L (grid load rate): The grid load rate L is directly extracted from the preprocessed data as a feature. The grid load rate reflects the current load of the grid and has an impact on the stability and dispatching strategy of the grid.
[0141] ΔL (expected load change trend): The expected load change trend ΔL is extracted from the preprocessed data as one of the grid features. This feature helps predict the grid status and formulate dispatch plans.
[0142] Feature selection, after extracting the above key features, feature selection is performed to reduce model complexity and improve prediction performance. Feature selection can be performed using statistical method correlation analysis. Based on the results of feature selection, features that have a significant impact on the model prediction performance are retained, and redundant or irrelevant features are eliminated.
[0143] Use historical data and extracted features to train the machine learning model, and improve the model's prediction performance by adjusting model parameters and optimizing algorithms. Select support vector machine (SVM) and random forest to build the mapping relationship between features and target variables. The target variables can be charging current I_set (unit: ampere) and charging time T_set (unit: hour). Use cross-validation technology to tune model parameters to minimize prediction errors.
[0144] Model training methods include:
[0145] S21: Data preparation, extracting pre-processed and integrated feature sets from historical data, including battery status data, user demand data, and grid condition data, and determining target variables, charging current I_set (unit: ampere) and charging time T_set (unit: hour);
[0146] S22: Dataset partitioning: randomly divide the dataset into training set, validation set and test set. The training set is used for model training, the validation set is used for model selection and parameter tuning, and the test set is used to evaluate the final performance of the model.
[0147] S23: In the model training phase, a machine learning algorithm is selected, and two algorithms, support vector machine and random forest, are used to build a prediction model using the training set data;
[0148] Support vector machine model training:
[0149] Data preparation: Preprocess the training set data and ensure that the features and target variables are ready. For SVM, pay special attention to whether the data is linearly separable or whether it needs to be mapped to a higher dimension through a kernel function to achieve linear separability.
[0150] Model initialization: Initialize the support vector machine training model and set basic hyperparameters;
[0151] In the Python environment, use the sklearn.svm.SVC class to initialize the SVM model. At this point, you can set some basic hyperparameters, such as the C value (the penalty coefficient for misclassification, the default value is 1.0), kernel (kernel function type, the default is the 'rbf' radial basis kernel function), and gamma (the coefficient for the 'rbf', 'poly', and 'sigmoid' kernel functions, the default is 'auto').
[0152] Model training: Call the fit method of the support vector machine object, pass in the features of the training set and the target variable as parameters, and start training the model; for example: svm_model.fit(X_train,y_train), where X_train is the feature data of the training set and y_train is the corresponding target variable.
[0153] Training monitoring and optimization: During the training process, monitor the training progress and performance of the model, and adjust hyperparameters as needed to improve the generalization ability of the model;
[0154] Random Forest Model Training:
[0155] Data preparation: Preprocess the training set data and ensure that the features and target variables are ready. For SVM, pay special attention to whether the data is linearly separable or whether it needs to be mapped to a higher dimension through a kernel function to achieve linear separability.
[0156] Model initialization: Initialize the random forest model and set basic hyperparameters;
[0157] In Python, using sklearn.ensemble.RandomForestRegressor,
[0158] Or RandomForestClassifier, depending on the type of target variable, to initialize the random forest model. Initialization parameters may include n_estimators (the number of trees, defaults to 100), max_depth (the maximum depth of the tree, defaults to None, indicating unlimited depth), and min_samples_split (the minimum number of samples required to split an internal node, defaults to 2), etc.
[0159] Model training: Train the model by calling the fit method of the random forest object and passing in the features of the training set and the target variable; for example: rf_model.fit(X_train,y_train).
[0160] Parallelization and optimization: The random forest algorithm naturally supports parallel computing, so multi-core processors are used to accelerate training during the training process, and the performance and complexity of the model are optimized by adjusting hyperparameters;
[0161] S24: Cross-validation and parameter tuning. The k-fold cross-validation technique is used to divide the training set into k subsets. Each time, k-1 subsets are used as training data, and the remaining subset is used as validation data. The hyperparameters of the support vector machine and random forest are adjusted respectively. The Bayesian optimization method is used to find the best hyperparameter combination, and the average performance of each set of hyperparameters in cross-validation is recorded.
[0162] S25: Model selection: Based on the results of cross-validation, select the model with the best performance and its corresponding hyperparameter settings, optimize and revalidate the model, revalidate the selected best model using the validation set data, and record the average performance of each set of hyperparameters in cross-validation (such as accuracy, mean square error, etc.).
[0163] Charging strategies include:
[0164] Generate the current charging and swapping strategy based on real-time data and trained models;
[0165] Battery charging requirements calculation:
[0166] Charging demand (E_demand) = (target power - current power) × battery capacity;
[0167] Charging current calculation:
[0168] Charging current (Iset) = charging demand (Edemand) / charging time (Tset);
[0169] Among them, the charging current (Iset) should not exceed the maximum charging current Imax of the battery;
[0170] Grid electricity price cost optimization:
[0171] Electricity cost (Cost) = Charged electricity (E_charged) × Electricity price (P)
[0172] Initialization parameters: set the time step and determine the total number of time steps in a day, obtain the electricity price P[t] for each time step, obtain the grid load rate L[t] and the expected load change trend ΔL[t] based on historical data or prediction models;
[0173] Construct the cost matrix: Create a two-dimensional array cost[i][j], where i represents the time step, j represents the battery charge state, and cost[t+1][j next ]=min(cost[t+1][j next ]); initialize cost[i][j] to a larger value (indicating an unreachable state), except that cost[0][initial power] is 0 (indicating that the initial state cost is 0).
[0174] Dynamic programming solver, traverses each time step t, for each time step t, traverses each possible battery power state j, and calculates the maximum chargeable power ΔE in the current time step according to the maximum charging current I_max of the battery and the charging time of the current time step;
[0175] Calculate the range of power states that may be reached in the next time step. For each possible j_next, calculate the cost of transferring from the current state (t, j) to (t+1, j_next):
[0176] Charging cost = (j_next-j)*battery capacity*P[t], update cost[t+1][j_next] to the currently known minimum cost; other costs may also need to be considered, such as battery replacement cost (if any), battery loss cost, etc., update cost[t+1][j_next] to the currently known minimum cost (if the cost obtained through (t,j) transfer is smaller).
[0177] Backtrack the optimal strategy, starting from cost[T_total-1][target power], backtrack to obtain the optimal power state at each time step, calculate the corresponding charging current and charging time based on the optimal power state at each time step, output the optimal charging and swapping strategy, and output the final optimal charging and swapping strategy to the main control board for execution.
[0178] During the backtracking process, ensure that the charging strategy meets user requirements (such as charging requirement type C_type, charging time preference T_pref) and battery limitations (such as maximum charging current I_max, maximum charging voltage V_max, temperature T, etc.). If the strategy obtained by backtracking does not meet these conditions, it needs to be adjusted (increase charging time or reduce charging current).
[0179] Through the optimization algorithm, choose to charge during the period with lower electricity prices to reduce costs. Taking into account multiple factors such as battery charging demand, grid electricity prices, battery replacement costs (if any), and battery life, the optimization algorithm is used to solve the optimal charging and replacement strategy.
[0180] Charging stage: During the charging process, the battery and the charger are in communication state, and the main control board reads the information related to the battery status. If the battery cannot communicate, it is necessary to pre-charge at 0.05C current (some batteries have low voltage, resulting in abnormal communication). If the communication is not established within the time limit T1 (1min≤T1≤20min), the charging is stopped and the battery communication abnormality fault is reported.
[0181] After the battery is connected, it is charged at a constant current of 0.5C until the SOC reaches 80%, and then converted to constant voltage charging V1. This voltage support is configurable, and the charging current is 0.2C. When the battery SOC is ≥100 or the current is <0.02C and the voltage is ≥V2 or the single cell is over-voltage, the charging is stopped, indicating that the charging is completed here. During the charging process, if abnormal conditions such as high cell temperature, large cell pressure difference, high ambient temperature, and rapid temperature rise are detected, the charging will be stopped and corresponding protection actions will be taken.
[0182] Conventional charging methods generally use constant current and then constant voltage charging, which is suitable for most batteries. PID charging mode is suitable for batteries in different health states. Different charging voltages and currents can be set to achieve precise charging control.
[0183] The PID algorithm can dynamically control the output voltage and current of the charger according to the real-time status of the battery. It can realize closed-loop control of the charging voltage and current to achieve the purpose of fast and safe battery charging. The charging voltage and current thresholds of batteries in different health states need to be set independently to avoid overcharging and over-discharging. Dynamically controlling the charger output and maintaining it in the best working state can improve the charging efficiency of the battery and achieve energy saving.
[0184] Using PID charging mode to charge the battery:
[0185]
[0186] After discrete conversion:
[0187]
[0188] In the formula, u(t) is the output curve, the PID output value changes with time, Kp is the proportional coefficient, e(t) is the curve of the deviation between the set value and the actual value changing with time, Ti is the integral time, Td is the differential time, and T is the adjustment cycle;
[0189] During the battery charging process, the real-time voltage and current of the battery are read as process feedback values, and the error is calculated with the voltage and current reference values set by the charging strategy. The control output is generated according to the error value, and the voltage and current output of the charger are adjusted. The P term proportionally adjusts the control quantity according to the error, the I term integrates the error, and the D term is adjusted according to the error change rate. By adjusting the PID parameters, precise control of the charging process can be achieved.
[0190] Charging end stage: the charger stops power output and enters the battery status detection state; the main control board controls the charger to disconnect the charging and discharging MOS and enter the idle state.
[0191] The charging cabinet will select the appropriate battery according to the existing batteries in the charging cabinet, open the battery compartment, and remind the user to remove the battery in time. If the user does not remove the battery and does not close the battery compartment door for a long time, the main control board will sound an alarm and remind the user on the APP.
[0192] In summary, the battery swap cabinet has good compatibility with lithium batteries of different specifications from different manufacturers, which can effectively improve the utilization rate of the battery swap cabinet and effectively increase the convenience of end users.
[0193] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
Claims
1. A method for charging multiple types of batteries using a battery swap cabinet, characterized in that: The following steps are involved: S1: The battery swap cabinet recognizes the battery manually or automatically. S2: During battery insertion, the main control board identifies the battery SN code, performs communication detection on the battery, and implements encryption and decryption of the battery based on the elliptic curve cryptography algorithm. The battery swap cabinet obtains battery-related information through handshake communication with the battery. S3: Based on the battery related information, determine whether the battery model is a battery replacement rule or a charging rule, wherein the battery replacement rule is to replace the battery, insert the battery, and then take out another battery, and the charging rule is to charge the battery; In S1, the battery-related information includes the battery number, charging conditions, placement status, charging voltage, charging current, technical parameters, and remaining power. If the battery is hard-connected, the battery placement status is first determined. If the battery is soft-connected, the placement detection is skipped and the battery information is directly obtained. In S2, the battery encryption method includes: When the battery is inserted into the battery swap cabinet, the cabinet generates a random public key based on a specific point on the elliptic curve. The elliptic curve equation is expressed as y 2 =x 3 +ax+b (1) Where a and b are curve parameters and satisfy 4a 3 +27b 2 ≠0, the public key is a point P on an elliptic curve equation, whose coordinates satisfy formula (1); The battery swap cabinet sends the generated public key P to the battery. After receiving the public key P, the battery uses its built-in private key d to encrypt the public key P, where the private key d is a randomly generated integer; The battery decryption methods include: Calculate the point multiplication of the base point G and the private key d, Q = d*G, where Q is the encrypted result and Q is the point on the elliptic curve equation; The battery returns the encrypted point Q to the battery swap cabinet. After receiving the encrypted data Q, the battery swap cabinet uses its built-in private key e to decrypt it. The decryption process is based on the point multiplication operation on the elliptic curve. The battery swap cabinet uses the private key e to perform a point multiplication operation on the received point Q, R = e*Q; The battery swap cabinet also knows the generation process of the battery public key P, P = e*G, and the battery swap cabinet verifies the identity of the battery by comparing whether R and P are equal; If R is equal to P, it means that the decryption is successful, the battery swap cabinet confirms the identity of the battery, and continues the subsequent communication. If R is not equal to P, it means that the decryption fails, and the battery swap cabinet refuses to communicate with the battery; In S3, the battery replacement rule applies to users who pay the battery deposit, and the information obtained includes: number of replacements, battery replacement fees, battery replacement users, and settlement forms; the charging rule applies to users who own batteries, and the information obtained includes: charging voltage, charging current, charging capacity, and charging time; The battery charging information acquisition method includes: S11: Data collection: real-time collection of battery status data, including voltage V, current I, temperature T and remaining power SOC; Collect user demand data in real time, record charging demand type, charging time preference and power demand; Collect grid condition data in real time, including current electricity price P, grid load rate L, and expected load change trend ΔL; S12: Data cleaning, by sorting the data set and comparing whether adjacent rows are exactly the same, to check and remove duplicate records; Identify and handle missing values, traverse the data set, check whether there are missing values in each field, and delete the field for missing values in non-key fields; For missing values of key fields, if the data is a time series or has an obvious trend, use interpolation to estimate the missing values. If the data has no obvious trend or seasonality, use the mean, median or mode to fill the missing values; S13: Identify and handle outliers. Use the statistical method IQR rule or Z-score method to identify outliers. Based on business needs and data characteristics, decide whether to delete outliers, replace them with other values, or keep them but mark them. S14: Data standardization: standardize the voltage V, current I, and temperature T in the battery status data, convert them into a distribution with a mean of 0 and a standard deviation of 1, and normalize the remaining power SOC, mapping its value to the interval [0,1]; S15: data normalization, normalizing the charging time preference and power demand in the user demand data to ensure that their values are within the range of [0,1] or [-1,1]; Category data processing: For charging demand type data, use one-hot encoding to convert it into a format suitable for machine learning model processing; Normalize the current electricity price P, grid load rate L, and expected load change trend ΔL in the grid condition data to ensure that their values are also within the range of [0,1] or [-1,1]; S16: Data integration: Integrate the cleaned, standardized and normalized battery status data, user demand data and grid condition data into the same dataset to ensure that each record contains all relevant features for subsequent model training.
2. The method for charging multiple types of batteries using a battery swap cabinet according to claim 1, characterized in that: Model training methods include: S21: Data preparation, extracting pre-processed and integrated feature sets from historical data, including battery status data, user demand data, and grid condition data, and determining target variables, charging current, and charging time; S22: Dataset partitioning: randomly divide the dataset into training set, validation set and test set. The training set is used for model training, the validation set is used for model selection and parameter tuning, and the test set is used to evaluate the final performance of the model. S23: In the model training phase, a machine learning algorithm is selected, and two algorithms, support vector machine and random forest, are used to build a prediction model using the training set data; Support vector machine model training: Data preparation: preprocessing of training set data; Model initialization: Initialize the support vector machine training model and set basic hyperparameters; Model training: Call the fit method of the support vector machine object, pass in the features of the training set and the target variable as parameters, and start training the model; Training monitoring and optimization: During the training process, monitor the training progress and performance of the model, and adjust hyperparameters as needed to improve the generalization ability of the model; Random Forest Model Training: Data preparation: preprocessing of training set data; Model initialization: Initialize the random forest model and set basic hyperparameters; Model training: Train the model by calling the fit method of the random forest object and passing in the features and target variables of the training set; Parallelization and optimization: Use multi-core processors to accelerate training during training and optimize the performance and complexity of the model by adjusting hyperparameters; S24: Cross-validation and parameter tuning. The k-fold cross-validation technique is used to divide the training set into k subsets. Each time, k-1 subsets are used as training data, and the remaining subset is used as validation data. The hyperparameters of the support vector machine and random forest are adjusted respectively. The Bayesian optimization method is used to find the best hyperparameter combination, and the average performance of each set of hyperparameters in cross-validation is recorded. S25: Model selection: Based on the results of cross-validation, select the model with the best performance and its corresponding hyperparameter settings, optimize and revalidate the model, and revalidate the selected best model using the validation set data.
3. The method for charging multiple types of batteries using a battery swap cabinet according to claim 2, characterized in that: Charging strategies include: Generate the current charging and swapping strategy based on real-time data and trained models; Battery charging requirements calculation: Charging demand (E_demand) = (target power - current power) × battery capacity; Charging current calculation: Charging current (Iset) = charging demand (Edemand) / charging time (Tset); Among them, the charging current (Iset) should not exceed the maximum charging current Imax of the battery; Grid electricity price cost optimization: Electricity cost (Cost) = Charged electricity (E_charged) × Electricity price (P) Initialization parameters: set the time step and determine the total number of time steps in a day, obtain the electricity price P[t] for each time step, obtain the grid load rate L[t] and the expected load change trend ΔL[t] based on historical data or prediction models; Construct the cost matrix: Create a two-dimensional array cost[i][j], where i represents the time step, j represents the battery charge state, and cost[t+1][j next ]=min(cost[t+1][j next ]); Dynamic programming solver, traverses each time step t, for each time step t, traverses each possible battery power state j, and calculates the maximum chargeable power ΔE in the current time step according to the maximum charging current I_max of the battery and the charging time of the current time step; Calculate the range of power states that may be reached in the next time step. For each possible j_next, calculate the cost of transferring from the current state (t, j) to (t+1, j_next): Charging cost = (j_next-j)*battery capacity*P[t], update cost[t+1][j_next] to the currently known minimum cost; Backtrack the optimal strategy, starting from cost[T_total-1][target power], backtrack to obtain the optimal power state at each time step, calculate the corresponding charging current and charging time based on the optimal power state at each time step, output the optimal charging and swapping strategy, and output the final optimal charging and swapping strategy to the main control board for execution.
4. The method for charging multiple types of batteries using a battery swap cabinet according to claim 1, characterized in that: Using PID charging mode to charge the battery: After discrete conversion: In the formula, u(t) is the output curve, the PID output value changes with time, Kp is the proportional coefficient, e(t) is the curve of the deviation between the set value and the actual value changing with time, Ti is the integral time, Td is the differential time, and T is the adjustment cycle; During the battery charging process, the real-time voltage and current of the battery are read as process feedback values, and the error is calculated with the voltage and current reference values set by the charging strategy. The control output is generated according to the error value, and the voltage and current output of the charger are adjusted. The P term proportionally adjusts the control quantity according to the error, the I term integrates the error, and the D term is adjusted according to the error change rate. By adjusting the PID parameters, precise control of the charging process can be achieved.
Citation Information
Patent Citations
Intelligent charging pile and charging method thereof
CN115891718A
Method and device for improving the performance of electrically powered vehicles
DE102009046991A1