<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>gonium.net &#187; english</title>
	<atom:link href="http://gonium.net/md/category/english/feed/" rel="self" type="application/rss+xml" />
	<link>http://gonium.net/md</link>
	<description>so much time, so little to do.</description>
	<lastBuildDate>Fri, 30 Jul 2010 13:47:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Contiki and Mac OS</title>
		<link>http://gonium.net/md/2010/07/30/contiki-and-mac-os/</link>
		<comments>http://gonium.net/md/2010/07/30/contiki-and-mac-os/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 09:52:42 +0000</pubDate>
		<dc:creator>md</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[smartgrid]]></category>
		<category><![CDATA[6LoWPAN]]></category>
		<category><![CDATA[avr]]></category>
		<category><![CDATA[microcontroller]]></category>
		<category><![CDATA[mysmartgrid]]></category>

		<guid isPermaLink="false">http://gonium.net/md/?p=271</guid>
		<description><![CDATA[At the moment I am building a small demo based on the AVR Raven and Contiki. I was running into some trouble with building the Firmwares on my Mac &#8211; this is the documentation of the workarounds.
The Contiki build system depends on some GNU utilities that are not installed. Using the following steps I was [...]]]></description>
			<content:encoded><![CDATA[<p>At the moment I am building a small demo based on the AVR Raven and Contiki. I was running into some trouble with building the Firmwares on my Mac &#8211; this is the documentation of the workarounds.</p>
<p>The Contiki build system depends on some GNU utilities that are not installed. Using the following steps I was able to compile for the &#8220;native&#8221; (i.a. Mac OS) target:</p>
<ol>
<li>Install GNU binutils using MacPorts.</li>
<li>Edit &#8220;cpu/native/Makefile.native&#8221; and adjust the &#8220;Compiler Definitions&#8221; section like this:<br />
<code><br />
### Compiler definitions<br />
CC       = gcc<br />
LD       = gcc<br />
AS       = as<br />
NM       = nm<br />
# Use GNU ar instead of /usr/bin/ar<br />
AR       = gar<br />
OBJCOPY  = objcopy<br />
STRIP    = strip<br />
ifdef WERROR<br />
CFLAGSWERROR=-Werror -pedantic -std=c99 -Werror<br />
endif<br />
CFLAGSNO = -Wall -g -I/usr/local/include $(CFLAGSWERROR)<br />
CFLAGS  += $(CFLAGSNO) -D_XOPEN_SOURCE=500 -O<br />
# Simplify ld arguments<br />
#LDFLAGS  = -Wl,-Map=contiki-$(TARGET).map,-export-dynamic<br />
LDFLAGS  = -Wl<br />
</code></li>
</ol>
<p>Another issue is the ELF binaries for the AVR Raven boards. These files contain all components of the programs: flash and eeprom<br />
images as well as fuse settings. Unfortunately, avrdude cannot read the ELF format. So you have to extract the flash manually:</p>
<p><code><br />
$ avr-objcopy -R .eeprom -R .fuse -R .signature -O ihex $NAME.elf $NAME.hex<br />
</code></p>
<p>It works similar for the EEPROM section (where the IP data is stored):<br />
<code><br />
$ avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex webserver6.elf webserver6.eep<br />
</code></p>
<p>You can also check which fuse settings are used:<br />
<code><br />
$ avr-objdump -d -S -j .fuse webserver6.elf<br />
webserver6.elf:     file format elf32-avr<br />
Disassembly of section .fuse:<br />
00820000 <__fuse>:<br />
  820000:	e2 99 ff<br />
</__fuse></code></p>
<p>The directory structure of Contiki is somewhat overwhelming. I am currently working in these directories:</p>
<ol>
<li>contiki-2.4/platform/avr-ravenlcd: This is where the code for the ATMega3290p lives. Run make here and upload.</li>
<li>contiki-2.4/platform/avr-raven: The ATMega1284p code lives here, this is where most patches are. Don&#8217;t run make here!</li>
<li>contiki-2.4/examples/webserver-ipv6-raven: Run make here for the ATMega1284p code. This builds the webserver code and includes the platform/avr-raven dir.</li>
</ol>
<p>In addition, I have a serial terminal for debugging output:<br />
<code>screen -U /dev/cu.SLAB_USBtoUART 57600</code></p>
]]></content:encoded>
			<wfw:commentRss>http://gonium.net/md/2010/07/30/contiki-and-mac-os/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby for Chumby: HowTo</title>
		<link>http://gonium.net/md/2010/06/02/ruby-for-chumby-howto/</link>
		<comments>http://gonium.net/md/2010/06/02/ruby-for-chumby-howto/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 15:06:09 +0000</pubDate>
		<dc:creator>md</dc:creator>
				<category><![CDATA[digital]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[smartgrid]]></category>
		<category><![CDATA[chumby]]></category>
		<category><![CDATA[embedded]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://gonium.net/md/?p=261</guid>
		<description><![CDATA[
It took me a while to figure this out, so here are my notes:


Install Scratchbox as described here. This greatly simplifies cross-compiling things. It also provides you a way to run the compiled ruby interpreter on a bigger host machine using QEMU. This is essential because I rely on rubygems, and the Chumby is too [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://gonium.net/md/2010/06/02/ruby-for-chumby-howto/chumby/" rel="attachment wp-att-265"><img src="http://gonium.net/md/wp-content/uploads/2010/06/chumby.jpg" alt="" title="chumby" width="500" height="387" class="alignnone size-full wp-image-265" /></a></p>
<p>It took me a while to figure this out, so here are my notes:<br />
<span id="more-261"></span></p>
<ol>
<li>Install Scratchbox as described <a href="http://wiki.chumby.com/mediawiki/index.php/Scratchbox">here</a>. This greatly simplifies cross-compiling things. It also provides you a way to run the compiled ruby interpreter on a bigger host machine using QEMU. This is essential because I rely on rubygems, and the Chumby is too small to execute the gem install commands. Besides, at least for the sqlite3-ruby and mongrel gems, I need to compile native code.</li>
<li>Install dependencies. I found the following libraries necessary:
<ul>
<li>OpenSSL 0.9.8n &#8211; avoid the 1.0.0 version, it causes problems with the Ruby interpreter.</li>
<li>Zlib 1.5.3 &#8211; same as installed on the Chumby.</li>
<li>Readline 6.1</li>
<li>A recent version of sqlite, since I need it for my gems later on.</li>
</ul>
<p>Compile the libraries and install them into /mnt/storage (use &#8211;prefix where necessary).</li>
<li>Adjust the environment to use the new libraries:<br />
<code>BASEDIR=/mnt/storage/usr<br />
export PATH=$PATH:$BASEDIR/bin<br />
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$BASEDIR/lib</code></li>
<li>Install Ruby and rubygems. I was not able to compile Ruby 1.8.7, but Ruby 1.8.6-p399 works nice. To configure everything, I use the following commands:<br />
<code>export ac_cv_func_getpgrp_void=yes<br />
export ac_cv_func_setpgrp_void=yes<br />
./configure --target=arm-linux --host=arm-linux --disable-pthread --enable-wide-getaddrinfo --enable-zlib --with-zlib-dir=/mnt/storage/usr --enable-readline --with-readline-dir=/mnt/storage/usr --prefix=/mnt/storage/usr --with-openssl-dir=/mnt/storage/usr &#038;&#038; make &#038;&#038; make install<br />
</code></li>
<li>Install rubygems:<br />
<code><br />
/mnt/storage/usr/bin/ruby setup.rb --prefix=/mnt/storage/usr<br />
mkdir -p /mnt/storage/usr/lib/ruby/gems/1.8<br />
</code></li>
<li>Afterwards, the necessary gems can be installed using the gem command. It might be necessary to provide additonal path information to the gems that compile native extensions, for example<br />
<code>gem install sqlite3-ruby -- --with-sqlite3-dir=/mnt/storage/usr</code>
</li>
</ol>
<p>The result is an image with Ruby installed, and all necessary gems for my project. The <a href="http://gonium.net/media/chumby-ruby-1.8.6-p399.tar.gz">tarball can be downloaded here</a>. To install, scp it to the Chumby and log in:<br />
<code><br />
scp *tarball* root@*chumby-ip*:/mnt/storage<br />
ssh -l root *chumby-ip*<br />
cd /mnt/storage<br />
tar xvzf *tarball*<br />
</code></p>
<p>Now you have a directory /mnt/storage/usr with all tools permanently installed on your Chumby. In order to use it, please adjust your PATH and LD_LIBRARY_PATH appropriately:<br />
<code><br />
export BASEDIR=/mnt/storage/usr<br />
export PATH=$PATH:$BASEDIR/bin<br />
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$BASEDIR/lib<br />
</code></p>
<p>/me mumbles more automation needed. But not today.</p>
]]></content:encoded>
			<wfw:commentRss>http://gonium.net/md/2010/06/02/ruby-for-chumby-howto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Power Metering with Flukso</title>
		<link>http://gonium.net/md/2009/11/10/power-metering-with-flukso/</link>
		<comments>http://gonium.net/md/2009/11/10/power-metering-with-flukso/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 16:01:36 +0000</pubDate>
		<dc:creator>md</dc:creator>
				<category><![CDATA[digital]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[flukso]]></category>
		<category><![CDATA[mysmartgrid]]></category>
		<category><![CDATA[smartgrid]]></category>
		<category><![CDATA[smartmeter]]></category>

		<guid isPermaLink="false">http://gonium.net/md/?p=180</guid>
		<description><![CDATA[
All the electric power generated from renewable energy is good &#8211; no additional CO2 is produced. Saving energy in general is also a good idea &#8211; what you don&#8217;t consume, you don&#8217;t need to produce. But energy savings require you to understand your own energy consumption &#8211; you can&#8217;t improve what you can&#8217;t measure. A [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://gonium.net/md/wp-content/uploads/2009/11/3554570745_0e9fd9a7ac.jpg" alt="3554570745_0e9fd9a7ac" title="3554570745_0e9fd9a7ac" width="500" height="331" class="alignnone size-full wp-image-198" /></p>
<p>All the electric power generated from renewable energy is good &#8211; no additional CO2 is produced. Saving energy in general is also a good idea &#8211; what you don&#8217;t consume, you don&#8217;t need to produce. But energy savings require you to understand your own energy consumption &#8211; you can&#8217;t improve what you can&#8217;t measure. A simple energy cost monitor is available for 10 Euro, but it requires you to plug it into different appliances in order to figure out what a specific device consumes. And only the more expensive ones log the power consumption over time, which is pretty interesting.</p>
<p><span id="more-180"></span></p>
<p>An alternative to the simple energy meters are smart meters. In Germany, utility providers need to offer their customers the replacement of old (typically black) meters with shiny new digital &#8220;smart&#8221; meters. Actually, there is nothing smart about them &#8211; they just transmit the energy consumption of the household via powerline or other technologies to the utility provider. The utility provider does not need to visit the household in order to get the reading. And, in some cases, customers can have a look at the realtime energy consumption of their household.</p>
<p>The benefit of the realtime data is that you can assess the impact of your actual energy use very quickly. Google.org is offering the <a href="http://www.google.org/powermeter/">PowerMeter</a>, which works for example with the smart meters offered by <a href="http://www.yellostrom.de/privatkunden/sparzaehler/index.html">Yello Strom</a>. An interesting open-source alternative is the <a href="http://flukso.net">Flukso</a>. </p>
<p>The Flukso is a little WLAN router with some additional circuits to measure your power consumption. You install it in your breaker box. Depending on the configuration of your breaker box you need one or three current clamps. These clamps just go around the cables that supply your household &#8211; it is not necessary to re-cable the breaker box. I have a three-phase supply, so my installation consists of three current clamps and the Flukso itself. <a href="http://www.rowetel.com/blog/?p=135">David Rowe</a> has a nice writeup on the installation.</p>
<p>The Flukso then measures the power and transmits the data over the WLAN to the Flukso website. Once you&#8217;re logged in you can see your own energy consumption as a realtime graph. It is quite fascinating to find out how your energy consumption is composed. Here is one of my charts:</p>
<p><img src="http://gonium.net/md/wp-content/uploads/2009/11/Power-Annotated.png" alt="My power consumption - jetlag clearly visible." title="Power-Annotated" width="600" height="430" class="alignnone size-full wp-image-196" /></p>
<p>The graph shows time on the X-axis and my energy consumption in Watts on the Y-axis. The peak (1) shows that I was getting up in the middle of the night, preparing some tea and switchin on my computer. I had a pretty decent jet lag that night. In the morning I got up again around 8:00 (2). Apparently I used my coffee machine and switched on some lights, but I left shortly afterwards. The regular power consumption (3) originates from my fridge which draws power in regular intervals. Around 18:00, I got home again, switched on lights, prepared tea etc (4).</p>
<p>The graph is very interesting and really helps to improve your energy usage. But it also scares me &#8211; as I demonstrated above, a lot of information is stored in such a graph. Honestly, I don&#8217;t want my utility provider to know this. And I definitely do not want Google to know that much about my life. Or would you like to see advertisements for sleeping pills after a night of jet lag?</p>
<p>The picture at the top is <a href="http://www.flickr.com/photos/22746515@N02/3554570745/">CC-BY BK59 on flickr</a>, thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://gonium.net/md/2009/11/10/power-metering-with-flukso/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Demand-Side Management: mySmartGrid</title>
		<link>http://gonium.net/md/2009/11/02/demand-side-management-mysmartgrid/</link>
		<comments>http://gonium.net/md/2009/11/02/demand-side-management-mysmartgrid/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 12:57:45 +0000</pubDate>
		<dc:creator>md</dc:creator>
				<category><![CDATA[digital]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[demand-side management]]></category>
		<category><![CDATA[mysmartgrid]]></category>
		<category><![CDATA[powergrid]]></category>
		<category><![CDATA[smartgrid]]></category>

		<guid isPermaLink="false">http://gonium.net/md/?p=177</guid>
		<description><![CDATA[
Green energy is good. Finally, people around the world begin to realize that the climate change is a serious problem for mankind. Driving with a car harms the environment &#8211; more efficient cars (or electric vehicles) are the new SUVs. On the other hand, a lot of energy is consumed in private households. In Germany, [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://gonium.net/md/wp-content/uploads/2009/11/renewable.jpg" alt="Renewable Energy" title="Renewable Energy" width="600" class="alignnone size-full wp-image-182" /></p>
<p>Green energy is good. Finally, people around the world begin to realize that the climate change is a serious problem for mankind. Driving with a car harms the environment &#8211; more efficient cars (or electric vehicles) are the new SUVs. On the other hand, a lot of energy is consumed in private households. In Germany, energy-efficient remodeling is rewarded with cheap credits. Often, solar power is used to heat water and generate electricity. More and more wind parks are built which also draw their energy from the sun, indirectly.</p>
<p>Unfortunately, renewable energy source create problems for the conventional power grids. In a power grid, demand and supply of electricity must match at all times. If a consumer draws power from it, the exact amount of power needs to be fed back into the power grid as fast as possible. There is almost no reservoir for electrical power (except for pump storage hydro power plants, but the capacity is limited). Since renewable energy sources such as solar and wind power cannot be planned additional power capacities need to be in place in order to compensate for the lack of power.</p>
<p><span id="more-177"></span></p>
<p>In the German research project <a href="http://mysmartgrid.de/">&#8220;mySmartGrid&#8221;</a> I am working on another technique to alleviate the erratic nature of these power sources. Instead of adding more production capacity or storage capacity we want to control the demand for power. In addition to the not-enough-power-available problem we currently have another problem: the too-much-power problem. When wind blows over Germany, significant power is generated &#8211; whether it is needed or not. Often, wind parks need to be shut down when too much power is generated. This is clearly not desirable from an ecological point of view. </p>
<p>To put it simply: We have either too much energy available, or not enough. It is rare that we have exactly the right amount of energy at our hands. This situation is shown here:</p>
<p><img src="http://gonium.net/md/wp-content/uploads/2009/11/demandsupply.png" alt="demandsupply" title="demandsupply" width="600" class="alignnone size-full wp-image-185" /></p>
<p>We can influence this only to a certain degree. BUT: We can change the way we consume the energy. For example, think of your fridge: It doesn&#8217;t matter whether it draws power now or five minutes later. The temperature change is inert. Thus, it is easy to move the demand &#8211; not save any power, but shift the demand for electricity by some time. In other words: switch the fridge of when the supply is short. Then, when the supply exceeds the demand, switch the fridge on again &#8211; it will draw more power since the internal temperature was raised. This is what we do:</p>
<p><img src="http://gonium.net/md/wp-content/uploads/2009/11/delaydemand.png" alt="delaydemand" title="delaydemand" width="600" class="alignnone size-full wp-image-186" /></p>
<p>Of course, this is only the simplified version of what we are doing. In reality, we must ensure that food doesn&#8217;t go bad. In addition, controlling a single fridge has almost no impact. But if you aggregate lots of households, the impact can be significant. Heat pumps consume a lot more energy and can be controlled in a similar way. If you can combine lots of households with heat pumps, fridges and freezers, the impact on the demand side is serious.</p>
<p>In the mySmartGrid project we combine up to 1000 households. We intend to control the energy consumption of household appliances as described above. The following picture shows a high-level overview of the architecture: </p>
<p><img src="http://gonium.net/md/wp-content/uploads/2009/11/Arch-Overview.png" alt="Arch-Overview" title="Arch-Overview" width="600" class="alignnone size-full wp-image-187" /></p>
<p>We combine the predicted power supply information for a period with statistical models of the power consumption of our households. This gives us an understanding when too much energy is available. We create schedules that contain information when a household should maximize its energy consumption. The schedules are then distributed to the households. The so-called &#8220;Kundenhub&#8221; is currently an iPod which offers a user interface. Household members can always override the schedule we propose.</p>
<p>The iPod uses various mathematical models to determine how to switch appliances on or off. It executes the strategies locally: there is no direct remote control over household appliances. The commands are sent to connectors close to the appliance which then can control the appliance.</p>
<p>This research project contains a lot of challenges &#8211; but I save this for another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://gonium.net/md/2009/11/02/demand-side-management-mysmartgrid/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DCF77 Radio Receiver &#8211; Filter Signals</title>
		<link>http://gonium.net/md/2009/09/16/dcf77-radio-receiver-filter-signals/</link>
		<comments>http://gonium.net/md/2009/09/16/dcf77-radio-receiver-filter-signals/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 15:36:46 +0000</pubDate>
		<dc:creator>md</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[digital]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[nerdism]]></category>
		<category><![CDATA[dcf77]]></category>
		<category><![CDATA[microcontroller]]></category>

		<guid isPermaLink="false">http://gonium.net/md/?p=157</guid>
		<description><![CDATA[
I live close to the DCF77 radio transmitter, so my signal was always pretty strong and clear. This is of course not the case for everybody :-) Gwen Roelants did run into problems. He writes:

Although your code works (thanks for that!) it looked like it was very sensitive to how the antenna was positioned.
I found [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://gonium.net/md/wp-content/uploads/2009/09/3307744005_240347734f.jpg" alt="Broadcast Tower" title="Broadcast Tower" width="333" height="500" class="alignnone size-full wp-image-158" /></p>
<p>I live close to the DCF77 radio transmitter, so my signal was always pretty strong and clear. This is of course not the case for everybody :-) Gwen Roelants did run into problems. He writes:</p>
<blockquote><p>
Although your code works (thanks for that!) it looked like it was very sensitive to how the antenna was positioned.<br />
I found that I did receive a signal every second, but that for the longer signals, I sometimes got a short flash interrupting it, causing the library to add 2 seconds instead of one. Since I got such a flash in almost every minute it could take a very long time before a proper sync was found, and because 2 seconds were counted the time would also drift during the time no new signal could be decoded.<br />
I found a rather simple fix for your code that greatly improved the reliability and time to find a correct signal.
</p></blockquote>
<p>I don&#8217;t have an Arduino around so I did not test it, but the proposed changes seem to be reasonable. You can find the changes <a href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1252842755">in the Arduino forums</a>. Thanks, Gwen!</p>
<p>The photo was CCed on flickr by <a href="http://www.flickr.com/photos/nathangibbs/3307744005/">Nathan Gibbs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gonium.net/md/2009/09/16/dcf77-radio-receiver-filter-signals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby 1.9 Performance</title>
		<link>http://gonium.net/md/2009/04/17/ruby-19-performance/</link>
		<comments>http://gonium.net/md/2009/04/17/ruby-19-performance/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 09:51:15 +0000</pubDate>
		<dc:creator>md</dc:creator>
				<category><![CDATA[digital]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[profiling]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://gonium.net/md/?p=146</guid>
		<description><![CDATA[I&#8217;m currently using Ruby to optimize schedules based on a simulated annealing approach. For my current intermediate version I rely on marshalling internal datastructures really frequently. Out of curiosity I compared the runtimes of Ruby 1.8 and 1.9:

Ruby 1.8.6: 21 minutes, 55 seconds
Ruby 1.9.0: 22 minutes, 13 seconds

I certainly did not expect any wonders, but [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently using Ruby to optimize schedules based on a simulated annealing approach. For my current intermediate version I rely on marshalling internal datastructures really frequently. Out of curiosity I compared the runtimes of Ruby 1.8 and 1.9:</p>
<ul>
<li>Ruby 1.8.6: 21 minutes, 55 seconds</li>
<li>Ruby 1.9.0: 22 minutes, 13 seconds</li>
</ul>
<p>I certainly did not expect any wonders, but in theis case, the runtimes are about the same. So I&#8217;m investigating further, using the ruby 1.8 profiler on a smaller test problem:</p>
<p><code><br />
    %   cumulative   self              self     total<br />
 time   seconds   seconds    calls  ms/call  ms/call  name<br />
 33.20    32.96     32.96      661    49.86    77.25  Marshal.load<br />
 17.80    50.63     17.67     6365     2.78    14.96  Array#each<br />
 17.52    68.03     17.40   601659     0.03     0.03  IO#getc<br />
  9.19    77.15      9.12      660    13.82    13.82  Marshal.dump<br />
  6.01    83.12      5.97   187158     0.03     0.03  Float#+<br />
</code></p>
<p>My code spends 42.39 percent of its runtime doing marshalling operations. For Ruby 1.9, the code spends 48.98 percent of its runtime doing marshalling. This is somewhat disappointing. In a second round I changed my code to not relying on marshalling &#8211; basically, I am using clone on essential internal datastructures. All other information can be reconstructed afterwards. This means that I need to recompute certain values, but evidently this is a much faster approach:</p>
<ul>
<li>Ruby 1.8.6: 1 minute, 34 seconds</li>
<li>Ruby 1.9.0: 1 minute, 17 seconds</li>
</ul>
<p>Note to self: always use a profiler before refactoring code for performance reasons. </p>
]]></content:encoded>
			<wfw:commentRss>http://gonium.net/md/2009/04/17/ruby-19-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>USBTemp v0.1.1 released</title>
		<link>http://gonium.net/md/2009/03/08/usbtemp-v011-released/</link>
		<comments>http://gonium.net/md/2009/03/08/usbtemp-v011-released/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 10:42:33 +0000</pubDate>
		<dc:creator>md</dc:creator>
				<category><![CDATA[digital]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[microcontroller]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[usbtemp]]></category>

		<guid isPermaLink="false">http://gonium.net/md/?p=140</guid>
		<description><![CDATA[
I just released a new version of USBTemp. This one includes some minor bugfixes:

The placement of C5 was wrong in the schematic.
The host software now compensates for some USB hickups.
The RRDTool graph generation script adds minimum, maximum and average temperature readings to the summary.

You can get the new version from the Mikrowerk page. The photo [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://gonium.net/md/wp-content/uploads/2009/03/154080119_b47a579bec1.jpg" title="154080119_b47a579bec1" width="500" height="384" class="size-full wp-image-142" /></p>
<p>I just released a new version of USBTemp. This one includes some minor bugfixes:</p>
<ul>
<li>The placement of C5 was wrong in the schematic.</li>
<li>The host software now compensates for some USB hickups.</li>
<li>The RRDTool graph generation script adds minimum, maximum and average temperature readings to the summary.</li>
</ul>
<p>You can get the new version from the <a href="http://code.google.com/p/mikrowerk/wiki/USBTemp">Mikrowerk page</a>. The photo of the Galileo thermometer above was CC&#8217;ed on flickr by <a href="http://www.flickr.com/photos/nicklawes/154080119/">Nick Lawes</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gonium.net/md/2009/03/08/usbtemp-v011-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>USBTemp: Continuous Temperature Monitoring</title>
		<link>http://gonium.net/md/2009/01/03/usbtemp-continuous-temperature-monitoring/</link>
		<comments>http://gonium.net/md/2009/01/03/usbtemp-continuous-temperature-monitoring/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 18:21:09 +0000</pubDate>
		<dc:creator>md</dc:creator>
				<category><![CDATA[digital]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[nerdism]]></category>
		<category><![CDATA[atmega168]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[microcontroller]]></category>
		<category><![CDATA[NSLU]]></category>
		<category><![CDATA[temperature]]></category>
		<category><![CDATA[usbtemp]]></category>

		<guid isPermaLink="false">http://gonium.net/md/?p=124</guid>
		<description><![CDATA[
Its this time of the year: I have time for a small project. This year I have built an USB-powered thermometer. Basically, you just plug it into an USB port. Then you can query the module via a small commandline tool. I wanted to be able to use my NSLU for creating temperature graphs. The [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://gonium.net/media/temp/outside-last-24-hours.png" alt="Kaiserlautern, Germany" /></p>
<p>Its this time of the year: I have time for a small project. This year I have built an USB-powered thermometer. Basically, you just plug it into an USB port. Then you can query the module via a small commandline tool. I wanted to be able to use my NSLU for creating temperature graphs. The image above is the temperature in Kaiserslautern, Germany &#8211; updated every 15 minutes.</p>
<p><span id="more-124"></span></p>
<p>The code and the schematic are open-source, licensed under the terms of the GPL. The code is available at the Mikrowerk code repository:</p>
<p><a href="http://code.google.com/p/mikrowerk/wiki/USBTemp">USBTemp start page at Mikrowerk</a></p>
<p>On these pages you can read more about the actual device and the software. This post describes how to use USBtemp to record temperature information continuously. Im am using my trusty NSLU running Debian as a host &#8211; any other Linux/Mac machine will work the same way. The NSLU is a NAS device. It is small and doesn&#8217;t consume too much power (about 20 W).</p>
<p><img src="http://gonium.net/media/usbtemp/NSLU.jpg" alt="My NSLU home server" /></p>
<p>The USBTemp device is attached to the second USB port of the NSLU. Using the host software I can easily query the sensors of the device:<br />
<code><br />
$ ./usbtemp sensors<br />
2 sensor(s) found, querying<br />
sensor 0: ID 9F17A5010800 type: (DS18S20)<br />
sensor 1: ID B46865010800 type: (DS18S20)<br />
</code><br />
The first sensor is soldered on the USBTemp board itself &#8211; it monitors the temperature in my office. The second sensor is attached to my balcony:</p>
<p><img src="http://gonium.net/media/usbtemp/outside-sensor.jpg" alt="Outside sensor" /></p>
<p>Actually the sensor is hidden in the white box to protect it from rain. The sensor is the second in the list above, so I can query it using the command<br />
<code><br />
/usbtemp temp B46865010800<br />
searching sensor with id B46865010800 - using sensor handle 1<br />
reading sensor 1 (°C): +1.1875<br />
</code><br />
In combination with RRDTool it is easy to create timeline graphs. The USBTemp package contains scripts that help you to do this. First, you have to edit the settings in etc/config.sh:</p>
<p><code><br />
# This file contains the configuration. Adjust it to meet your needs.<br />
SENSOR1_ID="9F17A5010800"<br />
SENSOR2_ID="B46865010800"<br />
TEMP_DATABASE="$HOME/usbtemp/temperatures.rrd"<br />
GRAPH_DIRECTORY="$HOME/usbtemp/temp-graphs"<br />
</code><br />
Then you must define the USB_HOME environment variable to point to your USBTemp installation directory, e.g. (for bash)<br />
<code><br />
export USBTEMP_HOME=/home/md/Projects/usbtemp/trunk<br />
</code><br />
As soon as you like the settings you can use bin/generate-db.sh to create the RRDTool database. Please review the script if you want to adjust some settings. I use the cron daemon to query the sensors periodically (every five minutes) and update the plots every 15 minutes. This is the crontab:<br />
<code><br />
# Linux cron can handle environment variables<br />
# set usbtemp path<br />
USBTEMP_HOME=/home/md/Projects/usbtemp/trunk</p>
<p># m h  dom mon dow   command<br />
*/5 * * * *     $USBTEMP_HOME/bin/log-temperature.sh > /dev/null 2>&#038;1<br />
*/15 * * * *    $USBTEMP_HOME/bin/plot-temperature.sh > /dev/null 2>&#038;1<br />
</code><br />
I use another little script to upload the graphs of the external sensor to my webserver. For my personal use, I also generate graphs of my office temperature &#8211; but I don&#8217;t publish these :-)</p>
<p>Here are the <a href="http://gonium.net/md/temperature/">currently available temperature plots</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gonium.net/md/2009/01/03/usbtemp-continuous-temperature-monitoring/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Code Kata: Project Euler #7, Finding Primes</title>
		<link>http://gonium.net/md/2008/09/08/code-kata-project-euler-7-finding-primes/</link>
		<comments>http://gonium.net/md/2008/09/08/code-kata-project-euler-7-finding-primes/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 08:08:52 +0000</pubDate>
		<dc:creator>md</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[nerdism]]></category>
		<category><![CDATA[codekata]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[primes]]></category>
		<category><![CDATA[projecteuler]]></category>

		<guid isPermaLink="false">http://gonium.net/md/?p=100</guid>
		<description><![CDATA[
I resumed my code katas &#8211; this time, I&#8217;m using Erlang to solve the problem:

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10001st prime number?


It seems to be clever to have a prime number generator for Project Euler [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://gonium.net/md/wp-content/uploads/2008/09/338443480_8127cdd845_o.jpg" alt="" title="Ulam_Spiral" width="500" height="333" class="alignnone size-full wp-image-101" /></p>
<p>I resumed my code katas &#8211; this time, I&#8217;m using Erlang to solve the problem:</p>
<blockquote><p>
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.<br />
What is the 10001st prime number?
</p></blockquote>
<p><span id="more-100"></span></p>
<p>It seems to be clever to have a prime number generator for Project Euler anyway. My implementation is based on the <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes">Sieve of Erathosthenes</a> and uses the <a href="http://mathworld.wolfram.com/PrimeNumberTheorem.html">Prime Number Theorem</a> for an estimate on the size of the sieve. The code is pretty easy:</p>
<p class="vci_info">[viewcode]src=pe7.erl [/viewcode]</p>
<pre class="vci_code"></pre>
<p class="vci_info">HTML code generated by <a href="http://www.zacharyfox.com/blog/free-tools/vim-color-improved">vim-color-improved v.0.4.0.</a><strong>Download this code:</strong> <a href="http://gonium.net/media//pe7.erl">pe7.erl</a></p>
<p>In the erathosthenes function, a list comprehension is used to purge all multiplies of the current Index value. My first attempt didn&#8217;t include the Index variable &#8211; I simply decreased the boundary. The disadvantage of this method is that it keeps the list of primes bigger over the runtime: Instead of removing the multiples of 2 at the very beginning, they get removed as the last multiples. The size of PurgedNumbers stays bigger, which leads to a runtime of 6.7 seconds. When I use the Index variable, the multiples of 2 get removed first which avoids copying them all the way. The runtime decreases to 1.2 seconds (on my Mac Mini).</p>
<p>Since all variables in Erlang are bound only once, I don&#8217;t know how to optimize this further. In C, I would use a bit array to further reduce the memory footprint. But: the Erlang code is much easier to read and write. I think Erlang is just not made for low memory bandwidth requirements :-)</p>
<p>The picture above is an representation of the <a href="http://en.wikipedia.org/wiki/Ulam_spiral">Ulam spiral</a>, CCed on flickr by <a href="http://flickr.com/photos/kusamakura/338443480/">no_typographic_man</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://gonium.net/md/2008/09/08/code-kata-project-euler-7-finding-primes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeRTOS for ATMega644</title>
		<link>http://gonium.net/md/2008/08/10/freertos_for_atmega644/</link>
		<comments>http://gonium.net/md/2008/08/10/freertos_for_atmega644/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 16:19:26 +0000</pubDate>
		<dc:creator>md</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[nerdism]]></category>
		<category><![CDATA[ATMega]]></category>
		<category><![CDATA[microcontroller]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[rtos]]></category>

		<guid isPermaLink="false">http://gonium.net/md/?p=89</guid>
		<description><![CDATA[
FreeRTOS is an open-source realtime operating system for microcontrollers. The ATMega644 of ATMEL provides 64KB of flash program memory in a DIY-friendly 40-pin PDIP package. Read on for how to combine both to my new software development platform.

FreeRTOS provides a nice RTOS for embedded systems and is readily available for various platforms. One timer of [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://gonium.net/md/wp-content/uploads/2008/08/1365045226_4e46522658.jpg" alt="six-legged chip bug" title="chip_bug" width="300" height="225" class="alignnone size-medium wp-image-90" /></p>
<p><a href="http://www.freertos.org/">FreeRTOS</a> is an open-source realtime operating system for microcontrollers. The <a href="http://www.atmel.com/dyn/products/product_card.asp?part_id=3694">ATMega644</a> of ATMEL provides 64KB of flash program memory in a DIY-friendly 40-pin PDIP package. Read on for how to combine both to my new software development platform.<br />
<span id="more-89"></span><br />
FreeRTOS provides a nice RTOS for embedded systems and is readily available for various platforms. One timer of the hardware is used to implement multitasking features. A library provides routines for creating tasks and synchronization. Unfortunately, FreeRTOS is currently only ported to the ATMega323 &#8211; so I created a basic port to the ATMega644 and stripped all unnecessary features.</p>
<p>Typically, the FreeRTOS demo shows how to implement various threads and let them access the hardware. While it is educating to read the code, it is too bloated to serve as a template for new developments. In addition, I prefer <a href="http://jump.to/fleury">Peter Fleury&#8217;s UART library</a> for serial outputs. So, I removed all threads and included the library. To make sure that two threads cannot write to the same UART at the same time, I introduced a mutex per UART to synchronize the output on a per-string basis. Please note that there is no Mutex to synchronize read access. The main program starts two tasks which print &#8220;foo&#8221; and &#8220;bar&#8221; to the serial line, respectively. I kept the task surveilance mechanism as implemented in the original FreeRTOS demo (this might become handy ;-))</p>
<p>Here is a peek at the main.c file:</p>
<p class="vci_info">[viewcode]src=freertos-atmega644-main.c [/viewcode]</p>
<pre class="vci_code"></pre>
<p class="vci_info">HTML code generated by <a href="http://www.zacharyfox.com/blog/free-tools/vim-color-improved">vim-color-improved v.0.4.0.</a><strong>Download this code:</strong> <a href="http://gonium.net/media//freertos-atmega644-main.c">freertos-atmega644-main.c</a></p>
<p>You can get the whole package (GPL licensed) from the download page. Have fun! Kudos for the CC&#8217;ed chip bug picture go to <a href="http://flickr.com/photos/oskay/1365045226/">oskay</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gonium.net/md/2008/08/10/freertos_for_atmega644/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
