Mac Program to disable charging

Alrescha

macrumors 68020
Jan 1, 2008
2,157
315
when they hit 100% and they let the computer run on battery power until it hits 80% or so. Then it resumes charging.
I would really like to see some Apple documentation that supports this, as it:

1) Is not the way I think it works, and
2) Sounds like a really good way to kill a battery

cycle the charge between 80% and 100% spreading the load around all the cells to prolong battery life as long as possible.
Ditto. What makes you believe that Apple runs the battery down to 80% and then charges it back up again?

A.
 

Toutou

macrumors 6502a
Jan 6, 2015
673
953
Prague, Czech Republic
I would really like to see some Apple documentation that supports this, as it:

1) Is not the way I think it works, and
2) Sounds like a really good way to kill a battery

Ditto. What makes you believe that Apple runs the battery down to 80% and then charges it back up again?

A.
You're right, they're wrong. When the battery reaches 100% the charging stops and the Mac starts using the mains power, and it doesn't resume until the charge drops by a few percent BY ITSELF.

Using the freshly charged battery when there is electricity available from the outside would be stupid as hell. Seriously guys, have you even thought it through?
 
  • Like
Reactions: GubbyMan

ArtOfWarfare

macrumors G3
Nov 26, 2007
8,591
4,063
You're right, they're wrong. When the battery reaches 100% the charging stops and the Mac starts using the mains power, and it doesn't resume until the charge drops by a few percent BY ITSELF.

Using the freshly charged battery when there is electricity available from the outside would be stupid as hell. Seriously guys, have you even thought it through?
Okay. That makes sense. You're kind of a jerk, though. There's no need to insult people because they got one tiny detail (albeit important) detail wrong.

In case you don't see the difference between what he said and we said:

What we said (wrong):
When the battery is full(ish) and plugged in, the computer pulls power from the battery until it's around 80%, then it pulls power from the wall and recharges the battery.

Correct:
When the battery is full(ish) and plugged in, the computer power from the wall. Independently, when the battery drops to around 80%, power from the wall goes to recharging the battery.
 
  • Like
Reactions: BigMcGuire

Alrescha

macrumors 68020
Jan 1, 2008
2,157
315
Okay. That makes sense. You're kind of a jerk, though. There's no need to insult people because they got one tiny detail (albeit important) detail wrong.
There is no need to insult, that is true. But the only thing worse than no information is bad information. If you make unsupportable, inaccurate statements, you should expect to be called on it.

A.
 

bjet767

macrumors 6502a
Oct 2, 2010
962
312
Ok if Apple plans on 1000 battery cycles by design and if we cycled every day threat will mean what?

The battery is good for almost three years. We all know they don't cycle every day so what would be a normal amount of battery cycles?

I cycled, with almost daily use, my battery 149 times in 447 days. Let's see... That means I have approximately 121 cycles per year and if I really get 1,000 cycles then...

I should get over eight years use out of my battery, assuming no technical failures.

Wow! I've never kept a computer for 8 years, so I'm good to go.

Is there really a problem here in this old thread?

The best part about a failed battery in an old computer is I now have a good excuse to buy a new one. Not that I've ever needed an excuse.
 

arjzor

macrumors newbie
Apr 1, 2017
1
0
Maybe not the best solution but how about a wifi controlled power socket? Should do the trick for any laptop. Please no debate on how it's a bad idea, just talk on how to enable/disable the charge.
 

boris42

macrumors newbie
Oct 17, 2007
12
0
I would like to make a program that gives the user the option to stop charging at a battery level of 80% (or any other configurable percentage).
So any ideas on how this can be done?
The reason for doing this is that battery wearing will be reduced to a very low level if you always keep it charged somewhere between 40 and 80% while at the same time discharging and charging it a bit every day to keep the electrons moving. I mostly use my system on battery power while commuting, and at home for a few hours now and then, but I think if I could automate not charging beyond 80% I would almost always keep an optimal charge at no cost at all. If, on the other hand, your Li-ion batteries are at a 100% charge a large part of the time, they will slowly deplete over time even when you never deep discharge it. Particularly as I quite often use my computer for statistical analyses: it is bad for Li-ion batteries to get hot when fully charged.
While it perhaps would be possible to achieve something alon gthose lines by directly addressing the SMC I maintain it is quite dangerous to go down this road, would be a bad idea to do so and would likely be subject to Apple software updates preventing it to work.

