Linux and Battery Charge Capacity

Solaris, RedHat, FreeBSD and the like
Post Reply
Message
Author
cb474
Sophomore Member
Posts: 128
Joined: Thu Jan 04, 2007 10:04 pm
Location: Washington, DC

Linux and Battery Charge Capacity

#1 Post by cb474 » Wed Aug 19, 2009 7:27 pm

This is entirely a subjective observation, but after a couple years and several batteries it really seems to me like my battery charge capacity when full diminishes significantly more rapidly in Linux than in Windows. I'm using Arch64 on a T61, but I've observed this in Ubuntu and Debian as well as on my slightly older T60. Is there anything to be done about this? Does the Lenovo/IBM battery monitor software really handle the battery charging better? Isn't this mostly controlled by the BIOS?

I'm interested if other people have had the same experience and what thoughts you may have about this. Thanks.

Superego
Sophomore Member
Posts: 239
Joined: Tue Feb 20, 2007 4:05 pm
Location: Minneapolis, MN

Re: Linux and Battery Charge Capacity

#2 Post by Superego » Thu Aug 20, 2009 10:18 am

I tend to disagree. When I first started using Linux on my laptop I would get better battery life in Windows (also the battery was brand new). Now that my battery is older and has less capacity I find that I can get longer life in Linux. I am also using some tweaks to extend the battery life in Linux that I did not initially use. I'm not sure if Linux fairs better with older batteries (doubtful, but that's just my observation) or if the tweaks are more effective in Linux (more likely). To help here's what I do.

- Use powertop
- Screen/Screensaver settings (dim on battery, blank when idle, shorter idle time, etc.)
- CPU Frequency scaling (Since you're using Arch: pacman -S cpufrequtils)
- Setting battery thresholds

The battery thresholds are, IMO, the most important. If you keep it from full charging and discharging you'll keep it's capacity high and, thus, get longer life. Of course this is tough since the whole idea of a laptop is to be mobile and nobody wants a half-charged battery all of the time (I tend to use mine more as a desktop replacement so I don't worry about mobility as much which is why I baby my battery).

In Arch you'll need the tp_smapi package which contains kernel modules for interacting with Thinkpad hardware (battery, HAPS, HDD, etc.). To set the thresholds you just need to do the following:

Code: Select all

echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 80 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh
You can create a script with this if you like and then add it to /etc/rc.local to make it run at startup.

NB: I'm on 32-bit Arch so you'll want to double-check all of this for Arch64 (either the ArchWiki or the forums).
W510: i7-820QM / 8GB 1066 RAM/ 1 GB NVIDIA Quadro FX 880M / 500GB 7200rpm / 15.6" HD 1080 / Arch Linux

cb474
Sophomore Member
Posts: 128
Joined: Thu Jan 04, 2007 10:04 pm
Location: Washington, DC

Re: Linux and Battery Charge Capacity

#3 Post by cb474 » Thu Aug 20, 2009 7:17 pm

Thanks for the suggestion about how to set battery thresholds. I wasn't aware this was possible in Linux.

I just want to be clear that I wasn't talking about battery life (though I realized no matter how I said this I would likely create a potential confusion). That is, I wasn't talking about battery life in the sense of, how many hours my computer will run on the battery when it is charged up. I was talking only about the overall lifetime of the battery (how many times it can be recharged and the rate at which it's full charge capacity diminishes).

That said, I really don't find that the battery life is better in Linux as you do. The rate of discharge in watts is always lower in windows, than in Linux, in my experience, no matter what I do. I have done all the things you suggest (powertop, etc.) and more (I used laptop-mode to regulate the hard drives). Linux for me isn't bad, but windows is always better. I assumed this is because Lenovo/IBM has written specific software and drivers for the T61 to regulate power use and it's hard to reproduce this in Linux. One question I've always had is how can I be sure the bluetooh and irda radios are disabled (since I don't use them)?

Anyway, I really appreciate the battery threshold suggestion. Thanks.

cb474
Sophomore Member
Posts: 128
Joined: Thu Jan 04, 2007 10:04 pm
Location: Washington, DC

Re: Linux and Battery Charge Capacity

#4 Post by cb474 » Fri Aug 21, 2009 2:49 am

Superego wrote:

Code: Select all

echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 80 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh
You can create a script with this if you like and then add it to /etc/rc.local to make it run at startup.
Is there any reason not to just add those two lines (echo 40 > /sys/devices/...) directly to rc.local? Instead of creating a script. That's what I do to set my trackpoint sensitivity and it seems to work fine.

Superego
Sophomore Member
Posts: 239
Joined: Tue Feb 20, 2007 4:05 pm
Location: Minneapolis, MN

Re: Linux and Battery Charge Capacity

#5 Post by Superego » Fri Aug 21, 2009 10:18 am

I've never tried to turn off the irda radio through Linux, I just turn off it in the BIOS (you should have a config option to hide it from the OS).

Regarding the bluetooth, there may be a similar option in BIOS but since I use bluetooth sometime I turn it on and off using ACPI. You can turn off power with the command:

Code: Select all

# Turn off
echo "0" > /sys/devices/platform/thinkpad_acpi/bluetooth_enable 

#Turn on
echo "1" > /sys/devices/platform/thinkpad_acpi/bluetooth_enable
You'll need to be root to this as using redirection with sudo is a little funky (I think sudo -s may work). I just mapped my Fn+F5 key to this command so I can turn bluetooth on and off when I need. Hope this helps.
W510: i7-820QM / 8GB 1066 RAM/ 1 GB NVIDIA Quadro FX 880M / 500GB 7200rpm / 15.6" HD 1080 / Arch Linux

cb474
Sophomore Member
Posts: 128
Joined: Thu Jan 04, 2007 10:04 pm
Location: Washington, DC

Re: Linux and Battery Charge Capacity

#6 Post by cb474 » Fri Aug 21, 2009 3:24 pm

Yes, very helpful. Thanks!

Superego
Sophomore Member
Posts: 239
Joined: Tue Feb 20, 2007 4:05 pm
Location: Minneapolis, MN

Re: Linux and Battery Charge Capacity

#7 Post by Superego » Fri Aug 21, 2009 7:18 pm

Yeah you could add those lines to rc.local directly. I mentioned the script because I wrote one a while back that allowed me to input what threshholds and which battery to use (for when I used the ultrabay battery).
W510: i7-820QM / 8GB 1066 RAM/ 1 GB NVIDIA Quadro FX 880M / 500GB 7200rpm / 15.6" HD 1080 / Arch Linux

cb474
Sophomore Member
Posts: 128
Joined: Thu Jan 04, 2007 10:04 pm
Location: Washington, DC

Re: Linux and Battery Charge Capacity

#8 Post by cb474 » Fri Aug 21, 2009 7:47 pm

Sounds good. Thanks for the follow up. Yeah, I did that with rc.local and it seems to be working. (By the way, the tp_smapi pacakage in AUR does work with 64 bit Arch).

Now I guess I'm wondering what are the best settings for me to get some benefit in maintaining the battery capacity longer. I read in ThinkWiki that 30 - 85 % charge is the ideal range. But since I do run off my battery a lot, I don' really want a battery that's only 85 % charged. Hmm.

I've noticed the battery rarely seems to go above 99% (to 100%), so I wonder if having it stop at 99% and not keep charging for hours to get to 100% has some benefit.

Of course, I don't want my battery to have to run down to 30% before it starts charging either, in case I find myself in a situation where I need to run off of the battery. So I'm also wondering what benefit there is if it at least has to run down to 95% or 85%.

Or is there a better way to do this for my needs?

ThinkRob
Senior ThinkPadder
Senior ThinkPadder
Posts: 2364
Joined: Wed May 20, 2009 9:54 am
Location: near RTP, NC

Re: Linux and Battery Charge Capacity

#9 Post by ThinkRob » Wed Aug 26, 2009 12:06 pm

Superego wrote: Regarding the bluetooth, there may be a similar option in BIOS but since I use bluetooth sometime I turn it on and off using ACPI. You can turn off power with the command:

Code: Select all

# Turn off
echo "0" > /sys/devices/platform/thinkpad_acpi/bluetooth_enable 

#Turn on
echo "1" > /sys/devices/platform/thinkpad_acpi/bluetooth_enable
Just a heads up: that might not always disable the BT chipset. On my machine (X61s) it appears to disable Bluetooth, but not in a way that results in a power reduction. In order to *really* disable it, I have a script that brings down the interface with hciconfig, disables it via thinkpad_acpi and then unloads the modules from the kernel. Seems to work -- my power consumption drops using that method, whereas it doesn't if I just do the thinkpad_acpi trick above.

YMMV though -- it's probably pretty hardware dependent as to whether or not you have the same issue I did.
Need help with Linux or FreeBSD? Catch me on IRC: I'm ThinkRob on FreeNode and EFnet.

Code: Select all

Current laptop: X1 Carbon 3
Current workstation: none

RasmusP
Sophomore Member
Posts: 136
Joined: Wed Apr 18, 2007 12:42 pm
Location: Barcelona, ES

Re: Linux and Battery Charge Capacity

#10 Post by RasmusP » Wed Sep 30, 2009 4:02 pm

ThinkRob wrote: Just a heads up: that might not always disable the BT chipset. On my machine (X61s) it appears to disable Bluetooth, but not in a way that results in a power reduction. In order to *really* disable it, I have a script that brings down the interface with hciconfig, disables it via thinkpad_acpi and then unloads the modules from the kernel. Seems to work -- my power consumption drops using that method, whereas it doesn't if I just do the thinkpad_acpi trick above.
Please post this scripts for inspiration :)
Thanks,
Rasmus

PS: On my X60 I get around 6-7 hours when I have turned off wlan which is comparable to Windows.

ThinkRob
Senior ThinkPadder
Senior ThinkPadder
Posts: 2364
Joined: Wed May 20, 2009 9:54 am
Location: near RTP, NC

Re: Linux and Battery Charge Capacity

#11 Post by ThinkRob » Sun Oct 18, 2009 4:48 pm

RasmusP wrote:Please post this scripts for inspiration :)
Sorry, I just noticed this today.

Here's my script (I put it in /etc/acpi/thinkpad-bluetooth.sh):

Code: Select all

#!/bin/bash

# we dont have /etc/init.d/bluetooth status, so we need a hack

fgrep "enabled" /proc/acpi/ibm/bluetooth &> /dev/null

if [[ $? -eq 0 ]]; then
	# BT is on
	hciconfig hci0 down; rmmod hci_usb
	echo disable > /proc/acpi/ibm/bluetooth	
	# attempt to unload uhci_hcd if possible
	rmmod uhci_hcd &> /dev/null
	if [ $? -ne 0 ]; then
		logger "Unable to unload uhci_hcd.  Still in use?"
	fi
	killall osd_cat
	echo "Bluetooth DISABLED" | osd_cat -d 2 -c green -s 2 --pos bottom -f "-adobe-helvetica-bold-r-normal-*-*-240-*-*-p-*-*-*" &
else
	# bluetooth is off, so switch it on
	# first load the modules
	echo enable > /proc/acpi/ibm/bluetooth
	# check if we need to load the USB 1.1 module
	lsmod | fgrep "uhci_hcd" &> /dev/null
	if [ $? -eq 1 ]; then
		modprobe uhci_hcd
	fi
	modprobe hci_usb && sleep 1 && hciconfig hci0 up
	killall osd_cat
	echo "Bluetooth ENABLED" | osd_cat -d 2 -c green -s 2 --pos bottom -f "-adobe-helvetica-bold-r-normal-*-*-240-*-*-p-*-*-*" &
fi
You can remove the osd_cat lines -- I use that to have an on-screen display of my Bluetooth status, but it'll (obviously) work fine without it.
Need help with Linux or FreeBSD? Catch me on IRC: I'm ThinkRob on FreeNode and EFnet.

Code: Select all

Current laptop: X1 Carbon 3
Current workstation: none

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Linux Questions”

Who is online

Users browsing this forum: No registered users and 2 guests