yashsingh1/xdaforums huggingface dataset:
[Nexus One Android Development] frozst:
Thank you guys for the tips. I didn't know that the battery reseted every time I shutdown my phone, that's why I couldn't see my new batt age.

Now I rebooted instead of shutdown, my new battery age is 89 %.

Thanks!
[Nexus One Android Development] mtw4991:
Great! Another happy customer ;)
[Nexus One Android Development] rdmay20:
Im having trouble getting into learn mode.

My phone auto shutdown before i can get to 3201mV

I tryed keeping my current mA in the -190s mA

also tryed keeping it in the -400s mA either way it auto shutdown before i can get to 3201mV

any help?

please and thank you
[Nexus One Android Development] RogerPodacter:
Your battery is likely reaching zero mAh (0%) prior to reaching 3.201 volts. The app has an advanced acr option which should fix this, so try that option. Charge for 3 minutes and try again. That option doesn't always work though, it needs adjustment. So if that doesn't work just manually bump up the mAh by setting register 10 to value 03. That should bump up mAh when you are down low under 10%.

Just keep trying a few tines, it will all come together, it just takes some tender love sometimes:).

Short cut is to just bypass everything and manually set age to 85%, then see if you can drain to zero. That's a close guess asvto what your proper age will end up being anyway.
[Nexus One Android Development] i6bazar:
I've tried to calibrate my battery (HTC Desire, stock battery, 14 months old, recently advertized with a Batt Age of 87%) because :

1- I was used to get a full charge at 1398mAh (94% of Batt Age) and a shutdown around 5% (with original battery settings)

2- A couple of days ago, my phone shutdown at 12% of battery. I recharged it powered off with the wall charger and since then I got 87% of battery age and a full charge around 1255mAh.

=> I followed the tutorial. (http://xdaforums.com/showpost.php?p=9583271&postcount=340)

When the phone was fully charged, I have shutdown/power it on again. Upon reboot, my Batt Age was still advertised at 100% (I set it to 100% before starting the calibration process).

The mAh capacity now 1425 (Full40 is set to 1452, just before the calibration process, the Batt Full Capacity was something like 1258 mAh)

1- Did I something wrong because I still have a Batt Age of 100% ? Should'nt I get a Batt Age of 1425/1452 = 98% ?!

2- Shall I restore the Min Chg Curr to 40mA or 80 mA ? 20mA is is safe & the best value to use every day ?

3- Shall I restore the Empty Volt to 3.416V instead of 3.201V ? Is it safe for the battery to have an empty voltage of 3.201V ?

Thanks for your support !
[Nexus One Android Development] Deliamber:
Wait a minute. This means that once I do a successful calibration if I ever let the phone discharge to the point it automatically shuts off then the calibration is lost?

That seems weird, and quite inconvenient.

But the calibration will be maintained if I just manually power the phone off, or just do a warm reboot, right?
[Nexus One Android Development] RogerPodacter:
you just manually set your proper age value right back if (and when) it ever resets, because it definitely will reset because th ds2784 chip in this battery keeps resetting itself for some reason, and we cant figure out why.

so periodically your age value will get set back to default, just use the app and set it back to your correct value which you will learn from the learn cycle. heheh.
[Nexus One Android Development] RogerPodacter:
from your numbers i approximate that your age should be around 86% or so. so yes you failed the learn cycle if you see age=100%. just give it a shot you will get it.

you can change min chg current back to stock if you want. i use 40 mA personally, i used 20mA for a while and then thought it might be better at 40mA. its all up to you, no harm either way.

same thing for empty volt. the lower the empty volt, the more capacity you are getting out of your battery theoretically. so if you put it back to stock at 3.416 volts, then when you reach that volt your phone shuts off. at 3.201 volts you get a little more range before shut down...albeit it's not a huge amount. maybe 50mAh i would guess. but its still something.
[Nexus One Android Development] i6bazar:
Ok thanks for your reply.

I will change it to 40mA/3.416V because I think a Li/ion battery gets damaged when totaly empty. Therefore I prefer to have a self power-down at a level not too low because if I don't have a charger at this time, I don't want to damage my battery capacity.

In your opinion, what is the best way to keep its battery capacity :

1- Discharge to something 15-5% then always charge to 100% then

2- Discharge to something 15-5% then charge to any level

3- Discharge to something 1% without reaching the self power-off level then always charge to 100%

4- Discharge to something 1% without reaching the self power-off level then charge to any level

5- Discharge to reach the self power-off level then always charge to 100%

6- Discharge to reach the self power-off level then always charge to any level

7- Discharge to any level then always charge until you reach 100%

8- Discharge to any level then charge to any level

9- Any other scheme ?

Thanks
[Nexus One Android Development] Sharks8:
Unfortunately I had a problem during the process and I want to reset everything like it was before the process. How can i do ?

Thanks
[Nexus One Android Development] i6bazar:
EDIT : wrong thread
[Nexus One Android Development] Dr Byte:
"None of the above"

"None of the above" :)

Charge the battery before it hits 40% or 3.6v, whichever comes first. Avoid starting a charge it when it's over 85%, and never when over 90%. Charge until full, or at least until the green light (90%). Every 3-4 months, run it down and charge it slowly from as low as possible without powering off - preferably with a limited charging current (ie, not the AC charger).

Ideally, the "forming charge" current should be in the range of 10-20% of the theoretical capacity - in the case of a 1450mAh battery, about 150-200mA max.

A normal recharge (or "fast" charge) at other times (600-750mA max).

Regularly running the battery down to 20% or lower will not be good for its longevity. Overcharging at 100% may give the max charge, but it isn't good for longevity either.

So sayeth the theory on Lithium rechargeable batteries. Amen :)

Summary:

normal charges when battery is between 40% and 80%

Avoid starting charging when over 90%

Avoid going below 20-30%

charge until at least 90%, but a full charge may be an hour or more after green light comes on at 90%

Using the phone (display, call, etc) over 90% may trigger an early charge termination (net current <40mA)

Do very occasional "slow" (forming) charges from near-flat, perhaps 2-3 times per year

BTW, I think you are right to revert to stock 3.416v/40mA charging thresholds - HTC really know batteries. They picked these points for good reasons IMHO. It's a pity they didn't pick the most important one correctly: 3000mAh needed vs 1400 delivered :) What use is a sports car with a 5 litre fuel tank?
[Nexus One Android Development] i6bazar:
Thanks for your precise & detailed answer :-)

Your post should be added in the first topic !

I'll try to charge my battery when it reach 40% now (I was used to wait 15% or lower).

When I plug my phone in a computer, I get a charge current around 300mA.

Is there a way to modify the charge current modifying a register ?

Another point, I noticed that once per hour of charge, I get messages such as

Note : I didn't touch my phone during the charge

Is it something normal ?
[Nexus One Android Development] RogerPodacter:
Yes his answer was near perfect. I recharge at 40% when possible.

About the usb charge current, there is no registers we can modify because this is actually limited by the usb port itself. It should be 480 mA thru usb but each pc might be different.

Regarding the timeout errors, we all get these once per hour. Its a bug in the battery driver. Remember in the beginning of this project this caused problems and we had to modify the code to increase poll because the timeout breaks the learn cycle.
[Nexus One Android Development] Dr Byte:
Not that I know of, though I haven't read all the white papers in the OP. 300mA is still an improvement on 800+ for the "forming charge" - you may be able to drop it a little by using a USB hub with a current-limited power supply. Haven't really gone into it too far myself, as I've just bought a second genuine HTC battery.

With CM7.03 and ManU kernel, the "old" battery maxed out at about 80 hours, where the "brand new" one will run just short of five days(!) if used carefully, and mainly on WiFi. Hypermiling can be a fascinating challenge, even if in practical terms it is better to recharge every other day.

Looking at the draw, it must be something quite significant, such as a fairly long 3G data sync, or even the GPS/location service going on for a while, triggering an overall negative current draw from the battery (-100mA << +40 << +300) for two cycles, which in turn seems to be making your charge cycle more of a stutter than a ramp. Try one charge in "airplane" mode and check the log - that'll quickly tell you if it's something running ON the phone, or something the phone is doing/responding to from the rest of the world. Divide and conquer.

Edit: Unlike Roger, I can't recall seeing the [TIMEOUT] messages, so I'll have to have a look next time and see. There are none in my log atm. Hmmmmmm. Edit2: I did see one of them (only one) in the log I kept for the very first charge of the new battery. I defer to Roger's superior knowledge and experience.

