{"id":748,"date":"2010-06-21T04:33:07","date_gmt":"2010-06-21T08:33:07","guid":{"rendered":"http:\/\/www.etotheipiplusone.net\/?p=748"},"modified":"2010-07-05T04:40:50","modified_gmt":"2010-07-05T08:40:50","slug":"deathblades-the-birds-and-the-xbees","status":"publish","type":"post","link":"https:\/\/www.etotheipiplusone.net\/?p=748","title":{"rendered":"Deathblades: The Birds and the XBees"},"content":{"rendered":"<p>I&#8217;ve been waiting to use that title for a long time.<\/p>\n<p>Building the &#8216;blades has been quite an exercise in unfamiliar territory. First, the skates will be using the Maxon <a href=\"https:\/\/www.etotheipiplusone.net\/?p=695\" target=\"_blank\">DEC modules<\/a>, which are essentially experimental with respect to the project, me having seen no other vehicles that use them (seriously &#8211; all other Google results seem to just be press releases). Having access to the DEC modules was the impetus behind me finally learning <a href=\"https:\/\/www.etotheipiplusone.net\/?p=691\" target=\"_blank\">PCB design and layout<\/a>.\u00a0 I just discovered the magic that is <a href=\"https:\/\/www.etotheipiplusone.net\/?p=745\" target=\"_blank\">force-sensing resistors<\/a> and how they can be used as an analog throttle.<\/p>\n<p>And now, as the final and pivotal step in closing the proverbial control loop of the Deathblades, I shall link the throttle with the DECs using XBee radio modules.<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.digi.com\/images\/products\/prd-xbeemoduleseries1_lg.jpg\" alt=\"\" width=\"400\" height=\"400\" \/><\/p>\n<p style=\"text-align: center;\"><em>SOOOOOO CUUUUUUUUTE. It&#8217;s just like a really obese centipede with a silly hat! That transmits and receives data!<\/em><\/p>\n<p>These little 2.4GHz, <a href=\"http:\/\/en.wikipedia.org\/wiki\/802.15.4\" target=\"_blank\">802.15.4<\/a> radio modules are very popular in the DIY and maker crowd because of their level of flexibility. They can form star, mesh, and mixed topology networks, and can act as wireless serial bridges. But much of their popularity (at least of the Series 1, not so much the newer models which adhere more closely to the standard) is the ability to act as an airwire. The XBee can be configured to pass two analog signals in the form of 0-100% digital PWM, and then up to 6 more digital I\/Os, all without involving another microcontroller in the loop. To make my life even easier, Digi International provides <a href=\"http:\/\/www.digi.com\/support\/productdetl.jsp?pid=3352&amp;osvid=57&amp;s=316&amp;tp=5&amp;tp2=0\" target=\"_blank\">X-CTU<\/a>,a useful GUI tool for configuring the radios to do your bidding.<\/p>\n<p style=\"text-align: center;\"><a href=\"\/pics\/death\/blades_89.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"\/pics\/death\/blades_89-mid.jpg\" alt=\"\" width=\"512\" height=\"384\" \/><\/a><\/p>\n<p>I yoinked two <a href=\"http:\/\/www.adafruit.com\/index.php?main_page=product_info&amp;cPath=29&amp;products_id=126\" target=\"_blank\">Xbee Adapter<\/a> boards from MITERS&#8217; neighboring student activities so I could easily throw together a breadboard assembly.\u00a0 Each unit here is receiving 3.3 volts from the FSR board regulator. I set them up such that the transmitting unit receives the analog FSR voltage on <strong>AD0\/DIO0<\/strong> and an &#8220;enable&#8221; signal, on <strong>AD1\/DIO1<\/strong>.<\/p>\n<p>On the receiving side, the radio has <strong>PWM0\/RSSI<\/strong> hooked to the oscilloscope, along with its own <strong>AD1\/DIO1<\/strong>. Digital I\/Os are paired, but the analog ones have their own pins.<\/p>\n<p>Conveniently enough, RSSI was connected to a red LED on the boards.<\/p>\n<p style=\"text-align: center;\"><a href=\"\/pics\/death\/blades_90.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"\/pics\/death\/blades_90-mid.jpg\" alt=\"\" width=\"512\" height=\"384\" \/><\/a><\/p>\n<p>Configuring the radios to act as analog and digital airwires. There are relatively few settings to change, and most of them revolve around how to use the I\/O pins. I referenced <a href=\"http:\/\/www.faludi.com\/2006\/12\/03\/xbee-direct-io-with-adc\/\" target=\"_blank\">Rob Faludi&#8217;s XBee I\/O page<\/a> (props for being the number 1 Google hit for the exact words &#8220;Xbee Direct I\/O&#8221;) and Digi&#8217;s own <a href=\"http:\/\/www.digi.com\/support\/kbase\/kbaseresultdetl.jsp?id=2180&amp;hit=Analog%20to%20Digital%20Conversion%20on%20the%20XBee%20802.15.4#knowledgebase\" target=\"_blank\">knowledge base page<\/a> on the matter. Needless to say, <a href=\"http:\/\/www.sparkfun.com\/datasheets\/Wireless\/Zigbee\/XBee-Manual.pdf\" target=\"_blank\">RTFM<\/a> came in handy also.<\/p>\n<p>The things I changed from the default firmware settings for the <strong>transmitting<\/strong> side, all values in hex:<\/p>\n<ul>\n<li>Pan ID (<strong>ATID<\/strong>)\u00a0 = 9000, because&#8230; well, I could.<\/li>\n<li>Radio ID (<strong>ATMY<\/strong>) = 1, just a number again.<\/li>\n<li>Destination Address L (<strong>ATDL<\/strong>) = FFFF, which is the <em>broadcast<\/em> setting for the simpler 16 bit addressing mode. If I wanted the transmitter to only talk to one other radio, this would be the ATMY of the other radio. But I ultimately want to control 2 other modules, and simple I\/O mode doesn&#8217;t allow changing of the address on the fly, so broadcast will have to do. Fortunately, there are settings for which radio IDs you should <em>listen <\/em>to.<\/li>\n<li>Digital I\/O 0 (<strong>ATD0<\/strong>) = 2, for this pin&#8217;s ADC mode, hooked to the 0-3.3v output.<\/li>\n<li>Digital I\/O 1 (<strong>ATD1<\/strong>) = 3, for this pin&#8217;s function as a digital <em>input<\/em>, mapped to DIO1 on the other modules trained to it.<\/li>\n<li>I left <strong>ATIU<\/strong> off because I didn&#8217;t need the packet information from the radio&#8217;s serial ports.<\/li>\n<li>Number of samples before transmission (<strong>ATIT<\/strong>) = 1. I don&#8217;t know what the effect of changing this to a higher value does &#8211; perhaps to filter out noise or slow the rate of updates, but I decided to just transmit everything.<\/li>\n<li>Sampling rate (<strong>ATIR<\/strong>) = 1. The sampling rate can increment in 1ms resolutions. I decided that 1ms was fine.<\/li>\n<li>Input address (<strong>ATIA<\/strong>) = FF. This is the <em>which radio is commanding my I\/O lines <\/em>option. In the case of the Tx, I set this to 0xFF, which is the &#8220;nobody&#8221; option, because&#8230; well, this <em>is <\/em>the transmitter. The <em>receiver<\/em> would have this set to 1, the ATMY of the transmitter. This was crucial. I missed it the first time and the bridge most definitely did not work.<\/li>\n<li>PWM0\/RSSI pin mode (<strong>ATP0<\/strong>) = 0. The transmitter won&#8217;t be putting out a PWM signal, so there is no need to set the pin.<\/li>\n<\/ul>\n<p>From this, it seems that ATIA = FFFF and ATDL = FFFF will cause all radios to affect all other radios. I&#8217;m sure this is not actually the case, because that sounds like a nightmarish scenario.<\/p>\n<p>Next, I set complementary values for the <strong>receiving<\/strong> side:<\/p>\n<ul>\n<li><strong>PAN ID<\/strong> = 9000<\/li>\n<li><strong>ATMY<\/strong> = 2 , this was arbitrarily the 2nd radio in my little network. It could have been the 987th.<\/li>\n<li><strong>ATDL<\/strong> = 1, because it should <em>talk only to the transmitter<\/em>, not broadcast.<\/li>\n<li><strong>ATD0<\/strong> = 0, or disabled, since I&#8217;m not using DIO0 as a <em>digital<\/em> I\/O.<\/li>\n<li><strong>ATD1<\/strong> = 4, for this pin&#8217;s digital output mode <em>with a default setting of LOW<\/em>.  Logical low disables the DEC&#8217;s outputs, which I want. DIO1 is hooked to  the enable signal on the FSR board.<\/li>\n<li>No <strong>ATIU, ATIT, or ATIR<\/strong> (left unchanged or default values)<\/li>\n<li><strong>ATIA<\/strong> = 1. This trains the receiver to radio ID #1, which is my transmitter.<\/li>\n<li>And finally, ATP0 = 2, to couple it to the analog-to-digital coversion of DIO0 on the transmitter side.<\/li>\n<li>I set pin timeouts (<strong>ATT0<\/strong> and <strong>ATPT<\/strong>) to 500ms so all the outputs return to their default states if no valid updates are received within that timeframe.<\/li>\n<\/ul>\n<p>What does all this result in?<\/p>\n<p>Well, first, nothing if I don&#8217;t hook up the VREF pin on the transmitting XBee. Which I didn&#8217;t. Comparing 3.3v to #NaN always results in bullshit.<\/p>\n<p>But here&#8217;s a <a href=\"\/pics\/death\/xbee_response_test.mov\" target=\"_blank\">video of the wireless signal transmission<\/a> working. The RSSI LED is being used as the PWM output here, and its brightness varies as I push down on the FSR.<\/p>\n<p>The scope clearly shows the 16kHz square wave coming out of PWM0 as well as the changing state of DIO1. On the FSR board, I made an (adjustable) comparator input that drives DIO1 high only after the FSR voltage exceeds a threshold. In the video, it&#8217;s about 30%. This acts as a very (very) rough control deadband so random hand flicks don&#8217;t cause the motors to turn on.<\/p>\n<p>The downside is that the minimum throttle at activation is 30%. Clearly, this will be adjusted to taste. More sophisticated glue circuitry will better approximate a deadband curve, but this is enough to prove the concept.<\/p>\n<p style=\"text-align: center;\"><a href=\"\/pics\/death\/blades_91.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"\/pics\/death\/blades_91-mid.jpg\" alt=\"\" width=\"512\" height=\"384\" \/><\/a><\/p>\n<p>One catch: the DEC modules run 5 volt logic but the XBee runs on 3.3 volts! So I lied &#8211; even at full throttle, it means a direct signal would only have me crusing at around 66%.<\/p>\n<p>Lame. So to validate one of the experimental parts of the &#8220;Double DEC&#8217;er&#8221; board, I made a small buffer that outputs 5 volts. Two 2n7000 signal FETs are wired sequentially in <a href=\"http:\/\/en.wikipedia.org\/wiki\/Common_source\" target=\"_blank\">common-source mode<\/a>, which makes sure the signal is still rectified. The 5v, 16kHz output is trivially filtered back to a smooth analog voltage   by a 1Kohm + 1uF RC filter.<\/p>\n<p>The actual DD board uses SOT parts for smallness.<\/p>\n<p>But did my crazy broadcast plan actually work?!<\/p>\n<p>I set up a 3rd  XBee\u00a0 (had to hunt down a 3rd explorer board for this one&#8230;)\u00a0 in the <strong>same<\/strong> fashion as radio #2, except with ATMY = 3.<\/p>\n<p style=\"text-align: center;\"><a href=\"\/pics\/death\/blades_92.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"\/pics\/death\/blades_92-mid.jpg\" alt=\"\" width=\"512\" height=\"384\" \/><\/a><\/p>\n<p>The presence of a variable red light on both modules indicates to me that they are linked successfully. Probing DIO1 on radio 3 results in the same enable line toggling.<\/p>\n<p>So to wrap up the whole deal with PAN ID, broadcast, radio ID, and destination address (for my own future reference and sanity, as it took me <strong>forever<\/strong> to distinguish between them&#8230;).<\/p>\n<ul>\n<li>An XBee with ATMY <em>x<\/em> and ATDL <em>y<\/em> will talk to an XBee with ATMY <em>y<\/em> and ATDL <em>x<\/em> if they are on the <strong>same<\/strong> PAN ID <em>z<\/em>.<\/li>\n<li>An XBee with ATMY <em>x<\/em> and ATDL <em>FFFF<\/em> will talk to any other XBee on the same PAN ID <em>z<\/em>. But the others will only talk back if their ATDLs are set to <em>x<\/em>. The others may still converse amongst themselves if their ATDLs and ATMYs are appropriately set.<\/li>\n<li>Changing the PAN ID effectively creates another network, and there can be more XBees with ATMY&#8217;s <em>x<\/em> and <em>y<\/em> which will in turn only talk to eachother.<\/li>\n<li>Changing the active channel will create the above scenario all over again.<\/li>\n<li>A billion fucking XBees can therefore be in the same general vicinity and will probably still all work.<\/li>\n<\/ul>\n<p>I hope this is all correct. If it&#8217;s not, <strong>CORRECT ME<\/strong>. Otherwise I might go through life spreading the same lies and misinformation that I believe in, which puts me awfully close to being a politician.<\/p>\n<p>Time left until <a href=\"http:\/\/www.otakon.com\/\" target=\"_blank\">Otakon<\/a>: A month and a week. I think I can bang up a decent cosplay by then.<\/p>\n<h1>waiting on you, advanced circuits<\/h1>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been waiting to use that title for a long time. Building the &#8216;blades has been quite an exercise in unfamiliar territory. First, the skates will be using the Maxon DEC modules, which are essentially experimental with respect to the project, me having seen no other vehicles that use them (seriously &#8211; all other Google [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,63,62],"tags":[64,65],"class_list":["post-748","post","type-post","status-publish","format-standard","hentry","category-project-build-reports","category-razerblades","category-reference-posts","tag-air-gear","tag-air-treks"],"_links":{"self":[{"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=\/wp\/v2\/posts\/748","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=748"}],"version-history":[{"count":11,"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=\/wp\/v2\/posts\/748\/revisions"}],"predecessor-version":[{"id":759,"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=\/wp\/v2\/posts\/748\/revisions\/759"}],"wp:attachment":[{"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.etotheipiplusone.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}