ADE7759 Algo de Teoria

59
University of Twente EEMCS / Electrical Engineering Control Engineering Real-time Evaluation System for State-of-Charge Estimation Hans van der Steen Pre-doctoral assignment Supervisors: prof.dr.ir. P.P.L. Regtien ir. M. Pop A.P. de Vries July 2006 Report nr. 018CE2006 Control Engineering EE-Math-CS University of Twente P.O.Box 217 7500 AE Enschede The Netherlands

description

ade7759

Transcript of ADE7759 Algo de Teoria

Page 1: ADE7759 Algo de Teoria

University of Twente

EEMCS / Electrical Engineering Control Engineering

Real-time Evaluation System for State-of-Charge Estimation

Hans van der Steen

Pre-doctoral assignment

Supervisors: prof.dr.ir. P.P.L. Regtien

ir. M. Pop A.P. de Vries

July 2006

Report nr. 018CE2006 Control Engineering

EE-Math-CS University of Twente

P.O.Box 217 7500 AE Enschede

The Netherlands

Page 2: ADE7759 Algo de Teoria
Page 3: ADE7759 Algo de Teoria

i

Theme of the Project

This assignment aims at the optimization and extension of a test system for the estimation of the remaining run-time of Li-ion batteries in portable applications. Starting point of this project has been a C-program developed for an existing State-of-Charge (SoC) indication board. At the end the present SoC system must be capable of estimating the remaining capacity of a Li-ion battery and the remaining run-time, as applied in, for example, mobile phones (remaining talk-time and standby time) and shavers (remaining shave time).

The estimation is based on on-line measurements of the battery parameters such as the voltage, the temperature and the current. Measurements are taken by different ADC’s present on the evaluation board. One of the tasks is to write drivers for the existing hardware.

As mobile phones are most challenging with respect to a variety of load currents and a wide temperature range, the project will focus at the beginning on testing a system corresponding to this application.

Control Engineering

Page 4: ADE7759 Algo de Teoria
Page 5: ADE7759 Algo de Teoria

ii Evaluation System for State-of-Charge Estimation

Abstract

Every user of battery-powered devices would like to know exactly how many minutes of usable talk-time is left in his cellular phone battery, video cam-recorder, laptop computer or any other device used. Portable devices continually rely on an accurate reading of the remaining battery capacity, so the system won't lose data or, worse, suddenly shut down during operation.

Until now, the solutions that have been offered range from the simple bar light, indicating when the power supply reaches a certain level of discharge, to the sophisticated power management software present on laptop computers.

The developed design in this report aims to give a more accurate SoC and remaining run-time estimation under a variety of loads, temperatures and aging effects. This new system focuses on SoC indication for mobile phone applications.

The parameters of the battery used for the SoC estimation are the voltage, the current and the temperature. There are written drivers for several ADCs, used for the on-line measurements of the three parameters, which need to be completed.

The first and main step was to update one of the ADC drivers for measuring the current through the battery. In the beginning, these measurements were performed with a not so accurate Analog-to-Digital converter.

A second step was to update one of the ADC drivers for measuring the temperature of the battery. At the beginning there was no temperature sensor and function to calculate the temperature present. So these two parts needed to be implemented.

The last step was to design a Graphical User Interface (GUI) to communicate with the system. The GUI needs to receive the measurements and show these in a graphical way on the screen. It is also needed to control the system, for example to start or stop the measurement.

University of Twente

Page 6: ADE7759 Algo de Teoria
Page 7: ADE7759 Algo de Teoria

iii

Contents

1 Introduction ........................................................................................................................1 1.1 State-of-Charge Importance.......................................................................................1 1.2 Hardware Support ......................................................................................................1

1.2.1 The Evaluation Board (STEED) .............................................................................2 1.2.2 The General Evaluation Controller Board (4ARM) ...............................................2

1.3 Software Support .......................................................................................................3 1.3.1 The Real-Time Operating System (FreeRTOS)......................................................3 1.3.2 The Integrated Development Environment (CrossWorks) .....................................4 1.3.3 The Development Environment Borland Delphi ....................................................4

2 Theoretical Fundamentals ..................................................................................................5 2.1 SoC Theory................................................................................................................5

2.1.1 SoC Indication Methods .........................................................................................5 2.1.2 SoC Indication used method ...................................................................................6 2.1.3 SoC Indication during Initialization........................................................................8

2.2 Serial Peripheral Interface .........................................................................................9 2.2.1 Inside the box........................................................................................................10 2.2.2 At a higher level....................................................................................................11

2.3 Analog Devices Measurement IC (ADE7759) ........................................................12 2.3.1 Introduction...........................................................................................................12 2.3.2 The Analog-to-Digital Conversion .......................................................................13 2.3.3 The Analog Inputs Circuit ....................................................................................13 2.3.4 The Interrupt Controller........................................................................................14 2.3.5 The Serial Peripheral Interface (SPI) ....................................................................15

3 Current Measurement .......................................................................................................17 3.1 Hardware of the Current Measurement ...................................................................17

3.1.1 Connections of the Measurement Circuits ............................................................17 3.1.2 Hardware Main Issues ..........................................................................................18 3.1.3 Hardware Results ..................................................................................................19

3.2 Software of the Current Measurement.....................................................................20 3.2.1 Software Implementation of the real-time evaluation system...............................20 3.2.2 Main Issues of the Software..................................................................................22 3.2.3 SPI Driver .............................................................................................................23 3.2.4 ADE7759 Driver...................................................................................................26 3.2.5 Software Results ...................................................................................................29

4 Temperature measurement ...............................................................................................31 4.1 Temperature sensor..................................................................................................31 4.2 Temperature calculation ..........................................................................................32

5 The Graphical User Interface ...........................................................................................33 5.1 User Manual.............................................................................................................33

5.1.1 Getting started.......................................................................................................33 5.1.2 Settings Tab ..........................................................................................................34 5.1.3 Measurements Tab................................................................................................35 5.1.4 SoC Tab ................................................................................................................35

5.2 The Log-File ............................................................................................................36 5.3 Software implementation of the GUI.......................................................................37

5.3.1 Comport ................................................................................................................37 5.3.2 Data.......................................................................................................................37 5.3.3 Interface ................................................................................................................37 5.3.4 Control ..................................................................................................................37 5.3.5 Timer.....................................................................................................................38 5.3.6 Log........................................................................................................................38

6 Results ..............................................................................................................................39

Control Engineering

Page 8: ADE7759 Algo de Teoria

iv Evaluation System for State-of-Charge Estimation

6.1 Problems ................................................................................................................. 39 6.2 Measurements Results............................................................................................. 40

6.2.1 Current Measurements Results ............................................................................ 40 6.2.2 Temperature Measurement Results ...................................................................... 41 6.2.3 Graphical User Interface Results.......................................................................... 41

7 Conclusions and Recommendations ................................................................................ 42 7.1 Conclusions............................................................................................................. 42 7.2 Recommendations................................................................................................... 42

Appendix I – Communication Protocol.................................................................................... 43 References ................................................................................................................................ 49

University of Twente

Page 9: ADE7759 Algo de Teoria

v

List of Figures

Figure 1.1: The evaluation board (STEED)---------------------------------------------------------------------- 2 Figure 1.2: The controller board (4ARM)------------------------------------------------------------------------ 3 Figure 2.1: Measurement principle of a SoC indication system based on direct measurement----------- 5 Figure 2.2: Measurement principle of a SoC indication system based on book-keeping------------------ 6 Figure 2.3: The possible states of a battery ---------------------------------------------------------------------- 7 Figure 2.4: Diagram of the SoC algorithm states --------------------------------------------------------------- 7 Figure 2.5: SPI implementation of single master and single slave ------------------------------------------10 Figure 2.6: SPI implementation of single master and multiple slaves --------------------------------------10 Figure 2.7: Functional block diagram of ADE7759 [10] -----------------------------------------------------12 Figure 2.8: First order sigma-delta ADC [10] ------------------------------------------------------------------13 Figure 2.9: Analog gain register [10] ----------------------------------------------------------------------------13 Figure 2.10: Interrupt management [10] ------------------------------------------------------------------------14 Figure 2.11: Addressing ADE7759 registers via the communications register [10] ----------------------15 Figure 2.12: Reading data from the ADE7759 via the serial interface [21] --------------------------------15 Figure 2.13: Writing data to the ADE7759 via the serial interface [21] ------------------------------------15 Figure 3.1: Schematic of the measurement circuits connections---------------------------------------------17 Figure 3.2: Chip select ADE7759 --------------------------------------------------------------------------------18 Figure 3.3: TI/AD ADC block schematic -----------------------------------------------------------------------19 Figure 3.4: Crystal oscillator--------------------------------------------------------------------------------------19 Figure 3.5: General diagram of the software implementation of the evaluation system------------------20 Figure 3.6: Reserving and freeing the SPI bus -----------------------------------------------------------------23 Figure 3.7: SPI flowchart------------------------------------------------------------------------------------------25 Figure 3.8: ADE7759 driver --------------------------------------------------------------------------------------26 Figure 3.9: ADE7759 task-----------------------------------------------------------------------------------------28 Figure 4.1: NTC circuit --------------------------------------------------------------------------------------------31 Figure 5.1: GUI startup screen------------------------------------------------------------------------------------33 Figure 5.2: Comport settings--------------------------------------------------------------------------------------34 Figure 5.3: Measurements tab ------------------------------------------------------------------------------------35 Figure 5.4: SoC tab-------------------------------------------------------------------------------------------------35 Figure 5.5: GUI log-file -------------------------------------------------------------------------------------------36 Figure 5.6: General diagram of the software implementation of the GUI ----------------------------------37

Control Engineering

Page 10: ADE7759 Algo de Teoria

vi Evaluation System for State-of-Charge Estimation

List of Tables

Table 1.1: Report structure----------------------------------------------------------------------------------------- 4 Table 2.1: Maximum Input Signals Levels for Channel 1 [10] ----------------------------------------------14 Table 4.1: NTC resistance ----------------------------------------------------------------------------------------31 Table 6.1: Leakage current measurements----------------------------------------------------------------------39 Table 6.2: Voltage measurements with an offset --------------------------------------------------------------39 Table 6.3: Current measurements of the battery during the equilibrium state -----------------------------40 Table 6.4: Current measurements of the battery during discharging with -100 mA ----------------------40 Table 6.5: Current measurements of the battery during charging with 100mA ---------------------------41 Table 7.1: UART Abbreviation list ------------------------------------------------------------------------------44 Table 7.2: PC Protocol Send list ---------------------------------------------------------------------------------47 Table 7.3: PC Protocol Receive list------------------------------------------------------------------------------48

