3D Printed Arduino Quadcopter_Instructables.pdf

9
http://www.instructables.com/id/3D-Printed-Arduino-Quadricopter/ Food Living Outside Play Technology Workshop 3D Printed Arduino Quadricopter by AwesomeAwesomeness on May 8, 2014 Table of Contents 3D Printed Arduino Quadricopter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Intro: 3D Printed Arduino Quadricopter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Step 1: Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Step 2: Parts List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Step 3: 3-D Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Step 4: I2C Accelerometer-Gyroscope setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Step 5: Building and wiring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Step 6: Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Step 7: Recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Transcript of 3D Printed Arduino Quadcopter_Instructables.pdf

Page 1: 3D Printed Arduino Quadcopter_Instructables.pdf

http://www.instructables.com/id/3D-Printed-Arduino-Quadricopter/

Food      Living       Outside        Play        Technology       Workshop

3D Printed Arduino Quadricopterby AwesomeAwesomeness on May 8, 2014

Table of Contents

3D Printed Arduino Quadricopter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro:   3D Printed Arduino Quadricopter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1:   Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2:   Parts List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Step 3:   3-D Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 4:   I2C Accelerometer-Gyroscope setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Step 5:   Building and wiring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Step 6:   Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Step 7:   Recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Page 2: 3D Printed Arduino Quadcopter_Instructables.pdf

http://www.instructables.com/id/3D-Printed-Arduino-Quadricopter/

Intro:  3D Printed Arduino QuadricopterOverview:

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 aquadicopter 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 acopter 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 ofbrushed 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 thatcan definitely be added.

Step 1: BackgroundMost 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, thoughtheir 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 tohover in a stable formation. Because of this stabilization, quadcopters are utilized for photography and video filming. Additionally, quadcopters and multirotors have beenutilized in disaster management and recovery efforts, police operations, military engagements, and agricultural applications. As technology has advanced and costs havecome down, many industries are finding that quadcopters can offer innovative solutions to their problems and help them reduce costs as well. Example designs that canbe 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 wefound that most quadcopter models made use of integrated circuits, tiny micro controllers, and brushless motors. Building a circuit for our copter seemed like a doabletask 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 workingunder 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 torqueabilities. 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 ourdesign. 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 makeuse 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 calleda 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 gravitationalpull, 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’sintegrated into goes from a standstill to any velocity, the accelerometer is designed to respond to the vibrations associated with such movement. It uses microscopic

Page 3: 3D Printed Arduino Quadcopter_Instructables.pdf

http://www.instructables.com/id/3D-Printed-Arduino-Quadricopter/

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 arecrucial for our design because they help decide which motors need to change speed in order to adjust and stablize.

Step 2: Parts ListThese are the parts and tools for which we used for our project:

-Wires

-Wire Strippers

-Wire Cutters

-Soldering Iron

-Tin Solder

-3-D Printer

-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 canhandle larger loads)

-Header Pins

-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 PrintingThe 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 quickconsideration 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 alsochose this medium because it would eliminate unnecessary weight. For designing the frame, we used the computer-aided design program Solidworks. If you haven’t hadthe 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 attachedthe 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. Ifyou 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 forSolidworks here and starting a new design. The process is simple and should be easy after having done the tutorials.

Page 4: 3D Printed Arduino Quadcopter_Instructables.pdf

http://www.instructables.com/id/3D-Printed-Arduino-Quadricopter/

File Downloads

diy_bottom_plate.stl (482 KB)[NOTE: When saving, if you see .tmp as the file ext, rename it to 'diy_bottom_plate.stl']

diy_motormount.STL (18 KB)[NOTE: When saving, if you see .tmp as the file ext, rename it to 'diy_motormount.STL']

diy_quad_boom.stl (12 KB)[NOTE: When saving, if you see .tmp as the file ext, rename it to 'diy_quad_boom.stl']

Step 4: I2C Accelerometer-Gyroscope setupTL;DR:

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 workfine, 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, sincemost 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 outputcorrelates 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 communicateslots 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 ofthe 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.

Wiring:

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 yourboard 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 isconnected 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.

Code:

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 ishttps://github.com/jrowberg/i2cdevlib. Click “Download Zip,” remember where you but it (probably desktop) and then unzip it. Open up the Arduino IDE program. Nowgo 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 knowmuch 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 uncommentone 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 accelerometerto 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

Page 5: 3D Printed Arduino Quadcopter_Instructables.pdf

http://www.instructables.com/id/3D-Printed-Arduino-Quadricopter/

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 differentoutput types.

File Downloads

MPU6050_calibration.ino (7 KB)[NOTE: When saving, if you see .tmp as the file ext, rename it to 'MPU6050_calibration.ino']

Step 5: Building and wiringThe 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 ofcurrent 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 muchabout 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). Thewiring 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. Theoutputs 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 inthe 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 themotors 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 theboard, 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 hindsightI'd suggest placing the accelerometer flat on your frame and then wiring it into the board. This should help with the accelerometer accuracy.

Page 6: 3D Printed Arduino Quadcopter_Instructables.pdf

http://www.instructables.com/id/3D-Printed-Arduino-Quadricopter/

Image Notes1. Wires from the motors connected to ground2. "Negative" end of the motors to the darlington3. Leads coming from the Arduino to the Darlington4. Lead connecting ground to the Darlington

Image Notes1. Leads coming from the Arduino connecting to our gyro/accel

Page 7: 3D Printed Arduino Quadcopter_Instructables.pdf

http://www.instructables.com/id/3D-Printed-Arduino-Quadricopter/

Step 6: CodingWe’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. Youshould 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. Theoutput 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 mathbehind 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 theoffset 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 asabove.

Page 8: 3D Printed Arduino Quadcopter_Instructables.pdf

http://www.instructables.com/id/3D-Printed-Arduino-Quadricopter/

File Downloads

quad.ino (14 KB)[NOTE: When saving, if you see .tmp as the file ext, rename it to 'quad.ino']

Step 7: RecommendationsThe 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 wantto 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 chipdirectly 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. Alternativelycould 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 withC/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.

Related Instructables

Custom ArduinoMicroQuadcopterConcept byjackjackboom

Quadcop Green/Black Shield ---QUADROTOR(video) bypreddy12 Magpi: The

Micro ArduinoGamingPlatformInterface byzippy314

Make a supercheap 3Dprinter usingrecycled partsby PracticalTechonlogy

Hexapoduino:tiny hexapod 3Dprinted, Arduinocontrolled bypictux

3dPrinted iPadMiniHoneycombCase (Photos) bysbanas

Advertisements

Comments

3 comments Add Comment

 jack bot says:  May 9, 2014. 11:46 AM  REPLYThat's what I'm building right now

 Jan_Henrik says:  May 9, 2014. 4:40 AM  REPLYvery cool!! Can you post a video of it Flying? :)