Design of an Effective State of Charge Estimation Method for a Lithium-Ion Battery Pack Using Extended Kalman Filter and Artificial Neural Network

Currently, Lithium-ion batteries (LiB) are widely applied in energy storage devices in smart grids and electric vehicles. The state of charge (SOC) is an indication of the available battery capacity, and is one of the most important factors that should be monitored to optimize LiB’s performance and improve its lifetime. However, because the SOC relies on many nonlinear factors, it is difficult to estimate accurately. This paper presented the design of an effective SOC estimation method for a LiB pack Battery Management System (BMS) based on Kalman Filter (KF) and Artificial Neural Network (ANN). First, considering the configuration and specifications of the BMS and LiB pack, an ANN was constructed for the SOC estimation, and then the ANN was trained and tested using the Google TensorFlow open-source library. An SOC estimation model based on the extended KF (EKF) and a Thevenin battery model was developed. Then, we proposed a combined mode EKF-ANN that integrates the estimation of the EKF into the ANN. Both methods were evaluated through experiments conducted on a real LiB pack. As a result, the ANN and KF methods showed maximum errors of 2.6% and 2.8%, but the EKF-ANN method showed better performance with less than 1% error.


Introduction
Energy storage systems are emerging as the biggest concern for modern smart grids and electric vehicles (EV), and the lithium-ion battery (LiB) technology is an efficient solution for energy storage applications with the advantages of long cycle life, large capacity and no memory effect. Already commercialized and matured for consumer electronic applications, the LiB is being positioning itself as a leading technology platform for plug-in hybrid electric vehicles (PHEVs) and all EVs [1,2]. It is also widely used in large facilities to support energy storage [3], load-leveling and peak shaving in the power grid [4], frequency regulation [5], and to reduce network load and capacity payments [6] in the smart grids.
In order for the LiBs to work as expected, a battery management system (BMS) must be designed for tracking and controlling the current level of battery energy. The BMS is defined as an electronic equipment that manages a rechargeable battery (single cell or battery pack). The main functions of the BMS are to monitor, compute, communicate, time calculation, simple current and voltage measurements. Specifically, these techniques are highly adaptable to the dynamic behaviors of batteries due to their self-learning ability. However, there are still some issues that need to be studied. Applying KF requires accurate battery modeling, and important factors such as temperature and SOC that may affect the internal parameters of the battery model are not yet considered. Using an ANN requires a large amount of training data that can lead to a large dimension and high computation of the network when implemented in a BMS. Therefore, it is necessary to design a practical BMS to properly analyze and evaluate the operational characteristics of the SOC estimation methods.
In this paper, an effective SOC estimation method was designed and implemented in a smart BMS for a LiB pack based on the extended KF (EKF) and ANN. First, the structure and specifications of the smart BMS and LiB pack were summarized, and the design process of the ANN was described in detail. The ANN was then trained and tested for SOC estimation using real battery data sets. Next, we developed an SOC estimation algorithm based on the EKF and a Thevenin battery model. Finally, we proposed a combination model of EKF and ANN (EKF-ANN) to compensate for the shortcomings of the above two methods. To evaluate the effectiveness of the SOC estimation method, the proposed methods were experimentally verified and compared with each other. As a result, the proposed ANN and EKF methods showed an error of 2.6% and 2.8%, respectively, and the SOC estimation error when using the EKF-ANN was significantly improved to less than 1%. The results show that the proposed SOC estimation method satisfies the requirements of the BMS for LiB packs.

Review of SOC Estimation Methods
An accurate estimate of the SOC plays an important role in a credible BMS, but the SOC cannot be measured directly. The SOC is associated with direct measurements such as current, voltage, temperature, and it can be extracted based on intrinsic relations or control theory of the battery. Many techniques have been proposed to estimate the battery SOC. In this section, we discuss some popular SOC estimation methods and compare them with each other.

Open Circuit Voltage Method
This method calculates the SOC or the remaining capacity of the battery based on the measured open-circuit voltage (OCV). Each battery has a corresponding curve between the SOC and OCV, from which one can determine the other. However, in order to get a stable voltage, the battery must be rested for a long time under no load. Moreover, since the OCV-SOC curve is sensitive to various temperatures and discharge rates, the method is only effective in estimating the SOC at the early and end stages of the charging and discharging process after the battery has been disconnected from the load for a long time [17,18].

Coulomb Counting Method
Coulomb counting, which is also called Ampare-hour (Ah) counting, is the most common technique for estimating the SOC based on the integration on time of the charge and discharge current values. However, the initial SOC is difficult to determine at the starting state. Even though we can gain the SOC from the record of the BMS or OCV look-up table, but the accuracy is hard to ensure [19]. Additionally, the SOC calculation is based only on the measurement of current without considering the measurement noise. Over time, errors will be accumulated due to the integration factor, and this is the reason why this method is prone to errors.

Impedance-Based Method
There is a dependency between the SOC and the impedance of a battery, and thus the SOC can be considered a function of battery impedance change [20]. However, the impedance varies significantly with the aging status of a battery; thus, this technology is no longer a good indicator for the SOC. Furthermore, the sensitivity of the battery impedance on the temperature is very high; thereby a high accuracy of SOC estimation is impossible to maintain for batteries in EVs due to quick temperature change during the driving process.

