Real-Time SoC Estimation for Li-Ion Batteries using Kalman Filter based on SBC Raspberry-Pi

Received: June 21, 2021 Revised: July 19, 2021 Available online: November 24, 2021 Measurement of electric charge on the battery in real-time cannot be separated from external noise and disturbances such as temperature and interference. An optimal State of Charge (SoC) estimator model is needed to make the estimation more accurate. To obtain the model, the battery was tested under room temperature conditions and at a temperature of 40°C to obtain a second-order RC model for the Li-Ion battery used. Based on the test data obtained, the data will be tested first using the Kalman Filter method to get an estimate of the State of Charge (SoC). Tests were carried out using MATLAB software. After the method was tested, the online SoC Estimator design began using the Raspberry Pi Single Board Computer (SBC). After that, the estimator will be tested first using data from offline measurements and then used in realtime (online) SoC estimation measurements. The Voc before the battery discharge test was 13.16 V and after the test, the measured Voc was 11.58 V. During the discharge the Voc was reduced by 1.58 V. While the discharge data from the battery manufacturer showed the reduced Voc during the discharge was 1.2V.


INTRODUCTION
The use of fossil fuels, especially oil and gas, is increasing every year. Carbon emissions released by fossil fuels are the main cause of global warming. About 93% of greenhouse gases are carbon emissions resulting from the combustion process of Internal Combustion Engine (ICE) fuel [1], To reduce the use of this fuel, an electric-fueled vehicle or Electric Vehicle (EV) can be an option.
There are two basic differences between a combustion engine car or Internal Combustion Engine (ICE), and an electric car or Electric Vehicle (EV) [2], [3]. A combustion engine car (ICE) using fuel oil as an energy source with a combustion engine as the driving force. While the electric car (EV) uses electrical energy in the battery as a source with an electric motor as the driving force.
Measuring the stored electric charge (State of Charge) in realtime on an electric car (EV) is not as simple as in a fuel car (ICE). In ICE cars, the measurement of the fuel capacity in the tank can be easily measured with the float sensor. In electric car batteries, the only variables that can be measured are current, voltage and battery temperature, so the SoC value can only be estimated. SoC measurements on electric cars in real-time are also inseparable from the influence of noise and external disturbances such as temperature fluctuations, vibration and interference.
So that electric car batteries can be used optimally and prevent damage, a battery management system is needed. The main objective is to estimate SoC and State of Health (SoH) [4]. This research is focused on determining the estimator algorithm for battery SoC. The estimator is designed to be able to deal with the influence of external disturbances and perform measurements accurately and can be used in real-time.
Several studies that are also related to the topic of SoC estimation on electric car batteries are research from Mingyue Zhang and Xiaobin Fan who discussed various methods for estimating SoC on batteries and their respective advantages and disadvantages [5], Asep Nugroho and Estiko Rijanto [6] in a study that discusses the estimation of SoC measurements in electric batteries using the coulomb counting and integral observer methods to improve the accuracy of coulomb counting, research by Andica Dian Isnaini, Suwandi and Reza Fauzi Iskandar [7] which discusses the estimation of SoC measurements in electric batteries using the coulomb counting method, Xiaopeng Tang, Furong Gao, Changfu Zou, Ke Yaoa, Wengui Hu, Torsten Wik [8] in a study that discusses model switching estimation for SOC using high pass filter and the coulomb counting, and research from Furqan Asghar, In-ho-ra and Muhammad Talha [9] which discusses the estimation of SoC measurement in electric batteries using the kalman filter method, in this study it is concluded that SoC estimation with kalman filter gives better results than other methods. but in this study the SoC estimation has not been carried out in real-time, therefore the author makes a study of Real-time SoC measurement estimates on li-ion batteries using the Kalman filter method with Single Board Computer (SBC) Raspberry-Pi in order to get current and power that is unaffected by noise and interference for real-time State of Charge (SoC) measurements.

METHOD
The concept of this research is to prove whether the Li-ion battery model can be used to estimate the SoC during discharge using the kalman filter method and apply it to real-time SoC using SBC in Raspberry Pi system.
In general, this research has two stages. The first is offline, measurement with Picoscope and processing of battery data during discharge using MATLAB, and the second is online. Liion batteries that have been set according to room temperature and 40℃ are connected in series, then connected to an inverter which to form constant load. In the offline stage, the battery current and voltage at the time of discharge are stored using a picoscope. Then the data obtained is processed using MATLAB software to generate battery parameters. Meanwhile, in the online stage, the battery current and voltage during discharge will be read and processed directly by kalman method that implemented using Python program that has been designed previously in the SBC. The analysis resulting from this research is in the form of SoC estimation analysis, parameter value analysis and the obtained Voc.
Li-ion battery measurements were carried out at room temperature and 40˚C. The eksperiment flowchart can be seen in From the flowchart above, in more detail the experimental stages can be explained as follows:

Li-Ion Battery Acquisition
The first stage carried out aims to obtain li-ion battery data acquisition. To get the data, data acquisition is carried out by connecting the battery and load, the results of the acquisition can be seen through the Picoscope software on the PC.
This acquisition is carried out with two condition temperature as previously mentioned. For 40˚C temperature condition carried out by placing the battery in a box, then the box is heated using a heater so that the temperature in the box reaches 40˚C, which is then given a load. Hardware design block diagram can be seen in Figure 2. In this figure, four Li-Ion battery cells connected in series are connected to an inverter to convert 12 VDC into 220 VAC which is then connected to dummies with rating of 350 W each.
Measurements were carried out with 2 different time conditions. The first measurement was measured for 2 x 15 minutes using a load of 350 W and 2 x 350 W each. The second measurement was measured for 2 x 30 minutes using a load of 350 W and 2 x 350 W each. To measure battery current and voltage, a Picoclamp is used which has been connected to a probe whose value can be displayed on a PC monitor. The clamp meter is used to measure the battery temperature when the temperature reaches 40˚C.

Determination of Li-Ion Battery Model Parameters
After getting the battery acquisition data. The parameter model of the li-ion battery can be determined. Determination of the parameters of the tested battery model is obtained by solving the least-square identification algorithm. The data obtained is then filtered using the Kalman Filter method which is processed using MATLAB, and then the parameter values are obtained from the Li-Ion battery.

Modeling Li-Ion Battery Structure
To prove that the Li-ion battery model is suitable for use in SoC estimation, the parameters of the battery model are needed. In the modeling shown in Figure 3. Voc is a function where 0 and 1 are the two parameters to be determined. The RC circuit ( 1 , 1 ) is used to simulate the relaxation effect of the battery. 2 is as internal resistance. V and I are the output voltage and current. After being given an example of the current, voltage and SoC value, the parameter values can be searched using the following algorithm[10]- [12]: Where, is the coulombic efficiency, and is the nominal capacity of the battery. 1 represents the voltage across the capacitor 1 . denotes the time step, and Δ is the sampling interval. The output equation is then:

Linear Identifiable formulation
A linear identifiable form of the model can be achieved by discretizing a frequency-dom ain model representat ion using the first-order backward differenc e and assuming that SOC(k) is approximat ely equal to SOC(k -1).
Such that After getting the value of 1 , 2 , 3 , 4 and 5 then the battery model parameters can be obtained by the following algorithm [10]:

Least-Squares identification algorithm
Given the sampled current, voltage, and experimental SOC values of the battery, the parameter vector c can be solved using the least-squares algorithm as follows: The subscript N plus 1 indicates the number of data samples.

