In recent years, the rapid adoption of electric vehicles has transformed the automotive industry, driven by their environmental benefits and lower maintenance costs. As a key component, the battery management system plays a critical role in ensuring the safety, durability, and reliability of electric vehicles. Accurately predicting the State of Charge during charging is essential for optimizing charging efficiency, extending battery life, and enhancing the overall driving experience. Traditional methods for SOC estimation, such as lookup tables and ampere-hour integration, often struggle with accuracy under varying conditions, while model-based approaches like Kalman filters require complex parameter estimation. In contrast, data-driven methods, particularly those leveraging deep learning, offer a promising alternative by utilizing historical data to capture nonlinear relationships without explicit physical models.
This article presents a novel approach for SOC prediction during the charging process of electric vehicles, combining Convolutional Neural Networks, Attention mechanisms, and Long Short-Term Memory networks. The methodology involves collecting real-time data from charging sessions, including voltage, current, temperature, and SOC, followed by data preprocessing to enhance model performance. The integrated CNN-Attention-LSTM model is designed to extract spatial features, emphasize important channels, and capture temporal dependencies, resulting in improved prediction accuracy. Through experiments conducted under different charging scenarios, the model demonstrates superior performance compared to conventional methods, highlighting its potential for widespread application in the evolving landscape of China EV technology.

