ST AN2390 APPLICATION NOTE

AN2390
Application note
A flexible universal battery charger
Introduction
In everyday life, more and more portable electronic appliances, such as mobile phones, are powered by re-chargeable batteries so the demand for battery chargers for charging these batteries is increasing all the time.
Figure 1. Universal battery charger evaluation board (STEVAL-ISB002V1)
It is based on a evaluation board built around the ST72324L microcontroller with a demo application code.
While the evaluation board described in this Application note is intended to be used for single cell Li-ion battery or 2 cell NiMH batteries you can customize this charger for a wide range of batteries because of the flexibility of the MCU and of the buck boost converter. The ST72324L MCU was selected for its main features, an embedded 10-bit A/D converter (to efficiently measure voltage, current and temperature), 16-bit timer (to generate PWM signals), main clock controller (to generate a time base signal) and 8 Kbytes of program memory which is more than enough to hold the algorithm for various battery chemistries. You can choose any other MCU that has similar capability. An LED is also used to indicate the charge status.
August 2007 Rev 1 1/42
www.st.com
AN2390
The evaluation board is powered from a 5 V supply. This supply is purposely chosen to show the application of the modified buck-boost converter. This is because, while a buck converter can be used to charge 2 cell NiMH battery from a 5 V supply, it is not generally suitable for charging a 4.2 V Li-ion battery due to the presence of protection diodes and other components which induce a voltage drop of around 1 V so you can not use a buck converter in this case.
The modified non-inverting buck-boost converter circuit used in this application note needs only one inductor and requires only an extra PWM signal compared to the kind of buck converter that is normally used. By using the switches in different forms, this converter can be used either as a buck converter or as a boost converter. Using the flexibility of the MCU, this converter is capable of charging a wide variety of batteries as can be seen from the evaluation board, where this converter has been used in buck converter mode to charge NiMH batteries, while a combination of buck-boost converter and boost converter modes are used to charge Li-ion batteries. For more details on the buck-boost converter, please refer to AN2389.
2/42
AN2390 Contents

Contents

1 Theory of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1 Li-ion battery charging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 NiMH battery charging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.1 Negative delta V method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.2 Zero delta voltage method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.3 Max temperature detection method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3 Slot management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4 Man-machine interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 Evaluation board implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1 Charging circuitry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.1 DC (Buck-Boost) converter component selection . . . . . . . . . . . . . . . . . 10
Inductor selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10
Capacitor selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10
2.1.2 Battery discharge protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2 Analog measurement circuitry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.1 Voltage reference generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.2 Current measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2.3 Voltage measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2.4 Temperature sensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2.5 Battery recognition mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Li-ion battery recognition scheme. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
NiMH battery recognition scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
2.2.6 Power supply restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3 MCU software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3.1 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3.2 Use of the ST7 MCU on-chip peripherals . . . . . . . . . . . . . . . . . . . . . . . 19
2.3.3 State diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3 How to use the evaluation board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.1 Connecting the evaluation board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.1.1 Jumper Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.1.2 Powering and running the evaluation board . . . . . . . . . . . . . . . . . . . . . . 28
3.2 Warnings/ Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3/42
Contents AN2390
3.3 Example test results with evaluation board . . . . . . . . . . . . . . . . . . . . . . . 28
3.3.1 Test environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.3.2 Li-ion battery charger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.3.3 NiMH battery charger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4 Conclusion: a low-cost flexible solution . . . . . . . . . . . . . . . . . . . . . . . . 35
5 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Appendix A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
A.1 Source file organization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
A.2 Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
A.3 BOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4/42
AN2390 Theory of operation

1 Theory of operation

1.1 Li-ion battery charging

Li-ion batteries have a constant current/constant voltage charging algorithm as shown in
Figure 2.
Figure 2. Li-ion battery charging
Battery
voltage
V
F
Battery current
I
CONST
I
SAT
Stage 1
Stage 2
During Stage 1 (constant current charge), the charging current is kept at a constant value (I
) until the battery voltage reaches the final cell voltage (VF). In Stage 2 (constant
const
voltage charge), the voltage is kept constant within this limit by slowly decreasing the current. Charging is stopped when the current drops below the threshold value fixed by the manufacturer (I
). This current indicates that the battery is saturated.
SAT
In some cases before stage 1, pre-charging can also be done if the battery is fully discharged.
A failure condition occurs if even after a certain time (t voltage remains particularly low (under V
). In this case, charging is stopped and the
SC
) of fast charging, the battery
FAI L
battery is isolated from the charger. The charger also indicates a battery failure without waiting (protection against short-circuit) if battery current is higher than the threshold I
FAIL
(equals to the maximum supply current).
If the charging time exceeds a certain expiration value (t battery is not yet saturated. As the t
value is greater than the t
EXP
), charging is stopped even if the
EXP
indicates that the battery is in good condition and fully charged.
5/42
value, the charger
FAI L
Theory of operation AN2390
The battery temperature is also monitored. If the battery overheats, charging is suspended until the battery cools down.
Once the battery is saturated, its voltage is still monitored to prevent the battery from discharging completely. If the battery voltage drops below V
, charging restarts until VF is
SAT
reached again. Charge time is reset when trickle charging starts.
Table 1. Li-ion charge parameters used in the evaluation board
Symbol Meaning Value Unit
V
V
V
V
I
FAST
I
FAI L
t
FAI L
t
EXP
MAX
V
F
TRI
FAST
SC
SAT
Maximum charging voltage 4.3
Final battery voltage 4.2
Trickle charge voltage 4.12
Fast charge voltage 3.0
Battery failure voltage 1.5
Fast charge current 1000
Battery saturation current 20
mAI
Short circuit current 1200
Battery failure time 30 s
Charge expire time 4 h
V
6/42
AN2390 Theory of operation

1.2 NiMH battery charging

The NiMH batteries uses a constant current algorithm as shown in Figure 3.
Figure 3. Variation of NiMH battery voltage
−∆V
(V)
cell
NiMH cell voltage: V
Charging time (t)
-10 mV/cell
The NiMH batteries use constant current charging. The end of charging can be detected by using the following methods.

1.2.1 Negative delta V method

As shown in Figure 3, the voltage of the NiMH batteries drops a little at the end of charging. So at the time, when the voltage slope versus time becomes negative, charging is stopped and trickle charging is started.

1.2.2 Zero delta voltage method

This method is a variant of the Negative delta V method. Actually in case of NiMH, there is a very slight drop in voltage (5-10 mV/ Cell) at the end of charging which is very difficult to detect using a 10-bit ADC. Also there is a chance of detecting the wrong end of charging due to noise. So instead of the negative delta voltage, we use a dV = 0 condition for a certain time duration. This gives very good approximations for detecting the end of charging. For this reason, this method is used in the evaluation board example instead of the negative delta method described in Section 1.2.1.

1.2.3 Max. temperature detection method

In this case if temperature rises above a threshold, charging is stopped and trickle charging is started.
In this demo the Zero Delta Voltage method is used as the primary technique for terminating the charging. Time Out, Max Voltage and Max Temperature are used as the secondary or back up methods for ending the charging.
7/42
Theory of operation AN2390
Once the battery is saturated, its voltage is still monitored to prevent the battery from discharging completely. If the battery voltage drops below V
, charging restarts until VF is
TRI
reached again. Charge time is reset when trickle charging starts.
Table 2. NiMH Charge parameters used in the evaluation board
Symbol Meaning Value Unit
V
MAX
TRI
V
FAI L
I
CONST
I
TRICKLE_1
I
SAT
I
FAI L
t
INITIAL
t
FAI L
t
EXP
t
FAST
Max Battery Voltage 1.7/Cell
Trickle Charge Voltage 1.0V/Cell
Battery Failure Voltage 0.9/Cell
Constant Charge Current 1000
Initial Trickle Charging Current 250
Battery Saturation Current 65
Short Circuit Current 1200
Initial Delay 10
Battery Failure Time 30
Charge Expire Time 4
Fast Charging Time 2

1.3 Slot management

In the demo, there are two different kinds of slots for charging Li-ion and NiMH battery chemistries to show that it can support wide range of batteries. But the positive terminal of one slot is shorted to the positive slot of another battery and similarly for the negative terminals. So the system can support charging of only one battery at a time. Hence you must take care to connect only one battery at a time to the charger. Otherwise the batteries will be shorted together.
VV
mA
minutes
h

1.4 Man-machine interface

The charger periodically checks for battery presence so no button is needed to start or stop charging. An LED is used to indicate the charge status as listed in Table 3..
Table 3. LED slot status color code
LED output Charging status
OFF No battery in the slot
Flashing @ 1 Hz Charging ongoing
Flashing @ 2 Hz Problem in charging
ON Battery Present/ Charging Complete
A reset button is also included on the evaluation board to manually reset the application.
8/42
AN2390 Evaluation board implementation

2 Evaluation board implementation

2.1 Charging circuitry

The evaluation board implements a solution with an external low-voltage DC supply.
To obtain a constant voltage or constant current during various stages, the ST7 microcontroller measures the battery voltage (V feedback, it provides the regulated output power to the battery under charge using a non­inverting buck-boost converter circuit.
The buck boost converter is controlled by 2 PWM signals coming from the microcontroller as shown in basic circuit diagram (Figure 4). For more details on the buck/boost converter, please refer to AN2389.
Figure 4. Basic circuit diagram of MCU-based non-inverting buck-boost converter
) and current (I
BAT
). Along with this
BAT
P+
P-
d1
PWM1
L
PWM2
d2
C
V
OUT
9/42
Evaluation board implementation AN2390

2.1.1 DC (Buck-Boost) converter component selection

The value of inductor L and capacitor C are selected by the following section. For more detail please refer to AN2389.
Inductor selection
The minimum value of the inductor can be selected by choosing the maximum of the values given by the following two formulae:
Lmin =
T * [ ( Vin - Vsat1) * D1 - Vsat2 * D2 - Vout * (D1 - D2))]
2 * Iout
T * [ Vd1 + Vout] * ( 1 - D1)
Lmin =
2 * Iout
Here Vsat1 and Vsat2 are the saturation voltages of the two switches Sw1 and Sw2.
Iout and Vout are the maximum output current and voltage respectively.
Vd1 and Vd2 is the voltage drop across diodes d1 and d2.
The duty cycle of the PWM signals driving switch Sw1 (PWM1) and Sw2 (PWM2) are D1 and D2 respectively.
Capacitor selection
The minimum capacitor value can be selected using the following formula to keep the variation in Vout with in 1%:
Cmin =
In practice we take inductor and capacitor values that are 25% more than the values calculated using the above formulae.
100 * Iout * (1 - D1) * T
Vout