University of Twente

Page 11: ADE7759 Algo de Teoria

1

1 Introduction

The main goal of this project is to develop the software drivers for a real-time State-of-Charge (SoC) evaluation system. The real-time SoC evaluation system uses as input the voltage, temperature and current measurements to calculate the SoC and the remaining run-time of a portable application powered by a Li-ion battery.

The voltage, temperature and current measurements are performed by different Analog-to-Digital Converters (ADC’s) of the real-time SoC evaluation system. In order to understand the real-time SoC evaluation system functionality, basis of the SoC calculation will be further given in this chapter.

1.1 State-of-Charge Importance

Due to the fact that people want to have a more mobile life, there is an increasing demand for mobile devices. When main power supply isn’t available for power delivery of these devices they have to rely on a portable power supply such as a battery. From that point of view it becomes important that users can trust the indicated remaining run-time and the SoC, which is defined as the percentage of charge that is present inside the battery. Otherwise, users will charge the battery more often resulting in a faster wear out of the batteries [1].

Almost as long as rechargeable batteries exist there are systems that are able to give some indication about the amount of charge that is available in a battery. These systems were mostly simple volt-gauges and they gave only a little clue about the charge that is present in the battery. Especially at low SoC, the indicated SoC was very inaccurate.

Nowadays there are better SoC indication systems that measure more properties of the battery, than only the voltage, such as current, impedance and relaxation time that are dependent on the temperature. This results in more accurate systems. Other systems measure and integrate the current and compensate for self-discharge and discharge efficiency of the battery [2].

The present SoC evaluation system contains SoC algorithm that combines the book-keeping with the Electro-Motive Force [1]. In order to deal with the aging affect, adaptive systems are also implemented on the SoC algorithm.

1.2 Hardware Support

Two boards are used for the SoC evaluation system: an evaluation board, i.e. STEED, and a general evaluation controller board, i.e. 4ARM. These boards are connected to each other by a connectivity block.

The evaluation board contains different circuits which some of them have the same purpose. These circuits need to be analyzed and compared, in order to decide which one is the best to use for future demonstration boards or for a direct implementation in a mobile phone.

The controller board is used to control the evaluation board and to make the communication possible between the circuits and a computer. The controller board is also used for powering the circuits on the evaluation board.

Control Engineering

Page 12: ADE7759 Algo de Teoria

2 Evaluation System for State-of-Charge Estimation

1.2.1 The Evaluation Board (STEED)

The evaluation board [3] has multiple measurements circuits to measure the voltage, the current and the temperature of a battery. The evaluation board has also a circuit to charge and discharge a battery. The evaluation board is shown in Figure 1.1

Figure 1.1: The evaluation board (STEED)

The board exists of ten blocks: • Connectivity: connects the ARM4 and Evaluation board. • Current Protection: circuit that prevents short circuit or other errors where there are going

to flow too high currents. • PCF50606 circuit (i.e. Obelix): measurement circuit for the voltage, current and

temperature of the battery. • Batman: circuit used to charge the battery. • TI/AD ADC: Used to measure the current, the voltage and the temperature. • PCF50603 circuit (i.e. Spinoza): circuit used to charge the battery. • Charge: charging circuit for the battery. • Discharge: discharge circuit for the battery. • DCDC: circuit for charging purpose. • EXT Charge: this circuit gives the property to connect an external charger on the system.

1.2.2 The General Evaluation Controller Board (4ARM)

The Advanced RISC Machine (4ARM) [4] controls the hardware of the evaluation board, via two connectors on the backside of the board. These connectors are connected with the connectivity block of the evaluation board.

The controller board is controlled by a microcontroller, the LPC2292 [5]. This is a microcontroller suited for control applications. It has two UART interfaces, two SPI busses and one I2C bus. These busses give the controller board the ability to communicate with a computer and to communicate between the component blocks of the evaluation board. The controller board has also a power supply used for the board self and for some circuits on the evaluation board. A debugging device is also present i.e. JTAG (Joint Test Action Group), Macraigor Wiggler.

University of Twente

Page 13: ADE7759 Algo de Teoria

Introduction 3

Figure 1.2: The controller board (4ARM)

The switch in Figure 1.2 (marked with a circle) is for debugging or running the controller board. If the switch is placed in the up position, the board is placed in the In System Programming (ISP) mode. This gives the ability to program and debug the board while running. In the down position the board is in the functional mode.

1.3 Software Support

Several software and development tools are used for writing the software for the SoC evaluation system and for the PC. An introduction of these will be given in the next sections.

1.3.1 The Real-Time Operating System (FreeRTOS)

For implementing the software of the SoC evaluation system, real-time programming is needed, because of the time constraints and of the complex design of the hardware. Almost all the circuits on the boards need to be executing at the same time, leading to the need of a multitasking implementation mechanism. The simplest way would be to use a real-time operating system and after analyzing more options the Operating System FreeRTOS [6] was chosen. FreeRTOS is a portable open source real-time operating system for embedded devices. Besides the fact that FreeRTOS is royalty free, it also provides the following features:

• Two types of scheduling policies: pre-emptive (always runs the highest available task) and cooperative (context switches only occur if a task blocks).

• Free development tools for ARM7 port. • Free embedded software source code. • Cross development from a standard Windows host. • Message queues. • Semaphores. • Trace visualization ability.

Another argument for using FreeRTOS is that nearly all the code is written in C, which makes the code readable, maintainable and easy to port. FreeRTOS allows tasks (pieces of code that do specific duties) to run quasi-concurrently. This means that tasks will seem to run all at the same time, doing many specific jobs simultaneously. The responsible for deciding which task should be executing at any particular time is the scheduler. The kernel can suspend and later resume a task many times during the task’s lifetime.

Control Engineering

Page 14: ADE7759 Algo de Teoria

4 Evaluation System for State-of-Charge Estimation

FreeRTOS allows a task of higher priority that is able to run (whether starting or resuming) to preempt the lower priority running task. This will cause the scheduler to save the context of the running (lower priority) task and restore the context of the higher priority task so that it is now running. As a truly preemptive RTOS, FreeRTOS allows interrupts to cause an immediate task switch. This means that the interrupts now have the added ability of using the RTOS functions. For More information about the FreeRTOS features, see [6].

1.3.2 The Integrated Development Environment (CrossWorks)

CrossWorks for ARM is a complete C development system for ARM 7 microprocessors, like the LPC2292 [5]. It is comprised of the ARM C compiler, the CrossWorks C Library and the CrossStudio integrated development environment.

CrossWorks is able to flash the software directly into the microprocessor by using JTAG, to visualize input/output registers and to debug in flash. In the present application, CrossStudio is used for debugging and building the project. More information about the CrossWorks features and about how it is used can be found at [7].

1.3.3 The Development Environment Borland Delphi

For the design and implementation of the Graphical User Interface (GUI) the development environment of Borland Delphi is used. The programming language Delphi, a next generation version of the language Pascal, is used. In Borland Delphi a comport-component is used to communicate via the comport of a PC with the controller board. For more information about Borland Delphi, see [8]. The source and install files for the comport-component can be found at [9].

The structure of this report is as follows: Chapter Title Chapter Description Theoretical Fundamentals The theoretical aspects regarding the SoC evaluation system

implementation are presented. Current Measurement The hardware and software design, to make the current

measurement to work, will be described here. Temperature Measurement An overall view of how the temperature of the battery is measured

and calculated will be given here. The Graphical User Interface An explanation about the usage, the Log-file and the

implementation of the code of the Graphical User Interface (GUI). Results The results on the end of this project will be handled here. Conclusions and Recommendations

This chapter will give some conclusions and recommendations about the real-time evaluation system.

Table 1.1: Report structure

University of Twente

Page 15: ADE7759 Algo de Teoria

5

2 Theoretical Fundamentals

The theoretical aspects regarding the SoC evaluation system implementation are presented in this chapter. The order and the content of the next sections have been chosen so that the reader could make a good idea about the project.

The first section presents two possible methods for estimating the SoC of a battery and, in the end, the method used for this project. Most of the information regarding the SoC estimation algorithm is confidential, but still, a brief description of the algorithm’s states will be given.

The next two sections of this chapter concern the communication protocol between the ADE7759 [10] (used for the current measurements) and the LPC2292 [5] (microcontroller) and detailed information about the ADE7759 [10].

2.1 SoC Theory

At this moment there are different battery powered devices that use a certain SoC indication. There are several classical methods, which can be used for estimating the SoC of a battery. Two of them will be presented in this section.

The SoC estimation method used for designing this evaluation system is a new method, described in [11], which basically combines the advantages of the two methods. A short description of the new SoC indication method will be done in Section 2.1.3.

2.1.1 SoC Indication Methods

In literature there are two main known methods for SoC indication: one based on direct measurements and another based on book-keeping [11]. The concept of the two methods is described in the next paragraphs.

Direct Measurement Systems

There exist several measurable properties of a battery that can give an indication about the SoC of that battery. Examples of such properties are the OCV (Open Circuit Voltage), the current (I), the impedance (Z) and the voltage relaxation time (τ) after application of a current step. Most measurable properties are very dependent on the temperature (T) of the battery and, therefore, the temperature should also be measured. With the measured data an according SoC value can be obtained with the aid of look-up tables or other relations. These systems are referred to as direct measurement systems ([11], [12]) since they can give a SoC indication immediately after the first taken measurement sample. Thus, there is no historical information required.

One of the cheapest systems is based on OCV measurements, but these systems are very inaccurate under normal conditions [13]. Therefore, a more intelligent system is required, which takes in consideration the discharge current and the temperature also. Unfortunately, even then, there is still not enough information available to obtain high accuracy. The basic principle of direct measurement systems able to indicate the SoC is shown in Figure 2.1.

I

SoC= f (V,T,I,Z,τ) V,T,I,Z,τ

Figure 2.1: Measurement principle of a SoC indication system based on direct measurement

Control Engineering

Page 16: ADE7759 Algo de Teoria

6 Evaluation System for State-of-Charge Estimation

Book-keeping Systems

Coulomb Counting (CC) also referred to as “Ampere hour” counting, is based on current measurement and integration. CC could give a good accuracy of the SoC, only if the battery equals a linear capacitor. However not all the charge that flows into a battery can be retrieved under all conditions and thus the battery is a non-linear capacitor [11].

