yashsingh1/xdaforums huggingface dataset:
[Nexus One Android Development] theloginwithnoname:
get learn mode again and rediscover age, or if you know it already, re-set age. then do a charge.

If you do an off-charge or something else resets it to 94, just manually set it.
[Nexus One Android Development] RogerPodacter:
yes shut down is triggered when AEvolt is hit. sure you can try lowering AEvolt. all these things we are just testing to try to get extra juice from our battery (if possible). we first tried AEvolt at 3006 mV but remember it dropped so fast that it was almost too unstable. so then we tried a happy medium of 3.2 since it seemed a little more stable. go ahead and lower AEvolt if you want, and maybe leave your full40 where its at for now and see how that test goes.
[Nexus One Android Development] theloginwithnoname:
I can usually get down to 11mAh before it shuts down - but just depends on what is using the display in the interim - i.e. y'all should avoid maps ;)

correct. As I posted before, I'm testing my current setup of 3.018v and min 35mAh.

Shutdown is when volt < aevolt and there have been two consecutive current readings < min current.
[Nexus One Android Development] theloginwithnoname:
test results so far

All,

I normally get about 4%/hr drain from my phone, resulting in about 1.5 days per charge.

I have recently tweaked my voltAE and min capacity settings, then did a learn cycle. Usable 1262mAh. Lasted about 1.5 days.

Did an on-charge (from ~7%?), hit 4.182mV and 1268mAh. Lasted about 1.75.

Did another on-charge (from a little less than last time), hit 4.182mV and 1272, and after 13 hours it was still around 50% (< 4%/hr)

Today, I've drained only 21% in over 11.5 hours!

Either something is going weird or I have "made" LOTS of capacity.

Will report back when I get to lowest mAh/%
[Nexus One Android Development] RogerPodacter:
you bring up a great point not everyone might be aware of. but when you look at these PDF docs and the discharge curves they show, the more current you draw from the battery, the less mAh is available over the full range. so its a balancing act in a way.

for example, they doscharge at various current levels. at 0.2C, 1C, 2C, 4C, etc. at 0.2C you can maybe get, hypothetical, 1000mAh. but at 4C, you're only gonna get maybe 800mAh.

so when we do these tests its hard to balance it. with screen on full blast and maps going with GPS, the current draw is gonna be pulling -700mA which is just hammering the battery voltage, which might give a false artificial shut down earlier than normal. on the other hand if you leave in standby where it only pulls -12mA, then it obviously will extend the capacity. the point is its a tough balancing act.

if i keep my screen on full can do a complete discharge, i only get thru maybe 1100mAh before shut down, and it dies early. if i use normally, with moderate draw, i get thru maybe 1400mAh and it does not die early. so the point is the same capacity battery technically can have different capacities depending on the current draw C placed on it.
[Nexus One Android Development] pwig:
Ugh neither method worked.

Terminal emulator didn't change the file and gave me no errors. Root explorer opened the file as a text and I entered the lines one at a time but it wouldn't change any thing. I would save and exit then open it up to check it and it would be blank. Oy.
[Nexus One Android Development] samarium:
While setreg looks like a file, it isn't it an interface to allow poking around in the battery controller chip, and as such you won't see anything when you read it. Look at dumpreg before and after.
[Nexus One Android Development] samarium:
Yes, I tried that however it didn't work. When I set full40 to 2750 and charge, the capacity charges up to about 2550 and then jumps to 2750 indicating that it is fully charged, however that doesn't seem to do me any good on the discharge side of to curve. I still run out of mAh before V.

At the present time I"m going to try slowly increasing the full40 value from 2550 in 50 increments for each charge and just iterate. I should be getting the two new batteries this week, so that will slow down figuring out this one, as I will want to see how they go.
[Nexus One Android Development] samarium:
driver patch suggestion

A suggestion for the driver patch Roger, add a /sys file for the timeout value, so we can get it & set it for testing purposes, but otherwise it is left alone.

Of course, fixing the bug would be better, but that will probably be harder, and most people just want to do a learn cycle and not have it timeout.
[Nexus One Android Development] pwig:
Full40 still won't change from 27306 mah.

