Accelerating AI-Based Battery Management System’s SOC and SOH on FPGA

. Lithium battery-based electric vehicles (EVs) are gaining global popularity as an alternative to combat the adverse environmental impacts caused by the utilization of fossil fuels. State of charge (SOC) and state of health (SOH) are vital parameters that assess the battery’s remaining charge and overall health. Precise monitoring of SOC and SOH is critical for efectively operating the battery management system (BMS) in a lithium battery. Tis article presents an experimental study for the artifcial intelligence (AI)-based data-driven prediction of lithium battery parameters SOC and SOH with the help of deep learning algorithms such as Long Short-Term Memory (LSTM) and bidirectional LSTM (BiLSTM). We utilized various gradient descent optimization algorithms with adaptive and constant learning rates with other default parameters. Compared between various gradient descent algorithms, the selection of the optimal one depends on mean absolute error (MAE) and root mean squared error (RMSE) accuracy. We developed an LSTM and BiLSTM model with four hidden layers with 128 LSTM or BiLSTM units per hidden layer that use Panasonic 18650PF Li-ion dataset released by NASA to predict SOC and SOH. Our experimental results advise that the selection of the optimal gradient descent algorithm impacts the model’s accuracy. Te article also addresses the problem of overftting in the LSTM/BiLSTM model. BiLSTM is the best choice to improve the model’s performance but increase the cost. We trained the model with various combinations of parameters and tabulated the accuracies in terms of MAE and RMSE. Tis optimal LSTM model can predict the SOC of the lithium battery with MAE more minor than 0.0179%, RMSE 0.0227% in the training phase, MAE smaller than 0.695%, and RMSE 0.947% in the testing phase over a 25 ° C dataset. Te BiLSTM can predict the SOC of the 18650PF lithium battery cell with MAE smaller than 0.012% for training and 0.016% for testing. Similarly, using the Adam optimization algorithm, RMSE for training and testing is 0.326% and 0.454% over a 25 ° C dataset, respectively. BiLSTM with an adaptive learning rate can improve performance. To provide an alternative solution to high power consuming processors such as central processing unit (CPU) and graphics processing unit (GPU), we implemented the model on feld programmable gate Aarray (FPGA) PYNQ Z2 hardware device. Te LSTM model using FPGA performs better.


Introduction
Using fossil fuels has resulted in adverse environmental impacts such as air pollution and global warming, leading to increased health issues and other socioeconomic impacts worldwide [1]. Most countries are signing international agreements and implementing national policies to combat this environmental impact. Recently, there has been a signifcant focus on EVs powered by lithium batteries, owing to the constraints associated with fossil fuels [2,3]. To encourage the acceptance of EVs in the country, the central government of India announced several promotional measures in the previous ten years, including tax incentives for EV owners and public EV charging infrastructure development [4,5].
Real-time monitoring of lithium battery parameters is crucial for the safety and optimum performance of the battery. Tis can be performed by accurately estimating SOC and SOH [6]. However, this is challenging due to the nonlinear dynamics and electrochemical properties of the lithium batteries. Many technologies attempt to solve this challenge. As battery degradation begins immediately after manufacturing, to ensure the safe functioning of batteries, it is advisable to replace them once they reach approximately 70-80% of their original capacity [7].
Within this article, we are implementing data-driven AIbased predictive BMS to estimate SOC and SOH using deep learning algorithms such as LSTM and BiLSTM. We have implemented various stochastic gradient optimizers used in LSTM and compared various optimizers with adaptive learning rates and constant learning rates. Te data-driven approach bypasses the need for knowledge about internal battery parameters and functioning [8]. Also, information on the physical model, chemical properties or reactions, flters, etc., of the battery is not required. It requires a considerable quantity of real-time battery data, which is readily available nowadays. We can extract battery features from historical data using advanced deep learning algorithms. Our research objective is to implement an FPGA-based AI-driven predictive BMS for electric mobility (E-mobility). We plan to predict a lithium battery SOC and SOH using LSTM and BiLSTM [9]. We have analyzed various gradient descent optimization algorithms and BiLSTM to improve the model performance. We also implemented the model on the FPGA PYNQ Z2 device with a limited dataset to measure SOH. Te challenges and drawbacks associated with the PYNQ Z2 board are also discussed [10].

