yashsingh1/xdaforums huggingface dataset:
[Nexus One Android Development] samarium:
<<8 means shift up 8 bits, ie 0x12 == 0b10010, and 0x12 << 8 becomes 0x1200 == 0b1001000000000

>>5 means shift down 5 bits, ie 0xd7 == 0x11010111 and 0xd7 >>5 becomes 0x06 == 0b110

| is just a bitwise or operator which, as long as there are no bits overlapping, is the same as +

So when looking at the extraction of an 11 bit temperature value from those two locations above, DS2784_REG_TEMP_MSB & LSB (most significiant byte and least significant byte) in the code segment, I would have to say that it looks wrong. If we are doing raw[LSB]>>5, then we are only getting 3 bits of data, but if we do raw[MSB]<<8 we create 8 bits of space below the 8bits of data we already have. Seems like we should be doing (raw[MSB]<<3)|raw[LSB]>>5 which would leave us with an 11bit number, rather than the code, which would leave us with the potential for a 16bit number. Seems like I'll have to read the doco some more.

Uhe underlined #defined values seem to be merely offsets into the ds2784 register/eeprom space, per page 29 of DS2784.pdf, and I guess that the raw array in ds2784_battery.c is used as a buffer, although I haven't looked to closely at the code.

the AE_SLOPE bytes are at least partially described in DS2784.pdf at page 21-23, and as a first guess isn't something I think we need to play around with

seems like the AN4043.pdf roger provided has most of the formulas needed?
[Nexus One Android Development] samarium:
That is a fallback, however since I'm currently using a WM kernel, it is possible he has some config options that aren't in the CM kernel, and I was planning on probably basing of pershoot's or IR's kernel, since I haven't found a git for the WM kernel.

Yes, I found that to and it seems to have worked, and although it seems I have a successful build, I haven't loaded it onto my phone to test as yet.

I've been meaning to play with git for a while, however I've just found a good enough reason to use it in anger, so expect to be up to speed soon enough for basic work, and frustrated by my limitations so I'll learn some more.

As for the fork/pull, as long as the work is sufficiently isolated I don't think it will matter which kernel is the base as ds2784_battery.c should be pretty much the same, and we should be able to get git to co-operate, however time will tell.
[Nexus One Android Development] theloginwithnoname:
I'm going to give WM's kernel a go, as I'm hearing nothing but good stuff about it. Anyway, back to CM - I've attached the one I used to build my last kernel (35.7). Copy/rename it to ".config" in your kernel source root!

Trust you know the steps (fastboot flash zimage <filename> etc)?

agreed. I suspect it will be a fork from cm-kernel, as that is where the ds2784 file "officially" sits (it came from the Desire source which is not available via git, only the HTC site)
[Nexus One Android Development] carbontulip:
Hey guys,

I just wrote this battery calibration app. Here is a link: hxxx://rapidshare.com/files/432721855/BatteryCalibrator.apk

Please note: this is for ROOTED phones only!

Enjoy!
[Nexus One Android Development] apratomo:
What does the app do? Can you put it on somewhere friendlier such as mediafire?
[Nexus One Android Development] theloginwithnoname:
A very good question to which I'm not expecting an answer from the "author" ;)
[Nexus One Android Development] RogerPodacter:
wow we're getting spammed for battery apps! i wonder if its a "generic" one or if it uses the proper stuff!! (doubtful!).

anyway when i read back over the beginning of this thread, its cool we actually made it all the way to final working method!
[Nexus One Android Development] mtw4991:
Roger, is your app fully functional now?
[Nexus One Android Development] RogerPodacter:
its working to hit learn mode, but its not technically done as the second tab isnt written yet. perhaps we could do a few small beta tests with 1 or 2 people at this point? since its the break i wont be doing any more work till next week, so rather than leaving you guys with nothing for 5 days maybe it would be a good time for a few people to at least play around with it? i dunno what noname or dvhgrl thinks on that...
[Nexus One Android Development] mtw4991:
Roger, just saw your PM from yesterday. Shoot it on over and I'll help to whatever extent I can.
[Nexus One Android Development] dvgrhl:
Here is the app. You can install it via adb. Roger didn't have much time to leave any instructions except to say tab 2 doesn't work right now. This is still just a very rough app, so any feedback is appreciated.

http://jonrichards.net/xda/BatteryApp.zip
[Nexus One Android Development] apratomo:
so same question :D, what will this app do?

