Download an2107_a_multi_chemistry_battery_charger.pdf

Application Note
AN2107
A Multi-Chemistry Battery Charger
By: Victor Kremin
Associated Project: Yes
Associated Part: CY8C26xxx
Summary
The multi-chemistry battery charger design is presented. The charger is capable of charging the
Ni-Cd, Ni-MH, Li-Ion, Li-Pol and SLA batteries without any hardware/software modifications. The
dedicated PC-based software has been developed to configure the charger and perform real-time
charging process visualization and analysis. This charger can be used as a standalone
application to charge various battery types or embedded into consumer, home appliances or
industrial applications. Alternative charger applications are studied as well.
Introduction
Modern applications use various battery types.
Sealed Lead-Acid (SLA) batteries are used
typically in cost-sensitive applications where cost
is more important than capacity/volume ratio. The
typical application examples include Uninterruptible Power Supplies, back-up power in
security or surveillance systems, and stationary
lighting systems. Nickel-Cadmium (Ni-Cd) and
Nickel-Metal-Hydride (Ni-MH) batteries are
characterized by moderate capacity/volume ratio
and are widely used in various consumer
electronics. The Lithium-Ion (Li-Ion) and the
Lithium-Polymer
(Li-Pol)
batteries
are
characterized by the greatest capacity/volume
ratio and can be found in notebooks, pocket PCs,
cell phones and newer consumer applications.
Each battery type needs a dedicated charging
scheme to properly charge a battery. Despite the
chipmaker’s suggestions that there are various
integrated circuits to implement battery chargers,
these circuits are designed to charge only
predefined battery types and cannot easily be
retuned to interact with other battery types or
implement additional features.
Each feature implementation needs dedicated
components thus increasing the device
complexity and price. The unique architecture of
PSoC allows building the multi-functional battery
charger with minimal external components and a
universal, multifunctional system at a very
affordable price. When a user wants to implement
additional functions or support a new battery
type, only the firmware needs to be modified. The
PSoC in-circuit and self-programming capabilities
make these operations simple.
This Application Note describes the universal
battery charger that can process various battery
types
without
hardware
and
firmware
modifications. Users must select an appropriate
battery type and battery parameters via PCbased software. These settings are then
uploaded into non-volatile memory and the
charger is ready to operate as a standalone
application. Alternatively, the charger can be
controlled via a PC as a slave device to provide
real-time, battery-charging process information.
AN2107
Table 1. Battery Charger Technical Data
Item
Item Value
Supported Battery Capacity (Determined by Step-Down Converter Parameters)
0.1-1.5 A*h
Maximum Battery Voltage (Determined by External Resistor Divider)
7.8 V
Battery Temp. Measuring Range (Re-configurable in Charger-Control Software)
0 … 64ºC
Maximum Total Charge Time
18 h
Battery Current Measuring Error (After Calibration)
1-3%
Battery Voltage Measuring Error (After Calibration)
0.5%
User Interface
2 Buttons and 3 State LEDs
PC Communication Interface
RS232
PC Communication Speed
19200 baud
Battery Charging Methods
The following section describes the battery
charge methods for various battery chemistries.
Detailed
information
concerning
battery
chemistry, operation and charging methods can
be found in the online resources at the end of this
note [1-5]. Reference [1] provides excellent
information concerning batteries and various
aspects of use. The reader must see this
reference first. Fast-charge methods, which allow
users to fully charge a battery within several
hours, are described briefly.
Note that during this section the symbol CA, [h-1]
will be used to mark charge current to batterycapacity relation. If not otherwise defined, all
battery voltages are related to a single cell.
Please note that all numerical values are given
for reference purposes only. The exact data must
be found in the battery’s data sheet or obtained
from the manufacturer.
Ni-Cd and Ni-MH Batteries
The rapid charging process of these batteries can
be separated into three distinct stages: activation
charge, rapid charge, and trickle charge. The
constant current source must be used to provide
battery charging during these phases.
First of all, the battery temperature must be
analyzed. If the battery temperature does not fall
into a predefined range, typically +10º…+ 50ºC,
only a small-current trickle charge is allowed. The
activation and rapid charge stages can be
permitted in an opposite case scenario.
If the battery was excessively discharged, the
activation charge stage must be used first. During
this stage the battery is charged with current
0.2-0.3 CA until the battery voltage reaches
0.8-1 V/cell or activation charge timeout elapses.
If the activation charge stage is terminated by
timeout, the battery is considered as inoperative
and the charge process is terminated with an
error. This can happen if the battery was
irreversibly discharged or contained shorted cells.
The rapid charge stage replaces activation
charge after battery voltage reaches the rapid
start threshold. The battery charge current is set
to 0.5-1 CA in this stage. This stage continues
until rapid termination conditions are true or
timeout elapses. If rapid charge stage was
terminated by timeout, the charging process is
terminated with an error similar to activation
charge timeout termination. This happens
typically when a battery is damaged or the charge
current was not selected in compliance with
battery capacity. Rapid charge timeout can be
calculated to transfer 150% of the nominal battery
charge; it corresponds to 90 min at 1 CA rapid
charge current. The rapid charge stage must be
switched to trickle charge stage if even one of the
following events has happened:
AN2107
The battery voltage dropped from its
maximum value. The battery voltage
drop level, ∆V , must be set equal to
15-20 mV/cell for Ni-Cd batteries and 510 mV/cell for Ni-MH. Please note that if
the battery was left unused for a long
period
of
time
or
excessively
discharged, the battery voltage can start
dropping
before
the
battery
is
completely
charged.
This
false
termination phenomenon must be
blocked by initial delay to prevent the
incomplete rapid charge termination.
Typical timer interval is 5-10 minutes.
The battery voltage reached its upper
threshold limit. This limit must be set to
1.8-1.9 V/cell and prevents the battery
from overcharging at the end of battery
life when cell resistance rises.
The battery temperature-raising speed
increased. Some portion of the electrical
energy is converted into battery
chemical energy and the rest is
dissipated into heat during the charging
process. This useful portion is
maximized during the initial rapid charge
phase and minimized when the battery
is completely charged. In this case
virtually all the electrical energy is
converted into heat, causing a speedy
increase in battery temperature. The
temperature derivate must be set to 12 ºC/min to detect rapid charge
completion.
Note that Ni-Cd battery charging is an
endothermic reaction, which causes the
battery temperature to decrease during
the initial rapid charge phase. The NiMH charge reaction is exothermic as
opposed to the Ni-Cd charge reaction.
For Ni-MH batteries, temperature
increases constantly with derivate rising
in the final rapid charge phase.
Battery temperature leaves the allowed
temperature range. If the battery was
placed in a very hot or cold ambient
space during charge (for example, under
direct sunlight), the battery temperature
can leave the safe rapid charge range. If
this happens the rapid charge must be
suspended until the battery temperature
returns to the predefined range. Only the
trickle charge current is allowed in this
situation.
The trickle charging stage is characterized by a
much smaller current charge; 0.02-0.05 CA is the
typical value. The timer terminates the trickle
stage. Trickle charge time is 15-20 hours for
these batteries.
Note: Some Ni-Cd batteries have memory issues
due to decreasing battery capacity after several
charging cycles in which the battery was not
discharged completely before the charge started.
To eliminate this phenomenon, the battery must
be discharged completely in the Ni-Cd battery
charger.
Figure 1 illustrates the battery-charging process
previously described.
AN2107
5
Vr max
6
4
−V
Vb
V rs
7
Irap
2
Legend:
1
1
Iact
Itrc
3
2
Irap - battery rapid charge current, 0.5-1 CA
3
Itrc - battery trickle charge current 0.033-0.05 CA
- false termination voltage rising, blocked by 5-10 min timer
4
Ich
trch
Vb - battery voltage
5
t
6
tсh
7
8
T rmax
8
dTb
dt
11
9
NiMH
10
11
10
T rmin
9
Ich - battery charge current
Iact - battery activation charge current, 0.2-0.3 CA
Tb
Vmax - rapid charge termination voltage, 1.8-1.9 V/cell
- rapid charge termination voltage dropping,
5-10 mV/cell for NIMH and 15-20 mV/cell for NICd
Vrs - rapid start voltage, typically 0.8-1.0 V/cell
Trmax - battery rapid charge maximum temperature, 45-60oС
Trmin - battery rapid charge minimum temperature, 5-15oC
Tb - battery temperature
NIMH and NiCd batteries temperature charge time dependence
-rapid charge termination temperature rising, 1-2oC/min
tr ch - rapid charge termination time, 90 min at 1 CA charge
tch - trickle charge termination time, 10-20 hours
NiCd
t
Figure 1. Ni-Cd/Ni-MH Battery Charge Profile
The SLA battery charging process can be
separated into three different stages (activation,
rapid, trickle) too. Each stage must be protected
by the timer, similar to the Ni-Cd and Ni-MH
batteries. The battery charge is allowed if the
battery temperature falls into a predefined range;
typical values are +5ºC...+45ºС.
The battery manufacturer recommends that the
rapid-charge current limit for SLA batteries be set
to 0.3-1 CA and voltage limit set to
2.2-2.45 V/cell. The trickle charge stage follows
the rapid charge stage. In trickle charge the
battery voltage and current limitation levels are
lower than in the rapid charge; typical values are
2.25 V/cell and 0.1 CA. The timer terminates the
trickle stage.
If the battery is over discharged, the activation
stage must be used first. This stage is useful to
detect shorted or damaged cells. The battery is
charged by constant current source at 0.1-0.2 CA
until cell voltage reaches 1.8-2.0 V for SLA. The
timeout for activation stage can be set to
3-5 hours. Once battery voltage reaches rapidcharge starting level, the rapid charge is started.
Note that other charge algorithms can be used
with SLA batteries. The algorithms use constant
charge current and analyze the absolute value of
the battery voltage and its second derivate to
rapid charge termination, pulse-charging methods
etc. Please see [1] for details. This SLA charge
method is most recommended by battery
manufactures.
Rapid charge is provided by the regulated source
that operates in constant current mode until just
before the battery voltage reaches the predefined
value. When the battery voltage reaches this
level, the charge source operates as constant
voltage source. Rapid charge terminates when
the charge current drops below predefined value;
typically 0.05-0.2 CA.
Figure 2 illustrates the SLA battery-charging
process previously described.
SLA Batteries
AN2107
6
Vbmax
Legend:
5
V blim
Vb
Ich - battery charge current
1
4
Vrs
2
2
3
Irap
1
Iact
Itrc
tcv
trch
3
ttch
- battery trickle charge current 0.025-0.05 CA
4
5
- constant-current / constant voltage switching point
7
7
Irtn
Itrc
Vb - battery voltage
Vrs - rapid start voltage, typically 2.0 V/cell
6
Ich
Iact - battery activation charge current, 0.1-0.2 CA
Irap - battery rapid charge current, 0.7-1 CA
Vmax - emergency shutdown voltage, 2.6 V/cell
- rapid charge termination current, typically 0.2 CA
8
Trmax - battery rapid charge maximum temperature, 45 oС
9
Trmin - battery rapid charge minimum temperature, 0o C
Tb - battery temperature
trch - rapid charge timeout time
t
ttch - trickle charge termination time, 1-5 hours for SLA
tcv - constant voltage charge time
8
Trmax
Tb
Trmin
9
t
Figure 2. SLA Battery Charge Profile
The Li-Ion and Li-Pol Batteries
Despite principal differences in battery chemistry,
the battery charging principles of Li-Ion and Li-Pol
are similar to SLA batteries. The main differences
lie in the charge-parameter values and the
demand for accuracy in the charge settings.
Please note that the Lithium-based batteries are
very sensitive to the charge voltage and current,
discharge limit, and are assembled into special
battery packs with built-in thermistor and
protective circuit. This circuit protects the battery
from over charge and over discharge, and limits
load/charge current to safe values. Without this
circuit, the battery can explode under adverse
conditions. The charge source voltage limiting
accuracy must be not be less than 1 %, which
causes additional challenges in the Li-Ion/Li-Pol
battery’s charger design.
Li-based batteries use a two-stage charge profile
(activation, rapid). The long trickle charge mode
is eliminated because batteries that contain
Lithium cannot accept additional charge without
battery degradation. The charge process can be
activated only if battery temperature is within
predefined limits.
The typical temperature values are +5…+50ºC. If
the battery voltage is less than 2.9-3.0 V/cell, the
battery must be activated first. In the activationcharge stage, the battery is charged with
constant current (0.05 - 0.15 CA) until battery
voltage reaches the level given above. The
activation charge timeout is set to 1.5-2 hours.
The activation charge can diagnose battery
health and identify troubles such as damaged or
shorted cells.
The rapid-charge stage starts after the activation
charge finishes without error. The rapid charge
consists of two modes. When the battery voltage
is less than the predefined level (4.1 or 4.2 V,
depending on battery type), the charge is
processed with constant current. When the
battery voltage reaches this level, the charge
source switches to constant-voltage mode and
the charge process is terminated when the
current drops below some predefined limit. The
battery manufactures recommend use of the
rapid-constant current at 0.5-1.0 CA and rapidtermination current at 0.07-0.2 CA.
AN2107
The rapid charge must be protected by timer
implementation. The rapid charge timeout
consists of the sum of the constant current and
constant voltage times. The constant current time
is estimated to provide 100-120% of the battery
charge because during this stage the battery is
charged up to 70-80%. The nominal value is 6075 minimum at 1 CA rate. The constant voltage
charge time is limited to two hours according to
the manufacturer recommendations.
As described early, there is no trickle charge for
Li-Ion batteries.
Figure 3 depicts the charge profile for Li-Ion/LiPol batteries:
5
Vbmax
Legend:
4
V blim
Vb
Ich - battery charge current
1
3
Vrs
2
2
Vb - battery voltage
Irap
3
4
5
6
Ich
1
Iact - battery activation charge current, 0.1-0.2 CA
Irap - battery rapid charge current, 0.7-1 CA
Iact
7
8
6
Vrs - rapid start voltage, typically 3 V/cell
- constant-current / constant voltage switching point
Vmax - emergency shutdown voltage, 4.3 V/cell
- rapid charge termination current, typically 0.1 CA
Trmax - battery rapid charge maximum temperature, 45 oС
Trmin - battery rapid charge minimum temperature, 0o C
Tb - battery temperature
Irtn
tcv
trch - rapid charge termination time
tcv - constant voltage charge time
t
trch
7
Trmax
Tb
Trmin
8
t
Figure 3. Li-Ion/Li-Pol Battery Charge Profile
Conclusion
In spite of the fact that various battery types are
characterized by different charging strategies and
rapid charge termination criteria, here are some
common characteristics of the battery-charge
profiles:
Regardless of battery chemistry, the
battery charging process can be
separated into several distinct regions
with different charge currents and
voltages.
For safety reasons, a timer must guard
each charge stage.
There are different charge modes
depending on if the battery temperature
falls into a defined region or not. For
some batteries the charging process is
completely
prohibited
when
the
temperature is outside a defined range.
Others tolerate only a small-current
charge.
To provide battery charge, the
programmable
source
with
both
constant current and constant voltage
operational modes must be used to
satisfy various charge stages.
The primary differences in the charge process lie
in termination conditions, programmable source
current and voltage values, and how they relate.
AN2107
The Charger Hardware
Multiplexer MUX for PGA/INA
output-signal switching
Analog-to-digital converter ADC to
digitize the analog signals
Central
processor
CPU
to
implement the charge algorithms
and
perform
charger
control
functions
Pulse-width modulator PWM to
drive step-down converter
RS232 level translator for remote
control and monitoring
User interface UI to allow user
interaction with device
SMBUS interface is intended to
interact with smart battery packs or
can be used as an alternative data
exchange channel
Figure 4 illustrates the general charger flow-chart.
The device consists of:
Power supply PS to power all
charger modules
Step-down converter SDC to
provide the battery charge energy
Battery interface BI to transform
battery current and voltage for
suitable processing by PSoC
signals
Switching matrix SWM to switch
battery interface signals
Instrumentation amplifier INA to
measure charge current
Programmable gain amplifier PGA
to measure battery voltage and
temperature
RS232
UI
SMBUS
PS
ADC
CPU
PWM
SDC
SWM
BI
PSOC
internals
INA
MUX
PGA
T
Figure 4. Charger Flowchart
The Schematics
The Figures 5 and 6 depict charger schematics. Note that the charger only consumes ports P0 and P1.
AN2107
VDD
Q1B
MMDF1300
3
6
5
50uH
D1
PWM_OUT
CCHARGE
MBR360
R2
220
D2
MBR360
4
R1
220
L1
C1
330u/25V
C2
2,2u
R5
47R
R6
47R
7
8
Q2
MTD5N06/MC
PWM2
MMDF1300
R8
10k
1
R7
10k
R4
47R
Q1A
2
PWM1
R3
47R
V_SENSE
V_BAT_MINUS
AGND
AGND
R13 330
R14 330
U1
VCC
1
2
3
4
5
6
7
8
9
10
11
12
13
Rx232
Tx232
PWM1
PWM2
14
P0[7]
P0[5]
P0[3]
P0[1]
P0[6]
P0[4]
P0[2]
P0[0]
P2[7]
P2[5]
P2[3]
P2[1]
P2[6]
P2[4]
P2[2]
P2[0]
SMP
XRES
P1[7]
P1[5]
P1[3]
P1[1]
P1[6]
P1[4]
P1[2]
P1[0]
28
R16 330
VCC
27
26
25
24
L2
L3
AGND
R9
10k
CHARGE
R10
10k
R11
10k
J1
ERROR
L4
1
2
R18
1R
R19
1R
R20
1R
BAT_LOAD
R21 30k
V_BAT_PLUS
J3
V_BAT_MINUS
2
1
J2
R22 30k
BAT_P
BAT_M
1
2
3
V_BAT_TEMP
BAT_CON
SMBus
19
SW1
18
17
16
15
U2
2
SW2
C3 0.1u
C1-
V+
C1+
C2+
V-
3
C4
0.1u
Vss
C5 0.1u
4
5
R23
470
CY8C26443
R17
1R
R15 30k
TRICLE
V_BAT_PLUS
V_BAT_TEMP
23
22
21
20
R12
10k
7
C6
0.1u
6
11
9
Tx232
Rx232
1
10
C2T1IN
R1OUT
T1OUT
R1IN
EN
FOFF
INVALID FON
13
8
CTX
CRX
16
12
VCC
5
9
4
8
3
7
2
6
1
P1
DB9
MAX3221E
Figure 5. Charger Part Schematic
VDD
VCC
R24
330
4
3
C7
470u
C8
C9
0.33uF
0.33uF
C10
0,33u
C11
0,33u
C12
0,33u
D4
LED
YELLOW
4
DCPOWER24V
2
VOUT
-
P2
2A
VIN
3
LP2950-5 (DPAK)
+
D3
U3
GND
1
1
J4
VDD
VCC
1
2
3
EXT_POWER
Figure 6. Charger Power-Supply Schematic
The dual MOSFET Q1 is a step-down converter
current switch. Q1A acts as a level translator and
Q1B has current switch role. The step-down
converter operation frequency was set to
100 kHz, but easily can be adjusted in the
firmware. MOSFET Q2 is a battery discharge
switch used in the processor-controlled battery
discharge for Ni-Cd batteries to eliminate the
battery memory effect that was previously
described.
Note that excellent information concerning the
switch-mode converter design and customization
can be found in [8].
The resistive network (R9-R12, R15, R17-R20R22) forms the battery interface that allows
transformation of the battery current and voltage
into suitable signal levels for PSoC.
AN2107
This interface allows users to accurately measure
battery voltage, charge/discharge current and
temperature.
The LED L2 indicates ACTIVATION or RAPID
charge. L3 indicates the TRICKLE or the
WAITING states and L4 displays the charger
ERROR conditions. The lighting of both L2 and
L3 corresponds to the battery discharge process.
The level translator U2 converts RS232 signals
into CMOS-compatible levels. The analog ground
bias was set to 2Vref, or 2.6V.
The current-sense resistor assembling R17-R20
was moved from the battery load current loop to
eliminate current sensing resistor loss when the
battery serves load.
The power supply consists of the linear regulator
U3 to power processor and level translator. Note
that the external DC power supply must be used
to charge power supply. The modern low-cost
high voltage switching power regulators from
many manufacturers [6] can be used to build AC
main charger power supply.
Note that for applications with large battery
voltage it is better to move current sense resistor
into negative battery lead path to eliminate large
common-mode voltages. Only minor changes
must be done in the firmware to support this
modification.
Battery pack is connected via 3-pin connector J2.
The thermistor must be connected to negative
battery lead (battery manufacturers connect the
thermistor in this way only). The connector J1 is
intended for battery load connection. J3 is the
SMBUS data connector.
The PSoC Internals
Most charger functions are implemented by user
modules in the project’s main configuration but
dynamic re-configurable blocks are used to
perform some measurements. Figure 7 depicts
processor internals:
The charger user-interface part is implemented
via two buttons, SW1 and SW2, to charge
process START/STOP control and three LEDs to
display charge status.
[P1.3]
PWM1
PWM
PWM
DBA0
DBA1
24V1
ADC
DBA2
24V1
Baud
Timer
DBA3
[P0.3]
AGND
BUF00
48M
REFMUX
ACA00
DBA03
Tx232
Rx232
Timer
Timer
DCA4
DCA5
DCA6
DCA7
INA
Configuration INA
PGA
ACA02
24V1
ASB11
ASB20
[P1.7]
Rx232
ACA02
ACA01
ASA10
[P1.5]
Tx232
ASA21
FTemp
ADC
ASA12
ASB22
Used blocks
Reserved blocks
Figure 7. PSoC Internals
Configuration PGA
INA
ACA03
ACA03
ASB13
ASA23
AN2107
The pulse-width modulator has been placed in
DBA00 and DBA01. The module is configured in
the software as 9-bit PWM unit, which is allowed
to provide enough regulation steps. The PWM
switching frequency is set to 100 kHz. The serial
port baud-rate timer is placed into DBA03. This
timer output is used as clock source for the
UART. The UART is comprised from separately
placed serial transmitter and receiver, which have
been placed into DCA04 and DCA05
respectively. Notwithstanding the fact that PSoC
Designer suggests the UART User Module but it
is unsuitable for this design because current API
version
does
not
provide
routines
to
disable/enable receiver/transmitter interrupts
separately. The default exchange speed is set to
19200 baud.
The delta-sigma ADC is placed into ASA12 and
DBA02 blocks. Despite the fact that other ADC
types provide better resolution, dynamic range
and signal-to-noise ratio (SNR), this ADC was
selected because ADC results have no
dependence on interrupt latency. The following
software digital filtering and averaging saw an
increase in delta-sigma ADC SNR and an
improvement in measurement accuracy. The user
can test other ADC types for performance by
replacing this ADC in PSoC Designer.
The baud-rate timer output serves as the clock
source for the temperature sensor, which is used
for measuring die temperature before selfprogramming internal memory to store charger
settings. When the charger is used at room
temperature this unit can be considered
redundant, but it is useful for extreme use
conditions.
The baud-rate timer output is used for additional
purposes. First of all, it drives the interval timer,
which is used as a real-time clock. It may be
curious to use the baud-rate timer as a real-time
clock source because the low-speed internal
oscillator exists. But PSoC data sheet currently
does not provide any time/temperature frequency
dependence
information
concerning
this
oscillator. It is known that the generated
frequency can be varied into several times. But
the high-speed oscillator provides guaranteed
frequency stability. So, the only way to use digital
PLL is to tune the low-speed oscillator during
charger operation or employ a high-frequency
signal as real-time clock. The last solution has
been implemented in this design.
Battery Measurements
To provide correct implementation of the charge
algorithms and battery voltage, the charge
current and temperature must be measured
accurately. The charger performs the dynamic reconfiguration to implement these functions.
Because the battery current is determined by
measuring the voltage drop in sense resistor with
presence of the large common-mode signal, the
best way to measure current is to use the
instrumentation amplifier (INA) to amplify this
small sense resistor signal. But the PSoC
instrumentation amplifier has minimum gain of 2
and limits battery voltage range, which can be
measured accurately in this way. The
programmable-gain amplifier (PGA) is ideal for
measuring battery voltage because it provides
gain levels as low as 1. An additional PGA is
needed to buffer the output if the PGA is set for
attenuation. Input voltage is only limited by the
input-stage acceptance levels of PSoC.
The timer generates interrupts with a 0.25s rate
that is used to calculate other time intervals.
U1
2*UREF
R9
R10
R11
R12
SDC
SW2
Config_INSTA
1
+
2
INA
-
SW1
R15
1
ADC
2
Config_PGA
R21
SW3
RT1
t
PGA
1
2
3
4
THERMISTOR
Figure 8. Battery Measurement Implementation
R22
R17-R20
V1
Ch Bat
AN2107
This amplifier can effectively be used to measure
battery temperature because PGA suggests wide
range of gain levels (useful values are from 0.5 to
16).
The switch SW2 is placed in position 2 and INA
inputs are shorted together in the first stage. Note
that the current routing scheme does not allow
connecting the INA inputs to AGND. This position
is used to measure INA offset voltage. The switch
SW2 goes to position 1 and the current sense
resistor signal is measured. If R10=R11=R12 and
R15=R21=R22, R17<<R15 then the difference
between ADC code, which corresponds to the
SW2 position 1 and 2, is directly proportional to
the battery current without influence of the INA
and ADC offset voltage. The following formulas
depict current measuring scheme:
Note that the thermistor resistance decreases
exponentially with a rise in temperature, so the
thermistor voltage can be varied in the wide
range [7].
Figure 8 illustrates implementation of the
measuring configuration. The measurement of
battery current is implemented as a two-stage
procedure to eliminate voltage offset of the
instrumentation amplifier and ADC input.
VADC1
n1 = nmax
VADC2
Vref
= nmax
GinaVos
Vref
Gina
(Vos + β ⋅ I bat R17 )
Vref
Vref
G β ⋅ I bat R17
∆n = n2 − n1 = nmax ina
Vref
n1 = nmax
= nmax
Where nmax is the maximum ADC code and the
value is equal to 1024 for 11-bit sigma-delta ADC
in bipolar mode. n1, n2 are the ADC code during
first and second measurements.
(1)
Vos is INA offset voltage, Ibat is battery current,
Gina is INA gain, Vref is bandgap reference
voltage, 1.3 V, and β is the resistive divider
coefficient:
β=
Note that the influence of the INA input current is
small for selected resistive divider values (the
parallel value is less than 10k) and can be
ignored in this case. The most important thing is
to use the precision resistors in the resistive
divider to obtain high-value common mode signal
rejection.
1
R
1 + 15
R12
(2)
The recommended R10-R12 and R15, R21 and
R22 tolerances are 0.1%. The maximum battery
voltage, Vbat max, battery current, Ibat max, and
resistive divider values must be selected to
satisfy the following:
INA maximum input voltage must be
lower than allowed instrumentation
amplifier common-mode voltage Vcm
max=4V for 5V supply, or;
(
)
2Vref + β Vbatmax + I batmax R17 − 2Vref < Vcmmax
(3)
to prevent ADC saturation by current sense resistor differential voltage, the following equation must
be true:
Gina
I bat R17
β <1
Vref
(4)
AN2107
Note that there must be an ADC input range
reserve of approximately 15-20% caused by
possible large INA offset voltage.
The battery voltage is also measured by using
PGA into two stages.
n1 =
First, SW3 is placed into position 4. The negative
battery lead voltage is measured. Second, SW3
is placed into position 3 and the positive battery
lead potential is measured. The difference
between these measurements allows the
program to calculate the exact battery voltage
without influence of the PGA/ADC input voltage
offset errors. The following question set illustrates
this:
nmax GPGA
(− 2Vref β + Vos ) n2 = nmaxGPGA (β (Vbat − 2Vref ) + Vos )
Vref
Vref
(5)
Vbat
∆n = n2 − n1 = nmax GPGA
β
Vref
Where GPGA is PGA gain. Vos is PGA input
voltage offset. Vref is reference voltage. nmax is
maximum ADC code value. n1 and n2 are in ADC
code during first and second measurements.
To prevent ADC saturation during voltage
measuring, the following disparity must be true:
GPGA
β (Vbat − 2Vref ) < 1
Vref
Note that the default gain value is 16 for INA and
1 for PGA. The following versions of the charger
firmware/PC-based
software
will
support
automatic gain selection and resistive divider
optimization for exact battery type and cell count.
The resistive divider values must be correctly
selected in equations (3), (4) and (6) for given
battery voltage and charge current. The rule to
calculate suitable resistor values is very simple.
For given maximum charge battery voltage,
calculate β values from (3), (4) and (6). Then
select the minimal value among these three
numbers and calculate R15 value according to
Equation (2) using the fixed value of the R12.
n AGND = nmax
(6)
The temperature is measured by measuring the
voltage drop across R9 and R10. The PGA has
been used to extend the measuring range. The
measuring process is separated into three
stages. The PGA input offset is measured first by
switching SW3 into position 2. Second, the switch
SW3 turns to position 1 and the R9 lower-pin
potential is measured. Third, the switch SW3
turns to position 4 and the R10 lower pin is
measured. Using these three values, the
resistance of the thermistor can be obtained by
the following equation:
GPGA
Vos
Vref
R10 
GPGA 
R9 
G 
Vos − 2Vref
, n2 = nmax PGA Vos − 2Vref

