I’ve been waiting to use that title for a long time.
Building the ‘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 – all other Google results seem to just be press releases). Having access to the DEC modules was the impetus behind me finally learning PCB design and layout. I just discovered the magic that is force-sensing resistors and how they can be used as an analog throttle.
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.
SOOOOOO CUUUUUUUUTE. It’s just like a really obese centipede with a silly hat! That transmits and receives data!
These little 2.4GHz, 802.15.4 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 X-CTU,a useful GUI tool for configuring the radios to do your bidding.
I yoinked two Xbee Adapter boards from MITERS’ neighboring student activities so I could easily throw together a breadboard assembly. 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 AD0/DIO0 and an “enable” signal, on AD1/DIO1.
On the receiving side, the radio has PWM0/RSSI hooked to the oscilloscope, along with its own AD1/DIO1. Digital I/Os are paired, but the analog ones have their own pins.
Conveniently enough, RSSI was connected to a red LED on the boards.
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 Rob Faludi’s XBee I/O page (props for being the number 1 Google hit for the exact words “Xbee Direct I/O”) and Digi’s own knowledge base page on the matter. Needless to say, RTFM came in handy also.
The things I changed from the default firmware settings for the transmitting side, all values in hex:
- Pan ID (ATID) = 9000, because… well, I could.
- Radio ID (ATMY) = 1, just a number again.
- Destination Address L (ATDL) = FFFF, which is the broadcast 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’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 listen to.
- Digital I/O 0 (ATD0) = 2, for this pin’s ADC mode, hooked to the 0-3.3v output.
- Digital I/O 1 (ATD1) = 3, for this pin’s function as a digital input, mapped to DIO1 on the other modules trained to it.
- I left ATIU off because I didn’t need the packet information from the radio’s serial ports.
- Number of samples before transmission (ATIT) = 1. I don’t know what the effect of changing this to a higher value does – perhaps to filter out noise or slow the rate of updates, but I decided to just transmit everything.
- Sampling rate (ATIR) = 1. The sampling rate can increment in 1ms resolutions. I decided that 1ms was fine.
- Input address (ATIA) = FF. This is the which radio is commanding my I/O lines option. In the case of the Tx, I set this to 0xFF, which is the “nobody” option, because… well, this is the transmitter. The receiver 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.
- PWM0/RSSI pin mode (ATP0) = 0. The transmitter won’t be putting out a PWM signal, so there is no need to set the pin.
From this, it seems that ATIA = FFFF and ATDL = FFFF will cause all radios to affect all other radios. I’m sure this is not actually the case, because that sounds like a nightmarish scenario.
Next, I set complementary values for the receiving side:
- PAN ID = 9000
- ATMY = 2 , this was arbitrarily the 2nd radio in my little network. It could have been the 987th.
- ATDL = 1, because it should talk only to the transmitter, not broadcast.
- ATD0 = 0, or disabled, since I’m not using DIO0 as a digital I/O.
- ATD1 = 4, for this pin’s digital output mode with a default setting of LOW. Logical low disables the DEC’s outputs, which I want. DIO1 is hooked to the enable signal on the FSR board.
- No ATIU, ATIT, or ATIR (left unchanged or default values)
- ATIA = 1. This trains the receiver to radio ID #1, which is my transmitter.
- And finally, ATP0 = 2, to couple it to the analog-to-digital coversion of DIO0 on the transmitter side.
- I set pin timeouts (ATT0 and ATPT) to 500ms so all the outputs return to their default states if no valid updates are received within that timeframe.
What does all this result in?
Well, first, nothing if I don’t hook up the VREF pin on the transmitting XBee. Which I didn’t. Comparing 3.3v to #NaN always results in bullshit.
But here’s a video of the wireless signal transmission working. The RSSI LED is being used as the PWM output here, and its brightness varies as I push down on the FSR.
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’s about 30%. This acts as a very (very) rough control deadband so random hand flicks don’t cause the motors to turn on.
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.
One catch: the DEC modules run 5 volt logic but the XBee runs on 3.3 volts! So I lied – even at full throttle, it means a direct signal would only have me crusing at around 66%.
Lame. So to validate one of the experimental parts of the “Double DEC’er” board, I made a small buffer that outputs 5 volts. Two 2n7000 signal FETs are wired sequentially in common-source mode, 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.
The actual DD board uses SOT parts for smallness.
But did my crazy broadcast plan actually work?!
I set up a 3rd XBee (had to hunt down a 3rd explorer board for this one…) in the same fashion as radio #2, except with ATMY = 3.
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.
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 forever to distinguish between them…).
- An XBee with ATMY x and ATDL y will talk to an XBee with ATMY y and ATDL x if they are on the same PAN ID z.
- An XBee with ATMY x and ATDL FFFF will talk to any other XBee on the same PAN ID z. But the others will only talk back if their ATDLs are set to x. The others may still converse amongst themselves if their ATDLs and ATMYs are appropriately set.
- Changing the PAN ID effectively creates another network, and there can be more XBees with ATMY’s x and y which will in turn only talk to eachother.
- Changing the active channel will create the above scenario all over again.
- A billion fucking XBees can therefore be in the same general vicinity and will probably still all work.
I hope this is all correct. If it’s not, CORRECT ME. 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.
Time left until Otakon: A month and a week. I think I can bang up a decent cosplay by then.