When I was first getting into multirotors, I didn’t have an RC transmitter and receiver pair to control a quadcopter with. But I did have a couple XBees and a Saitek PC USB Joystick. So, I made my own RC setup and I’ll show you how.

History

Mark I: Initial Prototype

My first version was very rudimentary. It was an XBee Series 1 and an Arduino nano on the quadcopter side and on the computer side was the joystick, an FTDI Basic and another XBee. The Ardunio nano was running a simple sketch which took serial commands in the form of 6 bytes in the range of 0-250 and a terminator byte, 254. The sketch interprets each of the first 6 bytes as a value to output on one pin, using the Arduino Servo library. To test it out, I plugged 6 servos into their respective pins and moved the joystick around and pushed buttons.

Mark II: Out of range kill switch

The biggest thing I was worried about was stepping on the gas and my quadcopter flying out of range and then off forever, to be found by highway workers, or worse – seeing on the news that “some mysterious device fell out of the sky and hit an unsuspecting person in the face”. So, I added some code to check if the receiver has gotten an update in the last two seconds, and if not, kill the throttle and disarm. It was originally written to auto-land, but I felt that it was too dangerous for both bystanders and the quad itself to have the motors (with blades!) spinning for ~20 seconds after control has been lost.

Mark III: Sum PPM

While chatting with some fellas and gals in the freenode #multiwii channel and I heard about “Sum PPM”, also known as “Serial PPM”. It’s a version of Pulse Position Modulation, the PWM protocol used to control a servo. The length of a pulse (how long the line is high) determines the servo’s position. The range is 1000 microseconds to 2000 microseconds. Which degrees the servo points to for each value is determined by whether it’s a 180° servo, or a 360° model.

Sum PPM squeeze all of the channels onto one wire instead of one wire for each channel. The first pulse will be for the first channel, the second pulse for the second channel and so on. It knows which channel is which, by having an extra long pulse of 5000 or more microseconds after all the channels have pulsed. The pulse following the long “sync” pulse is channel 0. So a full datagram for 4 channels may look something like this:

Mark IV: Deadbug

I thought this would be the final version. I have a bunch of DIP ATmega328 chips, so I decided to solder one up deadbug-style. It worked great and was much smaller than an Arduino Nano, but looked like… well, a dead bug! It just kinda hung there inline with the wires and there wasn’t really a nice way to keep it attached to the frame besides a rubber band. I also globbed it with hot glue to strengthen the connections and prevent shorts.

Mark V: Yes, this many revisions!

The major difference here is that I decided to switch to using a Roving Networks RN-XV Wifly Module. It fits in an XBee footprint which means I don’t have to change my receiver at all and I don’t need the XBee or the FTDI adapter on the laptop. Wifi has similar range to a Series 1 XBee anyway.

Here’s what the current model looks like:

Usage

Compatibility

I have tested it and it works on both MultiWii and Aeroquad when the configuration is set for Futubu. It looks like this in MultiWii:

How to make your own

I am currently considering designing a board which will fit an XBee pin-compatible radio and have a built in microcontroller if there is enough interest. But if you want to make one yourself, you’ll need:

The pins of the XBee explorer and the Arduino Pro Mini line up perfectly. With the Arduino Mini facing down, put the headers into the serial port (pins GND, VCC, RXI, TXO) and solder them in. I would put the short end of headers into the Arduino side. The pins will be sticking out of the bottom of the Arduino when you are done. This is a good time to upload the serial PPM sketch using an FTDI Basic.

Now, strip the ends of the male side of the servo cable. Then, with the Arduino Mini facing down, solder BLACK into GND on the Arduino, RED to VCC and WHITE to Arduino PIN 9. Make sure the wires are coming out of the bottom of the Arduino. This is so when we hot glue the boards together, the hot glue will hold the cable in place and reduce stress on the solder joints.

Flip the Arduino over. Slide the explorer on the headers, facing up. Make sure GND matches up with GND on both boards. Put some hot glue between the boards to help them stick together. Solder the explorer onto the headers. They are now permanently joined! You should have something like this:

Use it!

Set up your XBee or WiFly chip and insert it into the receiver. Get the code from joystick.py and make sure the pygame python module is installed.

If you are using a WiFly, make sure you set it up to do Ad-Hoc WiFi network and then connect to it from your computer once it is plugged in. Make sure the following line is uncommented when using a WifFly:

SERIAL_PORT = 'socket://169.254.1.1:2000'

Plug the receiver into your quadcopter. If you are running MultiWii, the signal (white wire) should be connected to DIGITAL 2 on an ATmega328 Arduino or DIGITAL 19 on a Mega.

Plug in your joystick and run joystick.py. It may take a minute to establish an IP address after connecting and you may see “no route to host”. Keep trying until it works. Once it does, you’ll see the values being sent to the receiver printed out every couple seconds to make sure it’s still alive. And you should be getting PPM output on your quad.

The receiver status LED will blink until it begins receiving commands and then will be solid.

Hve Fun! Here’s a few “flights” using one of the early versions:

Let me know in the comments if designing a custom board for purchase is something you are interested in.

After seeing hobbyist-oriented batch PCB services, such as Sparkfun’s BatchPCB and Laen’s OSHPark, I decided instead of squeezing an Arduino Mega and a DFRobotics shield into a plastic food container, I would make my own, compact PCB and send it out to be manufactured. To my dismay, it all worked on the first try!

Step 1: Establish requirements

There are some measures to cut cost and complexity (and thus board size) that were taken due to the nature of a multirotor. First, we can get rid of the voltage regulator circuit, since we will be powering the board with a 5v BEC such as this one or powered by an ESC motor controller with a BEC built in. This allows us to remove a voltage regulator and two electrolytic capacitors.

I also left out the FTDI USB serial converter. Thie probably cuts $10 off the board and we can just use a standard USB-TTL converter for all the boards to program them.

Step 2: Get it working on the breadboard

I’ve done breadboard Ardunio projects a bunch of times, so I’m pretty familiar with the process. I recommend trying it out, if you haven’t already. Here’s a good link for instruction: http://arduino.cc/en/Main/Standalone. I chose to use the MultiWii firmware for the quadcopter, which just needs 2 lines for I2C sensors, 1 line for Serial PPM from an RC receiver and 1 line for each rotor to control the motors.

Next, I needed to map out the pins.

For an ATmega328 microcontroller, which I chose to use for this project, the pins are as follows based on the diagrams from MultiWii:

Arduino Pin 3 -> Motor 1

Arduino Pin 10 -> Motor 2

Arduino Pin 9 -> Motor 3

Arduino Pin 11 -> Motor 4

Arduino Pin 2 -> Serial PPM Receiver

Arduino Analog Pin 4 -> Sensor I2C Bus SDA (data)

Arduino Analog Pin 5 -> Sensor I2C Bus SCL (clock)

Then I needed to map these pins to the ATmega328’s pins, since Arduino’s pins don’t match the microcontroller’s. So I used the following image, snagged from the Arduino.cc site.

Step 3: Pick out the parts

I bought all the crystals, capacitors, resistors, LEDs, headers and buttons on eBay, in quantities of between 20 and 100 each. For small quantities, I use Sparkfun. For the ATmega328P-AU, the SMT version of the microcontroller of the Arduino Uno, I went to Mouser which gives discounts with higher quantities. Each board needs:

I hooked it all up to a breadboard to test out with a through-hole version of the ATmega328 to make sure it was all working before doing the design.

Step 4: Design the board

Now that I’d figured out to get all the parts working together, it was time to figure out how do design a PCB. I read Sparkfun’s EAGLE tutorial a couple times to let it sink in. Then, I went and downloaded the free version of EAGLE and got started.

Then I roughly laid out the board, following the tutorial and just used EAGLE’s autorouter to route the traces.

Step 5: Fabrication

