<?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>InfoHole &#187; Robotics</title>
	<atom:link href="http://www.infohole.com/blog/category/robotics/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.infohole.com/blog</link>
	<description>A blog by Gordon Page</description>
	<lastBuildDate>Tue, 04 Oct 2011 05:44:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Verifying Integrity Of 9DOF Data Sent To Arduino Mega</title>
		<link>http://www.infohole.com/blog/robotics/verifying-integrity-of-9dof-data-sent-to-arduino-mega/</link>
		<comments>http://www.infohole.com/blog/robotics/verifying-integrity-of-9dof-data-sent-to-arduino-mega/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 05:40:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Robotics]]></category>

		<guid isPermaLink="false">http://www.infohole.com/blog/?p=413</guid>
		<description><![CDATA[In this video I show you how I verify the integrity of data being sent from the 9DOF (9 degrees of freedom) to an Arduino Mega. The only reason for doing this is to ensure that a poor cable connection does not result in the Arduino using corrupted or incorrect X,Y,Z data (which could be [...]]]></description>
			<content:encoded><![CDATA[<p>In this video I show you how I verify the integrity of data being sent  from the 9DOF (9 degrees of freedom) to an <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2Fs%3Fie%3DUTF8%26x%3D0%26ref_%3Dnb_sb_noss%26y%3D0%26field-keywords%3Darduino%2520mega%26url%3Dsearch-alias%253Daps%23&#038;tag=putcode-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=390957">Arduino Mega</a>. The only reason  for doing this is to ensure that a poor cable connection does not  result in the Arduino using corrupted or incorrect X,Y,Z data (which  could be catastrophic for a flying craft).</p>
<p><iframe width="540" height="340" src="http://www.youtube.com/embed/SfbgZNxdopc" frameborder="0" allowfullscreen></iframe></p>
<p>Here's my code for receiving the 9DOF data and checking it, there may be bugs, use at your own risk!</p>
<p><code><br />
float processByteToVal(int positionInArray, byte theData, float currentTotal)<br />
{<br />
    float newData=(float)(theData-48);//turn a byte of 49 into a number of 1, byte of 54 into int 6, etc.<br />
    float outputValue=0;</p>
<p>    if(positionInArray==0)<br />
    {<br />
       outputValue=currentTotal+(newData/100);<br />
    }<br />
    else if(positionInArray==1)<br />
    {<br />
       outputValue=currentTotal+(newData/10);<br />
    }<br />
    else if(positionInArray==2)<br />
    {<br />
       outputValue=currentTotal;<br />
    }<br />
    else if(positionInArray==3)<br />
    {<br />
       outputValue=currentTotal+newData;<br />
    }<br />
    else if(positionInArray==4)<br />
    {<br />
        if(theData==45)//the original byte passed was a minus sign;<br />
        {<br />
             outputValue=0-currentTotal;<br />
        }<br />
        else<br />
        {<br />
            outputValue=currentTotal+(newData*10);<br />
        }<br />
    }<br />
    else if(positionInArray==5)<br />
    {<br />
         outputValue=currentTotal+(newData/100);<br />
        if(theData==45)//the original byte passed was a minus sign;<br />
        {<br />
             outputValue=0-currentTotal;<br />
        }<br />
        else<br />
        {<br />
            outputValue=currentTotal+(newData*100);<br />
        }<br />
    }<br />
    else if(positionInArray==6)//positionInArray 6 can only ever be a negative sign<br />
    {<br />
        if(theData==45)//the original byte passed was a minus sign;<br />
        {<br />
             outputValue=0-currentTotal;<br />
        }<br />
    }<br />
    return outputValue;<br />
}</p>
<p>int getData()<br />
{<br />
  int inByte;<br />
  int dataFound=0;<br />
  while(dataFound<1)<br />
  {<br />
      if(Serial3.available())<br />
      {<br />
          inByte = Serial3.read();<br />
          return inByte;<br />
          dataFound=1;<br />
      }<br />
      else<br />
      {<br />
         //delay(1);<br />
      }<br />
  }<br />
}</p>
<p>void getAttitude() {<br />
        int inByte=0;<br />
        Serial3.flush();</p>
<p>        while(inByte!=58) // 58 is :<br />
        {<br />
              inByte = getData();<br />
        }</p>
<p>        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
        inByte = getData();<br />
        int xPos=0;<br />
        float xVal=0;<br />
        byte xData[7];<br />
        while(inByte!=44) // 44 is ,<br />
        {<br />
             if(inByte!=-1) // -1 is not available<br />
             {   </p>
<p>                 xData[xPos]=inByte;<br />
                 xPos++;<br />
             }<br />
             inByte = getData();<br />
        }<br />
        int newPos=0;<br />
        xPos--;<br />
        while(xPos>=0)<br />
        {<br />
             xVal=processByteToVal(newPos, xData[xPos], xVal);<br />
             xPos--;<br />
             newPos++;</p>
<p>        }</p>
<p>        //YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY<br />
        //YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY<br />
        //YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY<br />
        inByte = getData();<br />
        int yPos=0;<br />
        float yVal=0;<br />
        byte yData[7];<br />
        while(inByte!=44) // 44 is ,<br />
        {<br />
             if(inByte!=-1) // -1 is not available<br />
             {   </p>
<p>                 yData[yPos]=inByte;<br />
                 yPos++;<br />
             }<br />
             inByte = getData();<br />
        }<br />
        newPos=0;<br />
        yPos--;<br />
        while(yPos>=0)<br />
        {<br />
             yVal=processByteToVal(newPos, yData[yPos], yVal);<br />
             yPos--;<br />
             newPos++;</p>
<p>        }</p>
<p>        //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ<br />
        //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ<br />
        //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ<br />
        inByte = getData();<br />
        int zPos=0;<br />
        float zVal=0;<br />
        byte zData[7];<br />
        while(inByte!=44) // 44 is ,<br />
        {<br />
             if(inByte!=-1) // -1 is not available<br />
             {   </p>
<p>                 zData[zPos]=inByte;<br />
                 zPos++;<br />
             }<br />
             inByte = getData();<br />
        }<br />
        newPos=0;<br />
        zPos--;<br />
        while(zPos>=0)<br />
        {<br />
             zVal=processByteToVal(newPos, zData[zPos], zVal);<br />
             zPos--;<br />
             newPos++;<br />
        }</p>
<p>        //TOTAL - TOTAL - TOTAL - TOTAL -TOTAL<br />
        //TOTAL - TOTAL - TOTAL - TOTAL -TOTAL<br />
        //TOTAL - TOTAL - TOTAL - TOTAL -TOTAL<br />
        inByte = getData();<br />
        //Serial.println ("");<br />
        //Serial.print("This is total: ");<br />
        int totalPos=0;<br />
        float totalVal=0;<br />
        byte totalData[7];<br />
        while(inByte!=13) // 44 is ,<br />
        {<br />
             if(inByte!=-1) // -1 is not available<br />
             {   </p>
<p>                 totalData[totalPos]=inByte;<br />
                 //Serial.print(inByte, BYTE);<br />
                 totalPos++;<br />
             }<br />
             inByte = getData();<br />
        }<br />
        newPos=0;<br />
        totalPos--;<br />
        while(totalPos>=0)<br />
        {<br />
             totalVal=processByteToVal(newPos, totalData[totalPos], totalVal);<br />
             totalPos--;<br />
             newPos++;</p>
<p>        }<br />
            // Serial.print("totalVal is: ");<br />
            // Serial.println(totalVal); </p>
<p>        float localTotal=xVal+yVal+zVal;</p>
<p>        if((abs(totalVal)-abs(localTotal)<=0.03) &#038;& (abs(totalVal)-abs(localTotal)>=-0.03))<br />
        {<br />
           currentXAngle=0-xVal;//currentXAngle and currentYAngle are the gloabl variables that store the current x,y,z that we use throughout the code.<br />
           currentYAngle=yVal;<br />
           currentZAngle=0-zVal;</p>
<p>           //FOR DEBUG PURPOSES ONLY, MUST REMOVE BEFORE FLIGHT!!!!!!!!!!!!!!!!!!!<br />
           //currentXAngle=0;<br />
           //currentYAngle=0;<br />
           imuSuccesses++;<br />
        }<br />
        else<br />
        {<br />
          Serial.println("-------------------------The data is NOT NOT NOT NOT NOT NOT valid!!!!!!------------------");<br />
          Serial.println("");<br />
          imuFailures++;<br />
        }<br />
}</code></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.infohole.com%2Fblog%2Frobotics%2Fverifying-integrity-of-9dof-data-sent-to-arduino-mega%2F';
  addthis_title  = 'Verifying+Integrity+Of+9DOF+Data+Sent+To+Arduino+Mega';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.infohole.com/blog/robotics/verifying-integrity-of-9dof-data-sent-to-arduino-mega/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino Mega 2.4Ghz R/C Receiver Code</title>
		<link>http://www.infohole.com/blog/robotics/arduino-mega-2-4ghz-rc-receiver-code/</link>
		<comments>http://www.infohole.com/blog/robotics/arduino-mega-2-4ghz-rc-receiver-code/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 07:29:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Robotics]]></category>

		<guid isPermaLink="false">http://www.infohole.com/blog/?p=310</guid>
		<description><![CDATA[Since posting this video, a few people have been asking for the source code. I don't have that exact code available still, but here is some code which takes 3 input values from an R/C receiver and outputs them to the screen. I took this code from another of my projects, and just deleted all [...]]]></description>
			<content:encoded><![CDATA[<p>Since posting <a href="http://www.youtube.com/watch?v=Mpr7a8P1c30">this video</a>, a few people have been asking for the source code. I don't have that exact code available still, but here is some code which takes 3 input values from an R/C receiver and outputs them to the screen.</p>
<p>I took this code from another of my projects, and just deleted all the non-relevant code. I may have inadvertently deleted parts of the code that I shouldn't have, so if you have come across any errors just leave a comment below with details and I'll fix it.</p>
<blockquote><p>#include</p>
<p>//these store the current transmitter positions/values<br />
unsigned long transmitterThrottlee=0;<br />
unsigned long transmitterLeftRight=0;<br />
unsigned long transmitterForwardBack=0;</p>
<p>void setup()<br />
{<br />
pinMode (8, INPUT);<br />
pinMode (9, INPUT);<br />
pinMode (10, INPUT);</p>
<p>Serial.begin(57600);<br />
Serial.println("Done with setup");<br />
}</p>
<p>void checkTransmitter()<br />
{<br />
transmitterThrottlee = (pulseIn (9, HIGH, 100000))/10; //read RC channel, wait max of 0.1 seconds for pulse<br />
transmitterLeftRight = (pulseIn (8, HIGH, 100000))/10; //read RC channel, wait max of 0.1 seconds for pulse<br />
transmitterForwardBack = (pulseIn (10, HIGH, 100000))/10; //read RC channel, wait max of 0.1 seconds for pulse<br />
}</p>
<p>void loop()<br />
{<br />
checkTransmitter();//check the data being received by the transmitter.<br />
Serial.print ("data: ");//if we decrease altitude we should check for landing, and slow our decent when we get close to the ground.<br />
Serial.println (transmitterThrottle);<br />
Serial.println (transmitterLeftRight);<br />
Serial.println (transmitterForwardBack);</p>
<p>delay (200);<br />
}</p></blockquote>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.infohole.com%2Fblog%2Frobotics%2Farduino-mega-2-4ghz-rc-receiver-code%2F';
  addthis_title  = 'Arduino+Mega+2.4Ghz+R%2FC+Receiver+Code';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.infohole.com/blog/robotics/arduino-mega-2-4ghz-rc-receiver-code/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Robot Balancing On A Ball</title>
		<link>http://www.infohole.com/blog/robotics/robot-balancing-on-a-ball/</link>
		<comments>http://www.infohole.com/blog/robotics/robot-balancing-on-a-ball/#comments</comments>
		<pubDate>Thu, 06 May 2010 02:22:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Robotics]]></category>
		<category><![CDATA[balance]]></category>
		<category><![CDATA[ball]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.infohole.com/blog/?p=308</guid>
		<description><![CDATA[Here's a cool video of a robot balancing on a ball. Presumably it uses a few gyroscopes, magnetometers, etc. [See post to watch Flash video] addthis_url = 'http%3A%2F%2Fwww.infohole.com%2Fblog%2Frobotics%2Frobot-balancing-on-a-ball%2F'; addthis_title = 'Robot+Balancing+On+A+Ball'; addthis_pub = '';]]></description>
			<content:encoded><![CDATA[<p>Here's a cool video of a robot balancing on a ball. Presumably it uses a few gyroscopes, magnetometers, etc.</p>
[See post to watch Flash video]
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.infohole.com%2Fblog%2Frobotics%2Frobot-balancing-on-a-ball%2F';
  addthis_title  = 'Robot+Balancing+On+A+Ball';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.infohole.com/blog/robotics/robot-balancing-on-a-ball/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

