Abstract
In this article, a method for estimating the state of charge of lithium battery based on back-propagation neural network is proposed and implemented for uninterruptible power system. First, back-propagation neural network model is established with voltage, temperature, and charge–discharge current as input parameters, and state of charge of lithium battery as output parameter. Then, the back-propagation neural network is trained by Levenberg–Marquardt algorithm and gradient descent method; and the state of charge of batteries in uninterruptible power system is estimated by the trained back-propagation neural network. Finally, we build a state-of-charge estimation test platform and connect it to host computer by Ethernet. The performance of state-of-charge estimation based on back-propagation neural network is tested by connecting to uninterruptible power system and compared with the ampere-hour counting method and the actual test data. The results show that the state-of-charge estimation based on back-propagation neural network can achieve high accuracy in estimating state of charge of uninterruptible power system and can reduce the error accumulation caused in long-term operation.
Introduction
With the development of Industrial Internet of Things (IIoT), numerous industrial devices with the ability of wireless transmission are deployed to monitor the person, environment, and equipment, which facilitates centralized and unified management of multiple equipments in industry.1–3 Uninterruptible power system (UPS) serves as backup power supply that provides constant voltage and constant frequency for load through energy storage device and transformer. It has been widely used in industrial production, schools, hospitals, banks, and other places to provide uninterrupted power supply for electrical equipment to improve the stability of equipment and avoid data loss.4–6 However, it is difficult for a UPS to power all electrical equipment in factories, schools, and other places. Thus, more than one UPS is usually required to provide power for monitoring systems, electronic access control, and other electronic devices. Each UPS is connected to the Ethernet as a network node and centralized managed by the host computer.
UPS provides uninterrupted power supply for electrical equipment by battery packs. In the past, Ni-MH batteries or lead–acid batteries were often used in battery packs. However, with the development of battery technology, lithium batteries have gradually replaced the traditional Ni-MH batteries and lead–acid batteries in UPS due to their advantages of stable discharge voltage, small size, light weight, long cycling life, and so on. 7 Although lithium batteries have many advantages, the electrochemical properties of lithium batteries are complex. Over charging and over discharging will reduce the performance and life of lithium batteries, and repeated overuse may even lead to explosion hazards. 8 Therefore, the battery management system (BMS) is required to estimate the state of charge (SOC) to protect lithium batteries.
SOC is used to represent the remaining capacity of the battery, which is usually used as an important reference data for management and protection of lithium batteries. 9 By estimating SOC, the remaining capacity of battery is intuitively understood. Thereby, charging or discharging switch can be disconnected when the battery power is too high or too low, to avoid excessive charging or discharging of lithium batteries, prolong the service life of lithium batteries, and reduce the probability of dangerous situations. 10
In this article, we study the battery SOC estimation method based on BP neural network and implement it in UPS to improve the accuracy of UPS battery SOC estimation. Then, the BP neural network is trained by battery sample data and SOC estimation is simulated in MATLAB. Finally, we build an SOC estimation test platform and connect it to host computer via Ethernet. We implement the proposed battery SOC estimation method and verify the feasibility of BP neural network algorithm in estimating SOC in UPS.
The main contributions of this article are summarized as follows:
BP neural network for estimating SOC of batteries is established, and the neural network is trained using experimental data of batteries. The accuracy of BP neural network in estimating battery SOC is verified by comparing the data estimated by BP neural network algorithm and ampere-hour (AH) counting method with the actual test data.
SOC estimation test platform is built and connected to host computer via Ethernet. The battery SOC estimation algorithm based on BP neural network was implemented in test platform for the first time.
The rest of this article is organized as follows: section “Related work” describes the related research work of battery SOC estimation. Section “Model of BP neural network” describes the model of BP neural network. In section “Training of BP neural network,” the training and simulation process of BP neural network is described in detail. BP neural network estimation of UPS battery SOC implementation process and actual test results are described in section “Experiments and implementation.” Finally, we conclude this article in section “Conclusion.” The abbreviations used in this article are shown in Table 1.
Abbreviations.
Related work
With the development of new energy technology, lithium battery technology has been paid more and more attention, and there are many studies on battery SOC estimation because of the complex chemical changes that occur during battery charging and discharging. There are many factors affecting the estimation of SOC, including voltage, current, temperature, self-discharge rate, internal resistance, cycle times, and so on. The commonly used SOC estimation methods include open-circuit voltage (OCV) method, AH counting method, Kalman filter method, neural network method, and so on. 11 The comparison of SOC estimation methods is shown in Table 2. The OCV method estimates battery SOC based on the linear relationship between the OCV and SOC. Then, the OCV of the battery is measured and the SOC of the battery at the moment is estimated according to the SOC-OCV relationship.12–14 The OCV method is simple and easy to implement. However, the battery voltage is affected by temperature, and the SOC of the battery cannot be accurately estimated when the temperature is abnormal. The AH counting method is to calculate the charge accumulation of the battery during charging and discharging in a certain period of time, and to estimate the SOC of the battery at the moment according to the SOC of the initial state of the battery.15,16 The advantage of this method is that it is easy to implement in microcontroller unit (MCU) because of its less computation. But the estimation accuracy of SOC is affected by the initial value of SOC and the accuracy of current detection and the cumulative errors may be caused by this method for a long time. Kalman filtering method is based on the equivalent model of battery SOC, which according to the previous state SOC and the current state SOC is obtained by iteration and recursion.17–19 The advantage of this method is that the estimation accuracy is high but the disadvantage of this method is that it depends on the established mathematical model and the amount of calculation is large. Neural network method regards battery as a non-linear system and trains neural network by sample data, then estimates battery SOC based on battery voltage, current, temperature, and other information.20,21 This method has high accuracy and can simulate the non-linear relationship. However, a large number of sample data are needed to train the neural network, which has high computational complexity and is difficult to implement in MCU.
Comparison of SOC estimation methods.
SOC: state of charge; AH: ampere-hour; MCU: microcontroller unit.
Dong and Wang 22 and Guo et al. 23 studied the method of SOC estimation based on improved BP neural network. The author only makes simulation analysis, but does not apply it in practical system. The SOC estimation method for lithium battery based on an inclusive equivalent circuit model is proposed in Chen et al. 21 A nonlinear observer based on radial basis function (RBF) neural network is designed to estimate battery SOC. The performance of RBF neural network is verified by experiment and simulation, but the proposed method has not been applied to practical systems. The SOC estimation based on wavelet neural network by Levenberg–Marquardt algorithm is optimized in Xia et al. 24 The author discharges lithium batteries in battery-testing equipment and obtains battery data. The battery SOC estimation and experimental result analysis were completed in MATLAB. However, this article adopts multi-layer wavelet neural network, which has high computational complexity and is hard to realize in UPS. Baranti et al. 25 obtained SOC estimation on the device of field programmable gate array (FPGA) by mix algorithm, and combined the hardware block of SOC estimation with the processor of soft core to form a system on programmable chip to realize SOC estimation of multiple cells of a battery. However, MCU is often used as control chip in UPS, and mix algorithm is not applicable in MCU and is difficult to implement in UPS.
Based on the analysis above, although the battery SOC estimation method has been investigated by many researchers, many algorithms are too complex to be implemented in UPS. In addition, no researchers have realized centralized management of multiple UPS.
Model of BP neural network
BP neural network is a multi-layer forward feedback network of error back propagation, including input layer, hidden layer, and output layer. 26 The learning process of BP neural network is as follows: first, the input signal propagates forward and the battery sample data are transferred from the input layer to the hidden layer, and then, the output from the output layer is obtained after calculation. Second, the output error will be calculated when the difference between the SOC output value and the SOC expected value is not satisfied, and then the error will be propagated back. Third, the weights and thresholds between neurons will be modified according to the optimized algorithm until the SOC error satisfies the mean square error (MSE), and then the network training is completed. BP neural network can learn irregular samples and approximate arbitrary non-linear functions. Therefore, the SOC of lithium battery can be estimated by BP neural network.
Considering the estimation efficiency and ease of implementation, we use three-layer BP neural network to estimate the SOC of lithium battery. According to Kolrnogorov theorem, a three-layer BP neural network can approximate any non-linear function. 27 In addition, the input and output parameters of the neural network are less, in which voltage, temperature, and charge–discharge current of the lithium battery are used as input signals and SOC of lithium battery as output signal. Therefore, the accurate estimation of battery SOC can be achieved using three-layer BP neural network, that is, only one hidden layer. Further, a three-layer BP neural network can achieve a low computational complexity.
Then, the optimal number of neurons in the hidden layer will be determined according to the golden section method. 28 The optimal number of neurons in the hidden layer L can be derived as
where M denotes the number of neurons in the input layer and N denotes the number of neurons in the output layer. In this article, BP neural network has three inputs and one output, so the optimal range of hidden layer neurons is 2–14. After many training experiments, the number of neurons in the hidden layer L is set to 8, which can improve the estimation accuracy on the premise of guaranteeing the efficiency of SOC estimation.
After the number of input layer, hidden layer, and output layer is determined, the BP neural network can be modeled. The estimation model of SOC based on BP neural network is shown in Figure 1. The input parameters of BP neural network are expressed as