Vref 
R9 + Rth 
Vref 
R10 + R22 
G
R10
nmax PGA 2Vref
Vref
R10 + R22
n AGND − n2
R10
R9 + Rth
=
=
n AGND − n1
G 
R9  R10 + R22 R9

nmax PGA  2Vref
Vref 
R9 + Rth 
 n − n R + R22 
Rth = R9  AND 2 10
− 1
n
−
n
R
10
 AGND 1

n1 = nmax
(7)
AN2107
Where GPGA is PGA gain during temperature
measuring. GPGA is set to 1 or 8 automatically,
depending on the current ADC code value. nmax is
the maximum ADC code value.
As easily seen in (7), the temperature code has
no dependence on the reference voltage value,
Vref. To provide ADC saturation-free temperature
measurement, the thermistor value at maximum
expected temperature must satisfy the following
disparity:
Rth (t max )
> 2GPGA − 1
R9
(8)
Because GPGA min=1, then Rth(tmax) >R9. The
PSoC column 2 and 3 multiplexers serve the
SW2 and SW3. Switching is done by direct
modification to the AMX_IN register in the
charger firmware.
When the regulator voltage and current values
are determined, it is time to measure the current
battery voltage and charge current, and update
the step-down converter PWM value according to
the selected regulation law.
The Charger Firmware
After updating the PWM value, the series of
conditional tests will be completed. The total
charge time will be checked first and the charger
will be stopped with timeout error when the total
charge timeout has expired. Next, the battery
charge voltage must be checked. When this
voltage is higher than the allowed maximum
value, the charge process must be terminated
with the battery voltage error flag. This situation
happens typically when the battery is removed
during the charge process and the regulator does
not have enough time to reduce the charge
current. Alternatively, this condition test can be
used to detect damaged batteries with high
internal resistance.
The charger firmware is separated into several
modules that serve distinct functions, such as
performing measurements, regulating battery
charge
process
and
timer
functions,
implementing charge algorithm, checking charge
termination-conditions, storing selected charger
parameters and calibration settings into PSoC
Flash memory, remote control and data
exchange.
Battery Charge Algorithm
The following battery-charge algorithm performs
charge-profile analysis for various battery types.
First of all, the battery discharge setting is
analyzed. If the battery needs to be discharged,
the discharge switch is turned on. Now the
charger continuously measures the battery
voltage and waits until this voltage drops below
discharge-stop threshold. When the battery is
discharged, the charge process can begin. Note
that the timer protects the total discharge time.
When the timer timeout elapses, the discharge
process terminates with a timeout error.
The battery-charge process is started by resetting
the charge termination flag and setting the idle
values of the battery current and voltage. These
values will be put into the charge regulator when
the battery temperature is outside the allowed
range. Note that the Ni-based batteries allow a
small charge-current charge when the battery
temperature is outside the predefined range, but
other types do not. So, for SLA, Li-Ion and Li-Pol
batteries, idle mode-charge values must be set to
zero, which prohibits any charge current.
Then, the battery temperature must be checked.
If the battery temperature is not in the specified
range, the idle values of the battery charge
voltage and the current are sent to the charge
regulator and the operation timer is suspended.
This timer counts the rapid, activation or trickle
charge time. The charger returns to the battery
charge voltage, current measurements and PWM
regulation.
If battery temperature is good, the termination
flag is checked. If this flag was set, the trickle
charge values are sent to the regulator and
operation timer is resumed. The total trickle time
is then checked. If the trickle timeout elapses, the
process terminates with no errors. If the
termination flag was not set, the battery voltage is
analyzed. If this level is bigger then the rapidcharge start voltage, the rapid charge mode is
selected (activation charge in the opposite case).
The operation timer is resumed for both activation
and rapid charge modes and corresponding
timeouts are checked. If any timeout expires, the
charge process terminates with timeout error.
AN2107
When the termination criterion is true, setting the
termination flag terminates the rapid charge. The
different battery types are characterized by
various termination criteria. For example, the
rapid charge of the SLA batteries terminates
when the charge current drops below the
predefined level.
When these condition tests completed, the
charger started the battery measurements and
PWM regulation.
Figure 9 illustrates the proposed algorithm:
Start
Reset termination flag
Is battery must
be dicharged?
Set discharge switch
t total > t total max
Yes
Stop, timeout
error
No
Yes
Vbat > Vdis
No
Reset discharge switch
Reset termination flag
Set idle Vreg, Ireg
Vbat and Ibat
measurement
Regulate PWM using
Vreg and Ireg
Stop, timeout
error
Yes
ttotal > t total max
No
Stop,
voltage error
Yes
Vbat > Vterm
No
T min<T bat <Tmax
No
Set idle Vreg, Ireg
Suspend Operation
Timer
Set trickle Vreg, Ireg
Resume Operation
Timer
Yes
Is termination
flag was set?
Yes
No
ttric > ttric max
No
Yes
Stop, no
errors
V bat > V rap start
Yes
Set rapid Vreg, Ireg
Resume Operation
Timer
No
trap> t rap max
No
Yes
Yes
Stop, timeout
error
Set termination flag
Yes
Set activation Vreg, Ireg
Resume Operation
Timer
tact > tact max
Figure 9. Universal Battery Charge Algorithm
Is rapid term.
condition?
No
No
AN2107
Note that by varying algorithm settings and
modifying charge-termination criterion, new
battery types can also be supported.
DISCHARGE
marks
the
battery
discharge process;
WAITING is used for the idle state
depicting when battery temperature is
outside allowed temperature range;
ACTIVATION, RAPID and TRICKLE
depict the battery activation, rapid and
trickle charging.
This algorithm was implemented in the charger
firmware as a state machine.
The following states were used:
STOPPED marks the charged initial
state;
STARTING indicates charge process
initialization;
Figure 10 illustrates the charger state diagram:
2
Stopped
3
5
Starting
8
4
22
1
Discharge
18
6
19
5
20
Waiting
9
Tricle
21
11
7
15
16
12
10
14
17
Activation
13
Rapid
Figure 10. Charger State Diagram
Initially the charger is in STOPPED state and
preserves this state until just before an external
(from user interface or serial port) event is
received (2). If the charge starting command is
issued, the charger goes to the STARTING state
(3). If the battery must be discharged first, the
charger jumps to DISCHARGE (4) state, and to
WAITING state directly in the opposite case (6).
The charger preserves the DISCHARGE state
when battery is not discharged completely (22).
The charger will preserve the WAITING state until
just before the battery temperature falls into the
predefined range (7). If the battery temperature is
good, the ACTIVATION or RAPID states can be
switched.
If the battery voltage is lower than the rapid start
voltage, the charger goes to ACTIVATION state
(11) and to RAPID state (15) in the opposite
case.
When the battery voltage reaches the rapid start
voltage, the charger leaves the ACTIVATION
state and switches to the RAPID state (13). If
termination criterion is satisfied, the TRICKLE
state replaces the RAPID state (16). When the
TRICKLE state timeout has elapsed, the charger
moves into STOPPED state (8). From the RAPID,
ACTIVATION or TRICKLE states the charger can
temporarily return to WAITING state if the battery
temperature leaves the allowed range (12), (14),
(20).
AN2107
The charging process can be terminated with an
error if total or operation charge timeout elapses
or the battery voltage is higher than the charge
termination voltage (1), (8), (18), (19).
The Timers
As explained above, the charger uses 0.25s
interrupts as the primary real-time clock. The
double-byte variable is being incremented by
each timer tick and is used as a time counter.
The counter overflows each 4.5 hours but this
phenomenon has no influence on the charger
operation. Successive time intervals are
generated by this counter analysis. The current
firmware release employs three software countdown timers to calculate various time intervals.
Each timer has different resolution and serves
different purposes. Timer1 has a resolution of 1s
and is intended to provide battery temperature
measurement intervals. The battery temperature
is being measured every 4s. Timer2 is intended to
provide operation timeouts, has a resolution of
64s and supports suspend/resume operations
without resetting. Timer3 is used to calculate total
charge time and has a resolution of 256s.
Battery Temperature Calculation
The thermistor, which is widely used in modern
battery packs, has a non-linear transfer function.
The resistance temperature dependence can be
calculated using the following formula [7]:
1
= A + B ⋅ x + C ⋅ x 3 , x = ln ( Rt )
Tk
Where A, B, C are approximation coefficients. Rt
is thermistor resistance and Tk is thermistor
absolute temperature, K. The direct calculations
from Equation (9) need complex, float-point
calculations and are not suitable for this charger
implementation. Because the temperature range
is limited to 60ºC (no batteries are allowing
activation/rapid charge outside 0..60ºC), a better
way lies in using a lookup table to calculate
battery temperature. To eliminate any complex
mathematical calculations, this table must contain
an array of the ADC code, which will correspond
to the concrete temperatures. The search
algorithm is looking at the table value, which is
nearest to the measured ADC code. The table
index will reflect battery temperature linearly.
The lookup table code can be calculated from a
reverse function for Equation (9) (by using
Cardano formulas) to find thermistor resistance at
a particular temperature and Equation (7) to
calculate corresponding ADC code. This code
can be stored in the PSoC Flash memory after
charger calibration. The charger uses 256-point
lookup table with starting point at 0ºC in 0.25ºC
increments. The table consumes 512 bytes of
Flash memory and does not create any size
problems because PSoC has more than enough
Flash memory. So, the maximum temperature,
which when measured by using this lookup table
is 63.75ºC, is completely enough for this
application.
(9)
Charge Completion Checking
Various battery types employ different rapid
charge termination strategies. For SLA and Li-Ion
batteries, rapid charge terminates when the
charge current drops below the predefined level.
It is very simple to implement this criterion in
software. The Ni-Cd and Ni-MH batteries use two
complementary termination criteria: detection of
temperature derivate rising or detection of battery
voltage dropping from its maximum value. Most
chargers measure the temperature periodically
and calculate the difference between adjacent
temperature points. In spite of the simplicity of
algorithm implementation, this method is
characterized by poor noise immunity and can
mistakenly terminate the charge process in a
1
noisy environment . The proposed integral
method is free from this drawback.
The method is based on calculation and
comparing integration sums for adjacent time
intervals. Figure 11 depicts implementation of this
algorithm:
1
Author observed this effect in some commercial
chargers when thermistor wires were too long and
noise was introduced by other system parts.
AN2107
T
α2
T2
α1
T1
t
t1
t2
t4
t3
Figure 11. Battery Temperature Derivate Integral Analysis
Let us suppose that the temperature is rising
linearly within two accumulation intervals.
It is completely true if the accumulation interval is
small in comparison to the temperature derivate
change time. So, the temperature change law
can be written in the following form:
Ti = T0 + α ⋅ i
Where i is the sample-point number and
α are approximation coefficients.
(10)
The two adjacent integral sums will be estimated.
The index i changes within from 0 to N-1 for the
first sum and from N to 2N-1 for the second
integration sum.
T0 and
N −1
N −1
aN ⋅ ( N − 1)
i =0
i =0
2
S1 = ∑ Ti = ∑ (T0 + α i ) = NT0 +
S2 =
2 N −1
2 N −1
∑ T = ∑ (T
i=N
i
i=N
Note that the formula for the arithmetical
proportion sum calculation was used here and no
quantization effects were taken into account
during this estimation.
0
+ α i ) = NT0 +
α N ⋅ ( 3N − 1)
(11)
2
The difference between the two sums is as
follows:
∆S = S 2 − S1 = aN 2
The difference between the two sums has no
dependence on the initial temperature, T0 . To
practically use this criterion, the parameter α
can be estimated via temperature growth.
(12)
Let us suppose that within accumulation time,
∆t collected N points and observed the
temperature growth ∆T . By substituting these
values into Equation (10), the α can be
calculated by the following formula:
AN2107
a=
The charger periodically measures the battery
temperature and calculates the sum of the N
temperature values. After this process has been
completed, the comparison between adjacent
integration sums is done. If the difference
between these two integration sums is greater
than the predefined threshold value, it is
determined that the battery temperature derivate
reached the charge termination threshold and the
charger must switch to the next state. In this
firmware release, the temperature measurement
is being initiated each 4s and the integration sum
accumulation time is 64s, which takes into
account 16 temperature samples.
∆T
N
Decreasing
battery-voltage
detection
is
implemented by continuously updating the
maximum value of the charge voltage and
estimating the difference between this maximum
value and the latest charge voltage. If this
difference reaches the predefined threshold, this
termination criterion is considered true. To
improve detector noise resistance and charger
reliability, the voltage samples are filtered first by
the IIR LPF. The filter transfer function is
determined by the following equation:
y j = (1 − γ ) y j −1 + v j
Where
y j is the filter output signal j sample, v j
is the input voltage sample, and γ , γ < 1 is the
filter coefficient. This filter is characterized by the
γ −1 and the voltage threshold value is
−1
in proportion to the filter gain.
multiplied by γ
gain
This filter implementation allows decreasing the
influence of fixed-point rounding errors and
improving accuracy of small voltage drop
detection. Instead, dividing/multiplying the binary
shift has been done, the
γ = 2 − K , where K=1..3.
The Charge Regulator
In the first section of this Application Note the
battery charging algorithms were considered. To
implement a universal charger, the regulator must
be capable of regulating both charge current and
voltage and stay stable for loading various
dynamic characteristics. The traditional digital
proportional-integrate derivate control (PID)
regulator
provides
excellent
regulation
characteristics for properly selected regulator
coefficients. These coefficients must reflect the
step-down converter/load dynamic behavior and
desired sample frequency. To provide optimum
regulation, the regulator coefficients must be
dynamically updated to reflect load property
changes [2]. An alternative approach lies in using
fuzzy-logic systems.
(13)
(14)
This charger employs a simpler regulator, which
has worse dynamic characteristics but does not
demand estimation of regulator coefficients. The
regulator operation is based on increasing PWM
counter value if the charge voltage and current
are smaller than the predefined value. If the
charge voltage or current are greater than the
predefined value, the PWM counter will be
decreased. The counter values are limited both
from below and above by 0 and the PWM
maximum value. Figure 12 illustrates the
regulator operation:
AN2107
Legend:
Ibat - battery charge current
V bat
Vreg
Vbat - battery voltage
Iset - nominal charge current
Vset - nominal battery charge voltage
Vbat < Vreg - V d
Ibat
I reg
Id - current tolerance
Vd - voltage tolerance
+1
and
I bat < Ireg - I d
PWM conter
0..PWM max
Vbat
Vreg
Vbat > Vreg + V d
-1
or
Ibat
I reg
PWM/SDC
Ibat > I reg + I d
Figure 12. Charge Regulator Operation
write Flash memory block (used for
uploading both thermistor lookup table
and battery settings);
start and stop charging;
request charger state information; reply
includes state machine state, error code,
current time, battery temperature,
charge current and voltage.
Data Exchange Protocols
The charger uses serial port communication for
remote control and charge-process monitoring. It
can operate as a standalone application with two
control buttons, but the thermistor lookup table
and battery settings must be uploaded first.
These settings are stored in nonvolatile PSoC
Flash memory. The communication model is
based on master-slave approach. Under
dedicated control, the PC acts as master and the
charger acts as slave. Any host controller with
UART can remotely control the charger.
The PC or host controller is sending the
predefined commands and the charger is
returning a reply for each command. The current
firmware release supports the following
commands:
test data link to detect charger
connection;
measure PSoC die temperature and set
Flash memory starting block number;
‘S’
Start byte
‘A’
‘B’
Data byte 1
‘0’
‘1’
Data byte 2
The data communication protocol is trivial. Each
packet consists of the start byte ‘S’, data bytes
and stop byte ‘P’. The messages are different
lengths, depending on command type. The data
bytes are encoded into hex format, so each data
byte needs two bytes to be transmitted or
received. The 100 % overhead does not cause
any problems because the data exchange rate is
typically very low (several ten bytes per second)
and bytes are encoded or decoded on-the-fly,
without additional memory use.
Figure 13 illustrates data packet structure:
‘…'
‘...’
Other bytes
Figure 13. Data Packet Structure
‘2’
‘3’
Data byte N
‘P'
Stop byte
AN2107
The serial receiver and transmitter operation is
completely interrupt-driven to eliminate UART
polling. The receiver contains the state machine.
Figure 14 illustrates the receiver operation:
4
Receiving
2
5
3
6
1
Ready
7
Complete
Figure 14. Serial Receiver State Machine
Initially, the receiver is in READY state. The
receiver preserves this state until just before the
start byte is received (1). The receiver moves to
the RECEIVING state after receiving the start
byte (2). This state will be preserved until just
before the stop byte is received (4). If this
happens, the receiver went to COMPLETE state
(5). The receiver can transit from RECEIVING to
READY state if any of the following events occur
(3):
The new start byte was received.
The received symbol cannot be decoded
or was received with error.
More buffer size data bytes were
received without stop byte.
The receiver preserves COMPLETE state
until just before data packet is read and
processed (6). The receiver will be reset (7)
in the main program loop by calling the
corresponding routine after incoming data
processing.
The Charger Control Software
The dedicated charger control software has been
developed to simplify charger configuration and
monitor charge process. Software features
include:
Dialog-based battery-parameter settings
with disk load/store capability.
Voltage, current calibration.
Battery
voltage,
current,
and
temperature visual representation with
disk load/store/append capabilities.
Automatic
battery
settings
and
thermistor lookup table generation with
uploading into PSoC Flash memory.
The software is a multi-thread Win32 application
and runs under Microsoft Windows 98, NT, 2000,
or XP.
The program interface is very simple; user must
carry out several steps to complete charger
setup. These steps include the following:
Setting Program Options and Serial
Port Settings
After program installation, the serial port settings
must be checked. From main program menu,
select “Settings -> Serial Port Settings,” choose
free serial port and select 19200 baud 8-data bits,
1 stop bit and no flow control and parity. Press
“Ok” to close window. You can test serial port
settings by pressing the “Query” button. You must
see “The diagnostic message was received” in
the Messages window, Output tab. If you see red
text “The charger is not responding,” please
check serial port connection and charger power.
AN2107
Figure 16. Program Options Dialog Window
Figure 15. Serial Port Dialog Window
The program options window (Settings ->
Program Options) allows you to select charger
query period and charger response-wait timeout.
All values are in milliseconds. You can select the
checkbox to automatically upload the new battery
settings into charger Flash memory (but to upload
thermistor lookup table you must press
corresponding menu item manually).
Note that the serial port settings and program
options are automatically stored in the system
registry, so they will be retrieved next time the
program starts. All diagnostic messages are sent
into the Messages window, which has two tabs.
The “Output” tab displays various diagnostic
messages, the “Values” tab displays current
charger information such as the measured
battery voltage, current, temperature, charger
state machine state, error code… Here is a
message example:
Figure 17. Message Window Tabs
Setting Battery Parameters
Setting battery parameters must be done with
care because invalid battery settings can damage
the battery or even the charger.
The command is callable as “Settings -> Battery
Settings” or via the speedup button. There are
two tabs in this dialog. The first is intended to
provide battery settings; the second selects
charger hardware component parameters.
AN2107
Figure 18. Battery Settings Dialog
Select battery type first. Later, fill in all the battery properties according to the following tables.
Table 2. The Ni-Cd and Ni-MH Battery Settings Table
Parameter Name
Parameter Description and Dimension
-1
ActivationChargeRatio
Relation between battery charge current during activation stage and capacity, h
ActivationTimeout
Activation charge timeout, min
Alias
User-friendly battery name or model number, will be stored together with other parameters
Capacitance
Battery capacity, A*h
Cells
Battery cell count
CheckTempIncrease
Check if you want to use temperature derivate rising as rapid-charge termination criterion
CheckVoltageDecay
Check if you want to use the battery voltage dropping as rapid-charge termination criterion
DeactiveTime
Timeout to prevent false rapid-charge termination by initial voltage dropping, min
DischargeFirst
Check if you want the discharge to precede battery charging
DischargeStop
The discharge stop voltage, V/cell
MaxTemp
Upper limit of the allowed temperature interval, ºC
RapidChargeRatio
Relation between battery charge current during rapid stage and capacity, h
RapidStartVoltage
Switching threshold between activation and rapid charge, V/cell
RapidTimeout
rapid-charge timeout, min
StartTemp
Lower limit of the allowed temperature interval, ºC
TempIncValue
Battery temperature rising speed to detect rapid-charge termination, ºC/min
TotalTimeout
Total charge timeout, min
TricleChargeRatio
Relation between battery charge current during trickle stage and capacity, h
TricleTimeout
Trickle charge timeout, min
VoltageDecay
Battery voltage dropping level to terminate rapid charge, V/cell
-1
-1
AN2107
Table 3. The Li-Ion, Li-Pol and SLA Battery Settings Table
Parameter Name
Parameter Description and Dimension
-1
ActivationChargeRatio
Relation between battery charge current during activation stage and capacity, h
ActivationTimeout
Activation charge timeout, min
Alias
User-friendly battery name or model number
Capacitance
Battery capacity, A*h
Cells
Battery cell count
DischargeFirst
Check if you want the discharge to precede the battery charging
DischargeStop
The discharge stop voltage, V/cell
MaxTemp
Upper limit of the allowed temperature interval, ºC
RapidChargeRatio
Relation between battery charge current during rapid stage and capacity, h
RapidStartVoltage
Switching threshold between activation and rapid charge, V/cell
RapidTerminationCurrent
Relation between battery charge current and battery capacity to determine rapid-charge
-1
termination current, h
RapidTimeout
Rapid charge timeout, min
RapidVoltageLimit
Maximum charge voltage during rapid charging, V/cell
StartTemp
Lower limit of the allowed temperature interval, ºC
TotalTimeout
Total charge timeout, min
TricleChargeRatio
Relation between battery charge current during trickle stage and capacity, h
TricleTimeout
Trickle charge timeout, min
-1
-1
You can set zero for Li-based batteries
TricleVoltageLimit
Maximum charge voltage during trickle charge stage
When you have finished setting the batterycharging parameters, press the “Ok” button.
Please review the Messages window to make
sure there were no errors during battery
parameter calculation.
If you see messages similar to those shown in
Figure 19, your battery settings do not reflect the
resistive divider values. Please correct these
values according to the equations given earlier.
Figure 19. Error Message Example
Secondly, select Resistive Divider tab and modify
resistor values according to the equations, which
were considered in the charger hardware section.
The charger calibration possibility has been
implemented as well. The bandgap voltage error,
PSoC blocks’ gain error, resistor divider
resistance errors, and PCB voltage-drop tracking
introduce the errors in battery voltage and current
measurements that decrease accuracy of the
charge process.
These errors can be reduced by comparing
charger data to the values measured externally.
The calibration can be done in the following way:
set voltage and current measurement error to 0,
close dialog box by pressing “Ok” and upload
battery settings to the charger. Then, start the
battery-charge process.
AN2107
During
the
rapid
charge
stage,
take
measurements of the real battery current and
voltage using precision external U-I meter and
compare that with the charger-measured values,
which are displayed in the Messages window,
Values tab.
Calculate the percentage difference between
them. These values must be put in the “U
measuring error” and “I measuring error” edit
boxes. Press the “Ok” button. Review the new
voltage and current values in the Values tab.
They must be very close to the value measured
by the external meter. Upload the recalculated
battery settings into the charger and save battery
settings in the file for recall. The calibration
process is now complete. To do this operation,
the resistor can be used instead of a real battery.
The resistor value can be calculated as
relationship of nominal battery voltage to rapid
charge current.
After setting battery parameters you can save all
settings into a file. Use “File -> Save Battery
settings” and open it later via “File -> Open
Battery Settings.” Note that the charger resistive
divider values and calibration data are linked with
battery settings and will be saved/opened
together because these values are battery
dependent. When you properly select battery
settings, you can upload these values to the
charger by pressing “Action -> Upload Battery
Data.” In this way the calibration correction will be
taken into account for both charger setting
calculations and data visualization.
Entering Thermistor Calibration Data
The various battery packs are characterized by
different thermistor temperature coefficients. To
properly generate a charger lookup table, these
coefficients must be estimated according to the
thermistor temperature curve. The charger
control software allows you to extract thermistor
resistance approximation coefficients for any
thermistor using experimental or passport data.
Click “Settings -> Thermistor Calibration” and the
following
dialog
window
will
appear.
Figure 20. Thermistor Calibration Dialog Box
Enter the value of R9 in the upper edit box. As
easily seen in Equation (8), the divider resistance
must not be greater than the thermistor
resistance for maximum temperature operation to
prevent ADC saturation. The rule of thumb is to
set the divider resistance equal to the thermistor
value at 65ºC. You will see the warning message
in the Messages window if your R9 value was
selected improperly.
Using the Insert, Arrow and Page Up, Page Down
keys create new lines in the value editor and type
numerical values for temperature and resistance.
When all values are entered, you can save them
to a text file from the value editor contextsensitive menu. You can open the file next time
using this context menu. To find thermistor
coefficients, use the measured data from the
thermistor data sheet. User must provide a
minimum of three resistance-temperature pairs.
The software automatically calculates the
thermistor coefficients and lookup table.
AN2107
If your thermistor data are noisy, enter more than
three points to improve estimation accuracy. Do
not forget to include points near 0ºC and 60ºC.
Press
Generate
button.
You
will see
approximation
graph
and
approximation
coefficients with statistical information printed in
the Messages window. If needed, set the
Messages window to review approximation
results.
Note that the graph Y-axis scale can be switched
from log to linear and vice versa in the graph
context-sensitive menu. When the thermistor
coefficients are estimated and lookup table filled,
you can upload lookup table into the charger by
selecting “Actions -> Upload Thermistor Table.”
Start Charging
When the battery settings and thermistor lookup
table are generated and uploaded into charger
PSoC Flash memory, the user can start the
charge process by pressing the “Start” button.
You will see corresponding information in the
Messages window, Output Tab. The Values Tab
depicts the battery voltage, current, temperature,
current charger state and decoded error codes.
This information is useful during battery
evaluation or testing. Note the text in the
Messages window can be cleared in the contextsensitive menu. You can abort the charge
process any time by pressing the “Abort” button.
The charger then returns to STOPPED state.
Data Visualization
Once the charging process is started, the charger
is periodically queried by software. This query
interval can be adjusted in the Program Options
dialog
window
on-the-fly.
The
software
continuously updates the graph windows during
charging, so you can view the battery charge time
graphs in real-time. The possibilities to hide/show
data points and graph zoom are implemented as
well. To show/hide data points, use the graph
context-sensitive menu. For graph zooming,
press the [Shift] key together with left mouse
button and draw a rectangle around interesting
graph fragment. Release the left mouse button
and your graph will be zoomed to the rectangled
area. To restore the full graph view, press the
[Shift] button and double-click the graph area.
Figure 21. Graph Zooming
You can save graph data by pressing “File ->
Graph data.” The software allows you to open
previously stored data by pressing “File -> Open
Graphs Data” and append the other graphs to the
existing graph for comparison and detail analysis.
To do this, use “Append Graph Data.”
Figure 22. Several Charge Profiles in One Window
AN2107
To Probe Further
Conclusion
The proposed battery charger does not cover
some advanced battery charging topics such as
battery regeneration, advanced diagnostic and
testing, fuel gas measuring and rest-capacity
estimation, adaptive charging methods with
charging parameters temperature correction, etc.
These features can be added in the next
firmware release. The CRC checking of the
PSoC Flash self-programming memory blocks
will be provided as well to detect damaged
battery settings.
The universal, multi chemistry charger has been
considered. The charger reference design
includes the full firmware sources, Orcad
schematic and layout files. The charger control
software sources can be obtained freely from
http://www.cypress.com/
under
PSoC
>>
Reference Designs. This software has been
written in Borland Delphi 7. But the charger
applications are not limited to classic battery
charge. Thanks to the flexibility of PSoC
architecture, additional functions can easily be
implemented. For example, the author’s friends
are using this charger to quickly charge the small
electric racing cars during competitions, battery
screening and diagnostic, etc. In this case, this
$10 design replaces very expensive battery
diagnostic equipment.
The possibility to generate ‘C’ header files for
both battery settings and thermistor lookup table
will be added in the charger control software.
This feature will be very useful when the user has
tested the charger well and wants to put the
device into mass production with only one battery
type, without serial interface. Secondly, more
user-input checking will be implemented. And,
lastly, the automatic calculation and optimization
of all charger hardware coefficients depending on
battery parameters will be added. These
parameters include PGA/INA gain levels,
resistive divider values, etc.
References
1.
2.
3.
4.
5.
6.
7.
8.
Isidor Buchmann, Batteries in a portable
world. This excellent book concerning
battery chemistry, operation, charging
schemes is available freely online at
http://www.buchmann.ca/toc.asp.
Benjamin Kuo, Digital Control Systems;
The digital control systems questions
are discussed here.
Charge Methods for Ni-Cd Batteries.
Charge Methods for Nickel Metal
Hydride Batteries.
Charge Methods for Li-Ion Batteries.
The last three references describe the
chemistry-specific battery charge
methods and can be downloaded at
http://www.panasonic.com/industrial/batt
ery/.
Components for AC-DC main power
supply are produced by Power
Integration, On-Semiconductor,
International Rectifier, Infineon. Visit
their sites for details.
The NTC/PCT Thermistors, A AVXKYOCERA Reference manual, can be
downloaded from
http://www.avxcorp.com/.
P.P.K. Ghetty, Switch-mode powersupply design, TAB Books, 1986.
You can download full charger control software
sources from Cypress site at
http://www.cypress.com/ under PSoC >>
Reference Designs.
AN2107
Appendix A.
Following are charge profile examples for various battery types. The charger discharges battery then
consecutively turns on the activation, rapid and trickle modes.
Figure 23. The 2 Cell Ni-Cd Battery Charge Profile
Figure 24. The 2 Cell Ni-MH Battery Charge Profile
AN2107
Please see differences in the battery temperature time behavior.
Figure 25. The Single Cell Li-Ion Battery Charge Profile
Figure 26. The 3 Cell SLA Battery Charge Profile
AN2107
Appendix B.
Figure 27. The Charger Photograph, Actual Size
AN2107
Appendix C.
test_leds
delayi
BaudTimer_DisableInt
BaudTimer_WritePeriod
Legend
BaudTimer_Start
OpenExchange
PSOC Library function
Tx232_DisableInt
Tx232_Start
User function
Rx232_EnableInt
Rx232_Start
SDADC_Start
OpenADCSystem
RefMux_Start
SDADC_StartAD
PWMMain_DisableInt
OpenRegulator
PWMMain_WritePeriod
PWMMain_WritePulseWidth
ResetRegulator
TimeTimer_EnableInt
OpenTimers
TimeTimer_WritePeriod
ResetTime
TimeTimer_Start
ProcessButtonsCmd
CheckButtonsState
CheckRxData
ExchangeSend
GetCurTime
Tx232_EnableInt
Tx232_SendData
GetChargeVoltage
main
GetChargeCurrent
ProcessExchangeCmd
ResetReceiver
GetTemperature
FlashTemp_Start
fFlashTemp_IsData
IsConfig_INSTALoaded
cFlashTemp_GetData
INSAMP_Stop
FlashTemp_Stop
UnloadConfig_Config_INSTA
bFlashWriteBlock
ResetTime
ResetRegulator
ResetCheckings
IsConfig_PGALoaded
VoltageMeasure
PWMMain_Stop
LoadConfig_Config_PGA
PGA_Start
PGA_SetGain
SetTimer3
SetADCInput
ADCGetData
RegulateMainPWM
IsConfig_PGALoaded
GetTimer1
PGA_Stop
SetTimer1
UnloadConfig_Config_PGA
IsConfig_INSTALoaded
ChargerControl
CurrentMeasure
LoadConfig_Config_INSTA
PWMMain_Start
INSAMP_Start
IsConfig_INSTALoaded
INSAMP_SetGain
INSAMP_Stop
SetADCInput
UnloadConfig_Config_INSTA
ADCGetData
IsConfig_PGALoaded
TempMeasure
GetTimer3
GetChargeVoltage
SuspendTimer2
GetTemperature
SetTimer2
LoadConfig_Config_PGA
PGA_Start
PGA_SetGain
SetADCInput
ADCGetData
abs
ResumeTimer2
GetTimer2
CheckVoltageDecay
CheckCurrentDecay
GetChargeCurrent
CheckTemperatureRising
Figure 28. Charger Firmware Function Call Tree. (It is useful to understand how the firmware operates.)
AN2107
About the Author
Name:
Title:
Background:
Contact:
Victor Kremin
Associate Professor
Victor earned a radiophysics
diploma in 1996 from Ivan
Franko National Lviv University,
PhD degree in Computer Aided
Design systems in 2000 and is
presently working as an
Associate Professor at National
University "Lvivska
Polytechnika" (Ukraine). His
interests include the full cycle of
embedded systems design
including various processors,
operating systems and target
applications.
You may reach him at
[email protected]
Cypress MicroSystems, Inc.
2700 162nd Street S.W. Building D
Lynnwood, WA 98037
Phone: 800.669.0557
Fax: 425.787.4641
http://www.cypress.com/ / http://www.cypress.com/aboutus/sales_locations.cfm / [email protected]
Copyright  2003 Cypress MicroSystems, Inc. All rights reserved.
™
PSoC (Programmable System-on-Chip) is a trademark of Cypress MicroSystems, Inc.
All other trademarks or registered trademarks referenced herein are property of the respective corporations.
The information contained herein is subject to change without notice.