Kalman Filter-Based Method
The KF is a method for determining the internal states of any dynamic process, in which the mean of the squared error is minimized. Its target is to obtain accurate information from inaccurate data. This method can be utilized to calculate the SOC in real-time by using the terminal current and voltage measurements [21][22][23]. It is suitable for the SOC estimation of EVs in which the battery current is unstable [24]. However, it has high demands for the battery modelling and computational capability [25,26].

Artificial Neural Network-Based Method
The ANN is an intelligent technology, which has a strong self-learning and high adaptability, and this technique is very useful for researching complex nonlinear system models. For the SOC estimation, the ANN is able to be applied in all battery systems without the information of cell internal structure, as long as the battery dataset for training the network is available [27,28]. Also, the ANN has the ability to estimate the SOC without the initial SOC.

Fuzzy Logic-Based Method
This method is based on simulating the fuzzy thinking of a human being using the fuzzy logic based on a large number of test curves, experience and reliable fuzzy logic theories, and finally to perform the SOC estimation [29]. It requires a complete understanding of the battery itself and relatively large computations. However, the battery parameters significantly vary with the battery lifetime, and so the SOC estimation may not be accurate enough. It is only suitable for static battery characteristics and practically inapplicable for LiBs in the EVs [30].
In this paper, we decided to develop an effective SOC estimation method based on the ANN and KF.

Configuration of the Smart BMS and LiB Pack
A BMS is a device including hardware and software which controls the operating conditions of the battery to extend battery life, ensure safety, and accurately predict the various states of the battery. To ensure this, the BMS has several functions to control and monitor the battery states at various battery cells, battery modules, and battery pack levels. The estimation of the SOC is a core function in a BMS, but it is still a challenge to accurately estimate in online-real time, as battery characteristics change with the degree of aging and strong nonlinear and complex electrochemical reactions of the battery. The SOC can be estimated by continuously measuring terminal voltage, current and temperature of the battery. For a battery system in EVs and smart grids, the current trend is the design of a smart BMS, which includes researches in the field of artificial intelligence (AI) utilized for the battery SOC estimation. In large battery pack applications, the predictability and adaptability of BMS are especially important. In this study, in order to verify the performance of the SOC estimation methods through experiments, we developed a smart BMS module based on the master and slave topology design for the LiB pack as shown in Figure 1.

Configuration of the Smart BMS and LiB Pack
A BMS is a device including hardware and software which controls the operating conditions of the battery to extend battery life, ensure safety, and accurately predict the various states of the battery. To ensure this, the BMS has several functions to control and monitor the battery states at various battery cells, battery modules, and battery pack levels. The estimation of the SOC is a core function in a BMS, but it is still a challenge to accurately estimate in online-real time, as battery characteristics change with the degree of aging and strong nonlinear and complex electrochemical reactions of the battery. The SOC can be estimated by continuously measuring terminal voltage, current and temperature of the battery. For a battery system in EVs and smart grids, the current trend is the design of a smart BMS, which includes researches in the field of artificial intelligence (AI) utilized for the battery SOC estimation. In large battery pack applications, the predictability and adaptability of BMS are especially important. In this study, in order to verify the performance of the SOC estimation methods through experiments, we developed a smart BMS module based on the master and slave topology design for the LiB pack as shown in Figure 1. The LiB pack consisted of 3 module units connected in series, and each module unit consisted of 36 cells with a 9S4P configuration, meaning 9 cells in series and 4 cells in parallel. There are 3 slave microcontroller unit (MCU) boards to manage the module units. The main MCU board, which is the master, coordinates two-way communication between the master and the slave and executes battery management actions. The detailed specifications of the smart BMS and LiB pack are described in Table 1. We will develop SOC estimation methods with an error target of 3% as shown in Table 2.  The LiB pack consisted of 3 module units connected in series, and each module unit consisted of 36 cells with a 9S4P configuration, meaning 9 cells in series and 4 cells in parallel. There are 3 slave microcontroller unit (MCU) boards to manage the module units. The main MCU board, which is the master, coordinates two-way communication between the master and the slave and executes battery management actions. The detailed specifications of the smart BMS and LiB pack are described in Table 1. We will develop SOC estimation methods with an error target of 3% as shown in Table 2. An ANN is a computational model constructed by a set of individual processing units, which are called the artificial neurons. These neurons are interconnected by weights. The ANN is a universal approximator that is able to model any nonlinear function with the desired precision [33]. The network is configured in layers, with the input layer receiving inputs and the output layer generating outputs. The middle layers, called the hidden layers, have no connection with the outside. The neurons are responsible for connecting each layer, thereby they are the central component of the ANN. The basic configuration of a neuron in the network is described in Figure 2. The vector of the input signals is denoted by X = [x 1 , x 2 , x 3 , . . . , x n ], n ∈ N, the neuron weights by W = [W 1 , W 2 , W 3 , . . . , W n ], net is the multiplication response of weights with the input signals, b 1 is an external parameter called as the bias, f is the activation function, and y m is the output signal of the neuron.