SOC estimation model based on BP neural network.
The tansign function is completely differentiable, and the symmetric point is at the origin, which is the preferred feature of neural network. It has gradually replaced the sigmoid function as the standard activation function. Therefore, tansign function is chosen as the activation function of BP neural network. Therefore, we choose tansign function as activation function of BP neural network.
Then, the SOC of battery can be estimated by introducing voltage, temperature, and current into the activation function. The steps of estimating SOC by BP neural network algorithm are as follows:
Step 1. We normalize the voltage, temperature, and current of sample data to [−1, 1], set SOC error requirement ε and set the maximum training times T. Then, the weights wml, ul, threshold
Step 2. The normalized voltage, temperature, and current are inputs into the neural network, and the output data of the lth neuron in the hidden layer can be obtained as
Step 3. By substituting the output data of the hidden layer into the activation function, we can derive the output data of the output layer
Step 4. The error between the actual output and the expected output of the ith sample data can be calculated as
Step 5. BP neural networks propagate errors backwards, and the weights and thresholds are adjusted in the direction of negative gradient by gradient descent method.
The updating increment of the weight ul from the lth neuron in the hidden layer to the output layer is
The update increment of output layer neuron threshold can be expressed as
The updating increment of the weight wml between the mth neuron in the input layer and the lth neuron in the hidden layer is as follows
The updating increment of the threshold of the lth neuron in the hidden layer can be written as
After calculating the update increment, we get the weights and thresholds of the next training as
Step 6. Whether all the sample data are trained or not, if the training is completed, continue Step 7; otherwise, i = i + 1, jump Step 2 and continue to train the next sample data.
Step 7. Calculating total error E
Step 8. If E < ε or t > T, finish training and output training results; otherwise, let t = t + 1, i = 1, jump to Step 2 to continue training.
The above is the detailed steps of BP neural network learning, which can realize the estimation of SOC of lithium battery. After the establishment of BP neural network, we will train the neural network using sample data.
Training of BP neural network
BP neural network is a supervised training process, which compares the training output data with the expected value, and then feeds back the error to the network, so as to cycle training. Therefore, the accuracy of sample data is very important to the training of BP neural network.
In this article, we use data provided by lithium battery manufacturers, including voltage, temperature, current, and SOC. To increase the diversity of sample data, 60-AH lithium batteries are put in an incubator, and are charged and discharged at a current rate of 0.5, 1, 3 C (30, 60, 180 A) with temperatures of −20 C, 25 C, 55 C, respectively. After many charging and discharging experiments, the experimental data have high accuracy and can truly reflect the performance of lithium batteries. The data are divided into two parts: experimental data (sample data) and test data. The experimental data are used to train the BP neural network and the test data are used to test the performance of the trained BP neural network.
Battery experimental data including battery voltage, temperature, current, and SOC are input into BP neural network for training. After many training, BP neural network will output estimated SOC of battery and record it as training data. When the fitting degree between training data and experimental data is higher, it indicates that the SOC estimated by BP neural network is more accurate.
We train BP neural network and use neural network training tool in MATLAB. The BP neural network is trained by Levenberg–Marquardt algorithm and gradient descent method. Levenberg–Marquardt is an optimization algorithm of approximate Newton method, which is widely used in BP neural network and wavelet neural network. 24 It has been proved that using Levenberg–Marquardt algorithm to train BP neural network has better convergence speed and accuracy in Hagan and Menhaj. 29 Therefore, it is feasible to estimate battery SOC using BP neural network based on Levenberg–Marquardt algorithm in this article.
The neural network will be trained using the experimental data of discharges at different rates with 25°C. To get better training effect, MSE is set to 0.0001, and the maximum training times is set to 1000. The training results are shown in Figure 2. In the early stage of discharge, the battery voltage decreases slowly with the increase of discharge capacity, and the training data fit well with the experimental data. In the later stage of discharge, the battery voltage drops rapidly with the increase of discharge capacity, which may cause the training data to fall into the local minimum and lead to errors. But the errors are small enough to meet the training requirements. In addition, the figure shows that with the decrease of discharge current, the available power of the battery increases gradually. The reason is that as the discharge current decreases, the polarization of the battery also decreases, and the active substances of the battery can be fully utilized, so more electricity can be released. The simulation results show that the training data of the neural network fit well with the experimental data with different discharge rates and meet the training requirements.

