my quadcopter's settling time is very large, that is it sets its setpoint in very large amount of time, during which it has covered a large distance. But at settle point, when i gives it a jerk or push its returns to settle in normal duration. doesnt over shoots(little). The problem is with the settling time that is when i move the stick front or back it takes huge amount of time. what could be wrong. i have tried giving more P value and I value to PID but then it overshoots and get unstable. This is my PID program. the PID values are given. I read 6 channels from remote using the command pulsein(). which i guess is taking upto 20ms per command.

kp = 1.32;
ki= 0.025;
kd= 0.307;
void PID() {
  error = atan2(lx,ly);
  error *= 1260/22;   
  error = setpoint1 - error;   
  now = millis(); 
  dt = now - ptime;
  ptime = now;
  dt /= 1000;  
  integ = integ + (error * dt);
  der = (error - prerror) / dt;
  pidy = (kp * error); 
  pidy += (ki * integ);
  pidy += (kd * der); 
  prerror = error;

pidy is added and subtracted to esc speeds respectively.

  • $\begingroup$ It will be beneficial if you provide the graph of the response with the actual values of PID gains. $\endgroup$
    – CroCo
    Oct 11, 2015 at 13:34
  • $\begingroup$ I have no reach to take out the graph. but I will say that my quadcopter is imbalanced w.r.t weight on every side.(no extra weight, just usable elements). I tied it to rope. when not started, it is resting(tilting) on one side. when started it takes 15 to 20 seconds to level. now when i push it to tilt, it reaches back to its level in 1 to 1.5 secs. kp=1.32,ki= 0.025,kd= 0.307 $\endgroup$
    – Bilal Ayub
    Oct 11, 2015 at 13:40
  • $\begingroup$ Remove the D gain, or implement an observer. Numerical differentiation is bad practice. $\endgroup$ Oct 11, 2015 at 13:44
  • $\begingroup$ then longer osscilations are produced. But I havent practiced much without D gain. Will PI work?. $\endgroup$
    – Bilal Ayub
    Oct 11, 2015 at 14:02
  • $\begingroup$ A quadcopter can be stabilized withou any D gain. Don't add D unless you cannot stabilize your system. Tune firstly for P, while I and D are zero. You will probably observe some drift without I. Set I to prevent drift, but don't increase it more than necessary or it could cause instability. $\endgroup$ Oct 11, 2015 at 20:35

1 Answer 1


Typically when someone refers to settling time, it's time to achieve the desired target within some limit, and is usually in reference to oscillations about the desired target.

If you have a long time to reach a set position with little or no overshoot, it sounds to me like you have a long rise time and that maybe your controller is more damped than you would like. I would try increasing the proportional gain and/or the integral gain until you get a response that is closer to what you want.

  • $\begingroup$ i have tried higher gains for P and I, But then osscilations produce and very large. do I have problem in PID function, or do i need not to use D term, and also the program loop takes much time to complete so sample time increases, can that be a reason? $\endgroup$
    – Bilal Ayub
    Oct 11, 2015 at 17:07
  • $\begingroup$ ok, I have checked in my simulator. The reason is the sample timing. The problem is that the duration of reading pulses from the receiver is very large, due to which the sample time goes very large, resulting in bad stabilization. What should i do with the sample time. $\endgroup$
    – Bilal Ayub
    Oct 11, 2015 at 20:51
  • 1
    $\begingroup$ @BilalAyub - If you use a hardware interrupt to call your attitude control (PID loops for all axes), then you will probably find that you get much better control with little impact on your communications. $\endgroup$
    – Chuck
    Oct 12, 2015 at 12:41

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.