masterthesis_linzhu

69
Degree Certificate DESIGN AND IMPLEMENTATION A BATTERY MANAGEMENT SYSTEM FOR A MULTI‐FUNCTION POWER CONVERTER Lin Zhu Supervisor: Examnier: Björn Jernström Mihhail Matskin March 18, 2014 Ferroamp Elektronik AB School of Information and Communication Technology KTH|Kungliga Tekniska Högskolan Stockholm Sweden

Upload: lin-zhu

Post on 15-Apr-2017

157 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: MasterThesis_LinZhu

Degree Certificate

DESIGN AND IMPLEMENTATION A

BATTERY MANAGEMENT SYSTEM FOR A

MULTI‐FUNCTION POWER CONVERTER

Lin Zhu

Supervisor: Examnier:

Björn Jernström Mihhail Matskin

March 18, 2014

Ferroamp Elektronik AB

School of Information and Communication Technology

KTH|Kungliga Tekniska Högskolan

Stockholm Sweden

Page 2: MasterThesis_LinZhu

I

Abstract

This thesis work presents the design and implementation of an advanced Battery

Management System (BMS) for a battery package, with 96 Lithium-ion battery cells,

connected in series, with emphasis on battery model, battery balancing algorithm, State-

of-Charge (SOC) estimation algorithm, and software implementation on a microcontroller.

A set of simulation programs has been developed, along with an interactive web GUI, to

verify the battery model and the algorithms. A battery simulator, based on SPICE, is used

to implement a first order Thevenin dynamic electrochemical model. The battery cells are

balanced using a PID control algorithm. Meanwhile, Extended Kalman Filter (EKF)

algorithm is used for SOC estimation. The algorithms are implemented on the STM32F103

microcontroller to control a BMS hardware setup, developed at Ferroamp Elektronik AB.

The simulation result proves that the first order Thevenin dynamic electrochemical model

reflects the behavior of a real battery accurately, the PID balancing algorithm is effective

to make the battery cells stay in balanced state, and the error of EKF SOC estimation

algorithm is below 5%.

Keywords: BMS, SOC estimation, EKF, cell balancing, PID control, SPICE

Page 3: MasterThesis_LinZhu

II

Contents

Abstract ........................................................................................................................................... I

Contents........................................................................................................................................ II

List of Figures .............................................................................................................................. V

List of Tables ............................................................................................................................ VII

List of Abbreviations ............................................................................................................. VIII

Chapter 1 Introduction .......................................................................................................... 1

1.1 Background ................................................................................................................... 1

1.2 Problem Statement ....................................................................................................... 2

1.3 Project Tasks .................................................................................................................. 3

1.4 Market Investigation .................................................................................................... 5

1.5 Research Method .......................................................................................................... 5

1.6 Thesis Work Outline .................................................................................................... 6

Chapter 2 Previous Research and Algorithms Introduction .......................................... 7

2.1 Balance Control Algorithm ......................................................................................... 7

2.2 SOC Estimation Algorithm ......................................................................................... 9

Coulomb Counting Approach .......................................................................................... 10

Extended Kalman Filter Approach .................................................................................. 10

Vmin-EKF Approach ............................................................................................................ 11

Chapter 3 Battery Management System Simulation ..................................................... 13

3.1 Charge and Discharge Experiment .......................................................................... 14

3.2 Battery Cell Models .................................................................................................... 18

Black Box Model ................................................................................................................. 18

First Order Dynamic Thevenin Model ............................................................................ 18

3.3 SPICE Based Battery Simulator ................................................................................ 21

3.4 Battery Management System Simulator .................................................................. 23

Page 4: MasterThesis_LinZhu

III

BMS Flow Chart .................................................................................................................. 23

Extended Kalman Filter Implementing Steps ................................................................ 25

3.5 Simulator Interface ..................................................................................................... 28

Interface Architecture ........................................................................................................ 28

Frontend of the Interface ................................................................................................... 29

Backend of the Interface .................................................................................................... 30

3.6 Simulation Results ...................................................................................................... 31

Chapter 4 Hardware Implementation .............................................................................. 36

4.1 Hardware Overview .................................................................................................. 36

4.2 Hardware Function Blocks ........................................................................................ 37

Power Supply ...................................................................................................................... 37

Microcontroller ................................................................................................................... 38

Current Sensor .................................................................................................................... 38

Total Voltage Sensor .......................................................................................................... 39

Lithium-ion Battery Cell .................................................................................................... 39

Battery Cell Monitor Circuit ............................................................................................. 40

Other Functional Blocks .................................................................................................... 44

4.3 Hardware Drivers ....................................................................................................... 46

Develop Environment ........................................................................................................ 46

Programming STM32 ......................................................................................................... 46

Debugging and Tuning Hardware .................................................................................. 47

Chapter 5 Analysis and Evaluation................................................................................... 49

5.1 Research Result Analysis ........................................................................................... 49

5.2 Simulation Software Evaluation ............................................................................... 50

5.3 Hardware Evaluation ................................................................................................. 50

Chapter 6 Conclusion and Future Work .......................................................................... 52

6.1 Software Conclusion .................................................................................................. 52

6.2 Hardware Conclusion ................................................................................................ 52

6.3 Future Work ................................................................................................................ 53

Page 5: MasterThesis_LinZhu

IV

Bibliography ............................................................................................................................... 55

APPENDIX A Important Datasheets ..................................................................................... 58

Page 6: MasterThesis_LinZhu

V

List of Figures

Figure 1.1: Energy Hub ................................................................................................................ 3

Figure 2.1: PID Control Diagram ................................................................................................ 8

Figure 3.1: BMS Simulation Framework ................................................................................. 13

Figure 3.2: Battery Charge Experiment Equipment ............................................................... 15

Figure 3.3: Charge Experiment Current and Voltage Curve ................................................ 15

Figure 3.4: Current Load Circuit .............................................................................................. 16

Figure 3.5: Current Load........................................................................................................... 16

Figure 3.6: Current Load Current Curve During Discharging ............................................ 17

Figure 3.7: Quantity Voltage Curve ......................................................................................... 17

Figure 3.8: Battery Model .......................................................................................................... 18

Figure 3.9: Thevenin Model ...................................................................................................... 19

Figure 3.10: Voltage Response With Respect to Current Reference .................................... 19

Figure 3.11: Real SOC_OCV Curve and Fit Curve................................................................. 20

Figure 3.12: 6 Cells NetworkX Plot and 96 Cells NetworkX Plot ........................................ 22

Figure 3.13: BMS Control Diagram .......................................................................................... 23

Figure 3.14: System Block Diagram ......................................................................................... 26

Figure 3.15: Extended Kalman Filter Implementation Flow Chart ..................................... 27

Figure 3.16: Overall Structure of Web Based GUI ................................................................. 28

Figure 3.17: Battery Simulator Dashboard Interface ............................................................. 29

Figure 3.18: Battery Simulator Simulation Jobs Interface ..................................................... 30

Figure 3.19: Unbalanced Battery Cells ..................................................................................... 32

Figure 3.20: Cell Voltage during Balancing ............................................................................ 32

Figure 3.21: Estimated SOC and Real SOC Comparison in Ideal Condition ..................... 33

Figure 3.22: Estimated SOC and Real SOC Comparison with Noise .................................. 34

Figure 3.23: SOC Estimation Result ......................................................................................... 35

Figure 4.1: System Block Diagram ........................................................................................... 36

Figure 4.2: BMS PCB board and BMS with Battery Cells...................................................... 37

Figure 4.3: Relay Interlock Chain ............................................................................................. 38

Figure 4.4: Microcontroller ........................................................................................................ 38

Figure 4.5: Current Sensor ......................................................................................................... 39

Page 7: MasterThesis_LinZhu

VI

Figure 4.6: Total Voltage Sensor Circuit .................................................................................. 39

Figure 4.7: Rechargeable Lithium-ion Cell under Test.......................................................... 40

Figure 4.8: Daisy-Chained STM32 Master and LTC6803-3 Slave ........................................ 41

Figure 4.9: LTC6803-3 Daisy Chain .......................................................................................... 42

Figure 4.10: Isolation Circuit ..................................................................................................... 43

Figure 4.11: Temperature Sensor Circuit ................................................................................. 43

Figure 4.12: Battery Cell Balance Circuit ................................................................................. 44

Figure 4.13: CAN Transceiver Circuit ..................................................................................... 45

Figure 4.14: Supply Removal Sensor ....................................................................................... 45

Figure 4.15: EEPROM Circuit ................................................................................................... 46

Figure 4.16: Infrared Camera Figure ........................................................................................ 48

Figure 5.1: Discharge Load ........................................................................................................ 51

Page 8: MasterThesis_LinZhu

VII

List of Tables

Table 1.1: Off-the-Shelf BMSs ..................................................................................................... 5

Table 2.1: Comparison of SOC Estimation Method ................................................................. 9

Table 3.1: Battery Model Coefficients Table ........................................................................... 21

Table 3.2: Battery Model Parameter Table .............................................................................. 21

Table 3.3: UART Commands Table .......................................................................................... 24

Table 3.4: Kalman Filter Parameters Table ............................................................................. 26

Table 4.1: Parameters of Lithium-ion Cell under Test ........................................................... 40

Page 9: MasterThesis_LinZhu

VIII

List of Abbreviations

BMS: Battery Management System

SOC: State of Charge

SOH: State of Health

OCV: Open Circuit Voltage

EKF: Extended Kalman Filter

TOS: Top of Stack

BOS: Bottom of Stack

CAN: Controller Area Network

GPIO: General Purpose Input Output

DMA: Direct Memory Access

ADC: Analog to Digital Converter

SPI: Serial Peripheral Interface

MISO: Master in Slave Out

MOSI: Master Out Slave In

OV: Over Voltage

UV: Under Voltage

PCB: Printed Circuit Board

IC: Integrated Circuit

ROTS: Real Time Operating System

Page 10: MasterThesis_LinZhu

IX

Page 11: MasterThesis_LinZhu

1

Chapter 1 Introduction

BMS, short for battery management system, is any electronic system that manages a

rechargeable battery or a rechargeable battery package. The functionality of a BMS

includes monitoring the battery’s status such as output voltage, battery temperature etc.,

calculating and reporting data such as state-of-charge, state-of-health and also responsible

for the safety of the battery.

1.1 Background

With the growth demanding of clean energy from the market. Typical clean energy like

smart grid and Electronic Vehicles (EVs) are developing fast, thus the battery become the

most prominent energy storage device[1]. Lithium-ion batteries which are featured of

high energy density and long life cycle are preferable for many applications. While battery

technology is developing rapidly, developing cells with higher energy densities and

longer life cycles, it is equally important to developing the performance of the Battery

Management System (BMS) to manage the overall issues that the batteries will have. For

example provide charge/discharge protection, temperature monitoring, accurate state-of-

charge (SOC) and state-of-health (SOH) estimation, cell balancing, communication with

other devices etc. The BMS should not only have the functionality of monitor the batteries,

but also should prevent hazardous and inefficient operating conditions.

The thesis will focus on the BMS used to manage a large Lithium-ion battery group which

is the energy storage used in the smart grid. The smart grid is a concept involving an

electricity grid that delivers electric energy using communications, control, and computer

technology at a lower cost with higher reliability[2]. Major concerns about integration of

the battery storage into the smart grid are cost, lifetime, power delivery, safety and

environmental impact[1]. In order to satisfy the needs, a BMS usually contains the

following features[1].

Cell monitoring: Cell monitoring is to monitor the terminal voltage,

current flowing through the cell, temperature of the cell, connection of the

cell etc.

Battery protection: This is one of the most important functions a BMS

should have, since for many type of rechargeable battery, operating in