Kalman Filter
Kalman Filter is a set of mathematical equations that provides an efficient average calculation (repeatedly) to estimate the state of a process, by minimizing the Mean Squared Error. Kalman filters have been the subject of extensive research and application. This filter is very useful in several aspects. This filter can estimate the state in the past, present, and even in the future [13]. An equation of a continuous time-invariant linear system in a variable state can be formed as follows [14] = + + Where, x = state vector u = vector containing input control A = state transition matrix that uses the effects of each system state parameter B = a control input matrix that uses the effect of each control input parameter of the vector u on the state variable w = process noise on the system Measurements on the system can also be performed, according to modeling

Offline Measurement Data Processing
The data obtained is then entered into the MATLAB software. The data obtained during the measurement is still in the form of data that has noise. MATLAB is used to filter the data so as to reduce noise as much as possible. The data from the battery measurement results when discharge is processed using the Kalman Filter method [16].
The mathematical equations of the model equivalent circuit shown in Fig.3 and the related equations for the extended kalman filter are shown in the following [17]- [19]: Here, ( ) is the battery voltage across the load, ( ) is the voltage across RC, ( ) is the current flowing through load, 0 is the capacity of the battery. 1 is the battery internal resistance.
2 is the polarization internal resistance.
We take the battery SOC, RC link capacitor voltage as state variables, to get lithium-iron battery space state equation and observation equation. As shown in follows [19]: Here, ( ) is the battery load current at the sampling point.
Here, ̂( | − 1) is the predictive value of the state variables.

Estimator design and offline testing
After being tested offline and the Li-Ion battery parameters are also obtained, the SoC estimator is designed by incorporating a system algorithm using the Raspberry Pi module, the Raspberry Pi is a single board computer (SBC) module which will be used when measuring online and directly processing the data obtained during online measurement. After designing the estimator, it is tested offline first so that it can be ensured that the estimator can be used and implemented when measuring Li-Ion batteries online.

Li-Ion Battery Voltage Measurement After Discharge
After the battery discharges, the battery is then allowed to stand for 20 minutes so that the current in the battery flows into the capacitor and the terminal voltage on the battery returns to normal.

Battery parameters Data When Discharged Offline
To get the battery data parameters when the process of discharging offline, a circuit as presented in Figure 4. is used.
In the figure below, the Li-Ion battery used consists of 4 modules, each of which has the characteristics of 4 V 200 Ah. After the four battery modules are connected in series, the battery is connected to an inverter to convert DC current to AC current so that it can be connected to a load in the form of dummies, each of which has a power of 350 W.
Current and voltage are acquition using a picoscope by connecting it to a battery. The picoclamp is used to measure the current flowing from the battery to the inverter. Current and voltage will be displayed on PC using picoscope software. By using this circuit, data acquisition is carried out for predetermined conditions. In the current that is read there are small spikes and values that change quickly so that the graph displayed looks so tight. This is caused by noise that affects the signal so that the signal is disturbed at the time of measurement. The noise is caused by a disturbance during signal transmission or the voltage from the signal transmission medium (carrier) which is affected by temperature or also known as thermal noise. So the higher the temperature, the higher the noise. Likewise, at the voltage, there is also noise that affects the signal during measurement. On The voltage can also be seen in the condition of the battery discharge which causes the voltage capacity to decrease.
In the discharge acquisition for 15   . is the current and voltage data read on the picoscope software. Similar to using a 350 W load, the current that is read has small spikes and the value changes rapidly so that the graph displayed looks very close. This is also caused by noise that affects the signal so that the signal is disturbed at the time of measurement.
Using a 700 W load causes a higher current to flow than using a 350 W load. The increase in current also causes a larger electric charge to flow. This is in accordance with the column counting method, the higher the current flowing, the greater the electric charge.
Likewise for voltage, there is noise that affects the signal during measurement. At the voltage, it can also be seen that the discharge condition of the battery causes the voltage capacity to decrease.

