A Drone Made Out Of Lego Part 2: The Trees

This is a follow up post to Lego Drone Part 1. I’ll go into a bit more detail about the process and parts I used, and some of the lessons I learned along the way.

Making an Arduino Flight Controller

So much of the legwork for DIY Arduino flight controllers has been done by the MultiWii project. The long and the short of it is if you have an Arduino Uno, a gyroscope, and a tiny bit of Arduino experience, you’re most of the way to being able to set up a flight controller.

Wire up your gyroscope (and optional but highly recommended accelerometer and magnetometer), and you’re ready to upload the MultiWii software and test the orientation of your flight controller.

The gyroscope/accelerometer/magnetometer setup is commonly referred to as the Inertial Measurement Unit (IMU). Sources across the board recommend adding a bit of padding (such as foam or mounting tape) around your IMU to reduce vibrations. If your drone is made out of Lego there is nothing you can do to completely remove vibrations, so I recommend a large amount of foam.

Definitely the hackiest flight controller ever made.

Controlling an Arduino Flight Controller with XBees

Why use Xbees?

As I mentioned in Part 1, I chose to use XBees as my transmitter/receiver system mostly because I had a pair lying around, and did not want to splash out on a dedicated TX/RX system just for this project.  For short 2 way communication XBees are definitely overkill, since they have much more advanced capabilities:

In theory, many XBee series 1s can be connected together via a hub (though I have never done it). I like to imagine that one day this project will go far enough to have a network of Lego drones all working together, because everything is awesome when you’re part of a team. For now, though, just one drone will have to do.

How use Xbees?

The RC controller I made is a sort of crappy Lego PlayStation controller type thing. It uses two cheap analog thumb joysticks, and sends out the data from them via XBee. The code for the controller is here. The original code was written by Carl Strubens, who figured out how to do this sort of thing with Wii nunchucks.

Perhaps the hackiest dual stick controller ever made?

With help from the Sparkfun Xbee hookup guide, getting XBees to talk to each other is pretty straightforward. Getting XBees to talk to MultiWii was a little more involved than I had hoped.

The first hurdle to overcome is that the XBee shield is hardwired to use pins 2 and 3 for SoftwareSerial communication. Multiwii uses pin 3 for one of the motor controls. This is set deep in the code and I didn’t want to fiddle around with that, so I opted for a more physical solution.

It is possible to sever the connection to pin 3 on the XBee shield, and rewire it to pin 4. I used a flathead screwdriver to scratch across and break the line to pin 3, and then simply jumped a wire to pin 4.

Note that in the final version, reflected in the code linked below, I jumped to pin 6, not 4.

The second hurdle to overcome is that MultiWii does not inherently support XBee communication on a board with only one hardware serial port. The MultiWii code needs a bit of modification.

Making changes to the code

Engineer for Beer lays out some very clear instructions for how to modify the MultiWii code for XBee use. The instructions are a bit outdated for the newer MultiWii, but the overall steps are similar.

The specific changes I made for the newer version of MultiWii, my slightly modified XBee shield, and the custom controller that I made can be found on GitHub:


Modified files:
xbee-rc-controller.ino: the program that runs on the dual-stick controller
multiwii-xbee-mod/RX.cpp: delete contents
multiwii-xbee-mod/RX.h: delete contents
– multiwii-xbee-mod/xbee.cpp: receiver for XBee communication by Steve Holland modified for my system
– multiwii-xbee-mod/xbee.h: header for receiver code
– multiwii-xbee-mod/MultiWii.cpp: failsafe rewrites by Steve Holland, modified for newer MultiWii

Powering an Arduino Flight Controller

The battery you use to power your drone will be determined by its motors and propellers. More powerful motors will draw more current which will require a bigger battery. “Bigger” in this case means more milliamp hours (mAh) to spare, and a higher ‘C’ rating. Generally this results in a physically bigger battery as well.

“Milliamp hours” refers to the capacity of the battery; how many milliamps of steady charge will drain the battery in one hour. For example, if you have a 1000 mAh battery, and flying your drone steadily requires on average 10 amps (10 000 milliamps), your flight time will be about one tenth of an hour, or 6 minutes.

capacity (amp hours) = current drawn (amps) x time (hours).
1 amp hours = 10 amps x 0.1 hours

The ‘C’ rating is basically how much current the battery can supply at once. The safe operating current of a battery can be determined using the following:

Safe operating current (milliamps) = capacity (mAh) x ‘C’ rating

For example, a 1000 mAh battery rated at 10C will safely run at up to 10 000 milliamps, or 10 amps.

The point is to make sure you get a battery with a high enough C rating to provide as much current as your motors will draw based on the weight of your drone. You’ll likely find out how much that is on the manufacturer’s website, or through a quick Google search.

Pro Tip: take some extra time to wire in an easily-accessible physical power switch onto your drone. If the motors are spinning out of control you don’t want to be fiddling with cumbersome connectors. Trust me…

In Conclusion

Currently the drone has quite an obvious shake to it. I’m guessing this is caused either by vibrations messing with the IMU, or something out of whack with the PID calibration, or most likely both. Either way I have a lot more calibration to do, which is largely a matter of guesstimation and trail & error.

The drone also has a tendency to crash catastrophically, which I think is because of both the shake and my terrible piloting skills. Hopefully as both of these factors are improved upon I’ll have more stable flights to show.

I also have a few ideas to make this project even more awesome. “More awesome than a drone made out of Lego? Never!” I hear you say.  Ye of little faith. Of course I have to get the damn thing to actually fly well first, but after that the sky is the limit.

In short, this is not the last you’ll see of a Drone made out of Lego.