Design Process for the ANN
An ANN is a computational model constructed by a set of individual processing units, which are called the artificial neurons. These neurons are interconnected by weights. The ANN is a universal approximator that is able to model any nonlinear function with the desired precision [33]. The network is configured in layers, with the input layer receiving inputs and the output layer generating outputs. The middle layers, called the hidden layers, have no connection with the outside. The neurons are responsible for connecting each layer, thereby they are the central component of the ANN. The basic configuration of a neuron in the network is described in Figure 2 Table 3 shows the design process and design factors of an ANN for the SOC estimation. It starts from collecting and pre-processing the data, then designing the neural network in terms of network topology, configuration, activation function, loss function and metrics, loss optimizer, and learning rate. Finally, the training and validation of the network are implemented.  Table 3 shows the design process and design factors of an ANN for the SOC estimation. It starts from collecting and pre-processing the data, then designing the neural network in terms of network topology, configuration, activation function, loss function and metrics, loss optimizer, and learning rate. Finally, the training and validation of the network are implemented.  Table 3. Design process and design factors for the ANN. Step Contents Remarks

Design of the ANN for the SOC Estimation
The historical battery dataset was collected from the designed LiB pack by the company Battery Solution Co., Ltd. in South Korea. The dataset consists of the test time in seconds, the pack current in ampere, the pack terminal voltage in volts, the pack temperature, and the cumulative charge/discharge capacity of the battery pack in ampere-hour. The LiB pack was tested under 0-100% of the SOC condition for 20 cycles at room temperature. The data was collected with a sampling time of 1 s. The battery pack was charged and discharged with a constant current of 1.7 A (0.5 C rate). The battery charge and discharge processes correspond to the plus (+) and minus (−) signs of the current. The temperature was measured at the center of the battery pack by a thermal sensor with an accuracy of ±0.5 • C, and the temperature range was from 19 • C to 42 • C. From the battery pack dataset, the average values of voltage and current in one cell were calculated. The cell voltage range was from 2.6 V to 4.2 V. The actual SOC was also calculated offline by the integration on time of current to use for training and testing the ANN model. The dataset must be processed to obtain a satisfactory ANN, all trash data was deleted. The ANN was trained to estimate the SOC of one cell. The next step was to design the network topology for the ANN, and the Multi-Layer Perception (MLP) network was selected. The inputs of the network were the current, voltage, and temperature, and the output was the battery SOC. Figure 3 describes the relationships between the inputs and outputs of the designed ANN. The SOC has strong and nonlinear relationships with the voltage and temperature, which can be expressed as exponential functions. Thus, the nonlinear activation functions including hyperbolic tangent (tanh) and logistic (sigmoid) were considered for the ANN. The learning rate, α, is an amount by which the weights are updated during the training process. In the proposed network, the learning rate was set at 0.001. age, and temperature, and the output was the battery SOC. Figure 3 describes the relationships between the inputs and outputs of the designed ANN. The SOC has strong and nonlinear relationships with the voltage and temperature, which can be expressed as exponential functions. Thus, the nonlinear activation functions including hyperbolic tangent (tanh) and logistic (sigmoid) were considered for the ANN. The learning rate, α, is an amount by which the weights are updated during the training process. In the proposed network, the learning rate was set at 0.001.  After tuning the parameters and testing several configurations of the network, the most suitable specifications for the ANN are described in Table 4. The battery dataset contained approximately 250,000 samples, corresponding to the data measured at each sampling time. Each sample consisted of three input variables (battery voltage, current and temperature) and the actual SOC. Before training the network, the dataset was normalized and randomized to separate them into three sets: training, validation, and testing. The data in each set were different from each other and split evenly into three input variables. The amount of sample data for the training, validation, and testing were 80%, 10%, and 10% of the total samples, respectively. In this study, the ANN was designed, trained, and tested by using the Keras framework in the TensorFlow open-source library of Google. The ANN was trained during 500 epochs. As a result, the training performance achieved an MSE of approximately 0.  After tuning the parameters and testing several configurations of the network, the most suitable specifications for the ANN are described in Table 4. The battery dataset contained approximately 250,000 samples, corresponding to the data measured at each sampling time. Each sample consisted of three input variables (battery voltage, current and temperature) and the actual SOC. Before training the network, the dataset was normalized and randomized to separate them into three sets: training, validation, and testing. The data in each set were different from each other and split evenly into three input variables. The amount of sample data for the training, validation, and testing were 80%, 10%, and 10% of the total samples, respectively. In this study, the ANN was designed, trained, and tested by using the Keras framework in the TensorFlow open-source library of Google. The ANN was trained during 500 epochs. As a result, the training performance achieved an MSE of approximately 0.  After the training process, the model testing was performed to compare the estimated results and the actual results as described in Figure 5. The trained ANN was tested randomly with 5,000 samples, and the maximum and average errors of the estimated SOC were  After the training process, the model testing was performed to compare the estimated results and the actual results as described in Figure 5. The trained ANN was tested randomly with 5,000 samples, and the maximum and average errors of the estimated SOC were 2.3% and 0.34%, respectively. This result is satisfied with the target of SOC estimation. When the training process was completed, the weights and bias of the network were saved and exported as matrices to implement the SOC estimation function in the BMS for experiments.

