Battery Monitoring Dotpup for JWM

Stuff that has yet to be sorted into a category.
Message
Author
amish
Posts: 615
Joined: Sun 24 Sep 2006, 23:15

Re: Try this!

#41 Post by amish »

sadly i'm not going to be able to test this, because i won't have access to the machine i did the script on. (my laptop has power management turned off)
sadly, it is not possible to separate politics from free software. free software - politics = unfree software.

kirk
Posts: 1553
Joined: Fri 11 Nov 2005, 19:04
Location: florida

#42 Post by kirk »

Tried batmon-0.0.2.tar.gz in 212beta2. Does not display in the tray, Shows up on the desktop.

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

hi kirka

#43 Post by brad_chuck »

Yes, It will if you just run the exec. Check out the first post. Use the instructions to install it.

I have not put this into dotpup format yet because I don't think it is ready.

kirk
Posts: 1553
Joined: Fri 11 Nov 2005, 19:04
Location: florida

#44 Post by kirk »

Use the instructions to install it.
Yep, I missed line. Sorry. :oops:

Now it switches between free memory and a long line of strange symbols.

/proc/acpi/battery/BAT0/state:
present: yes
capacity state: ok
charging state: charging
present rate: unknown
remaining capacity: 33310 mWh
present voltage: 16886 mV
I liked your original batmon with the seperate tray display. Could you re-post it?

Thanks

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

yes

#45 Post by brad_chuck »

Another user requested it a while back. It is posted about half way down on the second page of this "topic".

I also prefer the no switching... This is the one I am using now.

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

a quick fix...

#46 Post by brad_chuck »

On most batterys there is a number

Lycanth
Posts: 9
Joined: Mon 13 Nov 2006, 01:20

#47 Post by Lycanth »

I have this half working [so to speak] it reads my second battery [after modprobing it manually at every boot] but it doesn't pick up my first, also I don't have those battery files in the /proc/acpi [though I'm not really worried about that] is it possible for it to pick up the power in both batteries? also insmod doesn't work either, it just says file/directory doesn't exsist, thinking I might have to copy some files from the CD to my hard drive

EDIT: got the files created and stuff, just the insmod comes up as none exsistant, and primary battery is detected, but there's no readout on it's remaining power, but it does report a remaining for my secondary battery if it's installed [either alone in the second slot or with the primary battery] is there a way of making puppy auto load the modprobes to save typing it in on each boot?

EDIT 2: ok, checked about a little and found out the following
BAT1 [secondary] detects battery presence, monitors state, displays remaining power for any battery inserted
BAT0 [primary] as above but doesn't show remaining power for any battery, am I the only one with that problem?

User avatar
peppyy
Posts: 443
Joined: Mon 27 Jun 2005, 23:49
Location: VT USA
Contact:

#48 Post by peppyy »

Works well on 2.0.1 ibm thinkpad t22. I don't need the freespace indicator there as much as I do the battery since I am using a hd install and have 4gb left. I will look at the switch and change it for my needs. It is a bit distracting when it resizes.

Nice job!
Puppy Linux...
It just works!

Braden
Posts: 69
Joined: Fri 22 Sep 2006, 20:39
Location: Waterloo, Ontario, Canada

#49 Post by Braden »

I couldn't get my system to modprobe ac, but there's a charging flag in the battery's state file.

I don't like the switching mode either, I'd rather have both the battery and the RAM-remaining displayed at once. Or better yet, have it change on clicks: power, RAM, and whatever other information we give it.

Would you consider releasing your source code? If you'd rather not release it, fine, but I think it would allow for better customization, and is more in the spirit of Puppy in particular and Linux in general. Dotpups are great for general users, but I imagine there's plenty of coders here who'd love to sink their teeth into the source and tweak it to their own preferences.

Maybe include some manner of control file, at least, allowing us to set the frequency of the switching, or disable the switching, or add new displays entirely, providing the name of a script to execute.

Also, if you have it reading that file entirely from inside your C code, there will be no easy way to handle slight differences in the battery and ac formats.

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

new dotpup

#50 Post by brad_chuck »

New dotpup see main post.

(batmon0.0.7.pup)

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

another addition

#51 Post by brad_chuck »

Another addition See first post.

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#52 Post by MU »

oh, I was curious about our first gins program :)
Tested it, though I have no battery extensions loaded, just to look how it works.

Found 3 issues:
- batmon.glade is inclluded with an absolute path, maybe should be relative.
- A small startscript "batmon" would be neat.
- You don't catch the window-close event:
If the window is closed, the script still runs.

I ran it in Icewm, where it runs as seperate window.
But also in JWM this might be an issue.
If JWM is restarted, does it still run? Did not try, just guessing.

Nice work, thanks for sharing :-)

Mark

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

other fourm

#53 Post by brad_chuck »

Did you catch my edit of the of the GINS program on the dev forum? This is needed to make the background picture change. I added some code to the program so you can wright boolean properties. I think we can use GINS for a lot of stuff.

I will iron out the wrinkles in the program... You called it, I just wonted to get something out there...

User avatar
HairyWill
Posts: 2928
Joined: Fri 26 May 2006, 23:29
Location: Southampton, UK

monitor battery voltage

#54 Post by HairyWill »

Thank you. Batmon works on my thinkpad x30, but the battery lies about its charge level. I can run for an extra 20-30 minutes whilst the charge level is zero.

I've tried logging the voltage instead and this seems much more accurate. Now that I know that my motherboard shuts down at just under 9.2 volts. I presume that monitoring this instead would be dependent on the characteristics of a particular battery / motherboard.

Interestingly the voltage drop from about 90% charge down to 10% (reported to acpi) is fairly linear though it does accelerate after this. I wonder if this last 10% discharge is good or bad for my (li-on) battery.
Will
contribute: [url=http://www.puppylinux.org]community website[/url], [url=http://tinyurl.com/6c3nm6]screenshots[/url], [url=http://tinyurl.com/6j2gbz]puplets[/url], [url=http://tinyurl.com/57gykn]wiki[/url], [url=http://tinyurl.com/5dgr83]rss[/url]

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

#55 Post by brad_chuck »

Yeah I had to do it that way because some laptops don't show voltage. In many I think it is one or the other not both. I only show mAh......


Post your changed script so others can see it and use it for themselves.

User avatar
HairyWill
Posts: 2928
Joined: Fri 26 May 2006, 23:29
Location: Southampton, UK

battery monitoring using voltage

#56 Post by HairyWill »

For those that are interested in using voltage to measure battery life, read on.

I wanted to investigate the discharge characteristics of my battery so I charged the battery up to full, disconnected the power, ran the following script and let the battery run flat, so that I had a record of the discharge. The script is customised to my ACPI setup on a Thinkpad X30 with a single battery on BAT0.

Code: Select all

#!/bin/sh
	echo  > /root/my-applications/share/batmon/bat.log
while true
do
	echo `cat /proc/acpi/battery/BAT0/state | grep "voltage" | awk '{print $3}'` >> /root/my-applications/share/batmon/bat.log
#	line below provides more details and is good for investigating 
#	echo `cat /proc/acpi/battery/BAT0/state | grep "present rate" | awk '{ print $3 }'`     `cat /proc/acpi/battery/BAT0/state | grep "voltage" | awk '{print $3}'`      `cat /proc/acpi/battery/BAT0/state | grep "remaining" | awk '{print $3}'` >> /root/bat-investigations.log
sleep 60
done
Once a minute it logs the voltage reported by ACPI. I actually recorded the remaining charge and discharge rate values from BAT0/state as well but as I don't now use these values for my monitor I've disabled that line. Here is a chart of the discharge log

Image
(I've never used gnumeric before and thought it was very good).

From this extended data collected I learnt that the remaining charge reported by ACPI was seriously underestimated, such that the battery was showing as almost flat for the last 40 minutes.

A small bit of theory.
I presume that there is no way of measuring the charge left in a battery. My understanding is that all that can be recorded is the voltage and current delivered by the battery at any time. Using power = voltage * current the system calculates the charge / discharge rate. Summing the rate over time can generate an estimate for the amount of charge put into or taken out of the battery.

By using my bat.log I calculated the total energy discharged by the battery this was approximately 50% more than the value reported in BAT0/info for "last full capacity".

All this talk of battery charge becomes irrelevant. What is important to the laptop is the voltage supplied by the battery and that it can supply sufficient current using that voltage. bat.log revealed a relationship between the voltage delivered by the battery and the remaining life. Studying the log also told me that my laptop powers off when the battery delivers less than 9.3 volts.

The important bit
Because the relationship between voltage and time left is not linear you can't use simple maths to calculate remaining life. (I suppose I could try and fit a function to the curve) I have kept my bat.log, and reversed it using

Code: Select all

sed '1!G;h;$!d' bat.log > discharge.log
My batmon script scans discharge.log to provide an estimate of the time left, based on the current battery voltage. A nice aside of using this is that if the load goes up, for instance when compiling, the battery voltage drops and this automatically adjusts the remaining battery life.

All this seems a lot of hassle and I wouldn't bother if my firmware battery monitor worked properly, but at least now I can get an accurate reading for remaining life. I haven't considered how it works when charging but I imagine its possible to do something similar. here is my batmon.sh script:

Code: Select all

#!/bin/sh
voltage=`cat /proc/acpi/battery/BAT0/state | grep "voltage" | awk '{print $3}'`
dischargerate=`cat /proc/acpi/battery/BAT0/state | grep "rate" | awk '{print $3}'`
#loop below scans each line in discharge.log until the log voltage is greater than the current voltage
#each line in the log corresponds to one minute of battery life
minutes=0
for volt in `cat /root/my-applications/share/batmon/discharge.log`
do
	if [ $volt -gt $voltage ]; then
		break
	fi
	let "minutes=(($minutes+1))"
done
#remove the values you are not interested in from the line below
	echo -n "${minutes}min ${voltage}mV ${dischargerate}mW"
This method works for the battery as it is now but doesn't take into account battery degredation over time.
Last edited by HairyWill on Wed 11 Apr 2007, 12:10, edited 1 time in total.
Will
contribute: [url=http://www.puppylinux.org]community website[/url], [url=http://tinyurl.com/6c3nm6]screenshots[/url], [url=http://tinyurl.com/6j2gbz]puplets[/url], [url=http://tinyurl.com/57gykn]wiki[/url], [url=http://tinyurl.com/5dgr83]rss[/url]

User avatar
debernardis
Posts: 180
Joined: Sat 12 Nov 2005, 08:01
Contact:

#57 Post by debernardis »

I would like to control the polling frequency for batmon, and in particular reduce it significantly. This because I have collisions between the apm utility (I have changed batmon.sh to use apm instead than acpi) and the mouse driver, which reset my pointer for several seconds. In order to reduce the incidence of such collisions, I would set polling to 60 seconds or similar long periods. Is it possible? Thanks

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

#58 Post by brad_chuck »

That's on my list. You can use the GINS version of batmon ( 0.1.0)

Just change the line that says

Code: Select all

sleep 1 
to

Code: Select all

sleep 60
you will have to download GINS and rename it to something like ginsbatmon then run the it from the jwm tray with ginsbatmon /path/batmonnew.sh

you will also have to change the line in batmonnew from this

Code: Select all

echo "/root/Projects/batmon/batmon.glade"
to the path to whrere you put the sctipt.

Sorry this is so crazy... I am sorting it out as fast as I can.


If you have problems post and I will give more precise instructions.

User avatar
HairyWill
Posts: 2928
Joined: Fri 26 May 2006, 23:29
Location: Southampton, UK

feedback on batmon-0.1.0

#59 Post by HairyWill »

Brad
I gave this a go last night but have a few problems.

1 Do you use JWM? I can't get the tray to swallow it properly, could you post your swallow entry?

2 It took me a while to realise I needed to use the gins from gins-bradc.tar.gz though I've worked that out now.

<edit> I've removed a comment about not finding ac_adapter, I hadn't loaded the module. Doh!</edit>
Keep up the good work, being able to have full control from a shell script is really good.

For future addins maybe toggling processor speed, temperature and fan speed as well would be good. I know all this stuff exists already but it must be possible to save some space and do it the puppy way.
Will
contribute: [url=http://www.puppylinux.org]community website[/url], [url=http://tinyurl.com/6c3nm6]screenshots[/url], [url=http://tinyurl.com/6j2gbz]puplets[/url], [url=http://tinyurl.com/57gykn]wiki[/url], [url=http://tinyurl.com/5dgr83]rss[/url]

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

#60 Post by brad_chuck »

Code: Select all

<Swallow name="ginsbatmon">
ginsbatmon /root/Projects/batmon/batmonnew.sh /root/Projects/batmon/batmon.glade
</Swallow>
Good power managment is on my list and it will be implemented as soon as possible.

For now you can install the processor modules to control your processor speed manualy.

just search google for "linux acpi processor scaling" or something of the sort.

the govanor you would be best to use is ondemand this will put your processor in the lowest state when not in use and ramp it up if it is needed.

Post Reply