<?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>Physical computing &#187; balcaen.bert@iaac.net</title>
	<atom:link href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/author/balcaen-bertiaac-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing</link>
	<description></description>
	<lastBuildDate>Wed, 01 May 2013 22:32:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Drawing machine, prototype</title>
		<link>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/12/drawing-machine-prototype/</link>
		<comments>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/12/drawing-machine-prototype/#comments</comments>
		<pubDate>Tue, 18 Dec 2012 16:41:12 +0000</pubDate>
		<dc:creator>balcaen.bert@iaac.net</dc:creator>
				<category><![CDATA[Bert Balcaen]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Students]]></category>

		<guid isPermaLink="false">http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/?p=838</guid>
		<description><![CDATA[A drawing machine I have a couple of ideas in mind that involve a drawing machine, so I wanted create one as a final project for our physical computing class. In post I&#8217;ll explain the technical side of the project. I&#8217;ll talk about my motivation for building such a thing in a later post. We [...]]]></description>
				<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/55871937?badge=0&amp;color=55c4e4" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
<h2>A drawing machine</h2>
<p>I have a couple of ideas in mind that involve a drawing machine, so I wanted create one as a final project for our physical computing class. In post I&#8217;ll explain the technical side of the project. I&#8217;ll talk about my motivation for building such a thing in a later post.</p>
<p><span id="more-838"></span></p>
<p>We just had a few days of time for completing this project, so I did my best of resisting the temptation to invent everything from scratch. I decided to base myself on the &#8216;hanging drawbot&#8217; design, which to my knowledge was first done by <a href="http://hektor.ch">Jürg Lehni with Hektor</a> ten years ago.</p>
<p>The basic idea is this: motors are used to control the position of a pen that is connected to the motors via threads. By using the Pythagorean theorem you can find out what the position of the pen is, and this information can be used to control the length of the threads.</p>
<p>There have been countless variations on this theme in the meantime. I mostly used the work of <a href="http://www.marginallyclever.com">Dan Royer</a> and his <a href="https://github.com/i-make-robots/DrawBot">DrawBot</a>. I choose this project because it&#8217;s open source, simple and well-documented. I&#8217;ve used his project to show me the way, but along the way I&#8217;ve had some troubles and I&#8217;ve made a few changes. I&#8217;m documenting them here.</p>
<h2>Bill of materials</h2>
<p>I almost couldn&#8217;t start this project because I couldn&#8217;t get some materials in time. Then I found out about <a href="http://www.bcncybernetics.com">Barcelona Cybernetics</a>, where you can order Arduino&#8217;s and related components online and pick them up the same day. Here&#8217;s what I bought from them:</p>
<ul>
<li>1 x ADA-081 Adafruit Motor/Stepper/Servo Shield para Arduino kit &#8211; v1.0, €24.81</li>
<li>2 x ADA-324	Stepper motor &#8211; 200 steps/rev, 12V 350mA, €32.10 for 2</li>
<li>1 x A-0072 Arduino ETH Shield Rev3 SIN PoE, €35.10</li>
</ul>
<p>Then I went to <a href="http://www.ondaradio.es">Onda Radio</a> where I go a couple of smaller standard items:</p>
<ul>
<li>A power supply (12v, 4.7 amps, around 20 euro)</li>
<li>Cabe for power supply (2.80 euro)</li>
<li>Wire, in 4 colours: red, yellow, green, grey, the same colors as the ones on the motors. (2 euro per color) The wires on my motors were pretty short.</li>
<li>Some screw terminals for extending the wires of the motors.</li>
</ul>
<p>And this is what I picked up in a basic crafts shop:</p>
<ul>
<li>A Staedtler marker.</li>
<li>A bulldog clip. (Used to give the pen holder some weight, could be something else.)</li>
<li>Fishing line.</li>
</ul>
<p>And this I had already:</p>
<ul>
<li>An Arduino Uno</li>
<li>Scrap pieces of plywood and acrylic.</li>
<li>A big wooden board to mount everything on.</li>
<li>Some M3 screws in various sizes.</li>
</ul>
<p>h2. The motorshield</p>
<p>I checked out various ways to control the stepper motors. The easiest seem to be <a href="https://www.sparkfun.com/products/10267">EasyDriver</a> and Adafruit&#8217;s shield. I went for the shield, since it&#8217;s only slightly more expensive but you can control 2 motors with it.</p>
<p>You need to assemble it. I didn&#8217;t have much soldering experience, but it was pretty easy using the <a href="http://www.ladyada.net/make/mshield/">instructions</a>. It took me around an hour.</p>
<h2>The motors</h2>
<p>Dan sells his DrawBot in kit form, and this comes with motors that can do 400 steps per rotation (see https://www.sparkfun.com/products/10846, more or less same price). This type of motors are used by CNC machines, so there pretty accurate. I&#8217;m using the <a href="http://www.adafruit.com/products/324">steppers</a> sold by Adafruit, which can only do 200 steps per rev. That means there&#8217;s only half as precise. In pratice, the results I get don&#8217;t seem that bad, but I&#8217;m curious what the difference is.</p>
<p>The <a href="//www.adafruit.com/products/324">wiring for the motors</a> is explained on Adafruit&#8217;s product page:</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/motor-shield.jpg"><img class="alignnone size-medium wp-image-853" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/motor-shield-300x198.jpg" alt="" width="300" height="198" /></a></p>
<p>After this I downloaded the library for the shield and I ran the examples. Everything seemd to work fine.</p>
<p>The wires on the motors were short (around 20 cm) so I extended them by connecting them to 1m wires I cut and tinned. I used screw terminals because I wasn&#8217;t sure if I was going to keep the motors in this setup. It was a good idea to spend a few euros on getting wires in the same color. This made this job much easier.</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/DSC_0020.jpg"><img class="alignnone size-medium wp-image-848" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/DSC_0020-300x198.jpg" alt="" width="300" height="198" /></a></p>
<p>The motors need 12V and 350mA each. I got a 12V/4amp power supply in the form of those metal boxes. You need to buy a power cord seperately for these things.</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/power-supply.jpg"><img class="alignnone size-medium wp-image-857" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/power-supply-300x198.jpg" alt="" width="300" height="198" /></a></p>
<h2>Motor mounts</h2>
<p>You&#8217;ll some way to hang the motors on a wall or a board. <a href="http://www.thingiverse.com/image:175415">Dan&#8217;s 3D-printable design for the mounts</a> is nice: it functions as an L bracket, and it has holes for the thread. I adapted it for laser cutting by tracing it in Rhino and adding some notches so the parts could be glued.</p>
<p>Here is what I sent to the laser cutter:</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/motor_mount_03.jpg"><img class="alignnone size-medium wp-image-861" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/motor_mount_03-300x92.jpg" alt="" width="300" height="92" /></a></p>
<p>I used 3 mm acrylic. Here is the mount after glueing:</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/motor-mount-on-motor.jpg"><img class="alignnone size-medium wp-image-852" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/motor-mount-on-motor-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>I forked Dan&#8217;s <a href="https://github.com/bertbalcaen/DrawBot/tree/master/printable-parts">project on GitHub</a> and added the files in AI, PDF and Rhino format.</p>
<h2>Spools</h2>
<p>I really like this <a href="http://stuartchilds.com/2012/07/drbo-thread-spool-assembly/">bobbin design from Stuart Childs</a>. It can be laser cut, and it has a hole for a screw that can be used to tigthen the spool to the motor.</p>
<p>Stuart&#8217;s bobbins are too big for the motor mounts I used, so I made a variation on it:</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/spools_04.jpg"><img class="alignnone size-medium wp-image-863" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/spools_04-300x63.jpg" alt="" width="300" height="63" /></a></p>
<p>I cut this on 3mm plywood. I&#8217;m using fishing line for the thread, and I connected it a screw after to the second disc. This is how the whole thing looks when it&#8217;s assembled:</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/bobbin-1.jpg"><img class="alignnone size-medium wp-image-845" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/bobbin-1-300x198.jpg" alt="" width="300" height="198" /></a></p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/bobbin-2.jpg"><img class="alignnone size-medium wp-image-846" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/bobbin-2-300x198.jpg" alt="" width="300" height="198" /></a></p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/bobbin-3.jpg"><img class="alignnone size-medium wp-image-847" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/bobbin-3-300x198.jpg" alt="" width="300" height="198" /></a></p>
<p>The <a href="https://github.com/bertbalcaen/DrawBot/tree/master/printable-parts">&#8220;files for lasercutting can be found on GitHub.</a></p>
<h2>Pen holder</h2>
<p>I reused the same idea of the tightening screw for the pen holder. This is the file that was sent to the laser cutter:</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/pen_holder_01.jpg"><img class="alignnone size-medium wp-image-862" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/pen_holder_01-300x296.jpg" alt="" width="300" height="296" /></a></p>
<p>This was cut on 3mm acrylic. Here is the finished piece:</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/pen-holder-1.jpg"><img class="alignnone size-medium wp-image-854" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/pen-holder-1-300x198.jpg" alt="" width="300" height="198" /></a></p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/pen-holder-2.jpg"><img class="alignnone size-medium wp-image-855" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/pen-holder-2-300x198.jpg" alt="" width="300" height="198" /></a></p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/pen-holder-3.jpg"><img class="alignnone size-medium wp-image-856" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/pen-holder-3-300x198.jpg" alt="" width="300" height="198" /></a></p>
<p>The hole in middle is big enough for the tip of a Staedtler marker. I had to add a bulldog clip on the top to add some extra weight so the pen holder would be close enough to the board.</p>
<h2>Firmware</h2>
<p>I loaded Dan&#8217;s DrawBot firmware into my Arduino. There&#8217;s a couple of very important changes I made:</p>
<ul>
<li>Bobbin size was set to 3mm.</li>
<li>And, most importantly: the maximum speed of the motors was decreased from 2000 RPM to 250 RPM. It took me a while to understand that this was necessary. With the 2000 RPM setting, the motors couldn&#8217;t keep up. They went a little forward, and then back again.</li>
</ul>
<p>See the <a href="https://github.com/bertbalcaen/DrawBot/commit/51737486cd4636f476932aca813c04932da06b80">changeset on Github</a> for the exact code.</p>
<h2>Drawing</h2>
<p>Dan&#8217;s DrawBot project includes a handy interface for controlling the drawing machine and sending images to it.</p>
<p>This is how mine has to be configured:</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/jog-motors.png"><img class="alignnone size-medium wp-image-850" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/jog-motors-300x264.png" alt="" width="300" height="264" /></a></p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/limits.png"><img class="alignnone size-medium wp-image-851" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/limits-300x258.png" alt="" width="300" height="258" /></a></p>
<p>Here&#8217;s how the first test looked like:</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/hello-world.jpg"><img class="alignnone size-medium wp-image-849" src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/12/hello-world-300x198.jpg" alt="" width="300" height="198" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/12/drawing-machine-prototype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Laser projector project, part 4: first code</title>
		<link>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/11/laser-projector-project-part-4-determining-motor-speed/</link>
		<comments>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/11/laser-projector-project-part-4-determining-motor-speed/#comments</comments>
		<pubDate>Thu, 29 Nov 2012 15:42:01 +0000</pubDate>
		<dc:creator>balcaen.bert@iaac.net</dc:creator>
				<category><![CDATA[Bert Balcaen]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Students]]></category>

		<guid isPermaLink="false">http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/?p=370</guid>
		<description><![CDATA[I&#8217;m trying to understand how I should program the projector. This is a program to determine the speed of the motor, using the photosensor: const int transistorPin = 9; // connected to the base of the transistor float rpm = 0; unsigned long lastRotTime = 0; unsigned long timeSinceLastRot = 0; boolean overPhotoSensor = false; [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m trying to understand how I should program the projector.</p>
<p><span id="more-370"></span></p>
<p>This is a program to determine the speed of the motor, using the photosensor:</p>
<p><code><br />
const int transistorPin = 9;    // connected to the base of the transistor</p>
<p>float rpm = 0;<br />
unsigned long lastRotTime = 0;<br />
unsigned long timeSinceLastRot = 0;<br />
boolean overPhotoSensor = false;<br />
boolean lastOverPhotoSensor = false;</p>
<p>void setup() {  </p>
<p>  pinMode(transistorPin, OUTPUT);</p>
<p>  Serial.begin(9600);</p>
<p>}</p>
<p>void loop() {</p>
<p>  int potValue = analogRead(A0);<br />
  int outputValue = potValue/4;<br />
  analogWrite(transistorPin, outputValue);</p>
<p>  timeSinceLastRot = micros() - lastRotTime;</p>
<p>  int photoSensorVal = analogRead(A1);<br />
  //  Serial.println(photoSensorVal);<br />
  // turn on laser if something is close to the photosensor<br />
  overPhotoSensor = photoSensorVal &lt; 100;<br />
  if(overPhotoSensor != lastOverPhotoSensor){<br />
    if(overPhotoSensor){<br />
      rpm = 60000 * 1000 / timeSinceLastRot;<br />
      Serial.println(rpm);<br />
      timeSinceLastRot = 0;<br />
      lastRotTime = micros();<br />
    }<br />
  }</p>
<p>  lastOverPhotoSensor = overPhotoSensor;</p>
<p>}<br />
</code></p>
<p>This is basically the StateChangeDetection example that comes with Arduino.</p>
<p>Here are some numbers. I&#8217;m still using 5V, and I&#8217;m getting top speeds around 1.800 rounds per minute, or 30 per second (= 1.800/60). That means one rotation takes around 32-33 ms (= 1/30 * 1.000).</p>
<p>I counted how many times the Arduino goes through the loop() function during each rotation: I get values around 125. And here I have a problem. Each time my code in loop() gets executed, I can draw 1 &#8220;pixel&#8221;. If the Arduino can only do the loop() 125 times then I can only draw 125 &#8220;pixels&#8221;, which is not enough to draw something interesting. I probably don&#8217;t need 1.800 rpm, but even at half that speed I would only get 250 pixels.</p>
<p>So the chip needs around 0.264 ms (= 125 executions per rotation / 33 ms per rotation) to execute my code in loop(). I confirmed this with this piece of code:</p>
<p><code><br />
timeSpentInFrame = micros() - now;<br />
Serial.println("timeSpentInFrame");<br />
Serial.println(timeSpentInFrame);<br />
now = micros();<br />
</code></p>
<p>Then I created a minimal Arduino program to see how much time it would to loop():</p>
<p><code><br />
unsigned long timeSpentInLoop;<br />
unsigned long now;</p>
<p>void setup(){<br />
  Serial.begin(115200);<br />
}<br />
void loop(){<br />
  timeSpentInLoop = micros() - now;<br />
  Serial.println("timeSpentInLoop");<br />
  Serial.println(timeSpentInLoop);<br />
  now = micros();<br />
}<br />
</code></p>
<p>Here, is some sample output:</p>
<p><code><br />
timeSpentInLoop<br />
8<br />
timeSpentInLoop<br />
8<br />
timeSpentInLoop<br />
4<br />
timeSpentInLoop<br />
8<br />
timeSpentInLoop<br />
8<br />
</code></p>
<p>This is in microseconds. The number is not stable and varies between 4 and 16. Let&#8217;s say 0.008 is the average, then is this around 30 times faster than my code. I think I have some optimizing to do.</p>
<p>I asked Alex and in the Arduino forums there&#8217;s <a href="http://arduino.cc/forum/index.php/topic,6549.msg51583.html#msg51583">a way to make analogRead() to its thing a bit faster</a> by trading a bit of resolution for speed. I tried it out, and it was indeed faster. The Arduino needed only around 65 microseconds to through loop() instead of 264.</p>
<p>At a speed of 1.600 rpm this gives me 526 pixels to work with. After slowing down to 1.500 rpm, the Arduino managed to 642 loop() iterations per rotation. That still wasn&#8217;t much, and looked like <a href="http://arduino.cc/en/Reference/AttachInterrupt">interrupts</a> might the solution. I was a bit afraid of going into that topic, because it seemed to bring me a step closer to the hardware, with the danger of loosing lots of time in uncharted territory. However, because timing is crucial for this project I decided to check it out.</p>
<p>Turns out that there&#8217;s two types of interrupts. One is for timers (feels a bit similar to threads), and that&#8217;s the hard one. The other types of interrupts are a bit similar to events, for example a JavaScript click event: you define a callback that get executed when a pin detects a change in value. This run directly on the hardware, outside of the loop, so its very fast. <a href="http://arduino.cc/en/Reference/AttachInterrupt">More details about interrupts can be found in the documentation.</a></p>
<p>Here is the new version of the code:</p>
<p><code><br />
const int transistorPin = 9;    // connected to the base of the transistor</p>
<p>float timePerRot = 0;<br />
float rpm = 0;<br />
volatile int rotations = 0;</p>
<p>unsigned long now = 0;<br />
unsigned long prevNow = 0;<br />
unsigned long timeSpentInFrame = 0;</p>
<p>int potValue = 0;<br />
int outputValue = 0;</p>
<p>void setup() {  </p>
<p>  pinMode(transistorPin, OUTPUT);<br />
  attachInterrupt(0, photoSensorActivated, FALLING);</p>
<p>  Serial.begin(115200);</p>
<p>}</p>
<p>void loop() {</p>
<p>  potValue = analogRead(A0);<br />
  outputValue = potValue/4;<br />
  analogWrite(transistorPin, outputValue);</p>
<p>  if(rotations &gt;= 1){<br />
    timePerRot = (micros() - prevNow)/ rotations;<br />
    prevNow = micros();<br />
    rpm = 60 / (timePerRot / (1000.0 * 1000.0));<br />
    Serial.println("rpm");<br />
    Serial.println(rpm);<br />
    rotations = 0;<br />
  }</p>
<p>  now = micros();<br />
  timeSpentInFrame = micros() - now;<br />
  Serial.println("timeSpentInFrame");<br />
  Serial.println(timeSpentInFrame);</p>
<p>}</p>
<p>void photoSensorActivated(){<br />
  rotations ++;<br />
}<br />
</code></p>
<p>I only fully understood the implication of what I just did by looking at the <a href="http://www.thepsychologicaltechnologist.nl/laser-projector-arduino-code/">sourcecode from a similar project</a>. (Michiel, I don&#8217;t know your lastname so I can&#8217;t credit you properly, but thanks for posting your code.) Because the main loop() function was now free from it&#8217;s job of checking the photosensor, I could now use delay() again. I was supposing that I could only draw one pixel per execution of loop() &#8211; and that was true in the version without an interrupt. Now however, I could draw all pixels in one loop(). </p>
<p>I made a quick test and was able to draw a fine pattern of pixels. The image was very unsteady, so I realized I couldn&#8217;t depend on the motor to maintain a constant speed. The Arduino forum had a <a href="http://arduino.cc/forum/index.php/topic,122622.msg923575.html#msg923575">simple algoritm</a> to keep the speed constant:</p>
<p><code><br />
if (rpm  setRpm) {<br />
  motorValue -= 1;<br />
}<br />
motorValue = constrain(motorValue, 0, 255);<br />
analogWrite(transistorPin, motorValue);<br />
</code></p>
<p>Far from perfect, but good enough to continue testing.</p>
]]></content:encoded>
			<wfw:commentRss>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/11/laser-projector-project-part-4-determining-motor-speed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Laser projector project, part 3: assembly</title>
		<link>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/11/laser-projector-project-part-3-assembly/</link>
		<comments>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/11/laser-projector-project-part-3-assembly/#comments</comments>
		<pubDate>Thu, 29 Nov 2012 14:40:58 +0000</pubDate>
		<dc:creator>balcaen.bert@iaac.net</dc:creator>
				<category><![CDATA[Bert Balcaen]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Students]]></category>

		<guid isPermaLink="false">http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/?p=348</guid>
		<description><![CDATA[I assembled the projector using recycled materials. For the motor (12V, round type), I used a lamp holder. The motor didn&#8217;t fit in perfectly, so I added some paper. Not sure if this is bad for ventilation, but the motor doesn&#8217;t get noticeably hot. I screwed the holder onto a block of plywood I found. [...]]]></description>
				<content:encoded><![CDATA[<p>I assembled the projector using recycled materials.</p>
<p><span id="more-348"></span></p>
<p>For the motor (12V, round type), I used a lamp holder. The motor didn&#8217;t fit in perfectly, so I added some paper. Not sure if this is bad for ventilation, but the motor doesn&#8217;t get noticeably hot. I screwed the holder onto a block of plywood I found. </p>
<p>Since I wasn&#8217;t sure if this would be the final circuit, I left everything on breadboard. I used two: one for the photo sensor related things, and another for the all the rest (motor control, pot and laser). I taped the boards and the wire on the wooden block, and screwed the Arduino to it as well. This made it easy to cary everything around.</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/11/DSC_0004.jpg"><img src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/11/DSC_0004-300x198.jpg" alt="" width="300" height="198" class="alignnone size-medium wp-image-349" /></a></p>
<p>The motor I used already had a gear connected to it. I glued a slim piece of leftover acrylic onto it. Next, I glued a wooden hexagonal prism on it. For the mirrors, I used a cheap handheld mirror. I tried different ways of cutting this, but none of them working without breaking the mirror. In most similar projects people just snapped the mirrors into pieces. I also found a project where the mirrors from a disco ball were used. Someone also suggested using mirrored plexiglass and lasercutting that.</p>
<p>I connected the laser and pointed it on the mirrors. I added some tape on the wall, added the first mirror and made a mark on the tape to indicate the position of the laser. This had to be repeated from each mirror, giving each of them a slightly different inclination, with the marks on the wall as a reference. I glue to keep the mirrors in place. Here is how that looks like:</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/11/DSC_0009.jpg"><img src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/11/DSC_0009-300x198.jpg" alt="" width="300" height="198" class="alignnone size-medium wp-image-354" /></a></p>
<p>This took a long while, and because I didn&#8217;t wait long enough for the glue to dry, the mirrors shifted out of place a bit. The result is that some lines are too close together:</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/11/laser_projector_lines.jpg"><img src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/11/laser_projector_lines-300x198.jpg" alt="" width="300" height="198" class="alignnone size-medium wp-image-366" /></a></p>
<p>Later on I found a really nice <a href="http://arduino.cc/forum/index.php/topic,8214.msg65637.html#msg65637">description on how to make such a mirror array</a>. Hot glue seems to be very useful here, since you can heat it up again and correct the alignment of a mirror.</p>
<p>I added a small plastic stick on the platform with the mirrors. The photosensor was mounted under it and sends back lower values when the stick is on top of it.</p>
<p>I was a little disappointed with the brightness. It needs to be pretty dark for the lines to be visible.</p>
]]></content:encoded>
			<wfw:commentRss>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/11/laser-projector-project-part-3-assembly/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Laser projector project, part 2: electronics</title>
		<link>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/11/laser-projector-project-part-2-electronics/</link>
		<comments>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/11/laser-projector-project-part-2-electronics/#comments</comments>
		<pubDate>Thu, 22 Nov 2012 00:22:27 +0000</pubDate>
		<dc:creator>balcaen.bert@iaac.net</dc:creator>
				<category><![CDATA[Bert Balcaen]]></category>
		<category><![CDATA[Physical Computing]]></category>

		<guid isPermaLink="false">http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/?p=208</guid>
		<description><![CDATA[At this point I have all the electronics working. I just had to add the phototransistor by following a tutorial. A quick test showed it works really well. I connected a cardboard disc to the motor, taped a few coins on the bottom side in one place, and put the sensor under the disc. There [...]]]></description>
				<content:encoded><![CDATA[<p>At this point I have all the electronics working. </p>
<p><span id="more-208"></span></p>
<p>I just had to <a href="http://bildr.org/2011/03/various-proximity-sensors-arduino/">add the phototransistor by following a tutorial</a>.  A quick test showed it works really well. I connected a cardboard disc to the motor, taped a few coins on the bottom side in one place, and put the sensor under the disc. There is a very large difference in the values you get back from the sensor when it&#8217;s covered with something and when not.</p>
<p>Here&#8217;s a first attempt at visualizing the schematic with Fritzing:</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/11/laser_projecter_01_bb.png"><img src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/11/laser_projecter_01_bb-300x264.png" alt="" width="300" height="264" class="alignnone size-medium wp-image-240" /></a></p>
<p>Note that for now this includes a pot (to set the motor speed) and no external power (doesn&#8217;t seem necessary for now).</p>
<p>And this is a simple program that will turn on the laser when something is in front of the photo sensor:</p>
<p><code>const int transistorPin = 9;    // connected to the base of the transistor<br />
const int laserPin = 13;    // connected to laser TTL control (white wire on https://www.sparkfun.com/products/8654)</p>
<p> void setup() {</p>
<p>   // set  the transistor pin as output:<br />
   pinMode(transistorPin, OUTPUT);<br />
   // set  the laser TTL pin as output:<br />
   pinMode(laserPin, OUTPUT);</p>
<p>   Serial.begin(9600);</p>
<p> }</p>
<p> void loop() {</p>
<p>   // read the potentiometer:<br />
   int potValue = analogRead(A0);<br />
   // map the sensor value to a range from 0 - 255:<br />
   int outputValue = map(potValue, 0, 1023, 0, 255);<br />
   // use that to control the transistor:<br />
   analogWrite(transistorPin, outputValue);</p>
<p>   int photoSensorVal = analogRead(A1);<br />
   Serial.println(photoSensorVal);<br />
   // turn on laser if something is close to the photosensor<br />
   if(photoSensorVal &lt; 100){<br />
     digitalWrite(laserPin, LOW);<br />
   } else {<br />
     digitalWrite(laserPin, HIGH);<br />
   }</p>
<p> }</code></p>
<p>That&#8217;s actually it for the electronics. This part went easier than expected, thanks to some great tutorials on SparkFun, Bildr, the physical computing wiki from ITP &#8211; and of course Alex&#8217;s great courses.</p>
<p>What&#8217;s next: I have to find a nice design to keep all the parts together. Now everything is literally kept together with tape, which is not very safe. I already sent some mirrors flying around the room. I think I&#8217;ll start with moving the optical sensor related things to a second breadboard and connect it to the other one with some longer wires.</p>
]]></content:encoded>
			<wfw:commentRss>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/11/laser-projector-project-part-2-electronics/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Laser projector project, part 1: references, concept, first tests</title>
		<link>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/11/laser-projector-project-part-1-references-concept-first-tests/</link>
		<comments>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/11/laser-projector-project-part-1-references-concept-first-tests/#comments</comments>
		<pubDate>Wed, 21 Nov 2012 18:29:38 +0000</pubDate>
		<dc:creator>balcaen.bert@iaac.net</dc:creator>
				<category><![CDATA[Bert Balcaen]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Students]]></category>

		<guid isPermaLink="false">http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/?p=164</guid>
		<description><![CDATA[For this project I want to develop a laser projector using rotating mirrors. References Here is a nice example: And this is another good example. Concept A few mirrors are mounted vertically on a spinning disc. A laser is pointed on the mirrors. The mirrors reflect the light. The mirrors are all have a slightly [...]]]></description>
				<content:encoded><![CDATA[<p>For this project I want to develop a laser projector using rotating mirrors. </p>
<p><span id="more-164"></span></p>
<h2>References</h2>
<p>Here is a nice example:</p>
<p><iframe width="730" height="548" src="http://www.youtube.com/embed/w5KdqRwMd1s?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>And this is <a href="http://codinglab.blogspot.com.es/2010/09/diy-laser-projector.html">another good example</a>.</p>
<h2>Concept</h2>
<ul>
<li>A few mirrors are mounted vertically on a spinning disc.</li>
<li>A laser is pointed on the mirrors. The mirrors reflect the light.</li>
<li>The mirrors are all have a slightly different inclination.</li>
<li>When the laser shines light continuously, then each mirror will reflect the light at a slightly different height on the wall. For example: 8 mirrors = 8 lines.</li>
</ul>
<p>That&#8217;s how to draw parallel lines. If we have 6 mirrors and the laser is on continuously, then we get this pattern:</p>
<p>mirror 1: on &#8212;&#8212;<br />
mirror 2: on &#8212;&#8212;<br />
mirror 3: on &#8212;&#8212;<br />
mirror 4: on &#8212;&#8212;<br />
mirror 5: on &#8212;&#8212;<br />
mirror 6: on &#8212;&#8212;</p>
<p>To draw patterns or text the trick is to turn the laser on and off at the right moment. For example, to have only two lines in the middle, we would need to do this:</p>
<p>mirror 1: off<br />
mirror 2: off<br />
mirror 3: on &#8212;&#8212;<br />
mirror 4: on &#8212;&#8212;<br />
mirror 5: off<br />
mirror 6: off</p>
<p>Controlling the speed of the disc with the mirrors is crucial for this. I&#8217;m thinking of using the solution from the video: the disc is white, and one spot has a black marker. An optical sensor detects when the black marker passes in front of it, and like this it&#8217;s possible to find out how many rounds per minute the disc is doing. This is a first shot the algorithm in pseudocode:</p>
<p><code><br />
numMirrors = 8;<br />
mirrorWeWantToHit = 2; // let's say we want to hit mirror 2</p>
<p>timePerMirror = discSpeed / numMirrors; </p>
<p>timeDiff = difference between now and markerLastSeenTime<br />
if(timeDiff &gt; mirrorWeWantToHit * timePerMirror &amp;&amp; timeDiff &gt; (mirrorWeWantToHit + 1) * timePerMirror){<br />
	switch laser on<br />
} else {<br />
	switch laser off<br />
}<br />
</code></p>
<p>At a later point I will also need to define a font map if I want to display text. However, all the examples I saw were using text, and I think it might be interesting to work with more abstract shapes, such as waves and blocks.</p>
<h2>Bill of materials</h2>
<ul>
<li>1 x <a href="https://www.sparkfun.com/products/8654">Laser Module &#8211; Red with TTL Control</a>. It bought this from SparkFun a while ago, but never used it. I&#8217;m not sure why this costs $18.95. Most examples I saw use cheap laserpointers.</li>
<li>1 x <a href="https://www.sparkfun.com/products/246">Optical Detector / Phototransistor &#8211; QRD1114</a> ($1.13). The range of this thing is 0.50 &#8211; 1 cm, so it seems like a good idea to use this.</li>
<li>2 resistors for the phototransistor, one 200-200ohm and one 4.7k – 5.6k ohm</li>
<li>A motor. I have one of these standard toy motors that came with my Arduino starter kit, but I&#8217;m pretty sure these are not powerful enough. I found a bigger, 12V (2.1W) motor laying around here.</li>
<li>An <a href="http://www.irf.com/product-info/datasheets/data/irf520n.pdf">IRF520 MOSFET transistor</a>, for switching high current for the motor.</li>
<li>A diode, also for the motor.</li>
<li>A pot resistor is nice for testing so you can control the speed of the motor easily. But it is not required.</li>
<li>An Arduino. I used an Uno.</li>
<li>An external power supply.</li>
<li>A mirror. I started off with a one I found in a cheap shop (€ 1.50).</li>
<li>Something to put the mirrors on. I&#8217;ll look for something simple to begin with, but it could be nice to have a Processing sketch that creates a 3D object I could print with the Makerbot. I could then easily make different versions of the object, for example one with more mirrors.
</ul>
<h2>First steps</h2>
<p>At this point I know enough about electronics to know that motors need power, but I&#8217;m a little unsure if I should use a transistor or a relay. <a href="http://bildr.org/2011/03/high-power-control-with-arduino-and-tip120/">This tutorial</a> seemed to suggest that a transistor is fine. I started off with building the <a href="http://itp.nyu.edu/physcomp/Tutorials/HighCurrentLoads">circuit to control the motor</a>, which was pretty easy by following the tutorial.</p>
<p>Then I taped a mirror to the motor and <a href="http://www.sparkfun.com/tutorials/260">connected the laser by following the guide from SparkFun</a>. I did a quick test by pointing the laser the rotating mirror.</p>
<p><a href="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/11/2012-11-21-19.33.49.jpg"><img src="http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/files/2012/11/2012-11-21-19.33.49-300x225.jpg" alt="" width="300" height="225" class="alignnone size-medium wp-image-167" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://legacy.iaacblog.com/mai2012-2013-physicalcomputing/2012/11/laser-projector-project-part-1-references-concept-first-tests/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