SOC Estimation Method Using the EKF
In 1960, Kalman successfully introduced the state space into filter theory and first proposed the KF. Basically, the standard KF is only appropriate for linear dynamic systems to obtain the best and unbiased estimate of the state variables. However, the battery is a non-linear system; thus, it needs to be linearized and approximated to a linear system. At this point, the system states can be estimated by the KF. This method is called the extended Kalman Filter (EKF) [34]. To implement the EKF, a battery model is first developed to define internal state variables, state-space equations to build the mathematical model. Moreover, based on the external variables, such as terminal voltage, current, and temperature, the battery model is able to determine the internal state variables such as the internal resistance, electromotive force, capacitance and SOC.

Battery Model for the LiB
In this study, the Thevenin model was chosen as a LiB model. This model type has good performance and can accurately simulate the dynamic characteristics of the LiB [35].   When the training process was completed, the weights and bias of the network were saved and exported as matrices to implement the SOC estimation function in the BMS for experiments.

SOC Estimation Method Using the EKF
In 1960, Kalman successfully introduced the state space into filter theory and first proposed the KF. Basically, the standard KF is only appropriate for linear dynamic systems to obtain the best and unbiased estimate of the state variables. However, the battery is a non-linear system; thus, it needs to be linearized and approximated to a linear system. At this point, the system states can be estimated by the KF. This method is called the extended Kalman Filter (EKF) [34]. To implement the EKF, a battery model is first developed to define internal state variables, state-space equations to build the mathematical model. Moreover, based on the external variables, such as terminal voltage, current, and temperature, the battery model is able to determine the internal state variables such as the internal resistance, electromotive force, capacitance and SOC.

Battery Model for the LiB
In this study, the Thevenin model was chosen as a LiB model. This model type has good performance and can accurately simulate the dynamic characteristics of the LiB [35]. Figure 6 describes the equivalent circuit of the Thevenin battery model, which consists of an ideal source of voltage V OC (OCV), an internal resistance R 0 , a polarization resistance R p, and a capacitor C p . The terminal voltage and current of the battery are denoted by V L and I L , respectively. The voltage and current flowing through the branch R p C p are denoted by V p and I p , respectively. In this study, the Thevenin model was chosen as a LiB model. This model type has good performance and can accurately simulate the dynamic characteristics of the LiB [35]. Figure 6 describes the equivalent circuit of the Thevenin battery model, which consists of an ideal source of voltage VOC (OCV), an internal resistance R0, a polarization resistance Rp, and a capacitor Cp. The terminal voltage and current of the battery are denoted by VL and IL, respectively. The voltage and current flowing through the branch RpCp are denoted by Vp and Ip, respectively. Based on the Kirchhoff's laws, the capacitor voltage variation, its current relationship and the characteristics of the Thevenin model can be expressed as follows: Based on the Kirchhoff's laws, the capacitor voltage variation, its current relationship and the characteristics of the Thevenin model can be expressed as follows: From Equations (1) and (2), where τ = R p C p is the time constant and ∆t is the sampling time, a discrete-time system for the V L and V p is built as shown in the Equations (3) and (4).
The V OC , R 0 , R p and C p are nonlinear functions of the battery SOC [36], thus the Equations (3) and (4) can also be expressed as below.
The SOC describes the relationship between the remaining and the maximum capacity available in the battery and can be described as Equation (7): where C a is the nominal capacity of the battery, and the SOC(k − 1) is the priority SOC. By using the Equations (5)- (7), we can express the state equation for the nonlinear battery system as follows: with, Where x k and u k are the system state vectors and the measured system inputs at discrete-time k, and w k is the unmeasured process noise that can influence the system state. The output of the system is y k , and v k is the measurement noise. A k , C k are the first partial derivatives matrices with respect to x k , and B k , and D k are the Jacobian matrice with respect to u k .
With the matrice C k , dV oc dSOC − dR o dSOC = M s is a function of the SOC, and thus it can be built from the battery experiment data.

Parameter Identification
In this section, we identify the internal parameters of the built battery model including V OC , R 0 , R p , C p, and M s . This requires the experiment data including current and voltage across battery terminals. The V OC of the battery is the potential difference between the poles of the battery in the no load state. In order to obtain open-circuit voltage and the battery SOC curve, the battery was charged in the standard way and then completely discharged with a constant current. The battery was discharged from 100% to 0% in 5% steps, and the period between the two steps is in a no-load (open-circuit) state; this procedure is completed within 2 h to achieve stable V OC . From obtained data, the mathematical relationship between the SOC and V OC was built by using the nonlinear curve fitting, and the fitting results are shown in Equation (9) and Figure 7.

Parameter Identification
In this section, we identify the internal parameters of the built battery model including VOC, R0, Rp, Cp, and Ms. This requires the experiment data including current and voltage across battery terminals. The VOC of the battery is the potential difference between the poles of the battery in the no load state. In order to obtain open-circuit voltage and the battery SOC curve, the battery was charged in the standard way and then completely discharged with a constant current. The battery was discharged from 100% to 0% in 5% steps, and the period between the two steps is in a no-load (open-circuit) state; this procedure is completed within 2 h to achieve stable VOC. From obtained data, the mathematical relationship between the SOC and VOC was built by using the nonlinear curve fitting, and the fitting results are shown in Equation (9)   In the case of R0, it can also be determined by using the above battery discharge data. The value of R0 was calculated corresponding to the SOC of each period by dividing the value of the voltage drop by the discharge current, where voltage drop is the difference between the no load and loaded voltages. The variation of R0 according to the SOC is given in Figure 8, which fits into Equation (10).  In the case of R 0 , it can also be determined by using the above battery discharge data. The value of R 0 was calculated corresponding to the SOC of each period by dividing the value of the voltage drop by the discharge current, where voltage drop is the difference between the no load and loaded voltages. The variation of R 0 according to the SOC is given in Figure 8, which fits into Equation (10).