If it really is pulsing the charge, it won't be good for the battery.

Now here's an interesting question:

We know that the age is reset to 94% if charging begins with the phone OFF.

What happens if the charge begins with the phone ON, and it finishes with it OFF? Anyone tried it?

(Keeping in mind that the phone isn't really "off" when shut down, not in the way it is when the battery is removed & replaced.)
[Nexus One Android Development] RogerPodacter:
The reason the charge current goes negative is directly because of the timeout bug. We all have this bug it was a big problem during this project and many people were getting it. I compiled the kernel with a 3 hour poll to get around this issue but I don't think we ever merged that change into the final cyan repo cause I think we weren't sure of any side effects. I never did solve why this bug exists, but its definitely there from the stock kernel.

I have a question though, the dmesg log a few posts back has an additional "cm=1" entry. This wasn't there previously. I remember adding additional entries into the batt value in that log, but we ultimately changed it back to stock. Anyone know what this entry is and why it's there now?
[Nexus One Android Development] Dr Byte:
I always assumed it meant "charge mode" with 0=not, 1=slow, 2=fast. Mine reads 0 and 2, and yes, I've trawled up some other logs that show these timeouts.

The charge does seem to abort and restart in fact; the reported mAh goes backward as well, ever so slightly.

Mind you, I'm on ManU rather than CM7 kernel.
[Nexus One Android Development] i6bazar:
Hi,

For your information, my phone was in airplane mode when I charged it, so the TIMEOUT messages are very likely to be independant to an application wakeup.

Moreover, I get this hourly timeout regardless if I am in airplane or not (I'm used to have wifi or 3G disabled when I don't use my phone).

I seems to be definitely related to the bug reported by RogerPodacter.

I'm running on GingerVilain 2.7 & ManU 2.0 HAVS-AXI-BFS

As far as I remember, i've always seen this message in my dmesg.

Maybe I can contact EViollet to see if we can generate a new kernel including the charge patch RogerPodacter has developped ?

Frankly I'm a bit disappointed to be at 86% of Battery Age after only one year of slight usage as I am used to charge my phone every 2 to 4 days.

But it might be to either :

- The charge bug that hurts the battery

- The fact that I was used to discharge my battery before recharhing it (I wasn't waiting the power-down level but something like 15%)

DrByte, which reference of battery have your bought ? You got it online or from a retail store ?
[Nexus One Android Development] Dr Byte:
That eliminates a few things and suggests system function, such as garbage collection - always worth considering. It would be interesting to see how the timestamps look: are they aligned to the time (in your timezone) or boot time, or are they exactly an hour apart, for instance? Perhaps exactly an hour since the last event of its kind finished? I'm afraid I can't translate the timestamps in my head :)

That is not far off where it should be - individual differences between batteries mean that it could have been a marginal sample originally, as opposed to the two "golden" ones I seem to have acquired.

It is, however, quite likely that your battery is not "really" at 86% (aged 14%) but at 94-8 = 86% (ie, aged 8% but from a start of 94) after the initial charge/age reset when you first plugged it in. Meaning, it's probably "really" at 92% (100-"8" for aging). Try setting that age in the application and seeing where the voltage drops below 3.5v - if it's around 10-15%, it's probably about right (based on my own two batteries.)

Batteries are subject to wear; I bought one before my old one dropped below 90% just so I would always have two decent charges available. The experiences of the trailblazers here in this forum convinced me that it was a much better option to pay $45 for one GOOD battery than four useless ones. This has proven absolutely true. You may be lucky with the after-market clone batteries, but usually not. This has been true of previous phone batteries I've bought, too (for Nokias.)

The second battery came from the HTC online accessory store here in Oz, because I couldn't find one anywhere else - let alone anywhere I trusted. The idea was to tide me over for a few weeks/months while the dust settles over the Sensation - but it now looks like I'll be staying with the Desire for quite a while. There are too many niggly issues and the price is just too high for the "a" variant needed for the network I'm on. 40% more than the "e."

...and the dust seems to be settling inside the cases, under the screens :o Oops.

I'm charging my phone tonight starting at on/56%/809mAh/100%age/1452-full40 and turning it off to finish the charge - it'll be intriguing to see what the "age" and mAh charge-level shows when it powers up in the morning. A normal charge with the phone booted should show 100% and 1380-1416mAh.
[Nexus One Android Development] RogerPodacter:
Well if you guys want to take a stab at the timeout bug its right there in the code of ds2784_battery.c file. The reason it happens each hour is because that is the sample poll rate in the driver. I get around this I increased the sample poll to 3 hours in order to finish a learn cycle. So then we would see the timeout happen every 3 hours.

I'm disappointed because the driver code looks solid I just can't see its happening. But just to be clear the code contains this timeout check, so it is definitely by design.

Regarding a 1 year old battery age, unfortunately we know that lithium ion batteries deplete at the same rate whether they sit on a shelf ir are constantly in use. Best to just buy a knew one.

This thread project in a way was like hitting the jackpot because we all read about how lithium batteries behave but always took it on faith that its true. But because we cracked open full access to this ds2784 chip we got full control over it to really see how this works. Other phones don't give this opportunity. For example it showed the difference between the genuine and cheap knockoffs and how the cheap ones use locked registers hence the cheapness.

About the charge mode entry, I just don't see it in the driver. It probably has been added to the kernel you're using.
[Nexus One Android Development] RogerPodacter:
At line 767 is timeout checks:

https://github.com/CyanogenMod/cm-kernel/blob/android-msm-2.6.37/drivers/power/ds2784_battery.c

It also continues further down in the "battery adjust charge state" function.

And specifically line 830 is where you can increase the poll rate. I changed

else if (di->last_charge_mode != CHARGE_OFF && check_timeout(di->last_poll, di->last_charge_seen, 60 * 60))

To this

else if (di->last_charge_mode != CHARGE_OFF && check_timeout(di->last_poll, di->last_charge_seen, 60 * 60 * 3))
[Nexus One Android Development] Dr Byte:
Charging while on, then finishing while off?

Don't do it. Same result as charging from off.

The age reset to 94%, it maxed at 4140mV, and 1340mAh.

Interesting - so there's more going on here than meets the eye; I thought the chip "defaulted" to 94% as a safe guess when it had no better information at the start of the charge. It seems otherwise.

I'll be charging with the phone booted from now on :)
[Nexus One Android Development] RogerPodacter:
Other ds2784 chips do not reset like this. It only happens with htc oem batteries. The ds2784 in the palm pre doesn't do it. And a seido battery for the nexus one doesn't reset.

So we think the htc is just a cheapo version of the chip.
[Nexus One Android Development] temasek:
My current battery (aftermarket type) still at age 96% :)