2.1.2 Battery discharge protection

If the charger is not powered on or if the battery is already fully charged, the PNP transistor is kept permanently off which isolates the battery from the charger. Because of series diode available in the buck-boost circuitry there is no reverse current flowing into the charger. Therefore, the battery discharges into the output capacitor and resistive bridge. This allows battery voltage measurement while consuming very little current. Also some leakage current flows through the output capacitor.
10/42
AN2390 Evaluation board implementation

2.2 Analog measurement circuitry

2.2.1 Voltage reference generation

In the evaluation board, TL1431 is used to provide the reference voltage for the ADC measurement as shown in Figure 5.
Figure 5. Voltage reference generation circuit
V
IN
R3
100 (1%)
R16
4.7k (0.1%)
R17
15k (0.1%)
1
TL1431AIZ
2
VAREF
D4
This device provides a reference voltage to the ADC and provides a reference of precision better than the 0.5% needed for the battery charger application.
By choosing the appropriate value of R16 and R17 with the proper accuracy, we can provide the required reference voltage to the VAREF pin of the ST7 MCU using the following formula:
VAREF_VALUE = 2.5 V * (1 + R16 / R17)
11/42
Evaluation board implementation AN2390

2.2.2 Current measurement

The current measurement circuit is given in Figure 6.
Figure 6. Voltage and current measurement circuit
V+
BTI LI-ION BATTERY
AIN0
R19 5k (0.5%)
V
V
BAT
B
th
AIN8
V-
AIN1
R20
5k (0.5%)
As shown in the above diagram, a shunt (R to measure the charging current. The drop across this sense resistor is further amplified by using the OP-AMP (Operational Amplifier) LM258A for better resolution and this amplified voltage is measured by the ST7 microcontroller using ADC channel AIN1. The amplification factor is chosen such that the OP-AMP output has a voltage range between ground and V
.
DD

2.2.3 Voltage measurement

The voltage measurement circuit is also given in Figure 6 above, where the ST7 ADC channel, AIN0 is used for voltage measurement. In the evaluation board, while the input supply voltage V not possible to read the battery voltage directly, but this voltage is attenuated by using a resistor bridge (R whole ADC input range (0 to V
Note: The ST7 MCU does not measure V
I
). Some calculation must be performed on the conversion results to get the actual
BAT
battery voltage.
= 5 V, the microcontroller is supplied with VDD = 3.3 V. Therefore, it is
supply
, R20). However, this attenuation must still allow us to make full use of the
19
DD
R22
3.3k (0.5%)
0.5,1W (0.5%)
) is connected in series to the battery in order
23
R24
13.32k (0.5%)
R23
).
, it measures VB, which is proportional to (V
BAT
U3
1
O1
2
1-
3
1+
4
GND
LM258AD
VCC
O2
2­2+
8 7
6 5
BAT
V
IN
+ RS*
12/42
AN2390 Evaluation board implementation

2.2.4 Temperature sensing

The circuit for the temperature measurement is given in Figure 7.
Figure 7. Temperature measurement circuit
V
ST7 analog input (AIN8 or AIN14)
DD
R
S
Battery
For Li-ion, there is an inbuilt NTC so there is no need for an external thermistor but for NiMH, an external NTC is connected to the negative terminal of the battery.
The same measurement technique is used for both cases. Here the ST7 ADC channel AIN8 is used for the Li-ion temperature measurement and ST7 ADC channel AIN14 is used for NiMH.
For this demo application, we do not need to monitor the temperature very extensively. We only need to detect extreme hot or cold conditions. For this reason, rather than using a look­up table to calculate the temperature, certain predefined parameters are used and these parameters are compared with the temperature reading in terms of NTC resistance which simplifies the calculation.
13/42
Evaluation board implementation AN2390
Figure 8. NTC resistance value indication for Li-ion
No battery present
R
det
Cold condition
R
cold
Battery under normal temperature conditions
R
heat
Heat condition
Note: 1 Here R
corresponds to 45°C as the temperature limit for Heat Condition and R
heat
corresponds to 0°C as the temperature limit for Cold condition for safe charging for both Li­ion and NiMH batteries.
2R
is a dummy condition to detect when no battery is in the slot. This threshold is used to
DET
detect the battery presence for Li-ion battery only. For NiMH we use a different battery recognition scheme as explained in the following section.

2.2.5 Battery recognition mechanism

In this demo, different techniques are used for Li-ion and NiMH batteries to recognize whether a battery is present in the evaluation board or not.
Li-ion battery recognition scheme
As explained in the previous section, for Li-Ion batteries, the in-built NTC thermistor is used to detect battery presence as shown in Figure 8
NiMH battery recognition scheme
In this case, there is no inbuilt NTC in the NiMH as there is in a Li-ion battery. Hence we can not use the same technique for recognizing a NiMH battery. The NiMH battery recognition circuit is shown in Figure 9.
cold
14/42
AN2390 Evaluation board implementation
Figure 9. NiMH battery recognition circuit
Q5
31
V
IN
V+
R7
1k
To charger
2STR1215
R26 470
2
BT2
Ni-MH BATTERY
R27 470
3
V-
Q6
2
E_FRONT
2STR1215
1
Here the combination of two transistors works as a switch which is controlled by the E_Front signal coming from the ST7 MCU. The algorithm for NiMH battery recognition is as follows.
15/42
Evaluation board implementation AN2390
Figure 10. NiMH battery recognition algorithm
NiMH BATT Recog Algo
IF (I
BAT
> I
OPEN
NO
)
Exit
YES
ENABLE THE SWITCH AND
MEASURE THE BATTERY
VOLTAGE
NO
IF (V
BAT
> V
OPEN
)
BATTERY PRESENT
YES
BATTERY NOT PRESENT
END
Here if the battery current is less than a predefined threshold, switch (Q5) as shown in
Figure 9, is enabled and the battery voltage is measured if the battery voltage is lower than
the certain threshold the battery is considered connected otherwise it is considered not to be connected to the evaluation board.

2.2.6 Power supply restrictions

The battery characteristics have a direct influence on the choice of the DC power supply. The supply must be able to drive enough current to charge the battery, even in fast charge mode.
V
SUPPLY
Also the MCU, Buck-Boost DC-DC converter, LED and OpAmp consumption must be taken into account as well. R
In this demo, a DC supply providing 5 V and 2 A is chosen which is sufficient to satisfy the above condition.
16/42
must be larger than (VCE|
is the sense resistor, indicated as R23 in Figure 6.
S
SAT
+ V
diode
+ V
BAT_MAX
+ RS* I
CONST
).
AN2390 Evaluation board implementation

2.3 MCU software

2.3.1 Architecture

The software provided in this demo has state machine architecture. To explain more, various charging states can be defined for each slot. Each slot is driven by its state machine, with some interactions to implement front slot priority.
In order to measure the charge time, a timekeeper is implemented and counters are incremented periodically. Most of the time, slot states are unchanged. This implies that the PWM duty cycle, charge enable signals and LED on/off states are constant. Periodically, the ST7 microcontroller measures the battery current, battery voltage and thermistor voltage of both slots. Using the measurements and the timekeeper values, it updates slot states and the output configuration. If necessary, it resets the timekeeper.
17/42
Evaluation board implementation AN2390
Figure 11. Main software flowchart
RESET
Initialize I/O ports and peripherals
Initialize slot states
Launch timekeeper
Wait for
state update request
from main time base
Perform the measurements
Correct battery voltage measurements
with battery current measurements
Poll Li-ion
battery
Ye s
No
Poll NiMH
battery
Ye s
No
Front Rear
Voltage mean of 16 mean of 16
Current mean of 16 mean of 16
Thermistor mean of 16 mean of 16
Li-ion slot monitor
Updates front slot state depending on:
Previous slot states
Update output configuration
NiMH slot monitor
Updates front slot state depending on:
Previous slot states
Measurements
Timekeeper
Measurements
Timekeeper
18/42
Update output configuration
?
Reset timekeeper
AN2390 Evaluation board implementation

2.3.2 Use of the ST7 MCU on-chip peripherals

The time base is generated using the Main Clock Controller and the PWM is generated by the 16-bit timer. In order to minimize supply current, the ST7 core puts itself into WAIT mode between two state updates which is updated @50 ms for Li-ion and @5 s for NiMH but the PWM duty cycle for both is updated @50 ms. The reason for keeping the state update high for NiMH is to detect the end of charging conditions properly which requires monitoring the voltage difference (Zero Delta Voltage Condition) for a long period of time, keeping a low value might result in wrong detection. The selection of state update request for NiMH depends on the user application.
In this demo, the same interrupt condition (Timer reaching zero) also increments the timekeeper counters. This means the timekeeper is synchronized with the state updates.
The timekeeper divides the standard timer frequency. To do this, it has three counters: tick, timeKeeper_Low and timeKeeper_Hi.
Table 4. Charge timekeeper counters
tick timeKeeper_Low timeKeeper_hi
Increment Condition Timer Zero IT tick = 0 timeKeeper_Low = 0
Period
General T
Evaluation
board
TMZ
2 ms 250 ms 1 min
125 * T
TMZ
60,000 * T
TMZ
The analog to digital converter (ADC) is used intensively before each slot state update. In most cases, the PWM output cannot be disabled, so due to switching noise, the ADC accuracy is not optimal. To reduce errors, the ADC measures battery voltage, battery current and battery temperature 16 times in a row and takes the average as the final value. The software is able to remove any spurious errors due to noise to avoid any wrong interpretations. The slot state monitoring software works with the mean values.
As explained earlier, battery voltage measurements must be corrected with battery current measurements. These corrections require some computing, performed on the 16-bit words.
19/42
Evaluation board implementation AN2390

2.3.3 State diagrams

A slot can be in one of the nine states as described in following table. These states are updated periodically as described earlier in Section 2.3.1
Table 5. Slot state definitions
Output configuration
Name Meaning
Slot outputs PWM duty cycle
IDLE Slot empty
TRI_1 1st Trickle charge state
CI Constant current charge
CV
Constant voltage charge,
duty cycle down
TRI_2 2nd Trickle charge state
SAT Battery saturated
EXP Charge time expired
FAIL Battery failure
Charge disabled,
LEDs off
Charge enabled,
LED blinking @ 1Hz
Charge disabled,
LED ON
Unchanged
Updated periodically to
bat
= I
tri_1
have I
Updated periodically to
have I
bat
= I
const
Updated periodically to
bat
= V
F
have V
Updated periodically to
bat
= I
tri_2
have I
Unchanged
Charge disabled,
HEAT
Charge suspended
by overheat
LED blinking @ 2Hz
It is important to understand that this choice of states is only one solution and that there are many possible ways to manage the behavior of the charger.
The state transition diagram is too complex to be shown in a single figure, it has been divided into six parts shown in Figure 12 through Figure 17. In the diagrams, 't' stands for the timekeeper value. The rectangles represent actions performed once during a state transition.
20/42
AN2390 Evaluation board implementation
Figure 12. General charging flow – Li-ion charging state diagram (1/3)
Li-ion charging
algorithm
EXP
If V
BAT
< V
TRI_2
SAT
IDLE
If V
> V
If (I
TRI_1
BAT
> I
If V
) OR if (V
FAIL
BAT
FAIL
> V
BAT
FAST
CC mode
< V
AND t > t
SC
FAI L
SAT
)
CV mode
If I
BAT
BAT
> I
F
SAT
Trickle charging to maintain current = 0.2C
CI_D
CI_U
Heat
If V
> V
BAT
F
Suspend PWM until it gets to normal condition
CV_D
CV_U
21/42
Evaluation board implementation AN2390
Figure 13. Time expiry condition – Li-ion charging state diagram (2/3)
Li-ion charging
algorithm
IDLE
EXP
TRI_2
TRI_1
FAIL
CC mode
CI_D
CI_U
If t >= t
Heat
SAT
EXP
CV mode
CV_D
CV_U
22/42
AN2390 Evaluation board implementation
Figure 14. Battery Idle condition – Li-ion charging state diagram (3/3)
IDLE
TRI_1
Heat (Suspend
PWM)
No battery present
CC mode
CI_D
CI_U
EXP or SAT
FAIL
CV mode
CV_D
CV_U
23/42
Evaluation board implementation AN2390
Figure 15. General charging flow – NiMH charging state diagram (1/3)
NiMH charging
algorithm
EXP
TRI_1
Trickle charging to maintain current = 0.2C, no -dV checking
FAIL
If (I
I
f
V
B
A
T
>
V
T
R
I
IDLE
> I
BAT
FAIL
CC mode
CI_D
) OR if (V
BAT
< V
If (dV/dt for timeCheck)
Or, if V Or, if (t > t
BAT
> V
FAS T
AND t > 30 min)
FAIL
MAX
SAT
)
CI_U
Trickle charging to keep current = 0.033C to 0.05C
Heat
24/42
Suspend PWM
AN2390 Evaluation board implementation
Figure 16. Time expiry condition - NiMH Charging State Diagram (2/3)
NiMH charging
algorithm
EXP
FAIL
TRI_1
IDLE
CC mode
CI_D
CI_U
Heat
If t >= t
SAT
EXP
25/42
Evaluation board implementation AN2390
Figure 17. Battery Idle Condition – NiMH Charging State Diagram (3/3)
NiMH charging
algorithm
EXP IDLE
No battery present
FAIL
SAT
TRI_1
CC mode
CI_D
CI_U
Heat
26/42
AN2390 How to use the evaluation board

3 How to use the evaluation board

3.1 Connecting the evaluation board

3.1.1 Jumper Connections

The following jumpers must be correctly configured for proper operation of the evaluation board.
J1: This is a 3-pin connector for selecting between ICC clock and resonator clock.
Figure 18. ICC connector
EXT
123
OSC1 ICC_OSC
J1
ICC clock is used only when we need to re-program the ST7 microcontroller. For normal operation please short pin 1 and pin 2.
J2, J3: These jumpers are used to connect charger slots for different batteries as shown in
Figure 19.
Figure 19. J2 and J3 connections
UNIVERSAL BATTERY
RT1: NTC CONNECTOR
CHARGER
J2 CONNECTOR FOR NiMH
V+
V-
J3 CONNECTOR FOR Li-ION
V+
TV-
Put NTC close to slot
2-CELL NiMH
BATTERY CHARGER SLOT
27/42
1-CELL Li-ION
BATTERY CHARGER SLOT
How to use the evaluation board AN2390
The role of each jumper is as follows:
J2: Used to connect NiMH Battery Charger Slot
J3: Used to connect NiMH Battery Charger Slot
RT1: RT1 is used to connect external NTC. This NTC is put close to the NiMH charger slot
to correctly monitor the NiMH battery temperature.

3.1.2 Powering and running the evaluation board

After all the jumpers are connected as described in Section 3.1.1, you can connect the power supply. To connect the power supply there is a power jack X1 (5V, Gnd) available on the evaluation board. You need to connect a DC power supply of (5V, 2A) to this connector.
After connecting the power supply, you need to press the Reset button on the evaluation board for correct operation.
Now the evaluation board is in running mode and you can monitor the charging status through LED D5 status as mentioned in Tab le 3 .
Note: It is necessary to press the Reset button once after connecting the power supply as the LVD
feature is not used in this evaluation board. However the LVD can be implemented in a real application

3.2 Warnings/ Limitations

The user should be aware of the following warnings/limitations when using this evaluation board.
1. Only one type of battery can be charged at a time and there is no protection to prevent shorting the batteries if they are connected simultaneously in both slots. So the user has to make sure to connect only one battery at a time.
2. There is no protection for reverse battery polarity connection but it can be provided on customer request.
3. To minimize noise spikes at the input power supply, please connect a capacitor of 100 ­220 uF between the input power supply and Gnd.

3.3 Example test results with evaluation board

3.3.1 Test environment

In this implementation of the buck-boost converter, the following values are taken into account.
Transistor drop |V V
= 0.5V, F
sense
timer is updated at 500 Hz.
| (SAT) = 0.2V, Diode drop |Vd| = 0.55 V, L = 75 mH, C = 470 uF, Max
CE
= 8 MHz, F
cpu
= 16 kHz and Ambient Temperature = 24 deg C. Also the
pwm
28/42
AN2390 How to use the evaluation board

3.3.2 Li-ion battery charger

The following parameter values are used in the Li-ion charger:
Table 6. Li-ion battery charger parameters
SL No Parameter name Value
Input Parameter
1 Input Supply Voltage 5 V
2 Max Input Supply Current 2A
Output Parameter
3 Max Battery Output Voltage 4.2V
4 Max Output Current 1000 mA
The following values are programmed for the different phases:
1) Precharge Phase:
Here Vbat <= 3.0 V and charging current: 200 mA
2) Constant Current Phase:
Here 3.0 < Vbat < 4.2 V and charging current: 500 mA
3) Constant Voltage Phase:
Here 4.15< Vbat < 4.2 V
Ta bl e 9 shows the results of an experiment with the evaluation board charging a single Li-ion
battery.
29/42
How to use the evaluation board AN2390
Table 7. Li-ion test results
SL No Time (minutes)
Input voltage
(V)
Input current
(mA)
Output voltage
(V)
Output current
1 0 5 1230 3.9 1050
2 3 5 1230 4 1050
3 8 5 1280 4.05 1050
4 13 5 1350 4.1 1050
5 18 5 1360 4.14 1050
6 23 5 1380 4.18 1050
7 28 5 1390 4.2 1050
8 30 5 1470 4.2 1080
9 31 5 1300 4.2 1045
10 32 5 1270 4.2 975
11 34 5 1260 4.2 968
12 36 5 1150 4.2 906
13 38 5 1070 4.2 867
14 40 5 970 4.2 799
15 42 5 850 4.2 712
16 44 5 720 4.2 616
(mA)
17 46 5 650 4.2 555
18 58 5 330 4.2 280
19 60 5 310 4.2 260
20 62 5 270 4.2 224
21 65 5 240 4.2 205
22 68 5 200 4.2 160
23 70 5 200 4.2 160
24 73 5 163 4.2 129
25 75 5 150 4.2 123
26 78 5 124 4.2 94
27 80 5 120 4.2 90
28 83 5 110 4.2 81
29 85 5 92 4.2 64
30 88 5 90 4.2 61
31 93 5 74 4.2 45
32 99 5 54 4.2 27
30/42
AN2390 How to use the evaluation board
The total time was around 99 minutes in which the constant current phase remained for around 30 minutes. Figure 20 shows the graph of the output current versus time.
Figure 20. Output Current vs. Time
Output Current (mA) Vs Ti m e (Minutes)
1200 1000
800 600 400
Current (mA)
200
0
0
13
28
32
38
44
60
68
75
83
93
Time (Minutes)
The variation in the output current was around +/- 10mA and the variation in output voltage was +/- 20 mV.

