|
Part 2: Hardware and Software Implementation
by Thomas Richter
Start ý The
Buck Converter ý Voltage Reference and
Battery Temperature ý AT90S2333 Battery
Charger ý ATtiny15 Battery Charger
ý Charge Current ý Software
Implementation ý User Settings ý Source
Code ý INT Battery Function ý The
Stable_ADC Function ý BC.H ý B_DEF.H
ý Charge MethodýSLA.C ý Charge
MethodýNiCd.C and NiMH.C ý Charge MethodýLilon.C
ý Suggested Improvement ý Sources
and PDF
SOFTWARE IMPLEMENTATION
Now that Iýve explained most of the hardware,
itýs time to take a look at the software used in the battery charger
reference design and the explanation of the C code implementation
for the ý2333. The same principles also apply for the assembly code
for ATtiny15. For a complete description of the ATtiny15 assembly
code, see the comments in the source code (download
entire code package).
As long as the battery type to be charged
is set at program compile time, the software can be extended to support
charging more than one battery. The straightforward implementation
is to charge batteries sequentially, allowing each battery a time
slot during trickle-charge. SLA and Li-Ion batteries can be charged
in parallel with constant voltage charging if the number of battery
cells in each battery pack is the same. The charging current for each
battery is limited and the charging voltage is limited to one cell.
In "Battery Characteristics"
of b_car.h all values are calculated with all their scaling
factors. These values are defined in the include files, calculated
at compile time, and then handled as constants during program execution.
All values taken from the A/D converter can be compared directly to
these constants. This means that no time is spent recalculating values
during program execution, which saves time and memory space. The values
and formulas used to calculate the values can be found in Equations
4ý7 (Equations 13ý15 for the ATtiny15).
For NiCd batteries, the charge is started
if the battery temperature is within the temperature range. The charge
is always terminated with an error message if the temperature is higher
than the maximum temperature, if the voltage exceeds the maximum battery
voltage, or if the maximum fast-charge time expires.
The normal signs that the battery is
fully charged are temperature rise (dT/dt) and voltage drop (ýdV/dt)
methods. Therefore, a sample is taken every minute for the temperature
and every second for the voltage. The values are compared to the sample
taken 1 min./s ago. If the battery is fully charged, the charge status
is automatically changed to trickle-charge, causing the program to
jump into the trickle_charge() function.
The trickle_charge() function
executes in a loop, checking for a change of the charge status, temperature,
and voltage measurement and adjusting the current. If the temperature
is outside the valid range or a voltage overflow is detected, an error
flag is set and the function is terminated. If no error occurs and
you do not change the charge status, the program loops forever, adjusting
the charge current to the current defined at the top of the module.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ýCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |