{"id":1906,"date":"2012-03-29T00:59:12","date_gmt":"2012-03-29T04:59:12","guid":{"rendered":"http:\/\/www.etotheipiplusone.net\/?p=1906"},"modified":"2012-03-29T01:01:22","modified_gmt":"2012-03-29T05:01:22","slug":"chibicopter-its-reached-that-stage","status":"publish","type":"post","link":"https:\/\/www.etotheipiplusone.net\/?p=1906","title":{"rendered":"Chibicopter: It&#8217;s Reached &#8220;That Stage&#8221;"},"content":{"rendered":"<p>&#8230;you know, the stage of all my projects where they become stuck in software hell.<\/p>\n<p>For Chibicopter, oddly enough, it&#8217;s not been the actual operation code which has stumped me, but the process of <em>getting it there<\/em>. As previously described, Chibicopter&#8217;s only means of code uploading after the ATMega328 has been turned into an Arduino is through wireless bootloading. This has been done successfully many times. In the Chibicopter board schematic, I included components intended to use the <a href=\"http:\/\/www.ladyada.net\/make\/xbee\/arduino.html\" target=\"_blank\">Adafruit Method<\/a>, and a similar arrangement is used on the <a href=\"http:\/\/www.gravitech.us\/xbadforarna.html\" target=\"_blank\">Gravitech XBee shield for the Arduino nano<\/a> and on the <a href=\"https:\/\/docs.google.com\/viewer?a=v&amp;pid=sites&amp;srcid=ZGVmYXVsdGRvbWFpbnwyMDA3YXJkdWlub3xneDo2MTFjMTM1OTI5NDcyMDg0\" target=\"_blank\">2.007 Nano carrier<\/a>. So it&#8217;s gotta be pretty bulletproof, right?<\/p>\n<p>Well, kind of. Here&#8217;s how shit went down.<\/p>\n<p>First off, I had to make one last wire jump for everything to stand a chance of working. The reason is because I connected the RTS pin of the FTDI cable (through the wonderful Adafruit XBee adapter) to DIO8 on the XBees:<\/p>\n<p><a href=\"\/pics\/edf\/pc25.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"\/pics\/edf\/pc25.png\" alt=\"\" width=\"645\" height=\"312\" \/><\/a><\/p>\n<p>(Don&#8217;t mind where it says &#8220;DIO12&#8221; &#8211; that&#8217;s because Sparkfun&#8217;s XBee footprint is weird, or something &#8211; it&#8217;s actually DIO8 according to the manual)<\/p>\n<p>I chose DIO8 instead of DIO3, the usual choice, because it was much closer to the appropriate pins of the ATMega based on component placement. It would have been less of a topological acid trip to route the trace there. The only problem with choosing DIO8? <em>It&#8217;s not a thing<\/em>. As in, DIO8 turned out to be only DI8 when I tried to configure it in X-CTU.<\/p>\n<p>Hmm. Well that&#8217;s disappointing. Wire jump time:<\/p>\n<p style=\"text-align: center;\"><a href=\"\/pics\/edf\/pc22.jpg\"><img decoding=\"async\" class=\"aligncenter\" src=\"\/pics\/edf\/pc22-mid.jpg\" alt=\"\" width=\"512\" \/><\/a><\/p>\n<p>I performed a Little Purple Wire jump, after cutting the DI8 trace, to DIO6 across the other side. Conveniently DIO6 was also the XBee&#8217;s default RTS pin. However, in the interest of following instructions for now, I configured the pin as standard digital input (on the transmtiter side) and a default-high digital output (on the receiver side). Now, I&#8217;m assuming there&#8217;s pretty much no difference at this point between setting it as instructed or setting both sides to &#8220;RTS FLOW CONTROL&#8221; for this pin, but I could be wrong.<\/p>\n<p>The fix was promising at first &#8211; I could upload blink programs of various durations with no problems through Arduino, getting to the &#8220;Done Uploading&#8221; stage every time. But as soon as I tried uploading a bigger program, it would quit &#8211; usually after only a few seconds (short enough to transmit a blink program, but nothing much else). The activity LED would turn off, whereas if it were transmitting, it would be on pretty solidly.<\/p>\n<p>Scoping the TX\/RX pins and the DIO pin associated showed that the reset pulse was making it through (as my hack D13 LED did flash) and at least something program-like was being transmitted. However, it would randomly shut off, and the process would abort with avrdude-in-Arduino complaining that the programmer was out of sync.<\/p>\n<p>I thought it might have been a <a href=\"http:\/\/scolton.blogspot.com\/2011\/09\/great-xbee-576kbps-mystery-finally.html\" target=\"_blank\">mild baud rate mismatch<\/a> problem (and still suspect it to some degree), so I hardwired Tx and Rx straight to eachother on the XBee adapter board:<\/p>\n<p style=\"text-align: center;\"><a href=\"\/pics\/edf\/pc23.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"\/pics\/edf\/pc23-mid.jpg\" alt=\"\" width=\"512\" height=\"384\" \/><\/a><\/p>\n<p>Of <em>course<\/em> this arrangement worked. The blame now lay square with the XBee, and at Shane&#8217;s behest, I reset both XBees to factory default, wiping every setting I might have changed, and then changed things back exactly as instructed. (The transmitting one came out of the defunct <a href=\"https:\/\/www.etotheipiplusone.net\/?p=863\" target=\"_blank\">RazErblades glove controller<\/a> and the receiving side came out of&#8230;. hell if I know where)<\/p>\n<p>It worked.<\/p>\n<p>But only sporadically. I&#8217;m in a position now where some uploads will complete, some will totally fail within the first few seconds, and others will seemingly fail and cause Arduino to wait forever in the &#8220;Uploading&#8230;&#8221; stage until finally terminating, usually a full minute later, with an out of sync error.<\/p>\n<p>Weeeeird. Well, at least I can upload some code:<\/p>\n<p><iframe loading=\"lazy\" src=\"http:\/\/www.youtube.com\/embed\/UAV_arTVQWc\" frameborder=\"0\" width=\"480\" height=\"360\"><\/iframe><\/p>\n<p>I&#8217;ve since balanced the propellers much better (the whole thing doesn&#8217;t really resonate any more, though it&#8217;s still not in perfect balance) and have cut and paste enough code from Pololu&#8217;s MinIMU9 library to read all the sensors and process them. I&#8217;m not sure how you&#8217;re supposed to use their library, by the way, so I just copied and pasted the important I2C register-setting code from it and never looked back. Are you supposed to&#8230; instantiate a new instance of each sensor or something? It didn&#8217;t compile in Arduino 1.0, and the provided AHRS code was of little help since it had such lovely high level functions such as &#8220;Read_Gyro();&#8221; without explanation of where they came from, and which I couldn&#8217;t located in all the linked .h files anyway.<\/p>\n<p>Anyways, Chibicopter is some more code and tuning away from flying, which is to say it will probably sit in a box for the next few weeks. If anyone from the Arduino hacker community has any idea why my code uploads are spotty, I am open to suggestions. My number one suspicion is still the 57.6Kbps baud rate mismatch now that other inconsistencies have been eliminated.<\/p>\n<p>The next step is to revive <a href=\"https:\/\/www.etotheipiplusone.net\/?p=1820\" target=\"_blank\">XBYPASS<\/a> and glue it back to my transmitter since for some reason I decided on making this thing talk over wireless serial. That step, however, has been done before. Wow, finally a legitimate use for XBYPASS that is not trolling the anti-Arduino crowd?!<\/p>\n<p>Also,<\/p>\n<p style=\"text-align: center;\"><a href=\"\/pics\/edf\/pc24.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"\/pics\/edf\/pc24-mid.jpg\" alt=\"\" width=\"512\" height=\"384\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8230;you know, the stage of all my projects where they become stuck in software hell. For Chibicopter, oddly enough, it&#8217;s not been the actual operation code which has stumped me, but the process of getting it there. As previously described, Chibicopter&#8217;s only means of code uploading after the ATMega328 has been turned into an Arduino [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89,5],"tags":[],"class_list":["post-1906","post","type-post","status-publish","format-standard","hentry","category-chibicopter","category-project-build-reports"],"_links":{"self":[{"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=\/wp\/v2\/posts\/1906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1906"}],"version-history":[{"count":3,"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=\/wp\/v2\/posts\/1906\/revisions"}],"predecessor-version":[{"id":1908,"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=\/wp\/v2\/posts\/1906\/revisions\/1908"}],"wp:attachment":[{"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}