easier access to set register and help us hit learn mode?

edit: nvm I just installed, so could someone list what features that are working right now?

I'd really want to hit learn mode, but very much confuse following all these thread speaking about hex code :D
[Nexus One Android Development] samarium:
Thanks.

First pass, looks good, however the registers page should use a fixed width font for the register dump, and probably should output each line with 8 values in portrait mode.
[Nexus One Android Development] chowlala:
You need to understand the hex code value in order to hit learn mode. Lol.

If you really want to do learn mode, you can follow the first fix on the first post at the battery calibration thread.
[Nexus One Android Development] mtw4991:
That's where I got mine and it's good but others haven't been so good luck!
[Nexus One Android Development] k3vink3vin:
That reading seems unreal...

But the stock battery only holds 1230mAh :rolleyes:

And people are complaining on battery life, same for its 3G brother (Desire HD)...

Oh well I guess every smart phone user does :p

http://community.htc.com/na/htc-forums/android/f/113/p/9582/41123.aspx
[Nexus One Android Development] heinz gruber:
strange:

i've set the age back to 87% but when i divide the capacity (mAh) 900 with the full40 value 1452 i get 62% but my actual percentage is at the moment at 72% does that mean, that the nexus will shutdown at 10%?

thanks...
[Nexus One Android Development] temasek:
Full40 = 1452mAh

Age = 87%

Max capacity at 100% battery level base on age of 87% = 1452 x 87% = 1263mAh

Current capacity = 900mAh

Battery level at 900mAh = 900 / 1263 = approx 72%

Nothing is wrong.
[Nexus One Android Development] mtw4991:
I doubt your true full40 is 1452 anymore due to its' age. If you set full40 to 1265, then 72%=900mAh approx. and you should be good to go.

Edit: I should know better, Temasek is lightning fast O_o ;-)
[Nexus One Android Development] heinz gruber:
argl! my fault :)

by the way, i've orderd this battery too http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=270650209530

i've read 2100mAh are not good? and they make the nexus fat.
[Nexus One Android Development] temasek:
Max is 1600mAh if u are to use your stock back cover. Anything above 1600mAh u have to use extended cover which will make your nexus look fat.

If u looking for extended battery get 3000mAh and above better.

Its a good practise for your next battery. Now u are semi pro in battery calibration. :D
[Nexus One Android Development] heinz gruber:
YES!:D

what are the full40 values for 1600mAh and 3000mAh?

and about the 3000mAh: i only find offers from hong kong for about 15€. do you think they are worth?

and what is the biggest battery for the nexus one?
[Nexus One Android Development] temasek:
Don't think of getting a super rated one. If u can get a standard rated 1600mAh u are already lucky. :p

Biggest battery for nexus one is 3200mAh

To test your new battery max potential capacity, you have to perform something similar to a learn cycle.

Search this thread for "Capacity Test" posted by myself.
[Nexus One Android Development] Nighthound:
I just received my HK battery! *excited*

I went to search for temasek's capacity test post, but now I have a few questions.

A) The battery arrives with 0% capacity (ie fully discharged). Do I charge it to max first before doing anything, or do I perform the learn cycle from this point?

B) When you say "Perform learn cycle" in step 1, what value should I use for Full40? I would assume Age is 100%.

C) For step 5, I will need to observe what is the peak charge before it drops to the manually set Full40. How do I check that in the log?
[Nexus One Android Development] temasek:
Plug-in and charge for abit and proceed to Battery App and check your full40. If full40 is about 1600mAh then its ok. What is needed is to let the battery know what is its empty point. So perform a learn cycle based on the acceptable full40 first.

For the 1st learn cycle, actually it is not important whether it is successful or failure because you are testing the capacity. If the potential max capacity is higher than the set full40, then during the learn cycle, it will climb beyond your set full40. Once the charge flag is turn on, u will see the capacity drop below your full40. So look at the log and see what is your highest mAh achieved before the drop.

Example,

1. Plugin and charge your phone, power up.

2. Open the Battery App and check its full40. If its acceptable then leave as it is. If not then maybe set 1600mAh as the initial full40.

3. Set your desired Empty Voltage point

4. Set your desired min charge

5. Set your age to 100

6. Start your learn cycle (w/ capacity test)

7. Success or failure (not important)

8. Once charge flag turned on, see the log for highest mAh before the drop below full40. Eg, if highest mAh is 1800mAh at 99% then hit 100% and capacity drop to 1550mAh. Then your real full40 should be 1800mAh.

