blob: 4a89cac1498952fda6fce38af0a53a29999a04ee [file] [log] [blame]
Uwe Freese38177302002-12-14 12:21:54 +00001CHARGING ALGORITHM
2
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +00003This doc and a part of the charger implementation (especially voltage curves,
4remaining time estimation, trickle charge) is written by Uwe Freese. If you
5miss some information here, write to mail@uwe-freese.de.
Uwe Freese38177302002-12-14 12:21:54 +00006
7
8
9[INTRODUCTION]
10
Jörg Hohensohn25848962005-03-03 07:25:43 +000011This doc describes how the charging works for the recorder. The algorithm
12can be found in firmware/powermgmt.[c|h]. Debug output is done in
13apps/debug_menu.c.
14
15Charging for the player and the FM/V2 recorder is done by the hardware and
16therefore isn't implemented in rockbox. Only the functions that
17calculate the battery level are also used for these models.
Uwe Freese38177302002-12-14 12:21:54 +000018
19All following information is related to the recorder.
20
21
22[TECHNICAL POSSIBILITIES AJB]
23
24- The AJB can read the voltage of the battery (all four cells in series,
25 resulting in about 5V).
26- We can switch the charging current (about 350mA, constant) on and off.
27
28
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +000029[VOLTAGE CURVES]
Uwe Freese38177302002-12-14 12:21:54 +000030
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +000031See http://www.uwe-freese.de/hardware-projekte/rockbox/ladeverfahren.html
32for some voltage curves taken while charging and decharging an AJB.
Uwe Freese38177302002-12-14 12:21:54 +000033
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +000034These voltage curves are implemented as arrays in rockbox. We can then
Uwe Freese38177302002-12-14 12:21:54 +000035calculate how full the batteries are (in percent) after taking the actual
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +000036voltage. Both voltage curves (charging and decharging) are used here.
Uwe Freese38177302002-12-14 12:21:54 +000037
38
39[CHARGE OVERVIEW]
40
41- If voltage drops under a certain value (with "deep discharge" option on the
Jörg Hohensohn25848962005-03-03 07:25:43 +000042 value is a lot lower), charging is started.
Uwe Freese38177302002-12-14 12:21:54 +000043- If end of charge is detected, go to top off charge.
44- Make the batteries completely full. 90 minutes of top off charge (voltage
Jörg Hohensohn25848962005-03-03 07:25:43 +000045 regulation at a higher value).
46- After that, trickle charge (voltage regulation at a nominal battery value).
47 The trickle charge will continue as long as the charger is plugged in (this
48 is a change from the original charge algorithm).
Uwe Freese38177302002-12-14 12:21:54 +000049
50
51[NORMAL CHARGE]
52
53When charging is started, the charger is turned on. The batteries are charged
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +000054with a constant current of about 350mA. The charging is stopped for three
55reasons:
Uwe Freese38177302002-12-14 12:21:54 +000056
57- the voltage goes down in a 5 min interval (delta peak, see below)
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +000058- the voltage goes up only a little bit in an 30 min interval (is mainly
59 constant)
Uwe Freese38177302002-12-14 12:21:54 +000060- the charging duration exceeds a maximum duration
61
62
63[DYNAMIC MAX DURATION CALCULATION]
64
65The max duration is calculated dynamically. The time depends on how full the
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +000066battery is when charging is started. For a nearly full battery, the max
67duration is low, for an empty one, it is a high value. The exact formula can
68be found in the source code. The battery capacity is also considered here.
Uwe Freese38177302002-12-14 12:21:54 +000069
70
Uwe Freese96f5de92003-01-26 17:19:31 +000071[LIION BATTERY IN FM RECORDER]
72
73(todo)
74http://www.seattlerobotics.org/encoder/200210/LiIon2.pdf
75
76
Uwe Freese38177302002-12-14 12:21:54 +000077[DELTA PEAK - WHY DOES IT WORK?]
78
79Delta peak means to detect that the battery voltage goes down when the
80batteries are full.
81
82Two facts on batteries are the reason why this works:
83
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +000084- If the batteries are full, the charging current cannot charge the battery
85 anymore.
Uwe Freese38177302002-12-14 12:21:54 +000086 So the energy is absorbed by heating up the battery.
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +000087- Each battery has a negative temperature coefficient, that means the voltage
88 goes down when the temperature goes up.
Uwe Freese38177302002-12-14 12:21:54 +000089
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +000090NiMH batteries have a smaller delta peak than NiCd, but is is enough for
Jörg Hohensohn25848962005-03-03 07:25:43 +000091Rockbox to detect that the batteries are full (in theory :-).
Uwe Freese38177302002-12-14 12:21:54 +000092
93Related documents on the web:
94
95 http://www.nimhbattery.com/nimhbattery-faq.htm questions 3 & 4
96 http://www.powerpacks-uk.com/Charging%20NiMh%20Batteries.htm
97 http://www.angelfire.com/electronic/hayles/charge1.html (soft start idea)
98 http://www.powerstream.com/NiMH.htm (discouraging)
99 http://www.panasonic.com/industrial/battery/oem/images/pdf/nimhchar.pdf
100 http://www.duracell.com/oem/Pdf/others/nimh_5.pdf (discharging)
101 http://www.duracell.com/oem/Pdf/others/nimh_6.pdf (charging)
102 Philips TEA1102/1103/1104 PDFs available at www.philips.com.
103
104
105[TOP OFF CHARGE AND TRICKLE CHARGE]
106
107After a normal charge is completed, trickle charging is started. That means
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +0000108charging to keep the batteries full. While trickle charge in other (stand
109alone) chargers means charging the amount that the battery loses because of
110self decharging, here it's charging the amount the AJB consumes when it's on.
111That's because it is not possible to switch off the AJB when charging is done.
112It goes on again and then the archos firmware charger code would charge again.
113So we have trickle charge in rockbox.
Uwe Freese38177302002-12-14 12:21:54 +0000114
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +0000115In simple words, rockbox charges about 15 seconds per minute in trickle mode.
Jörg Hohensohn25848962005-03-03 07:25:43 +0000116An AJB consumes 100 mA when it's on and the charging current is about 350mA.
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +0000117So charging 15 s and decharge 45 s will keep the batteries full.
Uwe Freese38177302002-12-14 12:21:54 +0000118
Jörg Hohensohn25848962005-03-03 07:25:43 +0000119But the number of seconds the charger is on in trickle charge mode is
120also adjusted dynamically. Rockbox tries to hold the battery level at
1215,65 V (top off charge, that means "make the batteries completely full")
122for 90 minutes, then a level of 5,45 V. If the voltage drops below the
123desired value, rockbox will charge one second more the next minute. If
124is is greater than this value, is will charge one second less.
Uwe Freese38177302002-12-14 12:21:54 +0000125
Jörg Hohensohn25848962005-03-03 07:25:43 +0000126The number of seconds the charger is on in top off and trickle charge
127modes is also dependant on the charger's output voltage: if the charger
128supplies less than about 10v, the current into the batteries is less and
129thus the percentage on is increased to maintain the proper current into
130the batteries.
131
132The original recharging algorithm stopped trickle charging after 12 hours,
133at which time the battery would be discharged until the the batteries
134fell below the "start charging" level. At that time the charge cycle
135would be repeated.
136
137The time limit was removed by Jerry Van Baren (along with other changes)
138in the February, 2005 timeframe. The rationale for this is that the
139trickle charge level is very low. In addition, it is disconcerting to
140have a AJR plugged in and "recharged" only to find out that the battery
141is only 86% full. This was giving the Rockbox recharging algorithm a
142bad name and frustrating our users.
Uwe Freese38177302002-12-14 12:21:54 +0000143
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +0000144Many chargers do top off and trickle charge by feeding a constant (low)
145current to the batteries. Rockbox, as described, makes a voltage regulation.
146That's because the power consumption of the AJB changes when backlight is
147on/disk is spinning etc. and doing a voltage regulation is the simplest way
148to charge exactly the needed amount.
Uwe Freese38177302002-12-14 12:21:54 +0000149
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +0000150There are two charge ICs I want to mention here: The Philips TEA1102 and
151TEA1103 do voltage regulation for NiCd and NiMH at 1,325 V per cell. That
152would be 5,3 V for four cells, but I think 5,45 V is best for Rockbox with the
153maximum time of 12 hours.
154Note that the voltage values are taken in the part of a minute where
Uwe Freese38177302002-12-14 12:21:54 +0000155the charger is off, so the values are a little bit smaller than the actual
156average of the whole 60 seconds.
157The Philips TEA1102 top-off charge time (with 0,15 C) is one hour.
158
159My test results with trickle charge (battery capacities measured with an
160external charger):
161
162- after normal charge and top off time: 1798, 1834, 1819, 1815 mAh
163- after normal + top off + trickle charge (12h): 1784, 1748, 1738, 1752 mAh
164- charged with external charger: 1786, 1819, 1802, 1802 mAh
165
166Result: Trickle charge works. :)
167
168
169[REMAINING TIME ESTIMATION]
170
171In simple words, it is
172
173remaining time = remaining battery energy / power consumption of AJB
174
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +0000175With using the battery curves described above and the battery capacity you
Uwe Freesef8484532002-12-15 23:25:27 +0000176selected in the settings menu, the remaining capacity is calculated. For the
177power consumption, a usual constant value is used. If the LED backlight is set
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +0000178to always on, it is also considered. Having a modified Jukebox with 8 MB of
179RAM leads to about 22 percent longer estimated running time.
Uwe Freese38177302002-12-14 12:21:54 +0000180
181
Uwe Freese3e3d8572002-12-18 19:39:13 +0000182[BATTERY DISPLAY HOW THE USER EXPECTS IT]
Uwe Freese38177302002-12-14 12:21:54 +0000183
Uwe Freese3e3d8572002-12-18 19:39:13 +0000184To not confuse the user with the shown battery level, some tricks are used in
185the battery level calculation (this does not affect the charging algorithm,
186because it uses the raw voltages):
Uwe Freese38177302002-12-14 12:21:54 +0000187
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +0000188- if charging is completed, top-off charge or trickle charge is running,
189 always set the battery level to 100%
190- the battery level is only allowed to change 1% per minute (exception: when
191 usb is connected, it is allowed to go 3% down/min)
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +0000192- after turning on the device, add another 5% to the battery level, because
193 the drive is used heavily when booting and the voltage usually gets a
Jörg Hohensohn25848962005-03-03 07:25:43 +0000194 little higher after that (rebounds)
Uwe Freese38177302002-12-14 12:21:54 +0000195
196
197[WHICH CHARGING MODE TO USE]
198
Jörg Hohensohn25848962005-03-03 07:25:43 +0000199Jerry Van Baren's revised recommendation: Select "deep discharge OFF"
200and "trickle charge ON". This will keep your batteries charged up and
201IMHO will not damage them.
Uwe Freese38177302002-12-14 12:21:54 +0000202
Jörg Hohensohn25848962005-03-03 07:25:43 +0000203Original recommendation:
Uwe Freese38177302002-12-14 12:21:54 +0000204
Jörg Hohensohn25848962005-03-03 07:25:43 +0000205A special case: If you use your AJR connected to the power supply all
206the time or if you fill up the batteries that are still nearly full every
Uwe Freese38177302002-12-14 12:21:54 +0000207night, it is recommended that you make a complete charge cycle from time to
Jörg Hohensohn25848962005-03-03 07:25:43 +0000208time. Select "deep discharge ON" and "trickle charge OFF" and wait till the
Linus Nielsen Feltzing25a60a52004-07-23 08:45:34 +0000209whole cycle is over (you can speed up the discharging a little bit by turning
210on the LED backlight). Even if the battery sellers say NiMH cells don't show a
211memory effect, I recommend making this procedure from time to time (every 10th
212charging cycle). BUT: Don't recharge the batteries completely every time if
213you don't have to.