release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide
translations

# Rockbox mail archive

Subject: Re: Question to powermgm.c charging algorithm

# Re: Question to powermgm.c charging algorithm

From: Heikki Hannikainen <hessu_at_hes.iki.fi>
Date: Fri, 9 Aug 2002 12:05:49 +0300 (EEST)

Hi.

On Thu, 8 Aug 2002, Uwe Freese wrote:

> First: What do you call negative and positive delta? It seems that
>
> positive delta = voltage is going down
> negative delta = voltage is going up

It's the other way around (delta is new_sample - old_sample, so if
new_sample is larger we get a positive delta).

> Now a question to the code:
>
> ------snip------
> if (delta < -50) { /* delta < -0.3 V */
> DEBUGF("power: short-term negative delta, enough!\n");
> charger_enable(false);
> snprintf(power_message, POWER_MESSAGE_LEN, "end negd %d %dmin", delta, charged_time);
> } else {
> /* if we didn't disable the charger in the previous test, check for low positive delta */
> delta = 0;
> for (i = 0; i < CHARGE_END_ZEROD; i++)
> delta += power_history[POWER_HISTORY_LEN-1-i]*100 - power_history[POWER_HISTORY_LEN-1-i-1]*100;
> delta = delta / CHARGE_END_ZEROD;
>
> if (delta <= 5) { /* delta of <= 0.005 V */
> DEBUGF("power: long-term small positive delta, enough!\n");
> charger_enable(false);
> snprintf(power_message, POWER_MESSAGE_LEN, "end lowd %d %dmin", delta, charged_time);
> }
> }
> ------snip------
>
> why is the second test (delta <= 5) ? Shouldn't it be (delta >= 5), that
> means "turn off charging if the voltage went down at least by
> 0.005" Volts?
>
> Does the first check (delta < -50) mean that charging stops if the
> voltage went up very quickly?

Linus got this right. The first test is for a large negative delta over
a short time (which should be a good sign of a NiMH cell being full). The
second test is for a too small positive delta over a long time (the
battery does not seem to charge any more even though we didn't see the
voltage actually drop). This is a backup of a sort in case we missed the
negative delta.

The aim should be to tune the deltas we look for, and the time which we
take the averages over, so that we always catch the negative delta (as
quickly as possible but without tripping on short voltage drops due to the
disk spinning up), and never stop charging too early due to the small
positive delta test. Currently we seem to stop charging a bit too early.

By the way, I suspect the Archos firmware does trickle charging, or
lowering the charging rate by switching the charger on and off quickly. I
think I can hear something oscillate in the box 8-) It also takes a much
longer time to charge than rockbox, and possibly gets more energy in the
cells.

- Hessu