Discharge Using a 350W Load with a Temperature of 40C
Data retrieval for the temperature of 40 C is to connect the battery series and then connected to the inverter. The battery is put in an acrylic box to be heated using a hair dryer, so that the room temperature in the box reaches 40 C. Once the temperature is reached, the current and voltage are measured. . shows the current and voltage values of the battery experiencing a lot of noise, causing a spike in the value higher than the current value reading at room temperature. This is because the noise in the battery has increased with the heating of the battery's ambient temperature. This is called also with thermal noise (heat). This can be proven using the formula in equation (23). At the voltage can also be seen the condition of the battery discharge which causes the voltage capacity to decrease.
On discharge for 15 minutes, the measured initial terminal voltage is 12.61 V and the final terminal voltage is 11.54 V. From the difference between the two voltages, the voltage used during discharge is 1.07 V. And on discharge for 30 minutes, the voltage is 1.07 V. the initial measured terminal is 13.02 V and the final terminal voltage is 11.59 V. From the difference between the two voltages, the voltage used during discharge is 1.43 V.
Discharge Using Load 700 W with Temperature 40C Figure 8. Discharge Using Load 700 W with Temperature 40C Figure 8. is the current and voltage data read on the picoscope software. Similar to using a 350 W load, the current that is read has high spikes and the value changes rapidly so that the graph displayed looks very close. This is also caused by thermal noise that affects the signal so that the signal is disturbed during measurement.
Using a 700 W load causes a higher current to flow than using a 350 W load. And with the higher the current flowing, the greater the electric charge. Likewise, at the voltage there is also noise that affects the signal during measurement. At the voltage can also be seen the condition of the battery discharge which causes the voltage capacity to decrease.
On discharge for 15 minutes, the measured initial terminal voltage is 12.55 V and the final terminal voltage is 11.21 V. From the difference between the two voltages, the voltage used during discharge is 1.34 V. And on discharge for 30 minutes, the voltage is 1.34 V. the initial measured terminal is 12.95 V and the final terminal voltage is 11.29 V. From the difference between the two voltages, the voltage drop/voltage used during discharge is 1.66 V.

The Impact of Time and Temperature Conditions on VOC
To see more clearly the effect of time, temperature and load on voltage, the values from the above experiments can be entered into the table, as shown in table 1. from the table we can note that the higher the temperature of the battery room and the time used, the higher the voltage drop that will be used during the battery discharge condition.

Li-Ion Battery Parameter Value
To estimate the SoC, it takes several parameters from the Li-Ion battery model. These parameters are obtained using equations (2) - (6). After obtaining the current and voltage data from the measurements, the required parameters are obtained as shown in Table.2 From the table above, it can be seen that there are several parameter values. In these data, it can be seen that there is difference between each condition, but the difference is not linear. This happens because the model is very sensitive to temperature and noise, but observers take measurements using a clamp meter.
To get more precise data, better sensors should be used. To simulate ideal conditions, data are used on parameters with high enough temperature conditions, long discharge times, and large enough loads. Therefore, for the SoC estimator, conditions are used at a temperature of 40℃ with a load of 700 W for 30 minutes

SoC Estimator usimg Offline Data with Kalman Filter Method
The parameters that have been obtained from the acquisition data can be used to estimate the State of charge using the Kalman Filter method. To estimate the SoC, we will use the Li-ion battery parameters that have been obtained previously with a temperature condition of 40℃ using a load of 700 W for 30 minutes. The results of the SoC graph are obtained as shown in Figure 9.
\ Figure 9. SoC Estimation during discharge 700 W at 40℃ for 30 minutes The data used in the processing results using the Kalman Filter above is the acquisition data when the battery is in a discharge condition using a load of 700 W with a temperature condition of 40℃. At the time of measurement for 30 minutes, the measurement starts when the estimated battery SoC is 86.14% until the measurement is completed when the estimated battery SoC is 82.99%.