Parameter Identification
In this section, we identify the internal parameters of the built battery model including VOC, R0, Rp, Cp, and Ms. This requires the experiment data including current and voltage across battery terminals. The VOC of the battery is the potential difference between the poles of the battery in the no load state. In order to obtain open-circuit voltage and the battery SOC curve, the battery was charged in the standard way and then completely discharged with a constant current. The battery was discharged from 100% to 0% in 5% steps, and the period between the two steps is in a no-load (open-circuit) state; this procedure is completed within 2 h to achieve stable VOC. From obtained data, the mathematical relationship between the SOC and VOC was built by using the nonlinear curve fitting, and the fitting results are shown in Equation (9)   In the case of R0, it can also be determined by using the above battery discharge data. The value of R0 was calculated corresponding to the SOC of each period by dividing the value of the voltage drop by the discharge current, where voltage drop is the difference between the no load and loaded voltages. The variation of R0 according to the SOC is given in Figure 8, which fits into Equation (10).    (11) In order to identify the remaining battery parameters, R p and C p , the Matlab toolbox "Parameter estimate", which is a powerful interface for battery parameter identification, was used. The obtained functions of R p and C p according to the SOC are shown in Equations (12) and (13), respectively. Figure 9 describes the variation of R p and C p according to the SOC. In order to identify the remaining battery parameters, Rp and Cp, the Matlab toolbox "Parameter estimate", which is a powerful interface for battery parameter identification, was used. The obtained functions of Rp and Cp according to the SOC are shown in Equations (12) and (13), respectively. Figure 9 describes the variation of Rp and Cp according to the SOC.

SOC Estimation Model with the EKF
This algorithm combines the Thevenin battery model with the Ah integration method; the SOC and Vp represent the system state variables, the current represents input variables, and the battery terminal voltage represents the output variable. Figure 10 shows the diagram of the SOC estimation method using the EKF.

SOC Estimation Model with the EKF
This algorithm combines the Thevenin battery model with the Ah integration method; the SOC and V p represent the system state variables, the current represents input variables, and the battery terminal voltage represents the output variable. Figure 10 shows the diagram of the SOC estimation method using the EKF. In order to identify the remaining battery parameters, Rp and Cp, the Matlab toolbox "Parameter estimate", which is a powerful interface for battery parameter identification, was used. The obtained functions of Rp and Cp according to the SOC are shown in Equations (12) and (13), respectively. Figure 9 describes the variation of Rp and Cp according to the SOC.

SOC Estimation Model with the EKF
This algorithm combines the Thevenin battery model with the Ah integration method; the SOC and Vp represent the system state variables, the current represents input variables, and the battery terminal voltage represents the output variable. Figure 10 shows the diagram of the SOC estimation method using the EKF. Definition of the noise matrices: Q = E v k , v T k and R = E w k , w T k -Initializing the state variable, x + 0 = x 0 and the estimation error P + 0 = P 0 -Prediction of the state variables, x k = [SOC(k), V p (k)] at time k by the Equations (6) and (7) from the measured current I L (k) -Linearization by calculating Jacobians: Prediction of the covariance matrix P k (estimation error): Computation of the Kalman gain, Kg: Update the new SOC based on the measured voltage, V L (k) and the output variable -Update the estimation error, P k to P + k for the next time step (k + 1):

Combination of the EKF and ANN for the SOC Estimation
In the case of using the EKF, the battery model was built for the SOC estimation based on the voltage and current characteristics. However, the battery is a dynamic system, and with a long operation time, the internal parameters of the battery model can be changed by other factors such as temperature, load changes, and SOC. These can cause errors in the SOC estimation model, and the battery modeling is very complex when considering them. With the method using the ANN, there were only three inputs including the voltage, current, and temperature of the present sample, and there was no information in the previous sample. This can cause a large dimension and high computation on the network. As the above results, the designed network had 4 hidden layers with 64 neurons in each layer, which means that the weight and bias matrices can take over a large amount of memory in the MCU and make it difficult to handle computation.
To solve the above-mentioned problems, we suggested a SOC estimation method combining the EKF with ANN as shown in Figure 11. The EKF model was applied to determine the battery SOC in the previous sample, SOC(k − 1), based on the measured values of the previous voltage, V L (k − 1) and the current, I L (k − 1). This SOC value was used as one input of an ANN to estimate the SOC in the present sample, SOC(k). The ANN was designed with four inputs including the measured voltage, V L (k), current, I L (k), and temperature, T(k) at the present sample. The EKF is incorporated with the ANN to adapt to the dynamic environments, and the SOC(k − 1) generated by the EKF takes into account battery hysteresis and measurement noise. Thereby, the accuracy and reliability of the SOC estimation can be improved.  (6) and (7) -Update the estimation error, k P to k P + for the next time step (k + 1):

