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



Rockbox mail archive

Subject: Re: I, battery man ;-) (was: Question to powermgm.c charging algorithm)

Re: I, battery man ;-) (was: Question to powermgm.c charging algorithm)

From: Heikki Hannikainen <hessu_at_hes.iki.fi>
Date: Mon, 12 Aug 2002 16:58:14 +0300 (EEST)

  Hi Uwe,

On Mon, 12 Aug 2002, Uwe Freese wrote:

> So the values in powermgmt.c are in mV and 50 means 50mV.

  Check the code & the comments after the commits I did today, it should
be clearer now. It now discards voltage samples taken while the disk is
spinning. I've also tuned the delta constants a little and removed the
unnecessary loops. And battery_level_safe() uses the history table too.
The tuned code seems to charge a bit better.

> Question: What happens if the AJB is connected to external power: Does
> the power for the Archos come from the external power then? That means
> if we don't switch the "charging pin" on, batteries are not used in
> any way?

  The device is not powered from the charger unless the charger is
connected to the batteries (charging enabled).

> So please tell me what you want.

  I cannot comment for everyone, but generally, trying different
alternative approaches is good (evolution). Personally I'd go for first
trying to tune the current charger to do what it does as well as it can
(by tuning the timings and constants and maybe adding a few tricks like
the trickle charging when reaching 'full' status). But it would be really
good if someone would try and test different approaches and tricks too.

> /If/ you want me to write and implement a charging algorithm, I'll need
> your help for this (are you the main charging algorithm programmer?) -
> especially for integrating it into the menu structure and the thread
> things. That's because I'm not so good in C programming and think
> there are others that know the RockBox structure better.

  I wrote the current charger code. I think you'd be best off using the
current powermgmt.[ch], ripping off the logic in the power_thread() and
putting your own in there. All of the necessary hooks are used there
already. If the code works, it'll be integrated (or the current code
changed to do the same, whichever is easier and cleaner, by me or someone
else), and patches will surely be tested and commented on when posted on
the mailing list.

> - Charging algorithm 1 that can be used while using rockbox. Mainly a
> simple trickle (if lower than x volts, turn on charging power).
> x adjustable in menu (maybe only two values as it's now).
> - Charging algorithm 2 that is started from inside the menu. The user
> starts it and the AJB does a complete charging. The battery has to
> be < 50% full for this (check voltage before). AJB cannot be used in
> parallel when charging. The charging status is displayed with a
> curve, time, voltage and everything that is interesting or even
> useful. ;)

  I don't see why the charging should be started in the menu. After the
last changes I did (skipping voltage samples while disk is spinning) we
can measure the charge quite well while the box is in use. And when the
user plugs in a charger we can be pretty sure that his intention is to
have the batteries charged (or kept charged if they're already full). So
why not start the charging right away, and go to trickle charge mode when
the battery is full (start with trickle charge if it's full already)?

> How charging works:
> - constant and maximum charging power (the battery SHOULD get hot,
> because the voltage drop at the end comes from the battery getting
> hot which makes the voltage go down)
> - charging end detected if:
> - time > x
> - voltage > y
> - voltage is going down (delta peak) 0.02 v
> - the phase analysis says that we are in phase three and the
> gradient is lower than e.g. 1/5 of the maximum

  This would be pretty much what the current code does, except for that it
doesn't keep track of a phase (in that sense). We don't check for maximum
voltage either (although it might be a sensible security check too, to cut
charging if the voltage gets really high).

> x = getVoltage;
> lcdout(1,2,x);
> switchchargepower(1);
> sleep(10)
> switchchargepower(0);
>
> or however that works. So I can see how
>
> - lcd output
> - get voltage
> - set charge power on/off

  All of this can be seen in firmware/powermgmt.c and apps/debug_menu.c's
view_battery(). The power thread cannot directly write to the LCD without
messing up with whatever is currently running there, so it updates a
global char[] variable and the foreground applications (the status bar,
view_battery() etc) display them.

  - Hessu
Received on 2002-08-12

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy