Scratch-Built Quadcopter Project
By Eric Hahn and Thomas Teisberg
This page documents an autonomously-stabilizing quadcopter built entirely from scratch as a project for the Northrop Grumman High School Involvement Partnership mentorship program. The quadcopter was created over the 2011-2012 school year with a $400 budget.
Just so you know: This project is quite old.
Northrop Grumman's High School Involvement Partnership (HIP) provides selected students with the opportunity to work on an engineering project with local Northrop Grumman engineers. During the 2011-2012 school year, we teamed up to create a quadcopter, a four rotor helicopter, entirely from scratch. Starting from a $400 budget, over the course of the year, we selected parts, designed and modelled a frame, had a custom-printed circuit board made, and wrote code for our quadcopter. Once a month we met with our mentors at Northrop Grumman. Between these meetings, we put in numerous hours working on our quadcopter.
Our finished quadcopter was built and programmed entirely from scratch and is capable of autonomous stabilization. Below is a video of it in action:
Quadcopters are four-rotor helicopters that fly with two pairs of blades spinning in opposite directions. Unlike a traditional helicopter, all four blades on a quadcopter work together to produce upward thrust. The quadcopter's movement is controlled by varying the relative thrusts of each rotor. This design creates a more stable platform than traditional helicopters, making quadcopters ideal for applications such as surveillance and aerial photography.
From a technical perspective, quadcopters create an interesting challenge, since, in order to be balanced, the quadcopter must continuously make minute adjustments to the speed of each rotor to keep the entire craft level. Since performing these adjustments manually in real time would be extremely difficult, a flyable quadcopter must be able to make these adjustments autonomously. This requires that the quadcopter be nearly perfectly balanced and have a sophisticated control system that is continually making adjustments.
While traditional helicopters generate most of their lift with a single blade, the weight of a quadcopter is split between four separate rotors, two of which rotate opposite the other two. Because each rotor generates a portion of the total lift, the flight of a quadcopter is controlled by varying the the relative lift and torque of each rotor.
When a quadcopter is hovering in the air, each rotor is generating the same amount of lift and the torques of two sets of rotors cancel out, keeping the quadcopter from spinning. In reality, due to the many variables affecting a quadcopter’s flight, hovering is not a fixed setting, but rather the result of continuously adjusting several flight parameters based on sensor input.
A quadcopter can be thought of as having four controllable degrees of freedom: roll, pitch, yaw, and altitude. Motion along each degree of freedom can be controlled by adjusting the thrusts of each motor.
For example, to roll or pitch, one rotor's thrust is decreased and the opposite rotor’s thrust is increased by the same amount. This causes the quadcopter to tilt. When the quadcopter tilts, the force vector is split into a horizontal component and a vertical component. This causes two things to happen: First, the quadcopter will begin to travel opposite the direction of the newly created horizontal component. Second, because the force vector has been split, the vertical component will be smaller, causing the quadcopter to begin to fall. In order to keep the quadcopter from falling, the thrust of each rotor must then be increased to compensate.
This illustrates how the adjustments made for each degree of freedom must work together to achieve a desired motion.
Control System (Programming)
In order to reduce the overall cost, we created our control system from scratch. We based our control system on the Arduino Pro platform, an inexpensive microcontroller development board.
(Image by David Mellis. Creative Commons licensed CC BY 2.0)
Position measurement is provided by a Sparkfun IMU Digital Combo Board, a single circuit board that combines a 3-axis accelerometer and a 3-axis gyroscope. These two sensors together provide an accurate representation of the orientation of the quadcopter in the air. We used open-source code to convert the measurements provided by these two sensors into yaw, pitch, and roll measurements.
Motor control is handled by four inexpensive electronic speed controllers (ESCs). Each of these ESCs is independently controlled by a PWM signal sent from the Arduino microcontrollers, allowing for full maneuverability.
A Bluetooth radio is used to allow the quadcopter to receive commands from any Bluetooth-enabled device, including most computers and phones. We did the majority of our testing from a laptop, however we have also tested sending commands from an Android phone.
The primary goal was for our quadcopter to be able to autonomously stabilize itself. This is achieved by running three independent proportional-integral-derivative (PID) controllers, one for each of the primary three degrees of freedom: roll, pitch, and yaw. Since the altitude does not require continuous adjustment to maintain stable flight, that input was left to the user.
Each PID controller takes a control input, such as the pitch angle for the pitch controller, and a setpoint value. For stable hovering, the setpoint of each controller would be zero, the state where the quadcopter is perfectly level to the ground. To move, the setpoint can be adjusted up or down to make the quadcopter tilt in the desired direction of movement.
In real time, each PID controller calculates the proximity of the current control input to the setpoint, the rate at which the input is approaching the setpoint, and the length of time for which the input has strayed from the setpoint. These three calculations make up the proportional, integral, and derivative components of the control loop, respectively. Each of these components is manually weighed in a PID tuning process. Once tuned, each controller will produce an output that combines these three components into a motor value offset.
For example, the roll controller receives an input from the gyroscope sensor indicating the degrees that the quadcopter has rolled (tilted forward). After calculating and weighting each component, the controller calculates an offset between the front and back motors needed to correct for this tilt. If the quadcopter is tilted 10 degrees forward and the setpoint is 0 degrees, for instance, the roll PID controller would produce an output indicating that the front motor needs to receive significantly more power than the rear motor. As the front motor receives more power, the quadcopter will tilt back to level. In a properly tuned PID loop, the PID controller's output will cause the quadcopter to return to a level position without overshooting and tilting the other direction. Finding the correct tuning requires careful testing with the assembled quadcopter. See the testing section for more on PID tuning.
The output sent to each motor is determined by the combined effects of each of the three PID controllers. The front motor's speed, for instance, is determined by adding the roll controller's output and the yaw controller's output to a base speed set by the user.
All of these calculations are performed approximately every 12 milliseconds. If the rate is significantly slower than this, the quadcopter cannot correct fast enough to stay in the air, so optimizing the code to prevent delays was essential.
The first thing that we looked at before manufacturing our project was the time constraint that we had. Because we only met once a month throughout the school year, the ability to replace parts at a moments notice, and having cheap replacement parts, was an absolute must. 3-D plastic printing, or additive fabrication, is a relatively new style of manufacturing method that colleges and universities are now utilizing and researching as a means for an overall shorter production time. Because our project had a relatively short time constraint we utilized a Dimension uPrint 3-D printer at our school.
Next, we looked at different materials for the skeleton, or frame, of the quadcopter. After brainstorming a list of materials we eventually decided to use carbon fiber for the frame. We designed 3D printable plastic components to hold the pieces of carbon fiber together.
Designing a secure system to mount the electronics was also a challenge. Since a simple breadboard connecting the components with wires would not be durable enough for a final project, we began looking at creating a printed circuit board (PCB) to house all the electronics while providing an aesthetically pleasing design. To design the PCB, we used an open source program called Fritzing. We had our PCB design professionally printed and mounted it on top of the quadcopter.
Once the quadcopter was built, code was complete, and electronics were finalized, we began to began the process of tuning the PID loops to achieve stable flight. We began with 1-axis pinned testing. Pinned testing involves cutting power to one axis while looking at the quadcopter's ability to remain level and balanced on the remaining free axis. Because carbon fiber arrow shafts were used for both axes we were able to clamp steel rods on two adjacent tables and suspend the vehicle in between the tables with minimal friction. To test the performance of the quadcopter we would push up, under one of the motor blocks, and observe the time taken to reach level balance.
While running the motors, we began to adjust the P value of our PID controllers (see the control system section). When we pushed up on the bottom of the motors, higher P values resisted the push more strongly, while lower values seemed like we were spinning the quadcopter on a pinwheel. Through observation and testing we noticed that P values between 6 and 10 would bring the copter back to level flight forcefully enough and quickly enough for sustained flight. Lower values worked well in calm conditions while higher values kept the copter calm in windier conditions. Though it would return fast enough and provide enough resistance when we pushed up against the motor block, we noticed the need to increase the D value of our PID settings in order to ensure that smooth, non oscillating flight, would exist. Lower D values made the quadcopter return to level flight very slowly, while a high D value caused the quadcopter to oscillate violently, unprovoked. Ultimately we settled for a D value from 1.75 to 2.25 based on the environment we were flying in. Finally, we added a small amount of I to bring the quadcopter back to dead center after bumping it around. After we found the correct settings for one axis we pulled the tables apart, turned the copter ninety degrees and repeated the process for the final axis.
With our PID controllers tuned, we tested the quadcopter while it was fully tethered. As one of us observed from a distance, the other tied each axis loosely to a fixed object nearby to make sure the copter did not fly into anything. Early tests were very sporadic and difficult to control. Through testing we found the correct settings and conditions to ensure smooth and even flight.
The final phase of testing consisted of tying a string through a hole in the center of the quadcopter. With this loose tether, we reached the point where we could finally let go and watch it fly. After months of testing, designing, and tinkering around to get the vehicle in the air, we finally let go of the tether; we saw it soar through the air. As it circled above us, it remained well balanced against small gusts of wind.
Designing a quadcopter is simple. Building one requires precision. Developing the electronics and software to be able to fly under control, though, is the ultimate challenge. We developed a quadcopter that stably flies, accomplishing our goal of building an autonomously-stabilized quadcopter.
You can also check out the quadcopter's code here.
This project would not have been possible without the support of all of the people involved in the HIP Program at Northrop Grumman. We would especially like to thank our mentors for their support.