I'd resort to a hardware-software combination. I'd buy a cigarette charger magsafe cable https://www.amazon.com/WeCharger-Ultra-Compact-Portable-MacBook-Connector/dp/B00ETCD9BC/ref=pd_sbs_147_2 or an Apple Airline adapter https://www.amazon.com/Apple-MagSafe-Airline-Adapter-L-Tip/dp/B00F9ISZY6. Reason is that as soon as the voltage drops to 15v, computer stops charging but continues to run on supplied power, effectively skipping the charging circuit completely. As soon as the voltage is 18.5v or 20v (some models), it will run on a/c and charge the battery. The only thing that is needed is to make it a user selection, perhaps with a rocker switch that routes DC thru a DC step down converter that drops the required voltage to 15v which will prevent charging. If you are into electronics, you can create this switch as a latching relay that is controlled programatically from the Mac either as an USB device, BlueTooth or WiFi when your desired threshold is reached at either end (80% and 40%).

Boris
 

bingeciren

macrumors 6502a
Sep 6, 2011
868
729
I realize that this is an old thread and the OP has either found a solution or has given up.

The Sony Vaios that I own have exactly what the OP is asking. Vaio battery management can be adjusted to stop charging the battery at 80% to extend the battery life.

While the OP is asking for a code to accomplish this with software, everybody is giving him their "expert" advice that he shouldn't bother.

I would be glad to find out how to do this with the help of a program if possible and not interested reading the opinions of people trying to enlighten us about battery management.
 
  • Like
Reactions: jcusick

gnasher729

macrumors P6
Nov 25, 2005
16,643
3,295
I've already read a lot of information about Li-ion batteries (also from scientific research), so I'm quite sure that a program like a I proposed would substantially reduce wearing.
I think Apple has some engineers who haven't just read about this, but who actually have a few hundred batteries at their disposal and are trying this stuff in real life.
 

spiffers

Suspended
Apr 12, 2009
105
88
I would like to make a program that gives the user the option to stop charging at a battery level of 80% (or any other configurable percentage).

I was under the impression that I could do this by setting the power management ChargeInhibit flag to 1 using IOPMAssertionCreateWithName (from the IOKit library). Setting this flag is no problem (pmset shows that it is enabled by my test application), but the system seems to simply ignore this and still continues charging to the full 100%...

The part in my code that is related to my question is as follows.
Code:
#define kIOPMAssertionTypeInhibitCharging       CFSTR("ChargeInhibit")
#define kIOPMChargeInhibitAssertion             kIOPMAssertionTypeInhibitCharging

IOPMAssertionID assertionID;

IOPMAssertionCreateWithName(kIOPMChargeInhibitAssertion, kIOPMAssertionLevelOn, kIOPMAssertionTypeInhibitCharging, &assertionID);
So any ideas on how this can be done?


The reason for doing this is that battery wearing will be reduced to a very low level if you always keep it charged somewhere between 40 and 80% while at the same time discharging and charging it a bit every day to keep the electrons moving. I mostly use my system on battery power while commuting, and at home for a few hours now and then, but I think if I could automate not charging beyond 80% I would almost always keep an optimal charge at no cost at all. If, on the other hand, your Li-ion batteries are at a 100% charge a large part of the time, they will slowly deplete over time even when you never deep discharge it. Particularly as I quite often use my computer for statistical analyses: it is bad for Li-ion batteries to get hot when fully charged.
There are some Read-Only APIs for the battery controller, but no way of controlling the charge itself. The controller is programmed through firmware, the code runs directly on the controller itself, and not in EFI, XNU, Core OS, Core Services or even AppKit. You could monitor the battery the same way Coconut Battery is doing it, a header dump of the app would give you some pointers, but you will never ever get even close to control the charge controller.
 

echo1877

macrumors member
Nov 10, 2015
82
105
I would like to make a program that gives the user the option to stop charging at a battery level of 80% (or any other configurable percentage).

I was under the impression that I could do this by setting the power management ChargeInhibit flag to 1 using IOPMAssertionCreateWithName (from the IOKit library). Setting this flag is no problem (pmset shows that it is enabled by my test application), but the system seems to simply ignore this and still continues charging to the full 100%...

The part in my code that is related to my question is as follows.
Code:
#define kIOPMAssertionTypeInhibitCharging       CFSTR("ChargeInhibit")
#define kIOPMChargeInhibitAssertion             kIOPMAssertionTypeInhibitCharging

