]> pere.pagekite.me Git - homepage.git/blob - blog/archive/2015/09/09.rss
Generated.
[homepage.git] / blog / archive / 2015 / 09 / 09.rss
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/'>
3 <channel>
4 <title>Petter Reinholdtsen - Entries from September 2015</title>
5 <description>Entries from September 2015</description>
6 <link>http://people.skolelinux.org/pere/blog/</link>
7
8
9 <item>
10 <title>The life and death of a laptop battery</title>
11 <link>http://people.skolelinux.org/pere/blog/The_life_and_death_of_a_laptop_battery.html</link>
12 <guid isPermaLink="true">http://people.skolelinux.org/pere/blog/The_life_and_death_of_a_laptop_battery.html</guid>
13 <pubDate>Thu, 24 Sep 2015 16:00:00 +0200</pubDate>
14 <description>&lt;p&gt;When I get a new laptop, the battery life time at the start is OK.
15 But this do not last. The last few laptops gave me a feeling that
16 within a year, the life time is just a fraction of what it used to be,
17 and it slowly become painful to use the laptop without power connected
18 all the time. Because of this, when I got a new Thinkpad X230 laptop
19 about two years ago, I decided to monitor its battery state to have
20 more hard facts when the battery started to fail.&lt;/p&gt;
21
22 &lt;img src=&quot;http://people.skolelinux.org/pere/blog/images/2015-09-24-laptop-battery-graph.png&quot;/&gt;
23
24 &lt;p&gt;First I tried to find a sensible Debian package to record the
25 battery status, assuming that this must be a problem already handled
26 by someone else. I found
27 &lt;a href=&quot;https://tracker.debian.org/pkg/battery-stats&quot;&gt;battery-stats&lt;/a&gt;,
28 which collects statistics from the battery, but it was completely
29 broken. I sent a few suggestions to the maintainer, but decided to
30 write my own collector as a shell script while I waited for feedback
31 from him. Via
32 &lt;a href=&quot;http://www.ifweassume.com/2013/08/the-de-evolution-of-my-laptop-battery.html&quot;&gt;a
33 blog post about the battery development on a MacBook Air&lt;/a&gt; I also
34 discovered
35 &lt;a href=&quot;https://github.com/jradavenport/batlog.git&quot;&gt;batlog&lt;/a&gt;, not
36 available in Debian.&lt;/p&gt;
37
38 &lt;p&gt;I started my collector 2013-07-15, and it has been collecting
39 battery stats ever since. Now my
40 /var/log/hjemmenett-battery-status.log file contain around 115,000
41 measurements, from the time the battery was working great until now,
42 when it is unable to charge above 7% of original capasity. My
43 colletor shell script is quite simple and look like this:&lt;/p&gt;
44
45 &lt;pre&gt;
46 #!/bin/sh
47 # Inspired by
48 # http://www.ifweassume.com/2013/08/the-de-evolution-of-my-laptop-battery.html
49 # See also
50 # http://blog.sleeplessbeastie.eu/2013/01/02/debian-how-to-monitor-battery-capacity/
51 logfile=/var/log/hjemmenett-battery-status.log
52
53 files=&quot;manufacturer model_name technology serial_number \
54 energy_full energy_full_design energy_now cycle_count status&quot;
55
56 if [ ! -e &quot;$logfile&quot; ] ; then
57 (
58 printf &quot;timestamp,&quot;
59 for f in $files; do
60 printf &quot;%s,&quot; $f
61 done
62 echo
63 ) &gt; &quot;$logfile&quot;
64 fi
65
66 log_battery() {
67 # Print complete message in one echo call, to avoid race condition
68 # when several log processes run in parallell.
69 msg=$(printf &quot;%s,&quot; $(date +%s); \
70 for f in $files; do \
71 printf &quot;%s,&quot; $(cat $f); \
72 done)
73 echo &quot;$msg&quot;
74 }
75
76 cd /sys/class/power_supply
77
78 for bat in BAT*; do
79 (cd $bat &amp;&amp; log_battery &gt;&gt; &quot;$logfile&quot;)
80 done
81 &lt;/pre&gt;
82
83 &lt;p&gt;The script is called when the power management system detect a
84 change in the power status (power plug in or out), and when going into
85 and out of hibernation and suspend. In addition, it collect a value
86 every 10 minutes. This make it possible for me know when the battery
87 is discharging, charging and how the maximum charge change over time.
88 The code for the Debian package
89 &lt;a href=&quot;https://github.com/petterreinholdtsen/battery-status&quot;&gt;is now
90 available on github&lt;/a&gt;.&lt;/p&gt;
91
92 &lt;p&gt;The collected log file look like this:&lt;/p&gt;
93
94 &lt;pre&gt;
95 timestamp,manufacturer,model_name,technology,serial_number,energy_full,energy_full_design,energy_now,cycle_count,status,
96 1376591133,LGC,45N1025,Li-ion,974,62800000,62160000,39050000,0,Discharging,
97 [...]
98 1443090528,LGC,45N1025,Li-ion,974,4900000,62160000,4900000,0,Full,
99 1443090601,LGC,45N1025,Li-ion,974,4900000,62160000,4900000,0,Full,
100 &lt;/pre&gt;
101
102 &lt;p&gt;I wrote a small script to create a graph of the charge development
103 over time. This graph depicted above show the slow death of mylaptop
104 battery.&lt;/p&gt;
105
106 &lt;p&gt;But why is this happening? Why are my laptop batteries always
107 dying in a year or two, while the batteries of space probes and
108 satellites keep working year after year. If we are to believe
109 &lt;a href=&quot;http://batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries&quot;&gt;Battery
110 University&lt;/a&gt;, the cause is me charging the battery whenever I have a
111 chance, and the fix is to not charge the Lithium-ion batteries to 100%
112 all the time, but to stay below 90% of full charge most of the time.
113 I&#39;ve been told that the Tesla electric cars
114 &lt;a href=&quot;http://my.teslamotors.com/de_CH/forum/forums/battery-charge-limit&quot;&gt;limit
115 the charge of their batteries to 80%&lt;/a&gt;, with the option to charge to
116 100% when preparing for a longer trip (not that I would want a car
117 like Tesla where rights to privacy is abandoned, but that is another
118 story), which I guess is the option we should have for laptops on
119 Linux too.&lt;/p&gt;
120
121 &lt;p&gt;Is there a good and generic way with Linux to tell the battery to
122 stop charging at 80%, unless requested to charge to 100% once in
123 preparation for a longer trip? I found
124 &lt;a href=&quot;http://askubuntu.com/questions/34452/how-can-i-limit-battery-charging-to-80-capacity&quot;&gt;one
125 recipe on askubuntu for Ubuntu to limit charging on Thinkpad to
126 80%&lt;/a&gt;, but could not get it to work (kernel module refused to
127 load).&lt;/p&gt;
128
129 &lt;p&gt;I wonder why the battery capacity was reported to be more than 100%
130 at the start. I also wonder why the &quot;full capacity&quot; increases some
131 times, and if it is possible to repeat the process to get the battery
132 back to design capacity. And I wonder if the discharge and charge
133 speed change over time, or if this stay the same. I did not yet try
134 to write a tool to calculate the derivative values of the battery
135 level, but suspect some interesting insights might be learned from
136 those.&lt;/p&gt;
137 </description>
138 </item>
139
140 <item>
141 <title>Book cover for the Free Culture book finally done</title>
142 <link>http://people.skolelinux.org/pere/blog/Book_cover_for_the_Free_Culture_book_finally_done.html</link>
143 <guid isPermaLink="true">http://people.skolelinux.org/pere/blog/Book_cover_for_the_Free_Culture_book_finally_done.html</guid>
144 <pubDate>Thu, 3 Sep 2015 21:00:00 +0200</pubDate>
145 <description>&lt;p&gt;Creating a good looking book cover proved harder than I expected.
146 I wanted to create a cover looking similar to the original cover of
147 the
148 &lt;a href=&quot;https://github.com/petterreinholdtsen/free-culture-lessig&quot;&gt;Free
149 Culture&lt;/a&gt; book we are translating to Norwegian, and I wanted it in
150 vector format for high resolution printing. But my inkscape knowledge
151 were not nearly good enough to pull that off.
152
153 &lt;p&gt;But thanks to the great inkscape community, I was able to wrap up
154 the cover yesterday evening. I asked on the
155 &lt;a href=&quot;irc://irc.freenode.net/%23inkscape&quot;&gt;#inkscape IRC channel&lt;/a&gt;
156 on Freenode for help and clues, and Marc Jeanmougin (Mc-) volunteered
157 to try to recreate it based on the PDF of the cover from the HTML
158 version. Not only did he create a
159 &lt;a href=&quot;https://marc.jeanmougin.fr/share/copy1.svg &quot;&gt;SVG document with
160 the original and his vector version side by side&lt;/a&gt;, he even provided
161 an &lt;a href=&quot;https://marc.jeanmougin.fr/share/out-1.ogv&quot;&gt;instruction
162 video&lt;/a&gt; explaining how he did it&lt;/a&gt;. But the instruction video is
163 not easy to follow for an untrained inkscape user. The video is a
164 recording on how he did it, and he is obviously very experienced as
165 the menu selections are very quick and he mentioned on IRC that he did
166 use some keyboard shortcuts that can&#39;t be seen on the video, but it
167 give a good idea about the inkscape operations to use to create the
168 stripes with the embossed copyright sign in the center.&lt;/p&gt;
169
170 &lt;p&gt;I took his SVG file, copied the vector image and re-sized it to fit
171 on the cover I was drawing. I am happy with the end result, and the
172 current english version look like this:&lt;/p&gt;
173
174 &lt;img src=&quot;http://people.skolelinux.org/pere/blog/images/2015-09-03-free-culture-cover.png&quot; width=&quot;70%&quot; align=&quot;center&quot;/&gt;
175
176 &lt;p&gt;I am not quite sure about the text on the back, but guess it will
177 do. I picked three quotes from the official site for the book, and
178 hope it will work to trigger the interest of potential readers. The
179 Norwegian cover will look the same, but with the texts and bar code
180 replaced with the Norwegian version.&lt;/p&gt;
181
182 &lt;p&gt;The book is very close to being ready for publication, and I expect
183 to upload the final draft to Lulu in the next few days and order a
184 final proof reading copy to verify that everything look like it should
185 before allowing everyone to order their own copy of Free Culture, in
186 English or Norwegian Bokmål. I&#39;m waiting to give the the productive
187 proof readers a chance to complete their work.&lt;/p&gt;
188 </description>
189 </item>
190
191 </channel>
192 </rss>