Offline SoC Estimator Testing and Design
The testing and design of the SoC estimator using the Kalman Filter method is carried out using the Raspberry Pi SBC module. The Raspberry Pi uses the Python programming language. The design is done using Python software that can be operated via a PC.
After the estimator is designed, it will be tested first using measurement data that has been used previously or offline. From the measurements that have been made, the parameters of the ideal Li-Ion battery are obtained. As previously discussed, the ideal parameters are obtained from the measurement results using a 750 W discharge load for 30 minutes with a temperature condition of 40 C. This parameter is used for offline testing.  Figure 10. above, it can be seen that the results of offline estimator data processing are in accordance with offline processing of measurement data using the Kalman Filter method. This means that the offline SoC estimator can be used for direct online measurement and data processing to estimate the State of charge.

Online Measurement of Li-Ion Batteries with Temperatur 40̊C
After the estimator is designed and tested using offline data, then the estimator can be used to perform and process the incoming data to determine the state of charge of the battery during discharge conditions.
In testing the online SoC estimator, inputs in the form of voltage and current are needed. To get the input we use a voltage sensor and a current sensor. The data obtained is still in the form of analog data. For that we need an Analog / Digital Converter (ADC) which functions to convert analog signal to digital. Therefore, the voltage and current sensors will first be connected to ADC. Then the ADC is connected to the Raspberry Pi to get the signal value read by the two sensors. The online SoC estimator test series can be seen in Figure 12. Figure 11. SoC estimator test series online The value contained in the input signal is still a value that is acquisition by the sensor. To get the acquition input value, the saw value will be processed first based on certain characteristics, which include sensors and batteries.
In this study, the voltage sensor used is a 0-25 V voltage sensor and a current sensor using ACS758. For ADC we use PCF8591. After the signal obtained from the voltage and current sensor is processed by the ADC, the sensor saw value is obtained in the form of 8 bits. To get the measured value of voltage and current, the sensor reading value which is still in the form of 8 bits was processed first.
After the voltage and current values are obtained, these values will be used to estimate the SoC of the Li-Ion battery. Any changes in the SoC value will be displayed every 1 second during battery discharge

Acquisition Li-Ion Battery Voltage after Discharge
After the measurement, the battery is allowed to stand first to stabilize the battery temperature so that the battery is also stable when acquition after discharge. Before the measurement, the battery voltage is 13.16 V. After the battery is left standing, the measured battery voltage is 11.58 V. The difference in voltage is 1.58 V, which is the voltage drop during discharge.

Comparison of Voc Curve Against SoC of Battery Manufacturers with Testing on Discharge
To determine the success of the SoC estimator testing that has been designed, a comparison of the voltage characteristic curve to the SoC is carried out between the data from the battery manufacturer used and the tests that have been carried out. Based on the producer curve in Figure (2.2), Figure 12. Voltage characteristic curve against the battery SoC when discharge [20] to discharge at a temperature of 25 C -55 C with an initial voltage of 4 x 3.5 V (using 4 battery modules) discharge until SoC = 0% (discharge capacity = 100%) then the remaining voltage is 4 x 3.2 V. So the reduced voltage from SoC = 100% to 0% is 1.2V.
In the test carried out using a temperature of 40 C, the initial voltage was 13.16 V, discharge was carried out to SoC = 0%, the measured voltage after discharge was 11.58 V. The voltage reduced from SoC = 100% to 0% was 1.58 V. When compared with existing data on battery manufacturers, there is a difference in voltage drop difference of 0.38 V. The value of this difference is not too significant for the comparison between battery manufacturer data and the tests that have been carried out.

CONCLUSIONS
From the results of data collection and testing and analysis that has been carried out, it can be concluded that the Kalman Filter method with SBC Raspberry Pi can be applied to estimate the battery condition (State of Charge) in electric cars in real-time, as well as in measuring tank capacity in electric cars. To determine the parameters of Li-Ion battery characteristics, current and voltage data can be used when the battery discharges. The advantage of the Kalman Filter method is that it can estimate the SoC of the battery in high temperature conditions. Meanwhile, the drawback of this method is that the method can only work optimally at high temperatures and uses high loads.