




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
this books is for review only
Typology: Cheat Sheet
1 / 222
This page cannot be seen from the preview
Don't miss anything!
Technology & Engineering/Drones
US $29.99 CAN $34. ISBN: 978-1-6804-5171-
Make: Drones
Inside Make: Drones, you'll find:
If you’re ready to get serious about drones and drone control systems, this is the book for you. Teach your Arduino how to fly today!
978-1-680-45171-
[LSI]
Make: Drones by David McGriffy
Copyright © 2017 David McGriffy. All rights reserved.
Printed in the United States of America.
Published by Maker Media, Inc., 1160 Battery Street East, Suite 125, San Francisco, CA 94111.
Maker Media books may be purchased for educational, business, or sales promotional use. Online edi- tions are also available for most titles ( http://safaribooksonline.com ). For more information, contact O’Reilly Media’s institutional sales department: 800-998-9938 or corporate@oreilly.com.
Editor: Roger Stewart Production Editor: Nicholas Adams Copyeditor: Charles Roumeliotis Proofreader: Rachel Head
Indexer: Ellen Troutman-Zaig Interior Designer: David Futato Cover Designer: Julie Cohen Illustrator: Rebecca Demarest
October 2016: First Edition
Revision History for the First Edition 2016-10-05: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781680451719 for release details.
Make:, Maker Shed, and Maker Faire are registered trademarks of Maker Media, Inc. The Maker Media logo is a trademark of Maker Media, Inc. Make: Drones and related trade dress are trademarks of Maker Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and Maker Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the informa- tion contained herein.
Preface
The successful people I have known all seem to have gotten there by some personal mix of talent, luck, and work. I hope that the mix turns out right in this book and that I succeed in inspiring you to make something. It will probably be a drone, but if it’s a great new garage door opener, I’ll count that as a success as well.
I have put my unique talents into this book, as you will into your project. I was born with a soldering iron in my hand, or almost, thanks to my father’s ham radio hobby. Also, largely due to his efforts, I started finding things to program when I was still a kid. I happen to love mathematics, which has served me well as a coder, of course. And there are several pilots on my father’s side of the family. But there are other threads in my life that led to drones.
From my mother’s side I get music. My love of music and my love of gear came together in recording technology. This led to computer audio and digital signal processing. And now we get back around to drones. Many of the very same algorithms I have coded for audio processing get used in drones to process sensor data and control inputs.
Add in some professional experience doing consulting in the control systems business, and perhaps you can see why I love building drones. It all comes together—building elec- tronics, flying, radios, programming, signal processing. But there was also some luck involved in the creation of Make: Drones.
My old friend Tim Deagan was working on his book, Make: Fire, and I shot some drone video of his fire projects. Then Roger, who would become our mutual editor, said, “Drones are hot, send me a book proposal on drones,” so I did.
Then there is the work. And I don’t just mean mine. Roger Stewart makes all those things happen that turn a bunch of files into a book on a shelf. Ron Parsons has saved me from many an error as technical editor. He also let me play on his Processor Technology Sol per-
ix
The following typographical conventions are used in this book:
Italic Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
This element signifies a general note, tip, or suggestion.
This element indicates a warning or caution.
Supplemental material (code examples, exercises, etc.) is available for download at http:// www.makedronesbook.com.
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to con- tact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from Make: books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Make: Drones by David McGriffy (Maker Media). Copyright 2017 David McGriffy, 978-1-680-45171-9.”
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at bookpermissions@makermedia.com.
Preface xi
Safari Books Online offers a range of plans and pricing for enterprise, government, educa- tion, and individuals.
Members have access to thousands of books, training videos, and prepublication manu- scripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more information about Safari Books Online, please visit us online.
Please address comments and questions concerning this book to the publisher:
Maker Media, Inc. 1160 Battery Street East, Suite 125 San Francisco, CA 94111 877-306-6253 (in the United States or Canada) 707-639-1355 (international or local)
Maker Media unites, inspires, informs, and entertains a growing community of resourceful people who undertake amazing projects in their backyards, basements, and garages. Maker Media celebrates your right to tweak, hack, and bend any technology to your will. The Maker Media audience continues to be a growing culture and community that believes in bettering ourselves, our environment, our educational system—our entire world. This is much more than an audience, it’s a worldwide movement that Maker Media is leading. We call it the Maker Movement.
For more information about Maker Media, visit us online:
Make: and Makezine.com: http://makezine.com Maker Faire: http://makerfaire.com Maker Shed: http://makershed.com
We have a web page for this book, where we list errata, examples, and any additional infor- mation. You can access this page at http://bit.ly/make-drones.
To comment or ask technical questions about this book, send email to bookques- tions@oreilly.com.
xii Make: Drones
And now we are getting closer to where the beauty lies.
As with the most interesting people and the best books, the real beauty of the multirotor drone is on the inside. An ArduCopter-based drone has four main inputs from two joysticks and four outputs to its motors. To compute those four outputs from those four inputs, it uses nearly three hundred parameters. At first it may appear that this is so complex as to be magic, but it’s not. It’s engineering. And precisely because of all the parts it doesn’t have, a drone turns out to be a wonderful platform to learn about engineering principles.
The algorithms used in drone control systems are basic, important, and beautiful. You’ll dis- cover that learning how to use them will be fun and interesting. But these methods have been around for decades. So whatever the aesthetics, they are not the breakthrough that made modern quadcopters possible. And make no mistake: there have been break- throughs.
I have flown radio control aircraft off and on for many years and have watched them with great interest since I was a kid. There have long been RC helicopters, but they were expen- sive and very hard to fly. Then there were toy helicopters, but to watch them fly is to know that they belong in the toy aisle. The military built cruise missiles, but they cost millions. Then one day a friend brought a quadcopter into the office. It would fit in your hand and it flew like an aircraft, not just a toy. And the punch line? It cost $20! Now that’s what I call a breakthrough.
So I bought one, then another, then a bigger one. Then I built one from scratch and started to modify the flight control code. After many crashes and much thought, I am now ready to say what has changed: motors, batteries, and control systems.
You will see several terms for the flying things we will build here. Some take “drone” to mean only a military system or vehicle that can fly autono- mous missions. Since it is by far the shortest, easiest word for it, I intend to use the word “drone” for just about anything that can fly without a human on board. The military actually calls them unmanned aerial vehicles (UAVs) and the FAA calls them unmanned aerial systems (UASs), but I use enough acronyms in my life without using one where a one-syllable word
like “drone” will do. The term “multirotor” leaves out fixed-wing aircraft and traditional helicop- ters, but describes everything we will build here. The term “quadcopter” describes an even more limited class—only those with four, not six or eight, props—but still covers all of our projects. We will use these words to differentiate our drones from fixed-wing or six-rotor vehicles when needed, but also sometimes just for vari- ety.
That first little quadcopter I saw at the office, like most micro drones, used tiny electric motors. They are smaller but look essentially the same as the small DC motors I bought 10 to a bag as a kid, but those were nowhere close to powerful enough to lift themselves. It
2 Make: Drones
Motors
turns out that there is an essential difference between the quadcopter motors and the motors I was familiar with. Like many motors these days, they use rare earth magnets, but that’s not the essential difference. These “coreless” motors (Figure 1-2) are optimized for aviation.
Figure 1-2 6 mm, 7 mm, and 8.5 mm coreless motors
The windings in small motors, like nearly all electric magnets, are generally made around a core of some ferrous material like iron. This makes the magnets more efficient—electrically efficient, that is. It turns out, however, that weight is more important than energy efficiency in aviation, so someone thought to take out that heavy core, and our tiny, flight-ready motors were born.
These coreless motors, used in smaller drones, are often called “brushed” to differentiate them from the sort of motor used in larger multirotors, which have no brushes. In most motors, brushes riding on a series of contacts control which windings get energized in what order. In a brushless motor, first developed for floppy disk drives (see Figure 1-3), electronics control the windings instead of contacts, making a simpler, longer-lasting motor.
Chapter 1 3
Figure 1-4 A selection of 1S and 3S LiPos
LiPos come in all sizes and shapes, from batteries the size of a thick postage stamp to bat- teries the size of a suitcase that can literally run your house or your car. Their capacities and capabilities vary accordingly. They can be rather finicky things compared to say, nickel– metal hydride (NiMH) batteries. LiPos don’t like to be left fully charged for long but don’t want to be stored completely empty either. Treat them wrong and it is pretty easy to ruin them, or worse. They have a bit of a reputation for catching on fire, but with a few reason- able precautions LiPos will allow us to do things no other batteries will.
In between the batteries and the motors is the control system. Even the tiniest micro drone has several subsystems, including radio receivers, gyros, accelerometers, and, of course, a processor to tie it all together. Since each of these components is just a little black chip on a circuit board that looks much like those out of any modern consumer electronics gadget, people may be less aware of the advances that have made modern drone control systems possible.
Before looking at what’s new, however, it’s worth pointing out that some parts of these lit- tle control systems date back years or even decades. The processors used are fairly modern, but the microcontrollers of several years ago could have done this job as well. On the software side, the algorithms used, including the Kalman filter and PID controller, have been used by control systems engineers since long before the microprocessor was inven- ted.
Chapter 1 5
Control Systems
Having acknowledged the great work of engineers past, however, some aspects of drone control systems do represent new breakthroughs. The general shrinking of electronic com- ponents in both physical size and power consumption makes smaller drones possible. Modern design and manufacturing techniques allow these tiny chips to be integrated into task-specific circuit boards that can be economically made in small numbers. A flight con- troller, containing all the subsystems mentioned above and more, can be put on a single board that you could lose in a shirt pocket.
At least one of the chips on that little board represents a breakthrough that is more spe- cific to aviation: the gyro. Gyroscopes have been used to stabilize aircraft since Lawrence Sperry demonstrated his gyroscopic stabilizer apparatus on a Curtis C-2 biplane to a French audience in June 1914. As mentioned earlier, radio-controlled helicopters were notoriously hard to fly, so someone eventually made a gyroscopic stabilizer for them. The first models used physical spinning disks, just like the children’s toys, and thus were rather large and heavy for all but the biggest model helicopters. The price of a single axis stabil- izer would buy a complete midsized quadcopter today.
Now we can get three gyros and three accelerometers in a single chip (Figure 1-5) and they only cost a few bucks, even in small, maker-friendly quantities. And this brings us to one more breakthrough and pleasant surprise. It’s nothing new for a consumer gadget like a drone to be made more cheaply in China. What makes this new world of micro aviation so exciting for makers is that Chinese manufacturing has resulted in a range of drone parts that we can buy in single units, mix and match, and make into our own designs.
Figure 1-5 A gyroscope module and its inspiration
6 Make: Drones