<?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>Puck&#039;s Workbench &#187; C Programming</title>
	<atom:link href="http://www.e-techgarage.com/Puck/category/c_programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.e-techgarage.com/Puck</link>
	<description>Embedded Geek</description>
	<lastBuildDate>Thu, 22 Apr 2010 00:00:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ZigBee Remote, Slave Mode, and the Restraining Bolt</title>
		<link>http://www.e-techgarage.com/Puck/2010/04/21/zigbee-remote-slave-mode-and-the-restraining-bolt/</link>
		<comments>http://www.e-techgarage.com/Puck/2010/04/21/zigbee-remote-slave-mode-and-the-restraining-bolt/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 23:58:30 +0000</pubDate>
		<dc:creator>Puck</dc:creator>
				<category><![CDATA[Analog Circuits]]></category>
		<category><![CDATA[C Programming]]></category>
		<category><![CDATA[Circuits]]></category>
		<category><![CDATA[Digital Circuits]]></category>
		<category><![CDATA[Rover]]></category>
		<category><![CDATA[Wireless]]></category>
		<category><![CDATA[ZigBee]]></category>

		<guid isPermaLink="false">http://www.e-techgarage.com/Puck/?p=704</guid>
		<description><![CDATA[At the request of our marketing team we have taken our intelligent rover who avoids obstacles without any assistance from anyone and given him a remote control feature via ZigBee.
Personally, I find this to be a sad state of affairs when an intelligent robot with SONAR vision is asked to behave like an RC car. [...]]]></description>
			<content:encoded><![CDATA[<p>At the request of our marketing team we have taken our intelligent rover who avoids obstacles without any assistance from anyone and given him a remote control feature via ZigBee.</p>
<p>Personally, I find this to be a sad state of affairs when an intelligent robot with SONAR vision is asked to behave like an RC car.   I&#8217;ve named this mode of operation &#8220;Slave Mode&#8221; to quietly voice my opinion on the matter.  It&#8217;s something like a zombie version of the same rover and you can understand why R2-D2 was so interested in getting rid of that restraining bolt in the first Star Wars movie so he could run for the hills.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="405" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/q9VN-eXc4RA&amp;hl=en_US&amp;fs=1&amp;color1=0x234900&amp;color2=0x4e9e00&amp;border=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="500" height="405" src="http://www.youtube.com/v/q9VN-eXc4RA&amp;hl=en_US&amp;fs=1&amp;color1=0x234900&amp;color2=0x4e9e00&amp;border=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>For the record, I wrote a command interpreter for the Rover so you can send him into Slave mode with a Wi-Fi device, ZigBee, or even from his own web server.  Truly, he is not going to escape and run off to find Obi-Won Kenobi.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.e-techgarage.com/Puck/2010/04/21/zigbee-remote-slave-mode-and-the-restraining-bolt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZigBee and the Rover</title>
		<link>http://www.e-techgarage.com/Puck/2010/02/12/zigbee-and-the-rover/</link>
		<comments>http://www.e-techgarage.com/Puck/2010/02/12/zigbee-and-the-rover/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 00:59:52 +0000</pubDate>
		<dc:creator>Puck</dc:creator>
				<category><![CDATA[Analog Circuits]]></category>
		<category><![CDATA[C Programming]]></category>
		<category><![CDATA[Circuits]]></category>
		<category><![CDATA[Digital Circuits]]></category>
		<category><![CDATA[Rover]]></category>
		<category><![CDATA[Wireless]]></category>
		<category><![CDATA[ZigBee]]></category>

		<guid isPermaLink="false">http://www.e-techgarage.com/Puck/?p=690</guid>
		<description><![CDATA[Anyone working in the Embedded field by now has caught the wireless ZigBee buzz and RoverLORD is no exception.  Digi has a pretty strong line of ZigBee products.
Adding ZigBee to the Rover&#8230; Scary Scary!
I admit that ZigBee is pretty intimidating but getting him up and running was less than a day with the Rabbit code.
The [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone working in the Embedded field by now has caught the wireless ZigBee buzz and RoverLORD is no exception.  <a href="http://www.digi.com/products/wireless/zigbee-mesh/xbee-zb-module.jsp#overview">Digi has a pretty strong line of ZigBee products</a>.</p>
<h2>Adding ZigBee to the Rover&#8230; Scary Scary!</h2>
<p>I admit that ZigBee is pretty intimidating but getting him up and running was less than a day with the Rabbit code.</p>
<p>The first thing you want to realize is that you can set up one of the ZigBee modems to fake out a serial port.  Why is that important?  It means my Rover doesn&#8217;t need to know &#8220;<em>thing one</em>&#8221; about ZigBee.  He just writes or reads with his serial port and the modem does all the work.  If there is no need to worry about the ZigBee software, I don&#8217;t increase my project&#8217;s code size and my CPU doesn&#8217;t have to carry the overhead either.</p>
<p>On the other end I have an <a href="http://www.rabbit.com/products/rcm4500W/">RCM4510W</a> acting as the ZigBee coordinator to the Rover&#8217;s ZigBee end device.  He comes up using our ZigBee API, sends off a command to set the Rover&#8217;s modem as a transparent serial port and then sits there listening as my rover happily chatters away to his fake serial port.  Little does he know that every log entry is being passed wirelessly to my other Rabbit where I can easily dump the data into a log file.</p>
<h2>ZigBee at Play</h2>
<p>In this video you can see our Rover happily face-planting into a cube wall while he reliably sends us a description of his many woes via the ZigBee connection back to my PC.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="445" height="364" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/LP7HLShdV78&amp;hl=en_US&amp;fs=1&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="445" height="364" src="http://www.youtube.com/v/LP7HLShdV78&amp;hl=en_US&amp;fs=1&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>You will see an XBee Series 2 modem on the Rover in the video and in the image below.</p>
<div id="attachment_692" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.e-techgarage.com/Puck/wp-content/uploads/2010/02/ZigBee_Rover_PCB.JPG"><img class="size-medium wp-image-692 " style="border: 5px solid black;" title="ZigBee_Rover_PCB" src="http://www.e-techgarage.com/Puck/wp-content/uploads/2010/02/ZigBee_Rover_PCB-300x225.jpg" alt="You can see the blue ZigBee Modem on the PCB." width="300" height="225" /></a><p class="wp-caption-text">You can see the blue ZigBee Modem on the PCB.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.e-techgarage.com/Puck/2010/02/12/zigbee-and-the-rover/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Collision Avoidance and More</title>
		<link>http://www.e-techgarage.com/Puck/2010/02/08/collision-avoidance-and-more/</link>
		<comments>http://www.e-techgarage.com/Puck/2010/02/08/collision-avoidance-and-more/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 23:16:59 +0000</pubDate>
		<dc:creator>Puck</dc:creator>
				<category><![CDATA[C Programming]]></category>
		<category><![CDATA[Rover]]></category>

		<guid isPermaLink="false">http://www.e-techgarage.com/Puck/?p=627</guid>
		<description><![CDATA[The initial rover collision avoidance algorithm was created so that the rover would turn his SONAR turret back and forth and attempt to detect an obstacle within 3 feet in any direction.  It worked well enough but was probably too aggressive.  When the Rover got close to a wall he got very suspicious when he probably [...]]]></description>
			<content:encoded><![CDATA[<p>The initial rover collision avoidance algorithm was created so that the rover would turn his SONAR turret back and forth and attempt to detect an obstacle within 3 feet in any direction.  It worked well enough but was probably too aggressive.  When the Rover got close to a wall he got very suspicious when he probably didn&#8217;t need to.</p>
<div id="attachment_628" class="wp-caption aligncenter" style="width: 315px"><a href="http://www.e-techgarage.com/Puck/wp-content/uploads/2010/02/Rover-Collision-Circle.bmp"><img class="size-full wp-image-628" style="border: 5px solid black;" title="Rover Collision Circle" src="http://www.e-techgarage.com/Puck/wp-content/uploads/2010/02/Rover-Collision-Circle.bmp" alt="Rover's Turret sweeping a constant forward arc for obstacles." width="305" height="277" /></a><p class="wp-caption-text">Rover will detect an obstacle anywhere within the 3 foot arc.</p></div>
<p style="text-align: center;">
<p style="text-align: left;">When the rover is operating near a wall, 3 feet of lateral clearance is too much.   It prevents him from traveling in parallel to a wall or from passing through any hallway less than 6 feet wide.</p>
<div class="wp-caption aligncenter" style="width: 300px"><a href="http://www.e-techgarage.com/Puck/wp-content/uploads/2010/02/Rover-Collision-Circle_Wall1.bmp"><img style="display: block; margin-left: auto; margin-right: auto; border: 5px solid black;" title="Rover Collision Circle_Wall" src="http://www.e-techgarage.com/Puck/wp-content/uploads/2010/02/Rover-Collision-Circle_Wall1.bmp" alt="As the Rover attempts to navigate this hallway, the 3 foot detection radius registers as a false obstacle." width="290" height="326" /></a><p class="wp-caption-text">As the Rover attempts to navigate this hallway, the 3 foot detection radius registers the hallway as a false obstacle.</p></div>
<p style="text-align: left;">
<p style="text-align: center;"><span style="color: #ff0000;">3 feet</span> of clearance on the left + <span style="color: #ff0000;">3 feet</span> of clearance on the right</p>
<p style="text-align: center;">=</p>
<p style="text-align: center;"><strong><span style="color: #ff0000;">6 fee</span><span style="color: #ff0000;">t</span> minimum lateral clearance</strong></p>
<p style="text-align: left;">If you would believe my high school math teacher we might be able to find a use for math in the real world.  In fact, there is a handy ratio function that lets us trim down the obstacle detection field.</p>
<p style="text-align: center;">
<div id="attachment_640" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.e-techgarage.com/Puck/wp-content/uploads/2010/02/ratio-math1.JPG"><img class="size-medium wp-image-640 " style="border: 5px solid black;" title="ratio math" src="http://www.e-techgarage.com/Puck/wp-content/uploads/2010/02/ratio-math1-300x294.jpg" alt="Calculating a ratio to scale the obstacle field." width="300" height="294" /></a><p class="wp-caption-text">Calculating a ratio to scale the obstacle field.</p></div>
<p>If our obstacle detection is 3 feet and we want 10 inches of clearance on either side for the wheels, we can use the ratio to get there like this:</p>
<ul>
<li>y &#8211; axis (Forward Obstacle Detection) = 36 inches (3 feet)</li>
<li>x &#8211; axis (Lateral Obstacle Detection) = <strong><span style="color: #339966;">10 inches</span></strong></li>
<li>36 inches &#8211; 10 inches = <strong><span style="color: #0000ff;">26 inches</span></strong></li>
</ul>
<p>We just plug our numbers into this equation and out drops our new detection zone:</p>
<p style="text-align: center;"><strong>Obstacle distance at angle Theta = (RATIO x <span style="color: #0000ff;">26 inches</span>) + (<span style="color: #339966;">10 </span><span style="color: #339966;">inches</span>)</strong></p>
<p style="text-align: left;">Crunching these numbers<strong> </strong>we get the following results<strong>:<br />
</strong></p>
<ol>
<li>-90 degrees = (0.0 x 26&#8243;) + 10&#8243; = 10&#8243; &#8211; <strong>(Looking Left)</strong></li>
<li>-45 degrees = (0.5 x 26&#8243;) + 10&#8243; = 23&#8243; &#8211; <strong>(Looking Left &amp; Forward)</strong></li>
<li>0 degrees = (1.0 x 26&#8243;) + 10&#8243; = 36&#8243; &#8211; <strong>(Looking Forward)</strong></li>
<li>+45 degrees = (0.5 x 26&#8243;) + 10&#8243; = 23&#8243; &#8211; <strong>(Looking Right &amp; Forward)</strong></li>
<li>+90 degrees = (0.0 x 26&#8243;) + 10&#8243; = 10&#8243; &#8211; <strong>(Looking Right)</strong></li>
</ol>
<p>That changes the shape of the obstacle detection field from a half-circle into this triangle:</p>
<div id="attachment_645" class="wp-caption aligncenter" style="width: 255px"><a href="http://www.e-techgarage.com/Puck/wp-content/uploads/2010/02/Rover-Collision-Triangle1.bmp"><img class="size-full wp-image-645" style="border: 5px solid black;" title="Rover Collision Triangle" src="http://www.e-techgarage.com/Puck/wp-content/uploads/2010/02/Rover-Collision-Triangle1.bmp" alt="The obstacle field is trimmed to allow for more lateral clearance." width="245" height="476" /></a><p class="wp-caption-text">The obstacle field is trimmed to allow for more lateral clearance.</p></div>
<p style="text-align: center;">
<p>With this little bit of math we can more easily travel through a narrow hallway.  This modified detection algorithm is what we used in the <a href="http://www.e-techgarage.com/Puck/2010/01/22/collision-avoidance-is-working/">successful obstacle avoidance test video</a>.  The best part is that while we travel parallel to a wall we won&#8217;t detect it as an obstacle but if we start to drift into it, the Rover will still detect it.</p>
<p style="text-align: center;">
]]></content:encoded>
			<wfw:commentRss>http://www.e-techgarage.com/Puck/2010/02/08/collision-avoidance-and-more/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sweeping the SONAR &#8211; Tests #29 and #30</title>
		<link>http://www.e-techgarage.com/Puck/2010/01/14/sweeping-the-sonar-tests-29-and-30/</link>
		<comments>http://www.e-techgarage.com/Puck/2010/01/14/sweeping-the-sonar-tests-29-and-30/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 18:51:49 +0000</pubDate>
		<dc:creator>Puck</dc:creator>
				<category><![CDATA[Analog Circuits]]></category>
		<category><![CDATA[C Programming]]></category>
		<category><![CDATA[Digital Circuits]]></category>
		<category><![CDATA[Rover]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.e-techgarage.com/Puck/?p=611</guid>
		<description><![CDATA[It seems the Rover has a very tight field of view and to counter this tunnel vision effect we are going to try sweeping the SONAR turret from side to side as he travels forward.
Test # 29 &#8211; SONAR Sweeping Bench Test

Test #30 &#8211; SONAR Sweeping Floor Test
Here we are getting closer to good collision [...]]]></description>
			<content:encoded><![CDATA[<p>It seems the Rover has a very tight field of view and to counter this tunnel vision effect we are going to try sweeping the SONAR turret from side to side as he travels forward.</p>
<h2>Test # 29 &#8211; SONAR Sweeping Bench Test</h2>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="445" height="364" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/RzD0qSSCxNU&amp;hl=en_US&amp;fs=1&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="445" height="364" src="http://www.youtube.com/v/RzD0qSSCxNU&amp;hl=en_US&amp;fs=1&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<h2>Test #30 &#8211; SONAR Sweeping Floor Test</h2>
<p>Here we are getting closer to good collision avoidance.  <a href="http://www.e-techgarage.com/Puck/2010/01/08/rovers-nemesis-the-dread-pipe-bob/">Bob the Dreaded Conduit Pipe</a> looks like he may be close to defeat.<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="445" height="364" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/vQ7RBPEbKr0&amp;hl=en_US&amp;fs=1&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="445" height="364" src="http://www.youtube.com/v/vQ7RBPEbKr0&amp;hl=en_US&amp;fs=1&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.e-techgarage.com/Puck/2010/01/14/sweeping-the-sonar-tests-29-and-30/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test Videos #27 and #28 &#8211; More Collision Avoidance</title>
		<link>http://www.e-techgarage.com/Puck/2010/01/14/test-videos-27-and-28-more-collision-avoidance/</link>
		<comments>http://www.e-techgarage.com/Puck/2010/01/14/test-videos-27-and-28-more-collision-avoidance/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 16:18:42 +0000</pubDate>
		<dc:creator>Puck</dc:creator>
				<category><![CDATA[Analog Circuits]]></category>
		<category><![CDATA[C Programming]]></category>
		<category><![CDATA[Circuits]]></category>
		<category><![CDATA[Digital Circuits]]></category>
		<category><![CDATA[Rover]]></category>

		<guid isPermaLink="false">http://www.e-techgarage.com/Puck/?p=609</guid>
		<description><![CDATA[Here are two more videos of the Rover trying to get the SONAR tuned up for good collision avoidance.
Test #27 &#8211; Oops!
Here the Rover is crashing because we aren&#8217;t sending any braking to his motors.  That means he is coasting forward even when he detects an obstacle.

Test #28 &#8211; Restoring the Hard Braking
Here the braking [...]]]></description>
			<content:encoded><![CDATA[<p>Here are two more videos of the Rover trying to get the SONAR tuned up for good collision avoidance.</p>
<h2>Test #27 &#8211; Oops!</h2>
<p>Here the Rover is crashing because we aren&#8217;t sending any braking to his motors.  That means he is coasting forward even when he detects an obstacle.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="445" height="364" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/keosEq5e5t8&amp;hl=en_US&amp;fs=1&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="445" height="364" src="http://www.youtube.com/v/keosEq5e5t8&amp;hl=en_US&amp;fs=1&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<h2>Test #28 &#8211; Restoring the Hard Braking</h2>
<p>Here the braking has been restored.  We brake by sending 1-2 inverted pulses to the motors which pops the wheels in the opposite direction very briefly.  It&#8217;s a jolting stop, but it certainly beats crashing.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="445" height="364" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/d65XQwRuLXk&amp;hl=en_US&amp;fs=1&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="445" height="364" src="http://www.youtube.com/v/d65XQwRuLXk&amp;hl=en_US&amp;fs=1&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.e-techgarage.com/Puck/2010/01/14/test-videos-27-and-28-more-collision-avoidance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
