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

# Rockbox mail archive

Subject: charging algorithm averaging

# charging algorithm averaging

From: Uwe Freese <mail_at_uwe-freese.de>
Date: Mon, 12 Aug 2002 18:08:03 +0200

Hello Heikki,

Comment to charging algorithm:

An average gradient (the delta), I would calculate like this
(s1,s2,... are the voltage samples here for a shorter explanation):

instead of delta = (s6 - s1) / 6
calculate if by delta = ((s4 + s5 + s6) - (s1 + s2 + s3)) / 6

and for the long term small positive delta:

instead delta = (s30 - s1) / 30
calculate it by delta = ((s26 + s27 + s28 + s29 + s30) - (s1 + s2 + s3 + s4 + s5)) / 30

For the real code, the first looks like this (CHARGE_END_NEGD has to
be at least 6):

delta = ( power_history[POWER_HISTORY_LEN-1]
+ power_history[POWER_HISTORY_LEN-2]
+ power_history[POWER_HISTORY_LEN-3]
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD]
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD+1]
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD+2] ) * 100 / CHARGE_END_NEGD;

Bye, Uwe.