I'm trying to make a quadcopter with Arduino. I already have the angles (roll pitch and yaw) thanks to an IMU. They are in degrees and filtered with a complementary filter. I want to apply a PID algorithm for each axis but I dont know if the inputs should be angles (degrees) or angular velocities in degrees per second so as to calculate the errors with respect referencies. Which will be the difference? Which will be the best way? 

Finally, another question about a PID code: I have seen that many people don't include time in their codes. For example, their derivative term is kd×(last error-actual error) instead kd×(last error-actual error)/looptime and something similar with the integrative term. Which is the difference?

Thank you in advanced.


3 Answers 3


I have seen three implementations of PID controllers for quadcopters. enter image description here

  1. Single PID control loop using only angle errors. (What I am currently using). I have heard people using this method with success. Example is this thread: ht tps://www . quora.com/What-is-rate-and-stabilize-PID-in-quadcopter-control.

    • Very intuitive since you are only assigning angle setpoints.
    • I have seen in my best tunings that there are still oscillations present which is about +-10degrees from the setpoint angle of zero. Though that is probably due to my lack of experience.
  2. Cascaded PID control loop using angular velocity for the Rate PID block and angle errors for the Stab (Stabilization) PID block. This is the most common implementation I've seen upon reading but I have difficulties in trying to find a suitable setup for tuning the Rate PID block since you are setting angular velocities instead of angle. (Will the same string on one axis setup suffice?)

EDIT: It is possible to "tune" the rate loop in the cascaded controller by setting first the angular velocity setpoint to zero and setting the inner loop PID gains until the quadcopter resists any change in motion (The quadcopter should when physically placed at any angle should resist motion or maintain that angle). After that a P-gain in the outer PID loop that would be responsible in translating the required angular velocity command to the inner PID loop to attain the user set angle setpoint/target from the outer PID loop

  • I have read in https://controls.engin.umich.edu/wiki/index.php/CascadeControl that cascaded control loops are used for their more responsive nature.
  • The inner rate PID loop is for control in high frequencies while the outer loop is for lower frequencies

    1. Additive PID control loop (What I'll be trying next)
  • I have seen this implementation in the work for my senior who was creating a stabilization control for her quadcopter.

  • She said that the Rate PID block is used to control sudden jerks while the quadcopter was hovering. She used only P and D.
  • However the quadcopter becomes unstable after 15 seconds of hovering due to tipping to one side possibly due to the lack of yaw control.

Regarding your question about PID controllers, you do need to take the loop time of your code into consideration. Here's a great read: http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/


It depends on what you want to control, either position or velocity. Generally a PID for the position (angles) is implemented, but in case you would be interested in velocity control you can also find some good materials at the voice 'Velocity PID'.

Regarding the second question, if the loop time is constant, it can be incorporated in the gain, that is:

$k_d$ = $k_d'/T$

So no differences, just a scaling factor.

  • $\begingroup$ The practice to incorporate the sample time $T$ within the PID gains is very much discouraged, because - as you can easily figure out - it hides the two contributions. It happens indeed very frequently that the PID is designed in the continuous time domain and only afterwards discretized. In this design process it is important to retain the information of the actual values of the gains (i.e. without the contribution of $T$). $\endgroup$ Oct 29, 2015 at 18:07

Making a quad with arduino is very difficult task. You will have to consider the delay taken by the reciever. For that you will have to use interupts to to collect the signals with out disturbing to process. And as you asked the input error will always be angles. You will have to change raw values to angles. And also before using pid, you will have to use the gyro values. You will have to use them in manner such that if angle of quad is disturbed in one axis then increase speed proportionaled to gyro out in that axis to react to the change. After that you will use pid. With out that. Its impossible. Ita my experience.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.