After scavenging the web for cheap methods of constructing a quadicopter and coming up with no viable solutions, we decided that it would be best if we created a quadicopter of our own. With a bit of electronics experience and a small budget, we were able to create a model that cost right around $60. Our model sought to create a copter that could run on its own power supply, and hover and stabilize its flight. Using components such as an Arduino Uno, a gyroscope/accelerometer, and a set of brushed RC motors, we were able to produce a working quadcopter. Though this particular design did not implement a method for controlling flight it is something that can definitely be added.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Background
Most of you may already know what a quadcopter is, but for those who don't, here is a quick description of what they are:
A quadcopter is multi-rotor copter with four arms, each of which have a motor and a propeller at their ends. Quadcopters are similar to helicopters in some ways, though their lift and thrust comes from four propellers, rather than just one. Also, helicopters have a “pitch” or tail rotor that helps stabilize the craft, whereas quadcopters do not. In a quadcopter, two of the propellers spin in one direction (clockwise) and the other two spin the opposite direction (counterclockwise) and this enables the machine to hover in a stable formation. Because of this stabilization, quadcopters are utilized for photography and video filming. Additionally, quadcopters and multirotors have been utilized in disaster management and recovery efforts, police operations, military engagements, and agricultural applications. As technology has advanced and costs have come down, many industries are finding that quadcopters can offer innovative solutions to their problems and help them reduce costs as well. Example designs that can be bought are linked here.
So now that you know a little more about quadcopters, let's jump into how we made one:
The first step in our design process was to look at current systems in the market in order to get an idea as to what components we needed. After doing some research we found that most quadcopter models made use of integrated circuits, tiny micro controllers, and brushless motors. Building a circuit for our copter seemed like a doable task and we knew we wanted to work with an Arduino, so this project definitely seemed achievable. The major issue would lie with the motors. Because we were working under a budget, brushless motors were out of the question. These motors range from $20 to $60 a piece, and in order to function these motors require speedcontrollers. So we were left with the option of choosing brushed motors. Because we knew we wanted to build a small quadcopter, we decided to look at motors that had low torque abilities. We then found an existing quadcopter model that used a set of viable motors. These motors could easily lift up to 55 grams of wieght, which was plenty for our design. We then purchased these motors here, and moved on to ways for which we could stabilize these motors. One method of stabilizing these motors was to make use of gyroscopes and accelerometers. A gyroscope is a device that uses Earth’s gravity to help determine orientation. Its design consists of a freely-rotating disk called a rotor, mounted onto a spinning axis in the center of a larger and more stable wheel. As the axis turns, the rotor remains stationary to indicate the central gravitational pull, and thus which way is “down.” An accelerometer on the other hand is a compact device designed to measure non-gravitational acceleration. When the object it’s integrated into goes from a standstill to any velocity, the accelerometer is designed to respond to the vibrations associated with such movement. It uses microscopic crystals that go under stress when vibrations occur, and from that stress a voltage is generated to create a reading on any acceleration. These two components are crucial for our design because they help decide which motors need to change speed in order to adjust and stablize.
Step 2: Parts List
These are the parts and tools for which we used for our project:
-3.7 Volt Lithium Ion battery pack (We used some AA Trustfire Batteries)
-ULN2003A Darlington Transistor (Note: We found that this transistor malfunctioned if we rev'd up the motors to max capacity so we suggest getting a transistor that can handle larger loads)
-0820 Coreless Motors (http://www.amazon.com/Hubsan-H107-A23-Clockwise-Co...
-Propellors for Motors(http://www.amazon.com/Hubsan-Quadcopter-Propellers...
-Arduino Uno (http://www.amazon.com/Arduino-UNO-SMD-R3-board/dp/...(We suggest buying an Arduino Uno Rev 3)
-Triple Axis Accelerometer and Gyro Breakout - MPU-6050 (Bought on sparkfun.com though you can find a cheaper one on amazon)
Step 3: 3-D Printing
The next part of our design process was to create the actual frame of our quadcopter. We had many options as to the material of choice for our frame, but after quick consideration we chose to go with 3-D printing. We had the great opportunity to have worked with 3-D printing before so it only seemed natural to print our frame. We also chose this medium because it would eliminate unnecessary weight. For designing the frame, we used the computer-aided design program Solidworks. If you haven’t had the chance of working with this software, I strongly suggest you go and try out a trial version of the software. We have saved you the time and effort and have attached the files for the 3-D print below. These files are saved as a stereolithography file (.stl file) and can be edited to some extent using CAD software such as Solidworks. If you end up buying larger motors, you can edit the motormount file below and change the parameters. If this doesn't work I suggest reading up on some turorials for Solidworks here and starting a new design. The process is simple and should be easy after having done the tutorials.
Step 4: I2C Accelerometer-Gyroscope Setup
1. DO NOT CONNECT TO 5V.
2. Don’t freak out.
3. Use this library: https://github.com/jrowberg/i2cdevlib
4. Don’t solder your board in until you’ve run a calibration.
We used a MPU6050 from SparkFun, https://www.sparkfun.com/products/11028. These can be found on Amazon for only $10, and I have it on good word that they work fine, but the wiring will be a little different from the pictures. This step will serve as a generic background and tutorial for setting up and using an I2C accelerometer, since most of this information is scattered among a dozen forum threads.
What is I2C?
You may have seen simple boards such as https://www.sparkfun.com/products/9269 with individual analog outputs for X, Y and Z. Those make sense; each output correlates to an axis of the accelerometer. Then you see an I2C board and freak out a little bit inside. I2C is a communication standard where the board communicates lots of information using digital logic pulses instead of analog outputs. The MPU6050 has 6-axises (3-gyro, 3-accelerometer) so if they were analog they’d use up all of the ports on your Arduino. The bottom line is the Arduino sends a digital control signal to the board, and reads in information digitally from the input pins.
The wiring for our specific MPU6050 is as follows. Note the library code assumes these are the inputs used. Other boards will be similar.
VDD -> 3.3v
GND -> ground
INT-> digital 2
SCL -> A5
SDA -> A4
VIO -> ground
Running 5v through the board can and will break it, so don’t. Some MPU6050 boards have voltage regulators that should protect it, but it’s not worth the risk. If your board has an AD0 pin, it should be connected to ground. On our board the VIO port is connected to an internal AD0, so it serves as the AD0 pin. Whether the AD0/VIO is connected to ground or VDD actually determines the memory address that the board interfaces with the Arduino (0x68 or 0x69). If this is confusing, don’t worry about it, just wire it to ground. If you have problems try switching VIO/AD0 from ground to VDD.
Now things get a little tricky. Hopefully you have a little coding / messing with software experience. If you don’t, just go slowly and google anything you don’t know. There is a lot of information out there. I’ll try to be as clear as possible, but I can’t cover all problems
Once you have your MPU wired to the Arduino, turn it on and upload this I2C scanner code: http://playground.arduino.cc/Main/I2cScanner#.Uxh...
Scroll to the bottom and copy-paste the code into an empty sketch and run it. Open the serial monitor (Tools->Serial Monitor) and make sure you are on port 9600 (bottom left). That’s in the code, but you didn’t read it anyway.
If everything works it should find an I2C device and give you a memory address of either 0x68 or 0x69. Write it down. If you get errors check the wiring.
Now you’re going to want to install code that actually talks to the accelerometer/gyroscope. There is a bunch of stuff out there but the one I’ve found which works best is https://github.com/jrowberg/i2cdevlib. Click “Download Zip,” remember where you but it (probably desktop) and then unzip it. Open up the Arduino IDE program. Now go to sketch->import library -> add library. You should add both the I2Cdev folder and the MPU6050 folders as libraries (they’re under Arduino in the folder).
Once they’re installed you should open up the MPU6050_DMP6 (it’s under MPU6050 -> Examples) file in Arduino. I’d suggest reading it over (even if you don’t know much code), it’s well commented and has a some options of how it outputs the readings from the board. If you got at 0x69 from the scanner, you’ll need to uncomment one line at the top of the code (after the #includes; just read the comments silly) since the default is 0x68. The program should now compile.
Upload the code, open the serial port (115200 this time) and follow the instructions. Congrats, you should get working readings from the board. If it seems to drift at first, don’t worry it needs about 10sec of being still to come to a rest. Also the yaw output will drift (a little), as it has no frame of reference. The board uses the accelerometer to get gravity and find “down” which act as a reference for pitch and roll. Some fancier boards contain a compass for reference.
Now before you move on, you’ll want to calibrate your board. Find a level surface and make sure your board is flat with the labeling upwards.
You should then run this handy-dandy calibration code available at the top, thanks to Luis Ródenas. Again the default it 0x68, but you can change that. Make sure you write down the offset values it gives you. You can and should use these as the offsets in the MPU6050_DMP6 code (and later our quadcopter code).
You now have a working and useful accelerometer/gyroscope. I’d now suggest you spend some time messing with the MPU6050_DMP6 code and trying the different output types.
Step 5: Building and Wiring
The wiring of the accelerometer is discussed above. The next step is getting the Arduino to control the motors. The Arduino itself is only able to output a small amount of current and voltage, so instead of wiring the motors directly to the digital out put pins, we use a darlington transistor pair to "amplify" the voltage. If you don't know much about transistors, we basically use the transistors as an on/off switch for a larger current coming directly from the battery.
You should start by bread boarding the circuit. For this step you'll need the Arduino, the motors and a darlington transistor pair (as well as a breadboard and wires). The wiring can be seen above, but I shall explain what is going on. Wire four of the digital PWM outputs (labeled with a ~ on the Arduino) to the darlington as shown. The outputs then go into the motors, which are wired to your power source. I'd start testing with a 5v power source, but a 3-5v battery should be fine for the final result.
Make sure your darlington is grounded and that you connect the ground on your Arduino to the ground from your power supply. Make sure that your rotors are spinning in the right direction (to get lift) and so that the total torque is zero. If you switch the motor lead from 5v to the darlington the motor will switch directions. Once you have the motors set up right, the rotors will never need to switch directions, just change speed.
Once you've tested everything, and have your accelerometer up and running, you'll want to solder everything onto a ProtoBoard. Don't solder the darlington directly to the board, you'll want to use a socket in case you need to replace the darlington. We soldered the accelerometer directly to the board and the re-calibrated, but in hindsight I'd suggest placing the accelerometer flat on your frame and then wiring it into the board. This should help with the accelerometer accuracy.
Step 6: Coding
We’ve written some code that should stabilize the quadcopter and hold it steady. If you want fancier movement and/or controls feel free to use this as a base. You should first install the Arduino PID library available here: http://playground.arduino.cc/Code/PIDLibrary
I’d suggest reading the link for the coding technicalities, but I’ll give a quick overview. The PID class takes three inputs: a set-point, a measurement, and an output. The output should change the measurement in some way, and the PID will vary the output to get the measurement to match the set-point. There are a lot of fancy math behind the library, but it attempts to do so in a way that the values remain stable.
In our stabilization algorithm we have two PID controllers: one for pitch and one for roll. The offset in speed between propeller 1 and 2 is guarantied to be the same as the offset between propeller 3 and 4. Similarly for 1,3 and 2,4. The PIDs then change the offsets in order to keep the pitch and roll at zero.
You'll also want to make sure you know which digital output pin on the Arduino goes to which motor, and then change the code accordingly. The motors are labeled as above.
Step 7: Recommendations
The biggest problem with a small quadcopter is money and weight. You could look into finding bigger/stronger motors, but there really aren't better ones unless you want to make the switch to brushless motors. Brushless motors are much nicer, but you'll need speed controllers, and all together it'll end up costing an addition $90.
To reduce the weight we'd suggest buying a SainSmart UNO R3 (or an older Arduino model) because the main chip is detachable. This means you can solder the chip directly to your ProtoBoard which will reduce about 30 grams of weight. You'll need to wire in a clock and some capacitors, but there is plenty of help online. Alternatively could also use an Arduino Pro Mini https://www.sparkfun.com/products/11113 which might be easier.
The code we've written can also be easily extended to add more functionality. The key is that the copter is able to self stabilize. You'll need to be comfortable with C/Arduino, but there is a lot of room for adding new functionality and improvements. If you want to make it remote controlled, I'd look into using bluetooth: https://www.sparkfun.com/products/12576. Nothing used here costs too much so you can play around with different parts. Thanks for reading.
Participated in the
Launch It! Contest
Participated in the
Participated in the