Fortunately, some information is known about the non-linear behaviour of the battery, such as the discharge efficiency that is smaller than 100% and the fact that the battery suffers from self-discharge. If this knowledge is combined with information about the CC, the temperature and the cycle life a system is obtained which is referred to as a book-keeping system [11].

Besides the fact that this knowledge might be inaccurate, also the CC suffers from propagated inaccuracies, due to the integration. Therefore the book-keeping system is only able to maintain accuracy if it’s calibrated at certain moments. Another disadvantage is the fact that the inaccuracy of the whole algorithm is difficult to be specified.

The principle of book-keeping systems is depicted in Figure 2.2 [11], [14].

I ∫ I dt = CC

V,T,I

SoC= f ( CCV,T,I)

Figure 2.2: Measurement principle of a SoC indication system based on book-keeping

2.1.2 SoC Indication used method

A good estimation of the SoC of a battery, used for mobile applications, requires a method able to give an accurate indication. The real-time evaluation system described in this thesis is based on a new method that predicts the SoC of a battery, mainly described in [11].

This method aims at eliminating the main drawbacks of the SoC estimation methods, by combining the advantages of the two methods described before. More information about SoC indication method could be found in [11], [12]. By combining the two methods, the diagram in Figure 2.3 on page 7 is created.

Since a battery shows a different behaviour for the several states, different methods are required in order to estimate the SoC in each state. In short, the algorithm uses current measurements and integration during charge and discharge and voltage measurement during transition and equilibrium states. Therefore the total system is controlled by a state-system that determines which method should be used [1].

University of Twente

Page 17: ADE7759 Algo de Teoria

Theoretical Fundamentals 7

Figure 2.3: The possible states of a battery

According to Figure 2.4, the system determines the state to go and starts executing the algorithm. In general, it can be seen that if the absolute current is smaller than a certain limit (Ilim) the transition state is executed until the battery is in equilibrium. Always when a positive current is larger than Ilim the charge algorithm is executed, while the discharge algorithm is used if a negative current smaller than -Ilim is flowing out of the battery.

Furthermore the stable conditions during charge and equilibrium will be used in order to update the system parameters to account for the aging effect [1].

Figure 2.4: Diagram of the SoC algorithm states

The next paragraphs are dedicated to shortly describing the states of the SoC estimation algorithm. Most of the information regarding the algorithm is confidential.

Control Engineering

Page 18: ADE7759 Algo de Teoria

8 Evaluation System for State-of-Charge Estimation

2.1.3 SoC Indication during Initialization

The SoC indication system starts up when a battery is connected to it. The system will enter the initial state of the algorithm and it’s assumed that the current flow is small and the voltage is relaxed. Since there is yet no other information available, the system considers the battery in equilibrium and estimates the SoC using the voltage measurement and a relation between the EMF (Electro-Motive Force) and the SoC [1]. First, the resulting SoC information is shown to the user, until a more accurate SoC is known. Thereafter, the system shifts to the transition state to determine if the system is in equilibrium.

SoC Indication during Equilibrium

When the absolute current flow is smaller than Ilim, SoC calculation is based on the EMF of the battery that can only be measured accurately if the battery is relaxed.

If the battery is fully relaxed, the EMF equals the OCV according to ( 2.1 ).

OCVbattVEMF ,= ( 2.1 )

It has been also proven that the EMF gives a good indication about the SoC of a battery, without a large dependence on other factors, such as aging [11]. This is an important advantage of the EMF that can be used into the SoC indication system for adaptation of the parameters.

For calculating the SoC during equilibrium, a physical mathematical model, that represents the relation between the EMF and the SoC, is used [11], [17]. Another option could be to use a look-up table, but that requires too much memory, in case an accurate indication is needed. For mobile applications, the size of the memory is limited. Also, the values stored in a table are only valid for specific conditions (meaning that for each particular set of conditions a look-up table needs to be defined).

The algorithm should go into equilibrium state if the battery voltage is fully relaxed. It is important that the system can enter the equilibrium state, because in that case there is less calculation required and thus the power consumption of the SoC indication system will decrease. Besides, if the system is in equilibrium the indicated SoC values have more certainty and thus are more accurate [1].

SoC Indication during Transition

Since the relaxation of the voltage can take a long time and since the battery is not in equilibrium state for that time, a method is required to estimate the SoC during that relaxation period. With the available knowledge about the state of the battery, three general methods exist to obtain an estimate of the SoC in the transition state. For more information about this methods, consult [1].

SoC Indication during Discharge

Estimation of the SoC during discharge is mainly based on current measurements, since it has been found that observation of the battery voltage has many disadvantages [18].

The first SoC indication, before the start of discharge, equals the SoC estimation in the previous state (e.g. charge, transition, equilibrium or initial state). Based on this initial SoC, which is converted to the absolute Qn (nominal available charge), expressed in Coulombs, the next Qn indication can be calculated with the aid of Coulomb Counting. Having this Qn, relative SoC can easily be calculated as the fraction Qn of Qmax (maximum charge), multiplied by 100. The relative SoC, expressed as a percentage, can directly be shown to the user.

University of Twente

Page 19: ADE7759 Algo de Teoria

Theoretical Fundamentals 9

Coulomb Counting delivers an updated Qn after each period of sampling time for discharging, when the current through the battery is almost constant over time.

Qn, might be used to calculate the remaining talk-time and standby-time under the actual conditions. Unfortunately, due to the overpotential, under normal conditions not the whole amount of Qn is available for discharging. Therefore, a certain compensated amount of charge, Qc, that is available to the user under actual conditions, must be calculated. Qc is a function of the current, time of discharging, temperature and aging.

The accuracy of the standby-time and talk-time indication is dependent on the estimation of the discharge efficiency. The discharge efficiency is lower than 100% due to the overpotential, which represents the difference between the fully relaxed voltage and the actual OCV.

SoC Estimation during Charge

The SoC estimation during charge is always based on Coulomb Counting. Since the Coulomb Counting during the charge state adds charge to the already available charge, only an estimation of the initial available charge is required ( 2.2 ). This initial amount of charge is always copied from the SoC estimation in the previous state.

CCprevstate

n QQSoC

Q +⋅= max100 ( 2.2 )

Having this Qn, relative SoC can be calculated, as in the discharge state, as the fraction Qn of Qmax, multiplied by 100 .( 2.3 ).

100[%]max

⋅=QQ

SoC n ( 2.3 )

Directly after disconnecting the charger, the algorithm comes into the transition state (if the mobile isn’t consuming too much power because of a phone call, case in which the algorithm will go into discharge state). After a certain time, the SoC estimation as function of the EMF has less uncertainty than the estimation based on the Coulomb Counting process. At that moment, the algorithm switches the indication of the SoC to an estimation based on the EMF-SoC relation [1].

2.2 Serial Peripheral Interface

Serial Peripheral Interface (SPI) provides good support for communication with slow peripheral devices that are accessed intermittently. EEPROM’s and real-time clocks are examples of such devices. But SPI is suited for applications that are naturally thought of as data streams (as opposed to reading and writing addressed locations in a slave device). An example of a "stream" application is data communication between microprocessors or Digital Signal Processors (DSP’s). Another example of stream application is data transfer from Analog-to-Digital Converters.

SPI can achieve high data rates. SPI-compatible interfaces often range into the tens of megahertz. SPI gains efficiency in applications that take advantage of its duplex capability, such as the communication between a "codec" (coder-decoder) and a digital signal processor, which consists of simultaneously sending samples in and out.

SPI devices communicate using a master-slave relationship. In this case a single master can control multiple slaves.

Control Engineering

Page 20: ADE7759 Algo de Teoria

10 Evaluation System for State-of-Charge Estimation

2.2.1 Inside the box

SPI is a serial bus standard established by Motorola and supported in silicon products from various manufacturers. SPI interfaces are available on popular communication processors such as the MPC8260 and microcontrollers such as the LPC2292 [5]. It is a synchronous serial data link that operates in full duplex (signals carrying data go in both directions simultaneously).

Devices communicate using a master/slave relationship, in which the master initiates the data frame. When the master generates a clock and selects a slave device, data may be transferred in either or both directions simultaneously. In fact, as far as SPI is concerned, data are always transferred in both directions. It is up to the master and slave devices to know whether a received byte is meaningful or not. So a device must discard the received byte in a "transmit only" frame or generate a dummy byte for a "receive only" frame.

Figure 2.5: SPI implementation of single master and single slave

SPI specifies four signals: 1. Serial CLocK (SCLK). 2. Master data Output, Slave data Input (MOSI). 3. Master data Input, Slave data Output (MISO). 4. Slave Select (SS) i.e. Chip Select (CS).

Figure 2.5 shows these signals in a single-slave configuration. SCLK is generated by the master and input to all slaves. MOSI carries data from master to slave. MISO carries data from slave back to master. A slave device is selected when the master asserts its SS signal.

If multiple slave devices exist, the master generates a separate Slave Select signal for each slave. These relationships are illustrated in Figure 2.6.

Figure 2.6: SPI implementation of single master and multiple slaves

The master generates SS signals using general-purpose discrete input/output pins or other logic. This consists of old-fashioned bit banging and can be pretty sensitive. Make sure the Chip Select will not change during a data frame to prevent data corruption.

University of Twente

Page 21: ADE7759 Algo de Teoria

Theoretical Fundamentals 11

While SPI doesn't describe a specific way to implement multi-master systems, some SPI devices support additional signals that make such implementations possible. However, it's complicated and usually unnecessary, so it's not often done.

The parameters called Clock POLarity (CPOL) and Clock PHAse (CPHA) determine the edges of the clock signal on which the data are driven and sampled. Each of the two parameters has two possible states, which allows for four possible combinations, all of which are incompatible with one another. So a master/slave pair must use the same parameter pair values to communicate. If multiple slaves are used that are fixed in different configurations, the master will have to reconfigure itself each time it needs to communicate with a different slave.

2.2.2 At a higher level

SPI does not have an acknowledgement mechanism to confirm receipt of data. In fact, without a communication protocol, the SPI master has no knowledge of whether a slave even exists. SPI also offers no flow control. If the hardware need flow control, there need to do done something outside of SPI.

Slaves can be thought of as input/output devices of the master. SPI does not specify a particular higher-level protocol for master-slave dialog. In some applications, a higher-level protocol is not needed and only raw data are exchanged. A possible example is an interface to a simple codec. In other applications, a higher-level protocol, such as a command-response protocol, may be necessary. Note that the master must initiate the frames for both its command and the slave's response.

