<?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>Brains in Jars</title>
	<atom:link href="https://brainsinjars.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://brainsinjars.com</link>
	<description>If it isn&#039;t impossible it isn&#039;t worth doing</description>
	<lastBuildDate>Wed, 11 Jul 2018 05:53:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.8</generator>

<image>
	<url>https://cdn.brainsinjars.com/wp-content/uploads/2016/07/cropped-brain-black-transparent-512x512-32x32.png</url>
	<title>Brains in Jars</title>
	<link>https://brainsinjars.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Linear Motion from a Rotary Actuator</title>
		<link>https://brainsinjars.com/archives/2013/06/linear-motion-from-a-rotary-actuator/</link>
		<comments>https://brainsinjars.com/archives/2013/06/linear-motion-from-a-rotary-actuator/#comments</comments>
		<pubDate>Mon, 10 Jun 2013 23:44:45 +0000</pubDate>
		<dc:creator><![CDATA[Kevin Loney]]></dc:creator>
				<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://brainsinjars.com/?p=851</guid>
		<description><![CDATA[<p>This is part of a project I have been playing with on and off for the last 9 months. It is similar in concept to a reverse geocaching box but with cooler locking mechanism. I have always appreciated the giant vault door bolt mechanisms and figured designing a laser cut version controlled by a servo [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://brainsinjars.com/archives/2013/06/linear-motion-from-a-rotary-actuator/">Linear Motion from a Rotary Actuator</a> appeared first on <a rel="nofollow" href="https://brainsinjars.com">Brains in Jars</a>.</p>
]]></description>
				<content:encoded><![CDATA[<figure style="width: 500px" class="wp-caption alignnone"><a title="Locked State by EasyAs314159, on Flickr" href="http://www.flickr.com/photos/easyas314159/8965843015/"><img alt="Locked State" src="http://farm3.staticflickr.com/2852/8965843015_9baa83d29b.jpg" width="500" height="375" /></a><figcaption class="wp-caption-text">Box lid prototype in the locked state</figcaption></figure>
<p>This is part of a project I have been playing with on and off for the last 9 months. It is similar in concept to a reverse geocaching box but with cooler locking mechanism. I have always appreciated the giant vault door bolt mechanisms and figured designing a laser cut version controlled by a servo would be an interesting learning exercise.</p>
<p>To accomplish the desired effect I had to solve a fairly simple geometry problem for the linkage mechanism. I figured this might be of use to someone else or my future self so I will walk through the derivation of the basic equations for finding functional linkage lengths.</p>
<p><span id="more-851"></span></p>
<h2>The Setup</h2>
<figure id="attachment_854" style="width: 1362px" class="wp-caption aligncenter"><a href="http://brainsinjars.com/wp-content/uploads/2013/06/actuation.png"><img class="size-full wp-image-854" alt="Linear actuation" src="http://brainsinjars.com/wp-content/uploads/2013/06/actuation.png" width="1362" height="546" /></a><figcaption class="wp-caption-text">Rotary to linear actuation geometry</figcaption></figure>
<p>This problem has 5 variables:</p>
<ul>
<li><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-6affe041739f78a044af6d3f56d6b659_l3.png" class="ql-img-inline-formula " alt="&#76;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="16" width="18" style="vertical-align: -4px;"/> &#8211; Length of the linkage when fully extended</li>
<li><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-84db227018e3228ebc26b639aa94bbd0_l3.png" class="ql-img-inline-formula " alt="&#76;&#95;&#50;" title="Rendered by QuickLaTeX.com" height="15" width="19" style="vertical-align: -3px;"/> &#8211; Length of the linkage when fully retracted</li>
<li><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-25b206f25506e6d6f46be832f7119ffa_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="12" width="13" style="vertical-align: 0px;"/> &#8211; Length of the linkage attached to the rotary actuator</li>
<li><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-770fd1447ccf2fc229801b486b0d8f8a_l3.png" class="ql-img-inline-formula " alt="&#66;" title="Rendered by QuickLaTeX.com" height="12" width="14" style="vertical-align: 0px;"/> &#8211; Length of the linkage attached to the bolt</li>
<li><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-18a8bd1009efb383e4e078de909a928c_l3.png" class="ql-img-inline-formula " alt="&#92;&#84;&#104;&#101;&#116;&#97;" title="Rendered by QuickLaTeX.com" height="12" width="13" style="vertical-align: 0px;"/> &#8211; The number of degrees of rotation required to fully retract the bolt</li>
</ul>
<h2>To the Mathing!</h2>
<p>I am going to start by assuming that <img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-25b206f25506e6d6f46be832f7119ffa_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="12" width="13" style="vertical-align: 0px;"/> and <img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-770fd1447ccf2fc229801b486b0d8f8a_l3.png" class="ql-img-inline-formula " alt="&#66;" title="Rendered by QuickLaTeX.com" height="12" width="14" style="vertical-align: 0px;"/> are the two unknowns as it simplifies the process dramatically. This is followed by a fairly straight forward application of the <a title="Law of Cosines" href="http://en.wikipedia.org/wiki/Law_of_cosines">Law of Cosines</a> which solves the problem nicely with a bit of manipulation:</p>
<p class="ql-center-displayed-equation" style="line-height: 21px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-9697c0c08bc833b3edd53caff42dbb73_l3.png" height="21" width="209" class="ql-img-displayed-equation " alt="&#92;&#091;&#66;&#94;&#50;&#32;&#61;&#32;&#65;&#94;&#50;&#32;&#43;&#32;&#76;&#95;&#50;&#94;&#50;&#32;&#45;&#32;&#50;&#32;&#65;&#32;&#76;&#95;&#49;&#32;&#99;&#111;&#115;&#92;&#84;&#104;&#101;&#116;&#97;&#92;&#093;" title="Rendered by QuickLaTeX.com"/></p>
<p>Solving for two variables is hard so since <img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-5614d9c6dbe1709ca55b0ce2dc4628f9_l3.png" class="ql-img-inline-formula " alt="&#76;&#95;&#49;&#32;&#61;&#32;&#65;&#32;&#43;&#32;&#66;" title="Rendered by QuickLaTeX.com" height="16" width="92" style="vertical-align: -4px;"/> we can substitute in so we only have to solve one variable:</p>
<p class="ql-center-displayed-equation" style="line-height: 21px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-254d8a5e312350ba38dc8e801c082d42_l3.png" height="21" width="263" class="ql-img-displayed-equation " alt="&#92;&#091;&#40;&#76;&#95;&#49;&#32;&#45;&#32;&#65;&#41;&#94;&#50;&#32;&#61;&#32;&#65;&#94;&#50;&#32;&#43;&#32;&#76;&#95;&#50;&#94;&#50;&#32;&#45;&#32;&#50;&#32;&#65;&#32;&#76;&#95;&#50;&#32;&#99;&#111;&#115;&#92;&#84;&#104;&#101;&#116;&#97;&#92;&#093;" title="Rendered by QuickLaTeX.com"/></p>
<p>Expand the polynomial:</p>
<p class="ql-center-displayed-equation" style="line-height: 22px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-0520c46fbf146ad444fcf1461423d9c3_l3.png" height="22" width="313" class="ql-img-displayed-equation " alt="&#92;&#091;&#76;&#95;&#49;&#94;&#50;&#32;&#45;&#32;&#50;&#32;&#65;&#32;&#76;&#95;&#49;&#32;&#43;&#32;&#65;&#94;&#50;&#32;&#61;&#32;&#65;&#94;&#50;&#32;&#43;&#32;&#76;&#95;&#50;&#94;&#50;&#32;&#45;&#32;&#50;&#32;&#65;&#32;&#76;&#95;&#50;&#32;&#99;&#111;&#115;&#92;&#84;&#104;&#101;&#116;&#97;&#92;&#093;" title="Rendered by QuickLaTeX.com"/></p>
<p>Cancel out the <img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-8b49aeb7162689d03dd9f9470a2ae1a6_l3.png" class="ql-img-inline-formula " alt="&#65;&#94;&#50;" title="Rendered by QuickLaTeX.com" height="15" width="20" style="vertical-align: 0px;"/> on both sides:</p>
<p class="ql-center-displayed-equation" style="line-height: 22px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-9deec9e45cf5320b1a2be9de45ad76a1_l3.png" height="22" width="228" class="ql-img-displayed-equation " alt="&#92;&#091;&#76;&#95;&#49;&#94;&#50;&#32;&#45;&#32;&#50;&#32;&#65;&#32;&#76;&#95;&#49;&#32;&#61;&#32;&#76;&#95;&#50;&#94;&#50;&#32;&#45;&#32;&#50;&#32;&#65;&#32;&#76;&#95;&#50;&#32;&#99;&#111;&#115;&#92;&#84;&#104;&#101;&#116;&#97;&#92;&#093;" title="Rendered by QuickLaTeX.com"/></p>
<p>Move the constants to the left and all of the <img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-25b206f25506e6d6f46be832f7119ffa_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="12" width="13" style="vertical-align: 0px;"/> terms to the right:</p>
<p class="ql-center-displayed-equation" style="line-height: 22px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-4809567ac3783c8247c56ea7e5c9d976_l3.png" height="22" width="228" class="ql-img-displayed-equation " alt="&#92;&#091;&#76;&#95;&#49;&#94;&#50;&#32;&#45;&#32;&#76;&#95;&#50;&#94;&#50;&#32;&#61;&#32;&#50;&#32;&#65;&#32;&#76;&#95;&#49;&#32;&#45;&#32;&#50;&#32;&#65;&#32;&#76;&#95;&#50;&#32;&#99;&#111;&#115;&#92;&#84;&#104;&#101;&#116;&#97;&#92;&#093;" title="Rendered by QuickLaTeX.com"/></p>
<p>Factor:</p>
<p class="ql-center-displayed-equation" style="line-height: 22px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-e1c1ffbc7342354fd1a14904467cb353_l3.png" height="22" width="220" class="ql-img-displayed-equation " alt="&#92;&#091;&#76;&#95;&#49;&#94;&#50;&#32;&#45;&#32;&#76;&#95;&#50;&#94;&#50;&#32;&#61;&#32;&#50;&#32;&#65;&#32;&#40;&#76;&#95;&#49;&#32;&#45;&#32;&#76;&#95;&#50;&#32;&#99;&#111;&#115;&#92;&#84;&#104;&#101;&#116;&#97;&#41;&#92;&#093;" title="Rendered by QuickLaTeX.com"/></p>
<p>Dive through by <img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-62449dfb96d65550ae9a5415e6ac7d3d_l3.png" class="ql-img-inline-formula " alt="&#50;&#32;&#40;&#76;&#95;&#49;&#32;&#45;&#32;&#76;&#95;&#50;&#32;&#99;&#111;&#115;&#92;&#84;&#104;&#101;&#116;&#97;&#41;" title="Rendered by QuickLaTeX.com" height="18" width="122" style="vertical-align: -4px;"/> so we are left with <img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-25b206f25506e6d6f46be832f7119ffa_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="12" width="13" style="vertical-align: 0px;"/>:</p>
<p class="ql-center-displayed-equation" style="line-height: 43px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-002d507325f275a8743ac743380b100c_l3.png" height="43" width="165" class="ql-img-displayed-equation " alt="&#92;&#091;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#76;&#95;&#49;&#94;&#50;&#32;&#45;&#32;&#76;&#95;&#50;&#94;&#50;&#125;&#123;&#40;&#76;&#95;&#49;&#32;&#45;&#32;&#76;&#95;&#50;&#32;&#99;&#111;&#115;&#92;&#84;&#104;&#101;&#116;&#97;&#41;&#125;&#32;&#61;&#32;&#65;&#92;&#093;" title="Rendered by QuickLaTeX.com"/></p>
<h2>End Result</h2>
<figure id="attachment_887" style="width: 1310px" class="wp-caption aligncenter"><a href="http://brainsinjars.com/wp-content/uploads/2013/06/Linkage-example.jpg"><img class="size-full wp-image-887" alt="How theta effects linkage lengths A (Blue), and B (Red) for L1=100, and L2=75" src="http://brainsinjars.com/wp-content/uploads/2013/06/Linkage-example.jpg" width="1310" height="694" /></a><figcaption class="wp-caption-text">How <img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-f0984ee218bc1d3d344f0979747197a3_l3.png" class="ql-img-inline-formula " alt="&#84;&#104;&#101;&#116;&#97;" title="Rendered by QuickLaTeX.com" height="13" width="46" style="vertical-align: 0px;"/> effects linkage lengths <img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-25b206f25506e6d6f46be832f7119ffa_l3.png" class="ql-img-inline-formula " alt="&#65;" title="Rendered by QuickLaTeX.com" height="12" width="13" style="vertical-align: 0px;"/> (Blue) and <img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-770fd1447ccf2fc229801b486b0d8f8a_l3.png" class="ql-img-inline-formula " alt="&#66;" title="Rendered by QuickLaTeX.com" height="12" width="14" style="vertical-align: 0px;"/> (Red) for <img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-dc3bf95d6faa58189cc69987e0c091c5_l3.png" class="ql-img-inline-formula " alt="&#76;&#95;&#49;&#32;&#61;&#32;&#49;&#48;&#48;" title="Rendered by QuickLaTeX.com" height="16" width="70" style="vertical-align: -4px;"/>, and <img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-79f95a76fa2f33a934551f90575343e8_l3.png" class="ql-img-inline-formula " alt="&#76;&#95;&#50;&#32;&#61;&#32;&#55;&#53;" title="Rendered by QuickLaTeX.com" height="16" width="60" style="vertical-align: -3px;"/></figcaption></figure>
<p>Tidying it up and bringing all of the variables over to the left hand side we are left with:</p>
<p class="ql-center-displayed-equation" style="line-height: 15px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-f3bd65c01652fc6843d10e74c0f8a184_l3.png" height="15" width="63" class="ql-img-displayed-equation " alt="&#92;&#091;&#76;&#95;&#49;&#32;&#62;&#32;&#76;&#95;&#50;&#92;&#093;" title="Rendered by QuickLaTeX.com"/></p>
<p class="ql-center-displayed-equation" style="line-height: 43px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-108e82073bc0c024642714bec3839d22_l3.png" height="43" width="166" class="ql-img-displayed-equation " alt="&#92;&#091;&#65;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#76;&#95;&#49;&#94;&#50;&#32;&#45;&#32;&#76;&#95;&#50;&#94;&#50;&#125;&#123;&#40;&#76;&#95;&#49;&#32;&#45;&#32;&#76;&#95;&#50;&#32;&#99;&#111;&#115;&#92;&#84;&#104;&#101;&#116;&#97;&#41;&#125;&#92;&#093;" title="Rendered by QuickLaTeX.com"/></p>
<p class="ql-center-displayed-equation" style="line-height: 15px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="https://cdn.brainsinjars.com/wp-content/ql-cache/quicklatex.com-79eb03351949744e8696a0862c658774_l3.png" height="15" width="93" class="ql-img-displayed-equation " alt="&#92;&#091;&#66;&#32;&#61;&#32;&#76;&#95;&#49;&#32;&#45;&#32;&#65;&#92;&#093;" title="Rendered by QuickLaTeX.com"/></p>
<figure style="width: 500px" class="wp-caption alignnone"><a title="Unlocked State" href="http://www.flickr.com/photos/easyas314159/8965840759/"><img alt="Unlocked State" src="http://farm6.staticflickr.com/5347/8965840759_31310f1131.jpg" width="500" height="375" /></a><figcaption class="wp-caption-text">Box lid prototype in the unlocked state</figcaption></figure>
<p>I am hoping to have the full build for the box done by September and will be posting full build details and schematics.</p>
<p>The post <a rel="nofollow" href="https://brainsinjars.com/archives/2013/06/linear-motion-from-a-rotary-actuator/">Linear Motion from a Rotary Actuator</a> appeared first on <a rel="nofollow" href="https://brainsinjars.com">Brains in Jars</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://brainsinjars.com/archives/2013/06/linear-motion-from-a-rotary-actuator/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Build Log: Helicopter on an LCD</title>
		<link>https://brainsinjars.com/archives/2013/03/build-log-helicopter-on-an-lcd/</link>
		<comments>https://brainsinjars.com/archives/2013/03/build-log-helicopter-on-an-lcd/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 14:00:41 +0000</pubDate>
		<dc:creator><![CDATA[Kevin Loney]]></dc:creator>
				<category><![CDATA[Build Log]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Making/Hacking]]></category>
		<category><![CDATA[arduino]]></category>

		<guid isPermaLink="false">http://brainsinjars.com/?p=804</guid>
		<description><![CDATA[<p>This was a fun little LCD project I spent an afternoon putting together. It&#8217;s based on a whole family of single button obstacle avoidance games. In short you move your helicopter up and down to avoid obstacles, scoring points for the distance travelled before inevitably crashing. Hardware The components of the hardware build are pretty [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://brainsinjars.com/archives/2013/03/build-log-helicopter-on-an-lcd/">Build Log: Helicopter on an LCD</a> appeared first on <a rel="nofollow" href="https://brainsinjars.com">Brains in Jars</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p style="text-align: center;"><iframe width="980" height="551" src="https://www.youtube.com/embed/Lmb0OcObO5A?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>This was a fun little LCD project I spent an afternoon putting together. It&#8217;s based on a whole family of single button obstacle avoidance games. In short you move your helicopter up and down to avoid obstacles, scoring points for the distance travelled before inevitably crashing.</p>
<p><span id="more-804"></span></p>
<h2>Hardware</h2>
<figure id="attachment_809" style="width: 617px" class="wp-caption aligncenter"><a href="http://brainsinjars.com/wp-content/uploads/2013/02/helicopter-schematic.png"><img class="size-full wp-image-809" title="Helicopter schematic" alt="Helicopter schematic" src="http://brainsinjars.com/wp-content/uploads/2013/02/helicopter-schematic.png" width="617" height="579" /></a><figcaption class="wp-caption-text">Helicopter schematic</figcaption></figure>
<p>The components of the hardware build are pretty straight forward:</p>
<ul>
<li><span style="line-height: 13px;">S1 &amp; R3 make up the games input and are tied to interrupt 0 (D2) on the Arduino. The sketch has some code for forcing a frame update when the button state changes, and a mediocre button debouncing.</span></li>
<li>R1, R2 &amp; T1 give the sketch control over the displays back light. I didn&#8217;t have it implemented when I took the video but the display now flashes on and off dramatically when you crash.</li>
<li>R4 is the screens mandatory contrast adjust</li>
</ul>
<h2>Software</h2>
<p>The software is a little less straight forward and consumed the vast majority of the build time. Most of the work focused on optimizing how fast I could push data to the screen using the built in LiquidCrystal library. Some of the highlights:</p>
<ul>
<li><span style="line-height: 13px;">%99.9 <em>delay</em>() free, all the timing in the sketch is done using <em>millis</em>() because it is non-blocking and good practice. The only delay in the sketch is used to help seed the random number generator with noise from analog 0 (A0).</span></li>
<li>All the animated game sprites are done by cycling through a set of custom characters. After doing the video I updated all of the game sprite to look like buildings and birds/airplanes (if you use you imagination a bit).</li>
<li>Collision detection and game state is done using bitwise operations on 2 unsigned 16-bit integers. I also use these two variables to ensure that the game never produces an impassable wall the player has no choice but to crash into.</li>
<li>High scores are stored in the Arduino&#8217;s EEPROM and use a very simple checksum to make sure the score is actually from the helicopter game.</li>
<li>The game gets faster and harder the longer you play.</li>
</ul>
<h2>Sketch &amp; Schematics</h2>
<p>If anyone is interested in doing their own version I have included the Eagle schematic and Arduino sketch: <a href="http://brainsinjars.com/wp-content/uploads/2013/03/helicopter.zip">Eagle schematic &amp; Arduino sketch</a></p>
<p><a href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US" rel="license"><img style="border-width: 0;" alt="Creative Commons License" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png" /></a><br />
This <span>work</span> is licensed under a <a href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US" rel="license">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</p>
<p>The post <a rel="nofollow" href="https://brainsinjars.com/archives/2013/03/build-log-helicopter-on-an-lcd/">Build Log: Helicopter on an LCD</a> appeared first on <a rel="nofollow" href="https://brainsinjars.com">Brains in Jars</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://brainsinjars.com/archives/2013/03/build-log-helicopter-on-an-lcd/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Build Log: Shaken Granular Laser</title>
		<link>https://brainsinjars.com/archives/2012/09/build-log-shaken-granular-laser/</link>
		<comments>https://brainsinjars.com/archives/2012/09/build-log-shaken-granular-laser/#comments</comments>
		<pubDate>Tue, 18 Sep 2012 21:02:35 +0000</pubDate>
		<dc:creator><![CDATA[Kevin Loney]]></dc:creator>
				<category><![CDATA[Build Log]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Making/Hacking]]></category>
		<category><![CDATA[Physics]]></category>
		<category><![CDATA[laser]]></category>
		<category><![CDATA[maker faire yyc]]></category>

		<guid isPermaLink="false">http://brainsinjars.com/?p=715</guid>
		<description><![CDATA[<p>Update: Someone translated this post to Russian. Update: I have confirmed that the output is still well within the spontaneous emission range and I am doubtful I can build an exciter with enough power. The paper uses a 532 nm Nd:YAG laser with a 7ns pulse duration and samples were performed at energies of 1.6mJ [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://brainsinjars.com/archives/2012/09/build-log-shaken-granular-laser/">Build Log: Shaken Granular Laser</a> appeared first on <a rel="nofollow" href="https://brainsinjars.com">Brains in Jars</a>.</p>
]]></description>
				<content:encoded><![CDATA[<figure style="width: 500px" class="wp-caption aligncenter"><a href="http://www.flickr.com/photos/easyas314159/7994128160/"><img title="Completed enclosures" alt="" src="http://farm9.staticflickr.com/8180/7994128160_efd32232f9.jpg" width="500" height="375" /></a><figcaption class="wp-caption-text">Completed enclosures</figcaption></figure>
<p><strong>Update:</strong> Someone translated this post to <a href="http://habrahabr.ru/post/151840/">Russian</a>.</p>
<p><strong>Update:</strong> I have confirmed that the output is still well within the spontaneous emission range and I am doubtful I can build an exciter with enough power. The paper uses a 532 nm Nd:YAG laser with a 7ns pulse duration and samples were performed at energies of 1.6mJ and 3.7mJ. This means that their source had an approximate power output between 229kW and 529kW.</p>
<p>There was an interesting article a while back over at new scientist describing <a title="Shaking metallic grains turns them into tunable laser" href="http://www.newscientist.com/article/mg21428712.000-shaking-metallic-grains-turns-them-into-tunable-laser.html" target="_blank">research into a laser with a tunable output wavelength</a>, after tracking down the <a title="Shaken Granular Lasers" href="http://arxiv.org/abs/1205.5977" target="_blank">original paper</a> over at arXiv.org and looking at there experimental setup the I decided the device should be pretty straight forward to build.</p>
<p>The principal behind the design is you suspend a bunch of reflective balls in a laser dye and shake them really fast so the balls behave as though they are suspended. The laser dye is then excited by an external source and by changing the vibration frequency you can filter out different wavelengths of laser light emitted by the dye.</p>
<p><span id="more-715"></span></p>
<p>The overall design only requires six components to build:</p>
<ul>
<li>A laser dye, in this case <a title="Rhodamine B" href="http://en.wikipedia.org/wiki/Rhodamine_B" target="_blank">Rhodamine B</a></li>
<li>Lots of small ball bearings</li>
<li>A small glass container to hold the ball bearings and laser dye</li>
<li>A speaker to serve as the source of vibrational energy</li>
<li>A laser to excite the dye</li>
<li>An adjustable frequency generator</li>
</ul>
<h3>Laser module &amp; exciter</h3>
<figure style="width: 500px" class="wp-caption aligncenter"><a href="http://www.flickr.com/photos/easyas314159/7994127357/"><img class=" " title="Laser module display samples" alt="Laser module display samples" src="http://farm9.staticflickr.com/8304/7994127357_cbd91fe76e.jpg" width="500" height="375" /></a><figcaption class="wp-caption-text">Laser modules display samples, left to right: Rhodamine B 0.1mol/L, 0.01mol/L, 0.001mol/L, and 1750 1mm steel ball bearings.</figcaption></figure>
<p>The <a href="http://www.vxb.com/page/bearings/PROD/BearingBalls/Kit12057" target="_blank">ball bearings</a> and <a href="http://www.amazonsupply.com/dp/B003HC8QSG" target="_blank">borosilicate sample vials</a> were the easiest parts to source however the Rhodamine B was a little more challenging. A fellow Protospace member was kind enough to prepare three different solutions of Rhodamine B in methanol for me: 0.001mol/L, 0.01mol/L, and 0.1mol/L. After cleaning the oil off the ball bearings with acetone and letting them dry it was then just a matter of adding the ball bearings to the vial and then filling them with Rhodamine B.</p>
<figure style="width: 500px" class="wp-caption aligncenter"><a title="Untitled by EasyAs314159, on Flickr" href="http://www.flickr.com/photos/easyas314159/7994132895/"><img title="Rhodamine B lasing" alt="" src="http://farm9.staticflickr.com/8444/7994132895_876ac6e2c3.jpg" width="500" height="375" /></a><figcaption class="wp-caption-text">Rhodamine B lasing</figcaption></figure>
<p>The next step was to find a suitable pump source, something powerful enough to push the Rhodamine past it&#8217;s lasing threshold. I ended up settling on a <a href="http://www.dealextreme.com/p/30mw-532nm-green-laser-module-3v-11-9mm-26888" target="_blank">30mW 532nm source</a> and decided not to go higher because of safety concerns about to taking it to Maker Faire YYC and not damaging anyone&#8217;s eyes. I&#8217;m still trying to figure out if that was enough to successfully pass the dyes lasing threshold or if the yellow light being produced by the Rhodamine is in fact spontaneous instead of stimulated emission.</p>
<figure style="width: 500px" class="wp-caption aligncenter"><a href="http://www.flickr.com/photos/easyas314159/7994137754/"><img alt="" src="http://farm9.staticflickr.com/8032/7994137754_0917a20865.jpg" width="500" height="375" /></a><figcaption class="wp-caption-text">Spontaneous or stimulated emmission?</figcaption></figure>
<h3>Speaker mount</h3>
<p>Initially I was going to just glue the module mount directly to the speaker. However after I successfully destroying the first speaker I was going to use by epoxying the voice coil to the magnet I settled on a more modular design that would let me swap laser modules out more easily.</p>
<p>The final design had a small rare earth magnet mounted to the voice coil of the speaker and I attached a small metal washer to the bottom of the module mount. You can see the magnet mount between the speaker and the module mount in picture. I also made sure there was enough space between the magnet and the vial to make sure the ball bearings would not clump together.</p>
<figure style="width: 500px" class="wp-caption aligncenter"><a href="http://www.flickr.com/photos/easyas314159/7994125918/"><img title="Exciter and laser module close up" alt="" src="http://farm9.staticflickr.com/8036/7994125918_543e65db90.jpg" width="500" height="375" /></a><figcaption class="wp-caption-text">Exciter and laser module close up</figcaption></figure>
<p>In an effort to replicate the source paper as accurately as possible I included an accelerometer to measure the intensity of the vibrations. I ended up using an old <a title="Sparkfun: IMU 6DOF Razor - Ultra-Thin IMU" href="https://www.sparkfun.com/products/9431" target="_blank">6DOF Razor IMU</a> I had around from another project (which has since been replace by a <a title="Sparkfun: IMU Digital Combo Board - 6 Degrees of Freedom ITG3200/ADXL345" href="https://www.sparkfun.com/products/10121" target="_blank">newer more compact model</a>), five of those degrees of freedom are completely unnecessary.</p>
<h3>Function generator</h3>
<figure style="width: 500px" class="wp-caption aligncenter"><a title="Electronics and module mount by EasyAs314159, on Flickr" href="http://www.flickr.com/photos/easyas314159/7977136436/"><img title="Laser control circuitry" alt="" src="http://farm9.staticflickr.com/8038/7977136436_ebd5d86842.jpg" width="500" height="375" /></a><figcaption class="wp-caption-text">XR2206 function generator and LM386 audio amplifier circuitry</figcaption></figure>
<p>I built the function generator around <a title="JAMECO: XR2206CP" href="https://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&amp;storeId=10001&amp;catalogId=10001&amp;productId=34972" target="_blank">EXAR&#8217;s XR2206 monolithic function generator</a> with the circuit being identical to the one presented in the chips datasheet. Most of the work here involved choosing an appropriate timing resistor and capacitor to get the frequency range I wanted with the parts I had on hand. The end result was a fairly simple circuit capable of outputting both sine and triangle waves with a frequency range of ~35-45Hz.</p>
<p>The output of the function generator is then fed into 1:1 audio transformer to make the output signal relative to circuit ground instead of my virtual ground and then passed into a LM386 audio amplifier in the simplest 20dB of gain configuration.</p>
<p>I did encounter one issue with the XR2206 sensitivity to temperature changes. While outside at Maker Faire YYC in direct sunlight the frequency drifted up 15Hz over the course of 2 hours.</p>
<h3>Maker Faire YYC</h3>
<p>To take it to <a href="http://makerfaireyyc.ca">Maker Faire YYC</a> I really wanted the whole thing to be interactive instead of just a fixed display. I ended up laser cutting some nice acrylic enclosures with controls for wave select (sine or triangle), amplitude adjust, and frequency adjust. This was great because it allowed my to demonstrate how frequency and amplitude effected the motion of the ball bearings in the liquid.</p>
<p>Faby Martin took a whole bunch of <a href="http://fabymartin.com/2012/09/makerfaireyyc/">pictures of the event</a> here including several of my laser and me giving the general public a very hand wavy introduction to basic laser physics.</p>
<h3>Further experiments</h3>
<p>I am putting this on the shelf for a while due to a bit of project burnout leading up to Make Faire. I have a whole slew of experiments I still want to perform and improvments I would like to make.</p>
<p>First I want upgrade to a more powerful pump laser, something in the 200mW or even 1W range so that I can be absolutely sure I have passed the lasing threshold of the Rhodamine. At this point I&#8217;ll be sticking the whole unit in a closed box so I can&#8217;t see it while I am running the  experiments so I don&#8217;t bake my eyes.</p>
<p>I also want to get my hands on a proper spectrometer so I can properly monitor the light output and better &#8220;see&#8221; the wavelength shift described in the original paper. I suspect I may also need to invest in an accelerometer with a higher tolerance, the peak acceleration of the speaker cone is somewhere in the magnitude of 30g.</p>
<p>A properly fabricated PCB for the control circuitry would be really nice, I have run into the typical breadboard issues where wires come loose or there is excessive signal noise. Once I have those issues sorted out and my basic experiments complete to have both the laser module and control circuitry mounted in the same case would be nice.</p>
<p>The post <a rel="nofollow" href="https://brainsinjars.com/archives/2012/09/build-log-shaken-granular-laser/">Build Log: Shaken Granular Laser</a> appeared first on <a rel="nofollow" href="https://brainsinjars.com">Brains in Jars</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://brainsinjars.com/archives/2012/09/build-log-shaken-granular-laser/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Selecting Random Items in Amazon SimpleDB</title>
		<link>https://brainsinjars.com/archives/2011/08/selecting-a-random-item-in-amazon-simpledb/</link>
		<comments>https://brainsinjars.com/archives/2011/08/selecting-a-random-item-in-amazon-simpledb/#comments</comments>
		<pubDate>Sat, 06 Aug 2011 17:52:13 +0000</pubDate>
		<dc:creator><![CDATA[Kevin Loney]]></dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[simpledb]]></category>

		<guid isPermaLink="false">http://brainsinjars.com/?p=388</guid>
		<description><![CDATA[<p>I am in the middle of working on a project that relies heavily on the ability to select random items from an Amazon Web Services SimpleDB domain. A little bit of google-fu turned up an answer to a post over at Stack Overflow which described Amazons recommended approach. A really rough psuedo-code implementation looks like [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://brainsinjars.com/archives/2011/08/selecting-a-random-item-in-amazon-simpledb/">Selecting Random Items in Amazon SimpleDB</a> appeared first on <a rel="nofollow" href="https://brainsinjars.com">Brains in Jars</a>.</p>
]]></description>
				<content:encoded><![CDATA[I am in the middle of working on a project that relies heavily on the ability to select random items from an Amazon Web Services SimpleDB domain. A little bit of google-fu turned up an <a title="Selecting a random result from Simple Database (SDB) on AWS" href="http://stackoverflow.com/questions/2070168/selecting-a-random-result-from-simple-database-sdb-on-aws/2179382#2179382" target="_blank">answer to a post</a> over at Stack Overflow which described Amazons recommended approach. A really rough psuedo-code implementation looks like this:

<figure><pre class="prettyprint">Item selectRandomItem() {
// Generate a random value
String randomValue = generateRandomString();

// Retrieve the data from SDB
Item item = randomLE(randomValue);
if(item == null) {
// Handle the edge case where there are no items
// with randomizers less than the random value
item = randomGE();
}
return item;
}

Item randomLE(String randomValue) {
return sdb.select(
"select * " +
"from MyStore " +
"where randomizer &lt;= '" + randomValue + "'" +
"order by randomizer desc " +
"limit 1"
);
}
Item randomGE(String randomValue) {
return sdb.select(
"select * " +
"from MyStore " +
"where randomizer &gt;= '" + randomValue + "'" +
"order by randomizer asc " +
"limit 1"
);
}</pre></figure>

The algorithm stores a randomizer field with a random value on all of the items; when you need a row, generate another random value and select the first item whose randomizer attribute is less than this new random value. Unfortunately this approach is broken.
<span id="more-388"></span>
<h1>Why This Approach is Broken</h1>
The selection probability in the above algorithm is non-uniform, in fact it behaves like a <a title="Fitness proportionate selection" href="http://en.wikipedia.org/wiki/Roulette_wheel_selection" target="_blank">roulette wheel selection</a> were the item&#8217;s weight is proportional to the distance to the next highest randomizer. For a quick demonstration lets say we have 3 items and that all our random numbers are integers in the range of 1 to 10, we could possibly end up with the following state:


<table id="wp-table-reloaded-id-2-no-1" class="wp-table-reloaded wp-table-reloaded-id-2">
<thead>
	<tr class="row-1 odd">
		<th class="column-1">Item</th><th class="column-2">Randomizer</th><th class="column-3">Selected On</th><th class="column-4">Probability</th>
	</tr>
</thead>
<tbody>
	<tr class="row-2 even">
		<td class="column-1">1</td><td class="column-2">3</td><td class="column-3">1,2,3,4,5,6</td><td class="column-4">.6 (60%)</td>
	</tr>
	<tr class="row-3 odd">
		<td class="column-1">2</td><td class="column-2">7</td><td class="column-3">7,8,9</td><td class="column-4">.3 (30%)</td>
	</tr>
	<tr class="row-4 even">
		<td class="column-1">3</td><td class="column-2">10</td><td class="column-3">10</td><td class="column-4">.1 (10%)</td>
	</tr>
</tbody>
</table>


The selected on column shows a list of the randoms values for which that item is selected and you can see from the probability column that the distribution is far from uniform. Depending on our requirements this might be fine but lets see if the algorithm can&#8217;t be tuned a bit to produce more uniform results.
<h1>The Coin Toss</h1>
Instead of always selecting an item whose randomizer is less or equal to some random value alternate randomly between less or equal and greater or equal. The new code looks something like this:

<figure><pre class="prettyprint">Item selectRandomItem() {
Item item = null;

// Generate some randomness
Random randomStream = new Random();
String randomValue = generateRandomString();

if(randomStream.nextBoolean()) {
// Retrieve the data from SDB
item = randomLE(randomValue);
if(item == null) {
// Handle the edge case where there are no items
// with randomizers less than the random value
item = randomGE(randomValue);
}
}
else {
// Retrieve the data from SDB
item = randomGE();
if(item == null) {
// Handle the edge case where there are no items
// with randomizers greater than the random value
item = randomLE(randomValue);
}
}
return item;
}</pre></figure>

Reusing the same example from above with 3 items the selection probability now looks like this:


<table id="wp-table-reloaded-id-3-no-1" class="wp-table-reloaded wp-table-reloaded-id-3">
<thead>
	<tr class="row-1 odd">
		<th class="column-1">Item</th><th class="column-2">Randomizer</th><th class="column-3">Greater or Equal</th><th class="column-4">Less or Equal</th><th class="column-5">Probability</th>
	</tr>
</thead>
<tbody>
	<tr class="row-2 even">
		<td class="column-1">1</td><td class="column-2">3</td><td class="column-3">1,2,3</td><td class="column-4">1,2,3,4,5,6</td><td class="column-5">.45 (45%)</td>
	</tr>
	<tr class="row-3 odd">
		<td class="column-1">2</td><td class="column-2">7</td><td class="column-3">4,5,6,7</td><td class="column-4">7,8,9</td><td class="column-5">.35 (35%)</td>
	</tr>
	<tr class="row-4 even">
		<td class="column-1">3</td><td class="column-2">10</td><td class="column-3">8,9,10</td><td class="column-4">10</td><td class="column-5">.20 (20%)</td>
	</tr>
</tbody>
</table>


This is still not uniform however it is significantly better and there is still one more thing we can add.
<h1>Using a Dynamic Randomizer</h1>
In order to achieve that nice uniform distribution requires adding something that changes uniformly. The easiest way to do this is to change an items randomizer attribute every time it is selected so it&#8217;s future probability of selection is no longer constant.

<figure><pre class="prettyprint">// Select a random item using the coin toss approach
Item item = selectRandomItem();

// Generate a new randomizer
String newRandomizer = generateRandomString();

// Update the items randomizer
sdb.putAttribute("MyStore", item.name(), "randomizer", newRandomizer);</pre></figure>

Because this method isn&#8217;t conducive to a nice countable table that fits on a blog I&#8217;ll skip that bit, however it is a pretty straight forward exercise to run a quick simulation of the above algorithm and show that it does in fact generate nice uniform results.<p>The post <a rel="nofollow" href="https://brainsinjars.com/archives/2011/08/selecting-a-random-item-in-amazon-simpledb/">Selecting Random Items in Amazon SimpleDB</a> appeared first on <a rel="nofollow" href="https://brainsinjars.com">Brains in Jars</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://brainsinjars.com/archives/2011/08/selecting-a-random-item-in-amazon-simpledb/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