I was looking into various hobbyist PCB fabrication services and I was liking the DorkbotPDX service the most when I realized it had been just re-done and had become OSHPark.com. Since then, I’ve basically been using that site as a Gerber file viewer to see how my design will look on a final board. When I finally got to a point where I liked the board, I submitted my board and paid the $30 to have it fabricated and shipped to me. It took about 3 or 4 weeks to get them, but it was like Christmas when I did!

Step 6: Soldering

I’d never soldered SMT before, but Sparkfun has a tutorial for that, too. I laid down the ATmega328 on it’s pads and soldered one corner to tack it down. Then I laid globs of solder down on each side and used solder wick to pick up the excess. Since I didn’t have flux, it was very frustrating to do at first, but I finally got the hang of it. Looking under a magnifying glass, it looked like there were no solder bridges, so I crossed my fingers and hoped all the pads were making contact with the pins and moved on.

Next, I put in all the through-hole components in and soldered them. Nothing interesting there. Then I soldered the headers in, one at a time. They are tricky since they wiggle and end up crooked. Sparkfun’s parts library has some “lock” headers which have the holes jagged, for a tighter fit, and I wish I had used them.

Step 7: Programming

Time for the fun part. I bought an USBasp from ebay to program AVR microcontrollers which is why I used the 2x5 shrouded headers for ICSP. I plugged it into the computer and the board and once again crossed my fingers. The power LED didn’t light up. Dang! I decided to try to burn the Arduino firmware on there anyway. I launched the Arduino IDE and hit the “Burn Bootloader” button and the status LED began flashing! Yay!

I wondered what was wrong with power LED, so I took another LED out of the bag and touched the leads to the pads, thinking I had inserted the LED backwards, and it lit up. I checked the orientation and the LED was in the right way, but was either defective or burned up from soldering too long. I sucked the solder out and put the new LED and everything was operational with the default Arduino blinky sketch.

It was time to put MultiWii on. I downloaded the Arduino MultiWii project and customized the config to match up with the hardware and used my Sparkfun FTDI Basic to program it. Since I did not implement auto-reset, I had to hold the reset button until the Arduino IDE says it is uploading to the board.

I then launched the MultiWiiConfig application on my computer and saw the orientation of the sensors were wrong, so I fiddled with them for about and hour, re-flashing every time I tested a change. Once the orientation was correct, I decided it was time for a test.

Step 8: Installation

I hot-glued some standoffs on the plastic container and screwed the board onto the standoffs. Plugged in the BEC for power, plugged in the motors (easy thanks to the silkscreen) and plugged in the serial PPM receiver. Easy as pie, compared to using an Arduino where you have to constantly check out the MultiWii site to figure out which pins were which.

Then I plugged in the battery and, amazingly, I heard beeps from all 4 ESCs. Success!

I figured I had to make sure they were all working, so I armed to motors and all spun up. I took it out back and practiced my hover until my battery died.

This was my first PCB and my first quadcopter, though I have had the copter for a while now and I was able to get it working. If I could design a PCB and have it work on the first try, anyone can. Hobbyist electronics has really come a long way in the past few years.

Thank you to the open source community and a huge thank you goes out to Sparkfun for sharing all of their secrets with the general public.

As a side note, I had a Hawaiian themed party last week and we have a left over fake parrot. I figured it could help me keep track of the orientation of my quadcopter instead of forgetting which way it’s facing. Here’s how it looks:

It was not easy by any means, but I aced Udacity’s seven-week class, CS373: Programming a Robotic Car. I spent a few hours a week on homework and a few hours a week on classwork, with the seventh week being the final exam.

I had to brush up on some math concepts I started to forget, like matrix arithmetic and probabilities, but I was able to get through, thanks to the Khan Academy. Some of the topics I learned about were:

All in all, I learned a ton and I’m looking forward to trying out some of these concepts with quadcopters. I wish Udacity the best of luck and I’m looking forward to new and exciting classes from them and I hope they make Computer Vision one of them.