SPI's full duplex communication capability and data rates (ranging up to several megabits per second) make it, in most cases, extremely simple and efficient for single master, single slave applications. On the other hand, it can be troublesome to implement for more than one slave, due to its lack of built-in addressing; and the complexity only grows as the number of slave’s increases.

Control Engineering

Page 22: ADE7759 Algo de Teoria

12 Evaluation System for State-of-Charge Estimation

2.3 Analog Devices Measurement IC (ADE7759)

The main scope of this project is to measure the current that flows into and out of the battery. In the SoC evaluation system presented in this report the ADE7759 IC [10] is used for this measurement. As a result the ADE7759 will be introduced in this section.

2.3.1 Introduction

The ADE7759 is an accurate active power and energy measurement integrated circuit, with a serial interface and a pulse output. The ADE7759 incorporates two second-order sigma-delta ADCs, a digital integrator, a reference circuitry, a temperature sensor and all the signal processing required to perform active power and energy measurement.

The digital integrator eliminates the need for an external analog integrator and provides excellent long-term stability and precise phase matching between the current and the voltage channels. The integrator can be switched off if the ADE7759 is used with conventional current sensors [10].

The interrupt request output is an open drain, active low logic output. The interrupt status register indicates the nature of the interrupt, and the interrupt enable register controls which event produces an output on the IRQ pin.

The functional block of ADE7759 is shown in Figure 2.7.

Figure 2.7: Functional block diagram of ADE7759 [10]

A more detailed description of the blocks needed for measuring and for handling the measurement results is presented in the following sections.

University of Twente

Page 23: ADE7759 Algo de Teoria

Theoretical Fundamentals 13

2.3.2 The Analog-to-Digital Conversion

The Analog-to-Digital Conversion in the ADE7759 is carried out using two second-order sigma-delta converters. The block diagram in Figure 2.8 shows a first-order (for simplicity) sigma-delta converter [10].

Figure 2.8: First order sigma-delta ADC [10]

The converter is composed of two parts, first the sigma-delta modulator and second the digital low-pass filter. A sigma-delta modulator converts the input signal into a continuous serial stream of ‘1’s and ‘0’s, at a rate determined by the sampling clock. In the ADE7759, the sampling clock is equal to a fourth of the input clock. The 1-bit DAC (Digital-to-Analog Converter) in the feedback loop is driven by the serial data stream. The DAC output is subtracted from the input signal. If the loop gain is high enough, the average value of the DAC output (and therefore the bit stream) will approach that of the input signal level. For any given input value in a single sampling interval, the data from the 1-bit ADC is virtually meaningless. Only when a large number of samples are averaged will a meaningful result be obtained. This averaging is carried out in the second part of the ADC, the digital low-pass filter. By averaging a large number of bits from the modulator, the low-pass filter can produce 20-bit data-words that are proportional to the input signal level [10].

2.3.3 The Analog Inputs Circuit

ADE7759 has two fully differential voltage input channels. The maximum differential input voltage for input pairs is ±0.5 V. In addition, the maximum signal level on analog inputs is ±0.5 V with respect to AGND (Analog GrouND) [10].

Each analog input channel has a PGA (Programmable Gain Amplifier) with possible gain selections of 1, 2, 4, 8, and 16. The gain selections are made by writing to the gain register, see Figure 2.9.

Bits 0 to 2 select the gain for the PGA in Channel 1 and the gain selection for the PGA in Channel 2 is made via bits 5 to 7.

Figure 2.9: Analog gain register [10]

Control Engineering

Page 24: ADE7759 Algo de Teoria

14 Evaluation System for State-of-Charge Estimation

In addition to the PGA, Channel 1 also has a full-scale input range selection for the Analog-to-Digital Converter. The converter’s analog input range selection is also made using the gain register. As mentioned previously the maximum differential input voltage is 0.5 V. However, by using bits 3 and 4 in the gain register, the maximum analog input voltage can be set to 0.5 V, 0.25 V or 0.125 V. This is achieved by adjusting the converter’s reference. Table 2.1 summarizes the maximum differential input signal level on Channel 1 for the various ADC range and gain selections.

Table 2.1: Maximum Input Signals Levels for Channel 1 [10]

2.3.4 The Interrupt Controller

ADE7759 interrupts are managed through the Interrupt Status Register (STATUS [7:0]) and the Interrupt Enable Register (IRQEN [7:0]). When an interrupt event occurs in the ADE7759, the corresponding flag in the status register is set to logic ‘1’. If the enable bit for these interrupts in the interrupt enable register is logic ‘1’, then the IRQ (Interrupt ReQuest) logic output goes active low. The flag bits in the status register are set irrespective of the state of the enable bits [10].

If an interrupt on a new current measurement needs to be given, the WSMP bit of the IRQEN register need to be set at ‘1’.

To determine the source of the interrupt, the system master should perform a read from the status register with reset (RSTATUS [7:0]). This is achieved by carrying out a read from address 05h. The IRQ output will go logic high on completion of the interrupt status register read command. When carrying out a read with reset, the ADE7759 is designed to ensure that no interrupt events are missed. If an interrupt event occurs just as the status register is being read, the event will not be lost and the IRQ logic output is guaranteed to go high for the duration of the interrupt status register data transfer before going logic low again, to indicate the pending interrupt [10].

Figure 2.10 shows a timing diagram with a suggested implementation of ADE7759 interrupt management using a Micro Controller Unit (MCU).

Figure 2.10: Interrupt management [10]

At time t1, the IRQ line will go active low, indicating that one or more interrupt events have occurred in the ADE7759. The IRQ logic output should be tied to a negative edge-triggered external interrupt on the MCU. On detection of the negative edge, the MCU should be configured to start executing its Interrupt Service Routine (ISR). On entering the ISR, all interrupts should be disabled using the global interrupt enable bit. At this point, the MCU external interrupt flag can be cleared to capture interrupt events that occur during the current ISR. When the MCU interrupt flag is cleared, a

University of Twente

Page 25: ADE7759 Algo de Teoria

Theoretical Fundamentals 15

read from the status register with reset is carried out. This will cause the IRQ line to be reset logic high (t2) [10].

The status register contents are used to determine the source of the interrupt(s), and thus the appropriate action will be taken. If a subsequent interrupt event occurs during the ISR, that event will be recorded by the MCU external interrupt flag, by being set again (t3). On returning from the ISR, the global interrupt mask will be cleared (same instruction cycle) and the external interrupt flag will cause the MCU to jump to its ISR once again. This will ensure that the MCU does not miss any external interrupts [21].

2.3.5 The Serial Peripheral Interface (SPI)

All ADE7759 functionality is accessible via several on-chip registers, as seen in Figure 2.11 the contents of these registers can be updated or read using the on-chip serial interface. After power-on, toggling the RESET pin low or a falling edge on CS, ADE7759 is placed in communication mode. In communication mode the ADE7759 expects a write to its communication register. The data written to the communication register determines whether the next data transfer operation will be a read or a write and also which register is accessed. Therefore, all data transfer operations with the ADE7759, whether a read or a write, must begin with a write to the communications register [10].

Figure 2.11: Addressing ADE7759 registers via the communications register [10]

The communications register is an 8-bit wide register. The MSB determines whether the next data transfer operation is a read or a write. The five LSB’s contain the address of the register to be accessed. Figure 2.12 and Figure 2.13 shows the data transfer sequences for a read and write operation, respectively [10].

Figure 2.12: Reading data from the ADE7759 via the serial interface [21]

Figure 2.13: Writing data to the ADE7759 via the serial interface [21]

Control Engineering

Page 26: ADE7759 Algo de Teoria

16 Evaluation System for State-of-Charge Estimation

On completion of a data transfer ADE7759 enters communications mode again. A data transfer is complete when the LSB of the ADE7759 register being addressed (for a write or a read) is transferred to or from the ADE7759.

The serial interface of the ADE7759 is made up of four signals: Chip Select (CS), Serial CLocK (SCLK), Data INput (DIN) and Data OUTput (DOUT). The serial clock for a data transfer is applied at the SCLK logic input. This logic input has a Schmitt-trigger input structure, which allows slow rising (and falling) clock edges to be used. All data transfer operations are synchronized to the serial clock. Data is shifted into the ADE7759 at the DIN logic input on the falling edge of SCLK. Data is shifted out of the ADE7759 at the DOUT logic output on a rising edge of SCLK.

The CS input is used when multiple devices share the serial bus. A falling edge on CS also resets the serial interface and places ADE7759 into communication mode. The CS input should be driven low for the entire data transfer operation. Bringing CS high during a data transfer operation will abort the transfer and place the serial bus in a high impedance state. The CS logic input may be tied low, if ADE7759 is the only device on the serial bus. However, with CS tied low, all initiated data transfer operations must be fully completed, because ADE7759 will not go back into communications mode without resetting the entire device [10]. For more information about ADE7759 see [10].

University of Twente

Page 27: ADE7759 Algo de Teoria

17

3 Current Measurement

In this chapter the hardware and software design, to make the current measurement to work, will be described. Most of the hardware and software where already implemented but some of them doesn’t seem to work correctly. Therefore the problems at the beginning of this project shall be given and explained first. Next the new implemented hardware and software and the results will be given. The parts that are relevant for the current measurement with the ADE7759 will be handled.

3.1 Hardware of the Current Measurement

This section will give a description and explanation of the hardware. First a schematic of how the measurements are done will be presented. Next a list of the Issues and their explanation will be given. At the end of this section the results of the hardware needed for the current measurements are presented.

3.1.1 Connections of the Measurement Circuits

Figure 3.1: Schematic of the measurement circuits connections

In Figure 3.1 the basis of the measurement circuit connections is given. Three measurement circuits are presented at the right of the figure:

• Philips Semiconductors, PCF50606 [13]. • Texas Instruments, ADS1256 [19]. • Analog Devices, ADE7759 [10].

On the left part of the figure the circuit of the battery and a charger is shown. The measurement circuits are connected at the points of this circuit where the measurements needed to be done.

Rsense1 and Rsense2 are sense resistors used for determining the value of the current, by measuring the voltage drop across them and then dividing the measured value with the value of the resistors. The value of the sense resistors is 20 mΩ.

Control Engineering

Page 28: ADE7759 Algo de Teoria

18 Evaluation System for State-of-Charge Estimation