9. Perform real learn cycle based on new full40.

Good Luck
[Nexus One Android Development] Nighthound:
disregard this post
[Nexus One Android Development] temasek:
The app itself has a log or u can osmonitor, free in market.
[Nexus One Android Development] Nighthound:
lol i saw the built-in log a few minutes after I posted, but you already replied :D
[Nexus One Android Development] temasek:
I'm that fast. :p
[Nexus One Android Development] Nighthound:
I attempted the first learn cycle, but I don't know if I messed things up or not. My settings were:

full40 = 1600

age = 100

empty volt = 3.201

min charge = 20

I activated learn flag, then let it charge. Towards the end however, I switched on the phone (to check if charging was complete, I was afraid if I wait too long the values may scroll out of the log buffer) BEFORE the charged flag was set, and that broke the learn cycle. At that point, capacity was 1620 and percent was 100%. Actually percent was at 100 from ~1600 onwards (which I guess is because my full40 was set to 1600). Subsequently, capacity dropped to 1587. After rebooting, Age is 100% (which should be correct since it's a new battery).

So what should I do at this point? Do I need to redo the first learn cycle, or can I use 1620 as the full40 for the second learn cycle?
[Nexus One Android Development] temasek:
That's a pretty good value. As I said earlier, a 1600mAh rated battery should work like a 1600mAh battery. (+/-).

U can set 1650 as your full40 and perform a new learn cycle. This time, don't peep! Lol. :)

Congrats on having a good battery!
[Nexus One Android Development] Nighthound:
Sweet, I'll do the second learn cycle once I finish draining this charge. :) Thanks for the help!
[Nexus One Android Development] temasek:
You should get age of 100 after a successful learn cycle. If u don't I means that your full40 is not achievable.
[Nexus One Android Development] :
any one try this 1800 batt http://cgi.ebay.com/1800mah-Battery...Accessories&hash=item3a63448e62#ht_2476wt_698
[Nexus One Android Development] temasek:
I'm curious too. I saw this way before I got my 1600mAh battery. If anyone got it, pls let us know the results.
[Nexus One Android Development] mtw4991:
just an fyi...

My 1600mAh battery that I got in early December came with only about 1550mAh capacity, but still better than stock obviously. I did a couple of capacity tests and now after 3 months it is charging up to about 1490-1505mAh depending on temp., so for ****s/giggles I did another learn mode, which completed successfully using 100%age, 1600mAh, 3201/20 and it

correctly

reset my age to 94%. This is what I calculated manually. Moral of the story is sometimes your age really is 94%, not just on learn failure :D
[Nexus One Android Development] ellesshoo:
I ordered one today. Will report back when I receive it.
[Nexus One Android Development] temasek:
Cool. Looking forward for your results.
[Nexus One Android Development] Nighthound:
Finished my 1st charge, now doing the second learn cycle with full40 = 1650. This time I'll just let it charge for 6 hours without turning on the screen lol.

By the way, is there ongoing development on the battery calibration app? I have a suggestion. For the learn mode page, is it possible to add a button at the bottom of the page to manually bump mAh by, say, 100mAh? That's for occassions when the auto-bump doesn't kick in. I know I can go to the learn prep page to manually setreg 0x10 01, but I'm lazy, and I thought this would be a great addition :)
[Nexus One Android Development] temasek:
The dev for Battery Calibrator (dvgrhl) had lost his Nexus One and had move on to a different phone. Dvgrhl had mentioned that he will no longer be doing further developments to this app, leaving only RogerPodactor as the last dev for this app.

Fyi
[Nexus One Android Development] RogerPodacter:
Yeah I believe dvgrhl is not doing anymore work on the app. I will be glad to do what I can with updating it, something like adding a simple button to bump up mAh could be done quickly. I honestly just lost steam with learning new code so I kinda stopped working on it for a few weeks. I just wish I was more efficient at it.
[Nexus One Android Development] temasek:
Your contribution to our Nexus One battery calibration app & its drivers will always be deeply appreciated by many.

Thanks :)
[Nexus One Android Development] mtw4991:
+100000 thanks from me too
[Nexus One Android Development] Nighthound:
My second learn cycle finished properly. Capacity was 1630mAh and age 100, using settings of full40 = 1650, empty voltage = 3.201 and min charge = 20.