Combination of the EKF and ANN for the SOC Estimation
In the case of using the EKF, the battery model was built for the SOC estimation based on the voltage and current characteristics. However, the battery is a dynamic system, and with a long operation time, the internal parameters of the battery model can be changed by other factors such as temperature, load changes, and SOC. These can cause errors in the SOC estimation model, and the battery modeling is very complex when considering them. With the method using the ANN, there were only three inputs including the voltage, current, and temperature of the present sample, and there was no information in the previous sample. This can cause a large dimension and high computation on the network. As the above results, the designed network had 4 hidden layers with 64 neurons in each layer, which means that the weight and bias matrices can take over a large amount of memory in the MCU and make it difficult to handle computation.
To solve the above-mentioned problems, we suggested a SOC estimation method combining the EKF with ANN as shown in Figure 11. The EKF model was applied to determine the battery SOC in the previous sample, SOC(k − 1), based on the measured values of the previous voltage, VL(k − 1) and the current, IL(k − 1). This SOC value was used as one input of an ANN to estimate the SOC in the present sample, SOC(k). The ANN was designed with four inputs including the measured voltage, VL(k), current, IL(k), and temperature, T(k) at the present sample. The EKF is incorporated with the ANN to adapt to the dynamic environments, and the SOC(k − 1) generated by the EKF takes into account battery hysteresis and measurement noise. Thereby, the accuracy and reliability of the SOC estimation can be improved. Figure 11. Configuration of the SOC estimation method combining the EKF with ANN. Figure 11. Configuration of the SOC estimation method combining the EKF with ANN.
In this method, the designed EKF model in the previous section was kept to use, and the ANN was designed and trained again with the same battery dataset. The final specifications of the ANN are shown in Table 5. This network only needs two hidden layers, and each hidden layer had 32 neurons. The required memory and computation time in the MCU are significantly reduced. The detailed configuration of the designed ANN including the input layer, hidden layers, output layer, number of neurons in each layer, weight matrices, bias matrices, and activation functions are described in Figure 12. In this method, the designed EKF model in the previous section was kept to use, and the ANN was designed and trained again with the same battery dataset. The final specifications of the ANN are shown in Table 5. This network only needs two hidden layers, and each hidden layer had 32 neurons. The required memory and computation time in the MCU are significantly reduced. The detailed configuration of the designed ANN including the input layer, hidden layers, output layer, number of neurons in each layer, weight matrices, bias matrices, and activation functions are described in Figure 12.  The network training was also performed in 500 epochs, and the performances of the redesigned ANN are shown in Figure 13. The MSE and MAE in the final epoch are approximately 0.0064 and 0.057, respectively, which are much lower than that of the ANN using three inputs. The trained model was also tested randomly with 5,000 samples to compare the actual and estimated SOC. The maximum and average errors of the estimated SOC were 0.27% and 0.069%, respectively, as shown in Figure 14. The network training was also performed in 500 epochs, and the performances of the redesigned ANN are shown in Figure 13. The MSE and MAE in the final epoch are approximately 0.0064 and 0.057, respectively, which are much lower than that of the ANN using three inputs. The trained model was also tested randomly with 5,000 samples to compare the actual and estimated SOC. The maximum and average errors of the estimated SOC were 0.27% and 0.069%, respectively, as shown in Figure 14.
Energies 2021, 14, x FOR PEER REVIEW 13 of 20 In this method, the designed EKF model in the previous section was kept to use, and the ANN was designed and trained again with the same battery dataset. The final specifications of the ANN are shown in Table 5. This network only needs two hidden layers, and each hidden layer had 32 neurons. The required memory and computation time in the MCU are significantly reduced. The detailed configuration of the designed ANN including the input layer, hidden layers, output layer, number of neurons in each layer, weight matrices, bias matrices, and activation functions are described in Figure 12.  The network training was also performed in 500 epochs, and the performances of the redesigned ANN are shown in Figure 13. The MSE and MAE in the final epoch are approximately 0.0064 and 0.057, respectively, which are much lower than that of the ANN using three inputs. The trained model was also tested randomly with 5,000 samples to compare the actual and estimated SOC. The maximum and average errors of the estimated SOC were 0.27% and 0.069%, respectively, as shown in Figure 14.

Implementations of the SOC Estimation Methods in the Smart BMS
To validate the proposed SOC estimation methods, we applied them to the SOC estimation function of the BMS in an experimental test with a real LiB pack. First, we implemented a real-time SOC estimation based on the ANN. Then, the SOC estimations based on the EKF and the EKF-ANN were implemented in offline experiments by using the MATLAB program. These models were built to calculate the SOC from the experiment data acquired using the ANN. Finally, the obtained results of three methods were compared with the reference SOC, which was calculated from the measured battery capacity.
Using the ANN, the SOC was estimated based on the average voltage and current of the battery cells and the temperature in the battery pack. The SOC estimation function was built by C programming language on the master MCU STM32F205, which has a flash memory of up to 1 Mbyte. In the designed ANN, there were three 64 × 64 weight matrices and four 1x64 bias matrices in the hidden layers, and it took about 24 ms for calculation speed. The SOC was calculated in each sampling time of 1 s with the full charge and discharge of the battery pack. We found no problems with the memory and operation of the master MCU during the experiment. A monitoring system was also facilitated for the BMS as shown in Figure 15. The main interface of the monitoring system includes the contents listed below:

Implementations of the SOC Estimation Methods in the Smart BMS
To validate the proposed SOC estimation methods, we applied them to the SOC estimation function of the BMS in an experimental test with a real LiB pack. First, we implemented a real-time SOC estimation based on the ANN. Then, the SOC estimations based on the EKF and the EKF-ANN were implemented in offline experiments by using the MATLAB program. These models were built to calculate the SOC from the experiment data acquired using the ANN. Finally, the obtained results of three methods were compared with the reference SOC, which was calculated from the measured battery capacity.
Using the ANN, the SOC was estimated based on the average voltage and current of the battery cells and the temperature in the battery pack. The SOC estimation function was built by C programming language on the master MCU STM32F205, which has a flash memory of up to 1 Mbyte. In the designed ANN, there were three 64 × 64 weight matrices and four 1x64 bias matrices in the hidden layers, and it took about 24 ms for calculation speed. The SOC was calculated in each sampling time of 1 s with the full charge and discharge of the battery pack. We found no problems with the memory and operation of the master MCU during the experiment. A monitoring system was also facilitated for the BMS as shown in Figure 15. The main interface of the monitoring system includes the contents listed below:

Experiment Results of the SOC Estimation Methods
Since the proposed SOC estimation methods were built based on the battery data, these methods only valid under the experimental conditions similar to the range of battery data collected as follows: -After measuring the voltage and current of the entire battery pack, calculate the average value of the voltage and current of one cell, -Battery pack is discharged and charged with a constant current of 1.7 A in each cell, -Cell voltage range is 2.6-4.2 V, -Temperature range of the battery pack is 19~42 °C.
In the experiment, we first performed the SOC estimation using the ANN in realtime. The average voltage and current of the cells and the measured temperature during the discharge and charge processes of the battery pack are described in Figure 16. The battery pack was fully discharged and charged with the same currents of 1.7 A in each cell, which were similar to the trained battery dataset. The temperature was measured at the center of the battery pack, and the temperature range was from 19 °C to 38 °C.  Figure 17 shows the experimental results of the online SOC estimation using the ANN, and the estimated SOC was compared with the reference SOC. As a result, the maximum SOC errors in the discharge and charge processes were 2.3% and 2.6%, respectively. This result has satisfied the initial design target of the SOC estimation error for the smart BMS.

Experiment Results of the SOC Estimation Methods
Since the proposed SOC estimation methods were built based on the battery data, these methods only valid under the experimental conditions similar to the range of battery data collected as follows: -After measuring the voltage and current of the entire battery pack, calculate the average value of the voltage and current of one cell, -Battery pack is discharged and charged with a constant current of 1.7 A in each cell, -Cell voltage range is 2.6-4.2 V, -Temperature range of the battery pack is 19~42 • C.
In the experiment, we first performed the SOC estimation using the ANN in real-time. The average voltage and current of the cells and the measured temperature during the discharge and charge processes of the battery pack are described in Figure 16. The battery pack was fully discharged and charged with the same currents of 1.7 A in each cell, which were similar to the trained battery dataset. The temperature was measured at the center of the battery pack, and the temperature range was from 19 • C to 38 • C.

Experiment Results of the SOC Estimation Methods
Since the proposed SOC estimation methods were built based on the battery data, these methods only valid under the experimental conditions similar to the range of battery data collected as follows: -After measuring the voltage and current of the entire battery pack, calculate the average value of the voltage and current of one cell, -Battery pack is discharged and charged with a constant current of 1.7 A in each cell, -Cell voltage range is 2.6-4.2 V, -Temperature range of the battery pack is 19~42 °C.
In the experiment, we first performed the SOC estimation using the ANN in realtime. The average voltage and current of the cells and the measured temperature during the discharge and charge processes of the battery pack are described in Figure 16. The battery pack was fully discharged and charged with the same currents of 1.7 A in each cell, which were similar to the trained battery dataset. The temperature was measured at the center of the battery pack, and the temperature range was from 19 °C to 38 °C.   Figure 17 shows the experimental results of the online SOC estimation using the ANN, and the estimated SOC was compared with the reference SOC. As a result, the maximum SOC errors in the discharge and charge processes were 2.3% and 2.6%, respectively. This result has satisfied the initial design target of the SOC estimation error for the smart BMS.  Figure 17 shows the experimental results of the online SOC estimation using the ANN, and the estimated SOC was compared with the reference SOC. As a result, the maximum SOC errors in the discharge and charge processes were 2.3% and 2.6%, respectively. This result has satisfied the initial design target of the SOC estimation error for the smart BMS. Next, the above experiment data including the battery voltage, current, and temperature were used to calculate the SOC offline using the other two methods in the Matlab simulation model. Figure 18 shows the comparison of the SOC estimation results using three methods with the reference SOC during the discharge and charge processes of the battery. The detailed absolute SOC errors of each method are given in Figure 19 and Table 6. Using the EKF, the maximum SOC errors in the discharge and charge processes were 2.8% and 2.4%, respectively, which were similar to that of using the ANN. We found the significant improvement for the SOC estimation by combining the EKF with ANN, which had the SOC error of less than 1%. Comparisons were made with other SOC estimation methods [37][38][39][40][41][42][43][44][45][46][47][48][49] and the maximum estimation errors are summarized in Table 7. Through this, it was confirmed that the proposed method guarantees the accuracy of SOC estimation similar to or better than other methods.  Next, the above experiment data including the battery voltage, current, and temperature were used to calculate the SOC offline using the other two methods in the Matlab simulation model. Figure 18 shows the comparison of the SOC estimation results using three methods with the reference SOC during the discharge and charge processes of the battery. The detailed absolute SOC errors of each method are given in Figure 19 and Table 6. Using the EKF, the maximum SOC errors in the discharge and charge processes were 2.8% and 2.4%, respectively, which were similar to that of using the ANN. We found the significant improvement for the SOC estimation by combining the EKF with ANN, which had the SOC error of less than 1%. Comparisons were made with other SOC estimation methods [37][38][39][40][41][42][43][44][45][46][47][48][49] and the maximum estimation errors are summarized in Table 7. Through this, it was confirmed that the proposed method guarantees the accuracy of SOC estimation similar to or better than other methods. Next, the above experiment data including the battery voltage, current, and temperature were used to calculate the SOC offline using the other two methods in the Matlab simulation model. Figure 18 shows the comparison of the SOC estimation results using three methods with the reference SOC during the discharge and charge processes of the battery. The detailed absolute SOC errors of each method are given in Figure 19 and Table 6. Using the EKF, the maximum SOC errors in the discharge and charge processes were 2.8% and 2.4%, respectively, which were similar to that of using the ANN. We found the significant improvement for the SOC estimation by combining the EKF with ANN, which had the SOC error of less than 1%. Comparisons were made with other SOC estimation methods [37][38][39][40][41][42][43][44][45][46][47][48][49] and the maximum estimation errors are summarized in Table 7. Through this, it was confirmed that the proposed method guarantees the accuracy of SOC estimation similar to or better than other methods.

