yashsingh1/xdaforums huggingface dataset:
[Nexus One Android Development] RogerPodacter:
well the reason it dropped from 2050 down to 1750 upon full charge is because your full40 is set to 1800, so that makes sense. 1800 would be the jump point at 40 degrees celcius, but you were likely around room temperature, hence it went to 1750.

if these are new batteries you are testing, i would first leave stock full40 value and charge to full, then drain to empty and see what happens, does it die early? can it make it all the way down to empty volt? does it run out of mAh? then based on those findings start screwing around with changing settings.

once you set full40 to 2100 then full charge hit 2030 which again makes sense since you were prob at room temperature or somewhere lower than 40C.

i dont know why the learn indicated a higher point, it may need another go at learn cycle. sometimes the mAh meter gets offset and falls out of alignment from the ACR reg, and you end up with that situation. last night on my flight i charge to full before i left, used the battery half way, and last night somehow when i re-charged it went all the way up to 1535mAh until CHGTF hit and it jumped down to stock 1430 value. that 15xxmAh wasnt true higher usage, it just fell out of alignment for some reason. which is why the data sheet says that the mAh gets reset at 2 points, when empty volt is hit, or when CHGTF is hit. which is what we see it resetting itself. dont know why it gets offset though...?
[Nexus One Android Development] RogerPodacter:
i think only phones using the DSxxxx chip would possibly have this problem. but maybe only the ds2784 specifically, which i think the desire is the only other android to use it.

its definitely the chip. we do see the android OS driver interact a little bit with the battery, like reading the status reg and sometimes writing a register here and there. but 99% of things is done completely inside the chip and has nothing to do with android OS. we know the chip calculates percent, mAh, temperature, voltage, current, all of it is calculated by the battery's chip and then just reported to the OS in the form of registers which are read from the OS/driver. the important registers are actually called "result registers" and there are 7 of them which perform calculations and are updated every 3.5 seconds. dont think the OS is doing squat really.

so it would have to be wrongly programmed ds2784 chip, or they altered it somehow. that's my guess.

BTW noname, i forgot you have a desire there. how feasble would the next project be to include the desire in all this?
[Nexus One Android Development] RogerPodacter:
you know one thing i have noticed since ssetting my min charge current to <20mA is that it seems my battery drops from 100% to 93% much more quickly. i know if you look at a discharge curve for li-ion they show the very tiny top end wiht a drop like this, then it flattens out. question is, is it still worth it as we are still reclaiming that little but of upper end that we didnt have before, even though it might visually drop a little quicker? anyone else notice anything like that?

the steep drop usually starts around 4.2 volts onthe curve, and now we <20mA i get pretty close to that, i hit about 4.19 volts. with stock setup, and <80mA, we only hit around 4.15 or so, which is under that drop and in a more flat portion of the curve. which setup is better?
[Nexus One Android Development] mtw4991:
Damn, just got down to 3.180mV when it was set to 3201??? had done 0x10 04 to keep mAh up. Seems I'm never getting the learnf to light up. aef/sef light up but no learnf or toast popup. The "plug in now" toast popup only happened once, days ago, but it timed out prior to completing the full learn charge.

Any suggestions?
[Nexus One Android Development] mtw4991:
Yeah, I've noticed that also but I'm not sure it makes a difference. The max I have ever got was 4197mV, but usually it shows 4182 or 4187mV. Seems like 6 of one/half dozen of the other...
[Nexus One Android Development] samarium:
See my post in the other thread, about using 10 1 rather than 10 4, seemed to work better for me, however I hardly have a reasonable size sample space.
[Nexus One Android Development] myakove:
what is the 0x27 flag in statusreg?
[Nexus One Android Development] rault18:
this thread is so full of win.unfortunately a win that I have no ome idea how to understand

I'm scared of running the app as I have no clue what are those numbers about lol
[Nexus One Android Development] RogerPodacter:
0x27 = 0010 0111

