Create Announcement

This feature requires that you be logged in as a Google Classroom teacher and that you have an active class in Google Classroom.

If you are a Google Classroom teacher, please log in now.

For additional information about using Science Buddies with Google Classroom, see our FAQ.

Areas of Science Robotics
Aerodynamics & Hydrodynamics
Difficulty
Time Required Short (2-5 days)

Abstract

The program in the DIY Mini Drone: Arduino™ Altitude Control project uses a proportional controller to control the drone's altitude. A potentiometer is connected to one of the Arduino's analog inputs. The potentiometer sends an adjustable voltage to the Arduino, and the code converts this voltage to a target height. An ultrasonic distance sensor measures the actual height, and the code subtracts this from the target height to compute an error. It then increases or decreases the motors' speed by an amount that is proportional to this error, in order to move the drone back toward the target height and decrease the error. The factor multiplied by the error is called the controller's "gain." In this case, the control signal is a pulse-width modulation (PWM) signal sent to the motors using the Arduino analogWrite() function. Since the PWM signal must be a non-zero value to make the drone hover at a fixed height, the control signal also includes a bias term, and is calculated using this equation:

Equation 1:

While proportional controllers are very simple, they have one major limitation. They are subject to a steady-state offset error, meaning the drone will never actually reach the exact target height. While you can decrease the offset error by increasing the controller's gain, this can have undesired side effects like rapid, jerky motion of the drone, and you can never eliminate the error entirely with a purely proportional controller.

You can solve this problem by using a proportional-integral (PI) or proportional-integral-derivative (PID) controller. As the names imply, these controllers also change the motor speed by amounts that are proportional to the integral and/or derivative of the error. A PID controller has three gains: KP, KI, and KD. The control signal is calculated with the equation (note that technically a PI controller is just a PID controller where KD=0):

Equation 2:

The process of selecting the gain values for Equation 2 is called "tuning" the controller. A properly tuned controller will give the drone a response that is "just right," meaning that it will quickly return to the target height (this is called the "rise time"), without too much overshoot, oscillation (the "settling time"), or steady-state error. A poorly tuned controller can result in undesired or erratic drone behavior, like moving very slowly toward the target height, or rapidly shooting past it, then over-correcting and shooting past it again, etc.

Can you design a PID controller for your drone that results in optimal behavior? You may need to do some of your own research about PID controllers to get started. The Bibliography contains several references that may be useful. Refer to DIY Mini Drone: Arduino™ Altitude Control for instructions to build your drone. The circuit diagram is reproduced in Figures 1 and 2, and you can download working code for a proportional controller here. (Click these links for a bigger version of the diagram and the circuit schematic.)

Breadboard diagram for Arduino drone altitude control circuit
Figure 1. Breadboard diagram for Arduino drone controller.

Circuit schematic for Arduino drone altitude control circuit
Figure 2. Circuit schematic for Arduino drone controller.

Share your story with Science Buddies!

I did this project Yes, I Did This Project! Please log in (or create a free account) to let us know how things went.

Credits

Ben Finio, PhD, Science Buddies

Cite This Page

General citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.

MLA Style

Finio, Ben. "PID Controller Tuning for a Drone." Science Buddies, 10 Mar. 2021, https://www.sciencebuddies.org/science-fair-projects/project-ideas/Robotics_p036/robotics/drone-pid-controller?class=AQUTcehAYo11sl7aszZl6kr4-inaYLaU_DU6ES2tbZFf3VDkQUvuT-xMOAYl9hfMCN_C8SUVM6fP_vZLWX36smze6FlArFXs28ItpqCDAwO6xEfx1EAmuIzpZkfDMtk323E. Accessed 6 May 2021.

APA Style

Finio, B. (2021, March 10). PID Controller Tuning for a Drone. Retrieved from https://www.sciencebuddies.org/science-fair-projects/project-ideas/Robotics_p036/robotics/drone-pid-controller?class=AQUTcehAYo11sl7aszZl6kr4-inaYLaU_DU6ES2tbZFf3VDkQUvuT-xMOAYl9hfMCN_C8SUVM6fP_vZLWX36smze6FlArFXs28ItpqCDAwO6xEfx1EAmuIzpZkfDMtk323E


Last edit date: 2021-03-10

Bibliography

News Feed on This Topic

 
, ,

Share your story with Science Buddies!

I did this project Yes, I Did This Project! Please log in (or create a free account) to let us know how things went.

Ask an Expert

The Ask an Expert Forum is intended to be a place where students can go to find answers to science questions that they have been unable to find using other resources. If you have specific questions about your science fair project or science fair, our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Ask an Expert

Related Links

If you like this project, you might enjoy exploring these related careers:

Log in to add favorite
Career Profile
Have you watched "The Transformers" cartoon series or seen the "Transformers" movies? Both shows are about how good and evil robots fight each other and the humans who get in the middle. Many TV shows and movies show robots and humans interacting with each other. While this is, at present, fantasy, in real life robots play a helpful role. Robots do jobs that can be dangerous for humans. For example, some robots defuse landmines in war-stricken countries; others work in harsh environments like… Read more
Log in to add favorite
Career Profile
Humans have always longed to fly and to make other things fly, both through the air and into outer space—aerospace engineers are the people that make those dreams come true. They design, build, and test vehicles like airplanes, helicopters, balloons, rockets, missiles, satellites, and spacecraft. Read more
Log in to add favorite
Career Profile
Mechanical engineers are part of your everyday life, designing the spoon you used to eat your breakfast, your breakfast's packaging, the flip-top cap on your toothpaste tube, the zipper on your jacket, the car, bike, or bus you took to school, the chair you sat in, the door handle you grasped and the hinges it opened on, and the ballpoint pen you used to take your test. Virtually every object that you see around you has passed through the hands of a mechanical engineer. Consequently, their… Read more
Log in to add favorite
Career Profile
Just as a potter forms clay, or a steel worker molds molten steel, electrical and electronics engineers gather and shape electricity and use it to make products that transmit power or transmit information. Electrical and electronics engineers may specialize in one of the millions of products that make or use electricity, like cell phones, electric motors, microwaves, medical instruments, airline navigation system, or handheld games. Read more

News Feed on This Topic

 
, ,

Looking for more science fun?

Try one of our science activities for quick, anytime science explorations. The perfect thing to liven up a rainy day, school vacation, or moment of boredom.

Find an Activity
Free science fair projects.