BMS SOC and SOH Parameters.
A BMS is an electronic circuit that manages battery conditions for increased lifespan and safety. It controls and monitors the battery at the cell, module, and pack levels, while a lithium battery consists of cells arranged to meet voltage and capacity requirements. Te BMS balances each cell unit to avoid degradation in EV performance. Te BMS performs various tasks, including measuring system voltage, current, temperature, SOC, SOH, and RUL; minimizing charging time; maximizing battery life; and cell balancing. Tus, it ensures the safety and optimum performance of the battery [11].
An advanced BMS plays a pivotal role in driving the expansion of the EV industry. Innovating a novel battery technology that provides higher energy and power density and reduces cost is essential. An efective BMS with algorithms that can control and monitor real-time data of the battery and ensure the safety and reliability of the energy storage devices is required. Te BMS monitors the battery pack that powers your EV and estimates the range for us [12]. Additionally, the BMS monitors the battery pack's health and safety during use. Lithium batteries operate under appropriate temperatures, SOC, SOH, and RUL conditions. Te BMS estimates the energy stored, such as a SOC, SOH, and RUL, in real-time [13].
"SOC refers to the amount of charge remaining in the battery and is given by the residual capacity of the battery divided by its nominal capacity." SOC can be mathematically represented by the following equation: where Qa is the battery charge available at present and Qn is the nominal capacity which is constant throughout the battery life (both in Ah).
where SOC 0 is the initial value of SOC and I bat is the battery current. Accurate SOC estimation is critical in efectively controlling battery charge and discharge and extending battery lifespan. However, SOC relies on several factors, such as electrochemical reactions, temperature, material degradation, and ageing cycles, as it represents the internal state of a battery. Hence, in the past few decades, research has been concentrated on devising a professional approach for estimating SOC [14]. Te SOH represents the diference between the health of a battery being used and a new battery. It is the ratio of the maximum battery charge to the rated capacity: where Q max represents the battery's maximum charging capacity and Q n represents nominal capacity * RUL of lithium battery � total number of charging/discharging life cycles * − actual number of charging/discharging life cycles ( * nominal capacity and total number of lifecycles are given by manufacturers and are fxed throughout battery life. SOH degrades as the number of charging cycles increase). Data-driven algorithms can estimate battery states using historical data without the physical model of the battery. Tis helps to save considerable time and efort. Optimized AI-based methods are widely used in natural language processing (NLP), computer vision, image processing, video processing, speech recognition, etc., and are areas of study within the feld of artifcial intelligence [15,16].
Optimizing neural networks in AI is a challenge. Overftting, characterized by a large gap between training and test errors, can be mitigated using regularization techniques and adaptive learning rate algorithms such as Adadelta, SGD, Adam, Adamax, AdaGrad, FTrl, and RMSProp [17].

Contribution
(i) Developed LSTM and BiLSTM models to predict SOC and SOH (ii) Implemented the model on feld programmable gate array (FPGA) PYNQ Z2 hardware device to provide an alternate solution to high power consuming processors such as CPU and GPU (iii) Compared FPGA time and space complexity with CPU and GPU.
In our experiments, we have correctly tuned LSTM/ BiLSTM model hyperparameters to overcome the issue of overftting. In addition, we investigated the efect of selecting the gradient optimization algorithm on the model's accuracy, especially regarding the SOC/SOH estimation of a lithium battery. We deployed a popular LSTM/BiLSTM model strategy, efectively using early stopping, dropout, adaptive learning rates, splitting testing, and training data.

