Post Reply

Battery Low Defy battery drops explained

OP jusid

17th July 2012, 01:36 PM   |  #1  
OP Junior Member
Flag Ukraine, Kyiv
Thanks Meter: 153
 
27 posts
Join Date:Joined: Aug 2007
Recently many users of the Motorola Defy phone have encountered sudden drops in battery charge after installing a new ROM. Such as, drops from 67% to 49%, from 34% to 19%, from 7% to 4%, etc.
I also have encountered such problem when installed CM7.2 after being used stock Froyo ROM for more than an year. I had searched forums for possible fix, but no method has helped.

Finally, I have made some tests with my phone and found interesting points about Defy battery that explain battery percentage drops.

Our Defy have very simple battery controller (it is referred as cpcap by Motorola). The controller does not calculate and provide battery percentage. It provides only a battery voltage and a current. The battd daemon do the battery percentage estimation. It seems some overcomplicated estimation algorithm is used to do that (I've seen the Coulomb counter technique is mentioned in the battd sources).

There are several battery percentage checkpoints at 5%, 20%, 50%, 80%, 100%. It seems the battd daemon have a voltage-percentage mapping table for these checkpoints. When a battery voltage reaches a checkpoint value then the percentage is immediately set to a corresponding value. All other intermediate percentage values are estimated by the battd daemon. The estimation is based on a battery capacity (requested from the battery itself) and the active current. A stock battery reports 1500 capacity. A 1700mAh Chinese battery, I also have, reports only 1200 capacity battd stores the last calculated battery percentage and voltage in the /data/battd/cc_data file. Data from the /data/battd/cc_data file is read on start-up and the percentage from this file is used as base and reported to the system. When battery is drained, the percentage is decremented. When you delete the cc_data and reboot, battd uses the current voltage and looks for the nearest checkpoint voltage value and sets the percentage accordingly.

How have I found the checkpoint values above?

Assume we have a brand new original Defy battery and it shows 25% of charge.
If you delete the cc_data file and then reboot the phone, battd will recreate the file and request the battery controller(?) for the current battery status. The controller will return 50% and battd show 49% to you (not 49% not 50%, due to rounding to the lowest integer). But the real charge is 25%! Now let the battery discharge. It will show to you 48%, 47%, 46%, etc. Great! But at 40-44% you get the instant drop to 19%, since the battery controller had reported real 20% charge at that point and battd has been forced to sync its estimated charge value to the real charge value.

When a battery is wearing its actual capacity is decreased. For example, it may be 1300 mAh after an year of usage. But battery still reports it have 1500 capacity and battd uses this capacity for its calculations. battd should decrement percentage a bit faster for this worn battery, but it still use the same decrement speed as for a new 1500 battery. When battery voltage reaches a check point value, battd updates percentage to corresponding checkpoint value and you register a drop.

battd has some battery information and correction data in the /pds/public/battd folder. This data helps battd to estimate battery charge more correctly. This folder contain 3 files:
Code:
batt_offset_data
batt_phasing_data
batt_tuning_data
Without this correction data you may encounter slight drops even on a new stock battery,

For Defy there at least 2 versions of battd. (Defy+ uses a different battd) Let's name them as old and new ones. To find out which version you have, check the size of the /data/battd/cc_data file.
cc_data = 16 bytes - old battd,
cc_data = 24 bytes - new battd.

Early stock Froyo ROMs have the old battd, newer stock ROMs have the new battd. CM7.2 is bundled with the new battd.

Is the battd version makes any difference in the battery readings? YES. The difference is in a user account which is used to run a battd daemon.
The old battd uses the mot_accy user account, The new battd uses the system account. The corresponding owner and group should be set for the /pds/public/battd folder and files inside it. Otherwise battd will not be able to read battery data from the /pds/public/battd folder and defaults will be used, which cause inaccurate estimations.

If you have used stock old Froyo ROM or old custom ROM, you had the old battd. The /pds/public/battd folder has permissions for the mot_accy user account only.
You install the CM7.2 ROM with the new battd and it can not read battery data from the /pds/public/battd folder, since battd is run under the system user account. You have inaccurate battery estimation and percentage drops even on a brand new battery.
That's why installing the old battd (and its companion lib libbattd.so) on CM7.2 resolves battery drops issue for some users.
If you are using CM7.2 or any newer CM you can just change the owner and group for the /pds/public/battd folder and files inside it. Set both owner and group to system and the new battd will be able to read battery data files.

If you still have battery drops then your battery is worn to some degree and battd can not estimate its charge properly between checkpoints.
Is it possible to correct this? Probably yes.

I was able to adjust checkpoint voltage values and eliminate drops on checkpoints. BUT the discharging speed is still the same and I have good discharge without drops from 100% to 10% and phone is turned off on 10% since a battery reaches critical voltage of 3.050V.
To adjust checkpoints it is needed to change the /pds/public/battd/batt_offset_data file. I have changed the last 3 bytes to 0xA0. It offsets voltage value for checkpoints on 50%, 20% and 5%.

The batt_phasing_data file have not helped at all in my tests. It contains correction values for displayed voltage, temperature, current.

The batt_tuning_data file is total mystery atm.

So the goal is to find a way to force battd to decrement percents faster for worn batteries. The simplest way is to patch the battd with hardcoded capacity value (e.g. 1300) instead of reading this value from the battery.

The other (better) option is to create a custom battery driver and use a very simple mapping from current voltage to percentage. Such method is used to display battery status in touch boot menu. Also Quarx started a custom battery driver some time ago in his git repository.

Important:
The battery calibration is a myth! The /data/system/batterystats.bin file is not related to battery charge/life/status (exactly as Google devs stated earlier).
In case of our Defy, charge the battery to 100% and keep charging for few hours after that. Then disconnect it battd will display correct 99%. That's all you need when changing ROMs or batteries! Do not waste your time on "battery calibration"!

Conclusion:
  • Find out which version of battd you are using.
  • Check owner and permissions for the /pds/public/battd folder and files inside it. Correct owner/permissions if needed.
  • Charge your battery to 100% and keep charging for few hours more.
If you still have battery percentage drops after that, your battery is worn to some degree. The sum of dropped percents indicates how bad is your battery (-10%, -15% etc, compared to a new battery). There is no way to magically increase real life for this battery. Drops just a display issue due to crappy cheap battery controller in our Defy and weak battd estimation logic. That's why stock ROMs have 10% steps for battery charge - to hide such issues.
Last edited by jusid; 4th November 2012 at 07:51 PM.
The Following 143 Users Say Thank You to jusid For This Useful Post: [ View ]
17th July 2012, 02:04 PM   |  #2  
Senior Member
Thanks Meter: 250
 
213 posts
Join Date:Joined: Mar 2012
More
nice investigation, indeed great job.
however, i would not agree to this:
Quote:
Originally Posted by jusid

Conclusion:
If you have battery percentage drops after single full battery charge, your battery is worn. The sum of dropped percents indicates how bad is your battery.

there's also hoop while charging which "compensates" the drop. moreover, there are no sudden voltage drops or so which would mean the battery is just fine, only the readings fail.
i wonder if can it be fixed or so by our devs?
Attached Thumbnails
Click image for larger version

Name:	screenshot-1342529348129.jpg
Views:	4715
Size:	35.3 KB
ID:	1204196  
17th July 2012, 02:13 PM   |  #3  
OP Junior Member
Flag Ukraine, Kyiv
Thanks Meter: 153
 
27 posts
Join Date:Joined: Aug 2007
Quote:
Originally Posted by MarcinRN

there's also hoop while charging which "compensates" the drop. moreover, there are no sudden voltage drops or so which would mean the battery is just fine, only the readings fail.
i wonder if can it be fixed or so by our devs?

Slightly worn battery does not have voltage drops, it just discharges faster due to lower capacity. battd expects slower discharging speed (as in a new battery) while making calculations. That's why the drops occurs when the real charge got from the controller. Drops are just a display issue, but your battery is worn to some degree (-10%, -15%, etc)
Last edited by jusid; 17th July 2012 at 02:18 PM.
The Following 2 Users Say Thank You to jusid For This Useful Post: [ View ]
17th July 2012, 03:39 PM   |  #4  
Llamatron's Avatar
Member
Thanks Meter: 25
 
96 posts
Join Date:Joined: Oct 2011
This thread should be stickied, or the info added to the all in one defy beginner guide
17th July 2012, 03:48 PM   |  #5  
Senior Member
Thanks Meter: 250
 
213 posts
Join Date:Joined: Mar 2012
More
Quote:
Originally Posted by jusid

Slightly worn battery does not have voltage drops, it just discharges faster due to lower capacity. battd expects slower discharging speed (as in a new battery) while making calculations. That's why the drops occurs when the real charge got from the controller. Drops are just a display issue, but your battery is worn to some degree (-10%, -15%, etc)

Thanks I get it now. But the question is can anything be done to make it more accurate?
17th July 2012, 03:57 PM   |  #6  
Senior Member
Thanks Meter: 419
 
711 posts
Join Date:Joined: Jan 2011
More
Great round up!

Would you mind supporting your findings with sources? Helps against criticism, trolling and so on...

Thanks a lot for sharing.
17th July 2012, 04:00 PM   |  #7  
OP Junior Member
Flag Ukraine, Kyiv
Thanks Meter: 153
 
27 posts
Join Date:Joined: Aug 2007
Quote:
Originally Posted by MarcinRN

Thanks I get it now. But the question is can anything be done to make it more accurate?

As I mentioned before, possibly battd has some auto-adjusting logic, bat I'm not sure about that. The solution is to create some proxy between battd and the system with a better estimation logic or create a new battd. But both are quite hard to implement.

As for me, I am going to purchase a new non-stock battery. Then I test how its controller behaves.
The Following User Says Thank You to jusid For This Useful Post: [ View ]
17th July 2012, 04:06 PM   |  #8  
OP Junior Member
Flag Ukraine, Kyiv
Thanks Meter: 153
 
27 posts
Join Date:Joined: Aug 2007
Quote:
Originally Posted by measel

Great round up!

Would you mind supporting your findings with sources? Helps against criticism, trolling and so on...

Thanks a lot for sharing.

These findings are based on simple tests. One of them is described in the OP.
For example, discharge your battery to 51%, then delete files in the /data/battd folder. Reboot the phone. You will get 79% of charge, since the controller reports 80% and the nearest lower step is 50% and it is not reached yet. Then the phone will show 78%, 77%, etc for some short time and then suddenly drops to 49% when the battery controller report the real charge to the system.
Using such method I have found all possible values which are reported by the controller of the stock Defy battery - 0%, 5%, 20%, 50%, 80%, 100%...
Last edited by jusid; 17th July 2012 at 05:42 PM.
The Following 2 Users Say Thank You to jusid For This Useful Post: [ View ]
17th July 2012, 05:48 PM   |  #9  
fioda's Avatar
Member
Thanks Meter: 11
 
54 posts
Join Date:Joined: Sep 2010
More
Excelent work... I've notice that it was a system behavior instead of a bug, but the test you've made everything very clear.
I'm waiting to buy a new battery on a official reseller, the one I've bought is not genuine and showed the same behavior.
17th July 2012, 06:49 PM   |  #10  
Member
Thanks Meter: 1
 
81 posts
Join Date:Joined: Feb 2011
More
Sadly, I replaced my battery with a new one, the drop still show up, this disprove some of your points. But still thanks for the useful information.

The Following User Says Thank You to Chelsea888 For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Defy General by ThreadRank