Just tested if it still drains till 0% and yes it does. With the low power consumption of CM7 ROM now and a well calibrated battery, well I'm contented.

Woot! :D
[Nexus One Android Development] waylo:
Which version of cm7 are you running, many I ask?
[Nexus One Android Development] temasek:
I am still on cm7 build 143.
[Nexus One Android Development] waylo:
Thanks for the info. I've recently started getting just ridiculously atrocious battery life for about a week. Trying to track down if it's my battery suddenly dying out or some rogue app. Battery use metrics don't show anything too unusual. New supposed OEM battery is on its way, so we'll see.
[Nexus One Android Development] Dr Byte:
I've had a look at the module, and a few things have me interested; I can see roughly what is happening, but it is hard to prove without instrumenting the code and recompiling it. In particular, I'd like to see the value of di->status.current_uA at line 830.

Two immediate possibilities:

current_uA is invalidated for some reason and is <1mA when tested

di->last_poll isn't being updated correctly

Clearly, to get to the code where the timeout is detected, current_uA is flat or negative - otherwise, the other branch of the if() would be taken, and the last_charge_seen would update.

There are too many code paths to check without knowing the values of

di->status.current_uA

di->last_poll

di->last_charge_seen

as at line 831. I'd love to see someone's log showing a charge cycle with those values emitted as diagnostics. Just knowing the last two values will probably be a slap in the face and point at the time where the problem originates.

I know that the temperature branches aren't active, because my log shows about 29.5 degrees, well below the active zone.