Related Work in AI-Based Algorithms, SOC and SOH
Estimation, and FPGA. Almaita et al. [18] implemented a data-driven BiLSTM NN method wherein MAE is evaluated at less than 0.62%, demonstrating both robustness and accuracy of SOC prediction. Sun et al. [19] proposed an MLbased LSTM-RNN with extended input (EI) and constrained output (CO) utilized for SOC estimation in lithium batteries, ensuring both accuracy and robustness, named EI-LSTM-CO wherein RMSE and MAE are estimated at 1.3% and 3.2%, respectively, on unknown data. To improve the SOH prediction accuracy of the lithium batteries, Sun et al. [19] implemented ICA-BiLSTM to predict lithium battery SOH. Mean square error (MSE) was used as a performance metric and compared with GRU, LSTM, and BPNN. Stighezza et al. [20] SVM was employed as a regression method for SOC estimation. Te model was simulated in MATLAB Simulink and converted to HDL to implement on FPGA Board with RMSE at 1.4%. Chemali et al. [21] presented an alternative solution for low-cost hardware to improve the throughput and resource usage of a SOC estimator for lithium-ion batteries which attains a low MAE of 0.573% at a constant ambient temperature and an MAE of 1.606% on a dataset with temperature ranging from 10 to 25 degrees Celsius. Kim [22] proposed an AI-based SOH estimation method that achieves high accuracy, with approximately 98.4% prediction accuracy for rule-based operation profles and around 99.5% for dynamic driving profles. A similar work by Luciani et al. [23] focuses on designing and validating a data-driven SOC estimation method using IoT-based HIL experiments. Te method achieves an impressive 98% accuracy in real-time hardware testing. Khumprom and Nita concluded in their article [24] that data-driven methods using advanced AIbased algorithms achieve higher performance and accuracy with the drawback of higher computational time. Li et al. [25] proposed that GRU RNN requires no physical model. Observable variables such as voltage, current, and temperature are directly linked to SOC through mapping. Te method is evaluated on two public datasets, yielding MAEs of 0.86%, 1.75%, and 1.05%. Li proposes the BMS hardware prototype as part of future work. Jemmali et al. [26] proposed an FPGA implementation of the EKF algorithm with low power consumption and high-speed advantages. He and He [27] implemented FPGA-based deep neural network to provide an alternative solution for CPU and GPU. Experimental results compared with CPU and GPU achieves improved performance in terms of speed and energy. Bobulski and Kubanek [28] applied deep learning technique for plastic waste classifcation system which would help to solve the plastic waste problem. Zhenhua Cui et al. proposed hybrid model CNN-BWGRU (CNN and bidirectional weighted gated recurrent unit) to enhance the performance of SOC prediction, which is able to predict MAE and RMSE 0.0127 and 0.0171 with 300 BWGRU units for 1000 iterations.
Based on the above literature review, data-driven approaches are accurate and robust. Tis implementation does not require knowledge or modelling of the battery's internal parameters but requires a substantial volume of data. Researchers suggest that deep learning algorithms such as RNN, LSTM, and BiLSTM algorithms ofer more accuracy and advantages than ML model-based algorithms. DL algorithms are ML subsets consisting of three or more network layers. Each layer of a deep learning NN is a series of complex mathematical operations such as multiplication and accumulation between the input data and some constraints such as activation functions, weights, and bias. So, we may require on-chip memory and a reliable processor to store data and real-time data processing.
Currently, CPUs and GPUs are used to process the data, but are slower than GPUs [29]. Terefore, DL algorithms are implemented on high-speed processors such as GPUs [30]. But GPUs consume high power and are expensive, which is a challenge in real-time applications. FPGAs are scalable and confgurable and use low power. FPGA is also a good choice considering GPU and CPU. FPGA provides low-cost hardware and improves throughput [31]. Based on the summary, fndings, and current research development, we proposed AIbased data-driven SOC and SOH prediction algorithms using a low-cost hardware FPGA to improve the performance.

