<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Soonho Kong]]></title>
  <link href="http://www.cs.cmu.edu/~soonhok/atom.xml" rel="self"/>
  <link href="http://www.cs.cmu.edu/~soonhok/"/>
  <updated>2013-06-14T11:49:21-04:00</updated>
  <id>http://www.cs.cmu.edu/~soonhok/</id>
  <author>
    <name><![CDATA[Soonho Kong]]></name>
    <email><![CDATA[soonhok@cs.cmu.edu]]></email>
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Running (Secure) Wordpress @ CMU]]></title>
    <link href="http://www.cs.cmu.edu/~soonhok/blog/Running-Wordpress-CMU"/>
    <updated>2012-11-20T18:32:00-05:00</updated>
    <id>http://www.cs.cmu.edu/~soonhok/blog/Running-Wordpress-CMU</id>
    <content type="html"><![CDATA[<p>By default, CMU web servers do not allow you to run scripts written in
PHP, Ruby, Perl, and Python. However there is a way to enable this
feature by using <a href="http://www.contrib.andrew.cmu.edu">http://www.contrib.andrew.cmu.edu</a> web server.</p>

<!-- more -->

<h1 id="first-step">First step</h1>

<p>Read <a href="http://www.contrib.andrew.cmu.edu/~minlix/wordpress/?p=69">whoji’s post</a> on How to setup wordpress on Andrew File
System(AFS) @ CMU. Though it’s not complete, it’s very good point to
start. He explains every step in detail so that it should be quiet
easy to follow. Once you followed his instructions, you have a working
wordpress blog on your account. Here, I assume that you
installed the blog at <code>~/www/blog</code>.</p>

<h1 id="problem-security-issue">Problem: Security Issue</h1>

<p>So, what’s the problem? Even if your-just-installed-blog works now,
there is a <em>security problem</em> in this configuration. Because of the way
AFS works, any user in the AFS system can access your <code>wp-config.php</code>
file where you put your <em>MySQL user ID</em> and <em>password</em>!</p>

<p>Please note that changing linux permission on your blog directory does
<em>not</em> help. If you read <a href="http://www.club.cc.cmu.edu/doc/contribweb/afswrite.php">Computer Club’s documentation</a>, you will find
that they already mentioned this problem (and also a possible
solution).</p>

<h1 id="solution">Solution</h1>

<p>Script are run by <code>contrib.your_andrew_ID@club.cc.cmu.edu</code> account.
Therefore, the solution is to put <code>wp-config.php</code> file into a
directory where no one but <code>contrib.your_andrew_ID</code> has an access and
use that file instead of the one at <code>~/www/blog</code>. Here, we use
<code>~/www/blog/secret</code> as an example.</p>

<ol>
  <li>
    <p>Create a folder where you hide your wp-config.php file.</p>

    <pre><code>~/www/blog&gt; mkdir secret
</code></pre>
  </li>
  <li>
    <p>Move wp-config.php to the secret directory</p>

    <pre><code>~/www/blog&gt; mv wp-config.php secret/
</code></pre>
  </li>
  <li>
    <p>On the secret folder, give no permission to system:anyuser:</p>

    <pre><code>~/www/blog/secret&gt; fs sa . system:anyuser none
</code></pre>
  </li>
  <li>
    <p>Give read/listing permissions to <code>contrib.your_andrew_ID@club.cc.cmu.edu</code>:</p>

    <pre><code>~/www/blog/secret&gt; fs sa . contrib.your_andrew_ID@club.cc.cmu.edu rl
</code></pre>
  </li>
  <li>
    <p>Substitute all the occurrences of <code>wp-config.php</code> with
 <code>secret/wp-config.php</code> in <code>~/www/blog/wp-load.php</code> and
 <code>~/www/blog/wp-admin/setup-config.php</code> files.</p>
  </li>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[LaTeX Template for Statement of Purpose]]></title>
    <link href="http://www.cs.cmu.edu/~soonhok/blog/latex-template-for-SOP"/>
    <updated>2012-11-12T12:00:00-05:00</updated>
    <id>http://www.cs.cmu.edu/~soonhok/blog/latex-template-for-SOP</id>
    <content type="html"><![CDATA[<p>The SOP (Statement of Purpose) season is back! and I got requests from
my friends to review and help them polish up their SOPs. I wanted to
share my LaTeX template for SOP with them. Please feel free to use it.</p>

<ul>
  <li>Sample SOP: <a href="https://bitbucket.org/soonhok/sop/src/45cf03aa273355f314ebfa13ee0848b38427f7d3/sample.pdf?at=master">sample.pdf</a></li>
  <li>Git Repository: <a href="https://bitbucket.org/soonhok/sop/src">https://bitbucket.org/soonhok/sop/src</a></li>
</ul>

<!-- more -->

<h2 id="requirement">Requirement</h2>

<ul>
  <li>It uses <code>Adobe Caslon Pro</code> font family. If you don’t have them, you
 cannot compile the SOP. For more information about the fonts, please
 visit
 <a href="http://store1.adobe.com/cfusion/store/html/index.cfm?store=OLS-US&amp;event=displayFontPackage&amp;code=1712">here</a>.</li>
</ul>

<h2 id="how-to-compile">How to Compile</h2>

<p>It uses <code>xelatex</code> to use custom fonts. After modifying the downloaded
 <code>main.tex</code>, type the following on the terminal:</p>

<pre><code>$ xelatex main.tex
</code></pre>

<p>I only tested it on OSX machines, you may have problems on other
 platforms such as Windows or Linux.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Programming Turing Machines]]></title>
    <link href="http://www.cs.cmu.edu/~soonhok/blog/programming-turing-machines"/>
    <updated>2012-07-21T08:00:00-04:00</updated>
    <id>http://www.cs.cmu.edu/~soonhok/blog/programming-turing-machines</id>
    <content type="html"><![CDATA[<p>In the <a href="building-a-lego-turing-machine">previous post</a>, we built a
LEGO Turing machine. However, we did not talk about how to run the
machine. In this post, we focus on how to <em>program</em> Turing
machines. Starting from a very naive implementation which only uses a
single task, we will add more features to the machine incrementally:</p>

<ul>
  <li>multi-task</li>
  <li>concurrent movements</li>
  <li>log via USB</li>
  <li>support its own programming language</li>
  <li>transfer a program via USB</li>
</ul>

<iframe width="590" height="325" src="http://www.youtube.com/embed/teDyd0d5M4o" frameborder="0" allowfullscreen=""></iframe>

<!-- more -->

<h1 id="turing-machine">Turing Machine</h1>

<p><a href="http://plato.stanford.edu/entries/turing-machine/">Turing Machine</a> is
an abstract computing device which was contrived by
<a href="http://www.turing.org.uk/turing/">Alan Turing</a>. It runs the following
algorithm:</p>

<ol>
  <li><strong>Read</strong> : Read the current cell of the tape.</li>
  <li><strong>Transition</strong> : Determine the next state, output, and shift
    direction based on the current state and the content of the
    current cell. If the new state is either <em>Accept</em> or <em>Reject</em>
    state, stop the machine.</li>
  <li><strong>Write</strong> : If needed, change the value of the current tape cell.</li>
  <li><strong>Move</strong> : Move the tape to the left or right based on the result of 2.</li>
  <li>Goto 1.</li>
</ol>

<h1 id="simple-single-task-turing-machine-downloaddownloadscodesimpletmreleasetargz">1. Simple, Single-task Turing Machine (<a href="../../downloads/code/simple_tm_release.tar.gz">Download</a>)</h1>

<p>We start with a simple implementation. This implementation has the
following properites (limitations):</p>

<ul>
  <li>Single-task</li>
  <li>Controlled by a Transition Relation</li>
  <li>Serialized Movement: Read - Write - Move, one by one.</li>
  <li>No Logging</li>
</ul>

<h2 id="main-loop">1.1 Main Loop</h2>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>Main code of the simple Turing Machine </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
<span class="line-number">20</span>
<span class="line-number">21</span>
</pre></td><td class="code"><pre><code class="c"><span class="line"><span class="n">TASK</span><span class="p">(</span><span class="n">TM</span><span class="p">)</span>
</span><span class="line"><span class="p">{</span>
</span><span class="line">    <span class="k">while</span><span class="p">(</span><span class="nb">true</span><span class="p">)</span>
</span><span class="line">    <span class="p">{</span>
</span><span class="line">        <span class="cm">/* Read */</span>
</span><span class="line">        <span class="n">input</span> <span class="o">=</span> <span class="n">Read</span><span class="p">();</span>
</span><span class="line">
</span><span class="line">        <span class="cm">/* Make transition */</span>
</span><span class="line">        <span class="p">(</span><span class="n">state</span><span class="p">,</span> <span class="n">output</span><span class="p">,</span> <span class="n">dir</span><span class="p">)</span> <span class="o">=</span> <span class="n">transition</span><span class="p">(</span><span class="n">state</span><span class="p">,</span> <span class="n">input</span><span class="p">);</span>
</span><span class="line">        <span class="k">if</span><span class="p">(</span><span class="n">state</span> <span class="o">==</span> <span class="n">HALT_STATE</span><span class="p">)</span>
</span><span class="line">            <span class="n">HALT</span><span class="p">;</span>
</span><span class="line">
</span><span class="line">        <span class="cm">/* Write (Optional) */</span>
</span><span class="line">        <span class="k">if</span><span class="p">(</span><span class="n">input</span> <span class="o">!=</span> <span class="n">output</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">            <span class="n">write</span><span class="p">(</span><span class="n">output</span><span class="p">);</span>
</span><span class="line">        <span class="p">}</span>
</span><span class="line">
</span><span class="line">        <span class="cm">/* Move */</span>
</span><span class="line">        <span class="n">move</span><span class="p">(</span><span class="n">dir</span><span class="p">);</span>
</span><span class="line">    <span class="p">}</span>
</span><span class="line"><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>The main loop is a direct translation of the algorithm presented
above. Repeatedly, it reads the tape cell, makes a transition which is
defined in <code>transition</code> function, optionally changes the current tape
cell, and moves the tape as directed.</p>

<h2 id="reader">1.2 Reader</h2>

<div class="bogus-wrapper"><notextile><figure class="code"> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
<span class="line-number">20</span>
<span class="line-number">21</span>
<span class="line-number">22</span>
<span class="line-number">23</span>
<span class="line-number">24</span>
<span class="line-number">25</span>
<span class="line-number">26</span>
<span class="line-number">27</span>
<span class="line-number">28</span>
<span class="line-number">29</span>
</pre></td><td class="code"><pre><code class="c"><span class="line"><span class="kt">_Bool</span> <span class="nf">read</span><span class="p">()</span>
</span><span class="line"><span class="p">{</span>
</span><span class="line">    <span class="n">U16</span> <span class="n">color</span><span class="p">;</span>
</span><span class="line">    <span class="kt">_Bool</span> <span class="n">input</span><span class="p">;</span>
</span><span class="line">
</span><span class="line">    <span class="cm">/* 1. Move READ Header to TAPE */</span>
</span><span class="line">    <span class="n">nxt_motor_set_speed</span><span class="p">(</span><span class="n">READ_MOTOR</span><span class="p">,</span> <span class="n">SPEED</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
</span><span class="line">    <span class="k">while</span><span class="p">(</span><span class="n">nxt_motor_get_count</span><span class="p">(</span><span class="n">READ_MOTOR</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="n">READ_REV</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">        <span class="cm">/* do nothing */</span>
</span><span class="line">    <span class="p">}</span>
</span><span class="line">    <span class="n">nxt_motor_set_speed</span><span class="p">(</span><span class="n">READ_MOTOR</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
</span><span class="line">
</span><span class="line">    <span class="cm">/* 2. Read Sensor Value */</span>
</span><span class="line">    <span class="n">ecrobot_set_nxtcolorsensor</span><span class="p">(</span><span class="n">COLOR_SENSOR</span><span class="p">,</span> <span class="n">NXT_LIGHTSENSOR_GREEN</span><span class="p">);</span>
</span><span class="line">    <span class="n">ecrobot_process_bg_nxtcolorsensor</span><span class="p">();</span>
</span><span class="line">    <span class="n">color</span> <span class="o">=</span> <span class="n">ecrobot_get_nxtcolorsensor_light</span><span class="p">(</span><span class="n">COLOR_SENSOR</span><span class="p">);</span>
</span><span class="line">    <span class="n">input</span> <span class="o">=</span> <span class="n">color</span> <span class="o">&lt;</span> <span class="n">COLOR_THRESHOLD</span> <span class="o">?</span> <span class="mi">1</span> <span class="o">:</span> <span class="mi">0</span><span class="p">;</span>
</span><span class="line">    <span class="n">ecrobot_set_nxtcolorsensor</span><span class="p">(</span><span class="n">COLOR_SENSOR</span><span class="p">,</span> <span class="n">NXT_LIGHTSENSOR_NONE</span><span class="p">);</span>
</span><span class="line">    <span class="n">ecrobot_process_bg_nxtcolorsensor</span><span class="p">();</span>
</span><span class="line">
</span><span class="line">    <span class="cm">/* 3. Move READ Header back */</span>
</span><span class="line">    <span class="n">nxt_motor_set_speed</span><span class="p">(</span><span class="n">READ_MOTOR</span><span class="p">,</span> <span class="o">-</span><span class="n">SPEED</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
</span><span class="line">    <span class="k">while</span><span class="p">(</span><span class="n">nxt_motor_get_count</span><span class="p">(</span><span class="n">READ_MOTOR</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">        <span class="cm">/* do nothing */</span>
</span><span class="line">    <span class="p">}</span>
</span><span class="line">    <span class="n">nxt_motor_set_speed</span><span class="p">(</span><span class="n">READ_MOTOR</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
</span><span class="line">
</span><span class="line">    <span class="k">return</span> <span class="n">input</span><span class="p">;</span>
</span><span class="line"><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p><code>read</code> function does three operations:</p>

<ol>
  <li>Move the READ header to the TAPE</li>
  <li>Read the sensor value</li>
  <li>Move the READ header back</li>
</ol>

<p>Let’s focus on the actual reading operation (in step 2) because it is
relatively trivial to move the header back and forth (step 1 &amp; 3). At
line 14, it turns on the color sensor and set it to
<code>NXT_LIGHTSENSOR_GREEN</code> mode. At line 16,
<code>ecrobot_get_nxtcolorsensor_light</code> function returns the raw value
which measures the reflection around the sensor. We use the
pre-defined constant <code>COLOR_THRESHOLD</code> to determine whether the given
raw value is interpreted as 0 or 1. (line 17). Then, it turns off the
light sensor (line 18).</p>

<p>Note that it is necessary to call <code>ecrobot_process_bg_nxtcolorsensor</code>
function at line 15 and line 19. When we change the sensor mode by
calling <code>ecrobot_set_nxtcolorsensor</code> at line 14, nothing really
happens on the sensor side. It only changes the sensor status on the
memory without affecting the sensor itself. It is the job of
<code>ecrobot_process_bg_nxtcolorsensor</code> function which makes requested
changes on the sensor side and copies the raw value of the sensor to
the memory. If we do not call <code>ecrobot_process_bg_nxtcolorsensor</code> at
line 14, 1) the sensor is <em>not</em> set to green light mode and 2) the
value we read at line 16 can be an <em>outdated</em> value– it is the value
of the sensor when <code>ecrobot_process_bg_nxtcolorsensor</code> function was
called last time.</p>

<h2 id="writer">1.3 Writer</h2>

<div class="bogus-wrapper"><notextile><figure class="code"> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
</pre></td><td class="code"><pre><code class="c"><span class="line"><span class="kt">void</span> <span class="nf">write</span><span class="p">(</span><span class="kt">_Bool</span> <span class="n">output</span><span class="p">)</span>
</span><span class="line"><span class="p">{</span>
</span><span class="line">    <span class="kt">int</span> <span class="n">sign</span> <span class="o">=</span> <span class="n">output</span> <span class="o">==</span> <span class="mi">1</span> <span class="o">?</span> <span class="mi">1</span> <span class="o">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span>
</span><span class="line">    <span class="n">nxt_motor_set_speed</span><span class="p">(</span><span class="n">WRITE_MOTOR</span><span class="p">,</span> <span class="n">sign</span> <span class="o">*</span> <span class="n">SPEED</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
</span><span class="line">    <span class="k">while</span> <span class="p">(</span><span class="n">sign</span> <span class="o">*</span> <span class="n">nxt_motor_get_count</span><span class="p">(</span><span class="n">WRITE_MOTOR</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="n">WRITE_REV</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">        <span class="cm">/* do nothing */</span>
</span><span class="line">    <span class="p">}</span>
</span><span class="line">    <span class="n">nxt_motor_set_speed</span><span class="p">(</span><span class="n">WRITE_MOTOR</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
</span><span class="line">    <span class="n">nxt_motor_set_count</span><span class="p">(</span><span class="n">WRITE_MOTOR</span><span class="p">,</span>
</span><span class="line">                        <span class="n">nxt_motor_get_count</span><span class="p">(</span><span class="n">WRITE_MOTOR</span><span class="p">)</span> <span class="o">%</span> <span class="n">WRITE_REV</span><span class="p">);</span>
</span><span class="line"><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Writing operation is simple. It flips the bit on the tape based on the
output value – clockwise to write 0 and counter-clockwise to write
1. The constant <code>WRITE_REV</code> is defined to be 180.</p>

<h2 id="tape-mover">1.4 Tape Mover</h2>

<div class="bogus-wrapper"><notextile><figure class="code"> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
</pre></td><td class="code"><pre><code class="c"><span class="line"><span class="kt">void</span> <span class="nf">move</span><span class="p">(</span><span class="kt">_Bool</span> <span class="n">dir</span><span class="p">)</span>
</span><span class="line"><span class="p">{</span>
</span><span class="line">    <span class="kt">int</span> <span class="n">sign</span> <span class="o">=</span> <span class="n">dir</span> <span class="o">==</span> <span class="n">RIGHT</span> <span class="o">?</span> <span class="mi">1</span> <span class="o">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span>
</span><span class="line">    <span class="n">nxt_motor_set_speed</span><span class="p">(</span><span class="n">TAPE_MOTOR</span><span class="p">,</span> <span class="n">sign</span> <span class="o">*</span> <span class="n">TAPE_MOV_SPEED</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
</span><span class="line">    <span class="k">while</span> <span class="p">(</span><span class="n">sign</span> <span class="o">*</span> <span class="n">nxt_motor_get_count</span><span class="p">(</span><span class="n">TAPE_MOTOR</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="n">TAPE_MOVE_REV</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">        <span class="cm">/* do nothing */</span>
</span><span class="line">    <span class="p">}</span>
</span><span class="line">    <span class="n">nxt_motor_set_speed</span><span class="p">(</span><span class="n">TAPE_MOTOR</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
</span><span class="line">    <span class="n">nxt_motor_set_count</span><span class="p">(</span><span class="n">TAPE_MOTOR</span><span class="p">,</span>
</span><span class="line">                        <span class="n">nxt_motor_get_count</span><span class="p">(</span><span class="n">TAPE_MOTOR</span><span class="p">)</span> <span class="o">%</span> <span class="n">TAPE_MOVE_REV</span><span class="p">);</span>
</span><span class="line"><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p><code>move</code> function is similar to <code>write</code>. Based on the given argument
<code>dir</code> – which is either <code>LEFT</code> or <code>RIGHT</code>, it rotates the motor to
move the tape to the given direction. The constant <code>TAPE_MOVE_REV</code> is
set to 1800 (five cycles).</p>

<h1 id="limitations">Limitations</h1>

<p>This implementation works well, however, there are limitations of this
implementation.</p>

<ul>
  <li><strong>Single-task with polling</strong> : We have one big monolithic task
doing every operation – read/write/move – in it. It uses
busy-wait polling to control motors as the following code (part of
<code>move</code> function).</li>
</ul>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
</pre></td><td class="code"><pre><code class="c"><span class="line">   <span class="k">while</span> <span class="p">(</span><span class="n">sign</span> <span class="o">*</span> <span class="n">nxt_motor_get_count</span><span class="p">(</span><span class="n">TAPE_MOTOR</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="n">TAPE_MOVE_REV</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">      <span class="cm">/* do nothing */</span>
</span><span class="line">   <span class="p">}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p><strong>Problem</strong>: It wastes CPU cycles and prevent us from doing other
   tasks. We are going to improve this by implementing multi-task
   version.</p>

<ul>
  <li><strong>Controlled by a Transition Relation</strong> : In this implementation, we
need to provide a transition relation to program the machine. For
example, the unary addition program has the following transition
relation:</li>
</ul>

<table>
  <thead>
    <tr>
      <th style="text-align: center">State</th>
      <th>Input</th>
      <th> </th>
      <th>Output</th>
      <th>Next State</th>
      <th>Direction</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">0</td>
      <td>0</td>
      <td> </td>
      <td>0</td>
      <td>0</td>
      <td>L</td>
    </tr>
    <tr>
      <td style="text-align: center">0</td>
      <td>1</td>
      <td> </td>
      <td>1</td>
      <td>1</td>
      <td>L</td>
    </tr>
    <tr>
      <td style="text-align: center">1</td>
      <td>0</td>
      <td> </td>
      <td>1</td>
      <td>2</td>
      <td>L</td>
    </tr>
    <tr>
      <td style="text-align: center">1</td>
      <td>1</td>
      <td> </td>
      <td>1</td>
      <td>1</td>
      <td>L</td>
    </tr>
    <tr>
      <td style="text-align: center">2</td>
      <td>0</td>
      <td> </td>
      <td>0</td>
      <td>3</td>
      <td>R</td>
    </tr>
    <tr>
      <td style="text-align: center">2</td>
      <td>1</td>
      <td> </td>
      <td>1</td>
      <td>2</td>
      <td>L</td>
    </tr>
    <tr>
      <td style="text-align: center">3</td>
      <td>0</td>
      <td> </td>
      <td> </td>
      <td>ERROR</td>
      <td> </td>
    </tr>
    <tr>
      <td style="text-align: center">3</td>
      <td>1</td>
      <td> </td>
      <td>0</td>
      <td>4</td>
      <td>R</td>
    </tr>
    <tr>
      <td style="text-align: center">4</td>
      <td>0</td>
      <td> </td>
      <td> </td>
      <td>HALT</td>
      <td> </td>
    </tr>
    <tr>
      <td style="text-align: center">4</td>
      <td>1</td>
      <td> </td>
      <td>1</td>
      <td>4</td>
      <td>R</td>
    </tr>
  </tbody>
</table>

<p>This form is difficult to understand and maintain. We will
   introduce an assembly-like language to program the machine.  With
   the new language, we may program the unary addition as follows:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
<span class="line-number">20</span>
<span class="line-number">21</span>
<span class="line-number">22</span>
<span class="line-number">23</span>
<span class="line-number">24</span>
<span class="line-number">25</span>
<span class="line-number">26</span>
<span class="line-number">27</span>
<span class="line-number">28</span>
<span class="line-number">29</span>
<span class="line-number">30</span>
<span class="line-number">31</span>
<span class="line-number">32</span>
<span class="line-number">33</span>
</pre></td><td class="code"><pre><code class="c"><span class="line"><span class="cm">/* Before it meets the first ones */</span>
</span><span class="line"><span class="mi">0</span><span class="o">:</span>  <span class="n">READ</span>
</span><span class="line">    <span class="n">CJUMP1</span> <span class="mi">1</span>
</span><span class="line">    <span class="n">MOVE</span>   <span class="n">L</span>
</span><span class="line">    <span class="n">JUMP</span>   <span class="mi">0</span>
</span><span class="line">
</span><span class="line"><span class="cm">/* scanning first operand */</span>
</span><span class="line"><span class="mi">1</span><span class="o">:</span>  <span class="n">MOVE</span>   <span class="n">L</span>
</span><span class="line">    <span class="n">READ</span>
</span><span class="line">    <span class="n">CJUMP1</span> <span class="mi">1</span>
</span><span class="line">    <span class="n">WRITE</span>  <span class="mi">1</span>
</span><span class="line">    <span class="n">MOVE</span>   <span class="n">L</span>
</span><span class="line">
</span><span class="line"><span class="cm">/* scanning second operand */</span>
</span><span class="line"><span class="mi">2</span><span class="o">:</span>  <span class="n">READ</span>
</span><span class="line">    <span class="n">CJUMP0</span> <span class="mi">3</span>
</span><span class="line">    <span class="n">MOVE</span>   <span class="n">L</span>
</span><span class="line">    <span class="n">JUMP</span>   <span class="mi">2</span>
</span><span class="line">
</span><span class="line"><span class="cm">/* last position */</span>
</span><span class="line"><span class="mi">3</span><span class="o">:</span>  <span class="n">MOVE</span>   <span class="n">R</span>
</span><span class="line">    <span class="n">READ</span>
</span><span class="line">    <span class="n">CJUMP0</span> <span class="n">ERR</span>
</span><span class="line">    <span class="n">WRITE</span>  <span class="mi">0</span>
</span><span class="line">
</span><span class="line"><span class="cm">/* computation finished, keep moving to the right until it ends */</span>
</span><span class="line"><span class="mi">4</span><span class="o">:</span>  <span class="n">MOVE</span>   <span class="n">R</span>
</span><span class="line">    <span class="n">READ</span>
</span><span class="line">    <span class="n">CJUMP1</span> <span class="mi">4</span>
</span><span class="line">    <span class="n">HALT</span>
</span><span class="line">
</span><span class="line"><span class="nl">ERR:</span>
</span><span class="line">    <span class="n">ERROR</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<ul>
  <li><strong>Serialized Movement</strong>: In the current implementation,
Read/Write/Move operations occur <em>one after another</em>, even if it is
physically possible to do them simulataneously in some cases. For
example, the read header can start to move to the tape while the
tape is being moved to the next position. The only constraint here
is that the tape should not move when the colorsensor reads the
value. By the same argument, we may move the writer lever and the
read header simulataneously. However, we should be careful to avoid
any physical collision. To implement concurrent movements, it is
natural to program using multiple tasks. This extension will
introduce more <em>complexity</em> to an implementation. We will see how to
use <a href="http://www.andrew.cmu.edu/user/arieg/Rek/">our verification tool</a> to make sure that an
implementation has desired properties.</li>
</ul>

<ul>
  <li><strong>No Logging</strong> : Currently, we do not have any logging feature so that
it is difficult to check the internal status of the machine or
debug a program. We will start to add logging by using the LCD
display in the NXT brick. Then, we will use <em>USB communication</em> to
output log messages to the connected computer.</li>
</ul>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Install nxtOSEK in OSX Lion]]></title>
    <link href="http://www.cs.cmu.edu/~soonhok/blog/install-nxtosek-in-osx-lion"/>
    <updated>2012-07-20T14:03:00-04:00</updated>
    <id>http://www.cs.cmu.edu/~soonhok/blog/install-nxtosek-in-osx-lion</id>
    <content type="html"><![CDATA[<p>There are two posts on how to install nxtOSEK in OSX (Lion) –
<a href="http://lejos-osek.sourceforge.net/installation_Mac_OS_X_Lion.htm">nxtOSEK official documentation</a>
and
<a href="http://www.aribeiro.info/content/nxtosek-mac-osx-106-snow-leopard">Augusto Ribeiro’s post</a>.
However, they do <em>not</em> work for me. I spent some time to figure out
problems and find a solution. Here is my finding:</p>

<!-- more -->

<ul>
  <li>Installing <a href="http://mindstorms.lego.com/en-us/support/files/Driver.aspx">LEGO Fantom driver</a> for Mac OS</li>
  <li>Downloading <a href="http://sourceforge.net/projects/yagarto/files/YAGARTO%20for%20Mac%20OS%20X/20111119/yagarto-bu-2.21_gcc-4.6.2-c-c%2B%2B_nl-1.19.0_gdb-7.3.1_eabi_intelmac_20111119.dmg/download">GNU ARM toolchain</a>
    <ul>
      <li>Note: This is <em>version 4.6.2</em>, not the latest version 4.7.1. I
tried the latest one, however, it generated incorrect binaries which
displayed broken strings once I ran them.</li>
    </ul>
  </li>
  <li>Installing GNU ARM toolchain
    <ul>
      <li>Create directory <code>work</code> in home folder.</li>
      <li>Mount downloaded .dmg file.</li>
      <li>Move installer <code>yagarto-4.6.2</code> from .dmg to <code>~/work</code>.</li>
      <li>Run installer. It will create directory <code>~/work/yagarto-4.6.2</code> and install toolchain to it.</li>
    </ul>
  </li>
  <li>
    <p>Download and install
<a href="https://github.com/mxcl/homebrew/blob/master/Library/Formula/wine.rb">Wine</a>
via <a href="http://mxcl.github.com/homebrew/">Homebrew</a></p>

    <pre><code>  brew install wine
</code></pre>
  </li>
  <li>Installing nxtOSEK
    <ul>
      <li>Download <a href="http://sourceforge.net/projects/lejos-osek/files/nxtOSEK/nxtOSEK_v2161.zip/download">nxtOSEK v2.161</a> and unpack it.</li>
      <li>Download <a href="http://lejos-osek.sourceforge.net/installation_mac_files/sam7_ecrobot.lds">sam7_ecrobot.lds</a> and replace with the one in <code>nxtOSEK/ecrobot/c</code>.</li>
    </ul>
  </li>
  <li>Editing <code>tool_gcc.mak</code> to specify GNU ARM directory and target prefix in <code>ecrobot.mak</code></li>
</ul>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>nxtOSEK/ecrobot/tool_gcc.mak</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
</pre></td><td class="code"><pre><code class="makefile"><span class="line"><span class="err">...</span>
</span><span class="line"><span class="nv">GNUARM_ROOT</span> <span class="o">=</span> /Users/<span class="o">[</span>your_home_dir<span class="o">]</span>/work/yagarto-4.6.2
</span><span class="line">...
</span><span class="line">
</span><span class="line">TARGET_PREFIX :<span class="o">=</span>arm-none-eabi
</span><span class="line">...
</span></code></pre></td></tr></table></div></figure></notextile></div>

<ul>
  <li>Editing <code>ecrobot.mak</code> to specify WINECONSOLE. If you use c++ instead
of c, you may need to edit <code>ecrobot++.mak</code></li>
</ul>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>nxtOSEK/ecrobot/ecrobot.mak</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
</pre></td><td class="code"><pre><code class="makefile"><span class="line"><span class="c"># Detect OS name </span>
</span><span class="line"><span class="err">...</span>
</span><span class="line"><span class="nv">UNAME</span> <span class="o">:=</span> <span class="k">$(</span>shell uname<span class="k">)</span>
</span><span class="line"><span class="cp">ifeq ($(UNAME), Darwin)</span>
</span><span class="line"><span class="c">        # Mac OS X detected.</span>
</span><span class="line">        WINECONSOLE :<span class="o">=</span> <span class="nv">LANG</span><span class="o">=</span>en_US.UTF-8 wineconsole
</span><span class="line">        LAUNCHER :<span class="o">=</span> <span class="k">$(</span>WINECONSOLE<span class="k">)</span>
</span><span class="line">...
</span></code></pre></td></tr></table></div></figure></notextile></div>
<ul>
  <li>
    <p>Download native <a href="http://bricxcc.sourceforge.net/nexttool_osx.zip">nexttool</a> for Mac OS X</p>
  </li>
  <li>
    <p>Re-building nxtOSEK libraries</p>
    <ul>
      <li>
        <p>Go to <code>nxtOSEK/ecrobot/c++</code> and run:</p>

        <pre><code> make all
 make release
</code></pre>
      </li>
      <li>
        <p>Go to <code>nxtOSEK/ecrobot/c</code> and run:</p>

        <pre><code> make all
 make release
</code></pre>
      </li>
      <li>
        <p>Go to <code>nxtOSEK/ecrobot/bios</code> and run:</p>

        <pre><code> make all
 make release
</code></pre>
      </li>
      <li>
        <p>Go to <code>nxtOSEK/ecrobot/nxtway_gc_balancer</code> and run:</p>

        <pre><code> make all
 make release
</code></pre>
      </li>
    </ul>
  </li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Building a LEGO Turing Machine]]></title>
    <link href="http://www.cs.cmu.edu/~soonhok/blog/building-a-lego-turing-machine"/>
    <updated>2012-07-18T09:52:00-04:00</updated>
    <id>http://www.cs.cmu.edu/~soonhok/blog/building-a-lego-turing-machine</id>
    <content type="html"><![CDATA[<p>In this article, I illustrate how to build a (slightly) modified version of <a href="http://www.legoturingmachine.org">the LEGO
Turing machine</a> built by researchers at <a href="http://www.cwi.nl">CWI</a>.</p>

<p><img src="http://www.cs.cmu.edu/~soonhok/images/20120718_LegoTM/00_TM1.jpg" alt="A LEGO Turing Machine" /></p>

<!-- more -->

<h1 id="introduction">Introduction</h1>

<h2 id="internship">Internship</h2>

<p>A month ago, I started my summer internship at
<a href="http://www.sei.cmu.edu/">Software Engineering Institute, Carnegie Mellon</a> working on
<a href="http://www.andrew.cmu.edu/user/arieg/Rek/">verification of concurrent programs</a> with <a href="http://www.sei.cmu.edu/about/people/profile.cfm?id=gurfinkel_14336">Dr. Arie Gurfinkel</a> and <a href="http://www.sei.cmu.edu/about/people/profile.cfm?id=chaki_13495">Dr. Sagar Chaki</a>. We looked for an interesting
example to demonstrate our <a href="http://www.andrew.cmu.edu/user/arieg/Rek/">verification tool</a> and to learn how
we can imporve it.</p>

<h2 id="lego-mindstorms--nxtosek">LEGO Mindstorms &amp; nxtOSEK</h2>

<p>Interestingly, <a href="http://www.sei.cmu.edu/about/people/profile.cfm?id=gurfinkel_14336">Arie</a> and <a href="http://www.sei.cmu.edu/about/people/profile.cfm?id=chaki_13495">Sagar</a> have used concurrent
programs written for <a href="http://mindstorms.lego.com/en-us/Default.aspx">LEGO Mindstorm</a> as benchmarks of their
verification tool. At first time, I got an impression that these LEGO
programs are not <em>realistic</em>. However, I learned that I was wrong.</p>

<ol>
  <li>Those LEGO Mindstorms programs are running on the <a href="http://lejos-osek.sourceforge.net/whatislejososek.htm">nxtOSEK</a>
 platform.</li>
  <li>A part of nxtOSEK is TOPPERS/ATK, which provided real-time multi
 tasking features proven in automotive industry.</li>
  <li>Actually, <em>“<a href="http://en.wikipedia.org/wiki/OSEK">OSEK</a>”</em> in “nxtOSEK” is an <strong>open standard</strong> for
 <strong>automotive embedded systems</strong>, published by a
 consortium founded by the <strong>automobile industry</strong> including BMW, Robert
 Bosch GmbH, DaimlerChrysler, Opel, Siemens, Volkswagen Group, Renault
 and PSA Peugeot Citroën.</li>
  <li>nxtOSEK’s real-time kernel is also compatible with <a href="http://www.ertl.jp/ITRON/SPEC/mitron4-e.html">μITRON 4.0</a> specification which is a <strong>de-facto industry standard</strong> in the
 embedded systems field.</li>
</ol>

<p><img src="../../images/20120718_LegoTM/mscar.jpg" alt="Mindstorms Car" /> </p>

<p>Sometimes, things are more than what we see. This Mindstorms car
looks like a toy, however it contains a complex embedded
system inside.</p>

<h1 id="cwi-turing-machine">CWI Turing Machine</h1>

<p>After spending some time on searching for good examples, I found this
fascinating <a href="http://www.legoturingmachine.org">Turing machine</a> which was designed by
researchers at <a href="http://www.cwi.nl">CWI</a>. I do recommend their
[<a href="http://vimeo.com/44202270">Video</a>] if you have not watched it yet.</p>

<p><img src="../../images/20120718_LegoTM/legotm.png" alt="A Lego Turing Machine by CWI researchers" /></p>

<p>We decided to build this machine because of the following reasons:</p>

<ul>
  <li><strong>Simple Mechanics</strong>: All operations – reading, writing, and moving –
 can be done by simply rotating motors and reading a sensor. We do not
 need to worry about complex movements which are basically not our
 interest.</li>
  <li><strong>Inherent Parallelism</strong>: Though the CWI TM is a single-thread program,
 it is natural to program a Turing machine using multiple threads. </li>
</ul>

<h1 id="required-components">0. Required Components</h1>

<ol>
  <li><a href="http://www.amazon.com/LEGO-4544091-Mindstorms-NXT-2-0/dp/B001USHRYI">LEGO Mindstorms NXT 2.0 Kit (8547)</a> ($280): Definitely,
 we need this one. This kit consists of one NXT brick, three servo
 motors, and four sensors (ultrasonic sensor, 2 touch sensors, and
 color sensor). To build this TM, we are going to use three servo
 motors and one color sensor.<br />
 <img src="../../images/20120718_LegoTM/mindstorms.jpg" alt="LEGO MINDSTORMS NXT" /></li>
  <li>Technic Parts ($20): It is not clear what components you really need
 even after reading the <a href="http://www.legoturingmachine.org">CWI webpage</a>. They just mention that
 you need some other parts from LEGO Technic Kits. Watching
 their video several times, I figured out what we needed to build
 a machine with a 16-bit long tape.</li>
</ol>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Number</th>
      <th style="text-align: left">Name</th>
      <th style="text-align: center">Quantity</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center"><a href="http://www.peeron.com/inv/parts/3647">3647</a></td>
      <td style="text-align: left">Technic Gear 8 Tooth</td>
      <td style="text-align: center">5</td>
    </tr>
    <tr>
      <td style="text-align: center"><a href="http://www.peeron.com/inv/parts/3713">3713</a></td>
      <td style="text-align: left">Technic Bush</td>
      <td style="text-align: center">40</td>
    </tr>
    <tr>
      <td style="text-align: center"><a href="http://www.peeron.com/inv/parts/3743">3743</a></td>
      <td style="text-align: left">Technic Gear Rack 1 x 4</td>
      <td style="text-align: center">10</td>
    </tr>
    <tr>
      <td style="text-align: center"><a href="http://www.peeron.com/inv/parts/3737">3737</a></td>
      <td style="text-align: left">Technic Axle 8</td>
      <td style="text-align: center">10</td>
    </tr>
    <tr>
      <td style="text-align: center"><a href="http://www.peeron.com/inv/parts/4274">4274</a></td>
      <td style="text-align: left">Technic Pin 1/2</td>
      <td style="text-align: center">25</td>
    </tr>
    <tr>
      <td style="text-align: center"><a href="http://www.peeron.com/inv/parts/4716">4716</a></td>
      <td style="text-align: left">Technic Gear Worm</td>
      <td style="text-align: center">2</td>
    </tr>
    <tr>
      <td style="text-align: center"><a href="http://www.peeron.com/inv/parts/6536">6536</a></td>
      <td style="text-align: left">Technic Cross Block 1 x 2(Axle/Pin)</td>
      <td style="text-align: center">15</td>
    </tr>
    <tr>
      <td style="text-align: center"><a href="http://www.peeron.com/inv/parts/32014">32014</a></td>
      <td style="text-align: left">Technic Angle Connector #6 (90 degree) (BLACK!)</td>
      <td style="text-align: center">15</td>
    </tr>
    <tr>
      <td style="text-align: center"><a href="http://www.peeron.com/inv/parts/48989">48989</a></td>
      <td style="text-align: left">Technic Cross Block 1 x 3(Pin/Pin/Pin) with 4 Pins</td>
      <td style="text-align: center">10</td>
    </tr>
  </tbody>
</table>

<p>Please note that you have to choose <strong>Black</strong> color when you buy
<a href="http://www.peeron.com/inv/parts/32014">32014 Technic Angle Connector #6 (90 degree)</a>
because this part will be used as a *bit” in a tape.</p>

<h1 id="tape-16-bit">1. Tape (16-bit)</h1>

<p>Let’s build the tape first. Basically,
<a href="http://www.peeron.com/inv/parts/32014">32014 Technic Angle Connector #6 (90 degree)</a>
– the L-shaped black part – plays the role of “bit”. Two bits are
separated by either a
<a href="http://www.peeron.com/inv/parts/3713">3713 Technic Bush</a> – Red
cylindrical object – or
<a href="http://www.peeron.com/inv/parts/6536">6536 Technic Cross Block 1 x 2(Axle/Pin)</a>.</p>

<p><img src="../../images/20120718_LegoTM/tape1.jpg" alt="Tape #1" /></p>

<p><img src="../../images/20120718_LegoTM/tape2.jpg" alt="Tape #2" /></p>

<p>The bottom of the tape is not shown on the <a href="http://vimeo.com/44202270">Video</a> and it
is actually quite tricky to figure out what there is. As you see in
image 7 and 8, there are
<a href="http://www.peeron.com/inv/parts/3743">3743 Technic Gear Rack 1 x 4</a>
at the bottom of the tape, which are attached with
<a href="http://www.peeron.com/inv/parts/4274">4274 Technic Pin 1/2</a>.</p>

<h1 id="rail--bridge">2. Rail &amp; Bridge</h1>

<p><img src="../../images/20120718_LegoTM/02_Rail.jpg" alt="Rail &amp; Bridge" /></p>

<p>Building a rail and a bridge is not difficult. Make sure that the gap
in the rail is three-hole wide so that the tape can fit in it.</p>

<h1 id="engine-gears--gear-worms">3. Engine (Gears &amp; Gear Worms)</h1>

<p>This is the most interesting part of the machine. Here is a
<strong>problem</strong>. We need <em>linear movement</em> to move the tape back and forth while
our servo motor only provides <em>circular movement</em>. The CWI design
solves this problem by using gear, gear worms, and gear racks.</p>

<p>My solution is simpler than the CWI design in a sense that mine does
not use a bevel gear.
<img src="../../images/20120718_LegoTM/engine1.jpg" alt="Engine #1" /></p>

<p>Once you finish up to step 6, please make sure that the gear worms do
not move back and forth when you rotate the 24-teeth black gear.</p>

<p><img src="../../images/20120718_LegoTM/03_Engine7.jpg" alt="Engine #2" /></p>

<p>You also need to place additional
<a href="http://www.peeron.com/inv/parts/3647">3647 Technic Gear 8 Tooth</a> on
the rail to hold the tape stably (see the top and bottom parts of
Engine #2 image).</p>

<h1 id="tape-mover">4. Tape Mover</h1>

<p>We need to transfer the drive from a motor to the engine part. First
assemble the Tape Mover unit with a servo motor.</p>

<p><img src="../../images/20120718_LegoTM/04_TapeMover1.jpg" alt="Tape Mover Unit" /></p>

<p>Then attach it to the bridge and engine part. Make sure that there is
no movement of the motor when it runs.</p>

<p><img src="../../images/20120718_LegoTM/04_TapeMover2.jpg" alt="Attached Tape Mover" /></p>

<h1 id="reader">5. Reader</h1>

<p><img src="../../images/20120718_LegoTM/05_Reader1.jpg" alt="Reader Unit" /></p>

<p>The Reader unit consists of one servo motor and one color sensor. Once
you assemble it, attach to the rail &amp; bridge.</p>

<p><img src="../../images/20120718_LegoTM/05_Reader2.jpg" alt="Attached Reader" /></p>

<h1 id="writer">6. Writer</h1>

<p><img src="../../images/20120718_LegoTM/06_Writer1.jpg" alt="Writer Unit" /></p>

<p>The Writer unit has a servo motor with a lever to flip a bit. It is
important to align the Reader and Writer well so that they can read
and write the same bit of the tape.</p>

<p><img src="../../images/20120718_LegoTM/06_Writer3.jpg" alt="Attached Writer" /></p>

<h1 id="thats-it">That’s it!</h1>

<p>Once you finish all the steps, connect all the motors and the sensor
to the NXT brick using cables. Now, you are ready to run this machine!</p>

<p><img src="../../images/20120718_LegoTM/tm.jpg" alt="A LEGO Turing Machine" /></p>

]]></content>
  </entry>
  
</feed>