The circuit works as follows: between pins 3 and 4 a battery should be connected and between pins 1 and 2, a battery charger. The charger can be implemented as a current or a voltage source. Instead of the battery, a resistor can be connected, especially for testing.

For voltage measurement, the Philips Semiconductors and the Texas Instruments circuits are used. The two circuits measure the voltage in different ways: PCF50606 measures only the potential of Batt +, while ADS1256 [19] measures the differential voltage between Batt + and Batt -. Even if PCF50606 [13] doesn’t measure the differential voltage, a software function can be implemented so that the value of the voltage is displayed as the difference between the potential measured at BATVOLT input and the one measured at ADCIN1 input.

For current measurement, the Philips Semiconductors and the Analog Devices circuits are used. It is important to specify the fact that the two circuits don’t measure actually the current, they measure the voltage drop across a sense resistor (Rsense2, in this case).

The calculation of the current value is done by a software function (by dividing the measured value of the voltage with the value of the sense resistor).

There are also some differences between the two measurements. While PCF50606 measures only the value of the current, ADE7759 [10] measures the value of the current and can also detect the sense of the current. This makes ADE7759 a more useful measurement circuit than PCF50606, because it can sense if the battery is charging or discharging.

An important aspect for current measurement is the fact that a current flow is present in the circuit, so the displayed value of the current represents a real current, not a potential one. It can be easily noticed that a voltage will always be present at the inputs of the circuits, but that would not mean a current is also flowing.

3.1.2 Hardware Main Issues

The following issues were present at the ADE7759 measurement circuit:

1. The Chip select of the ADE7759 didn’t work.

As shown in Section 2.3.5 on page 15 a chip select signal is needed to let the ADE7759 communicate with the SPI bus. The hardware for making the Chip Select signal is shown in Figure 3.2.

Figure 3.2: Chip select ADE7759

The Chip Select signal on the left of the figure is made by the LPC2292 [5]. This signal could be high (0V) or low (3,3V). With a voltage divider of two (100k, 100k), a signal of 2,5V or 4,25V is made. Because the Chip Select of the ADE7759 needs a voltage less then 0,8V to select, the chip could never be selected.

To make the selection possible, the horizontal resistor needs to be replaced for a 10k resistor.

2. There was no sampling clock on the ADE7759.

University of Twente

Page 29: ADE7759 Algo de Teoria

Current Measurement 19

As discussed in Section 2.3.2 on page 13, the ADE7759 [10] needs to be attached to an external clock (sampling clock) to let the ADE7759 work. Because there was no clock, the ADE7759 didn’t work. The clock could be delivered by the ADS1256 [19]. The ADS1256 and the ADE7759 circuit are connected as Figure 3.3 illustrates.

Figure 3.3: TI/AD ADC block schematic

The internal clock for the ADS1256 is attached to a Crystal Oscillator of 8 MHz. The ADS1256 has a Clock Out which generates a digital clock with the same frequency as the Crystal Oscillator. This clock can be attached to another IC, which is in this application the ADE7759.

The rest of the in and output ports are used for SPI purposes, which are introduced in Section 2.3.5 on page 15. Because the crystal oscillator didn’t oscillate, the ADS1256 didn’t generate a clock signal for the ADE7759. The circuit of the crystal oscillator is shown in Figure 3.4.

Figure 3.4: Crystal oscillator

X-Al is a Crystal of 8MHz. R1 is a resistance of 2MΩ. The problem of not oscillating of the crystal oscillator was the wrong chosen value of the capacitors C1 and C2. The value needed to be 10pF instead of 18pF.

3.1.3 Hardware Results

By replacing the parts which were causing the problems, handled in Section 3.1.2, the hardware is perfectly working now.

1. The ADE7759 can be selected for SPI communication. 2. The ADS1256 generates a digital clock and delivers it to the ADE7759. Writing to and

reading from the ADE7759 is possible now.

Control Engineering

Page 30: ADE7759 Algo de Teoria

20 Evaluation System for State-of-Charge Estimation

3.2 Software of the Current Measurement

In this section the design of the software to make the current measurement work is given. The focus will be relying on the software parts relevant for the work of the current measurement. First a general diagram is introduced and explained shortly. Next the main issues that were present will be handled, followed by the description and explanation of some software parts. At the end of this section the results of the software will be given.

3.2.1 Software Implementation of the real-time evaluation system

The general diagram of the software implementation is illustrated in the figure below.

Figure 3.5: General diagram of the software implementation of the evaluation system

As showed in Figure 3.5, the schematic diagram software application is divided in four parts: PC Communication Driver, Application Layer, Device Drivers and Hardware Communication Drivers.

These parts consist of one or more modules, which have their own task(s). The next section will shortly explain the purpose of every module. Further on, the explanations of the important modules for this report will be handled in more detail.

University of Twente

Page 31: ADE7759 Algo de Teoria

Current Measurement 21

General Control

This module is the hart of the software application. General Control receives the notifications of all the important events in the system: PC User input, ADE7759 measurement ready, etc. If an event is received General Control determines what action should be taken (e.g.: calculate SoC).

Uart

The Uart gives the ability to communicate with an external system, like a PC, via a RS232 connection.

PC Communication Receive

This module receives the commands given from the PC via the Uart. Based on the validity of these commands the PC Communication Transmit module will reply (ACK) or not reply (NAK). If a valid command (see Appendix I) was received it notifies general control of the input.

PC Communication Transmit

Any input given by general control or PC Communication Receive, will be transmitted via the Uart to the PC. For example: if general control gets a notification of a measurement that is ready, it notifies PC Communication Transmit so that the measurement can be send to the PC.

SoC

Based on the state of the battery (equilibrium, charging etc.), SoC will calculate the new State-of-Charge and Talk Time.

Charge / Discharge Control

This controls the function to discharge or charge a battery.

Obelix

This module contains all the functions to setup and control the PCF50606 [13] on the 4ARM and on the STEED board.

ADE7759 / ADS1256

This module controls the ADE7759 [10] and ADS1256 [19] measurement circuit via the SPI module. It will read the current measurement of the ADE7759 circuit. Because the SoC algorithm also needs an average and an integral of the current, this will be calculated each second. If a measurement or calculation is ready, it will notify General Control about it.

Batman

Batman contains all the functions to setup the P89LPC932 [20] on the STEED board.

SPI

This is the driver for the SPI communication. The ADS1256 [19], ADE7759 [10] and the P89LPC932 [20], controlling the Batman, communicate with the 4ARM board [4] via this bus.

Control Engineering

Page 32: ADE7759 Algo de Teoria

22 Evaluation System for State-of-Charge Estimation

I2C

This driver will handle the I2C communication. Obelix and Spinoza (not implemented yet) communicate with the 4ARM board via this bus.

3.2.2 Main Issues of the Software

The following Issues were present in the software: 1. The LPC2292 [5] resets itself, while enabling the extern interrupt detection.

As could be read in the errata sheet of the LPC2292 [21], this problem is a deviation of the LPC2292. The following information is presented in this errata sheet:

Introduction: The VPBDIV register controls the rate of the VPB clock in relation to the processor clock. EXTPOLAR and EXTMODE determine the operating parameters of the external interrupts.

Problem: A write to either the external interrupt polarity register (EXTPOLAR) or the external interrupt mode register (EXTMODE) will corrupt the VPBDIV register. A read of either EXTPOLAR or EXTMODE will be corrupted BY the VPBDIV register. If VPBDIV is “1” or “2” prior to any write to EXTPOLAR or EXTMODE, the CPU will hang up on the write to EXTPOLAR or EXTMODE.

Work-around: If VPBDIV is non-zero, write all zeroes to VPBDIV before reading or writing EXTMODE or EXTPOLAR, then write the proper value back to VPBDIV. In most applications this is a known and fixed value, but if there is a possibility of dynamic changes in VPBDIV, software will need to read VPBDIV, write zero to VPBDIV, read or write EXTMODE and/or EXTPOLAR, and then rewrite the value previously read from VPBDIV.

Code sample: VPBDIV = 0x0; /*EXTMODE */ EXTMODE = 0x1; VPBDIV = 0x1; VPBDIV = 0x0; /* EXTPOLAR */ EXTPOLAR = 0x0; VPBDIV = 0x1; VPBDIV = 0x0; /* Setting VBPDIV */ 2. The semaphore to start a current measurement was never released.

The semaphore, to start a current measurement, is released by the Interrupt Service Routine of the ADE7759 Task (see Figure 3.8 on page 26 ). The Interrupt Service Routine is executed when an interrupt of the ADE7759 Circuit is detected.

Because the interrupts of the ADE7759 circuit were not enabled, an interrupt was never given to the software. So the semaphore was never given free. By enabling the interrupts of the ADE7759, as introduced in Section 2.3.4 on page 14, the ISR is executed when an interrupt occurs, the semaphore is released and the ADE7759 Task is started.

3. The current measurements were not correct.

As introduced in Section 2.3.1 on page 12, the ADE7759 has a digital integrator. This integrator is enabled by default. Because the flowing current needs to be measured instead of the integral, the integrator needs to be disabled. This could be done by setting the MSB of the CH1OS register [10] to zero.

University of Twente

Page 33: ADE7759 Algo de Teoria

Current Measurement 23

3.2.3 SPI Driver

Note modes

Because the SPI has only one register for reading and writing data as well as only one interrupt source for both transmission complete and data received, it is needed to keep track of the SPI status internally. Therefore three modes are defined for the SPI driver: Read, Write and Idle. More information about these modes is provided in the text below.

Reserving the SPI bus

Because the SPI bus is used by multiple devices, some control need to be done, to prevent that two tasks are using the SPI bus on the same time. The reserved and available modes are further introduced in this report. These modes can be true or false. The available mode gives the used status of the SPI bus. If available is true, there is no other task using it so the bus can used directly. If not, the task wanted to use the bus needs to wait until the bus is available again.

The reserve mode is used to prevent releasing the bus while a task is still using the SPI bus. If the reserved mode is false the bus can be freed (set available to true) without any corruptions. If the bus wants to get freed, but a task has still reserved the bus, it needs to wait till it is not reserved anymore. A graphical representation of this process is given in Figure 3.6.

Figure 3.6: Reserving and freeing the SPI bus

Control Engineering

Page 34: ADE7759 Algo de Teoria

24 Evaluation System for State-of-Charge Estimation

Writing to the SPI

When a write function is called, the driver first waits for any reads to be finished. Next it checks if the DATA register is empty, so a direct write to a SPI device can be done. If this is not the case, the char needed to be send is placed in the (TX) queue. If the queue is full, the task trying to send the character will be blocked for a specified time.