Measured and training values of discharge capacity under different ratios.
Then, we train the neural network using the experimental data of discharge at 0.5 C rate with −20 C and 55 C. Similarly, we set MSE to 0.0001 and the maximum training times to 1000. The BP neural network is trained by Levenberg–Marquardt algorithm and gradient descent method, the training results are shown in Figure 3. In the early stage of discharge, the battery voltage decreases gradually with the increase of discharge capacity, and data curve is more stable. In the later stage of discharge, the battery voltage decrease rapidly with the increase of discharge capacity. With the sample data being gradually increased, the training data of the neural network can better fit the experimental data. It can be seen that with the decrease of temperature, the dischargeable capacity of the battery decreases gradually, and only 45-AH can be discharged from the battery at −20°C. The reason is that the activity of chemical substances in the battery decreases gradually with the decrease of temperature resulting in the reduction of dischargeable capacity of the battery. In addition, the lower the temperature, the lower the battery voltage of the same capacity. This is due to the higher concentration of electrolyte in the low temperature environment, which slows down the ion conduction velocity. As a result, the internal resistance increases and the external battery voltage decreases gradually.

Measured and training values of discharge capacity under different temperatures.
In this article, we use 1214 experimental data as samples to train BP neural networks. From the training results, it can be seen that the discharge capacity of the battery can be predicted by BP neural network when the battery voltage, temperature, and charge–discharge current are known. And the error between training data and experimental data meets the predetermined requirements, which shows that BP neural network can realize the SOC estimation of lithium battery.
Experiments and implementation
Estimation experiment of BP neural network
We use the trained BP neural network to estimate the SOC of battery during discharge, and compare it with the test data to verify the accuracy of the estimation of battery SOC by BP neural network.
The manufacturers provide data on lithium battery discharged at a current rate of 0.5 C with 20°C , which we use as test data to test the performance of the trained BP neural network. Then, we input the battery voltage, temperature, and current from the test data into the trained BP neural network to estimate the battery SOC, and the output data of trained BP neural network are recorded as estimation data.
The experimental results are shown in Figure 4. The MSE between the test data and the estimated data is 0.6824, and the accuracy of SOC estimation is higher. Before 50-AH, the voltage decreases slowly with the increase of discharge capacity, and the error between estimated data and test data is small. After 50-AH, with the increasing polarization of the battery, more and more power is consumed by internal resistance of battery, which leads to the rapid decrease of the battery voltage.

