maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   Estimating the charge time (https://talk.maemo.org/showthread.php?t=39140)

papo 2010-01-03 15:17

Estimating the charge time
 
Hello

I noticed that the N900 does not estimate how long it's going to take for the battery to get fully charged. Such an indication would be helpful to me and I can imagine that other people would be interested too.

I'm trying to do this, but I'm not sure if the information provided by lshal is accurate enough for a decent estimation. To figure that out, I have to profile the charging process. I wrote a script to do that, but I'd like to obtain samples from other N900 users. This enables me to get more samples faster and I can cross-check my code with other charging profiles.

If you want to help me out, use the following script:

#/bin/sh

FILE=$(date +%s|tr -d '\n').charge

while true
do
date +%s|tr -d '\n' >> $FILE
lshal|grep battery >> $FILE
echo "-- " >> $FILE
sleep 30
done


Put this code into the file /home/user/profile.sh, then cd into that directory (cd /home/user) and run chmod 755 profile.sh. When you are going to charge your device, open a terminal and run ./profile.sh before attaching the charger. Quit the script (ctrl-c) after you detached the charger. The script will generate a file with a timestamp and the suffix charge, for example 1262531100.charge. (Note that the internal file browser does not display suffixes). Send me these files; you may remove them afterwards. Please only send in files of charging processes where the device was fully charged, and if possible, write me which charger (USB or power outlet) you used, if WLAN was active and whether the device was idle during charging process.

I can't promise that the data will be accurate enough for a widget to predict charging time, but I promise I'll publish some graphs and analysis of the data if enough samples are returned.

Best regards and thank you

Matt

EDIT:
1. send the files to weyland - a t - library.ethz.ch
2. I was asked whether the script has to be stopped right after the battery gets fully charged. This is not necessary, you can keep the script running and stop it after you come back from whatever you were doing in the meantime. But please don't stop the script before the battery gets full, so that I can use the log file to determine precisely when this happens.

zehjotkah 2010-01-03 15:31

Re: Estimating the charge time
 
welcome to the forum! nice to have you here! i will see, what i can do. a widget with that function would be nice



edit: i've a problem:
made that file
chmod that file
but after ./ it says permission denied...

papo 2010-01-03 16:00

Re: Estimating the charge time
 
Hello

Quote:

Originally Posted by zehjotkah (Post 451243)
but after ./ it says permission denied...

Can you post ls -l profile.sh and make sure that there is no space between ./ and profile.sh? And can you post the full error message (there should be something before Permission denied)?

Regards & thanks

Matt

zehjotkah 2010-01-03 18:38

Re: Estimating the charge time
 
-rw-r--r-- 1 user root 162 Jan 3 17:32 profile.sh

-sh: -/profile.sh: Permission denied

my battery is low, so i must fix that soon... ;)

papo 2010-01-03 18:42

Re: Estimating the charge time
 
Hi

Quote:

Originally Posted by zehjotkah (Post 451495)
-rw-r--r-- 1 user root 162 Jan 3 17:32 profile.sh

The chmod did not work then:

~ $ chmod 644 profile.sh
~ $ ls -lh profile.sh
-rw-r--r-- 1 user users 152 Jan 3 16:56 profile.sh
~ $ chmod 755 profile.sh
~ $ ls -lh profile.sh
-rwxr-xr-x 1 user users 152 Jan 3 16:56 profile.sh


You can only execute the script if the executable bit (x) is set. Alternatively, you can also try sh ./profile.sh which does not require the executable bit.

Thank you for your efforts

Matt

That One Guy 2010-01-03 19:05

Re: Estimating the charge time
 
Email address to send .charge logfiles to?

papo 2010-01-03 19:11

Re: Estimating the charge time
 
Quote:

Originally Posted by That One Guy (Post 451522)
Email address to send .charge logfiles to?

weyland - a t - library.ethz.ch

zehjotkah 2010-01-03 19:22

Re: Estimating the charge time
 
i can't get the file mark as executable^^ thats really strange. i've tried it in the mmc1 but also in .documents...
stays at -rw-r--r--
i've made a .txt in windows, with the content, renamed to profile.sh, transferred to my n900..
something i'm doing wrong... feeling stupid right now^^

Matan 2010-01-03 19:26

Re: Estimating the charge time
 
You can't execute files on the VFAT partition. copy them to another partition.

papo 2010-01-03 19:26

Re: Estimating the charge time
 
Hm, it just popped into my mind that you may be trying on a filesystem that does not support modes (such as vfat). That would explain it. I'm trying in /home/user which is ext3. Anyway, sh ./profile.sh (or whatever the name of the file is) should work anyway, so just add a preceding 'sh' and you should be fine. I'll fix the first post in this thread.