Which line in dumpreg am I supposed to be looking? Since I have tried several times to enter those values, I won't be seeing their effects, right? Because i didnt look before those entries. Anyway, the phone still thinks it has a much bigger battery than it does! I wish I didn't have to keep asking for help. Don't want to wear out my welcome.
[Nexus One Android Development] temasek:
I think I just revert back to my battery learned cycle with age of 84% at full40 of 1448 (somehow I can't get 1452 back no matter what I tried).
[Nexus One Android Development] RogerPodacter:
you really just need to look at the full40 file since that is the only parameter you are changing. but if you wanted, in dumpreg it is the 10th and 11th numbers on row 60 in dumpreg, 0x6a and 0x6b.

it should have worked when you entered into setreg. just make sure to do the first command and then immediately the second. you wont see anything in setreg, but you should see the change in the full40 file.

just type:

0x6a 0d

0x6b 9d

and make sure a space between the numbers. not sure why that wouldnt work for you...
[Nexus One Android Development] pwig:
Changing batteries to an actual original OEM battery put full40 at 1452. Is it possible that the battery determines this number? Like maybe the crappy fake battery thinks it's a 2700 when in reality it really isn't even able to hang with a 1400?
[Nexus One Android Development] RogerPodacter:
hmmm that's not a bad idea. now i have to think about how exactly that could be implemented. because these setreg files we added are writing to the battery's chip. but to write to the timeout poll would be storing a value inside the driver itself, so its not immediately apparent how to do that.
[Nexus One Android Development] RogerPodacter:
all these numbers we are dealing with here are stored inside your individual battery's EEPROM memory chip. so yes the battery is determining that number, which is why earlier back i said it must be some knock-off battery which is programmed incorrectly.

we have been tracking non-OEM batteries in this thread, and i think you are the 3rd person with an aftermarket battery which came incorrectly programmed from whatever manufacturer it came from. the full40 is a pretty important number as it is what tells the full point of your battery to the phone. a few people had 3200 batteries, but the full40 was set to 1452, so they only got 1452 of capacity. point being it was incorrect, and once fixed it worked perfect.

so your battery is probably a decent battery, but its obviously incorrectly programmed like the others.
[Nexus One Android Development] mtw4991:
Which is best to watch, getvoltage file output or OS Monitor which lags about 50 seconds behind? getvoltage doesn't refresh automatically?
[Nexus One Android Development] RogerPodacter:
voltage in OS monitor only updates approx every 50 seconds like you said, which is why we added getvoltage file which updates instantly every time you read it. so its best to use getvoltage if you're trying to monitor very closely as it will give you the real time voltage anytime the file is read.
[Nexus One Android Development] temasek:
Roger

What's the figure for 1452......? I kept doing it in full40 but its 1448

Thanks
[Nexus One Android Development] samarium:
Just make the timeout a static int so the scope of the variable is limited so it only available in that compilation unit. Something like the below added to ds2784.c:

static int ds2784_timeout = 300; /* or whatever the default is */

void
ds2784_timeout_set(int newvalue)
{
ds2784_timeout = newvalue;
}

int
ds2784_timeout_get()
{
return ds2784_timeout;
}

and you already know how to setup sysfs interfaces. You probably don't event need the routines above, just set & get directly in the sysfs code you write. Just make sure you sanity check the set values.

Obviously, you will also need to hack the ds2784 code that actually references the timeout to use the new variable.
[Nexus One Android Development] RogerPodacter:
pretty sure its:

0x6a 0d

0x6b 9d
[Nexus One Android Development] chowlala:
So... I bump charged with setage at 100. Then dropped the setage back to the actual at 84. Heh. Hella cheat. Let's see if this gives me extra charge plus correct % values.
[Nexus One Android Development] RogerPodacter:
right something like that should work. interestingly i'm looking at the code and trying to understand just exactly what they were trying to accomplish. here is the offending code which i altered when originally testing:

if (di->status.battery_full == 1)
di->last_charge_seen = di->last_poll;
else if (di->last_charge_mode != CHARGE_OFF &&
check_timeout(di->last_poll, di->last_charge_seen, 60 * 60)) {
if (di->last_charge_mode == CHARGE_BATT_DISABLE) {
/* The charger is only powering the phone. Toggle the
* enable line periodically to prevent auto shutdown.
*/
di->last_charge_seen = di->last_poll;
pr_info("batt: charging POKE CHARGER\n");
di->charge(0, 0);
udelay(10);
di->charge(1, source == CHARGE_FAST);
} else {
/* The charger has probably stopped charging. Turn it
* off until the next sample period.
*/
charge_timeout = true;
charge_mode = CHARGE_OFF;
}
}

i changed 60*60 to 60*60*2 (from 1 hour to 2 hours) and was able to finish learn cycle before any timeout. so we could just add a new variable or function like you posted, say TIMEOUT_POLL = 60. and use sysfs files to change that when we want.
[Nexus One Android Development] temasek:
Lol I am interested in your your results. ..........but.......
[Nexus One Android Development] chowlala:
I feel we're on the right track. Matching the mAh to the setage is one move. But we might need to match the aevolt as well. This would be the key in having a 1:1 ratio for volts:mAh to give us the max squeeze from our batteries.

Thoughts?
[Nexus One Android Development] pwig:
But I was unable to reprogram the "fake" battery. Is that normal?

And current widget stopped working. It always thought it was charging at 44 ma.
[Nexus One Android Development] RogerPodacter:
No that's not really normal. The setreg should work, not sure why it didn't. Maybe It's not. If same chip? But that makes no sense cause the registers are being read since dumpreg works for you. I dunno man, you sure you did it right?
[Nexus One Android Development] jasrups:
This seems like a great thread with lots of information. At some point when I have time I plan to sift through the pages and learn a thing or two about proper calibration but in the mean time I'll ask, is bump charging the bets way to calibrate the battery?? My phone used to shut off at around 17%. I tried the bump charge method on page 10 of this thread and while it seemed to increase my battery life, the phone still shut off at around 12-15% percent.

Sorry for the noob question
[Nexus One Android Development] RogerPodacter:
no bump charging really doesnt do much at all. the quick summary of this thread is that if you are using the latest pershoot kernel, we have added edits that allow you to now write and interact with the EEPROM chip inside your battery, to change things like empty volt, current, full point, batt age, etc. there is even a hidden learn mode that can be activate in the chip to re-calibrate the battery. this fixes when your battery dies early like 15%. an app is on its way to do this stuff. but for now read thru the last few pages and manually change your reigsters. set your age value to stop your battery from dieing early. that's the easiest quick thing you could do for now.
[Nexus One Android Development] chowlala:
The early % shut down fix is on the first post.

Until we get the app out, you'll have to do with Fix 1, unless you know enough with what we're doing. Sorry. =(
[Nexus One Android Development] samarium:
TIMEOUT_POLL is the wrong style, it implies a #defined constant, not a variable. I just had a look at the cyanogen 2.5.35-exp tree where your 40 mAh change has been merged. https://github.com/cyanogen/cm-kern...ed245913149893/drivers/power/ds2784_battery.c

after line 93 you want to add

static int battery_timeout = 60 * 60;

and change line 504 to

check_timeout(di->last_poll, di->last_charge_seen, battery_timeout)) {

then write a sysfs routine creating a "timeout" file, which when read returns the value of battery_timeout, and when written loads the value into battery_timeout.

I really have to build a kernel build environment on my build VM, however ...
[Nexus One Android Development] samarium:
Given pwig's discomfort with the process, that is what I would guess.

Maybe it would be better for pwig to download the android sdk and get adb working do he can adb to the N1 and then just type in the commands, rather than poking around with root explorer. Or maybe that is just what makes me more comfortable ... however command line interfaces are more reliable and verifiable than most gui interfaces, so thus I suggest use adb.
[Nexus One Android Development] pwig:
Certainly not sure I did it right! But when I looked at dumpreg the values were correct in the correct spot. The crap battery was just stuck at 27630. 27000 mah! An obvious mistake.
[Nexus One Android Development] theloginwithnoname:
another good post samarium - if you have git, I'm in the process of creating/noobing an "experimental" branch for people to throw stuff into - send a pull request to it if you like? (github address at top of Bat Cal tools thread)
[Nexus One Android Development] theloginwithnoname:
Went down to 2% before I plugged in to do on-charge, ~18mAh and > 3.4v. That's over 2 days, which I've never had in normal use before.

One full on-charge later has got me 4.182v and 1276mAh now!!

Balmy.
[Nexus One Android Development] chowlala:
Heh. My current setup leaves me at 11 hours with 35% left. 3610 mv and 430 mAh. Heavy usage. Been in bad 3g spots, I use 3g only btw. Twitter, facebook, gtalk, emails, hour plus worth of calls, bluetooth.

Still up pretty strong. :)
[Nexus One Android Development] RogerPodacter:
well the interesting part is that 27630 or whatever it was just so happens to be the result when both registers are maxed out at 255! hex only goes from 0-255 so its almost like your registers 6a 6b are null or not used or something. we see the same thing on the stock battery, for example the stock battery has one called "aged capacity" but that register i think comes up as 255 because its not used or something. who knows.
[Nexus One Android Development] RogerPodacter:
wow and all that with your age set your new learned value? pretty nice numbers, i wonder if you can keep pushing it by lowering AEvolt...
[Nexus One Android Development] chowlala:
Ok. I had an early boot. But I don't know where it died at. Lol. I assume it was 20ish.

But funny thing is. On boot, my age reset to 94. And I could push the batt down as far as 1% at 14 mAh and 3298mV.

So the right setup for me would seem to be 1550 max mAh. 3201 aevolt. Age 94. Now I'm really confused. Cuz my actual battery age should be 82 or 84 to hit 1% battery shutdown.
[Nexus One Android Development] RogerPodacter:
well if you just got down to 1% at 14mAh with full40 set to 1550 then dude i would just roll with that for a while. i think its gonna really depend on how hard we push our devices as to whether we'll make it all the way down or not. use it heavy and its gonna kill the voltage no matter what. but use it lightly and i bet it could stretch the full range down to zero.
[Nexus One Android Development] Markdental:
I have had my settings at full40 to 1550 and mv to the lowered number and 100% battery age with stock battery.

Couple of observations.

I charge overnight and when I wake up, the battery smells like it is overheating.

Also, the phone is very unresponsive to the point where I HAVE to reboot. After that it runs fine. I have not let it get to where it will die yet, but I ran it pretty hard yesterday when I got home and it did great. I am using 11/20 Wildmonks OC to 1113 and Cm 254 nightly.
[Nexus One Android Development] chowlala:
Yah. I was gonna shutdown and go for manual learn mode. But when I saw the 1% I decided to plug in for an on charge. Will use this for a bit to check it out.

Odd thing is I noticed my mV's fluctuating up and down without being plugged in. Anyone else has this?
[Nexus One Android Development] RogerPodacter:
oh yeah dude, i see my voltage fluctuate a whole lot, especially when it gets to 3.5 and below. when you use something that shows you the getvoltage file every 10 seconds or so, you'd be surprised how erratic it gets that you dont see in the dmesg log. it goes from 3.46 up to 3.52, up and down, quite a bit. i wouldnt worry.
[Nexus One Android Development] RogerPodacter:
i havent heard of anything like this, but you are saying you think its overheating on the charge up to full?
[Nexus One Android Development] chowlala:
Haha. Almost feels funny. It's like as if the battery was drawing on air to charge it's volts. Lol.

Well, at least it doesn't seem to be an issue. Just thought I'd check.
[Nexus One Android Development] theloginwithnoname:
Consistent with what I have seen. On totally powering off (inc start of learn), age is reset. Why it is set to 94 is anyone's guess - it's not the battery manufacturer's default or new values! darn it.
[Nexus One Android Development] mtw4991:
Having real troubles getting into learn mode for some reason. Last night, I watched it die and slammed the charger within 1-2 seconds, but didn't hit 0x71. age=100, full40=1558, setreg=<20mAh, aEvolt=3201, fyi.

So, I let it charge for a minute or two to get back to 2-3% charge and watched it get down to 1% at 14mAh and 3214mV before it shutdown a second time. This second time around I had the charger resting in the power inlet and within a fraction of a second of shutdown, slammed the charger again and did an overnight full off-charge to 1538mAh. Also, using this method of just a slight charge to 1-2% then watching it die, isn't this just like learn mode whereby it gets down to 1% and then power up from there?

However, when I powered on this morning statusreg just showed 0x81 which is full, right? I'm looking for 0x71 for learn mode, correct? Also, what is 0x61, which I have seen a couple of times?
[Nexus One Android Development] RogerPodacter:
0x61 typically means that learn mode had turned off, but then it got lost for some reason. 0x61 in binary means the active empty and standby empty flags are both on, which happens also when the learn flag is on. so when i test learn mode i hit 0x71 and then if i stop it quickly it goes right to 0x61. if i continue the learn mode then it goes from 0x71, then at 5% battery switches to 0x31, then after 15% switches to 0x11 all the way till full.

if you're using a script then it should have showed 0x71 right before shut down. however it it showed 0x61 right before shut down, then that means you are running out of mAh before voltage, or they are happening simultaneously (see trick below).

one trick i have to do is if you attempt to hit learn mode and miss it, the next reboot starts the battery back at zero percent. this makes a second attempt difficult as you may run out of mAh before volt, which wont trip the learn flag. so every time i make a second attempt, i bump up my mAh a bit, which simulates the "turn off early" situation, which is good because that ensures empty voltage is tripped every time you make an attempt.

so for a second attempt, do a quick

echo 0x10 03 > setreg

and that will bump up your mAh. dont worry about the percent suddenly being off set, as soon as you hit the learn flag, it starts the battery over at zero to continue the learn cycle. same reason why if you guys have ever noticed when you have the "die early" problem at, say, 15%. when you reboot it immediately starts back at zero, not 15%. it resets itself at empty point. (and also at full point, which is why it jumps to full)
[Nexus One Android Development] mtw4991:
Thanks for the explaination! Guess I'm one of those guys that will just wait for the app to be finished because I usually don't have it connected to the desktop and most values are hard to see without it, lol.
[Nexus One Android Development] Markdental:
My battery fell out when I dropped my phone, my age did not reset to 94, stays 100.
[Nexus One Android Development] theloginwithnoname:
Sorry, I meant as in "when the device shuts down due to no battery left". Also when off-charges are done. Reboots, lock-ups etc seem to not affect.
[Nexus One Android Development] jasrups:
Thanks to you and Roger for your replies!
[Nexus One Android Development] chowlala:
No problem.

Roger and thelogin are working hard to get the app out which will help us memorize age and stuff... let's just give em room to breathe and keep brainstorming. =)

On the other hand Roger and thelogin:

Is it possible to hash out a script for charging?

Was thinking to get the automated boost:

1) On plugin: setage = 100 (this would give us the top end boost)