Proposed Data-Driven AI-Based BMS SOC and SOH
Te proposed method started with data preparation or data preprocessing of the lithium battery. Data preprocessing includes data cleaning, which helps improve data quality, transform data into a valuable and efcient format, and enhance the model's performance. Data preprocessing is essential to avoid duplication and eliminate missing data felds. Furthermore, it carried out outlier detection to identify any data points that lie outside the anticipated range. Additionally, it implemented data normalization techniques to guarantee consistency and coherence across the entire dataset. After that, a dataset is split into training and testing sets. Te model is trained and tested on diferent datasets. After an experimental result analysis, the LSTM and BiLSTM model is built with the correct number of LSTM units. Various gradient descent techniques are implemented and examined based on performance metrics. An optimized gradient descent technique model is then ready to implement on an FPGA board. All these steps are shown in Figure 1. Te proposed method is an AI-based data-driven approach, eliminating the need to manually construct a physical or mathematical model for varying temperatures and other unstable on-road real-time conditions. Te proposed method for estimating SOC and SOH can be applied to diferent types of batteries, enabling accurate prediction of SOC and SOH. We have employed two datasets of lithiumion batteries. In the dataset split step, the dataset is split into training, testing, and validation sets and adapted to suit the LSTM model. We trained the models on the frst 60% of the dataset and tested and validated it on the remaining 40%. Data is split to keep overftting in balance. Te splitting of data in training and testing afects the LSTM model. Data quality is vital in a data-driven approach to obtain good  PYNQ Z2 platform, so we need to design or develop LSTM from scratch [33]. We have developed the LSTM model from scratch without taking inbuilt support. Te model performance is tested on limited data and compared with CPU and GPU. Te proposed methodology is discussed in detail in the outcome analysis and discussion section.
In this article, we have efectively tuned the hyperparameters of the LSTM/BiLSTM model to address the challenge of overftting. Furthermore, we investigated the impact of selecting diferent gradient optimization algorithms on the model's performance, with a particular focus on SOC/SOH estimation for lithium batteries. We deployed a popular strategy in the LSTM/BiLSTM model of efectively using early stopping, dropout, adaptive learning rates, splitting testing, and training data. Tis has two critical benefts as compared to model-driven approaches.
(i) AI-based data-driven algorithms accurately predict the relationship between observable quantities (voltage, current, and temperature) and unobservable quantities (SOC and SOH) (ii) Te need to identify electrochemical machining (ECM) parameters is circumvented.
Terefore, we intend to conduct in-depth research and propose a solution using the AI algorithm as the next step.
Multiple complex factors impact battery SOC and SOH. None of the methods proposed by specialists can guarantee the accuracy and practicability of estimate SOC and SOH estimation. Our current research outlays the following technical challenges in the process of SOC and SOH prediction: (1) Enhancing the accuracy, robustness, and efectiveness of SOC and SOH estimation without increasing model complexity (2) To simplify the estimation models and enable their implementation on cost-efective hardware such as FPGA rather than relying on GPU/CPU.
Te solutions to the above are correlated. Terefore, the aim is to fnd an acceptable trade-of between accuracy and computational resources. We accomplished this by proposing an approach to curtail the sources of error in the SOC and SOH prediction. Tis article attempts to predict SOC and SOH using deep learning algorithms LSTM and BiLSTM. We implemented this model on an FPGA device. Our research aims to develop reconfgurable hardware for an advanced AI-based data-driven model.

Data-Driven AI-Based Algorithms and PYNQ Z2 FPGA Device
Tis section introduces the fundamental theories of RNN, LSTM, BiLSTM, lithium battery dataset, and the PYNQ Z2 device.

Recurrent Neural Networks (RNNs).
RNNs are deep learning models with cyclic connections that can store information for a long time. Unlike feed-forward networks, RNNs utilize input from previous neurons, making them suitable for sequential time series prediction. Figure 2 illustrates an unfolded RNN architecture for predicting SOC and SOH which is specifcally designed for this purpose. An RNN has a feedback loop, as shown in the above fgure. Tis feedback loop can be unfolded in time steps. Input and output at time step t is denoted as INPUT and OUTPUT. Te INPUT at the time sequence t consists of temperature, voltage, current, and other battery parameters. Tese parameters are mapped to SOC and SOH. We can provide SOC and SOH as input at time step t and estimate output the error between actual and predicted SOC and SOH. Te hidden state at time step t is represented by ℎ t , while the output SOC t+1 and SOH t+1 value at time step t + 1.

LSTM.
LSTM, a more advanced variant of RNN, incorporates time-cyclic neural networks and memory mechanisms to capture long-term dependencies and mitigate the vanishing gradient problem efectively. Unlike RNNs, LSTM is free from the issue of long-term dependencies as there are four interacting cells against a single neuron and a unique storage unit structure. Tese characteristics of the LSTM help in efectively forecasting battery states. In addition, the accuracies are visualized through a plot of training and testing battery states values. LSTM employs three gates to control data fow, allowing information retention over time. Te cell stores information, while the gates manage memory. Tis architecture enables LSTM to classify, analyze, and predict time series data with varying durations. Te forward pass of an LSTM cell architecture [34] is represented as shown in Figure 3.
At time step "t," the variables F t , I t , O t , C t , and h t represent the components of the LSTM architecture. Specifcally, F t denotes the forget gate, I t represents the input gate, O t represents the output gate, C t represents the cell state, and h t represents the hidden state. Te sigmoid activation function is denoted by the symbol σ. Te symbol ⊙ represents the Hadamard product, which signifes the element-wise multiplication of vectors. Te output of an LSTM cell in time series mostly depends on three gates: (1) cell state gate (C t ) long-term memory of LSTM cell, (2) hidden state (h t ) which stores the previous output, and (3) the input gate (I t ) stores the input data at the present step.
Tese gates decide what information to be entered in the LSTM network and out of the LSTM network [35]. Te initial step in the LSTM architecture cell involves the forget gate (F t ), responsible for determining which information from the previous cell state C t−1 will be discarded at time step t and what information should be stored to pass in the LSTM network. Utilizing a sigmoid activation function, the forget gate determines whether to discard or keep information from the previous cell state. 0 signifes low weightage and forgetting, while 1 indicates retaining everything. Tus, the decisions of gates are based on the current input I t , cell state C t , hidden state ℎ t , and the LSTM network's weights and biases [36].
where "x t " represents the current input at time step t and " b f " denotes the bias term. "W f " denotes the weight matrix associated with forget gate "F t ."

Input Gate.
Te sigmoid function determines the binary values (0 or 1) that impact memory, while the tanh function assigns weights to data on a scale of −1 to 1.
Te tanh layer produces the new value C t as shown in the following equation: Te cell state C t is updated by combining it with the previous cell state, as mentioned in equation (6). Te forget gate (F t ) and input gate (I t ) collectively determine whether the values from the previous LSTM cell should be stored or forgotten. Te cell state (C t ) at time t is represented by the following equation: Te fnal step involves the output gate (O t ) using a sigmoid activation function to determine which portion of the cell state is transferred to the hidden state (h t ). Within the hidden state, the cell state (C t ) is passed through the tanh function and then multiplied by the output gate (O t ) to retain only the desired output. Te output gate (O t ) and hidden state (ℎ t ) are shown in equations (8) and (9), respectively.

Output Gate.
Te LSTM architecture, as depicted in Figure 3, makes conditional decisions regarding what output to produce based on the block's input and memory.  Figure 2: RNN architecture for SOC and SOH. Note that this article aims to assess the performance of LSTM and BiLSTM with adaptive learning rates and constant learning rates with diferent gradient descent optimizations. So, we focused on developing an advanced deep learning model with minimum error and hardware realization. Te benefts of FPGA can be leveraged as real-time estimations through AI-based algorithms which are bound to require excessive computational power.

Performance Metrics RMSE and MAE.
Te AI-based LSTM/BiLSTM models for predicting SOC and SOH were trained and tested using two distinct datasets. Te performance of these models is assessed using various evaluation metrics, such as RMSE and MAE metrics, providing insights into their efectiveness [38].
Battery datasets used for experimental purposes: to measure SOC, we utilized a 2.9 Ah Panasonic 18650PF Liion cell, while for measuring SOH, we relied on the Li-ion battery dataset provided by NASA. Te input characteristics of lithium batteries are plotted in Figures 4 and 5, showing the relationship between the battery temperature vs. SOC and battery voltage vs. SOC. Temperature and voltage rate strongly infuence battery performance. Te battery should be operated at a proper temperature range for optimum performance. Figure 4 shows temperature versus SOC and indicates that the battery operates well at ambient temperature [40]. Figure 5 illustrates the correlation between battery voltage and SOC.
Te terminal voltage of the lithium battery exhibits a nearly proportional relationship with the SOC. Hence, understanding the relationship between voltage and SOC is crucial for accurately estimating and efectively managing the BMS [41]. Figures 6 and 7 display characteristic curves illustrating the degradation of SOH to the number of charging/discharging cycles. Te fgures demonstrate that the battery's health degrades as cycles increase. Te SOH degradation starts at about 120-130 cycles or when SOH is around 0.70%. Terefore, we can conclude that the battery's maximum and energy storage capacity is reducing slowly [42].

Data-Driven LSTM/BiLSTM Model Development.
Initially, we built the LSTM model of four hidden layers with 150 units in each layer, variable dropout in various layers, constant learning rate � 0.001, and other default parameters. Te LSTM model architecture depicted in Figure 8 consists of four hidden layers, with each layer comprising 150 units. Various gradient descent optimizer algorithms were taken from the TensorFlow and keras packages.
Next, actual SOC at sequential time steps is input to LSTM. Te dataset is partitioned into separate training and testing sets, and the testing data is used for validation. We have incorporated several gradient descent algorithms in our implementation, including Adadelta, Adagrad, SGD, and RMSprop. Follow the regularized leader (FTRL) and Adam. We trained and validated the LSTM model during  Applied Computational Intelligence and Soft Computing implementation for 100, 300, and 500 epochs. With constant learning rate � 0.001 and other default parameters. Te dataset is divided at 80% in testing and 20% in training. Te forecasting performance metrics are measured using MAE and RMSE. Comparisons between them are given in Table 2.
Based on the results presented in Table 2, it can be observed that the Adam optimizer outperforms other optimizers, yielding superior results. RMSprop also produces a better result, but it has an underftting problem. Another observation is that the performance metric RMSE of a test is more signifcant than the RMSE of a train. Tis indicates that the LSTM model has a problem with overftting. To overcome this, we have tried tuning the hyperparameter of the LSTM model by simplifying the network, reducing the number of LSTM units, early stopping, and reducing dropout regularization.     [43], as illustrated in Figure 9.
Te dropout stochastic regularization technique prevents neural networks from overftting. During training, specifc neurons are randomly excluded or "dropped out." Tis dropout technique introduces noise to the hidden state, enhancing the model's robustness and preventing overftting [44]. Our results suggest that reducing dropout improves performance and overcomes the problem of overftting. In general, if we cared about the LSTM deep learning model performance on the training dataset, we expect a model to have perfect performance on the testing dataset. Splitting the dataset into separate training and testing sets holds signifcant importance. Training and testing the model on distinct datasets is crucial to ensure accurate evaluation and robustness. To overcome the problem of overftting, the testing data should be almost equal to the training dataset.
Based on the fndings presented in Table 2, we have chosen Adam as a gradient descent optimizer and varying dropout regularization with diferent numbers of LSTM units but without early stopping. So, LSTM network is run for 500 iterations with 64 LSTM units in each hidden layer with varying dropout regularization, and the dataset is divided into 65% in testing and 35% training to reduce the problem of overftting as shown in Figure 10, and the results are shown in Table 3. Table 3 shows exciting results. We have taken only 64 LSTM units in this model in each hidden layer to simplify the network. As we reduce the dropout regularization, LSTM network performance improves regarding MAE and RMSE. By reducing dropout regularization, the performance of the LSTM network improves. However, still model is overftting. To address the overftting issue, the number of LSTM units in each hidden layer was increased to 100 from the previous 64 LSTM units. Additionally, dropout was reduced. Te results of these adjustments are displayed in Table 4.
Following are the key observations based on results shown in Tables 3 and 4: (1) As we reduced dropout, MAE and RMSE improved (2) As we decreased the number of LSTM below 100 units, MAE and RMSE increased, which degraded the performance of the LSTM model. Table 4 that model must have LSTM units of more than 100 with less dropout in each layer. However, the model still faced issues of overftting. We then used 128 LSTM units in each layer and compared it with 256 units and 64 LSTM units with optimizing gradient descent. We used "Adam" with and without early stopping, as shown in Tables 5 and 6.

