|
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
THE BUCK CONVERTER
The ýtiny15 includes special features
to make it specially suited for battery-charger applications. First,
the internal 100-kHz PWM is connected to a buck converter. The high
switching frequency and accuracy reduce the size of the external coil
and capacitors, and test points were added to easily monitor the PWM
output, voltage input, and current input.
The ATtiny15 also includes an internal
gain stage that can amplify the differential voltage between two A/D
channels. This eliminates the need for external op-amps. The charge
current is measured as the differential between two A/D channels over
a 0.25-ohm resistor.
To ensure the highest accuracy, the AT90S2333
battery charger design uses an external op-amp to amplify the voltage
for the current measurement. The charger is capable of communicating
with a PC, which then can be used to monitor charging parameters and
debug the charging algorithm.
The battery charger circuit was designed
to charge any of the four battery types (SLA, NiCd, NiMH, and Li-Ion)
with the appropriate charge algorithm. These charge algorithms include
fast-charge mode and a top-off trickle-charge to gain minimum charge
time with maximum battery capacity.
The buck converter is similar for both
the AT90S2333 (see
schematic 1) and the ATtiny15
(see
schematic 2). It is made up of
one P-channel MOSFET switching transistor driven by the AVR via one
bipolar NPN transistor. The switching transistor is connected to an
inductor, a diode, and a capacitor (see Figure 1).
(a) |
(b) |
| Figure 1ýHere you can see the
buck converter switching schemeý(a) charging and (b) inducing
voltage. |
An additional diode prevents the battery
from supplying voltage to the microcontroller when the power is disconnected.
When the switching transistor is on (illustrated by a switch in Figure
1) the current will flow. The capacitor is charged from the input
via the inductor (the inductor is also charged).
When the switch is opened (see Figure
1b), the inductor will try to maintain its current flow by inducing
a voltage. The current flows through the diode and the inductor charges
the capacitor. Then the cycle repeats itself. If the duty cycle is
decreased, by shorter on time, longer off time, the voltage will decrease.
If the duty cycle is increased (longer on time, shorter off time),
the voltage will increase. The buck converter is most efficient when
running on a duty cycle of 50%.
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. |