2) On remove charger: setage = actual age (this would then give us the actual % counter)

Hope you guys are catching my drift. Haha.
[Nexus One Android Development] samarium:
Seems like I had a successful cm build this morning.

I pulled pershoot's kernel-2635 to be a base, however I'm currently stuck at getting a .config for it, guess I'll grab it from the cm build.

I saw pershoot's refernce to your github kernel, was going to look at that after I got the above to compile. Wondering if I can pull from yours, and reference pershoot's, thus reducing the required download time?
[Nexus One Android Development] theloginwithnoname:
A bit off-topic so let's take this over to the Battery Calibration tools thread...
[Nexus One Android Development] samarium:
Interesting trace after echo 10 03 > setreg per Roger.

Wed Nov 24 23:46:31 EST 2010 3425086 uV -153564 uA 102400 uAh 0x27
Wed Nov 24 23:46:34 EST 2010 3425086 uV -166830 uA 100800 uAh 0x27
Wed Nov 24 23:46:37 EST 2010 3420200 uV -156445 uA 100800 uAh 0x27
Wed Nov 24 23:46:41 EST 2010 3420200 uV -164552 uA 100800 uAh 0x27
Wed Nov 24 23:46:44 EST 2010 3420200 uV -151420 uA 0 uAh 0x67
Wed Nov 24 23:46:47 EST 2010 3415314 uV -151420 uA 0 uAh 0x67
Wed Nov 24 23:46:50 EST 2010 3400656 uV -162207 uA 0 uAh 0x67
Wed Nov 24 23:46:53 EST 2010 3410428 uV -289105 uA 0 uAh 0x67
Wed Nov 24 23:46:56 EST 2010 3410428 uV -334866 uA 0 uAh 0x67
Wed Nov 24 23:46:59 EST 2010 3410428 uV -256878 uA 0 uAh 0x67
Wed Nov 24 23:47:02 EST 2010 3410428 uV -228604 uA 0 uAh 0x67
Wed Nov 24 23:47:06 EST 2010 3415314 uV -180029 uA 0 uAh 0x67

Phone stubbornly refuses to set LEARNF even though below AEV=3416.

This happened twice in a row.
[Nexus One Android Development] chowlala:
Ok. So my setup isn't really working.

Can't seem to get the mV's and mAh's to play along in a 1:1 ratio.

Phone was about to die at 15% because the mV was dipping crazy after 3416. I was at 3298 with 220 mAh left.

Gonna do the manual learn mode and then start from there again I suppose.
[Nexus One Android Development] theloginwithnoname:
<nods> You know it makes sense, Rodders... :D

Raises a good point actually - we could do with a cut-down version of stock "dumpreg" (or the data sheets) on the first page, to show what the standard values are - useful if someone has set something wrong and it's all gone t1ts up. Can't provide unfortunately, I've haxed too many of mine :D