Professional Documents
Culture Documents
Rev. xxxxA–10/99
1
The battery-charger reference design includes 2 battery solutions. Improved resolution allows charging to continue
chargers built with the high-end AT90S2333 microcontrol- closer to the maximum capacity of the battery. Improved
ler and the highly integrated low-cost 8-pin ATtiny15 resolution also eliminates the need for external Op-amps to
microcontroller, however, it can be implemented using any "window" the voltage. The result is reduced board space
AVR microcontroller with A/D converter, PWM output and and lower system cost.
enough program memory to store the desired charging AVR is the only 8-bit microcontroller designed for High
algorithm. Level Languages like "C". The reference design for 2333 is
written entirely in "C", demonstrating the superior simplicity
Introduction of software design in high level languages. "C" code makes
this reference design easy to adopt and modify for today's
As more and more electronic equipment becomes portable, and tomorrows batteries. The reference design for tiny15 is
the rush for better batteries with higher capacity, smaller written in assembly to achieve maximum code density.
size and lower weight will increase. The continuing
improvements in battery technology calls for more sophisti-
cated charging algorithms to ensure fast and secure Theory of Operation
charging. Higher accuracy monitoring of the charge pro- The charging of a battery is made possible by a reversible
cess is required to minimize charge time and utilize chemical reaction that restores energy in a chemical sys-
maximum capacity of the battery while avoiding battery tem. Depending on the chemicals used, the battery will
damage. AVR microcontrollers are one step ahead of com- have certain characteristics. When designing a charger, a
petition, proving perfect for the next generation of chargers detailed knowledge of these characteristics is required to
The Atmel AVR microcontroller is the most efficient 8-bit avoid damage inflicted by overcharging.
RISC microcontroller in the marked today that offers Flash,
EEPROM and 10 bits A/D converter in one chip. Flash pro- The AVR 8-bit RISC MCU
gram memory eliminates the need to stock microcontrollers
The reference designs includes two separate battery
with multiple software versions. Flash can be efficiently
chargers. One using 2333 AVR microcontroller, and one
programmed in production just before shipping the finished
using the tiny15 AVR microcontroller. The 2333 design
product. Programming after mounting is made possible
demonstrates how efficient a battery charger can be imple-
through fast In System Programming (ISP), allowing up-to-
mented with C-code. The tiny15 design shows the highest
date software and last minute modifications.
integrated and lowest cost battery charger available in
today’s marked. The 2333 can be used for voltage and
EEPROM data memory can be used for storing calibration temperature monitoring with UART interface to PC for data
data and battery characteristics, it also allows charging his- logging. The table below shows the differences in the
tory to be permanently recorded, allowing the charger to design:
optimize for improved battery capacity. The integrated 10-
bit A/D converter gives superior resolution for the battery
measurements compared to other microcontroller-based
Table 1.
AT90S2333 design ATtiny15 design
Programming language C Assembly
Code size(approx) 1.5 Kbytes <350bytes
Current measurement External Op-Amp gain stage Built-in differential gain stage
PWM frequency 14Khz, 8 bit resolution 100 Khz, 8 bit resolution
Clock Source External crystal, 7.3Mhz Internal calibrated RC osc, 1.6Mhz
Serial comm. interface Yes No
In-System Programming Yes Yes
2 AVR450
AVR450
• Nickel Cadmium (NiCd) current limit set by the manufacturer. The battery takes
• Nickel Metal Hydride (NiMH) damage from overcharging and may explode when
overcharged.
• Lithium-Ion (Li-Ion)
It is important to have some background information on
these batteries to be able to select the right battery and
Safe Charging of Batteries
charging algorithm for the application. Modern fast chargers (i.e. battery fully charged in less than
3 hours, normally 1 hour) requires accurate measurements
Sealed Lead Acid (SLA) of the cell voltage, charging current and battery tempera-
Sealed Lead Acid batteries are used in many applications ture in order to fully charge the battery completely without
where cost is more important than space and weight, typi- overcharging or otherwise damage it.
cally preferred as backup batteries for UPS and alarm-
systems. SLA batteries are charged using constant volt- Charge Methods
age, with a current limiter to avoid overheating in the initial SLA and Li-Ion batteries are charged with constant voltage
stage of the charging process. SLA batteries can be (current limited) NiCd and NiMH batteries are charged with
charged infinitely, as long at the cell voltage never exceeds constant current and have a set of different termination
the manufacturer specifications (typically 2.2V). methods.
3
t - Time top-off charge phase usually following the fast charge
This is one of the simplest ways to measure when to termi- phase.
nate the charging. Normally used as backup termination
when fast charging. Also used as primary termination T - Temperature
method in normal charging (14-16h). Applies to all Absolute temperature can be used as termination (for NiCd
batteries. and NiMH batteries), but is preferred as backup termination
method only. Charging of all batteries should be terminated
V - Voltage if the temperature rises above the operating temperature
Charging is terminated when the voltage rises above a pre- limit set by the manufacturer. Also used as a backup
set upper limit. Used in combination with constant current method to abort charging if voltage drops below a safe tem-
charging. Maximum current is determined by the battery, perature. Applies to all batteries.
usually 1C as described above. Current limiting is crucial to
avoid thermal damage to the battery if charge current is too dT/dt - Temperature Rise
high. SLA batteries are normally charged infinitely by set- The derivative of temperature over time can be used as ter-
ting the maximum voltage above the actual charge voltage. mination method when fast charging. Refer to the
Used for Li-Ion as primary charging algorithm/termination manufacturer's specifications on information on the exact
method. Li-Ion chargers usually continue with a second termination point (Typically 1°C/min for NiCd batteries).
phase after the maximum voltage has been reached to Applies to NiCd and NiMH.
safely charge the battery to 100%. Also used on NiCd and
NiMH as backup termination. DT - Temperature over Ambient Temperature
Terminates charging when the difference between ambient
-dV/dt - Voltage Drop (room) temperature and battery temperature rises over a
This termination method utilizes the negative derivative of preset threshold level. Applies to NiCd and SLA as primary
voltage over time, monitoring the voltage drop occurring in or backup termination method. Preferred over absolute
some battery types if charging is continued after the battery temperature to avoid battery damage when charged in a
is fully charged. Commonly used with constant current cold environment. As most systems have only one temper-
charging. Applies to fast charging of NiCd and NiMH ature probe available, the ambient temperature is usually
batteries. measured before charging is initiated.
4 AVR450
AVR450
Hardware Implementation
The reference design includes two complete battery charger designs. The reference design is divided in 5 main blocks:
Tiny15 Battery
charger
2333 Battery
charger
Power supply
5
ATtiny15 with 100Khz buck converter include fast-charge mode and a top-off trickle charge to
Tiny15 includes special features to make it specially suited gain minimum charge time with maximum battery capacity.
for battery charger applications. The internal 100Khz PWM Power supply for the battery charger is shown in appendix
is connected to a buck converter. The high switching fre- 2.
quency and high accuracy reduce the size of the external
coil and capacitors. Testpoints are added to easily monitor Buck Converter
the PWM output, voltage input, and current input. The The buck-converter is similar for both the AT90S2333 and
tiny15 includes a internal gain stage that can amplify the the ATtiny15. They consist of one P-channel MOSFET
differential voltage between two A/D channels. This elimi- switching transistor driven by the AVR via one bipolar NPN
nates the need for external Op-Amps. The charge current transistor. The switching transistor is connected to an
is measured as the differential between two A/D channels inductor, a diode and a capacitor (see Figure 3). An adi-
over a 0.25 Ω resistor tional diode prevents the battery from supplying voltage
Power supply for the battery charger is shown in appendix into the microcontroller when the power is disconnected.
2. When the switching transistor is on (illustrated by a switch
on the figures below) the current will flow like Figure 3a
AT90S2333 with 14Khz buck converter illustrates. The capacitor is charged from the input via the
The 90S2333 battery charger design use an external Op- inductor (the inductor is also charged up). When the switch
Amps to amplify the voltage for the current measurement. is opened (Figure 3b) the inductor will try to maintain its
This ensures the highest accuracy for the battery measure- current-flow by inducing a voltage. The current flows
ment. The charger is capable of communicating with a PC, through the diode and the inductor will charge the capaci-
which can be used to monitor charging parameters and to tor. Then the cycle repeats itself. If the duty cycle is
debug the charging algorithm. decreased, by shorter on time, longer off time, the voltage
will decrease. If the duty cycle is increased (longer on
The battery charger circuit was designed to charge any of
timer, shorter off time) the voltage will increase. The buck-
the four battery types SLA, NiCd, NiMH, and Li-Ion with the
converter is most efficient running on a duty cycle of 50%.
appropriate charge algorithm. These charge algorithms
6 AVR450
AVR450
The steps can be calculated by the following equation: The table indicates the steps equal to 0.5°C for ADC values
400 to 675. ADC value 400 is approximately 37°C and 675
RNTC
N = 1024⋅ is 8.6°C. Using this table and doing some minor changes in
RNTC + 10kΩ the header file B_DEF.H will make it easy to implement any
NTC resistor. The tiny15 battery charger design assumes
The NTC resistance does not follow a linear curve, which that the linearity of the thermistor is sufficient to detect a
makes it difficult to calculate the temperature from the ADC temperature increase. Therefore it uses a constant com-
value. Using a table to look up the temperature solves this. pare value to monitor the temperature.
7
AT90S2333 Battery Charger .
This chapter describes theory specific for the battery
*(V 1− V 2)
Ra
charger design based on 2333. VBAT 2 =
Rb
Parameters for layout:
Where:
Oscillator frequency: fOSC = 7.3728 MHz • VBAT2 is the output voltage from the op-amp to the AVR
Saturation voltage: Vsat = 0.5V A/D.
Input voltage: VI = 15V • V1 is the positive pole of the battery.
Output Voltage: VO = 1.5V • V2 is the negative pole of the battery.
Maximum output current: IO,max = 1.5A • Ra and Rb are the resistors in the resistor network used
8-bit PWM: to set the gain for the op-amp.
• Ra is equal to R10 and R12
510
T= = 69.199µs • Rb is equal to R6 and R7
fOSC
With duty cycle of 50%: The maximum charge voltage will be:
69.199µs
ton = = 34.60µs Rb 33K Ω
2 (V 1− V 2)= * AREF = *3.67 = 12.1V
Ra 10K Ω
Inductance:
Gain in op-amp:
(V − V − V )t (15V − 0.5V − 1.5V )34.60µs = 149.9µH
L = I sat 0 on =
2Io,max 2⋅1.5A
Ra 10K Ω
G U 1B = = = 0.303
Rb 33K Ω
L ⋅ 2⋅ IO max 150µH ⋅ 3A
ton = = = 33.83µs The resulting battery measurement resolution:
VI − Vsat− VO 15V − 0.2V − 1.5V
This gives a duty cycle of
ADCresolut ion 3.58mV mV
= = 11.82
ton 33.83µs G U 1B 0.303 step
= = 0.489= 48,9 %
T 69.199µs
Charge Current
2333 Measurement Circuitry
The charge current is measured by sensing the voltage
Battery Voltage over a 0.033Ω shunt-resistor(R1). This voltage is amplified
using an op-amp to improve the accuracy of the measure-
The charging voltage is monitored using an op-amp to
ment before it is fed into the A/D converter.
measure the voltage difference between the positive and
the negative pole of the battery. In order to select a suitable This voltage is amplified by the factor:
measurement range for the charger, decide how many bat-
R5 39kΩ
tery cells and what type of batteries to charge, select a 1+ = 1+ = 58.4
suitable input voltage (V1-V2) and scale resistors for the R2 680Ω
voltage measurement. The op-amp circuit for measuring
the battery voltage is an ordinary differential op-amp circuit. The OP-AMP output voltage is therefore:
The equation for the output voltage from the op-amp circuit
is shown below. The ADC is capable of measuring the volt- R
VIbat2 = 1+ 5 ⋅ IShunt⋅ R6
age range from AGND to AREF (3.67V). The output
voltage (VBAT2) from the op-amp has to be within this range
R2
8 AVR450
AVR450
which is: The step number for a given current can now be calculated
from:
VIbat2 = 1.926⋅ IShun
mA
The maximum current that can be measured is:
IShunt= N ⋅ 1.95
step
3.58
IBATmax = = 2.0A The current from a certain step number is:
1.926
IShunt
This gives a resolution of: N =
mA
1.95
2000mA mA step
= 1.95
1024steps step
9
ATtiny15 Battery Charger differential measurement of the battery charge current as
shown in Figure 4. The current is measured as the differ-
This chapter describes theory specific for the battery
ence between the negative and positive input to the internal
charger design based on tiny15. The 25.6Mhz oscillator
20x gain stage. This voltage is measured over a 0.25Ω
frequency is generated with an on-chip PLL from an
shunt resistor
1.6Mhz internal RC-oscillator. The reference design is
shipped without resistors for dividing down the voltage of
Figure 4. Voltage and current measurement
the battery. This limits the maximum voltage to 3.67V, mak-
ing it suitable for 1-2 cells NiCd or NiMh batteries. To use Tiny15
higher voltages, simply add the required resistors to divide
down the voltage into the 0-3.67V range. calculation of the Ibat
resistors are described at the end of this chapter.
20x
gain Sense
Parameters for layout: stage resistor
Oscillator frequency: fOSC = 25.6MHz A D C2
255
T= = 9.96µ S All measurements are done with 10-bit (1024 steps)
fOSC resolution.
The voltage resolution is decided by AREF
With duty cycle of 50%:
Resolution:
9.96µ s
ton = = 4.43µ S 3.67V mV
2 = 3.58
1024steps step
Inductance:
L=
(VI − Vsat− V0 )ton = (15V − 0.5V − 1.5V )4.43µs = 21.1µH In order to select a suitable measurement range for the
charger, decide how many battery cells and what type of
2Io,max 2 ⋅ 1.5A
batteries to charge. The ADC is capable of measuring the
voltage range from AGND to AREF (3.67V). The output
voltage (VADC) from the op-amp has to be within this
L ⋅ 2 ⋅ IO max 22µH ⋅ 3A range.
ton = = = 4.88µS
V I − V sat − VO 15V − 0.5V − 1.5V
*(Vb)
Rb
V ADC =
This gives a duty cycle of
Ra + Rb
Where:
ton 4.88µ s
= = 0.449 = 44.9 % • VADC is the output voltage from the op-amp to the AVR
T 9.96µ s A/D.
• Vb is the battery voltage.
tiny15 Measurement Circuitry • Ra and Rb are the resistors used to scale down the
battery voltage.
Battery Voltage • Ra is equal to R8.
The charge voltage is measured directly on the positive • Rb is equal to R16
battery pole. When a voltage higher than the reference volt- Note that the resistors R9 and R17 for scaling down the
age (3.67V) is used to charge the battery, the charging voltage of the shunt resistors must be equal to R8 and R16
voltage can be divided down with two resistors to fit into the for scaling down the voltage measurement. The reference
0-3.67V area. This input is also the negative input for the
10 AVR450
AVR450
11
Software Implementation status is automatically changed to trickle charge, causing
the program to jump into the trickle_charge() function.
This chapter describes the software used in the battery
The trickle_charge() function executes in a loop of check-
charger reference design, it explains the C-code implemen-
ing for a change of the charge status, temperature and
tation for 2333. The same principles also applies for the
voltage measurement and adjusting the current. In case
assembly code for tiny15. For complete description of the
the temperature is outside the valid range or a voltage
tiny15 assembly code, see the comments in the source
overflow is detected the error flag is set and the function is
code.
terminated. If no error occurs and charge status is not
The battery type to be charged has to be set at program changed by the user the program loops forever, adjusting
compile time. the charge current to the current defined at the top of this
The software can be extended to support charging of more module.
than one battery. The straightforward implementation is to
charge batteries sequentially allowing each battery a User Settings
timeslot during trickle charge. SLA and Li-Ion batteries can
be charged in parallel with constant voltage charging if the The charger is built as a multipurpose charger that can
number of battery cells in each battery-pack is the same. charge four types of batteries and a various number of cells
The charging current for each battery is limited and the by changing parameters before compiling the code. It is
charging voltage is limited as for one cell. very important that this is done properly before compiling or
it can damage the battery and the surroundings.
In the "Battery Characteristics" (b_car.h) all values are cal-
culated with all their scaling factors. These values are
Change Battery Type
defined in the include files, calculated at compile time and
then handled as constants during program execution. All There is a C-file and an h-file for each battery type.
values taken from the A/D converter can directly be com- Include the desired battery files in the compiler before
pared to these constants. This means that no time is used compiling and "uncomment" the battery type under
on recalculating values during program execution, saving "Battery Type" in B_Def.h.
time and memory space. The values and formulas used to
calculate the values are extracted from the "Measurement Change Number of Cells
Circuitry chapter". See “2333 Measurement Circuitry” on Change parameter "cells" in B_Def.h
page 8 and “tiny15 Measurement Circuitry” on page 10.
For NiCd battery, charge is started if the battery tempera- Change Cell Capacity
ture is within the temperature range. Charge is always Change parameter "capacity" in B_Def.h
terminated with an error message if the temperature is
higher than the maximum temperature, if the voltage Change Li-Ion Cell Voltage
exceeds the maximum battery voltage or if the maximum Change parameter "cell_voltage" in B_Def.h
fast charge time expires.
The normal ways to detect that the battery is fully charged, Change ADC Step Size
are the Temperature Rise (dT/dt) and the Voltage Drop (- After changing the resistor values as described in the
dV/dt) methods. Therefore a sample is taken every minute
Measurement chapter the parameters "voltage_step"
for the temperature and every second of the voltage. The
and "current_step" must be changed in B_Def.h. This
values are compared to the sample taken one minute/sec-
is very important and may damage the charger if not
ond ago. In case the battery is fully charged the charge
done properly.
12 AVR450
AVR450
The code size applies for version 1.0 of the code. Compiled
with IAR compiler v1.41C, maximum size optimization.
13
BC.C Figure 1. The Main() Function
This module contains the main function, the setup and the
UART functions, the real-time clock and the interrupt han-
dling routines.
In the "setup" routine all low-level initialization are done.
The UART is initialized and the real-time clock set to zero.
After the initialization the program loops in idle mode until
the status is changed in the global status variable.
The real-time clock is started when the PWM is started,
and is also stopped when the PWM is stopped, i.e. when
the battery voltage is measured. This ensures that only the
time when the battery is charged is taken into account. On
the other hand this method has the disadvantage that mea-
surements that rely on time (dV/dt or dT/dt) may be
inaccurate.
The user can cause an external interrupt by pressing a but-
ton to change the charge status. In the interrupt handling
routine the status is changed according to the button
pressed, either to "fast charge" or to "trickle charge". In the
main function the program then calls a function depending
on the value set in the "charge status" variable.
BC.C also includes some common functions used by the
different battery programs. The two most important are on
the following
14 AVR450
AVR450
Measurement
type?
ADMUX =
ADMUX = "volt"
"temperature"
stable_ADC stable_ADC
av = 0
i =0
i <=7?
yes
Start ADC
yes
no
no ADC done?
av = av +ADC
av = av/8
PWM on?
no yes
PWM on
return(av)
15
void stable_ADC(void) case of a charge error where the error was detected and
The stable_ADC function is used when measuring battery can be used for program debugging.
voltage or temperature. It makes sure the ADC values are
stable inside a defined area. This is important for an accu- B_DEF.H
rate measurement. The function loops until it gets three This module defines the battery to be charged. When a
ADC values where the highest is no more than one step customer designs a battery charger using the given circuit
higher than the lowest. and program code, this file has to be changed to meet the
needs.
Figure 3. The stable_ADC() function
The battery type defines the charging and termination algo-
stable_ADC rithm. If more than one battery type is chosen an error will
occur during linking the program, as all functions with the
same functions for different battery types have the same
V[0] > V[1]+1
names battery(), fast_charge() and trickle_charge(). An
error message will also occur if no battery type is chosen.
Yes
The cell number determines the voltage of the battery pack
and all related constants. It is assumed that all cells are in
V[5] = V[4]
V[4] = V[3] series. Zero cells are not very reasonable but will only
V[3] = V[2] result in zero charge current. The voltage range of the buck
converter and the voltage measurement circuit sets the
Start ADC upper limit.
The capacity (in mA) defines the charge current and all
no
related constants.
ADC done?
no All battery types except SLA, are fast-charged in a "conser-
vative" way at 1C. SLA is charged with 2C. This sets the
Yes
limit for the battery capacity. The buck converter is calcu-
V[2] = ADC
lated to supply a maximum current of 1.5A. The maximum
capacity for SLA is 750mAh, for the other battery types
V[1] = highest value of 1500mAh. If a higher charge current for NiCd or NiMH is
V[2] to V[5]
V[0] = lowest value of required, the buck converter layout has to be changed. In
V[2] to V[5]
case of a current higher than 2A the current measurement
circuit also need some modifications. If batteries with a
higher capacity than calculated above should be charged it
is possible to change the buck converter or to reduce
return charge current.
For the Li-Ion battery type, two cell voltages exist, depend-
ing on the battery manufacturer. This voltage, 4.1V or 4.2V,
must be edited. It will be included automatically if the Li-Ion
BC.H definition is chosen. Stating a wrong voltage in this place
In this module the bit handling macros, the charge status will not necessarily result in an error message, but will lead
and the termination bit mask constants are defined. to incorrect charge methods, which can damage the battery
and the battery charger.
The "charge status" indicates the actual status of the bat-
tery charger; fast charging, trickle charging or if an error The ADC step parameters are to be edited according to the
has occurred. For Li-Ion and SLA battery types an indica- resistors used in the measurement circuitry. This is
tion on the charge mode, constant voltage or constant described under measurement circuits.
current is included as well as if Li-Ion is in the final stage of The NTC table defines the ADC step value. A step value
its fast charge mode (called "delay"). The "termination" indi- indicates 0.5°C change in the temperature. This look-up
cates the reason why fast charge mode terminated or in table is used in NiCd charging. The table may be edited if
the NTC is different from the used in this description.
16 AVR450
AVR450
17
Figure 5. The fast_charge() function for SLA, part 1(2) Figure 6. The fast_charge() function for SLA, part 2(2)
NiCd.C
Charge Method
NiCd battery types are charged with a constant current. In
fast-charge mode this current is here set to 1C. In trickle
charge mode it is C/40. The charging is terminated by the
Voltage Drop (-dV/dt) method. Maximum charge voltage,
Temperature Rise (dT/dt), and maximum charge time are
used as backup terminations.
In case the battery is fully charged the charge status is
automatically changed to trickle charge, causing the pro-
gram to jump into the trickle_charge() function.
18 AVR450
AVR450
Absolute maximum temperature T = 40 °C Figure 8. The fast_charge() function for NiCd, part 1(2)
Absolute maximum Charge Voltage V = cells * 1500
mV
Fast charge termination:
Voltage Drop Threshold -dV/dt = 20 mV/min per cell
Temperature Rise Threshold dT/dt = 1 °C per minute
Fast charge error:
Minimum fast charge temperature T= 15 °C
Maximum fast charge time t = 90min at 1C current
19
Figure 9. The fast_charge() function for NiCd, part 2(2) NiMH.C
Charge Method
NiMH battery types are charged with a constant current. In
fast-charge mode this current is here set to 1C. In trickle
charge mode it is C/40.
The charging is terminated by the Temperature Rise
(dT/dt) and the Voltage Drop (-dV/dt) methods. Maximum
charge voltage and maximum charge time are used as
backup terminations.
In case the battery is fully charged the charge status is
automatically changed to trickle charge, causing the pro-
gram to jump into the trickle_charge() function.
20 AVR450
AVR450
Figure 10. The trickle_charge() function for NiMH Figure 11. The fast_charge() function for NiMH, part 1(2)
NiMH_trickle NiMH_fast_1
set last_min_T
YES
NO T
within limits
?
NO T
within limits
? YES
YES
NO V
< max_V
?
NO V
< max_V
? YES
YES
NO T
> min_T_fast
calculate finish_time ?
YES
green LED blinking
calculate fast_finish_time
green LED on
time NO
overflow
? NO status = fast
and no error
?
YES
YES
NO time
END overflow
?
A B
21
Figure 12. The fast_charge() function for NiMH, part 2(2) LiIon.C
Charge Method
Li-Ion batteries are the most advanced battery types to
charge. Fast charge starts at a constant current of 1C. This
current is kept constant until a cell voltage level of 4.1 or
4.2 V ±50 mV is set. Then the battery is charged with con-
stant voltage until the current drops below Imin.
For an accurate measurement of the battery voltage (and
not the charge voltage) the PWM is turned off during volt-
age measurements. If the charge method then changes
from "constant current" to "constant voltage", the charge
voltage is the relevant parameter to be measured. This is
the reason why there are two voltage measurement
modes, one with "PWM turnoff" and one without.
Trickle charge of Li-Ion batteries is in principle the same as
fast charge. The current is much lower than in fast charge
mode and the constant voltage phase of the trickle charge
mode is simply terminated by a timer.
22 AVR450
AVR450
Figure 13. The trickle_charge() function for Li-Ion Figure 14. The fast_charge() function for Li-Ion, part 1(2)
23
Figure 15. The fast_charge() function for Li-Ion, part 2(2) Suggested Improvements
B C A LiIon_fast_2 D
NiCd batteries suffer from "Memory Effect" - after charging
the battery several times it will not charge completely. To
reset the "memory", a shunt resistor can be added, allow-
NO
status = const_V
?
ing the MCU to completely discharge the battery prior to
charging.
YES
regulate voltage
YES time
overflow
?
stop PWM
and flag error
NO
YES
temperature
overflow
?
stop PWM
and flag error
NO
NO 60 sec. over
?
YES
YES
calculate fast_finish_time
status = delay
delay time NO
over
?
YES
stop PWM
status = const_C
status = trickle
END
24 AVR450
25
AVR450
Powersupply, Switches, LED and Analog referance AT90S2333 and 14kHz Buck converter
BC2_PSU.SCH BC2_14K.SCH
VIN VIN
VCC VCC
AVCC AVCC
AREF AREF
LED0 LED0
LED1 LED1
LED2 LED2
LED3 LED3
SWITCH0 SWITCH0
SWITCH1 SWITCH1
SWITCH2 SWITCH2
SWITCH3 SWITCH3
AGND
GND
ATtiny15 and 100kHz buck converter
BC2_100k.SCH
VIN
VCC
AREF
Figure 16. Block diagram of main blocks
Appendix 1: Schematic
AGND AGND
GND GND
TP14 Powersupply VCC
VIN Testpoint TP3, TP4, TP10, TP11, LED's and switches
I<=3A
VIN TP19 and TP20 have no marking LED0
1
TP10 LED0
in the silkscreen. They are placed
1
1
R25
close to their respective resistors LED0
11
U6 VCC 330R
L78M05ABDT TP1
making it easy to (if desired) cut LED1 GREEN
D9 D10 1 3 the track and patch the LED to an TP11 LED1
LSM345 LSM345 Vin +5V 1
1
VCC
other function. R21
J3 11
GND
LED1
1 330R
RED
1
2 LED2
3 TP19 LED2
1
C13 C5 LED7
2
100uF/25V R22
1
100nF RED 11
DC_JACK_2_1MM LED2
330R
LED3 YELLOW
Vin 9-15V DC TP20 LED3
1
9-12V AC D11 D12 R35
LSM345 LSM345 330R R23 11
LED3
TP2 330R
LED4 GREEN
1
TP3 LED4
1
GND
LED4 R41 11
GND 330R
LED5 GREEN
TP4 LED5
1
LED5 R42
11
330R
GREEN
R26
4
1
Figure 17. Power supply and reference voltage schematic
SWITCH0
1k
S1
1
GND
R27
4
1
SWITCH1
1k
S2
AVR450
2
1
Analog voltage reference GND
R28
4
1
SWITCH2
1k
Vcc S3
1
R24
AREF 1k GND
R29
4
AREF 1
SWITCH3
1k
1
TP13 S4
1
Vcc
1
R34 AREF
1
4k7
1
C11 R15 D13
10K BAS16 GND
2 U5 100nF
1
TL431
4
RESET
3
C14 S5
R14 47nF RESET
10k TP15
1
1
1
AGND AGND GND
1
GND
26
27
Vcc
Buck-converter 100kHz
LED6
RED 22uH/CDRH127-220
VIN
1
2
3
8
7
6
5
1
1
L2 D2
AVR450
1
R32
1
R4 LSM345
330R 680R D4 +
LSM345 C12 C3
TP6 Q3 100uF/25v 100nF
1
PWM1 SI4425DY
4
GND GND GND
1
U3 ATTINY15
RESET 1 2 R19 1 Q1
RESET RESET/PB5 ADC3/PB4 IBAT1 PWM1
1
AREF 5 3 BC847C
AREF PB0/MOSI/AREF ADC2/PB3 VBAT1 1k
VCC 7 R30
C4 PB2/ADC1/SCK TBAT1
1
8 10k R9
100nF C6 VCC 0(33k)
TP9
IBAT1
GND 100nF 4 6 R18
1
GND PB1/MISO/OCP PWM1
1
GND GND 0R25/CC2520FC
1
R36 IBAT1
1
Vcc AREF
1
0R
GND AGND Vcc
JP1 R17
1 2 10k(not mounted)
MOSI VCC
3 4 R13
LED GND
5 6 10K
RESET GND R37 R38
7 8
1
SCK GND 4k7 4k7
9 10 AGND
1
MISO GND TBAT1
TP12 R8
ISP GND VBAT1 0k (33k/0.1%)
3
SCL B1
1
1
BATTERY
SDA
SMBus
1
VBAT1
-T
SDA
R16
SCL
10k/0.1%(Not mounted)
NOTE: Use Either R37 and R38 or
R8,R9,R16 and R17. (R37 and R38 for
5
1
SMBus and R8,R9,R16 and R17 for
voltage and current measurement using
the ATtiny15 AGND GND
Using both will not work in either case.
R8 and R9 are shipped with 0ohm
Figure 18. Tin15 and 100Khz buck converter schematic
2 3 4 5 6
Buck-converter 14kHz
Vcc
VIN L1
1
2
3
8
7
6
5
1
1
150uH
D1
R39 R40
1
R3 LSM345
4k7 4k7 680R D3 +
LSM345 C1 C2
U4 AT90S2333-PC TP16 TP17 TP18 TP5 1000uF/25v 100nF
1
SDA 4 28 PC3 PC4 PC5 PWM2 Q4
1
4
PD2/INT0 ADC5/PC5 VBAT2 SI4425DY GND
SCL 5 27 GND GND
PD3/INT1 ADC4/PC4 IBAT2
1
1
6 26 Q2
SWITCH0 PD4/T0 ADC3/PC3 TBAT2 R20
11 25 1 BC847C AREF
SWITCH1 PD5/T1 ADC2/PC2 PWM2 U1B
12 24
SWITCH2 PD6/AIN0 ADC1/PC1 1k R6
13 23 R31 5 1
SWITCH3 PD7/AIN1 ADC0/PC0 10k
AREF 7
33k
1
14 TP7 6 R11
LED0 PB0/ICP
16 21 VBAT2 10K
LED1 PB2/SS AREF C22
17 AVCC L4 VCC LM358
1
LED2 PB3/MOSI
1
1
31
LED3 PB4/MISO AVCC TBAT2
1
19 BLM-21-xxx 10k
PB5/SCK C9 VBAT2
AGND
3 100nF
SMBus
1
TxD PD1/TXD R33
2 22 1 R12 10k AGND B2
RxD PD0/RXD AGND
0R 1 BATTERY -T
SDA
SCL
RESET 1 15 AGND GND
RESET RESET OC1/PB1 PWM2
VCC AVCC
R7
1
1
7 9 1
VCC XTAL1
C8 8 10 TP8
5
GND XTAL2 33k
8
1 X1 IBAT2 C24
100nF 100nF U1A
1
JP2 VCC 7M3728Hz 3
GND 1 2 1 X2 AGND 1
MOSI VCC IBAT2
1
1
3 4 2 R1
LED GND R033/CC2520FC
5 6 7M3728Hz
RESET GND
7 8 C15 C16 LM358
SCK GND
9 10 22pF 22pF
4
MISO GND
1
ISP GND GND GND
AGND
1 R5 R2 1
39k 680R
GND
Figure 19. 2333 and 14Khz buck converter schematic
AVR450
1
1
C20 C23
1
100nF 100nF U7
16 1 TP21
VCC C1+ C18
J1 GND TXD
1 2 3 100nF
V+ C1-
1
6 RS232 TTL
2 14 T1 11
TxD
7
3 13 R1 12
RxD
8
4 7 10
1
T2
9
5 8 R2 9 TP22
RXD
1
DB9 GND 6 4
V- C2+
C19 15 5 C17
GND C2- 100nF
100nF
MAX202CSE
GND GND
28
AVR450
Appendix 2: Power Supply The power supply unit for the battery charger is built
around a TOP224 from Power Integration. The flyback
The schematic below shows a power supply that supplies design technique makes a compact and efficient power
both +15V for the battery-charger and +5V for the AVR supply design. The input voltage may vary from 85 VAC to
microcontroller. 265 VAC (50-60 Hz).
1
1 1
V15P
D304 + +
PBYR1645 C307 C310
T301
1000uF/35V 100uF/35V
Phillips EFD20 **
5 6 GND GND
1
1
1
BZW04-188 D305
1
1
4 2 PBYR1645 + +
2 C308 C311
1
N D303
Mains in 39mH 10 U302
BYV26C GND 1000uF/35V R303 R304 R305 100uF/35V
2 41 1
1
85-265v AC
1
C305 PC817
1
1 R302
3
100
U301
100nF
1
1
Control
+
1
C306
TOP224 R301
1
1 47uF
2
1
6R2
C309
U303
C304 2 100nF
1n0
Y1* TL431 R306
10k
3
GND
1
GND
* Two series connected, 2.2nF, Y2-capacitors can replace C24
** Pins 4,8 and 9 on T1 are not connected
29
Table 5. Power Supply Part List (Continued)
Part Part Type Description
L303 3,3uH Post LC filter
L301 33mH Input choke
The transformer T301 is built around an EFD20 transformer kernel from Philips. The primary winding and the bias winding
use AWG26 (0.40mm) wire gauge. The secondary winding uses AWG20 (0.80mm). The primary winding and the bias
windings are separated from the two secondary windings with insulation tape. The 5V secondary winding is also a part of
the 15V winding. It is very important to make the windings according to the directions shown in the schematic.
30 AVR450
AVR450
Appendix 4: References
31
32 AVR450
Atmel Headquarters Atmel Operations
Corporate Headquarters Atmel Colorado Springs
2325 Orchard Parkway 1150 E. Cheyenne Mtn. Blvd.
San Jose, CA 95131 Colorado Springs, CO 80906
TEL (408) 441-0311 TEL (719) 576-3300
FAX (408) 487-2600 FAX (719) 540-1759
Europe Atmel Rousset
Atmel U.K., Ltd. Zone Industrielle
Coliseum Business Centre 13106 Rousset Cedex, France
Riverside Way TEL (33) 4 42 53 60 00
Camberley, Surrey GU15 3YL FAX (33) 4 42 53 60 01
England
TEL (44) 1276-686677
FAX (44) 1276-686697
Asia
Atmel Asia, Ltd.
Room 1219
Chinachem Golden Plaza
77 Mody Road
Tsimshatsui East
Kowloon, Hong Kong
TEL (852) 27219778
FAX (852) 27221369
Japan
Atmel Japan K.K.
Tonetsu Shinkawa Bldg., 9F
1-24-8 Shinkawa
Chuo-ku, Tokyo 104-0033
Japan
TEL (81) 3-3523-3551
FAX (81) 3-3523-7581
Fax-on-Demand
North America:
1-(800) 292-8635
International:
1-(408) 441-0732
e-mail
literature@atmel.com
Web Site
http://www.atmel.com
BBS
1-(408) 436-4309