Question about Automatic Drone Balancing activity

Ask questions about projects relating to: aerodynamics or hydrodynamics, astronomy, chemistry, electricity, electronics, physics, or engineering

Moderators: kgudger, bfinio, MadelineB, Moderators

Post Reply
hbenac
Posts: 2
Joined: Wed Nov 09, 2022 2:12 pm
Occupation: Parent

Question about Automatic Drone Balancing activity

Post by hbenac »

Type your question below and then press Submit!
Hello!
The code is acting very weirdly, changing ki makes the speedchange grow bigger infinitely.
also the joysticks shows it works on the serial monitor but the drone can't keep up. it doesn't respond somehow.
can you please help?
thank you so much!



-------------------------------------
Leave this to help the Experts:
The activity can be viewed at: Automatic Drone Balancing
bfinio
Expert
Posts: 761
Joined: Mon Aug 12, 2013 2:41 pm
Occupation: Science Buddies Staff
Project Question: Expert
Project Due Date: n/a
Project Status: Not applicable

Re: Question about Automatic Drone Balancing activity

Post by bfinio »

Hi - PID control is a pretty advanced topic, very small changes to the controller gains can result in very large changes in the drone's behavior. Integral control (the Ki variable) can result in "drift" where as you noticed the error just keeps accumulating so the speed change will just keep getting bigger and bigger. You can prevent this in your code by adding an IF statement to prevent the speed change from going above (or below) some maximum value, for example:

if(speedChange > maxValue){
speedChange = maxValue;
}

Here, for example, if your maxValue is set to 1000, then every time your speedChange variable goes over 1000 (becomes 1001), the IF statement will reset it to 1000, preventing it from ever going higher than 1000.

Depending on the gain settings and how fast you move the joystick, the drone may not be able to keep up. If you are having a lot of trouble with this project, we recommend doing the altitude control version with an ultrasonic sensor first, it is generally easier to get this one working:

https://www.sciencebuddies.org/stem-act ... de-control

Hope that helps!
Post Reply

Return to “Grades 9-12: Physical Science”