3.3.3 NiMH battery charger

The following parameter values are used for the NiMH charger.
Table 8. Table 8: NiMH battery charger parameters
SL No Parameter name Value
1 Input Supply Voltage 5 V
2 Max Input Supply Current 2 A
3 Max Battery Output Voltage 1.7 V / cell
4 Output Current 1000 mA
The following values are programmed for the different phases:
1) Pre-charging Phase:
Here Vbat <= 1.0 V and charging current: 0.1 C = 200 mA
Charging time taken by the battery: 10 minutes (approximately)
Input Parameter
Output Parameter
2) Constant Current Phase:
Charging Current = 1 A and Programmed charging time = 2 Hr
31/42
How to use the evaluation board AN2390
3) Saturation Phase:
Charging Current = 0.03 C = 60 mA, and Expiry Time = 4 Hr.
In this case the C rate is 1000 mA. After the expiry time is over, charging is stopped till a new battery is inserted.
Ta bl e 9 shows the results of an experiment for constant current charging phase for a 2 Cell
NiMH battery charger.
32/42
AN2390 How to use the evaluation board
Table 9. NiMH test results
SL No Time (minutes)
Input voltage
(V)
Input current
(A)
Output voltage
(V)
Output current
1 0 5 1.01 3.16 1015
2 5 5 1.01 3.165 1015
3 10 5 1.01 3.168 1015
4 15 5 1.01 3.172 1015
5 20 5 1.01 3.168 1015
6 25 5 1.01 3.16 1015
7 30 5 1.01 3.168 1015
8 35 5 1.03 3.172 1015
9 40 5 1.03 3.175 1015
10 45 5 1.03 3.186 1015
11 50 5 1.03 3.2 1015
12 55 5 1.03 3.206 1015
13 60 5 1.03 3.214 1015
14 65 5 1.03 3.223 1015
15 70 5 1.03 3.231 1015
16 75 5 1.03 3.245 1015
(mA)
17 80 5 1.05 3.252 1015
18 85 5 1.05 3.264 1015
19 90 5 1.05 3.282 1015
20 95 5 1.05 3.3 1015
21 100 5 1.08 3.35 1020
22 105 5 1.08 3.4 1020
23 110 5 1.08 3.38 1020
24 115 5 1.08 3.37 1020
25 120 5 1.08 3.37 1020
26 125 5 1.08 3.37 1020
27 130 5 1.08 3.36 1020
The variation in the output current was around +/- 10 mA and the variation in output voltage was +/- 20 mV. Figure 21 shows the graph of the output current versus time.
33/42
How to use the evaluation board AN2390
Figure 21. Output voltage vs. time (in minutes)
Output Volta ge Vs Time
3.45
3.4
3.35
3.3
3.25
3.2
3.15
3.1
Output Voltage (in V)
3.05 3
0
10
20
30
0
40
60
5
Time (In Minutes)
70
80
90
100
110
120
13
0
Figure 21 shows the variation in output voltage versus time for the constant current charging
phase. Here the programmed time for constant current is increased by 10 minutes just to show the behavior of the charger.
34/42
AN2390 Conclusion: a low-cost flexible solution

4 Conclusion: a low-cost flexible solution

Everything on the evaluation board has been designed to make it easy to adapt in any way (to other types of battery, new behavior specifications, additional design constraints, etc.).
The demo is developed with an ST72324L microcontroller device but you can choose
another MCU device if you so desire.
Because of the flexibility of the MCU, you can modify the firmware for wide variety of
applications and this is well supported by the flexible non inverting buck boost converter which can adapt to different supply voltages. For example, you could easily make a USB charger to charge a 4.2 V Li-ion battery.
The firmware is developed in ‘C’ language. So it is easily upgradeable.
The number of components needed for each slot (charging and feedback) is minimal,
so replacing them is inexpensive.
The code size is approximately 3 Kbytes. The current firmware supports Li-ion and
NiMh battery chemistry but it can be easily converted to charge other battery chemistries, for example to charge SLA batteries.
ST’s low cost PNP and NPN transistors and diodes are used to implement this
converter which makes it even more cost-effective.
35/42
References AN2390

5 References

[1] AN2389: “An MCU-based low cost non-inverting buck-boost converter for battery chargers”, STMicroelectronics
36/42
AN2390

Appendix A

A.1 Source file organization

The code is written in ‘C’ language. The Code Size is approximately 3 Kbytes. The source code consists of 3 source files and 3 header files as listed below:
main.c: it consists of the main subroutine.
BC_func.c: These files contain the definitions of all the functions used in the main
subroutine.
Interrupt_vector.c: it consists of the interrupt vector mapping files.
BC_func.h: it consists of the declarations of all the global variables and the functions
used in the main.
ST7lib_config.h: It is the configuration file and also consists of the #define statements
for assembly language instructions like ‘NOP’ etc.
st7lites2_5_reg.h: It contains the declarations of the hardware registers.
This modular organization makes it easier to perform minor modifications to the software.
Table 10. Examples of minor software modifications
If you want to change… …only modify…
Voltage thresholds
PWM frequency
State update frequency
Timing thresholds
I/O Configuration BC_InititalizePeripheral() in BC_Func.c
State diagram
State definitions
BC_SlotMonitor() function in BC_Func.c
Transition conditions
Transition priority
BC_Func.h
37/42

A.2 Schematic

D
8
Li-ION BATTERY
123
J2
V+
AIN8
100 (1%)
D3
Vsupply
F1
12
TL1431AIZ
R16
4.7k (0.1%)
IN4148
FUSE2
U1
V-
D4
8
Vin
Vout1GND2GND3NC
VDD
7654321
VAREF
R3
Vin
Universal Battery Charger
Ni-MH BATTERY
1
2
J3
V+
V-
Vin
7
8
O2
VCC
O111-21+3GND
U3
AIN1
R24
13.32k (0.5%)
R22
3.3k (0.5%)
AIN8
BT1
Li-ION BATTERY
th
C2
100nF(Not To Be Mounted)
3
R17
7
5
GND6GND
INHIBIT
4
Q3
R1
330
V+
R19
15k (0.1%)
R15
10k
KF33BDTR
6
4
E
C5C
C1C2B
3
5k (0.5%)
C1
470uF/16V
D2
1N5821
R4
L1
STT818B
100
75uH/1000mA
Vsupply
D1
1N5821
R2
100
31
6
5
2-
2+
LM258AD
4
R23
0.5,1W(0.5%)
Vin
13
Q5
V-
R7
R20
5k (0.5%)
AIN0
Q4
23
31
2
Q1
AN2390
C
LEDD6LEDD7LEDD8LED
D5
470
470
470
R9
R10
R11
R12
LED1
LED2
LED3
LED4
E_FRONT
2
2STR1215
Q6
31
R26
470
R27
470
2
2STR2215
1k
BT2
Ni-MH BATTER Y
2STF1360
1
Q2
R5
2STR1215
R13
68
2STR1215
R6
1k
2
PWM-1
470
AIN14
t
RT1
4.7k/NTC
V-
PWM-2
B
R25
10k
ICCSEL
ICCDATA
ICCCLK
RESET
470
33pFC433pF
Y1
C3
OSC_EXT
R8
1k
E_FRONT
1 2
3 4
5 6
7 8
9 10
CON1
U2
J1
PE0 PE1
GND
VDD
3 2 1
OSC_EXT
VDD
R21
4.7k
GND
OSC1
OSC2
22
23
VDD
OSC124OSC2
PB0 PB3
(HS)/PB4 PDO PD1
VAREF1VSS2AIN8/PF03PF14AIN10/PF45PF6
AIN8
GND
VAREF
10k (1%)
R14
VDD
VSS
C5
RESET
21
HEADER 5X2
10nF
ICCSEL
20
RESET
S1
LED4
ICCSEL
6
PWM-1
OSC1
PA719PA618PA4
LED3
ST72F324LK2T6
7
C6
LED2
17
PA3 PC7 PC6 PC5 PC4 PC3 PC2 PC1
PF7
PC0
8
ICC
16MHz
OSC2
25
VDD
26 27 28 29 30 31
AIN0
32
AIN1
A
1of1
STMicroelectronicsPvt Ltd
Plot no. 1 , Knowledge P ark III,
Greater Noida -201308, UP
INDIA
UNIVERSAL_ BATT_CHARGER
2.2 uF/16V
100nF
100nF
C7
C8
C9
VDD
AIN0
AIN1
16
LED1
15 14
ICCCLK
13
AIN14
12
ICCDATA
11 10
9
PWM-2
Scale Sheet
Size FCSMNo. DWG No. Rev
A3 1
100nF
100nF
C10
AIN8
AIN14
R18
4.7k (1%)
VDD
1
2
X1
D
C
38/42
1 2 3 4 5 6 78
B
A
AN2390