Once the DATA register becomes empty an interrupt occurs, so the Interrupt Service Routine of the SPI driver is called. The ISR will place the next char from the queue (if it’s not empty) in the DATA register.

Reading from the SPI

When a read function is called, the driver first waits for an active read to be finished. Next it sets up the ISR to read mode. When this is done it writes dummy data over the SPI to drive the clock. When this dummy data has been written an interrupt occurs and so the received data is in the buffer. The Interrupt Service Routine fetches the received data and places it in the received queue. It then wakes up the read function, which passes the data from the queue to the calling task.

Note that to receive data from a peripheral it is usually needed to do a write first, but that’s up to the peripheral driver.

The Interrupt Service Routine

The Interrupt Service Routine can operate in two modes, the WRITE mode or the READ mode. The ISR is placed in the WRITE mode by calling the write function. While in the WRITE mode the ISR fetches a new TX char from the buffer and places it in the DATA register for transmission on a corresponding interrupt. Once the TX queue is empty the ISR places itself in the IDLE mode. The READ function places the ISR in READ mode. If the SPI flag (interrupt) goes hi while the ISR is in the READ mode the ISR fetches the character from the DATA register, places it in the RX queue and notifies the READ function. The ISR then returns to IDLE mode. When the ISR is in IDLE mode an interrupt should not occur. If it does, it is not cleared because the source is undetermined. This can be represented as Figure 3.7 on page 25.

University of Twente

Page 35: ADE7759 Algo de Teoria

Current Measurement 25

Figure 3.7: SPI flowchart

Initialization of the SPI driver

The initialization (init) function sets up everything necessary for the SPI, except for the I/O pins. The I/O pins should be configured in the hardware init function.

Closing the SPI bus

To close the SPI the function vSpiClose need to be called. The driver will not close the SPI until all pending characters are transmitted. In the meantime the task using the SPI will be blocked. Any characters still in the receive buffer will be discarded.

Changing the SPI settings

To change the SPI settings the SPI need to be closed first before initializing it again.

Selecting the SPI bus

Setting the Chip Select line of the peripheral is the responsibility of the peripheral driver.

Control Engineering

Page 36: ADE7759 Algo de Teoria

26 Evaluation System for State-of-Charge Estimation

3.2.4 ADE7759 Driver

In Figure 3.8 the implementation of the ADE7759 driver is shown.

Figure 3.8: ADE7759 driver

As shown in Figure 3.8 the ADE7759 Driver consists of 3 parts: • ADE7779 Task. • ADE7759 ISR. • ADE7759 Interrupt.

The ADE7759 Task blocks till the specific semaphore for this task is available. If an interrupt occurs on the ADE7759 circuit, the Interrupt Service Routine of the ADE7759 driver is executed. The ISR will disable the interrupt first to prevent an interrupt during the ADE7759 Task. Next it will make the semaphore available for the ADE7759 task. When the task notice that the semaphore is available, it will take the semaphore and start executing. If the measurements are ready, and the ADE7759 Task has notified General Control of a new available current measurement, the interrupt is enabled again. The task will start at the beginning waiting till the semaphore is given away again.

University of Twente

Page 37: ADE7759 Algo de Teoria

Current Measurement 27

Initialization of the ADE7759 circuit

To make the driver work, two things needs to be initialized first. • The ADE7759 interrupt detection. • The ADE7759 Circuit settings.

First, the initialization for the interrupt detection is made. A jump to the ADE7759 ISR is needed when an interrupt is received from the ADE7759 circuit. This initialization is done by the function cADE7759InitExtIRQ.

This will initialize the first external interrupt port of the LPC2292 [5], that if a negative flank is detected the software jumps to the ADE7759 ISR. The ISR will decide which action should be taken.

Second, the initialization of the ADE7759 settings is needed. This is done by configuring the on-chip registers of the ADE7759 [10] circuit.

The configurations need to be set as following: • Enable WSMP interrupt flag in the IRQEN register. • Disable the digital integrator by clearing the MSB of the CH1OS register. • Disable all features in the MODE register, set the data rate on 27.9 Kbps and set the

measure channel on channel 1 only.

Reading from and writing to the ADE7759 Circuit

To read from or write to the ADE7759 circuit, two functions can be used: • prvADE7759WriteRegister( xSpiHandle spiDEV, unsigned portCHAR adress, unsigned

long int data ). • prvADE7759ReadRegister( xSpiHandle spiDEV, unsigned portCHAR adress, unsigned

long int data ).

With these functions a read or a write to one specific register of the ADE7759 circuit can be done. The parameters are used for:

• spiDEV: which SPI device needs to write or read? (in this case only SPI0). • adress: the address of the register of the ADE7759 [10] circuit which need to be written or

read. • data: the data that needs to be writing to the given register if a write needs to be done. If

reading it is the value that was read from the register.

It is important that the SPI is reserved first before using these functions, so that no corruptions on the SPI bus are made.

Control Engineering

Page 38: ADE7759 Algo de Teoria

28 Evaluation System for State-of-Charge Estimation

ADE7759 Task

The ADE7759 task will measure the flowing current, and will calculate every second the average and the integral of the measured current. A detailed flowchart is shown in Figure 3.9.

Figure 3.9: ADE7759 task

The ADE7759 task will start when the semaphore is available. If the semaphore is available, the task will try to get a current measurement from the ADE7759 circuit. If this succeeds, the task will notify General Control of a new measurement ready. Next it will check if a new average and integral calculation has to be done. If one second is expired the task will calculate a new average and a new integral of the measured current. If the calculation is done it will notify General control about it. On the end of the task the interrupt is enabled again, and the task will wait for a new ADE7759 interrupt.

University of Twente

Page 39: ADE7759 Algo de Teoria

Current Measurement 29

3.2.5 Software Results

By implementing the SPI and ADE7759 driver as handled in the two sections before, the ADE7759 and SPI driver are working correctly now.

The driver can read from or write to the ADE7759. It will read the current flowing through the battery and calculates every second the average and integral of this current. When the current, the average or the integral has been measured or calculated, the ADE7759 task will notify General control about it.

Control Engineering

Page 40: ADE7759 Algo de Teoria
Page 41: ADE7759 Algo de Teoria

31

4 Temperature measurement

This Chapter will give a view of how the temperature of the battery is measured and calculated. Because the task to get a temperature measurement was already implemented correctly in the software, this part will not be handled. There are two new things implemented to make the temperature measurement work.

1. Implementation of a temperature sensor in the hardware. 2. Implementation of a function in the software to calculate the temperature.

4.1 Temperature sensor

To measure the temperature, a NTC resistor (thermistor) is used. This resister has a resistance depending on the temperature. If the temperature is high, the NTC has a low resistance. If the temperature is low, it has a high resistance. The following figure will show how a NTC resister could be used.

Figure 4.1: NTC circuit

The Voltage of Vout will be between Vref and GND depending on the value of the NTC and R1. R1 is given a fixed value of 10kΩ.

A NTC Thermistor of Vishay ( 23816405103 )[22] is used. The value of the resistance of this NTC at a specific temperature is shown in Table 4.1.

Temperature (°C) Resistance (Ω)

-10 55050 -5 42160 0 32560 5 25340

10 19870 15 15700 20 12490 25 10000 30 8059 35 6535 40 5330 45 4372 50 3606 Table 4.1: NTC resistance

If Vout is known, the resistance of the NTC could be calculated and the temperature could be looked up in Table 4.1.

Control Engineering

Page 42: ADE7759 Algo de Teoria

32 Evaluation System for State-of-Charge Estimation

4.2 Temperature calculation

Two things need to be known to calculate the temperature: • The resistance of NTC. • A function to calculate the Temperature, given the resistance.

To calculate the NTC resistance, Vref and Vout need to be known. The voltage of Vref is delivered by the PCF50606 [13] and has a fixed value. In this case Vref is 2.923V. Vout is connected to the Analog-to-Digital Converter of the PCF50606, so could be measured. The formula for calculating the resistance of the NTC, knowing these two values, is given below.

( )( )VrefV

VrefVRR

out

outntc /1