[CHGTF] [AEF] [SEF] [LEARNF] [X] [UVF] [PORF] [X]

very rarely some people see their PORF and UVF turned on, not sure why. i've never seen those turned on even once, even if i've left the battery out of the phone for weeks. wish i knew how and why they are sporadic.
[Nexus One Android Development] RogerPodacter:
no worries, running the app can do no damage whatsoever in its current state. i'm working on writing up a nice tech help section at least to explain things as best i can so its easier to see what's happening.
[Nexus One Android Development] rault18:
they would be awesome sir!! props to you guys for creating such a cool app
[Nexus One Android Development] myakove:
This is new 1600 battery that I ordered, just got it and put it on the phone and get this reg.

Also can you explain what each of those mean?

Thanks
[Nexus One Android Development] RogerPodacter:
In that case, I've read before that a new battery will have some things set on initial power on only, then cleared after the first use to never come back. However we've seen others with those flags come on repeatedly, so really I don't know.
[Nexus One Android Development] myakove:
thanks for your reply.

Is this normal that I charge the battery for hour and 15 minutes and only get 38% till now?

<6>[ 4667.421600] batt: 36%, 4162 mV, 147 mA (149 avg), 31.5 C, 580 mAh

<6>[ 4717.520812] batt: 37%, 4157 mV, 156 mA (152 avg), 31.5 C, 582 mAh

<6>[ 4767.629821] batt: 37%, 4162 mV, 149 mA (148 avg), 31.5 C, 584 mAh

<6>[ 4817.735504] batt: 37%, 4148 mV, 95 mA (114 avg), 31.8 C, 585 mAh

<6>[ 4868.731292] batt: 37%, 4157 mV, 130 mA (109 avg), 31.8 C, 587 mAh

<6>[ 4918.868225] batt: 37%, 4162 mV, 143 mA (145 avg), 31.8 C, 590 mAh

<6>[ 4968.966186] batt: 37%, 4162 mV, 140 mA (139 avg), 31.7 C, 592 mAh

<6>[ 5019.077301] batt: 37%, 4157 mV, 103 mA (139 avg), 32.0 C, 593 mAh

<6>[ 5069.184020] batt: 37%, 4148 mV, 24 mA (56 avg), 32.6 C, 595 mAh

<6>[ 5119.305572] batt: 38%, 4153 mV, 87 mA (86 avg), 33.1 C, 596 mAh

<6>[ 5169.470611] batt: 38%, 4153 mV, 103 mA (102 avg), 33.3 C, 598 mAh

<6>[ 5219.575012] batt: 38%, 4153 mV, 105 mA (101 avg), 33.5 C, 600 mAh

usually I get around 600 mA with the original battery.
[Nexus One Android Development] myakove:
I have charge the new 1600 battery and it's jump from 43% to 100%.
[Nexus One Android Development] RogerPodacter:
i wouldnt panic just yet. now do a full drain from 100% and see what happens near the bottom, i.e. the empty point for volt and mAh. by the way when it jumped from 43 to 100, what did the mAh number jump to? and what is the full40 value of your 1600 battery? its AEvolt setpoint? maybe post your dumpreg screenshot...

anyway i had purchased a new stock battery and charged it to full then left it sit on my desk for a few weeks. when i popped it back in the phone, the voltage was still around 4 volt but the mAh somehow read like 700mAh. so when i charged it it only took in a small amount of mAh before hitting full charge. once that happened, the mAh and volt got lined back up and it worked normally from that point forward.

your 1600 battery probably just sat around for a bit and it should realign the mAh with the volt after your charge to full. keep us posted...
[Nexus One Android Development] myakove:
Here is the jump:

<6>[ 9888.765869] batt: 42%, 4187 mV, 22 mA (20 avg), 29.5 C, 673 mAh

<6>[ 9948.844573] batt: 42%, 4187 mV, 26 mA (24 avg), 29.3 C, 673 mAh