The growing demand for electric vehicles, especially in markets like China EV, underscores the need for advanced battery management solutions. SOC prediction is not only crucial for efficient charging but also for preventing overcharging and undercharging, which can degrade battery health. Previous studies have explored various neural network architectures, such as CNN-LSTM, but they often face challenges like feature loss and inadequate long-term dependency modeling. By incorporating an Attention mechanism, the proposed model dynamically weights feature channels, enhancing the focus on relevant information and improving generalization across diverse charging conditions. This approach aligns with the global shift towards smarter and more sustainable transportation systems, where electric vehicles play a pivotal role.
Experimental Design and Data Collection
To evaluate the SOC prediction model, we designed experiments that simulate common charging scenarios for electric vehicles, including slow and fast charging. Slow charging was performed using an 11 kW charging station, while fast charging utilized 120 kW and 500 kW stations. The electric vehicle used in the experiments featured a ternary lithium battery pack with a rated voltage of 331.2 V, capacity of 340 Ah, and a voltage range of 252 V to 378 V. Data collection was conducted under controlled environmental conditions, with temperatures maintained between 3°C and 7°C for slow charging and similar stable ranges for fast charging, to minimize external influences.
During each charging session, we recorded parameters such as battery voltage, current, temperature, SOC, State of Health, and charging time using TOSUN hardware and TSMaster software. The SOC values varied across experiments: for slow charging, SOC increased from 52.45% to 63.8%; for fast charging at 120 kW, from 70.5% to 94.15%; and at 500 kW, from 63.7% to 91.2%. This diverse dataset ensures that the model can handle different charging profiles, which is vital for real-world applications in the electric vehicle industry, particularly as China EV infrastructure expands. The collected data was stored in a structured format, with examples provided in the following table summarizing key metrics from a 120 kW fast-charging session.
| Voltage (V) | SOH (%) | SOC (%) | Temperature (°C) | Current (A) | Time (s) |
|---|---|---|---|---|---|
| 349.577 | 100 | 70.5 | 37.5 | 12.5 | 0 |
| 354.2 | 100 | 70.5 | 37.5 | -187.005 | 10 |
| 356.6 | 100 | 71.65 | 37.5 | -183.134 | 80 |
| 358.4 | 100 | 74.05 | 38 | -182.14 | 230 |
| 360.2 | 100 | 76.45 | 38.5 | -182.164 | 380 |
| 363 | 100 | 79.65 | 38.5 | -182.572 | 580 |
| 371.1 | 100 | 87.65 | 38.5 | -182.813 | 1080 |
| 370 | 100 | 87.8 | 38.5 | -135.9 | 1090 |
| 372.2 | 100 | 90.95 | 38 | -136.056 | 1370 |
| 370.4 | 100 | 94.15 | 35.5 | -48.5 | 2110 |
In this table, negative current values indicate charging, while positive values denote discharging. The SOH remains at 100%, signifying optimal battery condition. Such detailed data collection is essential for training robust models that can adapt to the dynamic nature of electric vehicle charging, a key focus in advancing China EV technologies. The experiments were designed to ensure safety and compliance with standards, reflecting the practical challenges faced in real-world electric vehicle operations.
Data Preprocessing and Evaluation Metrics
Data preprocessing is a critical step in machine learning pipelines, as raw data often contains noise, missing values, or inconsistencies that can impair model performance. For this study, we applied several preprocessing techniques to the collected charging data from electric vehicles. First, data extraction involved selecting relevant features: charging current, voltage, battery temperature, charging time, and SOC, with SOC as the output variable. Each sample had a feature dimension of four, and the dataset was randomly split into training and testing sets using an 80:20 ratio to ensure balanced learning and evaluation.
Normalization was performed using min-max scaling to transform the data into a [0,1] range, reducing the impact of varying scales on model training. The formula for min-max normalization is given by:
$$x’ = \frac{x – x_{\text{min}}}{x_{\text{max}} – x_{\text{min}}}$$
where \(x’\) is the normalized value, \(x\) is the original data point, and \(x_{\text{min}}\) and \(x_{\text{max}}\) are the minimum and maximum values in the dataset, respectively. This step helps in accelerating convergence during training and improves the stability of gradient-based optimization. Additionally, data flattening and format conversion were applied to reshape the data into a structure compatible with the neural network inputs, such as sequences for time-series processing.
To assess the model’s performance, we used three evaluation metrics: Coefficient of Determination (R²), Mean Absolute Error (MAE), and Root Mean Square Error (RMSE). These metrics are standard in regression tasks like SOC prediction for electric vehicles. R² measures the proportion of variance in the dependent variable that is predictable from the independent variables, with values closer to 1 indicating better fit. MAE and RMSE quantify prediction errors, with lower values signifying higher accuracy. The formulas are as follows:
$$R^2 = 1 – \frac{\sum_{i=1}^{n} (y_i – \hat{y}_i)^2}{\sum_{i=1}^{n} (y_i – \bar{y})^2}$$
$$MAE = \frac{1}{n} \sum_{i=1}^{n} |y_i – \hat{y}_i|$$
$$RMSE = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (y_i – \hat{y}_i)^2}$$
where \(y_i\) is the actual SOC value, \(\hat{y}_i\) is the predicted SOC value, \(\bar{y}\) is the mean of actual values, and \(n\) is the number of samples. These metrics provide a comprehensive view of model accuracy and are particularly relevant for applications in electric vehicle systems, where precise SOC estimation can enhance charging efficiency and battery longevity in China EV markets.
Model Architecture and Implementation
The proposed CNN-Attention-LSTM model integrates three core components to leverage their strengths in feature extraction, importance weighting, and sequence modeling. The Convolutional Neural Network is employed for spatial feature extraction from the input data. Specifically, a one-dimensional CNN with two convolutional layers is used, with strides and kernel widths of 1, and output channels of 32 and 64, respectively. This setup allows the model to capture local patterns in the time-series data, such as sudden changes in voltage or current during electric vehicle charging. The CNN layers are followed by pooling operations to reduce dimensionality and highlight salient features, mitigating overfitting.
The Attention mechanism, implemented as a Squeeze-and-Excitation block, enhances the model’s ability to focus on informative feature channels. It begins with a global average pooling operation that squeezes spatial information into channel-wise descriptors. This is expressed as:
$$z_c = \frac{1}{H \times W} \sum_{i=1}^{H} \sum_{j=1}^{W} x_c(i, j)$$
where \(z_c\) is the squeezed output for channel \(c\), and \(H\) and \(W\) are the spatial dimensions. Subsequently, excitation involves two fully connected layers that learn channel-wise weights, followed by a sigmoid activation to produce attention scores. The original features are then recalibrated by multiplying with these scores, emphasizing important channels and suppressing less relevant ones. This process improves feature representation without significant computational overhead, making it suitable for real-time applications in electric vehicle charging systems.
The Long Short-Term Memory network handles temporal dependencies in the data, which is crucial for SOC prediction as it evolves over time. The LSTM layer contains 50 hidden units and utilizes gate mechanisms (forget, input, and output gates) to regulate information flow. The cell state update equations are:
$$f_t = \sigma(W_f \cdot [h_{t-1}, x_t] + b_f)$$
$$i_t = \sigma(W_i \cdot [h_{t-1}, x_t] + b_i)$$
$$\tilde{C}_t = \tanh(W_C \cdot [h_{t-1}, x_t] + b_C)$$
$$C_t = f_t \cdot C_{t-1} + i_t \cdot \tilde{C}_t$$
$$o_t = \sigma(W_o \cdot [h_{t-1}, x_t] + b_o)$$
$$h_t = o_t \cdot \tanh(C_t)$$
where \(f_t\), \(i_t\), and \(o_t\) are the forget, input, and output gates, respectively; \(C_t\) is the cell state; \(h_t\) is the hidden state; and \(\sigma\) denotes the sigmoid function. By combining CNN, Attention, and LSTM, the model effectively extracts multi-level features and captures long-range dependencies, leading to accurate SOC predictions for electric vehicles. The overall architecture is trained using the Adam optimizer with a batch size of 30, initial learning rate of 0.01, and up to 500 epochs, incorporating learning rate decay to refine convergence.
Prediction Analysis and Results
We evaluated the CNN-Attention-LSTM model on charging data from different power levels: 11 kW (slow charging), 120 kW, and 500 kW (fast charging). For each scenario, the model was trained and tested on preprocessed datasets, and its performance was compared against a baseline CNN-LSTM model without the Attention mechanism. The input features included charging current, voltage, temperature, and time, with SOC as the target output. The training-test split was maintained at 80:20, and evaluation metrics were computed on the test set to ensure unbiased assessment.
The results demonstrate that the CNN-Attention-LSTM model achieves high accuracy across all charging conditions. For instance, in the 11 kW slow charging experiment, the model yielded an R² value of 0.99866, MAE of 0.098926, and RMSE of 0.12435, indicating nearly perfect alignment between predicted and actual SOC values. Similarly, for 120 kW fast charging, R² was 0.99913, MAE was 0.18579, and RMSE was 0.21703; and for 500 kW, R² reached 0.99951, MAE was 0.15295, and RMSE was 0.18524. These metrics underscore the model’s robustness and generalization capability, which is essential for diverse electric vehicle charging infrastructures, including those in China EV networks.
To provide a comprehensive comparison, we conducted multiple runs for each charging scenario and compiled the evaluation metrics into tables. The following tables summarize the results for slow and fast charging experiments, highlighting the consistency and superiority of the CNN-Attention-LSTM approach over CNN-LSTM.
| Run | Model | R² | MAE | RMSE |
|---|---|---|---|---|
| 1 | CNN-Attention-LSTM | 0.99866 | 0.098926 | 0.12435 |
| 1 | CNN-LSTM | 0.98769 | 0.31795 | 0.35904 |
| 2 | CNN-Attention-LSTM | 0.99800 | 0.10471 | 0.11651 |
| 2 | CNN-LSTM | 0.99008 | 0.18125 | 0.27217 |
| 3 | CNN-Attention-LSTM | 0.99784 | 0.13193 | 0.15263 |
| 3 | CNN-LSTM | 0.99509 | 0.15763 | 0.21276 |
| Run | Model | R² | MAE | RMSE |
|---|---|---|---|---|
| 1 | CNN-Attention-LSTM | 0.99913 | 0.18579 | 0.21703 |
| 1 | CNN-LSTM | 0.99511 | 0.42285 | 0.50197 |
| 2 | CNN-Attention-LSTM | 0.99928 | 0.13825 | 0.17101 |
| 2 | CNN-LSTM | 0.98890 | 0.45937 | 0.63924 |
| 3 | CNN-Attention-LSTM | 0.99772 | 0.33326 | 0.40920 |
| 3 | CNN-LSTM | 0.99544 | 0.45918 | 0.49671 |
| Run | Model | R² | MAE | RMSE |
|---|---|---|---|---|
| 1 | CNN-Attention-LSTM | 0.99951 | 0.15295 | 0.18524 |
| 1 | CNN-LSTM | 0.99705 | 0.41951 | 0.49344 |
| 2 | CNN-Attention-LSTM | 0.99888 | 0.28681 | 0.30760 |
| 2 | CNN-LSTM | 0.99275 | 0.67928 | 0.78818 |
| 3 | CNN-Attention-LSTM | 0.99843 | 0.27380 | 0.38284 |
| 3 | CNN-LSTM | 0.99554 | 0.51093 | 0.64684 |
From these tables, it is evident that the CNN-Attention-LSTM model consistently outperforms CNN-LSTM across all runs and charging scenarios, with higher R² values and lower MAE and RMSE. This improvement can be attributed to the Attention mechanism’s ability to prioritize informative features, reducing noise and enhancing prediction stability. Such advancements are critical for the electric vehicle sector, where accurate SOC estimation can optimize charging strategies, reduce energy waste, and support the growth of China EV ecosystems. The model’s efficiency in processing real-time data further positions it as a viable solution for future intelligent charging systems.
Conclusion
In this study, we developed and validated a CNN-Attention-LSTM model for predicting the State of Charge during electric vehicle charging. The integration of convolutional layers for spatial feature extraction, Attention mechanisms for channel weighting, and LSTM networks for temporal modeling resulted in a robust framework that accurately captures the nonlinear dynamics of battery behavior. Experimental results from slow and fast charging scenarios confirm the model’s high precision, with R² values approaching 1 and minimal errors, demonstrating its feasibility and generalization across different charging conditions.
The comparative analysis with CNN-LSTM highlights the superiority of the proposed approach, as the Attention mechanism effectively addresses limitations in feature emphasis and long-term dependency capture. This innovation holds significant promise for applications in the electric vehicle industry, particularly in regions like China EV, where the adoption of electric vehicles is accelerating. By leveraging real-time data on voltage, current, temperature, and time, the model can facilitate smarter charging protocols, enhance battery lifespan, and improve user experience. As sensor technology, IoT, and cloud computing continue to evolve, the CNN-Attention-LSTM algorithm is poised to play a pivotal role in advancing electric vehicle management systems, contributing to a more sustainable and efficient transportation future.
