FS#2927 - V1 charging algorithm changes

Attached to Project: Rockbox
Opened by jock765 (jock765) - Wednesday, 18 January 2006, 06:35 GMT
Last edited by jock765 (jock765) - Thursday, 26 January 2006, 19:18 GMT
Task Type Patches
Status Closed
Assigned To No-one
Operating System
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


1. Use short term - delta change only when long term
delta is fairly static - this avoids false trips early
in the cycle.
2. Use a much lower value for long term delta as low
rates of change on high capacity batteries will be
common. In fact long term delta can probably only
really capture a slow moving negative change, which is
what it now does. Also only use this - long term change
if there was no disc use in this period (causing maybe
a small voltage drop). Also for long term delta ignore
glitches in the middle of the sample period - only need
stability around where the measuring points are.
3. Extend the maximum charge time accordingly when the
disc is used during charging - otherwise the maximum
charge period will not be long enough.
4. When moving to Topup or Trickle charge modes, make
the target voltage relative to the voltage acheived
during charging as this voltage will vary from battery
type and temperature at the time amoung other things.
Have made trickle voltage the voltage at termination
minus 0.1v.
This task depends upon

Closed by  Jörg Hohensohn (hohensoh)
Saturday, 04 March 2006, 09:49 GMT
Reason for closing:  Accepted
Comment by Linus Nielsen Feltzing (linusnielsen) - Wednesday, 18 January 2006, 06:43 GMT

Great! Now we need only two things:

1) Your real name

2) The patch :-)
Comment by jock765 (jock765) - Wednesday, 18 January 2006, 07:25 GMT

whoops - (never checked the file tickbox) should be there now
Comment by jock765 (jock765) - Wednesday, 18 January 2006, 07:27 GMT

Real name - Alun Thomas
Comment by jock765 (jock765) - Wednesday, 18 January 2006, 21:09 GMT

update to reflect CVS change to powermgmt.c
also seperate .diff file for powermgmt.c and .h
Comment by jock765 (jock765) - Thursday, 19 January 2006, 19:35 GMT

Update for further CVS activity
Comment by jock765 (jock765) - Thursday, 19 January 2006, 19:39 GMT

Also fixed bug of no target voltage for trickle or topup
charge when first plugged in.
Comment by Jerry (vanbargw) - Friday, 20 January 2006, 02:00 GMT

Major critique:
Changed block starting with the comment "Start the charger
full strength"

Max charge time was the maximum of
1) 135% the estimated battery discharge level (more tha 100%
to make up for battery inefficiencies)
2) The absolute maximum time constant based on the battery
(the constant has been in the algorithm forever and was
undoubtedly picked based on battery recharge reserch).

The original's intent was to set the maximum charge time to
_less_ than the absolute max time if the battery was not
fully discharged.

This patch modifies the max change time to be the absolute
maximum time constant (#2 above) _increased_ by the
estimated battery discharge level. This is increasing the
maximum charge time beyond the previously determined
absolute maximum. I don't see any justification for this
change and don't agree with it. Give me a justification and
I may change my mind ;-)

Minor critique:
The target voltage if the negative delta is seen is set to
power_history[0] (the negative delta is -5 centivolts). The
other cases set it to power_history[0] - 10. To be
consistant, we should subtract 5 centivolts for the negative
delta case and -10 (-15?) for the positive delta case.

Please use "cvs diff -u" (or equivalent) to get a unified
diff file. That is easier to read and more robust for patching.

Disk is generally spelled with a "k" for hard drives,
including everywhere else in the module.

Please maintain comment styles. I would prefer to match the
original (and predominant) comment style:
* Start the charger full strength
* max_time calculated for 12v (safest)
rather than:
/* Start the charger full strength
* max_time calculated for 12v (safest) */
Yeah, OK, I'm over sensitive about comment styles, but the
above doesn't match any common comment style and is just
plain ugly IMHO.

Please trim trailing whitespace (even the lines where it
wasn't your fault :-).
$ sed "s/ *$//" < powermgmt.c > tmp.c
$ mv tmp.c powermgmt.c
Comment by jock765 (jock765) - Friday, 20 January 2006, 06:07 GMT

A. Returned original Maximum Time Calculation to algorithm
- on reflection there is probably alot of research behind it
- would be silly to throw it away as it was not the cause of
any problems.
B. Tidy up target voltage assignments as noted by vanbargw
- topup target voltage is maximum voltage acheived - 0.05v.
trickle target voltage is topup target -0.1v.
C. Minor formatting changes as suggested.
Comment by jock765 (jock765) - Thursday, 26 January 2006, 19:17 GMT

Update patch for CVS activity.
Comment by jock765 (jock765) - Friday, 24 February 2006, 19:01 GMT
Update for CVS - 24th.Feb.2006