STMicroelectronics AN1464 Low-cost double li-ion battery charger Datasheet

AN1464
APPLICATION NOTE
LOW-COST DOUBLE LI-ION BATTERY CHARGER
USING ST6255C/ST6265C MCU
by Microcontroller Division Applications
DESCRIPTION
In everyday life, more and more portable electronic appliances, such as mobile phones, are
powered by rechargeable batteries with a requirement for high capacity, small size and low
weight. Li-ion batteries have been widely used to support these kind of devices due to their superior capacity for a given size and weight.
This Application Note explains how to use the ST6255C 8-bit Microcontroller in a cost-effective battery charger for Li-ion batteries, as implemented in the Li-ion Battery Charger Demonstration Board. The design implemented on this Board is easily scaleable to other types of Liion batteries simply by changing the software parameters and primary input voltage/current.
The charger has two slots. The front one can be used to plug in a simple battery or a mobile
phone with an internal battery. The rear slot is for pluging in a stand-alone battery. A pair of
LEDs (green/red) are assigned to each slot to indicate the charge status.
The main target MCU is the ST6255C. Among other features, this microcontroller embeds an
A/D converter, a PWM signal generator and 4K bytes of program memory, which is enough to
embed the algorithm. The board also supports the ST6265C MCU, which adds 128 bytes of
internal EEPROM to the features of the ST6255C.
The evaluation board is intended to be equipped with two mobile phone batteries and an
ST62T55C OTP sample to execute the demonstration software. The software parameters are
adapted to a fixed battery capacity of 600 mAh. With minor modifications to the system, it is
possible to make the charger read the battery capacity and change its parameters accordingly
(feature not implemented on the evaluation board).
The board must be powered by an external low-voltage DC supply (6 V, 800 mA).
AN1464/1001
1/27
1
Table of Contents
DESCRIPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1 THEORY OF OPERATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1 BATTERY CHARGING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 SLOT PRIORITY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 MAN-MACHINE INTERFACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 EVALUATION BOARD IMPLEMENTATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1 CHARGING CIRCUITRY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.1 Charging Current Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 PWM SIGNAL SWITCHING GENERATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.1 Measurement Circuitry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.2 Battery Discharge Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.3 Power Supply Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 TEMPERATURE SENSING AND BATTERY DETECTION . . . . . . . . . . . . . . . . 10
2.4 MCU SOFTWARE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
On-chip peripherals usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
State Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Slot Monitor Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Source File Organisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3 CONCLUSION: A LOW-COST FLEXIBLE SOLUTION . . . . . . . . . . . . . . . . . . . . . . . 24
4 APPENDIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.1 SCHEMATIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2 BILL OF MATERIAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
27
2/27
1
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
1 THEORY OF OPERATION
1.1 BATTERY CHARGING
Li-ion batteries have a very different charging procedure from NiCd or NiMH batteries. Li-ion
batteries should be charged using two different methods (Figure 1.), constant voltage and
constant current.
Figure 1. Li-ion Charging Method
Battery
voltage
Vf
t
Battery
current
I const
I sat
t
Stage 1
Stage 2
During Stage 1 (constant current charge), the charging current is kept at a constant value
(Iconst) until the battery voltage reaches the final cell voltage (V F). Note that the battery could
suffer significant damage if this final voltage is exceeded. Then, in Stage 2 (constant voltage
charge), the voltage is kept constant within this limit by slowly decreasing the current.
Charging is stopped when the current drops below the manufacturer fixed threshold value
(ISAT). This current indicates that the battery is saturated.
3/27
2
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
If the battery voltage drops below a certain threshold (VFAST), a fast charge is applied. During
fast charging, the current is kept constant at IFAST > ICONST.
After a certain time (tFAIL ) of fast charging, and if battery voltage remains particularly low
(under VFAIL), the charger indicates a battery failure and stops charging. If the battery voltage
is even lower (below V SC), the charger indicates a battery failure without waiting (protection
against short-circuit).
If the charging time exceeds a certain expiration value (tEXP), charging is stopped even if the
battery is not yet saturated. As the tEXP value is greater than the tFAIL value, the charger indicates that the battery is in good condition and fully charged.
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 VTRI, charging restarts until V F is
reached again. Charge time is reset when trickle charging starts.
Table 1. Charge Parameters used by the Evaluation Board
Symbol
VF
VTRI
VFAST
VFAIL
VSC
IFAST
ICONST
ISAT
tFAIL
tEXP
Meaning
Final Battery Voltage
Trickle Charge Voltage
Fast Charge Voltage
Battery Failure Voltage
Short-circuit Voltage
Fast Charge Current
Constant Charge Current
Battery Saturation Current
Battery Failure Time
Charge Expire Time
Value
4.2
4.12
3.8
2.5
1.5
600
550
15
30
2.5
Unit
V
mA
s
h
1.2 SLOT PRIORITY
Battery presence in both slots is permanently monitored to implement the priority of the front
slot over the rear slot. Whenever a battery is plugged into the front slot while the rear slot battery is being charged, rear charging is stopped and front charging begins. When front charging
is terminated (battery saturated, expire time reached, battery failure or battery removed), rear
charging restarts from the beginning.
If the front battery requires trickle charging, rear battery full charging has the priority. If both
batteries are saturated, the first battery to meet the trickle charge condition is charged, and
then the second one. If both batteries meet trickle charge conditions at the same time, front
slot has the priority.
4/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
Priority rules are not changed even if charging is suspended because of overheating.
1.3 MAN-MACHINE INTERFACE
As the charger periodically checks battery presence, no button is needed to start or stop
charging.
A reset button is included on the evaluation board for development purposes.
A pair of LEDs (green/red) are dedicated to each slot to indicate the charge status.
Table 2. LED Slot Status Color Code
Color
Off
Red only
Red and green
Green only
Flashing red
Status
No battery in the slot
OR
Rear charge stopped by front charge
Battery under charge
Overheat
Charge cycle completed
Battery failure
5/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
2 EVALUATION BOARD IMPLEMENTATION
2.1 CHARGING CIRCUITRY
The evaluation board implements a solution with an external low-voltage DC supply, unlike the
solutions described in other Battery Charger Application Notes.
To obtain a constant voltage during one stage and a constant current during another, the ST6
measures the battery voltage (VBAT) and current (IBAT). With this feedback, it regulates the
charging voltage using a buck converter circuit (Figure 2.):
Figure 2. Schematic of PWM Control of Battery Charging
Vsupply
To ST6 analog
PWM signal
Diode
A
L
Battery
IBAT
Ra
VA
Schottky
rectifier
C
VBAT
VC
Rb
Vb
RS
To ST6
analog input
2.1.1 Charging Current Control
The PWM signal generated by the ST6255C switches the PNP transistor on and off. A
Schottky rectifier is needed to receive the current from the coil when the PNP transistor is off
(free-wheeling mechanism). As a result, the PWM signal is transferred to the node A voltage:
– when the transistor is on, VA = VSUPPLY - |VCE|SAT and the rectifier is off;
– when the transistor is off, the rectifier is on and VA = -Vd.
|VCE|SAT is the collector-emitter voltage of the PNP transistor in saturation state. Vd is the forward voltage drop of the Schottky rectifier.
Let us first consider a small period of time, e.g. ~100 PWM cycles.
Battery voltage variations are far slower than PWM switching, so V BAT can be considered as
constant during this period. With this approximation, V C can be seen as the response of the
LC network to the incoming PWM signal V A. The network acts as a low-pass filter. Therefore,
if the PWM frequency is far higher than cut-off frequency, V C is constant and equal to the
mean value of VA.
6/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
In this demo, L = 150 µH and C = 220 µF so the cut-off frequency is 876 Hz. The PWM frequency is fixed at ~30 kHz. This way, charging voltage ripple is minimized.
If α is the PWM positive duty cycle in A, the mean value of VA is α*(VSUPPLY - |VCE|SAT) + (1
- α)*(-Vd). Accordingly, the charging current is:
I bat =
(
α ⋅ Vsup ply − VCE
sat
) + (1 − α ) ⋅ (− V
d
) − VD
− V bat
RS
Where VD is the forward voltage of the diode.
Example with the evaluation board hardware:
For the maximum current to apply (600 mA), typical values are:
|VCE|SAT = 0.5 V,
Vd = 0.4 V,
VD = 0.9 V.
In fast charge mode, IBAT = 600 mA and the maximum battery voltage is 3.8 V. This requires
a duty cycle of ~92%. In constant current charge mode, IBAT = 550 mA and the maximum battery voltage is 4.2 V. In this case, the required duty cycle is ~98%. These values show that the
range of duty cycles is fully used, which improves PWM resolution.
Let us now consider the whole charging time. At this scale, α, IBAT and VBAT are not constant.
The above equation helps to understand how α evolves during this time.
During the 1st charge stage, VBAT increases, so the MCU increases α in order to keep IBAT
constant. During the 2nd stage, α decreases gradually in order to reduce I BAT, but this does
not decrease V BAT.
2.2 PWM SIGNAL SWITCHING GENERATION
The ST6255C only provides one PWM signal. Switching the signal from one slot to another is
done through the E_FRONT and E_REAR signals, generated by standard output pins. It is
less expensive to implement the AND function using NPN transistors than with AND gates.
7/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
Figure 3. PWM Signal Generation Circuit
Vsupply
REBf
IBf
REBr
ISf
Vdd
ICf
ISr
Vdd
Sf
IENf
IBr
ICr
RBf
Afront
Vsupply
RBr
RENf
RENr
front charge enable
signal from ST6
Arear
IENr
Sr
rear charge enable
signal from ST6
IPWMf
IPWMr
RPWMf
RPWMr
PWM signal from ST6
Selecting the proper power PNP transistor is not enough to make sure the buck converter can
actually output the maximum current. The driving resistors (REB, RB, REN and RPWM) should
also be chosen accordingly.
– When the PNP is on, |VCE| should be as small as possible to minimise losses. This requires
to be in saturation state, with a high base current. This current is equal to:
IB =
Vsup ply − VBE − VSon
RB
−
V BE
R EB
|VBE| is the base-emitter voltage of the PNP. VSON is the node S voltage when both NPNs
are on. It equals the sum of saturation collector-emitter voltages for the 2 NPNs.
RBE and RB guarantee that IC/IB ≤ 10 even if IC is at its maximum.
Example with the evaluation board hardware:
At maximum collector current (IC = 600 mA), |VBE| = 0.9 V typically.
At IS ~ 60 mA, VSON = 0.2 V.
REB = 270 Ω and RB = 75 Ω meet the requirements (and then IS = 65 mA).
– When on, the NPN transistors must also be in saturation state.
REN makes sure that IS/IEN ≤ 10 even for the maximum value of IS. E_FRONT and E_REAR
8/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
ST6 pins are open-drain outputs, so
I EN =
Vdd − (VBE )sat − (VCE )sat
R EN
Here, unlike previous equations, (VBE)SAT and (VCE)SAT refer to the NPN transistor values.
RPWM guarantees that (IS + IEN)/IPWM ≤ 10 even if (IS + IEN) is maximum.
I PWM =
V oh − (VBE )sat
R PWM
Voh is the output high voltage of the ST6 pin emitting the PWM signal.
Example with the evaluation board hardware:
At maximum current (IS = 65 mA), typical values are (VBE)SAT = 0.9 V and (VCE)SAT = 0.1 V.
For IPWM = 7 mA, VOH = 4 V typically (cf. ST6 datasheet).
REN = 620 Ω and RPWM = 430 meet the requirements.
2.2.1 Measurement Circuitry
A shunt (RS) is connected to the battery in order to measure the charging current. The MCU
reads the VS voltage with its on-chip A/D converter. The converter has a voltage range between ground and VDD. When VS is too low, like in this case, an amplification circuit is needed,
e.g. with an OpAmp.
In our case, Vsupply = 6 V and the microcontroller is supplied with VDD = 5 V. Therefore, it is
safer not to read Vbat directly, but to attenuate this voltage by using a resistor bridge (Ra, Rb).
However, this attenuation must not be too strong to take maximum profit of the whole ADC
input range (0 to VDD). This must be taken into account when choosing a proper Ra/Rb ratio.
Note that the ST6 does not measure V BAT but VB, which is proportional to (VBAT + RS*IBAT).
Some calculation must be performed on the conversion results to access the real battery
voltage.
2.2.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. The diode prevents the battery from discharging into the capacitor.
Therefore, the battery discharges into RA, RB and RS, which requires less current.
2.2.3 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.
9/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
– VSUPPLY must be larger than (|VCE|SAT + VD + VFAST + RS*IFAST) and larger than (|VCE|SAT
+ V D + VF + RS*ICONST), but does not need to be significantly larger.
MCU, LED and OpAmp consumption must be taken into account as well.
The board is designed to work with a DC supply providing 6 V and 800 mA. V DD = 5 V is generated from VSUPPLY by a voltage regulation circuit. If you intend to increase VSUPPLY, make
sure you adapt this regulation circuit.
2.3 TEMPERATURE SENSING AND BATTERY DETECTION
The Li-Ion battery used in this demo contains a thermistor connected to the negative pole, as
described in Figure 4.
Figure 4. Temperature Sensing Circuitry
Vdd
Battery
To ST6 analog input
RS
When the slot is empty (no battery plugged in), the ST6 reads VDD on the analog input. Thus,
a low value of the voltage indicates that a battery is present.
The thermistor resistance decreases with temperature, and so does the thermistor voltage.
Therefore, an anormally low value of this voltage indicates overheating.
10/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
Figure 5. Thermistor Voltage Indication
Vdd
no battery
Vdet
battery under normal
temperature conditions
Vheat
battery under overheat
Vss
Table 3. Thermistor Voltage Thresholds used by the Evaluation Board
Symbol
VDET
VHEAT
Meaning
Battery Detection Voltage
Overheat Voltage
Value
4.7
2.0
Unit
V
Note: Because the exact characteristics of the thermistor were unknown to us, the VHEAT value given in
the table above is only an example. Note that, generally, for this kind of batteries, the temperature
limit is set to 45°C.
2.4 MCU SOFTWARE
2.4.1 Architecture
The software provided with the evaluation board has a state machine architecture. As explained further, 10 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 ST6 measures battery current, battery voltage and thermistor voltage for both slots. Using the measurements and the
timekeeper values, it updates slot states and the output configuration. If necessary, it resets
the timekeeper.
11/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
Figure 6. ST6255C Software Flowchart
RESET
Initialise I/O ports and peripherals
Initialise slot states
Launch time-keeper
Wait for
state update request
from main time base
Perform the measurements
Voltage
Current
Thermistor
Front
mean of 256
mean of 256
1
Rear
mean of 256
mean of 256
1
Correct battery voltage measurements
with battery current measurements
Front slot monitor
Updates front slot state depending on:
Previous
slot states
Measurements
Time-keeper
Rear slot monitor
Updates rear slot state depending on:
Previous
slot states
Measurements
Timekeeper
Update output configuration
Front
?
Rear
Reset
timekeeper
12/27
Common PWM
LEDs on/off
Charge enable/disable
LEDs on/off
Charge enable/disable
Output on/off
Duty cycle
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
2.4.2 On-chip peripherals usage
The time base is given by the standard timer in output mode. When the timer counter
reaches zero, the interrupt routine generates a state update request. In addition, it reloads the
timer counter to start a new cycle.
In order to minimise supply current, the ST6 core puts itself into WAIT mode between two
state updates.
In this example, this same interrupt routine (Timer Zero) also increments the timekeeper
counters. This means the timekeeper is synchronised with the state updates.
The slot state update frequency is an important parameter. It must be high to maximise
charging efficiency. On the other hand, if the output configuration has changed, it is useless to
perform the next measurements before the system has stabilised. Therefore, an excessive
update frequency could prove harmful. Thirdly, a low update frequency reduces overall power
consumption.
The timekeeper divides the standard timer frequency. To do so, it contains three counters:
tick, chrono_lo and chrono_hi.
Table 4. Charge Timekeeper Counters
Increment Condition
Period
Compared with
General
Eval Board
General
Eval Board
tick
Timer Zero IT
chrono_lo
tick = 0
chrono_hi
chrono_lo = 0
TTMZ
6.1 ms
256*TTMZ
1.6 s
Tfail
30 s
65536*TTMZ
6 min 43 s
Texp
2.5 h
The PWM is generated by the auto-reload timer because a high frequency is required. In addition, this significantly reduces the CPU load, allowing the core to stay in WAIT mode most of
the time. If no charge is under way on either slot, the PWM output is switched off in order to reduce consumption and increase A/D converter accuracy.
The analog to digital converter (ADC) is used intensively before each slot state update. In
most cases, the PWM output cannot be disabled, so ADC accuracy is not optimal. To reduce
errors, the ADC measures battery voltage and battery current 256 times in a row. The slot
state monitoring software works with the mean values. The 256 measurements are added into
a 16-bit word. The mean value is equal to the most significant byte of the word (rounded if the
least significant byte is greater than 128).
As explained in Section 2.2, battery voltage measurements must be corrected with battery
current measurements. These corrections require some arithmetical computing, performed on
the 16-bit words.
13/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
The core puts itself into WAIT mode during each conversion in order to gain accuracy. Precision is improved even more by using the ADC SYNC option bit.
2.4.3 State Diagrams
A slot can be in one of the ten states described in the Slot States Definitions table, where text
in italic is valid only for the rear slot.
Table 5. Slot States Definitions
Name
Meaning
IDLE
Slot empty
OR
Charge suspended by
front charge priority
CI
Constant current charge
CV_D
CV_U
Constant voltage charge,
duty cycle down
Constant voltage charge,
duty cycle up
FAST
Fast charge
TRI
Trickle charge
SAT
Battery saturated
EXP
Charge time expired
FAIL
Battery failure
HEAT
Charge suspended
by overheat
Output configuration
Front priority
request
Slot Outputs
PWM Duty Cycle
Charge disabled,
Both LEDs off
Unchanged
No
updated periodically to
have Ibat = Iconst
Incremented
periodically
Decremented
periodically
Updated periodically to
have IBAT = IFAST
Yes
Charge enabled,
Green LED off,
Red LED on
Charge disabled,
Green LED on,
Red LED off
No
Charge disabled,
Green LED off,
Red LED flashing
(toggled periodically)
Charge disabled,
Both LEDs on
Unchanged
Same as original
state
Note that this choice of states is only one solution - among many - of implementing the required behaviour of the charger.
Here, “periodically” means “at every state update”. Therefore, the state update frequency is
equal to the PWM duty cycle increase or decrease rate in the CI, CV_D, CV_U and FAST
states. In FAIL state, the red LED flashing frequency is half of the state update frequency.
The diagram of state transitions is too complex to be described by only one figure. Hence the
three figures in Figure 7. 't' stands for the timekeeper value. The rectangles represent actions
performed once during a state transition.
14/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
The rear slot state is updated after the front slot state. As a result, a front priority request depends on the updated value of front state.
Once the slot is in a given state, conditions to move to another state are not always incompatible. Therefore, priority rules must be defined:
1
(Highest priority) Transition related to battery presence
2
Front slot priority
3
Temperature
4
Time
5
Battery current
6
Battery voltage
Figure 7. State Diagram (1) - Charging
SAT
other slot not using the PWM
AND Vbat < Vtri
other slot using
the PWM
OR
Vbat > Vf
EXP
IDLE
t > Texp
battery detected
AND
front slot not
requesting priority
duty cycle ← 80%
t←0
t > Texp
t > Texp
PWM duty cycle ← 50%
t←0
TRI
t > Texp
t > Texp
CI
Vbat > Vf
Ibat < Isat
CV_D
Vbat < Vf
Vbat > Vf
CV_U
Vbat < Vfast
Vbat < Vfast
Vbat < Vfast
HEAT
FAIL
(Vbat < Vfail AND t > Tfail)
OR
Vbat < Vsc
FAST
Note: A slot is considered to be using the PWM if it is in a charging state (CI, CV_D, CV_U,
FAST or TRI) or if it is in HEAT state.
15/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
Figure 8. State Diagram (2) – Returning to IDLE State
SAT
IDLE
EXP
no battery
detected
TRI
front slot
priority
t
CI
CV_D
HEAT
FAIL
16/27
FAST
CV_U
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
Figure 9. State Diagram (3) – Heat State Transitions
SAT
EXP
IDLE
TRI
overheat
Original
state saved
HEAT
CI
no overheat
CV_D
CV_U
Original
state
FAIL
FAST
2.4.4 Slot Monitor Flowchart
In the software, slot states are updated by a subroutine called “slot monitor”. Using a subroutine is possible because the front and rear slot state diagrams are almost identical.
Slot state is stored in a one-byte variable, coded in a way that facilitates decoding the condition tree:
IDLE
HEAT
FAIL
EXP
SAT
TRI
FAST
CV_D
CI
CV_U
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
00000001b
10100000b
11000001b
11010001b
11011001b
11100001b
11110000b
11111000b
11111100b
11111110b
Decoding starts from the most significant bit. The least significant bit indicates front slot priority
request (1 = no request). When the slot enters HEAT state, this bit is modified to be the same
as in the original state. Bit b5 indicates if the slot is using the PWM (b5 = 1) or not (b5 = 0).
17/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
The flowchart, represented in Slot Monitor Flowchart (1), Slot Monitor Flowchart (2) and Slot
Monitor Flowchart (3), takes full advantage between transitions. For example, if the monitor
knows that slot state is either CI, CV_D or CV_U, it can check the expiration time before
switching to one of the three possibilities.
The order in which questions are asked (e.g. time before battery voltage) defines the priority
of the state transition.
On the flowcharts, b7, b6, etc. refer to the corresponding bit in the slot state variable.
18/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
Figure 10. Slot Monitor Flowchart (1)
Slot monitor
b7 ?
Battery
detected?
0
previously IDLE
No
Yes
Rear
slot?
Yes
Front priority
request?
Yes
still IDLE
1
No
Reset timekeeper
PWM duty cycle at 50%
No
previously not IDLE
Battery
detected?
No
CI now
IDLE now
Yes
b6 ?
0
Rear
slot?
previously HEAT
Yes
Front priority
request?
Yes
IDLE now
No
1
No
Overheat?
No
Back to
original state
Yes
s11
still HEAT
19/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
Figure 11. Slot Monitor Flowchart (2)
s11
previously FAIL
b5 ?
b4 ?
0
1
previously EXP
b3?
previously SAT
1
still FAIL
0
0
still EXP
Yes
Other slot
uses PWM?
1
Vbat < Vtri ?
No
Yes
still SAT
No
b4 ?
0
Other slot
uses PWM?
previously TRI
Yes
Reset
chronometer
Initilalise PWM
duty cycle at 80%
SAT now
TRI now
No
Overheat?
Yes
Store original state
Disable priority request
No
HEAT now
1
t > Texp ?
Yes
EXP now
Vbat > Vf
SAT now
No
Vbat ?
s1111
20/27
Vfast < Vbat < Vf
Vbat < Vfast
still TRI
FAST now
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
Figure 12. Slot Monitor Flowchart (3)
s1111
previously FAST, CV_D, CI or CV_U
Rear
slot?
Yes
Front priority
request?
Yes
IDLE now
No
Overheat?
No
Yes
Store original state
Enable priority request
No
HEAT now
t > Texp ?
Yes
EXP now
No
b3 ?
Yes
Vbat > Vfast ?
Yes
CI now
previously FAST No
Vbat < Vfail ?
No
Yes
Vbat < Vsc ?
Yes
No
t > Tfail ?
Yes
FAIL now
No
No
s11111
still FAST
21/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
Figure 13. Slot Monitor Flowchart (4)
s11111
b2 ?
Vbat < Vf ?
0
previously CV_D
1
No
still CV_D
previously CI or CV_U
Yes
FAST now
Yes
CV_D now
No
Vbat > Vf ?
No
b1 ?
1
still CV_U
22/27
previously CI
0
CV_U now
Yes
SAT now
No
Ibat < Isat ?
Vbat < Vfast ?
Yes
still CI
previously CV_U
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
2.4.5 Source File Organisation
Code is written in RIDE MAST6 assembly language. It consists of five files:
■
1 program file main.st6 (main routine, subroutines, interrupt service routines and interrupt
vector definitions);
■
1 variable definition file vars.st6
■
3 header files:
– IOs.inc (definitions of I/O configuration constants),
– vars.inc (declarations of variables),
– params.inc (definitions of application parameter constants).
This division makes it easier to perform minor modifications to the software, as shown in Table
6.Example of Minor Software Modifications.
Table 6. Example of Minor Software Modifications
If you want to change…
Voltage thresholds
PWM frequency
State update frequency
Timing thresholds
I/O configuration
State diagram
State definitions
Transition conditions
Transition priority
…only modify…
params.inc
IOs.inc
state constant definitions
and monitor subroutine
in main.st6
23/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
3 CONCLUSION: A LOW-COST FLEXIBLE SOLUTION
Everything on the evaluation board has been designed to make it easy to adapt in any way
(other type of battery, new behaviour specifications, additional design constraints, etc.).
■
The number of components needed for each slot (charging and feedback) is minimal, so
replacing them is inexpensive. Besides, the circuit has a simple and predictable behaviour.
This avoids costly and time-consuming trial-and-error procedures.
■
The system has an inner self-adaptation capability thanks to its many closed loop
regulations (voltage, current, temperature). For example, no software change is needed if
VSUPPY changes – provided VDD remains at 5 V.
■
As explained in Section 2.4, parameter modifications in the software are easy to perform.
■
The software only occupies a fourth of the total MCU program memory. Port C is not used
at all; neither is the SPI (nor the EEPROM on the ST6265C). Subsequently, many
improvements and/or new features can still be added without changing the MCU.
■
Analog inputs available on Port C can read the identification resistor included in the batteries
to determine their capacity and adapt the charging parameters accordingly.
■
The EEPROM can be used for ADC calibration.
24/27
1
2
3
1
2
3
Slot connector
1
2
3
4
NTC
Power Jack Socket 2.5 mm
CN1
DC Supply 6 V / 600 mA
t
A
Rid
Li-ion cell
470uF/16V
C1
Bat t er y
+
Vsupply
R23
430
B
PWM
R22
620
Q6
2N3904
VDD
E_REAR
R21
75 1/2W
Q5
2N3904
R20
270
Q4
2SA1011
R13
430
PWM
R12
620
Q3
2N3904
VDD
V1
TL431
E_FRONT
R11
75 1/2W
4R7
R1
Q2
2N3904
R10
270
Q1
2SA1011
1N4002
D1
B
1N5819
D4
L2
150uH/900mA
1N5819
D2
L1
150uH/900mA
+
+
D3
220uF/16V
C8
1N4001
D5
220uF/16V
R26
43K 1%
R25
10K 1%
R16
43K 1%
R15
10K 1%
100uF/10V
+ C2
1N4001
C7
R3
30K 1%
R2
30K 1%
VDD
R27
0.5 1%
R17
0.5 1%
1
2
3
4
1
2
3
4
C
Rear Slot
CN3
Front Slot
CN2
R8
560
VDD
sl ot
R28
4.3K 1%
VDD
R18
4.3K 1%
Fr ont
D7B
LED-GREEN
C
5
4
3
2
1
U2B
7
D
F_Temp 14
13
11
10
9
8
7
1
C3
0.1u
VDD
PWM
E_REAR
E_FRONT 6
R5
560
PA2/Ain
PA1/Ain
VSS
VDD
PC2/Sin/Ain
ST6255
Date:
A3
Size
Title
15
16
17
18
19
20
21
22
23
24
25
26
27
28
C4
22p
Monday, September 10, 2001
Document Number
Li-Ion Battery Charger Demo Board
C5 22p
X1
8MHz
R_Temp
Reference Desi gn
PA3/Ain
PA4/Ain
PA5/Ain
PA6/Ain
PA7/Ain
OSCin
OSCout
/RESET
NMI
PC4/Sck/Ain
PC3/Sout/Ain
PB7/ARTIMout
PA0/AN
PC0/Ain
PC1/TIM1/Ain
U1
PB6/ARTIMin
PB5
PB4
PB3
PB2
Vpp/TEST
PB1
PB0
D6A
LED-RED
st at us
12
R9 10K
R6
560
sl ot
D
U2A
VDD
LM358
R29
39K 1%
6 -
5 +
VDD
R_Temp
10K
R24
Rear
D6B
LED-GREEN
LM358
R19
39K 1%
2 -
3 +
VDD
F_Temp
10K
R14
R7
560
D7A
LED-RED
st at us
VDD
8
4
8
4
4
A
0.1u
E
C6
1
10K x 8
RN1
Sheet
VDD
E
of
VDD
1
1
Rev
reset sw
S1
R4
10K
1
2
3
4
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
4 APPENDIX
4.1 SCHEMATIC
25/27
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
4.2 BILL OF MATERIAL
Item
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
26/27
Quantity
1
1
1
1
1
1
2
2
2
1
2
2
2
2
1
2
2
4
1
1
1
1
2
4
4
2
2
2
2
2
2
2
2
2
1
1
1
1
1
Reference
BT1
CN1
CN2
CN3
C1
C2
C3,C6
C5,C4
C7,C8
D1
D2,D4
D3,D5
D6A,D7A
D6B,D7B
J4
L1,L2
Q1,Q4
Q2,Q3,Q5,Q6
RN1
RT1
Rid
R1
R2,R3
R4,R9,R14,R24
R5,R6,R7,R8
R10,R20
R11,R21
R12,R22
R23,R13
R15,R25
R16,R26
R17,R27
R18,R28
R19,R29
S1
U1
U2
V1
X1
Part
Li-ion cell
Power Jack Socket 2.5 mm
Front Slot
Rear Slot
470uF/16V
100uF/10V
0.1u
22p
220uF/16V
1N4002
1N5819
1N4001
LED-RED
LED-GREEN
Slot connector
150uH/900mA
2SA1011
2N3904
10K x 8
NTC
R
4R7
30K 1%
10K
560
270
75 1/2W
620
430
10K 1%
43K 1%
0.5 1%
4.3K 1%
39K 1%
reset sw
ST6255
LM358
TL431
8MHz
LOW-COST DOUBLE LI-ION BATTERY CHARGER USING ST6255C/ST6265C MCU
“THE PRESENT NOTE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH INFORMATION
REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS
SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO
ANY CLAIMS ARISING FROM THE CONTENT OF SUCH A NOTE AND/OR THE USE MADE BY CUSTOMERS OF
THE INFORMATION CONTAINED HEREIN IN CONNEXION WITH THEIR PRODUCTS.”
Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences
of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted
by implication or otherwise under any patent or patent rights of STMicroelectronics. Specifications mentioned in this publication are subject
to change without notice. This publication supersedes and replaces all information previously supplied. STMicroelectronics products are not
authorized for use as critical components in life support devices or systems without the express written approval of STMicroelectronics.
The ST logo is a registered trademark of STMicroelectronics
2001 STMicroelectronics - All Rights Reserved.
Purchase of I2C Components by STMicroelectronics conveys a license under the Philips I2C Patent. Rights to use these components in an
I2C system is granted provided that the system conforms to the I2C Standard Specification as defined by Philips.
STMicroelectronics Group of Companies
Australia - Brazil - Canada - China - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan
Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - U.S.A.
http://www.st.com
27/27
Similar pages