So, we have concluded from
In Table 5, we have run the LSTM model for 200 iterations without early stopping. LSTM model with 256 units performs better. Increasing the number of LSTM units in each hidden layer leads to improved performance; however, it also results in increased costs.

Applied Computational Intelligence and Soft Computing
In Table 6, we have run the LSTM model for 200 iterations with early stopping. It is observed that with early stopping, the model performed very well compared to those without early stopping. A model with zero dropouts produced better results. Tis means early stopping afects the model performance.
Te results in Table 6 show that the LSTM model with 256 units in each hidden layer performs well compared to 64 and 128 units in each layer. Tough a model with 256 units in each layer performs exceptionally well, it will increase the cost of the LSTM network. To balance all these parameters and save cost, a model with zero dropout and early stopping, the LSTM model with 128 units, seems to be the best choice. For further investigation, a model with 128 LSTM units in each hidden layer, as illustrated in Figure 11. Te LSTM model is built with the following specifcation:      Figure 12 shows LSTM Model loss plot in training and testing (validation) phase. Figure 13 shows the SOC prediction of LSTM Also, we have developed the BiLSTM model as shown in Figure 14. Gradient descent is optimized using "Adam" for the BiLSTM Model. Results are shown in Table 7.
Te BiLSTM model produces better results with 128 BILSTM cells in each layer without dropout with early stopping. Results are shown in Table 7.  Table 8.
As the number of LSTM units in each hidden layer increases, the model performance improves with fewer iterations required. Te model performs far better with 128 units. Table 8 analyses the BiLSTM model with an adaptive learning rate using diferent confgurations of hidden units in each layer: 32, 64, and 128. As can be observed, the BiLSTM model with 128 units in each hidden layer without dropout performs better than with dropout. Datasets splitting of training and testing is performed with an 80 : 20 ratio, shown in Table 9 and compared with the BiLSTM model with datasets splitting 60 : 40 ratio in Table 8.
Datasets splitting 60 : 40 ratio performs well compared to 80 : 20. Datasets splitting also afects the model's performance. Also, we can select an adaptive learning rate instead of a constant learning rate. BiLSTM is the best choice, but it will increase the network cost. Table 10 shows that the BiLSTM model performs slightly better than LSTM with early stopping. Based on the results shown in Table 10, model loss and SOC prediction are plotted in Figures 15 and 16, respectively.

Applied Computational Intelligence and Soft Computing
As we plan to implement the LSTM model on the FPGA board, we must consider the resources available on-chip. LSTM, with early stopping and an adaptive learning rate, is the best choice, requiring fewer resources than BiLSTM. Tis developed model is used for predicting time steps t and t + 1. As we increased the look-back time steps, the model performed poorly.
BiLSTM model is developed with 128 LSTM units in each layer with look-back 5, 10, and 15. As we increased the look back, the model's performance is degrading, i.e., MAE and RMSE are increasing, as seen in Table 11. Based on the previous results, we used the LSTM model with 128 units in each hidden layer to estimate SOH on NASA battery sets. Figure 17 shows the architecture of the LSTM model SOH prediction.

Applied Computational Intelligence and Soft Computing
Using the same LSTM model, we predicted the SOH of lithium-ion batteries on various datasets and displayed the results in Table 12. Table 12 shows the results for the LSTM model that are run for 50, 100, and 200 iterations, and the model is free from overftting. RMSE in training and testing is almost equal. Te LSTM model is also run for look back 5, 10, and 100. Results are shown in Table 13.
Te diference between RMSE values under train and test is very minimal. Te model SOH dataset released by NASA does not have a problem with overftting or underftting. Table 14 presents a comparison of the results obtained from the LSTM and BiLSTM models with the fndings from existing studies.