Should I bring my full40 down to 1630 in this case? Because the moment I unplug the charger, after less than a minute it already shows 99%.
[Nexus One Android Development] Old MuckenMire:
Yeah I have to add my thanks as well. This app finally gave me some control over my battery and is much appreciated. :)
[Nexus One Android Development] mtw4991:
For Login or Roger

Login, can you please update the instructions (cut/paste) on post#3 of the OP from here:

http://xdaforums.com/showpost.php?p=9583271&postcount=340

I rewrote the instructions today as the original was a bit dated considering how far the app has come and may help avoid redundant questions. Also, I included Temaseks' instuctions for doing a Capacity Test at the bottom for easy reference.

Roger, if you see this, please forward to Login. Thx!:)

Also, if anyone sees anything I missed or need to correct just let me know.
[Nexus One Android Development] RogerPodacter:
yeah it really was an awesome project. it was only because the perfect unique situation occured with that particular battery chip model, with a super data sheet, driver source from google, and the palm pre guys, where it really made for such an awesome project to do. we hacked the damn battery! android and its crazy openess...

i keep checking new android phones, but none seem to have the same ability to do what we did with the nexus batt...
[Nexus One Android Development] RogerPodacter:
i too see it drop from 100% to 99% within a minute. it frustrates me a little, but i think it just just the way mAh is counted and not much we can do about it. i think if you changed your full40, it will just re-adjust itself to the new setpoint and drop just as quick. you could trick it the first time where it would stay at 100% for a long time, but it would correct itself on the next full charge...
[Nexus One Android Development] temasek:
Same. But I'm not complaining. In fact I'm happy that my battery is evenly spread from 100 - 0%.
[Nexus One Android Development] theloginwithnoname:
Roger that! erm, I mean Wilko!!

(done ;))
[Nexus One Android Development] mtw4991:
Thanks dude:p

T, see anything that needs changing? Did the rewrite on the back porch after a couple of beers...
[Nexus One Android Development] ellesshoo:
I've been thinking... how can we assume the mah we see in our logs is the true full 40 if 1) we're almost certainly not performing a learn at 40C 2) we'd be able to charge to a higher capacity if this could be done with the phone off?

Also, is it normal, even after successful learn cycles, that under regular use 0% is reached well before 3.2V (usually around 3.6V on my 1600mah battery)?

Speaking of my 1600... I got it back in October 2010 and my latest learn cycle (today) it dropped under 20mAh after hitting 1608mAh. Pretty damn good IYAM.
[Nexus One Android Development] RogerPodacter:
Well the first question, the mAh is adjusted by the ds2784 chip based on the actual temperature of your battery at that time. It uses 4 programmed break point temperature slopes to interpolate At any given time.

The bump charge when phone is off just allows charging to bypass the min charge current parameter and squeeze in that last bit of charge.

You should not be running out of mAh before reaching your empty volt, so you prob should experiment with a larger full40 value so you get to use the full range. And/or adjust your age higher to compensate. It's really a balancing act. The harder you use the phone, the voltage will drop faster than the mAh can be counted. The lighter you use the device, the longer it can go and be more accurate. This is the problem with this type of coloumb counting. Using voltage in a more direct way is likely a better solution, or a combo of the two would be ideal.
[Nexus One Android Development] mtw4991:
I haven't tried to do a bump charge after a successful learn cycle but that's interesting, if we could do both? My mAh always dies before mV, so I'm going to try to tweak it some. Also, my #600 battery rarely will charge above 1490 and I got mine in december.
[Nexus One Android Development] temasek:
Bump charge requires power off charging and if u power off charging, your battery age will reset itself to 94%.

Hmm your statement rather interesting. My mAh will die about the same time I hit my Empty Voltage. Always.

-At age 100, same

- At age 99, still able to

- Now at age 98, still able to

Note that my Battery Age auto drop from 100 to 99 to 98 (this is only possible for non-stock batteries).
[Nexus One Android Development] mtw4991:
Yeah, I know about the bump charge resetting to 94%. Usually, I can get down to the 3400mV range before it will die, but never seen it get to 3201'ish. It's almost like it is ignoring the 3201 and sticking with 3416 even tho it shows otherwise.

