<?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>Pacelg</title>
	<atom:link href="http://pacelg.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://pacelg.com</link>
	<description></description>
	<lastBuildDate>Thu, 09 Feb 2012 20:31:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Egg carton Lights</title>
		<link>http://pacelg.com/egg-carton-lights/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=egg-carton-lights</link>
		<comments>http://pacelg.com/egg-carton-lights/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 20:28:58 +0000</pubDate>
		<dc:creator>Jan Ole</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[Led]]></category>
		<category><![CDATA[RGB]]></category>

		<guid isPermaLink="false">http://pacelg.com/?p=890</guid>
		<description><![CDATA[After making the Party in a Jar I wanted to create more but it is boring to make the same things over and over again, so I descided to look for something else to make and in the spirit of recyceling, which Kine is very fond of, I found three old egg cartons. Egg carton [...]]]></description>
			<content:encoded><![CDATA[<p>After making the <a title="PartyJar" href="http://pacelg.com/partyjar/">Party in a Jar</a> I wanted to create more but it is boring to make the same things over and over again, so I descided to look for something else to make and in the spirit of recyceling, which Kine is very fond of, I found three old egg cartons. Egg carton have nice shapes and have potential to become a lot of cool stuff, it is just a mather of geting the right idea at the right time.</p>
<p>I got an idea, and it was hopefully at the right time. If you turn an egg carton upsidedown you can see five deep holes and I figured tht if I could fill those holes with light it would look rather nice. And indeed it did. I must be some kind of an average genious (did I spell that right?).</p>
<p class="alignnone size-medium wp-image-892" title="IMAG2339">So what I did was to fit one rgb blinking led in each top (or bottom) of the egg carton egg divider sphere, soldered them to some wires, added a battery and woila, it looks pretty from the sides, it is in fact a litle to bright when you watch it straight on, but not as bright as in the videos . My phone camera have an isue with led lights.</p>
<table width="549">
<tbody>
<tr>
<td><a href="http://pacelg.com/wp-content/uploads/2012/02/IMAG2339.jpg"><img title="IMAG2339" src="http://pacelg.com/wp-content/uploads/2012/02/IMAG2339-179x300.jpg" alt="" width="179" height="300" /></a>
</td>
<td><a href="http://pacelg.com/wp-content/uploads/2012/02/IMAG2341.jpg"><img class="alignnone size-medium wp-image-893" title="IMAG2341" src="http://pacelg.com/wp-content/uploads/2012/02/IMAG2341-179x300.jpg" alt="" width="179" height="300" /></a></p>
</td>
<td><a href="http://pacelg.com/wp-content/uploads/2012/02/IMAG2343.jpg"><img class="alignnone size-medium wp-image-894" title="IMAG2343" src="http://pacelg.com/wp-content/uploads/2012/02/IMAG2343-179x300.jpg" alt="" width="179" height="300" /></a></td>
</tr>
</tbody>
</table>
<p><iframe src="http://www.youtube.com/embed/UpbCi7-BT7A" frameborder="0" width="640" height="480"></iframe></p>
<p><iframe src="http://www.youtube.com/embed/jn6WVArRPpU" frameborder="0" width="640" height="480"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://pacelg.com/egg-carton-lights/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wire Animals</title>
		<link>http://pacelg.com/wire-animals/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wire-animals</link>
		<comments>http://pacelg.com/wire-animals/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 16:20:18 +0000</pubDate>
		<dc:creator>Jan Ole</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[School]]></category>
		<category><![CDATA[Wireanimals]]></category>

		<guid isPermaLink="false">http://pacelg.com/?p=880</guid>
		<description><![CDATA[Today Kine came to ifi and created stuff with me, while I put my finnishing touch on the big orange robot that are going to revolutionise the state machine world. Kine made a yellow dog, a black monkey and a white flower. arent they pretty?]]></description>
			<content:encoded><![CDATA[<p>Today Kine came to ifi and created stuff with me, while I put my finnishing touch on the big orange robot that are going to revolutionise the state machine world.</p>
<p>Kine made a yellow dog, a black monkey and a white flower. arent they pretty?</p>
<table>
<tbody>
<tr>
<td><a href="http://pacelg.com/wp-content/uploads/2012/02/IMAG2314.jpg"><img class="alignnone size-medium wp-image-882" title="IMAG2314" src="http://pacelg.com/wp-content/uploads/2012/02/IMAG2314-300x179.jpg" alt="" width="300" height="179" /></a></td>
<td><a href="http://pacelg.com/wp-content/uploads/2012/02/IMAG2315.jpg"><img class="alignnone size-medium wp-image-883" title="IMAG2315" src="http://pacelg.com/wp-content/uploads/2012/02/IMAG2315-300x179.jpg" alt="" width="300" height="179" /></a></td>
</tr>
</tbody>
</table>
<p><a href="http://pacelg.com/wp-content/uploads/2012/02/IMAG2319.jpg"><img class="alignnone size-medium wp-image-887" title="IMAG2319" src="http://pacelg.com/wp-content/uploads/2012/02/IMAG2319-300x179.jpg" alt="" width="300" height="179" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://pacelg.com/wire-animals/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Training Master Students</title>
		<link>http://pacelg.com/training-master-students/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=training-master-students</link>
		<comments>http://pacelg.com/training-master-students/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 19:30:32 +0000</pubDate>
		<dc:creator>Jan Ole</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Master]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[School]]></category>
		<category><![CDATA[University]]></category>
		<category><![CDATA[ThingML]]></category>

		<guid isPermaLink="false">http://pacelg.com/?p=844</guid>
		<description><![CDATA[Once upon a time. I, the mighty master student, was granted the privilege to train two other master students and mold them in my image. This was a clever plan created by the two research lords who worked compiler magic to generate new programing languages for the working man to enjoy. Having two apprentices when [...]]]></description>
			<content:encoded><![CDATA[<p>Once upon a time.<br />
I, the mighty master student, was granted the privilege to train two other master students and mold them in my image. This was a clever plan created by the two research lords who worked compiler magic to generate new programing languages for the working man to enjoy.</p>
<p>Having two apprentices when you are just a master student sound like a great deal of responsibility, and I, the mighty master student, can agree on that. In fact it is almost to much responsibility, but luckily for me they are for the most part obedient, at least if it is not on a day where a horde of web comics are released, if that is the case Kyrre is lost in the depth of the all-knowing interwebz.</p>
<p>The master plan of the research lords are to provide the general public with a programing language that the simplest peasant can program as if he was the king of programmers. This new glorious programming language are called ThingML and is supposed to be able to<br />
<em>program</em><br />
<em>all the things</em><br />
One of the visions the research lords have is that everything that is programmed should be able to access the all-knowing interwebz, and since the interwebz is in fact all-knowing all things that are interlaced with the interwebz could also be all-knowing. Imagine the wast amount of things that would know everything. Your toaster could know what the weather is, your fridge could know today&#8217;s quests, your electric toothbrush could know your kill count and the TV schedule and your computer could know how often you brush your teeth, how often you open your fridge and how often opening the fridge results in  a toast.</p>
<p>This is a vision well shared with the mighty master student, and a vision that I, the mighty master student, are trying to push down on my apprentices.</p>
<p>To get my apprentices to fully grasp this great heaven like  idea I must train them like only a mighty master student can do, and I believe that the best way to train is to head out to life threatening programing quests that could fail miserably or bring home gold and fortune to your fellow programmers.</p>
<p>This day I sent my young students on a very dangerous quest, and I must admit that I was not expecting either of them to complete this task by the end of this day, but in fact they both manage to shine through and prove them self very special. The quest the mighty master student gave them on this glorious day was to make a potentiometer of doom to control the timer interrupts of great descending and ultimately control the rate of which a mystical LED is blinking. This was not a trivial quest, one might thing so, but only if one have yet to try out the magnificent language of ThingML. It is a state machine oriented language that requires you to program the potentiometer of doom in one realm and the mystical LED in a whole another realm. This I did not know in my youth and had to learn the hard way, by trial and error and then directly from the research lords. My apprentices on the other hand got this knowledge as a hint in the quest description.</p>
<p>You might also wonder how the apprentices solved this quest, and I will tell you that great tale. They used the simplest of logic, they avoided all bloathiness by dodging all dangerous obstacles through learning and exploring of all great things in the land of ThingML. They traversed files and found hidden messages that could travel through enchanted ports and trigger old mythological states to act on newly discovered input from the potentiometer of doom. They did well and earned them self a great loot of XP and wisdom.</p>
<p>In fact they did better then their almigty teacher and earned more xp then I did on that spesific quest in my youth. Not only did the both manage to finnish the quest with a lower linecount, but also by using fewer enchanted ports and hidden messages.</p>
<p>But in order to show you, the reader of this tale, that I am not a noob, but still better then my two young padawans, my code had the great ability to cancel out any timer events on the LED and restart it when needed, theirs code could not.</p>
<p>Here you can see Kyrres code</p>
<pre class="wp-code-highlight prettyprint linenums:1">import &quot;../../hardware/bricks/led.thingml&quot;
import &quot;../../hardware/io/analog_input.thingml&quot;

thing portRGB includes TimerMsgs, LedMsgs, AnalogInputMsgs {

   property temp : UInt16 = 100

   required port timer {

       receives timer_timeout
       sends timer_start, timer_cancel
       }

   required port led {

       sends led_on, led_off, led_toggle

       }

       required port input {
           receives analog_input_value
           sends read_analog_input
           }

       statechart portRGBImpl init green {

           state Led {

               on entry do
                  timer!timer_start (temp)
               end

               transition-&amp;gt;Led
               event timer?timer_timeout

           }
           region potMeter init pot {

             state pot {

                      on entry do
                      input!read_analog_input ()
                      end

                      transition-&amp;gt;pot
                      event m: input?analog_input_value
                      action do
                         if(m.value &amp;gt; 1) do
                             temp = m.value
                          end
                      end

           }
       }
    }
}</pre>
<p>And here comes the code that I, the almighty master student, wrote in my youth:</p>
<pre class="wp-code-highlight prettyprint linenums:1">import &quot;../../hardware/io/analog_input.thingml&quot;
import &quot;../../hardware/bricks/led.thingml&quot;

thing AnalogReadBlink includes AnalogInputMsgs, TimerMsgs, LedMsgs{

    property freq : UInt16 = 0

    required port TimerPot
    {
        sends timer_start
        receives timer_timeout
    }
    required port TimerLed
    {
        sends timer_start
        sends timer_cancel
        receives timer_timeout
    }

    required port Led
    {
        sends led_toggle
    }

    required port AnalogInput
    {
        sends read_analog_input
        receives analog_input_value
    }

    message update();

    provided port ReceiveUpdate
    {
        receives update
    }
    required port SendsUpdate
    {
        sends update
    }    

    statechart AnalogReadBlinkImpl init ReadPot
    {
        property delay : UInt16 = 100

        state ReadPot
        {
            on entry do
                AnalogInput!read_analog_input()
                TimerPot!timer_start(20)
            end

            internal event m : AnalogInput?analog_input_value
            action do
                if( not (delay == m.value)) do
                    if( not (m.value == 0)) do
                        if (m.value &lt; delay - 3 or m.value &gt; delay + 3) do
                        delay = m.value
                        SendsUpdate!update()
                        'Serial.println('&amp; m.value &amp;');'
                        end
                    end 

                end
            end

            transition -&gt; ReadPot
            event TimerPot?timer_timeout

        }

        region Led init Blink
        {
         state Blink
         {
             on entry  do
                Led!led_toggle()
                TimerLed!timer_start(delay)
             end

             transition -&gt;Blink
             event TimerLed?timer_timeout

             transition -&gt; Blink
             event ReceiveUpdate?update
             action TimerLed!timer_cancel()
         }
    }
}</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://pacelg.com/training-master-students/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Led Clock Coding Tutorial</title>
		<link>http://pacelg.com/led-clock-coding-tutorial/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=led-clock-coding-tutorial</link>
		<comments>http://pacelg.com/led-clock-coding-tutorial/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 22:43:15 +0000</pubDate>
		<dc:creator>Jan Ole</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Binary]]></category>
		<category><![CDATA[Led Clock]]></category>

		<guid isPermaLink="false">http://pacelg.com/?p=840</guid>
		<description><![CDATA[As you might know, or will know in three seconds, I have made a Binary Led Clock.  I posted a tutorial on how to build it with physical materials, by soldering and swearing. This time I will walk you through the code, and guess what, the code have hidden features that I have not implemented [...]]]></description>
			<content:encoded><![CDATA[<p>As you might know, or will know in three seconds, I have made a <a title="LED Clock" href="http://pacelg.com/led-clock/">Binary Led Clock</a>.  I posted a tutorial on how to build it with physical materials, by soldering and swearing. This time I will walk you through the code, and guess what, the code have hidden features that I have not implemented suport for in the current physical version of the clock.</p>
<p>Okay, lets start of with the pin declaration:</p>
<pre class="wp-code-highlight prettyprint linenums:1">int sekData = 11, minData = 8, hourData = 5;
int sekClock = 12, minClock = 9, hourClock = 6;
int sekLatch = 13, minLatch = 10, hourLatch = 7;</pre>
<p>As you can see, I use nine pins, three for each shift register. Then I also have to define them as output pins in the Arduino enviroment.</p>
<pre class="wp-code-highlight prettyprint linenums:1">  pinMode(sekData, OUTPUT);
  pinMode(sekClock, OUTPUT );
  pinMode(sekLatch, OUTPUT);

  pinMode(minData, OUTPUT);
  pinMode(minClock, OUTPUT );
  pinMode(minLatch, OUTPUT);

  pinMode(hourData, OUTPUT);
  pinMode(hourClock, OUTPUT );
  pinMode(hourLatch, OUTPUT);</pre>
<p>Then I must assign a variable to store the time in minutes and hours, notice that I don&#8217;t do anything about the seconds, this is because I don&#8217;t feel that I need the functionality to set the seconds.</p>
<pre class="wp-code-highlight prettyprint linenums:1">  int i = 13;
  int j = 43;</pre>
<p>i is for hours and j is for minutes.</p>
<p>Then the first thing I want to do in the setup method after making the pinMode statements is to flush all the shift registers to avoid having old data in them. This is done by calling three methods I have written. Also I&#8217;m attaching two interrupts, and we have code that looks like this:</p>
<pre class="wp-code-highlight prettyprint linenums:1">  //Flasher sekund ledsa
  updateSek(0);
  //Flusher min og time registeret
  updateMin(j);
  updateHour(i);
  //Setter interrup handlere
  attachInterrupt(0, setMin, RISING);
  attachInterrupt(1, setTime, RISING);</pre>
<p>As you might see the two interrupts are calling on two methods called setMin and setTime, which basically means set minute and set hour. Don&#8217;t mind my Norwegian coding style ;) It is mainly to confuse myself ;)<br />
But anyways, these two methods are defined like this:</p>
<pre class="wp-code-highlight prettyprint linenums:1">void setMin(){
  j++;
  if(j == 60)
  {
    j = 0;
  }
  digitalWrite(minLatch, LOW);
  shiftOut(minData, minClock, MSBFIRST, j);
  digitalWrite(minLatch, HIGH);
}

void setTime(){
  i++;
  if(i == 24){
    i = 0;
  }
  digitalWrite(hourLatch, LOW);
  shiftOut(hourData, hourClock, MSBFIRST, i);
  digitalWrite(hourLatch, HIGH);
}</pre>
<p>Ok, now it is time to start up the clock with the loop method, and this method is really simple, it waits one second, and updates the seconds counter, and if necessary, the minutes and hours as well. And it all looks like this:</p>
<pre class="wp-code-highlight prettyprint linenums:1">void loop(){

  //løper gjennom alle sekundene
    for(int k = 0; k &amp;lt; 61; k++){
       if(k == 60){
        k = 0;
        j++;
         if(j == 60){
          j = 0;
          i++;
          if(i == 24){
            i = 0;
          }
         }
       }
      // Serial.print(k);
      // Serial.print(&quot;-&quot;);
      // Serial.print(j);
      // Serial.print(&quot;-&quot;);
      // Serial.println(i);
       updateSek(k);
       updateMin(j);
       updateHour(i);
       delay(1000);
    }
}</pre>
<p>And then, at last the three methods that updates the shift register</p>
<pre class="wp-code-highlight prettyprint linenums:1">void updateSek(int value){
  digitalWrite(sekLatch, LOW);
  shiftOut(sekData, sekClock, MSBFIRST, value);
  digitalWrite(sekLatch, HIGH);
}

void updateMin(int value){
  digitalWrite(minLatch, LOW);
  shiftOut(minData, minClock, MSBFIRST, value);
  digitalWrite(minLatch, HIGH);
}

void updateHour(int value){
  digitalWrite(hourLatch, LOW);
  shiftOut(hourData, hourClock, MSBFIRST, value);
  digitalWrite(hourLatch, HIGH);
}</pre>
<p>And now, at last I will put all this code together for you to enjoy in case you didn&#8217;t manage to put it together in the right fashion yourself</p>
<pre class="wp-code-highlight prettyprint linenums:1">
//Setter pins på shift registerne
int sekData = 11, minData = 8, hourData = 5;
int sekClock = 12, minClock = 9, hourClock = 6;
int sekLatch = 13, minLatch = 10, hourLatch = 7;

//Setter bare litt tilfeldig starttid på klokka
  int i = 13;
  int j = 43; 

void setup(){

  //PinMode på alle shiftregisterne
 pinMode(sekData, OUTPUT);
 pinMode(sekClock, OUTPUT );
  pinMode(sekLatch, OUTPUT);

 pinMode(minData, OUTPUT);
 pinMode(minClock, OUTPUT );
  pinMode(minLatch, OUTPUT);

 pinMode(hourData, OUTPUT);
 pinMode(hourClock, OUTPUT );
  pinMode(hourLatch, OUTPUT);
  Serial.begin(9600);
  //Flasher sekund ledsa
  updateSek(0);
    //Flusher min og time registeret
  updateMin(j);
  updateHour(i);
  //Setter interrup handlere
  attachInterrupt(0, setMin, RISING);
  attachInterrupt(1, setTime, RISING);

}
//To metoder for stillig av klokka
void setMin(){
  j++;
  if(j == 60)
  {
    j = 0;
  }
  digitalWrite(minLatch, LOW);
  shiftOut(minData, minClock, MSBFIRST, j);
  digitalWrite(minLatch, HIGH);
}

void setTime(){
  i++;
  if(i == 24){
    i = 0;
  }
  digitalWrite(hourLatch, LOW);
  shiftOut(hourData, hourClock, MSBFIRST, i);
  digitalWrite(hourLatch, HIGH);
}

void loop(){

  //løper gjennom alle sekundene
    for(int k = 0; k &amp;lt; 61; k++){
       if(k == 60){
        k = 0;
        j++;
         if(j == 60){
          j = 0;
          i++;
          if(i == 24){
            i = 0;
          }
         }
       }
     //  Serial.print(k);
      // Serial.print(&quot;-&quot;);
      // Serial.print(j);
      // Serial.print(&quot;-&quot;);
      // Serial.println(i);
       updateSek(k);
        updateMin(j);
        updateHour(i);
       delay(1000);
    }
}

//The f do u think?
void updateSek(int value){
  digitalWrite(sekLatch, LOW);
  shiftOut(sekData, sekClock, MSBFIRST, value);
  digitalWrite(sekLatch, HIGH);
}

void updateMin(int value){
  digitalWrite(minLatch, LOW);
  shiftOut(minData, minClock, MSBFIRST, value);
  digitalWrite(minLatch, HIGH);
}

void updateHour(int value){
  digitalWrite(hourLatch, LOW);
  shiftOut(hourData, hourClock, MSBFIRST, value);
  digitalWrite(hourLatch, HIGH);
}</pre>
<p>Happy thrill.</p>
]]></content:encoded>
			<wfw:commentRss>http://pacelg.com/led-clock-coding-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two-coloumn article</title>
		<link>http://pacelg.com/two-coloumn-article/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=two-coloumn-article</link>
		<comments>http://pacelg.com/two-coloumn-article/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 19:16:58 +0000</pubDate>
		<dc:creator>Jan Ole</dc:creator>
				<category><![CDATA[Master]]></category>
		<category><![CDATA[School]]></category>
		<category><![CDATA[University]]></category>
		<category><![CDATA[Article]]></category>
		<category><![CDATA[LaTeX]]></category>

		<guid isPermaLink="false">http://pacelg.com/?p=832</guid>
		<description><![CDATA[I don&#8217;t write a lot, but when I write scientific I use LaTeX. If you are above average in the field of common sense, you figured that I rather seldom write stuff in LaTeX, and that means that every time I&#8217;m writing stuff in LaTeX I must use google a lot. One could say that [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t write a lot, but when I write scientific I use LaTeX. If you are above average in the field of common sense, you figured that I rather seldom write stuff in LaTeX, and that means that every time I&#8217;m writing stuff in LaTeX I must use google a lot. One could say that I should write my thesis and article in Word instead, but where is the challenge in that, everything have a time limit, and I can&#8217;t risk holding that limit by using easy tools. No, I like living on the edge, therefore I use tools I don&#8217;t know well and use the time I should have been using writing my thesis on googling how to format one little piece of text.</p>
<p>These days I&#8217;m writing an article on how to improve transitions written in ThingML and showing of the great results I get, but writing an article is a little different from writing the master thesis, for starters, there is no front page, and it have to be in two columns. Needless to say I didn&#8217;t know how to do that, so I googled, I found, I wrote. Here I will put my article template for further reference.</p>
<pre class="wp-code-highlight prettyprint linenums:1">\documentclass[11pt,twocolumn]{article}

\begin{document}

\title{Something about ThingML Transitions}
\author{
    Jan Ole Skotterud\\
    Institute for Informatics\\
    University in Oslo\\
    janoleos@ifi.uio.no
}

\maketitle

\begin{abstract}
The abstract text goes here.
\end{abstract}

\section{Introduction}
Here is the text of your introduction.

\subsection{Subsection Heading Here}
Write your subsection text here.

\section{Conclusion}
Write your conclusion here.

\end{document}</pre>
<p>This will provide the foundation to write great articles that can be approved and cherished in scientific circles.</p>
<p>I also figured that my supervisor also might wan&#8217;t to have his name on the top of the first page and that required me to do some more googleing, the result that came back was the little but efficient TeX command \and, and there I could add more authors. Like this:</p>
<pre class="wp-code-highlight prettyprint linenums:1">\author{
    Jan Ole Skotterud\\
    Institute for Informatics\\
    University in Oslo\\
    janoleos@ifi.uio.no
  \and
    First Last\\
    Institute\\
    Uni\\
    Mail
}</pre>
<p>And just like that I have made my first reference blog post for LaTeX.<br />
Jippi Kay Yey Article Writer</p>
<p>Hehe, I also wanted a LaTeX related image for the header, so I googled latex, not a clever idea&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://pacelg.com/two-coloumn-article/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Birthday at School</title>
		<link>http://pacelg.com/birthday-at-school/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=birthday-at-school</link>
		<comments>http://pacelg.com/birthday-at-school/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 15:03:37 +0000</pubDate>
		<dc:creator>Jan Ole</dc:creator>
				<category><![CDATA[Baking]]></category>
		<category><![CDATA[Beer]]></category>
		<category><![CDATA[Master]]></category>
		<category><![CDATA[School]]></category>
		<category><![CDATA[University]]></category>
		<category><![CDATA[Birthday]]></category>
		<category><![CDATA[Cake]]></category>
		<category><![CDATA[Dominion]]></category>
		<category><![CDATA[gifts]]></category>

		<guid isPermaLink="false">http://pacelg.com/?p=810</guid>
		<description><![CDATA[I must start of by saying thanks to all my friends, most of you congratulated me on facebook, but some of you went the extra mile to make my birthday a really special day. The day started as any other day, I went to school to work. When I got there, some of the girls [...]]]></description>
			<content:encoded><![CDATA[<p>I must start of by saying thanks to all my friends, most of you congratulated me on facebook, but some of you went the extra mile to make my birthday a really special day. The day started as any other day, I went to school to work. When I got there, some of the girls that I study with had been planning a little surprise. They had decorated the masters room on the sixth floor with balloons and glittery stuff. They all had birthday hats, Åshild had baked buns with nonstop inside, they were delicious and Lill had made me a really cool crown. It was made of origami flowers in different colors and she must have used a lot of time on that.</p>
<p>Through the day a lot of people came by to congratulate me, I even got some sweet gifts. Some of the gifts I got was cola, bamsemums, cola, Kinderegg, cola, a thsirt with linux. cola, cola, a origami bird ++.</p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/383253_10150714763869937_736069936_12233722_870009943_n.jpg"><img class="alignnone size-medium wp-image-820" title="383253_10150714763869937_736069936_12233722_870009943_n" src="http://pacelg.com/wp-content/uploads/2012/01/383253_10150714763869937_736069936_12233722_870009943_n-224x300.jpg" alt="" width="224" height="300" /></a></p>
<p>After a while Kine came by with food and cake, and the timing was great. It had been just enough time since lunch so most people managed to eat some more cake. You can never eat enough cake.</p>
<p>After most people had went home, I got some time alone at school to actually get some work done and after half an hour Frode called and we went to his place and took a couple of beers. Life was good.</p>
<p>Then it was time to get home and spend the last hour of the day with Kine. From her I got two expansion packs to Dominion. I got Cornucopia and Alchemy. We played a couple of rounds and then the last sms ticked in. And guess what, I had become an uncle again.</p>
<p>Ulrik came to the world 17.01.12 22:34. Weight 2440g and was 49 cm long.</p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/407639_2863782205904_1600213429_2588120_1887486039_n.jpg"><img class="alignnone size-medium wp-image-812" title="407639_2863782205904_1600213429_2588120_1887486039_n" src="http://pacelg.com/wp-content/uploads/2012/01/407639_2863782205904_1600213429_2588120_1887486039_n-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>Sooooo, little nephew. I guess we will have to come to an agreement on the newly acquired birthday issue&#8230;&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://pacelg.com/birthday-at-school/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Film review: Starship troopers</title>
		<link>http://pacelg.com/film-review-starship-troopers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=film-review-starship-troopers</link>
		<comments>http://pacelg.com/film-review-starship-troopers/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 14:18:20 +0000</pubDate>
		<dc:creator>Jan Ole</dc:creator>
				<category><![CDATA[Movie]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[Shooter]]></category>
		<category><![CDATA[Space]]></category>

		<guid isPermaLink="false">http://pacelg.com/?p=801</guid>
		<description><![CDATA[This is a collective review of the movies Starship troopers 2 and three, and i must start of with saying that I started to write this review for about a week ago when I saw the two movies for the first time. The two movies motivated my a lot to write this review, and I [...]]]></description>
			<content:encoded><![CDATA[<p>This is a collective review of the movies Starship troopers 2 and three, and i must start of with saying that I started to write this review for about a week ago when I saw the two movies for the first time. The two movies motivated my a lot to write this review, and I wanted to write this review in a review system for wordpress, which meant that I had to find a good review plugin. there were none. This eventually resulted in me having to spend precious time writing my own plugin to have access to all the functionality that I wanted, but more on that later.</p>
<p>Starship troopers is a great movie that I have seen many times since it first came out in 1997, it have great animations, super effects and superduper hidden messages about the American society although most people think that it is references to the Nazis.</p>
<p>So back to movie two and three in the series, as the first one had a budget of 100 000 00 dollars, and number two and three had a budget of approximately 9 000 000 and 7 000 000 dollars they were doomed to not keep the standard of the first one. (ref <a href="http://imdb.com">imdb.com</a>)</p>
<p>I have always heard a lot of crap about those movies, and therefore I have never watched them before now, and now I wish that I could use four hours to unsee them. It was bad, really bad.</p>
<p>The second movie was the best of those two, it had the same great animations from the first movie, I figure that they just reused it, fair enough.  But they changed the complete cast,  what is that all about? No more Neil Patric Harris and Carmen Electra. What have the world come two? According to the movie it had come to be a worse place&#8230;.</p>
<p>Damn, I don&#8217;t want to write more about those crappy movies, but here comes some more. The third movie was a fuck up without any equal. The animations were badder, much badder. It&#8217;s like they hired two 10 year old kids to re animate everything. The guy who played John Ricco in the first movie was back, but unfortunately he was not allowed to do any acting in the movie, they just filmed him saying emotionless uninspired lines and sometimes he shoot at things. They also included Christianity and faith in the movie as one of the main things. And they even tried to display it as it was faith in god who ultimately saved the human race. What a bunch of bullshit.</p>
<p>If i ever but these movies, it must be so I can break them and throw them away.</p>
<p>I give them a solid 1 in total even though Starship troopers 2 was slightly better. <img src="http://pacelg.com/wp-content/plugins/dosjosreview/images/one.png"></p>
]]></content:encoded>
			<wfw:commentRss>http://pacelg.com/film-review-starship-troopers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rainbow cake</title>
		<link>http://pacelg.com/rainbow-cake/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rainbow-cake</link>
		<comments>http://pacelg.com/rainbow-cake/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 13:34:25 +0000</pubDate>
		<dc:creator>Jan Ole</dc:creator>
				<category><![CDATA[Baking]]></category>
		<category><![CDATA[School]]></category>
		<category><![CDATA[Cake]]></category>
		<category><![CDATA[Food]]></category>
		<category><![CDATA[Rainbow]]></category>
		<category><![CDATA[Recipe]]></category>

		<guid isPermaLink="false">http://pacelg.com/?p=609</guid>
		<description><![CDATA[Yesterday a challenge appeared, and I enjoy a good challenge, needless to say I jumped on it and got to work. The challenge was to make a mind blowing or totally awesome cake. Why? because I wanted to do it and apparently a lot of people wanted me, and nobody else, to make them cake. [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday a challenge appeared, and I enjoy a good challenge, needless to say I jumped on it and got to work. The challenge was to make a mind blowing or totally awesome cake. Why? because I wanted to do it and apparently a lot of people wanted me, and nobody else, to make them cake.<br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/face.png"><img class="alignnone size-full wp-image-610" title="face" src="http://pacelg.com/wp-content/uploads/2012/01/face.png" alt="" width="466" height="204" /></a></p>
<p>So, as you can see everybody (at least all ten of them) voted on me, and my though was that if they wanted me to make them cake, I sure would make them some great cake.</p>
<p>The next step of my cake plan was to get some inspiration and I googled terms like &#8220;cool cake&#8221; and &#8220;awesome cake&#8221;. I don&#8217;t remember which term that guided me towards the great idea, but I found a rainbow cake with a lot of colors inside, it looked fantastic. It just had to be that cake. Now I needed a lot of things, mostly regular cake baking things like flour, sugar, eggs and so on, but also real good and vibrant food coloring stuff. Kine told me about this great store called Cacas, I googled it and found that they had everything cake related that you can ever need so I went there and bought eight colors and some pens that can draw on cakes.</p>
<p>After i came home again I consulted with Kines mother about the cake bottoms and the marzipan. She know her cakes and you can see some of them here if the album is public <a href="http://www.facebook.com/#!/media/set/?set=a.1474505429696.2064173.1445499252&amp;type=3">http://www.facebook.com/#!/media/set/?set=a.1474505429696.2064173.1445499252&amp;type=3</a>.</p>
<table width="470">
<tbody>
<tr>
<td>Then it was just to get cooking, I mixed the batter and splited it into five parts. The cool thing about this recipe is that if you make it, it will weigh almost exactly 1000g which means that it is rather easy to divide it into five equal parts. Then I took one part an mixed in the color. I used maybe a little to much color since my pink became red as well, but no harm done anyways. Then I threw each layer in the oven for about ten minutes. I also made a completely new batter and mixed all the colors in it. Guess what, it became brown.Then it was just to wait for every thing to cool down, while waiting i whipped together some some cream, and I found a pack of vanilla cream in the fridge.</td>
<td>
<table width="159" border="1" cellpadding="4">
<tbody>
<tr>
<td>
<h3>Recipe</h3>
<p>Ca 5 eggs<br />
250g sugar<br />
190g flour<br />
140g potato flour<br />
1 ts baking powder</p>
<p>Mix the eggs and the sugar.<br />
Then mix in the rest.<br />
Put into oven at 180 degrees Celsius for about 25 minutes</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p>Then it was time to start stacking the cake layer for layer. I started off with one cake bottom, soaked it a little with a little saft (yes that is a norwegian word). Then I added raspberry jam and a new cake layer. From here on out I used whipped cream and vanilla cream for every other layer and stacked all the colored layers on top of each other.</p>
<p>Then I covered the rest of the cake in cream an put marzipan on top of the whole cake. The I decorated it with different drawings with references to games, programing, Ifi, cartoons and the Internet. Everything was something that meant something to someone in our group.</p>
<p>Here some pictures from the baking process and the eating process will follow:<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2138.jpg"><img class="alignnone size-medium wp-image-623" title="IMAG2138" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2138-300x179.jpg" alt="" width="300" height="179" /></a><a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2140.jpg"><img class="alignnone size-medium wp-image-624" title="IMAG2140" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2140-300x179.jpg" alt="" width="300" height="179" /></a><a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2137.jpg"><img class="alignnone size-medium wp-image-622" title="IMAG2137" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2137-179x300.jpg" alt="" width="179" height="300" /></a><a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2155.jpg"><img class="alignnone size-medium wp-image-625" title="IMAG2155" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2155-300x179.jpg" alt="" width="300" height="179" /></a><a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2156.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2156" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2156-300x179.jpg" alt="" width="300" height="179" /></a><br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2157.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2157" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2157-300x179.jpg" alt="" width="300" height="179" /></a><br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2159.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2159" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2159-300x179.jpg" alt="" width="300" height="179" /></a><br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2160.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2160" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2160-300x179.jpg" alt="" width="300" height="179" /></a><br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2163.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2163" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2163-300x179.jpg" alt="" width="300" height="179" /></a><br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2164.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2164" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2164-300x179.jpg" alt="" width="300" height="179" /></a><br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2165.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2165" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2165-300x179.jpg" alt="" width="300" height="179" /></a><br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG21566.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2166" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2166-300x179.jpg" alt="" width="300" height="179" /></a><br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2167.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2167" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2167-300x179.jpg" alt="" width="300" height="179" /></a><br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2168.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2168" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2168-300x179.jpg" alt="" width="300" height="179" /></a><br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2170.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2170" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2170-300x179.jpg" alt="" width="300" height="179" /></a><br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2171.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2171" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2171-300x179.jpg" alt="" width="300" height="179" /></a><br />
<a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG2172.jpg"><img class="alignnone size-medium wp-image-626" title="IMAG2172" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG2172-300x179.jpg" alt="" width="300" height="179" /></a></p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/Ai9LCiLCMAAeOyV.jpg"><img class="alignnone size-medium wp-image-621" title="Ai9LCiLCMAAeOyV" src="http://pacelg.com/wp-content/uploads/2012/01/Ai9LCiLCMAAeOyV-179x300.jpg" alt="" width="179" height="300" /></a><a href="http://pacelg.com/wp-content/uploads/2012/01/bilde2.jpg"><img class="alignnone size-medium wp-image-642" title="bilde2" src="http://pacelg.com/wp-content/uploads/2012/01/bilde2-300x225.jpg" alt="" width="300" height="225" /></a><a href="http://pacelg.com/wp-content/uploads/2012/01/379163_10151141437630694_644555693_22482840_753074385_n.jpg"><img class="alignnone size-medium wp-image-618" title="379163_10151141437630694_644555693_22482840_753074385_n" src="http://pacelg.com/wp-content/uploads/2012/01/379163_10151141437630694_644555693_22482840_753074385_n-300x223.jpg" alt="" width="300" height="223" /></a><a href="http://pacelg.com/wp-content/uploads/2012/01/378112_10150594208956133_521811132_11509475_1054004901_n.jpg"><img class="alignnone size-medium wp-image-617" title="378112_10150594208956133_521811132_11509475_1054004901_n" src="http://pacelg.com/wp-content/uploads/2012/01/378112_10150594208956133_521811132_11509475_1054004901_n-300x300.jpg" alt="" width="300" height="300" /></a><a href="http://pacelg.com/wp-content/uploads/2012/01/383743_10151172692860323_610705322_22059783_537093378_n.jpg"><img class="alignnone size-medium wp-image-619" title="383743_10151172692860323_610705322_22059783_537093378_n" src="http://pacelg.com/wp-content/uploads/2012/01/383743_10151172692860323_610705322_22059783_537093378_n-300x300.jpg" alt="" width="300" height="300" /></a></p>
<p>Also thanks to Lill for this cool comment:</p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/lill.png"><img class="alignnone size-medium wp-image-645" title="lill" src="http://pacelg.com/wp-content/uploads/2012/01/lill-300x93.png" alt="" width="300" height="93" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://pacelg.com/rainbow-cake/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transitions in state machines</title>
		<link>http://pacelg.com/transitions-in-state-machines/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=transitions-in-state-machines</link>
		<comments>http://pacelg.com/transitions-in-state-machines/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 12:40:57 +0000</pubDate>
		<dc:creator>Jan Ole</dc:creator>
				<category><![CDATA[Master]]></category>
		<category><![CDATA[School]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[University]]></category>
		<category><![CDATA[Bender]]></category>
		<category><![CDATA[Futurama]]></category>
		<category><![CDATA[Microcontroller]]></category>
		<category><![CDATA[State machine]]></category>
		<category><![CDATA[ThingML]]></category>
		<category><![CDATA[Transitions]]></category>

		<guid isPermaLink="false">http://pacelg.com/?p=525</guid>
		<description><![CDATA[I will write a little bit here about transitions in state machines just for myself but if you want to spend time reading it, go ahead. The reason for me to write about it here is that it is easier for me to write down something more suitable for others to read compared to the [...]]]></description>
			<content:encoded><![CDATA[<p>I will write a little bit here about transitions in state machines just for myself but if you want to spend time reading it, go ahead. The reason for me to write about it here is that it is easier for me to write down something more suitable for others to read compared to the notes I take and don&#8217;t take if I&#8217;m the only one who are going to read them. Things I write here might also end up in my master thesis in the end, just so you know.</p>
<p>State machines are a really old concept and is used in computer science a lot. It is most widespread in the world of software modeling and robotics (I do believe, but can not base that statement on facts because I don&#8217;t care to google it right nao). The reason for me to suddenly have a interest in state machines, when I merely have used them in one course before, is that they turned up to be an important part of my thesis and therefore I must obtain some interest and knowledge about them. While  playing around with a newly developed language called ThingML I found that the way transitions were defined may not be the best and most effective way to write them. It sure wasn&#8217;t the most intuitive way to write them. This is one transition definition in ThingML:</p>
<pre class="wp-code-highlight prettyprint linenums:1">transition -&gt; NameOfNextState
event Port?Message
guard ( CONDITION )</pre>
<p>Here we say that we are going to have a transition which will lead us from the current state to <em>NameOfNextState</em>. This will happen if we get a message through the port and that message meat the guard condition. Easy, right? Yes indeed.</p>
<p>So what is the problem then? you might ask. Well, the transition definition you can see above is supposed to be written inside a state, and each state that have a transition that can lead to another transition need one of these transition definitions. So given that we have three states as seen in the next diagram, here we have three transitions one from S1 to S2, one from S2 to S3 and one from S3 to S1.</p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG0716.jpg"><img class="alignnone  wp-image-529" title="IMAG0716" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG0716-300x179.jpg" alt="" width="425" height="253" /></a></p>
<p>In this scenario there is really no need to change anything, there is perfectly alright to write each of the three transition statements in their corresponding state. But if we infer that every state should be able to transact into any of the other states when a specific event occurs, then the diagram will look like this:</p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG0717.jpg"><img class="alignnone size-medium wp-image-530" title="IMAG0717" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG0717-e1325802882655-300x241.jpg" alt="" width="300" height="241" /></a></p>
<p>In this example we actually have to write all the transition definitions twice, this is because both S3 and S1 leads to S2 and therefore the same transition declaration have to be written both places. This results in us writing six transition definitions instead of three. That is double the amount. Now if we add one state and let the same rules apply we will end up writing twelve transition definitions instead of four. This starts to seem like a lot of work, right? Now imagine a sophisticated robot which have eight different states and that no mater which state it is in, it can jump to any of the other states directly. This means a lot of transition definitions and remember when you look at the picture you have to write one for each line&#8230;. That is 56 to be rather precise for once. And we can abstract the rule n*n-1 = number of transitions where n = number of states. and all states leads to all other states.</p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG0718.jpg"><img class="alignnone size-medium wp-image-531" title="IMAG0718" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG0718-e1325803873152-300x284.jpg" alt="" width="300" height="284" /></a></p>
<p>In all of the above examples there is a small detail that I have neglected and that is the fact that a state can also transact to itself. This will add n to the equation and the rule will look like this n+(n*n-1) = number of transitions. Which can be shortened into n*n = number of transitions.</p>
<h3>My solution</h3>
<p>So as you already might have understood I want to eliminate the redundancy that occurs when you write the same declarations several times, but to be able to do this I must create a new way of declaring transitions and take into account all the special cases that might occur. It is important to say that what I am about to propose as a great change to the ThingML language is only a great change in the cases where several states can lead to a number of other states and that most of the transitions leading to one state are triggered by the same message no mater which state the state machine are in at the current time. If this is not the case then the old way of writing transition declarations are still a good alternative. The first example I wish to offer is a visual one, you have seen a state machine with eight states where each state have a transitionto every other state. This is how I wish for four states to be symbolized. The arrows comes from an outlying event queue</p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/globaltrans.png"><img class="alignnone  wp-image-555" title="globaltrans" src="http://pacelg.com/wp-content/uploads/2012/01/globaltrans.png" alt="" width="270" height="226" /></a></p>
<p>My first suggestion on how to write the transition definitions looks like this:</p>
<pre class="wp-code-highlight prettyprint linenums:1">transitions m : Light.value {
    (m.value &lt; 40) -&gt; State2
    (m.value &gt;= 40) -&gt; State3
}</pre>
<p>This code block is to be placed outside the statechart, but inside the thing scope(these are ThingML components, to learn more about them go to <a href="http://thingml.org">thingml.org</a>).  The transitions scope are intended to contain all transitions that are to trigger depending on a given message from a given port, in this example the value message from the Light port (Light.value). Then each transition are defined with one line, the first part of the line is the guard condition, this part is essential since without a guard the first transition would be triggered every time. The guard condition should also be a logical expression with the received message as one of the attributes. The last part of the line is the State that the transition are  leading to. In this part there is also an optional part which is the name of the transition, this one is only good to have if you are to make a model of your code, then the transition on the model will receive the name you have given it. The name are written between the guard condition and the arrow. like this:</p>
<pre class="wp-code-highlight prettyprint linenums:1"> (m.value &lt; 40) TransitionName -&gt; State2</pre>
<p>This way of writing transitions might at first glance seem like a good way of doing it, at least it did for me. But when you stop to think about it there are several things that isn&#8217;t covered and could cause problems. But I will try to solve them one by one from here on out. The first thing I need to do now is to create a real &#8220;functional&#8221; example that makes sense that we can use forward in this post. I found a example online using the popular robot Bender, that example was showing one implementation that are quite ok, but it is still a couple of things there that I don&#8217;t agree with. Anyhow, they display two State machine diagrams, the first one shows what Bender should be able to do, the other one is an optimization, but I believe that it takes away states and are not as good in showing of what bender should be able to do. You can see them here:</p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/Figure12.jpg"><img class="alignnone size-medium wp-image-547" title="Figure12" src="http://pacelg.com/wp-content/uploads/2012/01/Figure12-300x178.jpg" alt="" width="300" height="178" /></a><a href="http://pacelg.com/wp-content/uploads/2012/01/Figure13.jpg"><img class="alignnone size-medium wp-image-548" title="Figure13" src="http://pacelg.com/wp-content/uploads/2012/01/Figure13-286x300.jpg" alt="" width="286" height="300" /></a></p>
<p>In the optimalizated version the stopped state seems to be missing, or it could be included in TurnedOn. But I feel that Bender should be awesome enough to go directly from one activity to another without going back to the turned on state first (ref figure one) and I think that Bender should be able to go from a activity to the turned off state without going through the turned on state first (ref figure two). Therefore to illustrate this I drew my own state machine diagram, it looks really complex and messy, but that is what we get from having the possibility to go from a state to almost any other state.</p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/bender2.png"><img class="alignnone size-full wp-image-551" title="bender2" src="http://pacelg.com/wp-content/uploads/2012/01/bender2.png" alt="" width="692" height="735" /></a></p>
<p>To bad there ain&#8217;t a bidirectional arrow&#8230;. Anyhow, When the Bender program is started he is in TurnedOff mode, consider this the initialization of Bender, After this he can move into turnedOn mode from here Bender can turn into every state in the diagram. In the activity states, Walking, running, raising arms, stopped and so on he can switch to any other state EXCEPT from TurnOn, this is because the obvious fact that Bender have to be turned on in order to perform any activities except from actually turning himself on. So what is Benders setup? I want to imagine that he have a knock sensor in his head and if this sensor register that he is hit in the head he is supposed to chant out a negative comment in a fashion that fits Bender. Also he have a distance sensor in his eyes that makes him run if he is more then 5 meters away from anything, he walks if he is closer then 5 meters and if he is about 10 centimeters away from any object he stops.  At this point you might shout out that I am stupid and that if he is chasing anything and gets closer he will first be running, then walking an then when he gets close enough he will be stopping. Therefore you might argue that he always have to walk before he stops. But I say that a meteor might fall in front of him while he runs forcing him to stop, therefore he must be able to come to a full stop while running. Bender also have functional ears and can hear chanting and will react to positive chanting like &#8220;Go Bender&#8221; and &#8220;You Rock&#8221;, if he hears those frases he will raise his hands and if he hears negative frases like &#8220;you suck&#8221; or &#8220;Fry is better then you&#8221; he will be depressed and lower his arms. Bender is a persistent robot and will not consider turning off unless he runs out of alcohol, which means that he will turn off until he receives a message about low alcohol levels.</p>
<p>The outline of the program will look like this:</p>
<pre class="wp-code-highlight prettyprint linenums:1">import &quot;legs.thingml&quot;
import &quot;arms.thingml&quot;
import &quot;head.thingml&quot;
import &quot;ears.thingml&quot;
import &quot;power.thingml&quot;
import &quot;alcohol.thingml&quot;
import &quot;../../thingml.thingml&quot;

thing Bender includes LegsMsgs, ArmsMsgs, HeadMsgs, EarsMsgs, PowerMsgs, AlcoholMsgs{

    property booted : UInt16 = 0

    required port Ears{
        receives positive
        receives negative
    }
    required port Arms{
        sends rise
        sends lower
    }
    required port Legs{
        sends run
        sends walk
        sends stop
    }
    required port Head{
        receives knock
        receives distance
    }
    required port Power{
        recieves powerOn
        recieves powerOff
    }
    required port Alcohol{
        receives low
    }
    statechart BenderImpl init PowerOff{

        state PowerOff{
            on entry do
                Legs!stop()
                booted  = 0
            end
        }
        state PowerOn{
            on entry do
                //Code that boots system goes here
                booted = 1
            end
        }
        state Running{
            on entry do
                Legs!run()
            end
        }
        state Walking{
            on entry do
                Legs!walk()
            end
        }
        state Stopped{
            on entry do
                Legs!stop()
            end
        }
        state RaiseArms{
            on entry do
                Arms!rise()
            end
        }
        state LowerArms{
            on entry do
                Arms!lower()
            end
        }
        state Talking{
            on entry do
                Arms!rise()
            end
        }
    }
}</pre>
<p>It is assumed that all ports are connected to a actual working part of a Bender robot on the other side of the interface. At this point the ThingML program is written so that it is functional with the current way of writing transitions and the way that i want to propose transitions to be written. As you can see there are seven messages that bender can receive and interact on, this means that we have to write seven transition statements in the <em>thing</em> scope. This is a great improvement compared to how it is done in the current version where you have to write seven transition statements in almost every state. The states are written so that they will trigger an action when the state are entered, there is no way to do some clean up and stop the walking procedure while bender is supposed to rise his arms for example since bender is capable of multitasking. Firstly lets compare one of the current style transition to my suggestion. The transition from any state to running would look like this:</p>
<pre class="wp-code-highlight prettyprint linenums:1">transition -&gt; Running
event m : Head?distance
guard booted == 1 and m.distance &gt; 5000</pre>
<p>My suggestion looks like this:</p>
<pre class="wp-code-highlight prettyprint linenums:1">transitions m : Head?distance {
    (booted == 1 and m.distance &gt; 5000) -&gt; Running
}</pre>
<p>At this point we can start to see the advantage of my proposed way of writing transitions, because we will also need to define transitions on the events of the distance being less then 5000 cm and less then 10 cm in order to decide on the correct behavior. In the current implementation this would mean two more transitions, two more event listeners and two more guards, resulting in six more lines of code, in every state, which sums up to 21 lines of code. So the benefits are great in writing it as this:</p>
<pre class="wp-code-highlight prettyprint linenums:1">transitions m : Head?distance {
    (booted == 1 and m.distance &gt; 5000) -&gt; Running
    (booted == 1 and m.distance &lt; 5000 and m.distance &gt; 10) -&gt; Walking
    (booted == 1 and m.distance &gt; 10) -&gt; Stopped
}</pre>
<h3>Problems</h3>
<p>This way of writing the transitions gives us some problems though, in this example one of the problems is solved by the <em>booted == 1</em> check. This does so that we can never go directly from the <em>TurnedOff </em>state to an activity state. Instead of using control variables like this there should be a construct in the transition declaration where the programmer can exclude states that will not allow these transitions to take place. One solution to this might be to add a comma separated list behind the transition that the are not to happen from a specific state, like this:</p>
<pre class="wp-code-highlight prettyprint linenums:1">(m.distance &gt; 5000) -&gt; Running, PowerOff</pre>
<p>This symbolize that the transition that goes to the Running state is not available from the PowerOff state. More states can be added with commas between. In this example neither of the three transitions are to be accessible from the PowerOff state and in the spirit that surrounds this article writing things several times is a abomination. Therefore I suggest that it shall be possible to write a comma separated list of states that will not trigger these transitions behind the closing curly brace, like this:</p>
<pre class="wp-code-highlight prettyprint linenums:1">transitions m : Head?distance {
    (m.distance &gt; 5000) -&gt; Running
    (m.distance &lt; 5000 and m.distance &gt; 10) -&gt; Walking
    (m.distance &lt; 10) -&gt; Stopped
} PowerOff</pre>
<p>Another problem that occurs with this way of writing transitions is how to handle transition to the same state as the program currently are in. In some programs it don&#8217;t matter if a transition goes from a state to itself and thereby running the <em>on exit</em> and the <em>on entry </em>clausula again, but in other programs it might be crucial that it does not loop in a specific state. This problem I want to solve by introducing a new keyword: <em>notself</em>. This is to be placed at the end of the transition declaration, after a eventually comma separated list of excluded states. Here is an example that show that if bender is in the Running state he can not loop into the Running state again, if he is walking he can not start to walk, but if he is stopped he can still stop one more time. No mater how illogical that seems. Remember that Bender is from Futurama and dosn&#8217;t need to be logical.</p>
<pre class="wp-code-highlight prettyprint linenums:1">transitions m : Head?distance {
    (m.distance &gt; 5000) -&gt; Running, notself
    (m.distance &lt; 5000 and m.distance &gt; 10) -&gt; Walking, notself
    (m.distance &lt; 10) -&gt; Stopped
} PowerOff</pre>
<p>Lets move on to the third problem that needs to be solved. Unfortunately this problem does not fit into the Bender example, at least not right now, so I will explain it in a more generic way. Say that we have a state machine with four states S1 to S4 these have all one transition to each of the other three states and are triggered by the same messages, as we have seen in the previous examples. But lets say that S4 is a little different, instead of transiting to S2 on a specific condition as the rest of the states, S4 wants to transit to S3 instead on that specific condition. To solve this problem I propose that it should still be aloved to write transitions inside the states as it is currently done in ThingML. This will allow the compiler to first check the global transitions and thereafter check if there is a local transition inside the state, and if it is give that local transition precedence over the global transition. To show this in the Bender example lets add a rule, for example that Bender is not allowed to rise his arms while Running because this will be to dangerous to his surroundings. So as a safety measure we will instead go into the LowerArms state, since we actually dosn&#8217;t know if his arms are pointing upwards or downwards. The code will look like this:</p>
<pre class="wp-code-highlight prettyprint linenums:1">transitions m : Ears?positive {
    -&gt; RiseArms
} PowerOff
...
statechart BenderImpl init PowerOff{
...
    state Running{
        on entry do
            Legs!run()
       end

        transition -&gt; LowerArms
        event Ears?positive
    }
...</pre>
<p>Now it is time to make a quick comparison between the Bender program written in my proposed way to the way it should be written in the current version of ThingML. Here you can see my implementation:</p>
<pre class="wp-code-highlight prettyprint linenums:1">import &quot;legs.thingml&quot;
import &quot;arms.thingml&quot;
import &quot;head.thingml&quot;
import &quot;ears.thingml&quot;
import &quot;power.thingml&quot;
import &quot;alcohol.thingml&quot;
import &quot;../../thingml.thingml&quot;

thing Bender includes LegsMsgs, ArmsMsgs, HeadMsgs, EarsMsgs, PowerMsgs, AlcoholMsgs{

    required port Ears{
        receives positive
        receives negative
    }
    required port Arms{
        sends rise
        sends lower
    }
    required port Legs{
        sends run
        sends walk
        sends stop
    }
    required port Head{
        receives knock
        receives distance
        sends chantMessage
    }
    required port Power{
        recieves powerOn
        recieves powerOff
    }
    required port Alcohol{
        receives low
    }

    transitions m : Head?distance {
        (m.distance &gt; 5000) -&gt; Running
        (m.distance &lt; 5000 and m.distance &gt; 10) -&gt; Walking
        (m.distance &lt; 10) -&gt; Stopped
    } PowerOff

    transitions m : Ears?positive {
        -&gt; RiseArms, PowerOff
    }
    transitions m : Ears?negative {
        -&gt; LowerArms, PowerOff
    }
    transitions m : Head?knock {
        -&gt; Talking, PowerOff
    }
    transitions m : Alcohol?low {
        -&gt; PowerOff
    }

    statechart BenderImpl init PowerOff{

        state PowerOff{
            on entry do
                Legs!stop()
                Arms!lower()
                //Code to shut down goes here
            end
        }
        state PowerOn{
            on entry do
                //Code that boots system goes here
            end
        }
        state Running{
            on entry do
                Legs!run()
            end
            transition -&gt; LowerArms
            event Ears?positive
        }
        state Walking{
            on entry do
                Legs!walk()
            end
        }
        state Stopped{
            on entry do
                Legs!stop()
            end
        }
        state RaiseArms{
            on entry do
                Arms!rise()
            end
        }
        state LowerArms{
            on entry do
                Arms!lower()
            end
        }
        state Talking{
            on entry do
                Head!chantMessage()
            end
        }
    }
}</pre>
<p>Here I managed to implement Bender in a smashing 103 lines long program, we do of course look away from the interfaces and actual implementation of the electronics that goes into Bender since it is not important to the scope of this article. By doing it the traditional ThingML I got astonishing 254 lines of code, that is more then twice the amount of code.  The file is available here :<a  title='BenderExample' href='http://pacelg.com/?wpdmact=process&did=My5ob3RsaW5r' style="background:url('http://pacelg.com/wp-content/plugins/download-manager/icon/download.png') no-repeat;padding:3px 12px 12px 28px;font:bold 10pt verdana;">Download</a>.  Now imagine that you have discovered that one of your transactions are subject to change, that means that you have to traverse through the code and find everywhere that the transition is written and change it accordingly. This is time consuming work that can be avoided by implementing my proposed way of defining transitions in ThingML. Another argument for implementing my proposed changes into the language is that Internet of Thing (IoT) is something that is becoming more and more common and we need better languages to program our things. I feel that ThingML is a step in the right direction of bringing stuff online and I feel that we will see a lot more autonomous things in the future.  These things, who often are robots, are relying on getting sensory data in order to navigate and interact with their surroundings. Therefore it is often important for them to be able to react to every kind of input no matter what state they are currently in. My proposed changes makes this easier to accomplish and I believe that this will allow us to create better robots which can operate more smoothly in every kind of environment. I hope you can see the benefits from it as well and will give ThingML a try.</p>
<p>If you have any thought on this topic or any other things that might be relevant, donæt by shy to drop a line.</p>
]]></content:encoded>
			<wfw:commentRss>http://pacelg.com/transitions-in-state-machines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Evil Vimbot</title>
		<link>http://pacelg.com/evil-vimbot/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=evil-vimbot</link>
		<comments>http://pacelg.com/evil-vimbot/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 13:10:46 +0000</pubDate>
		<dc:creator>Jan Ole</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[Figure]]></category>
		<category><![CDATA[Vinyl]]></category>

		<guid isPermaLink="false">http://pacelg.com/?p=538</guid>
		<description><![CDATA[A couple of years ago I bought a Vimbot from my friend Kyrre at Desucon. A Vimbot is a small vinyl figure that you can draw, paint, modify as you see fit. I have for a long time been thinking about what I should do with it without anything great coming to mind. During my [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of years ago I bought a Vimbot from my friend Kyrre at Desucon. A Vimbot is a small vinyl figure that you can draw, paint, modify as you see fit. I have for a long time been thinking about what I should do with it without anything great coming to mind.</p>
<p>During my lazy Saturday an Idea came to mind and I ran all the three meters to my electronic stash, lifted it down and found everything that I needed to make my Vimbot rather cool. It wasn&#8217;t much stuff I needed, only two 3mm red LEDS,  one 3mm blue LED, three 330ohm resistors, one 9v battery plug and one 9v battery. The tools I needed was a knife, a soldering iron, glue, a 3mm drill bit and a 5mm drill bit.</p>
<p>I don&#8217;t have any work in process pictures since this is a easy to do modification and I think that if anyone who sees this and wan&#8217;t to replicate it in some way is able to do it without me holding their hands.</p>
<p>On the front I have drilled two 3mm holes for the red LEDs to go in, they have to be put in from the back side because of the rim on the bottom og the LED.</p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG0725.jpg"><img class="alignnone size-medium wp-image-540" title="IMAG0725" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG0725-e1326028030224-179x300.jpg" alt="" width="179" height="300" /></a></p>
<p>In the back I have drilled two 5mm holes and pushed the two red LEDs into the eye holes. I also cut away some material on the bottom and put the blue LED inside pointing upwards, then glued it in place. Then I soldered the resistors in place, one on each positive LED pin. and then soldered the leads from the three resistors to each other. Then I soldered the battery plug to both the positive and the negative leads.</p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG0726.jpg"><img class="alignnone size-medium wp-image-539" title="IMAG0726" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG0726-e1326028065759-179x300.jpg" alt="" width="179" height="300" /></a></p>
<p>This is how it looks plugged in standing on top of a<a href="http://www.finn.no/finn/torget/tilsalgs/annonse?finnkode=32544523"> speaker on my shelf.</a></p>
<p><a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG0724.jpg"><img class="alignnone size-medium wp-image-542" title="IMAG0724" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG0724-179x300.jpg" alt="" width="179" height="300" /></a><a href="http://pacelg.com/wp-content/uploads/2012/01/IMAG0724-1.jpg"><img class="alignnone size-medium wp-image-541" title="IMAG0724-1" src="http://pacelg.com/wp-content/uploads/2012/01/IMAG0724-1-213x300.jpg" alt="" width="213" height="300" /></a></p>
<p>If you wan&#8217;t to buy your own Vimbot or other kind of cool vinyl figure, Kyrre is selling all his figures here: <a href="http://www.finn.no/finn/torget/tilsalgs/annonse?finnkode=32544523" target="_blank">http://www.finn.no/finn/torget/tilsalgs/annonse?finnkode=32544523</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pacelg.com/evil-vimbot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