IOPMAssertionID assertionID;

IOPMAssertionCreateWithName(kIOPMChargeInhibitAssertion, kIOPMAssertionLevelOn, kIOPMAssertionTypeInhibitCharging, &assertionID);
So any ideas on how this can be done?


The reason for doing this is that battery wearing will be reduced to a very low level if you always keep it charged somewhere between 40 and 80% while at the same time discharging and charging it a bit every day to keep the electrons moving. I mostly use my system on battery power while commuting, and at home for a few hours now and then, but I think if I could automate not charging beyond 80% I would almost always keep an optimal charge at no cost at all. If, on the other hand, your Li-ion batteries are at a 100% charge a large part of the time, they will slowly deplete over time even when you never deep discharge it. Particularly as I quite often use my computer for statistical analyses: it is bad for Li-ion batteries to get hot when fully charged.
One thing to realize about IOKit is that all such constants (such as kIOPMChargeInhibitAssertion), are completely generic to all macOS/iOS devices, and so the existence of such constants is very poor indication of whether or not such functionality is actually supported by the system. For instance, the constant might exist because it was a feature on some PowerBook model 15 years ago...

More specifically I'll tell you that I've looked closely at the iDevice gas gauge specs and it might not even support such a command from the host (the iOS device). If you're really curious about this, check out the spec of one of the gas gauge chips to see the supported commands. If you want to directly communicate with the chip, it is possible to do so with IOKit on a jailbroken device (There is a device called HDQGasGauge or something like that), but I've not found a way to do this without jailbreak.

To be clear, this is all specific to iDevices, I'm not sure if Macs use the same or similar TI chips for battery and charging management.
 
Last edited:
  • Like
Reactions: BigMcGuire

yashag

macrumors newbie
Jul 20, 2016
4
0
I have always wanted to have my macbook charge to only 80%, too. I know this is an old thread, but there is an interesting change coming to ios devices with the next updates: They will charge to 80% once you plug them in and continue to 100% just in time before you usually unplug them. Maybe, just maybe this somehow means that macos devices are capable of doing that, too.
[doublepost=1559852417][/doublepost]btw: i LOVE how people believe that apple engineers are thinking about the longevity first.
 

Galaxy001

macrumors newbie
May 15, 2018
2
0
It is available on iOS 13 to stop charging at 80%, but it will continue to charge without your permission based on when you unplug before.

So it is a GOOD function as certified by Apple.

Now, will anyone write an app for macOS to stop charging at a configureable percentage ?
 

jcusick

macrumors newbie
Feb 24, 2008
12
4
Phoenix, AZ
The "charging to a predefined percentage" is something I would love to have on my MacBook Pro. ALL electric cars have this option for a reason! There is nothing wrong with charging to 100% as long as you don't LEAVE it at that percentage and use it as soon as possible. Only you know when you are going on a long trip and NEED that 100%. That is why Apple added this option into iOS 13. Keep the battery at 80% then fully charge to 100%, just before leaving and using battery only. I have been babying my iPhone XS Max by trying to keep the battery inside of the extremes as much as possible (20%-80%). After over a year, I am at 99% capacity. Same with my Tesla. I just discovered the "tape trick" for the Mag Safe adapter. Wish I knew it sooner, as it does give some control. Too bad there is no such trick for Thunderbolt 3 Macs. My 16" MBP will be here in a couple of weeks and I'm sure I'll have it for 10 years! With as much battery capacity as it has, It will be easy to use the computer starting at 80% on a daily basis.

Just a small tidbit. I sort of get the ability to keep out of the 100% battery charge by using a very small charging adapter. Even a 30W will work on the big MacBook Pro, but it charges much slower and will not charge the battery nearly as fast when your using the computer, even discharging the battery if you need more wattage. There is the added benefit that the charger is tiny! https://www.amazon.com/dp/B07PT7XMP9/?coliid=I1I9ZHZMOTO2BO&colid=30Z1W088Z9HDH&psc=1&ref_=lv_ov_lig_dp_it
 

LOLDERS