hazard conditions are harmful both to the battery and the user, for example

over charge of a rechargeable battery will cause the battery being

destroyed, what more is that it will cause fire also.

SOC estimation: SOC, which represent the available energy stored in the

battery compared to the full capacity charge of the battery, is a key

Page 12: MasterThesis_LinZhu

2

parameter for many battery applications. It helps to estimate battery time

and can indicate the depth of charging and discharging thus prevent the

battery goes to overcharging/over discharging status.

Cell balancing: In smart grid technology, rechargeable batteries appears

usually not only in a single battery, the most common case is to connect

many batteries in series, parallel or in combination to achieve higher

voltage and capacity. The cell balancing is an issue that happens in a

battery package when many batteries contains not similar capacity. For

safety and efficiency sake, the BMS should be responsible to balance the

battery package.

Thermal management: Battery dispatch heat when charging and

discharging, it is important to know if the battery is working in normal

operating temperature. If the temperature is above the operating

temperature, the BMS should take action to lower down the temperature

for example start the fan. BMS should also monitor the under temperature

condition and take corresponding actions.

SOH estimation: SOH predicts the number of times the battery can be

charged and discharged before its life is terminated. SOH is not a

parameter can be measured directly, but can be estimated by using specific

algorithms from parameters that are measureable like current and voltage.

Communication management: BMS works directly on the hardware

(batteries) in smart grid it should always communicate with higher level

energy controller.

The features listed above are the main functions of a BMS, there are also some other

functions that BMS has, for example charging control, discharging control, user control

interface etc.

Distinguishes between advanced BMS and less advanced BMS in the market today are

functionality and precision of parameters. One of the most important functions for an

advanced BMS is the balance function and one of the most important parameters is SOC.

Advanced BMS can make the battery package in balanced state and can estimation SOC

accurately. So the focus of the thesis will be put on developing advanced balance

algorithm and SOC estimation algorithm.

1.2 Problem Statement

The aim of this master thesis is to design, implement and verify a battery management

system for a multi-function power converter for Ferroamp Elektronik AB. The power

converter also known as Energy Hub is shown in Figure 1.1.

Page 13: MasterThesis_LinZhu

3

Figure 1.1: Energy Hub

As it known that the major problem of renewable energy such as solar power or wind

power is their intermittent characteristic. As share of renewable increase, they can no

longer be balanced by traditional electricity production method for example hydroelectric

or gas fired power plants. So with more use of renewable energy, it will cause the grid to

be instability. The trends proves that the intermittent generation must be balanced by

energy storage and flexible demand[3]. The Energy Hub from Ferroamp allows arbitrary

control of the energy flows between solar cells, a local battery package, local loads and the

grid, which can solve the problem cause by intermittent characteristic of solar energy.

The main body of the Energy Hub comprises a bidirectional three phase inverter, a boost

converter for solar cells and a buck-boost converter for battery strings, all interconnected

via a common DC-link. The energy storage of the Energy Hub is a sub independent system

which consist of a battery package comprises 96 series connected lithium cells up to a

nominal voltage of 400 voltages. The responsibility of the energy storage is to provide

energy when user needs more than the solar cells produce and store energy when the

solar cells produce more energy than the user’s demand. Despite the battery group a BMS

is needed to be manage the battery package. The tasks of the thesis is to design, implement

and verify the BMS for the battery package.

1.3 Project Tasks

All the hardware design work was done by staff in Ferroamp and the thesis work deals

with software of the BMS. The software of the BMS include develop software to simulate

the system and develop software runs in a STM32 microprocessor. Hardware Debugging

is mainly to test and verify every function of the circuit, check for design error and give

Page 14: MasterThesis_LinZhu

4

improvement suggestions. Simulating software is to build models for the battery package,

then test the developed algorithms on it. A brief summary of tasks given by the company

are listed below:

1. Functionality design of the BMS software.

The BMS should including functions of monitor voltage, current, temperature

of very individual cells, protect the battery package from running in conditions

of over/under voltage, over/under temperature and over current. BMS should

report state-of-charge (SOC) with error less than 5%, and state-of-health (SOH).

The BMS should use CAN bus communication protocal to communicate with

the Energy Hub.

2. Model and simulate the performance of the designed BMS in pure software.

Including build models for the battery and battery package, build models for

the battery management system, simulate the model in software and get

results including effect of the balance algorithm, precision of the SOC

estimation algorithm and precision of SOH estimation algorithm from the

simulation.

3. Debug the finished first version BMS hardware, report design bugs and fix the

bugs in hardware.

4. Implement the designed BMS software in a STM32 microprocessor then debug the

BMS in hardware.

5. Test and verify functionality of the BMS in actual prototype under different

conditions, for example in different charging rate, in difference temperature etc.,

and analysis stability and performance of the system.

From the requirements listed above, there are 3 main tasks for the thesis, first is design

the functionality of the BMS and implement it in a STM32 microprocessor. Second is to

simulate both the battery package and the battery management system in pure software.

Third is to testing and verifying the BMS first in simulation then in real hardware.

From knowledge aspect, the thesis will need knowledge of developing software for

microprocessor, debugging electronic circuit and solve hardware problem during

developing, mathematic knowledge of modelling the performance of a battery package,

programming for simulate the behavior of battery and BMS and knowledge of how to

design BMS etc.

Page 15: MasterThesis_LinZhu

5

1.4 Market Investigation

There are lots of BMSs available in the market, they are usually divided into two categories,

one is digital BMS another one is analog BMS[4].According to a white paper of BMS in

market[5] , The main function of the BMS include reporting individual cell voltage,

balancing the battery, requesting that battery be switched off and turning off the battery,

indicate SOC, indicate SOH etc. The hardware of the BMS can be integrated in a big PCB

board or can be divided into separate parts according to functionality. Digital BMS is

much more expensive than analog one, and the price of BMS is rational to the number of

battery cells. Price of digital BMS for 100 cells can be vary from 500 US dollars up to more

than 10000 US dollars[5]. A table of on market BMS is shown below[4]:

Company Name Function Cells Features

Black Sheep Balancer More than 32 SOC indicator,RS232 connector

Clayton Power Balancer 4 to 496 SOC indicator

EVPST Balancer unknown SOC indicator ,CAN,RS485 connector,

Display

Elithion Lithiumate Monitor 256 SOC indicator,CAN,RS232 connector

Gantuo Monitor 100 SOC indicator, CAN, USB, Display

REAP Balancer 168 SOC indicator, CAN, RS232, Optional display

Lithium Balance Protector 4 to 23 SOC indicator

Elithion Lithiumind Balancer 24 Current sense, SOC indicator, SOH indicator,

Optional Display

Table 1.1: Off-the-Shelf BMSs

From the table above we can see the basic functionality of the available BMSs which gives

suggestions of functionality design for a BMS.

1.5 Research Method

A set of research methods are applied to the research of developing the BMS which

include literature review, usability testing and quantitative approach. Most used method

is quantitative method, it is used for all experiments and data analysis. At the beginning

of the thesis, literature review method is used to study previous research and current

market of the BMS. Then a basic model of BMS is proposed using usability testing

approach which is based on the previous study. In this stage all functions and

requirements for the functions are proposed. Main part of the thesis is doing experiment,

collecting experiment data and analyzing those data, so quantitative method is applied to

this part, and the finally model of the battery which is a first order dynamic Thevenin

model is proposed based on the analysis result of the collected experimental data.

Quantitative method is also used in later part which evaluate the prototype.

Page 16: MasterThesis_LinZhu

6

1.6 Thesis Work Outline

The thesis can be divided into 6 chapters. Chapter 2 and chapter 3 are the key parts of the

thesis. Chapter 1 introduces the research background, thesis tasks, research method and

gives a brief introduction of the current market. Then previous research of important

algorithms used in BMS is presented in chapter 2. Chapter 2 focuses on introducing the

EKF algorithm for estimation the SOC, it also introduces the balance algorithm and

coulomb counting SOC estimation algorithm. Chapter 3 is the BMS simulation part. There

are two main topics in chapter 3, one is building models for the battery cell and another

part is to realize the algorithms introduced in chapter 2, a web based simulator GUI is also

introduced in this chapter. Chapter 4 introduced the hardware implementation of the

BMS, first it gives a detailed introduction of every functional blocks of the BMS PCB board,

and then it gives a brief description of the hardware drivers for the BMS board. Chapter

5 gives evaluation and analysis of both hardware and software of the BMS. Eventually a

brief conclusion of both software and hardware and future work are presented in chapter

6.

Page 17: MasterThesis_LinZhu

7

Chapter 2 Previous Research and Algorithms Introduction

Most challenging part of designing a BMS is developing algorithms used for balancing,

SOC estimation and SOH estimation. Based on many previous research, in this thesis a

PID controller is used to do balancing, both Coulomb Counting and Extended Kalman

Filter approach are used to estimate SOC. SOH estimation is a following parameter of

SOC, but it can only be estimated using Extended Kalman Filter approach. SOH

estimation algorithm is not researched in this thesis since lack of time.

2.1 Balance Control Algorithm

Because of manufactory, transportation, storage etc. the same type battery cell does not

have the same capacitance, internal resistance etc. When charging and discharging ,

different cell have different performance, in another word the cell is in unbalanced status.

There are several resons why battery should be balanced. Obviusly that balance will leave

room for more charge which is limited by cask effect [6] when unbalanced, the total

capacity of the battery stack will be limmited by the lowest one, secondly balancing the

cell can prevent overcharging the most charged cell[4]. But more importantly for this

application that large number of cells connect in series, unbalance will easily lead to

overcharge or overdischarge of some cells which will lead to failure of the whole battery

stack[7].

Cell balancing method can be devide into two categroyies,which are passive balancing

and active balancing[8]. Passive cell balancing method use a dissipative resistor to

discharge the cell with a higher voltage so that charging can be continued untill all cells

reached the same ternimal voltage. Active cell balance method is to use a short time

storage element such as a capacitor or an inductor to transfer energy between cells in a

battery stack [8].Both methods have advantages and disadvantages. Passive balancing is

easy to implement, but energy waste and low effciency are the drawbacks. Passive

balancing also known as the simplest and cheapest balancing method[9]. On the other

hand active balancing is more complicated to implement but better performance.

Though active balance method has many advantages over passive balance, but for this

application passive balancing is perferable. The most importance reason is that it is a big

battery package. Since this application have 96 battery cells in series,using active

balancing method will largely increase the complexity of the PCB layout as well as the

apparence of a battery stack. Another reason is that there no IC that has the feature of

active balancing on the market right now. On the other hand the battery monitor chosen

in this application provide the passive balance feature. And by using advanced control

algorithm to control the balance time and schedule which cell to balance, the passive

Page 18: MasterThesis_LinZhu

8

balance method can achevie the same performance. The last reson is that since in this

application the battery stack is connected the energy hub so the energy waste issue is out

of consideration, what’s more by calculation, balance a 3.65 voltage battey cell with a

dissipative resistor of 240 Ω for 10 hours is less than 0.3% of the total energy of the battery

cell. So the simplest and cheapest balancing method is the bast for this application.

Two questions about balancing are which cell to balance and how long it should be

balanced. For the first question the answer is that all the cells that have the OCV larger

than the smallest OCV of the whole stack should be balanced. This criterion sounds a bit

unreasonable, but for a large battery package it is much more important to make all the

cells in balanced state than lower energy waste. For the second question a controller is

used to control the balance time. PID controller is used to control the balance time from

the suggestion of [10]. PID controller short for proportional-integral-derivative controller

is a classical controller used for over 100 years and still widely used now[11]. Figure 2.1

shows the PID controller control diagram used in the BMS.

Figure 2.1: PID Control Diagram

As shown in Figure 2.1, PWM is the output of the system, and cell voltage is the feedback.