Discussions
From the above experimental results, it can be seen that the SOC estimation methods proposed in this study were accurate and satisfied the requirements of the designed smart BMS. However, there are still issues to be investigated. The performances of the method were evaluated when the battery pack was discharged and charged with a constant current. In a real battery system such as an EV, the load current continuously changes according to the vehicle speed. Therefore, to improve the quality of the battery modeling in the EKF method, the dynamic characteristics of the battery must be considered. Applying an ANN to EV requires more battery data trained with a dynamic current profile. In addition, other important issues of SOC estimation and BMS design, such as cell balancing and battery capacity fade, have not yet been considered. During long-term operation, more experiments need to be performed to collect battery data for each cell and analyze the cathode chemistry of the cells entirely. The next study will consider these issues and improve the accuracy of the SOC estimation method for the LiBs in various real systems.

Conclusions
The authors proposed effective SOC estimation methods based on the EKF and ANN for a LiB pack in a smart BMS. Detailed configurations and specifications of the smart BMS and LiB pack were presented. First, an ANN was used to build an SOC estimation model,

Discussions
From the above experimental results, it can be seen that the SOC estimation methods proposed in this study were accurate and satisfied the requirements of the designed smart BMS. However, there are still issues to be investigated. The performances of the method were evaluated when the battery pack was discharged and charged with a constant current. In a real battery system such as an EV, the load current continuously changes according to the vehicle speed. Therefore, to improve the quality of the battery modeling in the EKF method, the dynamic characteristics of the battery must be considered. Applying an ANN to EV requires more battery data trained with a dynamic current profile. In addition, other important issues of SOC estimation and BMS design, such as cell balancing and battery capacity fade, have not yet been considered. During long-term operation, more experiments need to be performed to collect battery data for each cell and analyze the cathode chemistry of the cells entirely. The next study will consider these issues and improve the accuracy of the SOC estimation method for the LiBs in various real systems.

Conclusions
The authors proposed effective SOC estimation methods based on the EKF and ANN for a LiB pack in a smart BMS. Detailed configurations and specifications of the smart BMS and LiB pack were presented. First, an ANN was used to build an SOC estimation model, which was trained and tested using a real battery dataset including voltage, current, temperature, and measured SOC over 20 cycles. Inputs of the designed network consisted of voltage, current, and temperature, and output was the estimated SOC of the battery. The design process for the ANN was described in detail. The Google TensorFlow open-source library was used to design and optimize the network configurations. Next, we developed a SOC estimation algorithm using the EKF, in which the LiB model was studied and a Thevenin model was developed to combine it with the Ah integration method. The current and terminal voltage of the battery represent the input variables, and the SOC represents the output variable. Finally, the EKF-ANN was proposed to improve the shortcomings of the above two methods, where the ANN was redesigned by adding one more input of the previous SOC determined using the EKF method. Both methods were confirmed through experiments performed on real battery data collected from the battery pack consisting of the LIB 18,650 35E cells at 4.2 V and 3.4 Ah. With the ANN and EKF, the SOC estimation performances were almost similar with a maximum SOC errors of 2.4% to 2.8%. Meanwhile, the use of the EKF-ANN significantly improved the accuracy of SOC estimation with less than 1% error. We are confident that the results of this study can be effectively applied to a smart BMS for industrial energy storage systems.