Monitoring Real-Time SOC and SOH Poses Hardware
Development Challenges Tat Need to Be Addressed. We are implementing our module on a System on Chip (SOC) based PYNQ Z2 board, a programmable device. Te PYNQ Z2 development platform combines an ARM Cortex-A9 processor with FPGA fabric. It allows for control of FPGA overlays through a Python interface, enabling seamless software and hardware components integration. Te drawback of PYNQ Z2 is that it does not support the latest keras and Tensorfow libraries. We cannot use predefned LSTM modules from these libraries. So, we have developed an LSTM model without using Tensorfow or keras. For our results on PYNQ Z2, we have tried many alternatives to get the highest possible accuracy. We collected approximately 650 data samples to predict a lithium battery's SOH. Due to signifcant discrepancies between the actual and predicted data, we experimented with various methods and approaches to reduce errors. Eventually, we chose to train the model using 1000 cycles, a learning rate of 0.5, and 128 LSTM units. Te following tables show the parameters we experimented with and the corresponding training and test accuracies. Table 15 shows that the model is run for 1000 iterations with varying learning rates. As we decreased the learning rate, the CPU performed slower. Te selection of the learning rate must be in the proper range. As we decreased the learning rate, model performance improved. We observed that at a lower learning rate, the model takes more CPU time and moves to overftting. We have tested our model for a learning rate of 0.01, and the results are shown in Table 16.
We have run a model for 100, 500, and 1000 cycles with a learning rate of 0.01, but it takes more CPU time than 0.5. So, to keep the balance between CPU performance and accuracy, we have run the model with a learning rate of 0.5 for 100, 500, and 1000 iterations implemented on the PYNQ Z2 board. We compared the speed and resource utilization between CPU and GPU. Table 17 shows the system specifcation on which the LSTM model is implemented. In this experiment, CPU/GPU and PYNQ Z2 are utilized.
Te LSTM model with a limited dataset runs for 100, 500, 1000, 1500, and 2500 iterations. Performance is measured based on speed and memory usage. Comparison results are shown in Table 18.
Results for the LSTM model with a constant learning rate of 0.5 and 128 LSTM units are in Table 18. CPU and GPU performance is almost identical for small data volumes and fewer iterations. It is not recommended to use GPU for small applications. GPU is faster for large applications, as seen when the model runs for 2500 iterations. PYNQ Z2 board is much slower because specifcations are low-end. Te LSTM model is implemented on PYNQ Z2 device. Te results are presented in Figure 18, which shows the relationship between the SOH and the number of data samples.
Te design and development cycle is signifcantly faster with Python than with C/C++ and hardware description languages (HDLs). However, we cannot use Python to enhance the model's performance on FPGA. To achieve this, we must develop our model using C/C++ or HDLs. Code quality is better with Python, but most inbuilt advanced libraries are not supported by PYNQ, which can estimate the resource utilization of hardware on FPGA. To improve the model's performance in terms of speed, power, and area, PYNQ with Python may not be the most suitable option.        Figure 18: SOH vs. number of data samples.

Conclusion
Prediction of lithium battery's SOC and SOH is crucial for the enhanced performance of the BMS of EVs. Te proposed AI-based SOC and SOH prediction is validated through experiments and testing using diverse EV drive cycles at room temperature, showcasing its adaptability and generalization capability. Our experimental results indicate that the performance of the LSTM model is infuenced by the selection of the gradient descent optimization algorithm with an adaptive learning rate. Tis BiLSTM can predict the SOC of the 18650PF lithium battery cell with MAE smaller than for training and 0.012% and 0.016% for testing. Similarly, using the Adam optimization algorithm, RMSE for training and testing is 0.326% and 0.454% over a 25 C dataset. BiLSTM with an adaptive learning rate can improve performance. As we increased the look back number, the model performance degraded. We must improve the performance LSTM/BiLSTM model with the long look back number. Te proposed AI-based approach for estimating state variables of lithium batteries ofers advantages such as low cost, low power consumption, high speed, reprogrammable logic, and ample on-chip memory storage, making it a superior choice over existing techniques. To improve the overall performance of the LSTM model, we need to implement the LSTM model using HDLs or C/C++. Te fndings of this study will aid in developing an efcient algorithm for estimating state variables of lithium batteries such as SOC and SOH, thereby contributing to the future of E-Mobility.

Data Availability
Te data supporting this study are from previously reported studies and datasets, which have been cited. We have used third-party open-source data for experimental purpose. Our experimental source code is available from the corresponding author on request.