I have some other theories, but this is the most likely and easiest to test. (a few relate to typecasting, particularly with check_timeout() - but would be exposed by the above anyway :)

At a guess, there may be a race condition or missing/dishonoured mutex reading and decoding the registers.

I have to be elsewhere tonight, but perhaps someone can build a kernel with the instrument required? If I am to do it, I'll need to start with ManU's kernel sources and work out _everything_ I need to build one from scratch. I've never needed to know how!
[Nexus One Android Development] RogerPodacter:
I wouldn't mind testing your theories. I am setup to compile the kernel right now with one catch, its the cyan 6.1.1 kernel. My build environment is frozen such that I could change the code and have a kernel in a minute. Haven't updated my repository to gingerbread yet.

All we need is someone with a nand backup of Froyo lying around, restore it, flash the kernel and see.

Also I could rearrange the code that spits out the dmesg log of batt values and place it where the code path in question is located, and add

di->status.current_uA

di->last_poll

di->last_charge_seen

To the log. Unless I'm wrong, that would spit out the needed values anytime the timeout occurs.

Like I said a modified Froyo kernel could be ready in minutes. Otherwise its hours of syncing the repository.
[Nexus One Android Development] Dr Byte:
Gotos considered Harmful :)

I think I might have something here.

I've checked the source of the EVoillet (ManU) kernel and it has some interesting differences in charge termination (it actually reads the %, the CHGTF flag etc).

However, during a normal uneventful charge cycle, neither driver actually updates di->last_charge_seen = di->last_poll unless the charge_mode has actually changed. Which will only happen if something very odd happens, like the cable being unplugged.

The goto at line 864 (cm7) or 877 (ManU v2.0) would appear to prevent last_charge_seen from ever being updated, EXCEPT at the start or end of a charge cycle (ie, when the state changes). Ironically, the state-change forced by the timeout code triggers the next charging stage in this way. This may repeat 2-4 times or more depending on the battery % and input current.

Thus, the fix would appear to be as simple as adding the code in italics:

if (di->last_charge_mode == charge_mode) {

if (charge_mode == CHARGE_FAST || charge_mode == CHARGE_SLOW) di->last_charge_seen = di->last_poll;

goto done;

}

As for the earlier question about whether it is possible to limit the charging current (do a slow, forming charge) the code would suggest that it might be possible - however, it would need some external control (a kernel variable, a "trick" battery register setting, such as an "odd" value for min.chg.current). Eg, 33mA instead of the common 20mA or default 40mA setting.

I'm sure there are much more elegant ways to get this information into the driver; I'm just thinking like the proverbial handyman who already has a hammer in his hand and sees everything around as a nail :)

A slow charge mode would be a sweet addition, if it actually makes a difference to the way the battery chip feeds energy into the battery; a slow charge *should* be better for longevity, but it's something I'd like to have control over. I guess the next stop is the chip documentation. Or a kernel hard-wired to always charge in "slow" mode, just to see how much it draws. I'd be willing to give that a go.
[Nexus One Android Development] RogerPodacter:
ahhh looking at Eviollet's repository, the previous version of the driver is being used. that's why you see in the cyanogen repo that function is only checking the CHGTF in the status reg, but in the previous version there were additional checks in that "if" statement. in that "if" statement there is the check we added to stop charging at <= 40 mA. but that is now unecessary as we can just set that associated register to do the same thing.

I think i see what you're getting at. only one way to see and that's to try it out and test it. if it works you've got a sharp eye there my friend:D. i'm gonna try to update my repo to GB tonight. before i do i'll quickly compile a froyo kernel with that change, since it will only take a minute. maybe i'll be able to compile a GB one as well.
[Nexus One Android Development] waylo:
Aside from losing maximum capacity, what other signs indicate a dying battery?

I did a learn cycle yesterday (an adopted technique, I've never managed to get a normal, self-setting battery age calibration cycle to work) and my battery is ~89% after 6 months of use.

But since this last week, a full charge will only last to mid-afternoon, markedly less than before, with no increased use or activity.

EDIT: Never mind, found this thread:

http://xdaforums.com/showthread.php?t=1190155#

T-Mobile issue. Some crap involving 3g/"4g" updates.
[Nexus One Android Development] mtw4991:
I'm watching this new development with baited breath!