Measured and estimated values of discharge capacity.
In summary, the BP neural network can estimate battery SOC, according to battery voltage, temperature, and current. The error between estimated data and test data of battery SOC is small by observing the whole discharge process. Therefore, we can apply the trained BP neural network to the practical system for further testing.
Design of UPS
According to the actual application environment of UPS, we design the overall block diagram of the system as shown in Figure 5. UPS mainly includes transformer, inverter module, lithium batteries, BMS, relays, sensors, and so on. And the working state of the system is introduced in two cases.

Overall block diagram of UPS.
Case 1. When the AC input is normal, the input AC voltage is converted to a specified voltage (220 or 110 V) through a transformer, and then passes through the inverter module to output. In addition, AC input voltage charges lithium batteries through battery charger, and BMS measures battery voltage, temperature, and charging current through sensors.
Case 2. When the AC input is abnormal due to power outage, the amount of electricity stored in the battery will be released. The DC voltage of the batteries will be converted to AC voltage through the inverter module, and then output to the equipment for power supply. Similarly, BMS measures battery voltage, temperature, and discharging current through sensors.
BMS transmits the measured battery voltage, temperature, and current to the host computer through Ethernet, and estimates the battery SOC according to the measured battery parameters. When the battery SOC reaches 100% or 0%, BMS will control the relay switch to stop charging or discharging to protect the lithium batteries.
Implementation of BP neural network
In this article, we apply BP neural network to estimate SOC of lithium batteries in UPS, and test the accuracy of SOC estimation in practical system. UPS used in testing includes BMS and PC software. Because it is difficult to complete complex mathematical calculation in MCU of BMS, we realize the estimation of battery SOC based on BP neural network in PC software. Then, the estimated battery SOC is transmitted to BMS via Ethernet. To avoid communication interruption and unable to obtain battery SOC, an AH counting method is also used to calculate battery SOC in BMS to improve the stability of UPS. The implementation process of estimating battery SOC based on BP neural network is as follows:
Step 1. The weights and thresholds of the trained BP neural network are obtained and stored in the PC software.
Step 2. The PC software receives the data of voltage, temperature, and current uploaded by the BMS.
Step 3. The weight, threshold, voltage, temperature, and current are substituted into the activation function to calculate the battery SOC.
Step 4. The battery SOC calculated by PC software is transmitted to BMS.
To verify the feasibility of estimating battery SOC in UPS by BP neural network, we build an SOC estimation test platform for practical test. The test platform is shown in Figure 6, including 16 lithium batteries (single cell capacity 60-AH), BMS board, inverter module, Ethernet module, resistor (maximum resistance 35 Ω), and host computer. Resistance is used as load in the test and BP neural network is used to estimate battery SOC in the host computer.

SOC estimation test platform.
In the actual test, the lithium battery pack is charged and discharged with 10 A current. We use C language to write AH counting method program to estimate battery SOC in BMS, and use Visual Studio software to import trained BP neural network to estimate battery SOC in host computer. Then, we record the actual estimated battery SOC in UPS as actual test data. The estimated data are compared with the actual test data, and the data graph is drawn using MATLAB (Figure 7). The X-axis represents the discharge time and the Y-axis represents the current SOC of the battery.

Actual test data of SOC estimation.
It can be seen from Figure 7 that the SOC of battery changes from 100% to 0% and the discharge time of actual test data is 367 min. The discharge time estimated by the BP neural network is the same as the actual test data, but the discharge time estimated by the AH counting method is 360 min, which has some errors. The SOC estimated by the AH counting method is close to the actual test data, but the error increases gradually with the accumulation of time. Moreover, there are some fluctuations in battery SOC estimated by BP neural network, but the overall data are close to the actual test data, and there is no cumulative error in BP neural network. In summary, the implementation results show that BP neural network can improve the accuracy of SOC estimation and avoid the cumulative error caused by long-term cyclic charging and discharging.
Conclusion
In this article, we study and implement the SOC estimation method of lithium battery based on BP neural network in UPS. First, the BP neural network model for estimating SOC of lithium batteries is established. The input parameters are battery voltage, temperature, charge, and discharge current; and the output parameter is battery SOC. Second, BP neural network is trained with battery sample data to meet the MSE requirement. Then, the discharge experiments of lithium batteries were carried out, and the experimental data of SOC and the estimated data of BP neural network were recorded. The results showed that the MSE between the estimated data and the test data was 0.6824. Finally, SOC estimation test platform is built and BP neural network is implemented in test platform to verify the feasibility of the proposed method. The implementation results show that estimating SOC by BP neural network can effectively reduce the cumulative error and improve the stability of smart UPS.
Footnotes
Handling Editor: SooKyun Kim
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work is supported by Science and Technology Project of Xuzhou (KC18068) and by National Natural Science Foundation of China (51504255).