macrumors newbie
Jan 3, 2020
3
0
(signed up just to post this) I have been using an iMac for the past 5 years. Just sold it for the new 16in Mac book pro. I live off grid, race drones, fly drones for a living. Taking care of batteries is very important to me. The thing I missed immediately was being able to just leave my computer on all day and not worry about the battery. What aggravates me is that there is not an app or the function built into the OS to allow for a pre determined Charge STOP, say 80%. All electric cars have this function for a reason! Every time you charge to 100% you are actually overcharging the cells and degrading their life. Batteries are happiest when they can stay at their resting voltage - not over, not below! Because I know better, I am constantly unplugging my battery at 80%. Sure it is easy, but its super annoying. I am pretty sure the computer runs better when plugged into AC as well. I found this forum thinking someone surely has already made an app that does this, but I haven't found one... I found it funny that people think Apple is concerned about prolonging their batteries lol, yeah right! Oh well, I will just keep doing it manually, but I REALLY HOPE SOMEONE IS ABLE TO FIGURE THIS OUT! I mean on my old MacBook Pro I could just pop the battery out and run off AC lol. Silly when you need the computing power you must sacrifice your battery first. Finger Crossed we get this implement on a nice slider soon! If someone has a fix for this please email me at Olders.liam@gmail.com! The best solution might be to find the perfect "slow" charger so it's able to maintain the charge but not charge it up when in use!?



- - Post merged: - -

The "charging to a predefined percentage" is something I would love to have on my MacBook Pro. ALL electric cars have this option for a reason! There is nothing wrong with charging to 100% as long as you don't LEAVE it at that percentage and use it as soon as possible. Only you know when you are going on a long trip and NEED that 100%. That is why Apple added this option into iOS 13. Keep the battery at 80% then fully charge to 100%, just before leaving and using battery only. I have been babying my iPhone XS Max by trying to keep the battery inside of the extremes as much as possible (20%-80%). After over a year, I am at 99% capacity. Same with my Tesla. I just discovered the "tape trick" for the Mag Safe adapter. Wish I knew it sooner, as it does give some control. Too bad there is no such trick for Thunderbolt 3 Macs. My 16" MBP will be here in a couple of weeks and I'm sure I'll have it for 10 years! With as much battery capacity as it has, It will be easy to use the computer starting at 80% on a daily basis.

Just a small tidbit. I sort of get the ability to keep out of the 100% battery charge by using a very small charging adapter. Even a 30W will work on the big MacBook Pro, but it charges much slower and will not charge the battery nearly as fast when your using the computer, even discharging the battery if you need more wattage. There is the added benefit that the charger is tiny! https://www.amazon.com/dp/B07PT7XMP9/?coliid=I1I9ZHZMOTO2BO&colid=30Z1W088Z9HDH&psc=1&ref_=lv_ov_lig_dp_it
I like your idea of a slower charger so when your using your computer it struggles to top up! =) With it being USB-C, I can find the perfect "slow" charger from my other devices!?
 
Last edited:

LOLDERS

macrumors newbie
Jan 3, 2020
3
0
The "charging to a predefined percentage" is something I would love to have on my MacBook Pro. ALL electric cars have this option for a reason! There is nothing wrong with charging to 100% as long as you don't LEAVE it at that percentage and use it as soon as possible. Only you know when you are going on a long trip and NEED that 100%. That is why Apple added this option into iOS 13. Keep the battery at 80% then fully charge to 100%, just before leaving and using battery only. I have been babying my iPhone XS Max by trying to keep the battery inside of the extremes as much as possible (20%-80%). After over a year, I am at 99% capacity. Same with my Tesla. I just discovered the "tape trick" for the Mag Safe adapter. Wish I knew it sooner, as it does give some control. Too bad there is no such trick for Thunderbolt 3 Macs. My 16" MBP will be here in a couple of weeks and I'm sure I'll have it for 10 years! With as much battery capacity as it has, It will be easy to use the computer starting at 80% on a daily basis.

Just a small tidbit. I sort of get the ability to keep out of the 100% battery charge by using a very small charging adapter. Even a 30W will work on the big MacBook Pro, but it charges much slower and will not charge the battery nearly as fast when your using the computer, even discharging the battery if you need more wattage. There is the added benefit that the charger is tiny! https://www.amazon.com/dp/B07PT7XMP9/?coliid=I1I9ZHZMOTO2BO&colid=30Z1W088Z9HDH&psc=1&ref_=lv_ov_lig_dp_it
I wonder now... Is the computer using the AC power first and then AC Power charging the battery second? Ie. When plugged into AC power is the computer running off the battery or is it running off the AC power?
 

LOLDERS

macrumors newbie
Jan 3, 2020
3
0
I would like to make a program that gives the user the option to stop charging at a battery level of 80% (or any other configurable percentage).