Suggestions for testing?
[Nexus One Android Development] temasek:
At 1% my voltage is already below 3400mV. At 0% my voltage usually very close to 3201mV. If your learn cycle is done properly, mAh will deplete very close to your Empty Voltage level. I've no idea why some including yourself cannot hit that. My only conclusion is that your learn cycle is not considered successful.
[Nexus One Android Development] mtw4991:
It completes just fine and gets down to <1% with 10mAh remaining, but mV never near 3201 unless the learn mode is turned on, so idk?
[Nexus One Android Development] ellesshoo:
Same here. I'm going to double check at the end of today though.
[Nexus One Android Development] Rickbob:
learn mode

Hi all, im doing everything mentioned in post 3 about achieving learn mode but when my mV hits 3200 and the learn flag and popup shows i plug my charger in but i dont get a learn mode achieved message instead the phone just charges??

when fully charged i restart the phone and the battery age is 89 or 94% but never 100%?

Im running a HTC desire with stock battery on GingerVillian

Can anybody help?

Thanks

Ricky
[Nexus One Android Development] __max__:
Strange.. mine is a stock one and my age auto drop from 91 to 90 to 89.. :rolleyes:

Happens to me too, every time, tried to raise my age but that didn't help.
[Nexus One Android Development] temasek:
Stock = battery that comes with your nexus one, not another HTC battery.

But maybe what u say is true cuz I never really tested stock battery that much. The info was from loginwithnoname
[Nexus One Android Development] mtw4991:
Raising age didn't help mine either. Next I'm gonna try lowering age just a bit...
[Nexus One Android Development] __max__:
I didn't buy any extra battery, I'm still on the one that I found inside my nexus (a new one, not used).

Idk how it is supposed to work, but I notice my battery age going down without doing any learn cycle.
[Nexus One Android Development] temasek:
Good info thanks!
[Nexus One Android Development] __max__:
I read in this thread that at 80% age the battery is to trash.

First time I made a learn cycle I had factory settings and the result was 86% age.

Then I made some changes, min chg at 20 and empty volt at 3201, settings that I still have, and my age raised at 91%.

Now I have 89%, so with factory settings I should have 84% (didn't try).

The 80% is a number found with standard settings?

If so, that means my battery is nearer than I think to the dead line?
[Nexus One Android Development] temasek:
Age 80% of default settings = bye bye

But.......

Your battery still usable. Its just an indicator, not really mean that battery is dead.

I had my stock battery at 86% when I decided to grab a new 1600mAh battery. It was a great decision then for me. :)
[Nexus One Android Development] ellesshoo:
So that 1800mAh battery from Andida arrived today. It appears like it's slightly larger than stock, I had to press it in hard but it does fit. It came charged to about 45%. Here are some shots of the register values it came programmed with.
[Nexus One Android Development] mtw4991:
ugg, looks like you got one of those NON-programmable batterys, unfortunately. The register values are all f'd up :(
[Nexus One Android Development] temasek:
I would have to agree with mtw4991. :(

On a side note, your battery may be a good one just that it cannot be calibrated. Test it out .......
[Nexus One Android Development] System of a pWne!^:
I need a bit of clarification:

I've got a HTC Desire with CM7 on it.

The app showed me an age of 85% (according to this thread, this is bad).

I performed all steps and now it shows 87% after a reboot.

Does this mean I should trash it? Or do I "only" (actually it's a lot) miss 13% of capacity.

Also: Does doing the calibration several times improve the situation?

I'm still confused why my battery was at 85%. I always loaded my phone properly with charge < 40% and always > 15%. I just had it once that it drained all battery (searching for a net). Could this already be the reason for that age (one accidental discharge?)
[Nexus One Android Development] __max__:
Ok, thanks!

I'll keep my battery until I can last one day with the phone working :)
[Nexus One Android Development] temasek:
Battery ages with the number of charges u performed. In simple terms it ages with time. Battery cannot maintain full capacity throughout its life cycle.

Performing a learn cycle does not improve your battery capacity. Only by changing the battery registers u may squeeze abit more of your battery potential.

Basically the battery does not know its empty point so by performing a learn cycle the battery will know its empty point, ie 0%.

Hope the above clarify abit of info.
[Nexus One Android Development] System of a pWne!^:
Yeah, most of that is common knowledge. But in that "short" time (10 months), it aged over 15% and I was quite "nice" to the battery. The worst things you can do to a LiIon battery are (deep) discharge (so keep it at above 7-10% when you recharge it) and overcharging a cell above 4.2 V because both an make your battery age really fast.

Anyway, thanks for the reply. I will keep on using that battery and buy a new one next year.