A.3 BOM

Table 11. Bill of material
Index Qty Reference
1 1 C1 470uF/16V RB-.2/.4 Any
26
3 1 C6 2.2 uF/ 16V 805 Any
4 1 C5 10nF 805 Any
5 1 CON1 HEADER 5X2 IDC-10B Any
6 2 D1, D2 1N5821
C3, C4, C7,
C8, C9, C10
Value / Generic
Part Number
Package
100nF 805 Any
DO-
201AD
Manufacturer’s
Manufact
urer
ordering code /
Recordable Part
ST 1N5821
Number
7 1 D3 IN4148
DO-35-
TH
Any
8 2 D4 TL1431 TO-92 ST TL1431AIZ
94
D5, D6, D7,
D8
LED LED Any
10 1 F1 FUSE2 FUSE Any
11 1 J1 CON3 SIP-3 Any
12 1 J2 CON3 SIP-3 Any
13 1 J3 CON2 SIP-2 Any
14 1 L1 75uH/1000mA IND Any
15 3 Q1, Q2, Q6 2STR1215 SOT-23 ST 2STR1215
16 1 Q3 STT818B
SOT23-
6L
ST STT818B
17 1 Q4 2STF1360 SOT-89 ST 2STF1360
18 1 Q5 2STR2215 SOT-23 ST 2STR2215
19 1 R1 330 805 Any
R5, R9, R10,
20 7
R11, R12,
470 805 Any
R26, R27
21 1 R13 68 805 Any
22 2 R14, R15 10k (1%) 805 Any
23 1 R16 4.7k (0.1%) 805 Any
24 1 R17 15k (0.1%) 805 Any
25 1 R18 4.7k (1%) 805 ST
26 2 R19, R20 5k (0.5%) 805 Any
27 1 R2, R7 100 805 Any
39/42
Table 11. Bill of material
Manufacturer’s
Index Qty Reference
28 1 R21 4.7k 805 Any
29 1 R22 3.3k (0.5%) 805 Any
30 1 R23 0.5, 1W (0.5%) RES Axail Any
31 1 R24 13.32k (0.5%) 805 Any
32 1 R25 10k 805 Any
33 1 R3 100 (1%) 805 Any
34 1 R4 100 805 Any
35 3 R6, R8 1k 805 Any
36 1 RT1 4.7k/NTC RAD-0.1 Any
37 1 S1 SW-PB PUSH Any
38 1 U1 KF33 SO-8 ST KF33BDTR
39 1 U2 ST72F324L TQFP-32 ST ST72F324LK2T6
Value / Generic
Part Number
Package
Manufact
urer
ordering code /
Recordable Part
Number
AN2390
40 1 U3 LM258AD SO-8 ST LM258AD
41 1 X1
42 1 Y1 16MHz XTAL-1 Any
Power
Connector
Euro 2 pin Any
40/42
AN2390 Revision history

Revision history

Table 12. Document revision history
Date Revision Changes
21-Aug-2007 1 Initial release.
41/42
AN2390
Please Read Carefully:
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY, DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.
© 2007 STMicroelectronics - All rights reserved
STMicroelectronics group of companies
Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan -
Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America
www.st.com
42/42
Loading...