<6>[10008.915130] batt: 43%, 4187 mV, 19 mA (21 avg), 29.3 C, 673 mAh

<6>[10068.981628] batt: 100%, 4187 mV, 19 mA (19 avg), 29.3 C, 1582 mAh

<6>[10069.009826] batt: charging BATTOFF [FULL]

<6>[10129.049957] batt: 100%, 4182 mV, -1 mA (-1 avg), 29.3 C, 1582 mAh

<6>[10189.010070] batt: 100%, 4182 mV, -1 mA (-1 avg), 29.3 C, 1582 mAh

<6>[10249.073730] batt: 100%, 4182 mV, -1 mA (-1 avg), 29.3 C, 1582 mAh

<6>[10309.147003] batt: 100%, 4182 mV, -1 mA (-1 avg), 29.3 C, 1582 mAh

I set the full40 to 1600 and AEvolt to 3.201
[Nexus One Android Development] RogerPodacter:
Yeah I would just see how low you can drain it before worrying. Looks fine to me so far. Do you remember what the stock full40 value was set to on that 1600 battery before you changed it?
[Nexus One Android Development] myakove:
It was like the original battery 1452
[Nexus One Android Development] RogerPodacter:
Ok that's just insane. We've now seen pretty much every type of after market battery out there come incorrectly programmed from the manufacturer out of the box, and in such a way that it completely negates the point of having an extended battery by only letting the phone use as much as stock capacity. No wonder so many people complain! I wonder how many people out there don't even know this.
[Nexus One Android Development] myakove:
But can we really know that this is 1600 battery or it's exactly like the stock battery?

Right now I'm on 48% with 768 mAh
[Nexus One Android Development] RogerPodacter:
you wont know till you drain it all the way to empty and see how much mAh you burn thru. also was the stock AEvolt setpoint the same as a stock battery, 3.416? or was it different?
[Nexus One Android Development] myakove:
All values was the same as stock.

I will let the battery drain and keep you posted, thanks for you help.
[Nexus One Android Development] samarium:
I have a G5 battery and UVF & PORF are on constantly thoughout the charging & discharging cycle, while the N1 battery has them clear.

So it seems I must clear these flags. Seems like more reading required.
[Nexus One Android Development] RogerPodacter:
Yeah I've read that. And we do actually see the palm pre Dr battery app writing the status reg to clear the under volt flag sometimes. I'm not sure it matters to hit learn mode. But I made the edited driver status reg file writeable for just this purpose. So if you want to give it a shot go ahead and write that bit to zero to the status register. It should work just fine.
[Nexus One Android Development] samarium:
I don't think it matters to hit learn mode at all. It certainly doesn't stop me.

My current method of choice is:

0. Establish 2 ssh connections to the dropbear server on the phone.

1. In session one, run my bat.sh script, as attached, to monitor uV, uA, uAh and status every 3 seconds.

2. In session two, use echo 10 2 > setreg; echo 11 0 > setreg whenever uAh < 100000.

3. When uV is within 1500000 uV of AEV ensure uA is in range -250000 to -500000 as don't want to approach AEV to fast or too slow.

4. Watch bat.sh monitor.

5. When LEARNF is set, insert power.

This is mostly reliable for standard batteries, as long as I'm paying attention at the right time. Need to do more testing with extended batteries.

Note that if you use the torch app in high intensity mode to drain the battery then it can cause the battery temperature to skyrocket. I've seen mine around 60C. Since full40 is based around 40C, I'd rather try and hit full40 with the phone battery temp <= 40C, rather than > 40C.

bat.sh:

#!/system/bin/sh
cd /sys/de*/pl*/ds*
while echo `date` ' ' `cat getvoltage` uV ' ' `cat getcurrent` uA ' ' `cat getmAh` uAh ' ' `cat statusreg`
do
sleep ${1-60}
done
[Nexus One Android Development] RogerPodacter:
Have you tried the app yet? (Think you have). We can try to work some of your method in there if possible. Most of its there but I'd like to add some of those parameters in the learn tab as it prob will help.
[Nexus One Android Development] samarium:
Yes I've tried the app, however the learn tab doesn't provide the data I want, and my method works well enough, and I find it easier and quicker to type commands than navigate GUIs.
[Nexus One Android Development] myakove:
The phone shutdown in 3% and I think i got all the 1600 mAh from the battery (I was far from my PC so no logs). should I increase the mAh little more?
[Nexus One Android Development] lojden:
Is my battery bad or what? I've hitted learn mode and charged all night, this is the result.
[Nexus One Android Development] temasek:
I don't think you got the learn cycle right. By default the battery that comes with n1 has a start age of 94%. Try draining your battery and if it auto power down before 0-1% then your have not got it right yet.

So far I got all leaning cycle spot on since my early failures. Set age to 100 , set empty voltage to 3201mV, charge to full. Drain battery (normally) , monitor voltage and mAh using app, turn on learn mode and wait. LEARNF lit and turn on charger (mine for all successful tries using battery app did not auto power down). Charge till full. Reboot. Success.
[Nexus One Android Development] lojden:
Well i connected my charger when the pop-up came.

Okey, i'll try that, but what value should i but on ACR and Full40?
[Nexus One Android Development] temasek:
You may have possibly timed out. That's the only reason I can think of.
[Nexus One Android Development] lojden:
Hm okey, i'll give it a try later, yesterday the pop-up came up several times efter i connected it to charger.. got 85% now after 2 hours.
[Nexus One Android Development] Lazat:
how do i set the min to min 35mAh? tried to search in the tread but i couldnt find it :S
[Nexus One Android Development] samarium:
Cheat Sheet

My cheat sheet, if it helps anyone. I use it to cut'n'paste into a terminal window.

cd /sys/devices/platform/ds2784-battery # you need to be here

grep . [!um]* # show values now
tail /d/battery_log # battery log, last 10 lines
dmesg | grep batt # system log, batt messages

echo 6a 20 > setreg; echo 6b d0 > setreg # 3500 mAh
echo 6a 1e > setreg; echo 6b 00 > setreg # 3200 mAh
echo 6a 19 > setreg; echo 6b c8 > setreg # 2750 mAh
echo 6a 18 > setreg; echo 6b 60 > setreg # 2600 mAh
echo 6a 17 > setreg; echo 6b e8 > setreg # 2550 mAh
echo 6a 17 > setreg; echo 6b 70 > setreg # 2500 mAh
echo 6a 13 > setreg; echo 6b b0 > setreg	# 2100 mAh
echo 6a 13 > setreg; echo 6b 38 > setreg # 2050 mAh
echo 6a 12 > setreg; echo 6b c0 > setreg # 2000 mAh
echo 6a 10 > setreg; echo 6b e0 > setreg # 1800 mAh
echo 6a 0f > setreg; echo 6b 00 > setreg # 1600 mAh
echo 6a 0e > setreg; echo 6b 88 > setreg # 1550 mAh
echo 6a 0e > setreg; echo 6b 10 > setreg # 1500 mAh
echo 6a 0d > setreg; echo 6b 9d > setreg # 1448 mAh

echo 14 80 > setreg # age 100%
echo 14 79 > setreg # age 94%
echo 14 70 > setreg # age 87%
echo 14 66 > setreg # age 80%

echo 65 18 > setreg # end charge 80 mA
echo 65 0c > setreg # end charge 40 mA
echo 65 06 > setreg # end charge 20 mA

echo 66 af > setreg # aev 3416 mV
echo 66 a4 > setreg # aev 3201 mV
echo 66 9e > setreg # aev 3084 mV