I was under the impression that I could do this by setting the power management ChargeInhibit flag to 1 using IOPMAssertionCreateWithName (from the IOKit library). Setting this flag is no problem (pmset shows that it is enabled by my test application), but the system seems to simply ignore this and still continues charging to the full 100%...

The part in my code that is related to my question is as follows.
Code:
#define kIOPMAssertionTypeInhibitCharging       CFSTR("ChargeInhibit")
#define kIOPMChargeInhibitAssertion             kIOPMAssertionTypeInhibitCharging

IOPMAssertionID assertionID;

IOPMAssertionCreateWithName(kIOPMChargeInhibitAssertion, kIOPMAssertionLevelOn, kIOPMAssertionTypeInhibitCharging, &assertionID);
So any ideas on how this can be done?


The reason for doing this is that battery wearing will be reduced to a very low level if you always keep it charged somewhere between 40 and 80% while at the same time discharging and charging it a bit every day to keep the electrons moving. I mostly use my system on battery power while commuting, and at home for a few hours now and then, but I think if I could automate not charging beyond 80% I would almost always keep an optimal charge at no cost at all. If, on the other hand, your Li-ion batteries are at a 100% charge a large part of the time, they will slowly deplete over time even when you never deep discharge it. Particularly as I quite often use my computer for statistical analyses: it is bad for Li-ion batteries to get hot when fully charged.
Any Luck? As a work around, I bought a weak 30w charger. So when I am using the laptop it can't really charge. I will see how long the charger lasts...
 

Red Menace

macrumors 6502
May 29, 2011
402
71
Littleton, Colorado, USA
Any Luck? As a work around, I bought a weak 30w charger. So when I am using the laptop it can't really charge. I will see how long the charger lasts...
The reason you haven't found anything is that battery charging is done with purpose-built hardware designed by the various battery designers and engineers (and for a "smart" battery with components built into the battery or battery pack itself). The charging hardware is what monitors the condition and determines the charging profile. It wouldn't make much sense for any company to expose itself to tons of support calls as a result of people playing games with the charging profile because they watched some random video posted on YouTube.

As already mentioned, what will wear out the typical lithium-based battery is the depth of discharge, so the smaller the discharge (from a full charge) the longer the battery will last, e.g. the battery will last longer if only allowed a 10% discharge vs 20%. This is why the recommendation is to avoid full discharges, and to charge the battery more often between uses. Although there also is a tradeoff with longevity, most mobile device chargers are designed for maximum capacity, so your best bet would be to just store a separate battery pack.

The laptop wall units are usually sized fairly close to the maximum draw - when plugged in, the machine uses power from the mains, with any additional capacity used to charge the battery. Note that if there isn't enough power the battery may be used as needed, and the processor will throttle back to conserve whatever is available.

I'm not sure where you got that 80% thing for auto batteries, but that isn't correct, either. The fast chargers will slow down around 80%, but that is for battery condition and to avoid overheating (again, by the charging hardware) - they will continue to a full 100% charge, that last 20% just takes more time. It wouldn't make much sense to have a battery that won't charge to its full capacity now, would it?
 

Carlosriosness

macrumors newbie
Nov 5, 2018
3
0
I'm not sure where you got that 80% thing for auto batteries, but that isn't correct, either. The fast chargers will slow down around 80%, but that is for battery condition and to avoid overheating (again, by the charging hardware) - they will continue to a full 100% charge, that last 20% just takes more time. It wouldn't make much sense to have a battery that won't charge to its full capacity now, would it?
He is referring to tesla cars specifically. They are defaulted to stop charging at 80%. You can manually set it to charge to 100 if you know you have a long trip coming up. But keeping it under 80% on the regular will ensure it stays at Max capacity over its life.
 

Carlosriosness

macrumors newbie
Nov 5, 2018
3
0
It's cool to know Sony vaios have this feature. I know lenovos with lenvov advantage software can also be set to charge in certain ranges.

They are very common computers for business and spend much of their time in docks. You can set the range to any amount. I set my girlfriend's to start charging at 40% and to stop at 70%
 

rob g

macrumors newbie
Jan 28, 2020
1
0
My 2012 MacBook Pro battery needed service after only 2 years and about 250 battery cycles. I think leaving it plugged in with it sitting at 100% really is bad for any battery but it's kind of hard not to when you use it docked... I agree that this feature would be great to have...