Thanks, Matt

ravioli156 2010-01-03 19:36

Re: Estimating the charge time
 
Anyway, I don't see how the users output will help you to estimate the charge time... It's not easier to just calculate the time elapsed for a percent of charge, and estimate the remaining time based on that info ?

e.g. : starts charging at 15%, when the battery is 16% charged, 2 minutes have passed. So the remaining time is (100 - 16) * 2 = 168 min
and each percent gained, you redo the thing, so when battery is 80% charged, you know that (80 - 15) = 65 percent takes 50min, so 20% left will take (20 * 50 / 65) = 15 minutes

zehjotkah 2010-01-03 19:51

Re: Estimating the charge time
 
that was the mistake... profile.sh was sitting on a VFAT partition. running it in home/user does work.
thanks.

papo 2010-01-03 20:20

Re: Estimating the charge time
 
Hello

Quote:

Originally Posted by ravioli156 (Post 451553)
It's not easier to just calculate the time elapsed for a percent of charge, and estimate the remaining time based on that info ?

Well yes, but first, the relation is not linear and second, I don't think there is a way to poll the battery level while charging. If there is, I'd be interested in it, though.

Thanks, Matt

ravioli156 2010-01-03 20:30

Re: Estimating the charge time
 
when you do a lshal | grep battery, when charging, the percentage of battery is not refreshed ? seems odd if it's not refreshed.
I'll do a test

ravioli156 2010-01-03 20:45

Re: Estimating the charge time
 
ok right the level of battery is not updated.

But you can rely on voltage.current and voltage.design to approximately determine the remaining time, with the same method as above.

And better, you can check at the first launch of your program the voltage.current when battery is considered as full, to know what's the max level the battery can achieve.

Because everyone can have a battery with a max voltage different, so once again I don't see how the results sent by users will help you.

papo 2010-01-03 21:04

Re: Estimating the charge time
 
Hello

Quote:

Originally Posted by ravioli156 (Post 451628)
But you can rely on voltage.current and voltage.design to approximately determine the remaining time, with the same method as above.

Yes, this is what I am planning. However, charging a Li-battery is a little bit tricky. There are several stages; first, the voltage is constantly increased, and then, the current keeps decreasing at constant voltage. I agree with you that the technique you are proposing can be used, but it's probably going a little bit more complicated than just a linear fit.

Quote:

Originally Posted by ravioli156 (Post 451628)
And better, you can check at the first launch of your program the voltage.current when battery is considered as full, to know what's the max level the battery can achieve.

Because everyone can have a battery with a max voltage different, so once again I don't see how the results sent by users will help you.

I have two reasons for asking the community for more logs. First, I charge my device every night when I go to bed, using the outlet charger. That means that I don't have any data about charging curves using the usb cable, charging curves of devices which are being used while charged etc. If I write an application that is supposed to be used by a broader user base, it's reasonable to me to develop the extrapolation algorithm with data from several devices, to cover variations related to user behaviour and the device itself. If I would rely on my own data only, I could naively assume that the second stage starts when 4140 mV are reached. Comparing my data with other data from other devices and batteries may reveal that it's not always 4140 mV. Furthermore, I'm trying to find a good estimation for the second stage of the charging process which suits as many charging and using pattern as possible, not just my own.

Second, it's just an easy way for me to get a large sample size. As I said, I charge my device once a day, so I can collect 7 profiles a week. I have a background in biostatistics and to make some reasonable predictions, I'm looking for n>20, which would take me a long time to collect. I'm also profiling the charging curves on my own device by the way.

Best regards

Matt

ravioli156 2010-01-03 21:30

Re: Estimating the charge time
 
I understand your approach, and the fact you need data to get the charging curve.

But there is a problem, how to be sure that the charging curve is constant in the time (and I'm pretty sure it won't, problem is N900 has been released since a month only), and how to be sure that there are not (or there won't be) different models of battery ?

In addition to the data you'll get, the best is not to collect data on the phone where the application is installed at each charging, so the estimation will remain the closest of the reality ?

papo 2010-01-03 21:52

Re: Estimating the charge time
 
Hi

Quote:

Originally Posted by ravioli156 (Post 451661)
But there is a problem, how to be sure that the charging curve is constant in the time (and I'm pretty sure it won't, problem is N900 has been released since a month only), and how to be sure that there are not (or there won't be) different models of battery ?

Actually there are quite a bunch of problems. First I have to figure out if the current voltage data can be used at all. My first impression is that it's quite jumpy but may be used after some pre-processing. Now for the doubts you mentioned, this may very well be an issue. I can run some kind of "goodness of fit" estimations to check the quality of my prediction, but this should ideally be ran on a variated sample instead of repeated measurements on my own device, hence I need as much data as possible.

Quote:

Originally Posted by ravioli156 (Post 451661)
In addition to the data you'll get, the best is not to collect data on the phone where the application is installed at each charging, so the estimation will remain the closest of the reality ?

I'm not sure if I understand what you mean here. Can you rephrase?

Regards, Matt

ravioli156 2010-01-03 22:26

Re: Estimating the charge time
 
in addition to the curve you'll extrapolate to estimate the remaining charging time (e.g. starts charging with 35% @ 4040mAh equals 40 minutes remaining according to the charging curve) maybe you can collect data on the phone each time it's being charged, so that you'll generate a curve specific to the phone.

So you'll know that for this specific phone, 4040mAh equals 32 minutes remaining for this phone, instead of 40, because the last 10 chargings, on average, there was 32m remaining @ 4040mAh, 25m @ 4100, 15 @ 4150, 5 @ 4170.

And because a battery degrade in time, and a new firmware can also improve - or not - battery duration, your program will always be accurate.

I'm maybe wrong, but it's how I see the thing

papo 2010-01-03 23:56

Re: Estimating the charge time
 
Quote:

Originally Posted by ravioli156 (Post 451716)
So you'll know that for this specific phone, 4040mAh equals 32 minutes remaining for this phone, instead of 40, because the last 10 chargings, on average, there was 32m remaining @ 4040mAh, 25m @ 4100, 15 @ 4150, 5 @ 4170.

And because a battery degrade in time, and a new firmware can also improve - or not - battery duration, your program will always be accurate.

I'm maybe wrong, but it's how I see the thing

Yes, this is precisely what I am intending. The plan is first to look at the data and inspect how variable it can be. Then to come up with a suitable algorithm/model for the prediction. That could either be rather simple (use measurements gathered at the beginning and during the charging process) or a little bit more tricky, with a learning element (prediction based not only on current charging process, but also on earlier charging processes on the local device to a certain extent). It all depends on the accuracy and variability of the data, that's why I'm trying to get as much as possible.

Once I come up with that algorithm, I can simulate the prediction for each profile that was handed in and decide whether it's enough accurate for productive use.

I believe that using some pre-computed parameter estimates based on the data from various devices within the actual program would not be very smart. (I think we agree on that point). The data is only for some early inspection, not to derive any actual numbers to be used in the program.

Matt

shadowjk 2010-01-04 07:11

Re: Estimating the charge time
 
It'd be cool if your widget collected some of this data during charges, adjusting the profile on the fly, adapting to the user's battery. The battery will lose capacity and gain internal resistance over time, mostly related to the temperature it gets exposed to. This will make the charging reach 4200mV sooner, the constantt voltage stage, and this stage will take longer and longer time, relatively.

davost 2010-01-04 20:38

Re: Estimating the charge time
 
Alright, so I ran your script while charging. Curious about the result I couldn't resist peeking at the data. What I found was an imho weird behavior. Take a look at the graph. Is this normal?

http://farm5.static.flickr.com/4047/...c6157029_o.png

ravioli156 2010-01-04 23:20

Re: Estimating the charge time
 
Quote:

Originally Posted by davost (Post 453062)
Alright, so I ran your script while charging. Curious about the result I couldn't resist peeking at the data. What I found was an imho weird behavior. Take a look at the graph. Is this normal?

http://farm5.static.flickr.com/4047/...c6157029_o.png

I think there is a problem... I've done a charging test yesterday, and the voltage level was increased almost linearly... I don't know what's wrong, but if I were you I'll redo the test asap :D

When you unplug the charger and type lshal | grep battery, what's the current voltage ?

ndi 2010-01-05 00:07

Re: Estimating the charge time
 
Trying to help...

a) Mine is near-linear, I can calculate percentage charge to within a few points (checked by removing charger). Fiddling with it is bad tho.

b) It doesn't have to be by-the-second. Batteries in N900 are quite similar and charge current is 500 mA until such is the time to throttle it. Can't we just use a conversion table? Say, every 10 % or so, and guesstimate that a 30% battery will charge in 55-65 minutes? We'll call it "about 60 minutes". 40% would be "about 50 minutes", etc. Community could help with figures.

c) Can't a software self-profile? When plugged in, it times the charge time from current level to full _assuming_no_interaction_ (if the user plays with it it's no longer fully charging). It should be able to do decent estimates after -say- 3 charges at 5, 30 and 60 percent?

contro 2010-01-05 02:21

Re: Estimating the charge time
 
I like where you guys are going with this.


All times are GMT. The time now is 07:21.

vBulletin® Version 3.8.8