A new concept of balancing is proposed here: balance rate. Balance rate is a value to

control the balance switch on off duty cycle. The thought is similar to PWM control. PWM

short for Pulse-with modulation, it is a modulation technology widely used in tuning the

speed of a motor and many other applications. In order to let the system works in a stable

state the balance frequency is set comparatively high around 10Hz. Main reason of doing

so is that on and off of the balance switch may affect the total voltage, and a higher

frequency can make the total voltage stable in a similar level. The algorithm process shows

below:

Find out the lowest voltage in the battery stack, the lowest voltage should be in

the valid range which means 2.75 V < cell voltage < 4.2V and if the voltage is too

Page 19: MasterThesis_LinZhu

9

low compared with others, an warning will be reported and the balancing will not

be conducted

The valid lowest value will be used as the reference input for the PID controller

and a control signal u will be produced.

The control signal u will be input to a PWM generate which will generate the

balance rate

Balance rate updated to the BMS and the new cell voltage value will be used as the

feedback signal b for PID controller

The balancing process will stop when all the voltage is the same as the reference

input voltage

2.2 SOC Estimation Algorithm

SOC is the key parameter for a BMS, which is one of the most important parameters to

determine the remaining charging and discharging ability of a rechargeable battery. There

are a lot of SOC calculation algorithms available. The table below shows the characteristic

of available methods.

Name of Approach Basic method Pros Cons

Electrochemical

method

Using experiment method to

monitor the internal

chemistry interaction inside

a battery

Very accurate 1) Needs a lot of time

and many equipment

2)strict with the

environment

Coulomb counting

method

Recoding the current and

time of charging and

discharging, then do

integration of current and

time

Easy to implement the

algorithm

1) Initial SOC need to be

know

2) Inevitable

accumulation errors[12]

Open circuit

voltage method

Measure the open circuit

voltage of the battery after

the battery stay rest for a

long time(about 24 hours

[13])

Do not need to

implement algorithm

and very accurate[14]

Need a long rest time so

can’t be used in real

time[14]

Kalman filter

method

Using Kalman filter do

estimation of the SOC

1) Accurate

2) Deal with white

noise

difficult to implement

the algorithm

Table 2.1: Comparison of SOC Estimation Method

According to Table 2.1 there are three methods implemented and tested in this thesis. The

OCV approach is implemented in chapter 3, and another two methods will be introduced

and implemented in the following sections.

Page 20: MasterThesis_LinZhu

10

Coulomb Counting Approach

Coulomb Counting approach is widely used in today’s BMS since its simplicity. The

method is basically based on the formula from [15].

𝑆𝑂𝐶(𝑡) = 𝑆𝑂𝐶(0) + ∫

𝜂𝑖𝑖(𝜏)

𝐶𝑛

𝑡

0

𝑑𝜏

2-1

𝑆𝑂𝐶(𝑡): State of charge at time t

𝑆𝑂𝐶(0): Initial state of charge

𝜂𝑖: Columbic efficiency, 𝜂𝑖=1 for discharge and 𝜂𝑖 = 𝜂 < 1 for charging[15]

𝐶𝑛: Battery cell nominal capacity

𝑖(𝑡): Current at time 𝑡

When computation is done by programs using a rectangular approximation for

integration and a suitable small sampling period 𝛥𝑡 can be used to discrete formula

2-1[15], and the new discrete formula can be rewrite as:

𝑆𝑂𝐶(𝑡 + 1) = 𝑆𝑂𝐶(0) +∑(

𝜂𝑖𝛥𝑡

𝐶𝑛)𝑖𝑡

𝑡

𝜏=0

2-2

As show in formula 2-2 𝑖𝑡 is the input of the system which should be measured by a

current sensor and the SOC is the output of the system. In this BMS 𝛥𝑡 of 1 second is

chosen. Verifying the algorithm and the results will be conducted in chapter 3.

Extended Kalman Filter Approach

The Kalman Filter is the optimum state estimator used for dynamic linear systems such

as target tracking, global positioning, communication, dynamic systems etc. [16]. It is

presented by Professor Rudolf E. Kálmán in 1960. The Kalman filter comprises a set of

recursive equations which are repeatedly evaluated as the system operates. Usually a

dynamic system generates its output as a function of the past and present inputs. The

battery package is a dynamic system whose inputs include current, temperature and

output are terminal voltage. It can always regard the dynamic system as a state vector.

The state vector can present the past inputs on the system. For a battery system the state

vector includes SOC, relaxation dynamics and hysteresis effects [16] for example.

Since the Kalman filter is for linear dynamic system but the battery system is nonlinear

dynamic system so a nonlinear Kalman filter should be implemented here. There are

many Kalman filter can be used for nonlinear dynamic system for example unscented

Kalman filter and extended Kalman filter. Extended Kalman filter are chosen here because

of its good performance[17].

In extended Kalman filter the nonlinear system can be expressed as two equations [16]:

State equation:

Page 21: MasterThesis_LinZhu

11

𝑥𝑘+1 = 𝑓(𝑥𝑘 , 𝑢𝑘) + 𝑤𝑘 2-3

And measurement equation:

𝑦𝑘 = 𝑔(𝑥𝑘 , 𝑢𝑘) + 𝑣𝑘 2-4

The state equation presents the system dynamics and the measurement equation

represents the relationship of system output and system state as show in 2-3 and 2-4.

𝑓(𝑥𝑘 , 𝑢𝑘) and 𝑔(𝑥𝑘 , 𝑢𝑘) are nonlinear state transition function and nonlinear

measurement function, 𝑤𝑘 and 𝑣𝑘 are zero-mean white Gaussian noises.

As can be learned from previous introduction the battery system state vector 𝑥𝑘 is only

related with SOC since temperature is ignored here and the input is the current, so for a

battery system the state equation is:

𝑥𝑘+1 = 𝑥𝑘 − (

𝜂𝑐𝛥𝑡

𝐶𝑛)𝑖𝑘

2-5

And for measurement equation, a combined electrochemical model will be used to

represent the relationship between input and output. There are many electrochemical

models available now and they are show below[16]:

Shepherd model:𝑦𝑘 = 𝐸0 − 𝑅𝑖𝑘 − 𝐾𝑖/𝑧𝑘

Unnewehr universal model: 𝑦𝑘 = 𝐸0 − 𝑅𝑖𝑘 − 𝐾𝑖𝑧𝑘

Nernst model: 𝑦𝑘 = 𝐸0 − 𝑅𝑖𝑘 + 𝐾2 ln(𝑧𝑘) + 𝐾3ln (1 − 𝑧𝑘)

In the above models 𝑦𝑘 is the cell open circuit voltage, 𝑅 is the internal resistance, 𝐾𝑖 is the

polarization resistance and 𝐾2 and 𝐾3 are constant to fit the data from real test. So a

measure equation [16]can be concluded from above models is:

𝑦𝑘 = 𝐾0 + 𝐾1𝑧𝑘 +

𝐾2𝑧𝑘+ 𝐾3 ln(𝑧𝑘) + 𝐾4ln (1 − 𝑧𝑘) − 𝑅0𝑖𝑘

2-6

In the above equation 𝑍𝑘 is SOC.

Vmin-EKF Approach

The final task of the SOC estimation is to estimate the SOC of the battery package, and

doing EKF algorithm takes a lot of computing resources, so it is impossible to do EKF to

every single battery cell. In order to estimate the total SOC of the battery package, a

concept of 𝑉𝑚𝑖𝑛-𝐸𝐾𝐹 is proposed[6]. 𝑉𝑚𝑖𝑛-𝐸𝐾𝐹 suggest using the smallest voltage value

𝑉𝑚𝑖𝑛in the battery package as the input terminal voltage to the extended Kalman Filter. So

the total SOC estimation is the smallest voltage battery SOC estimation. This method

proposal is reasonable for this application since it is mentioned in cell balance in previous

chapter, all the cells in the battery package will be balanced according to the smallest

voltage, and the balancing will be conducted during all status of the battery package

Page 22: MasterThesis_LinZhu

12

which means the battery cells will keep in balancing status all the time. And as mentioned

before, the energy wasted in the balancing process will not be calculated in this

application since it is too small for the whole battery package. All in all, the 𝑉𝑚𝑖𝑛-𝐸𝐾𝐹

proposal is suitable and will be implemented in this application.

Page 23: MasterThesis_LinZhu

13

Chapter 3 Battery Management System Simulation

A battery simulator and a battery management system simulator are implemented in

order to verifying the control algorithm of the BMS. There are some reasons why

simulation is critical important and can’t be avoid in this application. First is the testing

cycle of a Lithium-ion battery is really long. One complete discharge and charging cycle

for the whole battery stack takes about 4.5 hours by standard discharge and charge

method, second is the result of the algorithm cannot be verified, and third is the safety

issues and last is that for advanced algorithms like EKF or sliding processing a battery

model is need to implement the algorithm.

All simulation work is implemented in Python. Python is an easy implement powerful

script language always used in prototype. Python support almost all kinds of operating

systems, the special one that need in this application is Raspbian of Raspberry Pi.

After deciding tools for simulation, a simulation a framework shown in Figure 3.1 is

proposed.

Figure 3.1: BMS Simulation Framework

As show in Figure 3.1 simulation model involves a PC, a Raspberry Pi, a BMS board and

a battery stack. They compatible with each other and can be combined together by using

UART Commands. This is a highly flexible structure which can be used for different

purposes. They are used for different purpose with different combinations. Used

combinations in simulation task are listed below:

Raspberry Pi and PC

PC, BMS board and battery stack

BMS board and battery stack

Page 24: MasterThesis_LinZhu

14

Raspberry Pi and PC combination is used for BMS algorithm development, the Raspberry

Pi will be used as a software battery which carries all information of a real battery and the

PC will act as the BMS. The second combination is PC, BMS board and battery stack

combination, it is used to validate BMS algorithm, in this combination the BMS board will

act as the battery simulator which means the BMS board is responsible for collecting all

data of the battery that needed. This combination will test all bottom layer hardware

function of the BMS board. The last combination is the BMS board and the battery stack

only, PC will be used but only act as a display.

After setting up the framework, some experiments should be conducted for developing

both the battery simulator and BMS simulator.

3.1 Charge and Discharge Experiment

The most important data should be obtained from experiment is OCV (open circuit

voltage) and cell quantity. Unfortunately the relaxation of the lithium-ion battery

chemistry lasts many hours. In conventional test to get the steady-state OCV needs 24

hours or longer to equivalent[13],so for complete record of SOC takes about 20 days. So a

quicker method is used in the experiment according to a rapid test method. Charge or

discharge 10% of battery capacity then rest for 15 minutes and then charge or discharge

again[13][12]. It can be experimental proved that 15 minutes of resting allows the battery

reaches 96% of the real OCV[18].

Charge Experiment

According to the datasheet, the battery should charge with constant current of 0.7C (3.71A)

to 4.2V and then charge with constant voltage (4.2V) until current is 50mA. Figure 3.2

shows the charging experiment equipment. The experiment involves 2 multi-meters to

measure current and voltage respectively, one adjustable voltage source and a Swing®

5300 battery.

Page 25: MasterThesis_LinZhu

15

Figure 3.2: Battery Charge Experiment Equipment

Both multimeter connect to the computer through USB and can display the recorded data

in real time. The voltage and current graphs are shown in Figure 3.3.

Figure 3.3: Charge Experiment Current and Voltage Curve

Since the multi-meter will reduce the sample rate automatically when the reading value

is 0, so in Figure 3.3 the resting time looks less than the charge time but actually resting

time is 3 minutes more.

Discharge Experiment

Discharge experiment needs a load that will draw current from the battery constantly. A

constant current load is needed for discharge experiment. Since the market available

constant current load costs too much, a self-made constant current load is used. The

constant current load is made according to Figure 3.4.

Page 26: MasterThesis_LinZhu

16

Figure 3.4: Current Load Circuit

The current load was built based on feedback control theory. It used PI demodulator to

control the conduction strength of the high power N channel MOSFET thus control the

current without static error. It is a low cost, high control precision and simple design.

The discharging current is around 3 A which means discharging will generate a lot of heat,

so the high power N channel MOSFET is installed in a big metal heat dissipation device

as shown in Figure 3.5.

Figure 3.5: Current Load

After finishing the current load, a testing experiment of the current load has been

conducted before battery discharging experiment. The experiment is to discharge the

same Swing® 5300 battery with a setting current of 2.65A for about 2 hours and recording

current of the experiment. As shown in Figure 3.6, within around 2 hours the current

varies from 2.65A to about 2.558A, the total variation is 92mA. For the calculation of the

total capacity the error is around 3.4%, and by averaging the recorded current the error

can be minimized to around 1.7% and it is acceptable for prototype.

Page 27: MasterThesis_LinZhu

17

Figure 3.6: Current Load Current Curve During Discharging

The experiment neglects the influence of the temperature since the BMS with the battery

package will be installed in the room, and according to the datasheet [19] within 0 to

45 the OCV and SOC curve will almost doesn’t change. The relationship of OCV and

quantity can be seen in Figure 3.7.

Figure 3.7: Quantity Voltage Curve

According the discharge and charge OCV and SOC graph of [18] and [20], there is no big

difference between charging and discharging in quantity voltage curve so for simplify in

the prototype charging will be regarded as the reverse process of discharging, and both

process will use the same quantity voltage look up table from discharging experiment.

2.54

2.56

2.58

2.6

2.62

2.64

2.66

0 200 400 600 800 1000 1200

Current Load Current Plot

Page 28: MasterThesis_LinZhu

18

3.2 Battery Cell Models

Black Box Model

A mathematic model of the battery can be developed from different frameworks.

Common used frameworks are: chemical modeling, equivalent electrical circuit modeling

and black-box modeling[18]. Battery model used for testing balancing algorithm is black

box model combined with equivalent electrical circuit model in this thesis. Figure 3.8

shows the electric model of the battery group.

Figure 3.8: Battery Model

There is a voltage source with an internal resistance in series which modeled a single

battery cell. 96 of these batteries connected in series models the battery stack. The voltage

source will use the data collected from the experiment and internal resistance is around

15.5mΩ according to the datasheet. But in this model it will be set to be with different

initial values for every cell in order to model the unbalanced state of the battery cell in

real life, the internal resistance will be set manual to a value that ±3mΩ of the resistance

specified in the datasheet. Every battery cell is connected with a balance resistor. The

value of the balance resistor varies from 240Ω to infinite.

There are 3 states of the battery group need to be modeled. They are charge state,

discharge state and stay stable state. In charge state, a DC source is connected to the

battery group. In discharge state, a load is connected to the battery group. In stay stable

state, the battery group remains open ended, and there is no current flow between battery

stack negative polar and positive polar. Balance can be conducted in all states and the

value of the balance resistor is tuned by the balance algorithm.

First Order Dynamic Thevenin Model

As described in previous section, the battery model used is a black box model, but there

are many limits of the simply block box model. The black box model also known as the 0th

order battery model, the most important factor it cannot represent of a real battery is the

battery hysteresis. Hysteresis is the dependence of a system output not only on its current

situation but also the past situation. Because of the hysteresis effect the battery’s OCV and

Page 29: MasterThesis_LinZhu

19

SOC function is not a one-to-one mapping, but decided by many other factors include

operating conditions, current rate and cycle history[21]. As shown in Figure 3.10 when

apply a current to a battery, the voltage changes of the battery is neither linear nor

immediately. So in order to model the nonlinear and dynamic character another

equivalent circuit battery model is introduced. It is the Thevenin model[20], the circuit of

the model can be seen in Figure 3.9.

Figure 3.9: Thevenin Model

As shown in the figure above the Thevenin model consists of a voltage source, a parallel

connected RC circuit and an internal resistance 𝑅0. The 𝑉𝑜𝑐𝑣 is the battery open circuit

voltage. The parallel connected RC circuit is used to simulate first order system dynamics.

In physics 𝑅𝑝 represent the diffusion resistance and 𝐶𝑝 represent the diffusion

capacitance[22]. 𝑉𝑡 is the terminal voltage of two poles of a battery. The system dynamic

simulation result from eispice is shown in Figure 3.10.

Figure 3.10: Voltage Response With Respect to Current Reference

Page 30: MasterThesis_LinZhu

20

Figure 3.10 shows the experiment data of the terminal voltage varies with current and

time. Combined with equations developed in chapter 2, equations can be concluded from

the new model are shown below:

V(t) = V(SOC) − (𝑉0(t) + 𝑉𝑝(t)) 3-1

Where:

V(SOC) = 𝐾0 − 𝑅𝑖𝑘 −

𝐾1𝑧𝑘− 𝐾2𝑧𝑘 + 𝐾3 ln(𝑧𝑘) + 𝐾4ln (1 − 𝑧𝑘)

G(𝑠) =𝑅𝑝

1 + 𝑠𝑅𝑝𝐶𝑝𝑖(𝑡)

3-2

Doing inverse Laplace transform of equation 3-2 .we can have:

G(𝑡) = 𝐾𝑒

−𝑡𝑅𝑝𝐶𝑝⁄

+ 𝑓(∞) 3-3

Where:

𝐾 = 𝑓(0+) − 𝑓(∞) 3-4

As shown in equation 3-3 and equation 3-4, 𝑓(∞) is the finial voltage between the

capacitor and 𝑓(0+) is the initial voltage between the capacitor. The parameters of the

Thevenin model are still unknown, but it is possible to estimate all the parameters of the

model by method presented below.

Coefficients of the open circuit voltage expressed in equation 2-6 can be identified by

experimental data based on the Least Square Root (LSR) techniques. The estimated SOC-

OCV curve and real SOC-OCV curve is shown in Figure 3.11.

Figure 3.11: Real SOC_OCV Curve and Fit Curve

Page 31: MasterThesis_LinZhu

21

As shown in Figure 3.11 the total error of the estimated curve is less than 5% which only

appears in the beginning of charging. The error is acceptable for this application. The

identified coefficients are shown in Table 3.1.

𝑲𝟎 𝑲𝟏 𝑲𝟐 𝑲𝟑 𝑲𝟒

𝟑. 𝟑𝟒𝟔𝟑𝟔 0.59164 0.00542 −0.00926 −0.06431

Table 3.1: Battery Model Coefficients Table

The internal resistance 𝑅0 of the Thevenin model can be evaluated from the immediate

effects of the current jumps on voltage variation regardless of the self-relaxation [18]. 𝑅0

can be calculated by equation below:

𝑅0 =𝑣𝑚𝑖𝑛,𝑖 − 𝑣𝑚𝑎𝑥,𝑖𝑖𝑚𝑎𝑥,𝑖 − 𝑖𝑚𝑖𝑛,𝑖

3-5

Parameters needed in equation 3-5 are clearly shown in Figure 3.10. By using least square

method the parameters can be estimated and the result is shown in table below:

𝑹𝟎 𝑹𝒑 𝑪𝒑

𝟐𝟓. 𝟔𝟒 𝒎𝜴 17.16 𝑚𝛺 340.7F

Table 3.2: Battery Model Parameter Table

3.3 SPICE Based Battery Simulator

SPICE short for simulation program with integrated circuit emphasis, it is a general

purpose open source analog electronic simulation program for nonlinear DC, nonlinear

transient and liner AC analyses[23]. It is software widely used in integrated circuit and

board-level design to check the integrity of circuit designs and to predict circuit behavior.

The electrical model of the battery cell is implemented in Python using a library called

eispice, eispice is the Python version of SPICE. Since the battery stack consists of 96 battery

cells which is complex network. So another tool, NetworkX, is used to check the

connections of the battery cells. NetworkX is a python language software package for the

creation, manipulation and study of the structure, dynamics and functions of the complex

networks[24].Figure 3.12 gives an example of the NetworkX plot of a battery stack of 6

battery cells in series and a battery stack of 96 battery cells in series.

Page 32: MasterThesis_LinZhu

22

Figure 3.12: 6 Cells NetworkX Plot and 96 Cells NetworkX Plot

Both 0th order and first order dynamic model are built by eispice. It is simple to model

the 0th order model, component used such as a resistor or a voltage source is standard

component in eispice. A simply example of eispice is given here:

cct = eispice.Circuit("Resistor Test")

cct.Rx = eispice.R(1, eispice.GND, '10n')

cct.tran('0.5n', '100n')

As shown in the code, it first defines a circuit, and then adds the component to the

circuit through the node name, and finally does a transient analysis, the voltage

between any two nodes and the current flow through any component can be obtained

after the transient analysis. This is the basic though for modeling 0th order model.

The first order dynamic model is more complicated when model in eispice. In order to

model the dynamic behavior, another two features of eispice should be introduced.

They are the behavioral model feature and combined device feature. The second model

use the eispice behavioral model, a simple example of eispice behavioral model is

shown below:

cct = eispice.Circuit("Nonlinear Time Test")

cct.Bx = eispice.B(2, eispice.GND,eispice.Voltage,'sin(2*3.14159*100e6*time)')

cct.tran('0.5n', '15n')

As the code shows above, it introduced a behavioral model and it is a voltage type

behavior, it behaves according to a sin function varies with time. The behavioral model

used in the first order Thevenin model is called PyB model (python based behavioral

model). what’s worth mention is that when doing transient analysis in the behavioral

model, the status of the model can’t be saved during the transient process, so if the

transient analysis duration is very long for example 7000 seconds used in this

application, A function called runTimeCallBack should be used to record results during

doing the transient analysis.

Page 33: MasterThesis_LinZhu

23

Another feature called Subckt is used to create combined model and then pack it to

create a new device. There are only basic electrical elements in eispice like capacitor,

resistor etc. In order to have a customized component such as a battery, the Subckt

model should be used. In this model Subckt is used to create a component of the Swing®

5300 battery cell.

3.4 Battery Management System Simulator

BMS simulator implemented 2 important algorithms for the BMS. One is the balance

control algorithm and another is the SOC calculation algorithm. BMS simulator also

implemented a battery management system routine.

BMS Flow Chart

The overall BMS works as flow chart shown below:

Figure 3.13: BMS Control Diagram

BMS will first read all status of the battery stack including battery cell OV or UV (over

voltage or under voltage) flags, battery cell voltages, battery stack temperatures, and

battery stack total voltage, total current and current time of the system. Then it will check

the error status, if there are any errors, it will open the connection between the battery

stack and the load, and then continue to processing the command. It will process

command from the Energy Hub and also from UART. After finished processing the

commands it will do balancing and finally do SOC estimation.

As the simulation framework shown in Figure 3.1, the communication between all 3 parts

will use UART commands. The difference of UART commands between the STM32

Page 34: MasterThesis_LinZhu

24

software and the BMS simulator is that BMS simulator use the command to schedule the

tasks of the BMS. A self-defined UART commands table is shown below:

Table 3.3: UART Commands Table

The UART commands table listed all the UART commands used both in the simulator

and the STM32. With this mechanism the battery simulator, BMS simulator and the

STM32 can communicate with each other. So it is very easy to realize any combination

shown in Figure 3.1.

Example

Command

Command

meaning

Command

meaning

Command meaning Comments

V102 V: Read voltage 0~7: stack

number(old

voltage sample)

02: cell number

T102 T: Read

temperature

0~7: stack