/*1

−= ( 4.1 )

To calculate Rntc at a specific temperature, the following formula is used.

⎟⎟⎠

⎞⎜⎜⎝

⎛⎟⎠⎞

⎜⎝⎛ −

+= 2981

2731*

25 * TB

Cntc eRR ( 4.2 )

R25C is the thermistor's nominal resistance at room temperature, B (beta) is the thermistor's material constant in Kelvin, and T is the thermistor's actual temperature in Celsius.

If the resistance is known but the temperature needs to be calculated, this formula ( 4.2 ) is used the other way around. Formula ( 4.3 ) follows:

273

2981)/ln(

125

−+

=

BRR

Tcntc

( 4.3 )

The values of B and R25c of the NTC applied in this system are 3977 and 10 kOhm, respectively (see [22]).

University of Twente

Page 43: ADE7759 Algo de Teoria

The Graphical User Interface 33

5 The Graphical User Interface

The Graphical User Interface (GUI) is a tool to show and control the SoC evaluation system. The measurements could be stored each second in a log-file. In this chapter an explanation about the usage, the log-file and a short description of the implementation of the code will be given.

5.1 User Manual

5.1.1 Getting started

When the GUI (GUI.exe) is started the following mobile phone will appear on the PC screen.

Figure 5.1: GUI startup screen

Control Engineering

Page 44: ADE7759 Algo de Teoria

34 Evaluation System for State-of-Charge Estimation

Before the measurements can be started, two steps are needed to be done. 1. Make sure the Comport settings are correct (see Figure 5.2 ).

Figure 5.2: Comport settings

2. Push the red button on the upper right to let the GUI connect to the SoC evaluation

system. (If a connection could be made, the button turns green).

When these two steps are done correctly, the GUI can be used. The screen of the mobile exists of three tabs.

• Settings. • Measurements. • SoC.

Every tab has its own function and will be explained in the next sections.

5.1.2 Settings Tab

As already shown in Session 5.1.1 on page 33 the settings of the comport could be set here. There are three more settings or options which could be set. These settings can set the measurements on or off. By checking, the specific measurement will be set on. By unchecking, the measurement will be set off. Note that first the current measurement has to be set on before the rest of the measurement are set on.

University of Twente

Page 45: ADE7759 Algo de Teoria

The Graphical User Interface 35

5.1.3 Measurements Tab

This tab will show the values of the measurements.

Figure 5.3: Measurements tab

Four measurements are shown: • Voltage, given in Volts [V]. • Current, given in milliamps [mA]. • Temperature, given in Kelvin’s [K]. • Time, given in milliseconds [ms].

The measured value is printed under each label. If the label is green, the measurement is turned ON. If the label is red, the measurement is turned OFF.

5.1.4 SoC Tab

This tab will show the data of the State-of-Charge of the battery.

Figure 5.4: SoC tab

Control Engineering

Page 46: ADE7759 Algo de Teoria

36 Evaluation System for State-of-Charge Estimation

Four things are shown in this tab: • Talk Time, given in hour: minutes [h:m]. • Standby Time, given in hour: minutes [h:m]. • SoC, given in percentage [%]. • SoC bar, given in percentage [%].

5.2 The Log-File

As already noticed at the introduction of Chapter 5 on page 33, it is possible to store the voltage, the current and the temperature measurements each second in a log-file. This logging could be set on or off with the button on the upper left of the mobile (see Figure 5.1 on page 33). The measurements will be stored in the log-file called ‘Log.txt’. The log-file could be found in the same directory as the GUI. An example of a log-file is shown in Figure 5.5.

Figure 5.5: GUI log-file

The shown data from the left to the right is: • Time, given in milliseconds [ms]. • SoC, given in percentage [%]. • Talk Time, given in hour and minutes [h:m]. • Voltage, given in Volts [V]. • Current, given in milliamps [mA]. • Temperature, given in Kelvin’s [K].

University of Twente

Page 47: ADE7759 Algo de Teoria

The Graphical User Interface 37

5.3 Software implementation of the GUI

In this section a description is given of the software implementation of the GUI. The general diagram of the software implementation is illustrated in the figure below.

Figure 5.6: General diagram of the software implementation of the GUI

As shown in Figure 5.6, the schematic diagram of the software application is divided in six modules: Comport, Control, Interface, Data, Timer and Log. The next sections will explain the purpose of each module.

5.3.1 Comport

This module will communicate with the 4ARM board [4] via the RS232 connection. A comport component [9] for Borland Delphi [8] is used to implement this module.

5.3.2 Data

If data is received by the comport module, the data is send to the Data module. The data will be examined and the module will check if a measurement is present in the data. If a measurement is present, the measured value(s) of this measurement(s) will be extracted and passed to the module Interface.

5.3.3 Interface

Interface controls the data that will be shown to the user on his PC screen. It puts all the measurements, received from Data, on the right location of the GUI. Interface will also notice the user if a measurement is running or not.

5.3.4 Control

This module will decide which action should be taken if the user pushes a button on the screen. It communicates with Comport to send data to the STEED board and it communicates with Log to make a Log-file or not.

Control Engineering

Page 48: ADE7759 Algo de Teoria

38 Evaluation System for State-of-Charge Estimation

5.3.5 Timer

This module will keep track off the measurements if they are received or not by data. If a measurement is not received within some period time, it will notify Interface about this. Interface then will turn the measurement off (the specific label turns red, see Section 5.1.3 on page 35).

5.3.6 Log

This module will take care of all the logging that needs to be done. The last received value of every measurement will be written in the log-file (Log.txt) each second.

University of Twente

Page 49: ADE7759 Algo de Teoria

39

6 Results

In this chapter the results on the end of this project will be presented. But before the measurements are shown some problems needs to be discussed first.

6.1 Problems 1. Too high leakage current

In the hardware of the evaluation board there is measured a leakage current, greater then expected. At a battery voltage of 3.69V and in the equilibrium state a current of ± -3mA is measured.. These measurements are shown in the table below.

Time [ms] SoC [%] Talk Time [h:m] Voltage [V] Current [mA] Temperature [K] 1254487 13 0:46 3.69 -3 297 1255489 13 0:48 3.693 -3 297 1256491 14 0:48 3.693 -4 297 1257493 14 0:48 3.69 -3 297 1258495 14 0:48 3.69 -4 297 1259497 13 0:46 3.693 -3 297 1260499 13 0:46 3.693 -3 297

Table 6.1: Leakage current measurements

The reason of this leakage current is probably a hardware error. Due to the lack of time and the fact that solving this problem is not a part of this project, this problem is not solved.

2. Wrong battery voltage

If the battery is charged with a current, for example 100mA, the voltage of the battery is increasing too fast as expected. An offset is added to the battery voltage. A measurement of the voltage and the current is shown in the table below.

Time [ms] SoC [%] Talk Time [h:m] Voltage [V] Current [mA] Temperature [K]

18716 18 1:3 3.732 18 297 20720 18 1:3 3.756 34 297 21722 18 1:3 3.775 40 297 26232 18 1:3 3.864 73 297 27234 18 1:3 3.887 83 297 29238 18 1:3 3.906 100 297 30240 18 1:3 3.936 110 297

Table 6.2: Voltage measurements with an offset

As shown in Table 6.2: Voltage measurements with an offsetTable 6.2 the voltage is 3.936V at a charge current of 110 mA. If the same battery is charged with a current of 110 mA, without the evaluation system, the voltage of the battery is measured at 3.75V. So some sort of offset is added to the battery. After investigations have been observed, this offset has been caused by an external current measurement device. This device introduced a resistance of 1.8 Ohms which caused an offset of 180 mV with a current of 100mA. As a result the current measurement device has not been further used. For this reason, the correct voltage is measured now.

Control Engineering

Page 50: ADE7759 Algo de Teoria

40 Evaluation System for State-of-Charge Estimation

6.2 Measurements Results

Although the first problem handled in Section 6.1 on page 39 still occur, the current could be measured correctly. It is not the current that is expected to be measured, but it is the current of the battery caused by the charger and the evaluation system. The value of the current through the battery differs from the expected value, but the measurements are still correct.

6.2.1 Current Measurements Results

The main goal of this project was to measure the current through a battery, using the ADE7759 [10]. The ADE7759 is working correctly now. It measures the current (in milliamps) by measuring the voltage drop on a sense resister of 20 mΩ and dividing it by the value of the sense resistor. In the next 3 tables some measurements are shown. The first table will show the measurements in the equilibrium state of the battery. The second table shows the discharge state and the third table will show the charge state of the battery.

Time [ms] SoC [%] Talk Time [h:m] Voltage [V] Current [mA] Temperature [K]

140548 12 0:43 3.700 -3 297 141550 12 0:43 3.702 -3 297 142552 12 0:43 3.700 -3 297 143554 12 0:43 3.700 -3 297 144557 12 0:43 3.700 -4 297 145558 12 0:43 3.700 -3 297 146560 12 0:43 3.700 -3 297 147562 12 0:43 3.700 -3 297 148564 12 0:43 3.700 -3 297 149566 12 0:43 3.700 -4 297

Table 6.3: Current measurements of the battery during the equilibrium state

Table 6.4 displays the measurements of the battery during its discharging state. As mentioned

in Section 6.1 on page 39 a leakage current of ± -3 mA is present which is shown in Table 6.1. So the measured current of the battery, with a discharge current of -100mA, will be -103 mA. These measurements are shown in Table 6.4.

Time [ms] SoC [%] Talk Time [h:m] Voltage [V] Current [mA] Temperature [K]

173012 12 0:42 3.660 -103 297 174014 12 0:42 3.660 -104 297 175016 12 0:42 3.660 -103 297 176018 12 0:42 3.660 -103 297 177020 12 0:42 3.660 -104 297 178022 12 0:42 3.660 -104 297 179024 12 0:42 3.657 -104 297 180026 12 0:42 3.655 -104 297 181028 12 0:42 3.657 -104 297 182030 12 0:42 3.657 -104 297

Table 6.4: Current measurements of the battery during discharging with -100 mA

Table 6.5 on page 41 displays the measurements of the battery during charging with a current

of 100 mA. As mentioned in Section 6.1 on page 39 a leakage current of ± -3 mA is present. So the measured current of the battery will be 97 mA.

University of Twente

Page 51: ADE7759 Algo de Teoria

Results 41

Time [ms] SoC [%] Talk Time [h:m] Voltage [V] Current [mA] Temperature [K]

281128 12 0:42 3.730 97 297 282130 12 0:42 3.730 97 297 283132 12 0:42 3.730 97 297 284134 12 0:42 3.730 97 297 285136 12 0:42 3.730 97 297 286138 12 0:42 3.735 97 297 287140 12 0:42 3.732 97 297 288142 12 0:42 3.735 97 297 289144 12 0:42 3.735 97 297 290146 12 0:42 3.735 97 297

Table 6.5: Current measurements of the battery during charging with 100mA

6.2.2 Temperature Measurement Results

Another goal that was introduced later on during this project was to make the temperature measurement, using the PCF50606 [13], to work. The temperature measurement is working now. A NTC resistor is implemented in the hardware and a function for calculating the temperature is implemented in the software. The temperature is calculated by measuring the resistance of the NTC and getting the temperature that represents this resistance. The temperature measurement can be found in the tables given in Section 6.2.1 on page 40. The measurements were taken at a temperature of 25 ˚C which is the same as 297 K

6.2.3 Graphical User Interface Results

To control the real-time SoC evaluation system, a GUI has been designed. The GUI gives the opportunity to start the voltage, current and temperature measurements and display the measured values in a graphical way on the PC screen. The GUI gives also the opportunity to store a log-file, with all the measured values each second, so that a history of the measurements can be saved. The results of the GUI could be found at Chapter 5 on page 33.

Control Engineering

Page 52: ADE7759 Algo de Teoria

42 Evaluation System for State-of-Charge Estimation

7 Conclusions and Recommendations

The final purpose of the entire project is to develop a real-time evaluation system, which could be used for a SoC estimation algorithm. The main goal of the part of the project presented in this report has been to make the current measurements working, using the ADE7759 [10] circuit. The goals to make the temperature measurements work and to design a Graphical User Interface (GUI) were presented later on during this project. For this purpose, the two boards available were presented and briefly described and also the software support.

The second chapter of the report presented theoretical fundamentals regarding the SoC estimation method, the SPI protocol and the circuit used for measuring the current of the battery.

In Chapter 3 to 5 the implementation of the current measurement, the temperature measurement and the GUI are presented.

In the end (Chapter 6) the results of this project are presented.

7.1 Conclusions

All the parts that were handled in this report are working now. The ADE7759 driver can communicate with the ADE7759 so it can receive current measurements. The only problem is that first the current measurements need to be set on before some other measurements could be set on. This has probably something to do with incomplete implementation of the software. The hardware and the function to measure the temperature of the battery are also implemented correctly now. And the design of the GUI is finished. The GUI can start and stop measurements and it can receive the measurements given from the 4ARM board [4] to show this in a graphical way on a PC screen.

The final conclusion is that all the goals of this project have been met.

7.2 Recommendations

A recommendation for future work is to solve the problem why the current measurement needs to be set on first before other measurements. Also another recommendation is to solve the problem of the too high leakage current of the evaluation system.

University of Twente

Page 53: ADE7759 Algo de Teoria

Appendix I – Communication Protocol 43

Appendix I – Communication Protocol

Here’s an overview of all the different commands. Note alternatives are listed below the command. Eg [CHG:BAT:CV] means that the 2nd parameter can be BAT or OBX.

Abbreviation Description

0.1K 0.1-kilo samples per second. 0.5K 0.5-kilo samples per second. 10S 10 samples per second. 14K 14-kilo samples per second. 15K 15-kilo samples per second. 15S 15 samples per second. 1K 1-kilo samples per second. 2.5S 2.5 samples per second. 25S 25 samples per second. 27.9K 27.9-kilo samples per second. 2K 2-kilo samples per second. 3.5K 3.5-kilo samples per second. 3.75K 3.75-kilo samples per second. 30K 30-kilo samples per second. 30S 30 samples per second. 50S 50 samples per second. 5S 5 samples per second. 60S 60 samples per second. 7.5K 7.5-kilo samples per second. 7K 7-kilo samples per second. 1 Binary read Analog most recent measurement 2 Binary read Analog average measurement 3 Binary read TI most recent measurement 4 Binary read TI average measurement A Ack (short to save chars) A2D Analog to digital ABACK Automatic backwards transmission (errors etc) ANA Analog devices IC (ADE7759) B Prints information in the GUI. The string is obtained

from the Text parameter. Info: is added to indicate that it is just information.

B1-4 Return on 1-4 BAT Batman BOOST Boost charging BOOST-CC Indicates that the system is in BOOST CC mode. BOOST-CV Indicates that the system is in BOOST CV mode. CALIB Calibrate / calibration register CC Constant current CCP Pulse charging CHG Charge CLAMP Clamp level COMSS Com speed CURR Current CV Constant voltage DCX DCDC DIS Discharge EXT External

Control Engineering

Page 54: ADE7759 Algo de Teoria

44 Evaluation System for State-of-Charge Estimation

I Current (in A) LBX Local Obelix All LBX commands are not

implemented. LED Light Emitting Diode LOG Logging (output of average measurements) M Measurement OBX Obelix on STEED OFF Off ON On OUTP Output pins PING Nop command, just returns a checksum. R Prints an error in the GUI. The string is obtained from

the Text parameter. *** ERROR is added to indicate that it is an error.

RD Read READY The experiment has reached its end. REG-- Register at – where – is an address. E.g. 01. RTE Return end S State SET Set SOC State of Charge SOCE Sets the SoC level (in%) on which to terminate the

charge cycle. Only effects the charge cycle if SOC is selected as termination condition.

SOFTWARE BUILD The version of the software (integer number) SPEED Update rate of measurement SPX Spinoza STATUS Status STOP Stop charging / discharging. T Temperature (in °C) TARGET BOARD ID The type of board connected (integer number) TARGET BOARD SERIAL

The SERIAL of the board connected (integer number).

TERM Sets the termination condition for charge cycle. Text Text string to print (without /r/n). TI Texas Instruments IC (ADS1256) Time

Contains the time in ms since the start of the experiment.

TIMEE Sets the duration (in seconds) of the charge cycle. Only effects the charge cycle if time is selected as termination condition.

TT Talk time in hour and minutes ST Talk time in hour and minutes V Voltage (in V) VE Sets the Voltage level (in Volt (currently in mV)) on

which to terminate the charge cycle. Only effects the charge cycle if V is selected as termination condition.

Value Return value, in V, I, %, or °C. VER Version of the software / board VEND Voltage terminination level VOLT Volt WR Write

Table 7.1: UART Abbreviation list

University of Twente

Page 55: ADE7759 Algo de Teoria

Appendix I – Communication Protocol 45

Mode Select Option 1 Option 2 Option 3 / Description

CHG BAT CV CC BOOST OBX CV CC SPX CV CC DCX CV CC EXT CV CC STOP Equal to LOD STOP SET PRECC CURR value in I VEND value in V CCBOOST TERM V TIME SOC CURR value in I TIMEE value in sec SOCE value in SoC VE value in V CLAMP value in V e.g. 4.2 CVBOOST TERM TIME SOC VOLT value in V TIMEE value in sec SOCE value in SoC CLAMP value in I CC TERM V TIME SOC CURR value in V TIMEE value in sec SOCE value in SoC VE value in V CLAMP value in V e.g. 4.2 CV TERM TIME SOC VOLT TIMEE SOCE CLAMP value in I DIS GSM CC STOP Equal to CHG STOP BAT RD REG01 REG02 REG03 REG04 PING

Control Engineering

Page 56: ADE7759 Algo de Teoria

46 Evaluation System for State-of-Charge Estimation

OBX LOG ON OFF RD A2D I IA V T WR A2D I ON/OFF V ON/OFF T ON/OFF RES (BIT) 8/10 LED value led number value patron number LBX WR A2D RES value 8 or 10 LD value led number value patron number ANA RD A2D I IA WR A2D I ON/OFF SPEED 27.9K 14K 7K 3.5K CALIB value 0 up to +- 31 LOG ON OFF TI LOG ON OFF WR SPEED 0.1K 0.5K 10S 15K 15S 1K 2.5S 25S 2K 3.75K 30K 30S 50S 5S 60S 7.5K RD A2D V VA I IA SOC SET V OBX TI I TI ANA T OBX RD SOC T

University of Twente

Page 57: ADE7759 Algo de Teoria

Appendix I – Communication Protocol 47

PING ABACK ON OFF RTE - LF CRLF COMSS ascii int

value

VER OUTP WR value in ascii binary

(number of pins still need to be defined) e.g. 0b0110

1 2 3 4

Table 7.2: PC Protocol Send list

Keep in mind that there are logical dependencies. For example you cannot turn on the logging using the ADE7759 if you have not defined the speed rate for the ADE7759. These dependencies are not listed here as they are logical and the application will report any mistakes made (if reporting is not turned of).

Return data: Data returned by the 4ARM always starts with an and ends with an . After the the 4ARM always send a carriage return and line feed unless this is turned off. Also, the 4ARM can always send data unless this is turned off.

Control Engineering

Page 58: ADE7759 Algo de Teoria

48 Evaluation System for State-of-Charge Estimation

Mode Select Option 1 Option 2 Option 3 / Description

M TI V value in V e.g. 0.2

Time

VA value in V e.g. 0.2

Time

I value in I Time ANA I value in mA Time IA value in mA Time IINT value in mA Time OBX I value in mA Time IA Value in mA V Value in V T Value in C SoC value in % Time TT Value in h:m Time ST Value in h:m Time BAT REG1 REG2 REG3 REG4 REG5 S CHG PRECC CC CV CCBST CVBOOST OFF PULSE READY R Text BAT PING

ACK

BAT PING NAK

B Text A value of

CRC16

B1 raw 40 bits B2 c double

format

B3 raw 24 bits B4 c double

format

Table 7.3: PC Protocol Receive list

= Working = Fully implemented but not working = Partially implemented = Not implemented

University of Twente

Page 59: ADE7759 Algo de Teoria

References 49

References

[1] Cornelis Korver, “State-of-Charge in GSM Applications”, Report Number 001M05, January, 2005

[2] J. Garche, A. Jossen, “Battery Management Systems (BMS) for Increasing Battery Life-time”, TELESCON 2000, IEEE Cat. No.00EX424, Dresden, 2000

[3] Emdes, “50-0080-1”, STEED Emdes Layout, October 2004 [4] Emdes, “50-0080-1”, 4ARM Emdes Layout, June 2004 [5] Philips Semiconductors, “LPC2119/2129/2194/2292/2294”, USER MANUAL, May 2004 [6] Real-time Operating System “FreeRTOS”, www.freertos.org[7] Rowley associates LTD “Rowley CrossWorks”,

www.rowley.co.uk/documentation/arm/index.htm[8] Delphi development environment “Borland Delphi”, www.borland.com/delphi/[9] Comport component for Delphi “Comport”, http://sourceforge.net/projects/comport/[10] Analog Devices, “ADE7759 – “Active Energy Metering IC with di/dt Sensor Interface”,

Datasheet, 2002 [11] H.J. Bergveld, W.S. Kruijt, P.H.L. Notten, “Battery Management Systems, Design by

Modelling”, Philips Research book series, vol. 1, Kluwer Academic Publishers, Boston, 2002 [12] V. Pop, H.J. Bergveld, P.H.L. Notten, P.P.L. Regtien, “State-of-Charge Indication in Portable

Applications”, submitted ISIE2005, Croatia, 2005 [13] Philips Semiconductors, “PCF50606 Controller for Power Supply and Battery Management”,

Datasheet, August 2002 [14] L. Bowen, R. Zarr, S. Denton, “A MicroController-Based Intelligent Battery System”, IEEE

AES Systems Magazine, May 1994 [15] Aylor, J.H.,Thieme, A., Johnson, B.W., “A battery State-of-Charge indicator for electric

wheelchairs”, IEEE transactions on industrial electronics, Vol. 39, No.5. October 1992 [16] Dreer, H., “Product Test Report, Curtis Wheelchair Battery Fuel Gauge”, Curtis Instruments,

Inc., Livermore, 1984 [17] V. Pop, D. Danilov, “Mathematical Model for the EMF(SoC) Simulation”, preliminary draft,

Measurement and Instrumentation, University of Twente, Enschede, 2004. [18] Dallas Semiconductors, “Inaccuracies of estimating remaining cell capacity with voltage

measurements alone”, App. Note 121, 2000 [19] Texas Instruments, “ADS1256 - Very Low-Noise, 24-Bits Analog-to-Digital (A/D)

Converter”, Datasheet, June 2004 [20] Philips Semiconductors, “P89LPC932”, Datasheet, January 2004 [21] Philips Semiconductors, “LPC2292”, ERRATA SHEET, March 2006 [22] Vishay BCcomponents, “NTC Thermistors, Accuracy Line 2381 640 5103”, Datasheet,

April 2005

Control Engineering