echo 10 02 > setreg; echo 11 00 > setreg # acr poke
[Nexus One Android Development] lojden:
Well it seems that my learn mode was ok..
[Nexus One Android Development] :
thanks :)
[Nexus One Android Development] temasek:
You seems to have some more juice in your voltage.
[Nexus One Android Development] lojden:
Yeah it died at 6mAh.
[Nexus One Android Development] theloginwithnoname:
Ran down to 2% which is when I plugged in.

Latest full on-charge went all the way up and gave me 1299mAh!

RP, what do you make of this? That lowering min charge actually bumps capacity properly??
[Nexus One Android Development] theloginwithnoname:
convert it to binary by:

http://xdaforums.com/showpost.php?p=8013370&postcount=548

then look at page 25 of the datasheet:

http://datasheets.maxim-ic.com/en/ds/DS2784.pdf

chow, might be worth adding a link to the above PDF/page on first post - "what does my status_reg value mean?"
[Nexus One Android Development] lojden:
never mind.
[Nexus One Android Development] lojden:
double post..
[Nexus One Android Development] theloginwithnoname:
Two points

1) I think you mean ">= 40 && <= 41" ;)

2) what's the mA pull using torch? Maps with GPS on full brightness is ~700mA on mine, temp is acceptable
[Nexus One Android Development] theloginwithnoname:
http://xdaforums.com/showpost.php?p=7850470&postcount=2 -> spreadsheet of registers, row 26 (register 0x65)

convert using ratio - 35 * 0.3 = 10.5 (think I went to 10)

convert value to hex (e.g. using windows calc), e.g. 10 -> hex = A

echo 0x65 0a > setreg

RP, I have just added a "1/2 bit" col to the spreadsheet, might also be worth adding in the ratio's so people can work out the values.
[Nexus One Android Development] theloginwithnoname:
nice work!
[Nexus One Android Development] temasek:
Maybe u can actually get more out of your battery by lowering your empty voltage to 3201mV and perform a new learn cycle.

I did it and I am glad I did it. :)
[Nexus One Android Development] myakove:
now I'm on 0x07 but with the battery app I see that UVF and PORF are on.
[Nexus One Android Development] RogerPodacter:
yeah that seems right. i've never seen those flags turned on in any of my batteries!
[Nexus One Android Development] RogerPodacter:
i wonder what the current draw would be if we turned on the torch, then opened google maps on HSDPA and scrolled forever in one direction? would we hit -1000mA? lol i can hit -800mA just scrolling google maps forever over 3G.
[Nexus One Android Development] RogerPodacter:
you definitely have more capacity left in your battery if you want to try to get at it. you seemed to not reached 3.416volt before you ran out of capacity mAh.
[Nexus One Android Development] RogerPodacter:
i guess it seems that it does;). so you lowered your AEvolt and also raised your top end by setting <35mA current. seems to have give a 50mAh increase give or take. i'd say that makes sense.

i wonder if performing a learn cycle via usb charging yields any gains in capacity? does the slower charge allow for more juice to be placed into the battery vs AC charging? prob not but curious to test it.
[Nexus One Android Development] RogerPodacter:
seems you're right around the correct settings already, but hell i would play with it and tweak just for fun and see if you can bump up full40 just a bit. why not.
[Nexus One Android Development] theloginwithnoname:
interested what you said the other day re 100-90% seems to go very quickly - have noticed this a couple of times now. Will dig around the logs and see what's what.

We kicked this theory around a while back I think and I believe the consensus was "negligble". Depends what's running on the phone if you're doing an on-learn by the app, or manual via shutdown/off-charge (i always do learn on the latter one so can't advise).
[Nexus One Android Development] temasek:
My battery 100% to 90% drained normally. In fact all % drained normally down till it died.

Tested many times.
[Nexus One Android Development] RogerPodacter:
i usually gauge by my commute to work. from the time i unplug till i get to work lately i've seen the first 10% gone. for example right now i've been unplugged from the charger for 59 minutes, with 24 minutes of display-on time. and i'm at 90%. seems to be typical as of late for me. i cant recall what it used to be like a few months ago to compare.

we'd have to set back to <80mA and then see i guess?
[Nexus One Android Development] RogerPodacter:
the other thing, has anyone noticed any strange charge behavior since we changed the timeout poll? this morning i woke up at 6am and my phone was still plugged in from last night, but it was draining while still on the charger. then it hit 90% and started charging back up. i went back to bed and it was staying at full when i woke up.

but it had been charging all night, so i hope our timeout poll isnt having side effects. i've not seen this before, and normally i can leave it plugged in for 8 hours and it will stay at 100% the entire time. weird news...
[Nexus One Android Development] temasek:
Mine is set to min 20mA
[Nexus One Android Development] theloginwithnoname:
remind me, have you set AEvolt and min charge lower? think it theory is, only happens with these lowered
[Nexus One Android Development] temasek:
AEvolt 3201mV

Min 20mA
[Nexus One Android Development] theloginwithnoname:
nah its that kernel charge point/battery full code change, expected behaviour to stop battery being constantly charged.

not sure where it is in code, will have a dig
[Nexus One Android Development] RogerPodacter:
it wasnt like this before for the last few months, was it? you are talking about the status reg && 0x80 check portion of the code? i'd like to set it back to stock i guess then...there's no way its healthy for our battery to charge up and down 10% all night over and over lol. the way it worked before i thought was once full charge is reached, the phone is powered by the charged only, and the load is taken off the battery.
[Nexus One Android Development] theloginwithnoname:
I *knew* you'd say - and after I'd shut down! :D

Not sure, hence I'll have a look. Let's be careful not to start a virtual riot here!

What tells the battery the level at which it says it is full? I suspect it's that bit of (EEPROM) code that is at fault, as the status reg check just asks the battery if it's full or not. Hence why we had to hax it in the past.

If anything, in the past your battery will have charged to 100%, stop charging, then go to 99%, then to 98% then start charging again to 100% and repeated.

Suspect it's to do with CHARGE_DISABLE vs CHARGE_OFF - will take a closer look.
[Nexus One Android Development] temasek:
I am using wildmonks kernel. When fully charged, I did not see the battery drop even when I watch videos or play games while still plugin. I suppose it uses charger for power instead of battery.
[Nexus One Android Development] mtw4991:
From Wildmonks blog:

-Latest battery commits from thelogin and RP

Note: I retained the commits related to charging when below 99% (instead of the defauly 90%). If it interferes with using the battery app made by thelogin and RP, please report.

It might be that the charging doesn't take place until 99% vs. the stock 89%? You guys would know better than I.

fyi, I'm also using <20, 3201, 100% and 1452 for my next learn attempt. Question: Just like we need to stay above -200 to turn the learnf on, do we need to stay above <20 to keep it on while charging or even above -200 while charging. I ask as I have seen (in the app) a couple of times that charge current dropped temporarily to like 9mV for a very brief time, which is below <20 so did it turn learn off at that point? idk. If the learn-off point is -200 (just like learn-on) how do we keep the current draw that high for 3 hours?:confused:
[Nexus One Android Development] RogerPodacter:
i just looked at the old driver code and the <99% was there, even from the stock AOSP git repository shows the 99% condition. and it still seems to be in our recent driver. so i think it was just a fluke i experienced.

if you place a large enough load on the battery for long enough period of time while you are nearing the top of your full charge, yes you certainly can dip the load so that it drops below <20mA and giving a false full charge condition. but this can only happen near full when the current is already low.

for the learn flag, the AEcurrent only needs to be above 200mA for the time you cross AEvolt. it doesnt matter what happens afterwards during the 3 hours of charging. you only need to trip the learn flag once to start the cycle, after that it looks for CHGTF to be set to stop the cycle. it doesnt matter what happens in between as long as you dont unplug etc.
[Nexus One Android Development] RogerPodacter:
yeah i think it was just a fluke incident and i prob wont see it happen again.