|
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
SOURCE CODE
In this section, Iýd like to talk about
some of the source code files for the battery charger reference design
(see Tables
2 and 3).
Also note that Iýve made the C source code and the assembly source
code available for downloading.
First, letýs take a look at BC.C.
This module contains the main function, the setup and UART functions,
real-time clock, and interrupt handling routines.
During the setup routine, all low-level
initialization is done. The UART is initialized and the real-time
clock is set to zero. After initialization, the program loops in idle
mode until the status is changed in the global status variable.
The real-time clock is started and stopped
when the PWM is started and stopped (i.e., when the battery voltage
is measured). This ensures that the only time taken into account is
when the battery is charged. On the other hand, the disadvantage is
that measurements, which rely on time (dV/dt or dT/dt), may be inaccurate.
You can cause an external interrupt by
pressing a button to change the charge status. During the interrupt
handling routine, the status is changed according to the button pressed,
either to fast-charge or trickle-charge. During the main function,
the program then calls a function depending on the value set in the
"charge status" variable (see
Figure 5).
BC.C also includes some common
functions used by the different battery programs. The two most important
are the int battery (unsigned char value) and the void
stable_ADC (void).
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. |