number(old temp

sample)

00: means read

external temperature

01: means read

internal temperature

Only for BMS

board

8: get new

temperature

samples

00:no meaning Only for BMS

board

F001 F:read flag 0~7:stack

number(old flag

sample)

00:FLGR0, 01:FLGR1,

02:FLGR2

Only for BMS

board

8:get new fag

samples

00:no meaning

P001xxx P:receive the PWM

rate

0~7:stack

number(old flag

sample)

01: cell number xxx: PWM rate,

varies from 0 to

100

B102 B: Balance cells 1: stack number 02: cell number

S102 S: Stop balance

cells

1: stack number 02: cell number Only for BMS

board

R000 R:read total

voltage

0:no meaning 00:no meaning

I000 I:read total current 0:no meaning 00:no meaning

C000 C: close the relay 0:no meaning 00:no meaning

O000 O:open the relay 0:no meaning 00:no meaning

J000 J:read current time 0:no meaning 00:no meaning Only for BMS

simulator

K000 K:kill the

simulation

0:no meaning 00:no meaning Only for BMS

simulator

Page 35: MasterThesis_LinZhu

25

Extended Kalman Filter Implementing Steps

For now all the parameters of the model have been solved and the model has been built

in eispice. So EKF SOC estimation algorithm can be tested for now. Before implementing

the algorithm in real code some preparations should be done. The first preparation of

implementing the EKF is to discrete the battery model. A brief summary of the discrete

form of the model’s state equation and the output equation are given below.

The state equation:

𝑆𝑂𝐶(𝑡 + 1) = 𝑆𝑂𝐶(𝑡) +

𝜂𝑖𝛥𝑡

𝐶𝑛𝑖𝑡

𝑉𝑝(𝑡 + 1) = 𝑒(−𝛥𝑡𝑅𝑝𝐶𝑝

)𝑉𝑝(𝑡) + 𝑅𝑝[1 − 𝑒

(−𝛥𝑡𝑅𝑝𝐶𝑝

))]𝑖𝑡

3-6

The output equation:

𝑉𝑚𝑖𝑛(t) = 𝑉𝑜𝑐𝑣(SOC(t)) + 𝑉𝑝(t) + 𝑅0𝑖𝑡 3-7

All the parameters in equation 3-6 and equation 3-7 are the same as those used in previous

equations, 𝛥𝑡 is the sample time internal and 𝑘 is the time index.

The second preparation to implement the extended Kalman filter is to linearize both

𝑓(𝑥𝑘 , 𝑢𝑘) of state equation and 𝑔(𝑥𝑘 , 𝑢𝑘) of measurement equation respectively. 𝑓(𝑥𝑘 , 𝑢𝑘)

and 𝑔(𝑥𝑘 , 𝑢𝑘) can be linearized by a first-order Taylor-series expansion[25][16]. The

flowing equations show the way to linearize both equations.

𝑓(𝑥𝑘 , 𝑢𝑘) ≈ 𝑓(𝑥𝑘 , 𝑢𝑘) +

𝜕𝑓(𝑥𝑘 , 𝑢𝑘)

𝜕𝑥𝑘|𝑥𝑘=𝑘

(𝑥𝑘 − 𝑥𝑘)

3-8 𝑔(𝑥𝑘 , 𝑢𝑘) ≈ 𝑔(𝑥𝑘 , 𝑢𝑘) +

𝜕𝑔(𝑥𝑘 , 𝑢𝑘)

𝜕𝑥𝑘|𝑥𝑘=𝑘

(𝑥𝑘 − 𝑥𝑘)

Combined with equation 3-6 we have:

𝑘 =

𝜕𝑓(𝑥𝑘 , 𝑢𝑘)

𝜕𝑥𝑘|𝑥𝑘=𝑘

= [1 0

0 𝑒(−𝛥𝑡𝑅𝑝𝐶𝑝

)]

3-9

𝑘 =𝜕𝑔(𝑥𝑘 , 𝑢𝑘)

𝜕𝑥𝑘|𝑥𝑘=𝑘

= [ 𝑑𝑉𝑜𝑐𝑣(𝑠𝑜𝑐)

𝑑𝑠𝑜𝑐|𝑠𝑜𝑐=𝑠𝑜𝑐(𝑘)

−1]

Combined with equation 2-6, we have:

𝑑𝑉𝑜𝑐𝑣(𝑠𝑜𝑐)

𝑑𝑠𝑜𝑐|𝑠𝑜𝑐=𝑠𝑜𝑐(𝑘)

= 𝐾1 −𝐾2𝑠𝑜𝑐2

+𝐾3𝑠𝑜𝑐

−𝐾4

(1 − 𝑠𝑜𝑐)

3-10

A table of parameters used in Kalman filter is presented below:

Page 36: MasterThesis_LinZhu

26

Kalman Filter Parameter Meaning

𝑿 Kalman filter input matrix

𝒀 measurement output matrix

𝑷 state covariance matrix

𝑸 process noise covariance matrix

𝑨 state matrix

𝑼 measurement matrix

𝑪 observation matrix

𝑹 measurement noise covariance matrix

𝑳 Kalman gain matrix

Table 3.4: Kalman Filter Parameters Table

All the symbols used in Kalman Filtering can be found in Table 3.4.

Figure 3.14 shows the system block diagram of a system with measurement noise in space

form, it clearly shows how every parameter of Table 3.4 in Kalman filter is used.

Figure 3.14: System Block Diagram

After all preparation work is finished, implementing the extended Kalman filter in python

can be conducted as following steps[26][25]:

Step 1: initialize input matrix, state matrix, observation matrix, and the three covariance

matrix. For K=0, set

𝑥0 = 𝐸[𝑥0]

𝑃𝑥0 = 𝐸[(𝑥 − 𝑥0)(𝑥 − 𝑥0)𝑇]

In this step the initial value of initial SOC and the value of 𝑉𝑝 and the state covariance

matrix 𝑃 are set.

Step 2: state estimation time update:

𝑥𝑘− = 𝑓(𝑥𝑘−1

− , 𝑢𝑘)

𝑃𝑥𝑘− = 𝑘−1𝑃𝑥𝑘−1

− 𝑘−1𝑇 + 𝑄𝑥

Page 37: MasterThesis_LinZhu

27

In the second step the input value of matrix 𝑋 has been updated as well as the process

covariance matrix 𝑃.

Step 3: measurement update:

𝐿𝑘 = 𝑃𝑘𝑘𝑇[𝑃𝑘𝑘

𝑇 + 𝑅𝑘]−1

𝑥𝑘+1 = 𝑥𝑘 + 𝐿𝑘[𝑦𝑘 − g(𝑥𝑘−, 𝑢𝑘)]

𝑃𝑘+1 = (𝐼 − 𝐿𝑘𝑘)𝑃𝑘

In this step first is to compute the Kalman gain matrix 𝐿 , and then update the state

matrix 𝑋, finally update the process covariance matrix 𝑃.

The process of Kalman filter is a converge process, the estimated voltage will converge to

the truly measure value after several iteration. And the estimated SOC will converge to

the true value as well. To conclude the implementation steps for a Kalman filter, a flow

chart is shown in Figure 3.15

Figure 3.15: Extended Kalman Filter Implementation Flow Chart

The EKF algorithm is a recursive and converge process, the output SOC value will

converge to true value after several iterations.

Page 38: MasterThesis_LinZhu

28

3.5 Simulator Interface

Interface Architecture

The BMS is used for an Energy Hub which is monitored by a computer, so an interface is

designed for convenient monitor and easier control. When considering the fast developing

and advanced web technology used for this kind of application, a web based interface is

developed for this application for extend future development.

The following aspects are taken into consideration when choosing a web based GUI:

Using web technology such as HTML5, CSS and JavaScript, will be much more

flexible compared with native GUI toolkit such as Tkinter in Python or other kind

of GUI tools. There are many libraries such as Bootstrap and Jquery can be used to

build decent interfaces.

Web GUIs can be exposed to the LAN or internet, it can be rendered by most

modern browser, and even be accessed by mobile devices such as mobile phone

and tablets.

Web application using Python is easy to port single-board computers, such as

Raspberry Pi and BeagleBoard. This will make the device more portable and more

like a handy device.

There are mainly two blocks in web based interface architecture, they are frontend and

backend. Frontend is responsible to format the display content in the web page and

backend is responsible for functionality realization, communication, battery simulation,

BMS simulation etc. The following block-diagram shows the basic structure of our web

based GUI.

Figure 3.16: Overall Structure of Web Based GUI

As shown in figure above, the frontend and backend are connected and communicate

through TCP/IP communication protocol via Ethernet.

Page 39: MasterThesis_LinZhu

29

Frontend of the Interface

The final web GUI is shown in figure below.

Figure 3.17: Battery Simulator Dashboard Interface

As the Web GUI in Figure 3.17 shows, there are 3 parts in the web page. The upper part is

a control section, there are pull down menus for basic information about the application,

manuals of the application and the administration information. In upper left there are 3

push bottoms, the left blue one is used to pause the simulation job, the middle one is to

terminate the simulation job and the right green one is the bottom to control and display

the status of the series port.

The left side bar is used for switching to different functions. There are three functions

available in the application. They are the dashboard, simulation jobs and the logs. The

dashboard tab is to display the information of the BMS. The simulation jobs tab is the

control interface of the BMS and the logs tab is used to retrieve the logs of the battery

simulation. When in the dashboard tab the information of the BMS is shown in the middle

of the web page. In the middle section the top part shows two meters which show the total

voltage and the total current of the battery package. Below the meter is a bar graph shows

information of individual of the battery cell, the battery cells are index as the stack number

and the cell number, and the information including voltage, quantity, SOC and cycles,

they will be displayed in the end of the bar.

Page 40: MasterThesis_LinZhu

30

The Web GUI can also control the BMS through a simulation interface. Figure 3.18 shows

the simulation jobs interface. In the middle of the web page, different simulation jobs can

be chosen from the library, after load the simulation job from the library press the “Send

to Simulator” bottom and the battery simulator will start simulate the chosen simulation

job.

Figure 3.18: Battery Simulator Simulation Jobs Interface

As shown in Figure 3.18 it is now simulate the discharge process, and the simulation code

is written in Python. The simulation job can be paused or terminated using the buttons

on the top of the webpage as introduced before.

Backend of the Interface

The application is implemented through a web server named Bottle. Bottle is a fast, simple

and lightweight WSGI micro web-framework for Python[27]. It connects the web GUI

with the battery simulator which is implemented in Python. Here is a simple example of

Bottle code[27]:

from bottle import route, run, template

@route('/hello/<name>')

def index(name='World'):

return template('<b>Hello name</b>!', name=name)

run(host='localhost', port=8080)

Page 41: MasterThesis_LinZhu

31

This piece of example code is doing a route to a server. The route() function will return a

function to the local host.

JavaScript is used to fulfill the functions of the application, HTLM5 and CSS are used for

formatting the display content of the web page. What is worth mention is the AJAX

technology. AJAX, short for asynchronous JavaScript and XML, is a group of interrelated

web development techniques used on the client-side to create asynchronous Web GUI[28].

AJAX technology is needed for the battery simulator Web GUI because the information of

the battery is updated all the time.

The web GUI has a powerful interactive function which is all implemented by JavaScript.

It realizes functions like terminate simulation, chosen file from library etc. Here is a simple

example of load command into widget function JavaScript code from the source code:

function load_into_command_widget(gcode, name)

$('#command_list_name').val(name);

$('#command_program').val(code);

$('#command_program').trigger('blur');

The piece of code sets vision effect for the command widget when user loads a new

command.

3.6 Simulation Results

PID Balance Controller

Parameters tuning and total algorithm verify of the PID balance controller is done in

battery simulator. Balancing experiment is conducted using 2 stacks of battery cells, since

8 stacks takes more time and it will generate too much data which is not convenient to

analysis. 2 stacks of battery cells are enough to verify algorithm. As shown in Figure 3.19

there are 24 battery cells and the voltage varies from 4.016V to 4.035V.

Page 42: MasterThesis_LinZhu

32

Figure 3.19: Unbalanced Battery Cells

Battery simulator simulated about 5 hours in real life time, After about 5 hours’

balancing ,the result can be seen in Figure 3.20.

Figure 3.20: Cell Voltage during Balancing

As can ben seen in the graph, the voltage of each battery cells is the same as the lowest

voltge cell after the balancing process. A problem will occur in the process of balancing is

that it may over balancing the battery cells accord to the method described above. This

means the battery cell will continue balancing when one of the cell’s terminal voltages is

less than the previous smallest voltage between time intervals of sampling the voltage. By

having a faster sampling rate this can be solved, this is another reason why balance is

Page 43: MasterThesis_LinZhu

33

conducted in high frequency. The simulation result shows that the PID balance control

algorithm can make the battery stack in balanced state.

The problem remains for PID balancing algorithm is that the parameters for the PID

controller is not tuned yet, since the test cases used in simulation showed that different

parameters used in the controller make no difference since the time duration is very long.

Tuning parameter for the PID controller will be left as future work when doing

experiment with the real battery cells.

Coulomb Counting

The result of performance of Coulomb counting algorithm of a complete cycle of

discharging is shown in Figure 3.21 and Figure 3.22.

Figure 3.21: Estimated SOC and Real SOC Comparison in Ideal Condition

As shown in Figure 3.21 the estimation error goes bigger with time, even without

unknown initial SOC error and any measure noise, at the end of discharging the error

reached to about 20%.

Since the current sensor of this BMS hardware is a Hall Effect sensor and for this kind of

sensor noises is inevitable and even zeroes drift. So in order to simulate the real situation

a white Gaussian noise with mean of 300mA and exception of 0.25 is added.

Page 44: MasterThesis_LinZhu

34

Figure 3.22: Estimated SOC and Real SOC Comparison with Noise

As shown in Figure 3.22 the estimation error grows steadily with time and at the end of

one complete discharge cycle the error reached approximately 20%.

So the conclusion of Coulomb counting algorithm is that this algorithm is very limited

and it is not suitable for a constant charging and discharging application which need

accurate information of SOC.

Extended Kalman Filter

The extended Kalman filter is tested for half cycle of discharging, since the last 20% SOC

is hard to estimate, it is tested together with the Coulomb counting algorithm. The result

is shown in Figure 3.23 :

Page 45: MasterThesis_LinZhu

35

Figure 3.23: SOC Estimation Result

As can be seen from the graph, the Coulomb Counting estimation algorithm have a steady

increase error with time, and the initial state of the SOC makes the estimated SOC have

an initial error. On the other hand the EKF estimated SOC converge to the real SOC very

soon, even with a much bigger initial SOC error than Coulomb Counting it is almost the

same with the real SOC in less than 3 minutes. The final estimation result turns out that

the total estimation error is less than 2%, which is much better than the 5% requirement.

Page 46: MasterThesis_LinZhu

36

Chapter 4 Hardware Implementation

4.1 Hardware Overview

The first version of hardware is available when the thesis work starts. Figure 4.1 below

shows the functionality blocks of the BMS hardware.

Figure 4.1: System Block Diagram

AS shown in Figure 4.1 the BMS is controlled by a STM32 microcontroller. There are 8

battery monitor chip to monitor the voltage, temperature, etc. for individual battery cells.

The battery monitor chip also takes responsibility to protect the cells and balance the cells.

There are separate voltage sensor and current sensor monitor the total voltage and the

current. 5 different power supplies are implemented in the system to make sure the safety,

the 5 different power supplies including air-core DCDC converter, relay interlock chain,

MCU power supply and so on. An 8 Kb serial CMOS EEPROM is used to store data and

a serial port is implemented for general communication purpose. CAN bus is used for

communication with the Energy Hub.

The real hardware is shown in Figure 4.2, the figure shows the BMS PCB board and the

BMS with 96 Li-ion battery cells installed without the top board (used for connecting the

battery in serial with each other).

Page 47: MasterThesis_LinZhu

37

Figure 4.2: BMS PCB board and BMS with Battery Cells

4.2 Hardware Function Blocks

Power Supply

There are 5 different power supply circuits in the BMS board. They are power supply

input, power supply for MCU, power supply for relay interlock chain, power supply for

the high DC voltage isolated part and power supply for the power removal sensor part.

Relay interlock chain is used for safe and spark free disconnect and connect the battery

group positive termial from the load. As can been seen in Figure 4.3 there are two relaies

in the chain, the Panasonic AEV-series relay is used for disconnect and connect battery

group, and the IM series relay is used for control the Panasonic relay. IM relay is powered

by 12V which is separate from the main 5V supply. The IM relay is controlled by STM32

through transistor BC847C. The STM32 will control on and off of the IM relay thus control

the Panasonic relay.

Page 48: MasterThesis_LinZhu

38

Figure 4.3: Relay Interlock Chain

Microcontroller

STM32F103RCT6 is the control unit of the BMS. Accord to the datasheet it is a 32-bit MCU

with 256 KB flash memory, 64 pins and can operate normal from -40 °C to 85 °C. There

are I2C, SPI, CAN, UART and JTAG interface we need for our application.

STM32F103RCT6 has 3 12-bit AD converters and 4 timers. As shown in Figure 4.4 the

microcontroller is power by VDD_MCU which is 3.3V and an 8 MHz crystal is used as

system clock input.

Figure 4.4: Microcontroller

Current Sensor

A Hall Effect current sensor ASC710 is used for measuring the total current. The current

sensor circuit is shown in Figure 4.5. ASC710 has high noise performance and high voltage

isolation which is need for this application. The chip also has overcurrent fault report

feature and user-adjustable overcurrent fault level. The sensitivity of the sensor is 56mV/A.

ASC710 output voltage signal which is proportional to the current flows over the chip and

the voltage signal goes directly to the STM32 AD converter.

Page 49: MasterThesis_LinZhu

39

Figure 4.5: Current Sensor

Total Voltage Sensor

Total voltage of the battery group varies from 264V to 403.5V by normal operation. As

shown in Figure 4.6 an amplifier TS274CDT is used. TOS(top of stack) and BOS(bottom

of stack) are connected to the differential input of the amplifer and the amplifier output is

connected to the STM32 12-bit AD converter. The reference voltage of the STM32 AD

converter is 3.3V, by calculation the output range of the amplifier circuit is from 2.025V to

1.2V which equals 405V to 240V between BOS and TOS.

Figure 4.6: Total Voltage Sensor Circuit

Lithium-ion Battery Cell

In this application the Li-ion battery cell chosen comes from Boston Power ®, the

particular battery cell is Swing®5300 rechargeable Lithium-ion cell. It is featured by its

high energy density and long cycle life and unmatched safety. Its typical application

include battery electric vehicles, stationary energy storage etc. Figure 4.7 shows the cell.

Page 50: MasterThesis_LinZhu

40

Figure 4.7: Rechargeable Lithium-ion Cell under Test

The basic parameters from the datasheet [29] of the battery cell are given in Table 4.1

Nominal capacity 5300 mAh

Nominal energy 19.3 Wh

Nominal voltage 3.65 V

Nominal cell impedance 15.5 mΩ

Cycle life

(0.5C discharge at 23°C)

100% DOD >1000 cycles

90% DOD >2000 cycles

80% DOD >3000 cycles

Table 4.1: Parameters of Lithium-ion Cell under Test

Battery Cell Monitor Circuit

SPI Daisy Chain

Battery monitor chip used in this BMS is LTC6803-3 from Linear Technology. It is an IC

for monitor the behavior of rechargeable batteries. One chip can monitor up to 12 battery

cells in serial. The chip has a stackable architecture which means with several chips stack

up it can monitor more battery cells. For this BMS 8 chips are used to monitor 96 battery

cells, each chip monitor 12 cells. The communication between LTC6803-3 and STM32 and

the communication through all the LTC6803-3 chips uses SPI communication, the

communication speed is up to 1 MHz. SPI short for serial peripheral interface bus named

by Motorola, it is full duplex serial communication in master/slave mode[30].some

products with SPI interface are designed to be capable of connecting in a daisy chain. In

electrical engineering a daisy chain is a method of propagating signals along a bus in

which the devices are connected in serial[31].Figure 4.8 shows a 3 chip stack daisy chain.

As shown in the figure the clock and chip select single are controlled by the master and

all slaves share the same signal from the master. The Master out Slave in (MOSI) and

Master in Slave out (MISO) signal formed a chain which starts from STM32 MOSI to

LTC6803-3(T) MOSI then to LTC6803-3(T) MISO then to LTC6803-3(M) MOSI etc. and

finally back to STM32 MISO.

Page 51: MasterThesis_LinZhu

41

Figure 4.8: Daisy-Chained STM32 Master and LTC6803-3 Slave

In this BMS 8 LTC6803-3 is stacked, Figure 4.9 show the LTC6803-3 daisy chain circuit, the

chip has a high side SPI and a low side SPI, the high side SPI is used for communication

with the upper stack and the low side SPI is for the lower side.

Page 52: MasterThesis_LinZhu

42

Figure 4.9: LTC6803-3 Daisy Chain

High Voltage Isolation Circuit

Since the LTC6803-3 is connected directly to the high voltage DC so it cannot connect to

the STM32 directly. An isolation IC is used for safety purpose. SI8441AB is a fast digital

isolator which can isolate up to 2500 VRMS and operate up to 150 Mbps. Figure 4.10 shows

the isolation circuit. As shown in the figure the chip is powered by 2 different power

supplies, the low voltage part is powered by 3.3 V VDD_MCU which is the same with

power to STM32, and the high voltage part is powered by 5V VDD_ISOLATED. The other

pins are connected to SPI port respectively.

Page 53: MasterThesis_LinZhu

43

Figure 4.10: Isolation Circuit

Temperature Measure Circuit

Expect the SPI communication, the battery monitor chip can measure battery cell voltage,

temperature and balance battery cell features. A negative temperature coefficient (NTC)

thermistor NTCS0805E3104 is used to sensor the temperature. The battery monitor chip

has onboard temperature sensor and thermistor, the thermistor input connect to a 12-bit

ADC. As shown in Figure 4.11, the thermistor with another resistor makes up of a voltage

divider.

Figure 4.11: Temperature Sensor Circuit

The input voltage of the thermistor can be known easily when knowing the reference

voltage. The resistor of the thermistor can be calculated with the formula below:

𝑅𝑡 = 𝑅 ∗ 𝑒(𝐵∗(1/𝑇1 − 1/𝑇2)) 4-1

𝑅𝑡 : The resistance of the thermistor when temperature is 𝑇1

𝑅: The resistance of the thermistor at 𝑇2 which is room temperature

𝐵: The coefficient of the thermistor

From the equation above we can get the temperature of the thermistor.

Page 54: MasterThesis_LinZhu

44

Battery Cell Balance Circuit

Beside the temperature acquization feature another important feature is the balance

feature. The balance feature of LTC6803-3 is passive balance. Figure 4.12 shows the

blancing circuit.

Figure 4.12: Battery Cell Balance Circuit

The battery cell is connected between pin C(n) and C(n-1), S(n) is the pin to control on/off

of the balance switch, when S(n) is high the battery cell will connect to the dissipative

resistor.

Other Functional Blocks

CAN Bus Circuit

CAN bus short for controller air network bus is a vehicle bus standard designed to allow

microcontrollers and devices to communicate with each other within a host computer[32].

Due to its fast speed, long distance transporting, good noise performance, it is widely used

in industry which does not limited to vehicles. In this application the CAN bus is

implemented to communicate between the BMS and the Energy Hub. The main reason

for this is because the off-sale product in the market is implement by CAN bus according

the pervious market investigation, in order to be compatible with available products,

CAN bus is implemented in this application.

The STM32 has CAN engine with it, a CAN transceivers is needed. Figure 4.13 shows the

CAN transceiver circuit.

Page 55: MasterThesis_LinZhu

45

Figure 4.13: CAN Transceiver Circuit

There are only two signal wires for CAN communication, CAN_H and CAN_L. CAN_H

and CAN_L are differential signal and they are connected together by a terminal resistor

which is used for prevent the signal reflect. Synchronization in CAN communication is

done by diving each bit of the frame into a number of segments: synchronization,

propagation, phase1 and phase 2 [32] which is called bit timing. The other side of the

transceiver is connected to STM32 CAN mode directly.

The hardware of CAN transceiver is simple but the communication protocol which should

be compatible with the available products in market is a topic should be researched.

Supply Power Removal Sensor

Information such as SOC, charge time and so on needs to be stored to EEPROM when the

supply power is removed. So a supply power removal sensor is designed. The sensor used

another channel of the TS274CDT which is used to sensor the total voltage also. As shown

in Figure 4.14.

Figure 4.14: Supply Removal Sensor

V+_IN is the 5V supply power and V+_LDO is the input of the differential amplifier. If the

supply power is removed, then there will be a high signal out from the differential

amplifier. The output of the amplifier is connected to the STM32 directly. There are also 2

Page 56: MasterThesis_LinZhu

46

capacitors used to store energy in case of the supply is removed. By calculation there is

approximately 50ms before the VDD_MCU drops to 3.3V. So whenever the STM32

sensors the high input from the amplifier, important information should be stored. The

time before VDD_MCU drop to 3.3V can be maximized by disable all unnecessary

peripherals when the interrupt is sensed.

EEPROM Circuit

An 8 Kb EEPROM is used to store needed data. The EEPROM store circuit can be seen in

Figure 4.15. The chip can be powered from 1.5V to 5V and communication with STM32 is

implemented by I2C. I2C short for Inter-Integrated Circuit is a multi-master serial single-

ended bus used for attaching low-speed peripherals to motherboard[33]. I2C bus speed is

usually 100 kb/s.

Figure 4.15: EEPROM Circuit

JTAG port for testing software for STM32 and UART port used for general purpose

communication with STM32 is directly connected to STM32 alternative function ports

respectively. No further driver circuit is needed.

4.3 Hardware Drivers

Develop Environment

Software for STM32 is written in C, complier used is GCC for ARM embedded. Eclipse

IDE is used as an editor, and build work is done by another small tool named Scons. Scons

is a software construction tool which is a superior alternative to the classic “Make” build

tools. Scons is implemented as a Python script and easy understand by its program style.

ARM-USB-OCD-H from Olimex is used for download program and debugging. It is a

high speed JTAG support up to 4 breakpoints when debugging.

Programming STM32

STM32 needs a large number of libraries to get started. All libraries needed for driving the

microprocessor can be downloaded from ST website. Usually first step of programing a

Page 57: MasterThesis_LinZhu

47

microprocessor is to setup the debugging environment. Common used debugging

methods are controlling a pin which connects to a LED and controlling the UART port to

output something from the microprocessor. When using UART to get communication

with STM32, a RS232/TTL to USB converter is needed for most laptop today and a super

terminal should be installed in the computer. After all the setting up is, programming job

can be started.

In this application need firmware of STM32 include GPIO,UART, I2C ,SPI ,ADC ,CAN ,

timer and DMA.GPIO(General Purpose Input Output) is for controlling the pins of the

microprocessor. DMA (Direct Memory Access) is a fast method to store input data to the

microprocessor. It is always used together with ADC, SPI RAM etc. Timer is used to

control the time, always used together with NVIC (Nested Vectored Interrupt Controller)

or to generate control signal. ADC is used to converter analog signal to digital signal. All

other firmware is used for communication with other chips or devices.

Every function unit should be set to desired mode when using. Usual set up procedure is

as follows:

Set GPIO (match to the right pin and set the right mode of the pin)

Set clock (match to the right clock source and set to the right frequency)

Set individual function parameter(according to the requirement configure the unit

properly)

LTC68030-3 is the most complex chip in the design, to drive this chip properly there are

some suggestions:

Make sure the communication speed of the SPI port no more than 1MHz

Pay attention to the Packet Error Checking feature and use proper command to

drive different functions

A watchdog timer is enabled on measure mode and a “feed dog” signal with

frequency of 1Hz should be giving when doing balancing

Debugging and Tuning Hardware

Since this is the first version of the hardware, there are many places needs to be improved

and also some design errors should be fixed. Usual tools to debugging hardware are

multi-meter and oscilloscope. Since the special condition, high DC voltage, exists in the

system and the hardware is un-debugged, so infrared camera is used as an extra tool. IR

camera is very effective to check short circuits since short circuit generate much more heat

than normal state. Figure 4.16 shows an IR camera picture when a battery monitor chip is

short circuit.

Page 58: MasterThesis_LinZhu

48

Figure 4.16: Infrared Camera Figure

With the help of these tools, debugging working can be much more easy and effective.

When the hardware can run there are still some tuning jobs to make the hardware working

better, for example calibrate an AD converter or tuning delay time for communication etc.

when all drivers for all necessary hardware are finished, the next step is to testing all the

hardware together in a loop in the main function to make sure each block of software is

compatible with each other.

The main loop flow chart of STM32 is the same as shown in Figure 3.13. How to realize

the follow chart in STM32 is another topic need to mention. All the processes can be done

in a while loop in main function except processing command. It is based on the interrupt

mechanism. There are 60 external interrupt channels available for STM32F103RC, they

can be configured to 16 different priority levels according to necessity[34]. Interrupt used

in this application include timer interrupt, UART interrupt, CAN interrupt and GPIO

interrupt.

Another technology used to schedule the BMS tasks is the semaphores. Semaphore is an

abstract data type used for simple abstraction for controlling access by multiple processes

to a common resource[35]. It works just like the flag bit .semaphore is used to control the

access the battery monitor chip. Since the balancing algorithm is executing all time, and

some other functions for example reading over voltage or under voltage flags, reading

temperature of the battery stack also need to access the battery monitor chip, so the

semaphore is used to prevent the master to access the same slave at the same time.

Page 59: MasterThesis_LinZhu

49

Chapter 5 Analysis and Evaluation

In this chapter, a simple analysis of the result of the thesis will be presented. The testing

methods of software and hardware will be listed in details, and brief evaluation of both

software and hardware will be presented also.

5.1 Research Result Analysis

Delivery of the thesis can be separated into two parts, the simulation part and the

hardware implementation part. According to the requirement, the functionality design is

all fulfilled. At the end of the thesis, the BMS has functionality of monitor individual cell

voltage and temperature, monitor total voltage and total current of battery stack;

over/under voltage, over/under temperature and over charging/discharging current

protection and warning function; report state-of-charge, balance the battery package and

communicate with upper systems. All those functions are verified in simulation and

hardware. The most important two algorithms, namely the battery package balancing

algorithm and the SOC estimation algorithm, are the main delivery of the thesis. A PID

control algorithm based battery package balancing algorithm can balance an unbalanced

battery package. The error of the SOC estimation algorithm is below 5 % which fulfilled

the requirement.

Beside those mentioned above achievements, there are also some issues need to be

discussed and reconsidered. Since the BMS runs in STM32 is a different implementation

of the simulation software, so main concerns will be put on the simulation part. The first

issue is the battery model used in the simulation. The finally model chosen for the

Lithium-ion battery used is a first order dynamic Thevenin mode, as mentioned in

previous chapter the first order dynamic Thevenin mode can represent the nonlinear and

dynamic character of the battery, but it is not precise enough to reflect those characters,

according to research result from[36], the precision of second order is less than 9.5% and

the first order is only less 19%. The second major concerns is the criteria for being balanced

is not discussed in detail in the thesis, the only criteria used in judging whether the battery

package is being balanced is the terminal voltage of the battery cell. As suggested in [37],

a more precise way of balancing battery cells is to use the individual SOC value. But in

reality it is difficult to estimate SOC for every cell. If using Coulomb Counting approach

the SOC value will be too inaccurate, if using EKF approach the computation load will be

too heavy for the microprocessor. As can be seen the QV curve in Figure 3.7, the quantity

and open circuit voltage is not liner, a more sophisticated way should be developed,

which can combine both terminal voltage and battery quantity.

Page 60: MasterThesis_LinZhu

50

There are also some issues towards only hardware implementation should also be discuss,

the first question is whether the BMS implemented in STM32 need a Real Time Operating

System (ROTS) to handle all the tasks. On one hand is that without an ROTS the system

will be easier to implement and there will be less collision in time within the system. On

the other hand, there are many tasks in the BMS and the BMS is a real time system which

needs to update the information all the time, by using only NVIC in STM32 will make it

very complicated to set the priority of the interrupts and using too many interrupts will

also cause collision. At the end of the thesis, the BMS is not finished implemented as a

stand-alone automotive system, it only works in different functional blocks separately, so

the time during for each tasks, how the BMS should behave as an automatic system and

how time critical each task are should be investigated before making the decision of using

a ROTS or not.

5.2 Simulation Software Evaluation

The steps of testing the simulation software are as follows:

1. Start the web GUI, wait until the web page is opened in the web browser, it will

start the battery simulator.

2. Go to the simulation job tab and load the initial.py file from the library then send

the initial job to the simulator.

3. After the initialization is down, start the BMS simulator.

4. Load the discharge.py file from the library and send it to the battery simulator.

5. After the simulation is down, the battery simulator will terminated automatic, all

the data is stored in separate files.

6. Analysis the collected data.

The software simulation software not only fulfilled the tasks of verify control algorithms

for the BMS, the web GUI design even makes the simulation software a sale point for the

BMS on the market. It is an eye catching point for the customer and the GUI makes the

customer understand the BMS better. What’s more the GUI user interface is a multi-

platform application, it can run directly in many platforms including normal PC,

embedded systems for example Raspberry Pi, BeagleBone board etc. and it can run in

most severs. That means it can use as the interface of the finally product that runs in the

upper system of the BMS in this case is the Energy Hub.

5.3 Hardware Evaluation

The steps of testing the BMS boards are as follows:

1. Assemble all the battery cells in the grid, check all the battery’s polarity then put

on the top board and checking the connection of every cell.

Page 61: MasterThesis_LinZhu

51

2. Set the DC voltage supplier to 5V with current limit of 0.3A, plug in the UART to

USB dongle, turn on the super terminal and set all terminal parameters correctly

3. Turn on the STM32 power switch and read the output from the terminal.

4. After confirming status of the battery package, connect the battery package with a

load which shown in Figure 5.1. It is a heater which has 3 levels, 32 Ω, 64 Ω and 96

Ω, it has an independent power supply of a fan to dispatch the heat of the heater.

Use 96 Ω level to discharge first.

Figure 5.1: Discharge Load

5. Monitor the status of the battery package, record it, and stop the discharging after

30 minutes.

6. Analysis the collected data and compare with the simulation result.

Though the hardware of BMS have some design errors, the functionality of the BMS

satisfied the requirements, the current version of the hardware supported the

realization of a BMS of basic functionality. Errors in the hardware design should be

fixed and more features should be added.

Page 62: MasterThesis_LinZhu

52

Chapter 6 Conclusion and Future Work

6.1 Software Conclusion

Finished software tasks are listed below:

1. A working 0th order battery package model with balance resistors.

2. A working first order Thevenin battery package model with balance resistors.

3. A BMS simulator with PID balance control algorithm, Coulomb Counting

algorithm and EKF SOC estimation algorithm and BMS control routine.

4. An interactive web GUI for battery simulator.

Except the finished parts above, both the simulation software and STM32 software need

to be improved and the suggestions are listed here:

1. The battery model should be recalculated with more experiment data collected in

a more scientific way.

2. Some parameters of the EKF should be tuned.

6.2 Hardware Conclusion

Until the end of the thesis finished parts of hardware working is listed below:

1. BMS PCB board debugging.

2. Power supply control unit driving, relay chain controlling, power removal

detecting and other miscellaneous functions realizing.

3. UART communication port driving, CAN bus communication port driving and

SPI communication port driving

4. Battery monitor chip capable of reading all cell voltage, reading all over voltage

and under voltage flags, read on chip and board temperature, balancing battery

cells etc.

5. EEPROM storage driving

6. Current sensor and voltage sensor driving

7. Balancing algorithm and Coulomb Counting algorithm realizing

Except the finished parts listed above, for the first version of the BMS hardware and

STM32 software there are many need to be improved. There are several mistakes and

some problems in the hardware. The biggest problem of the hardware is the mechanic

design which makes the PCB board almost cannot be debugged. It is because of the of the

battery stack shown in Figure 4.2, the BMS PCB board is designed to be placed inside the

battery cells which make the board inaccessible to debug. Another design drawback is

Page 63: MasterThesis_LinZhu

53

that the whole PCB has too less debugging points which makes it very difficult to measure

the signals. Suggestions for next version of the BMS hardware are as follows:

1. Correct the CAN bus connector pin number error and the net error in last but one

battery monitor chip in the PCB.

2. Redesign the whole mechanic part of the battery stack. The grid between the top

board and bottle board is not a good choice since it will cause the battery

connection not very well.

3. The BMS and the battery stack should be separated and the BMS board should be

accessible. BMS board and the cells should be placed in independent separate parts.

4. An indicator of high voltage should be added as the alarm of high voltage danger,

and an indicator of the power of the MCU should be added as the conventions.

5. A power switch of the MCU, a reset bottom and another UART should be added

for debugging purpose, the DB9 port for the UART should be added in the PCB.

6. Add a temperature sensor for the battery monitor chip and change the position of

the temperature sensor in the PCB so that it wills sensor the temperature of the

battery cells instead of the PCB board.

7. The buffer chip before the battery monitor chip should be removed since the high

energy consumption which will lead to reduce the power up time when the power

of the MCU is removed.

8. Unknown reason for many times of damage of the high voltage isolator chip

should be considered, do more test on that particular circuit.

9. An operating system should be implemented in the MCU software since currently

method by using semaphore technology to manage multi tasks is really limited.

10. Chose a more powerful MCU in the next version of the hardware because of the

suggestion above.

11. For future version BMS, add an Ethernet port, since the Web GUI can be directly

used in a web server.

12. As developing of a BMS need to take a lot of experiment to get the data that need

to develop the algorithm, it is strongly recommend to have more advanced

experiment equipment or send the battery to a professional test center to get the

experiment data.

6.3 Future Work

Much future work should be done for a better BMS. There are a lot of suggestions in both

hardware and software in chapter 5. The future work of both hardware and software

should first solve problems listed in chapter 5 and then do the work listed below:

Page 64: MasterThesis_LinZhu

54

1. Rebuilt the battery model using a second order RC model since first order model

can’t estimate SOH. And second order RC model is can make the battery model

more accurate.

2. Redo all charging and discharging experiments by more accurate experiment

equipment, separate the charging and discharging process, using individual data

for each process in battery simulator and BMS simulator.

3. Port battery simulator python code in Raspberry Pi, test the battery simulator and

BMS simulator in continuous long time to see the behavior of the BMS.

4. Add more exception handler feature in the software both in battery simulator,

BMS simulator and software in STM32.

5. Develop PID balance algorithm and EKF SOC estimation algorithm in C for STM32.

6. Do more investigations about available CAN bus protocol and develop CAN bus

communication protocol in STM32 for communication with the Energy Hub.

7. Implement an operating system such as μC/OS II to schedule multitasks more

easily and effectively.

The listed above tasks should be implemented in the next version of the BMS.

Page 65: MasterThesis_LinZhu

55

Bibliography

[1] H. Rahimi-Eichi, U. Ojha, F. Baronti, and M.-Y. Chow, “Battery Management System: An Overview of Its Application in the Smart Grid and Electric Vehicles,” IEEE Ind. Electron. Mag., vol. 7, no. 2, pp. 4–16, Jun. 2013.

[2] J. Eyer, “Energy Storage for the Electricity Grid : Benefits and Market Potential Assessment Guide A Study for the DOE Energy Storage Systems Program,” no. February, 2010.

[3] “Setting the scene – Ferroamp Elektronik AB.” [Online]. Available: http://www.ferroamp.com/energyhub/setting-the-scene/. [Accessed: 25-Mar-2014].

[4] D. Andres, Battery Management Systems for Large Lithium-Ion Battery Packs, First. ARTECH HOUSE, p. 64,119.

[5] “Li-Ion BMS - Li-Ion BMS options.” [Online]. Available: http://liionbms.com/php/bms_options.php. [Accessed: 23-Sep-2013].

[6] Z. C. Xintian Liu, Yao He, “State-of-Charge Estimation for Power Li-ion Battery Pack Using Vmin-EKF,” vol. 4, pp. 27–31.

[7] D. Xu, L. Wang, and J. Yang, “Research on Li-ion Battery Management System,” 2010 Int. Conf. Electr. Control Eng., pp. 4106–4109, Jun. 2010.

[8] M. Einhorn, S. Member, W. Roessler, and J. Fleig, “Improved Performance of Serially Connected Li-Ion Batteries With Active Cell Balancing in Electric Vehicles,” vol. 60, no. 6, pp. 2448–2457, 2011.

[9] X. Wei and B. Zhu, “The research of vehicle power Li-ion battery pack balancing method,” 2009 9th Int. Conf. Electron. Meas. Instruments, pp. 2–498–2–502, Aug. 2009.

[10] M. F. M. Elias, K. M. Nor, and S. M. Ieee, “Design of Smart Charger for Series Lithium-Ion Batteries,” pp. 1485–1490, 2005.

[11] “PID controller,” 2013. [Online]. Available: http://en.wikipedia.org/wiki/PID_controller. [Accessed: 01-Oct-2013].

[12] M. A. Yan, B. A. I. Qingwen, and C. Hong, “Estimation of Li-ion Battery State of Charge Based on Extended Kalman Filtering,” pp. 6815–6819.

[13] S. Abu-Sharkh and D. Doerffel, “Rapid test and non-linear model characterisation of solid-state lithium-ion batteries,” J. Power Sources, vol. 130, no. 1–2, pp. 266–274, May 2004.

[14] S. Lee, J. Kim, J. Lee, and B. H. Cho, “State-of-charge and capacity estimation of lithium-ion battery using a new open-circuit voltage versus state-of-charge,” J. Power Sources, vol. 185, no. 2, pp. 1367–1373, Dec. 2008.

Page 66: MasterThesis_LinZhu

56

[15] G. L. Plett, “Extended Kalman filtering for battery management systems of LiPB-based HEV battery packs Part 3. State and parameter estimation,” J. Power Sources, vol. 134, no. 2, pp. 277–292, Aug. 2004.

[16] G. L. Plett, “Extended Kalman filtering for battery management systems of LiPB-based HEV battery packs Part 2. Modeling and identificatio,” J. Power Sources, vol. 134, no. 2, pp. 262–276, Aug. 2004.

[17] S. Santhanagopalan and R. E. White, “State of charge estimation using an unscented filter for high power lithium ion cells,” no. December 2009, pp. 152–163, 2010.

[18] P. Spagnol, S. Rossi, and S. M. Savaresi, “Kalman Filter SoC estimation for Li-Ion batteries,” 2011 IEEE Int. Conf. Control Appl., pp. 587–592, Sep. 2011.

[19] “Swing® 5300 Cell Databook overview,” 2013.

[20] C. Y. Hongjie Wua, Shifei Yuana, “Online state of charge estimation based on adaptive extended kalman filter and linear parameter-varying model with recursive least square technique,” no. August, 2013.

[21] H. Rahimi Eichi and M.-Y. Chow, “Modeling and analysis of battery hysteresis effects,” 2012 IEEE Energy Convers. Congr. Expo., pp. 4479–4486, Sep. 2012.

[22] J. Kim, S. Member, and B. H. Cho, “State-of-Charge Estimation and State-of-Health Prediction of a Li-Ion Degraded Battery Based on an EKF Combined With a Per-Unit System,” vol. 60, no. 9, pp. 4249–4260, 2011.

[23] “The Spice Home Page.” [Online]. Available: http://bwrcs.eecs.berkeley.edu/Classes/IcBook/SPICE/. [Accessed: 15-Aug-2013].

[24] “Overview — NetworkX 1.8.1 documentation.” [Online]. Available: http://networkx.github.io/documentation/latest/overview.html. [Accessed: 15-Aug-2013].

[25] G. L. Plett, “Extended Kalman filtering for battery management systems of LiPB-based HEV battery packs Part 1. Background,” J. Power Sources, vol. 134, no. 2, pp. 252–261, Aug. 2004.

[26] J. Kim, S. Lee, and B. Cho, “The determination of state of charge based on extended kalman filter using per-unit system and time constant principle,” INTELEC 2009 - 31st Int. Telecommun. Energy Conf., pp. 1–5, Oct. 2009.

[27] “Bottle: Python Web Framework — Bottle 0.12-dev documentation.” [Online]. Available: http://bottlepy.org/docs/dev/. [Accessed: 13-Sep-2013].

[28] “Ajax (programming),” 2013. [Online]. Available: http://en.wikipedia.org/wiki/Ajax_(programming).

Page 67: MasterThesis_LinZhu

57

[29] Boston Power ®, “Swing® 5300 Rechargeable Lithium-ion Cell Datasheet,” Boston, 2002.

[30] “Serial Peripheral Interface Bus.” [Online]. Available: http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Daisy_chain_SPI_configuration.

[31] “Glossary Definition for daisy_chain.” [Online]. Available: http://www.maximintegrated.com/glossary/definitions.mvp/term/daisy_chain/gpk/71.

[32] “CAN bus,” 2013. [Online]. Available: http://en.wikipedia.org/wiki/CAN_bus. [Accessed: 13-Aug-2013].

[33] “I2C - Wikipedia, the free encyclopedia.” [Online]. Available: http://en.wikipedia.org/wiki/I2C. [Accessed: 14-Aug-2013].

[34] STMicroelectronics, “STM32F103xC STM32F103xD STM32F103xE Datasheet,” 2011.

[35] E. W. Dijkstra, Cooperating sequential processes (EWD-123). Center for American History, University of Texas at Austin.

[36] G. Wu, C. Zhu, and C. C. Chan, “Comparison of the First Order and the Second Order Equivalent Circuit Model Applied in State of Charge Estimation for Battery Used in Electric Vehicles,” J. Asian Electr. Veh., vol. 8, no. 1, pp. 1357–1362, 2010.

[37] “Cell Balancing and Battery Equalisation.” [Online]. Available: http://www.mpoweruk.com/balancing.htm. [Accessed: 13-Aug-2013].

Page 68: MasterThesis_LinZhu

58

APPENDIX A Important Datasheets

Boston Power® Swing© 5300 battery datasheet.

Page 69: MasterThesis_LinZhu

59

LTC6803-3 datasheet.