Wow it’s been a long time since I’ve posted anything here. I promise I have not abandoned this blog or my quadcopter and I am going to try to post more often…

Anyway recently I have been working on getting the feedback loops to control the pitch and roll angles of my quadcopter so it will fly straight. At this point it is stable with a step input although it does oscillate a bit so I probably could make some improvements.

Currently the step responses for my two PID loops look like this:

As you can see there is till a bit of oscillation but I do have both axis’ stable which is the first step. Some of the oscillation I think is die to the fact that the kalman filter cannot track fast movements very well so when the quadcopter is rotating fast there is an inherent lang in the output of the kalman filter. This may or may not be an issue in the quadcopter since these loops are just used to maintain a constant set-point and should never be moving very fast. If I do have problems I think I might be able to improve this by running the kalman filter and sensor sampling at a faster rate than the feedback loop. I might investigate that in the future.

Somethings I have learned in this exloration with implementing PID loops:

There are two was of implementing derivative action in a PID loop; error feedback and rate feedback. In error feedback you take the derivative of the error the same as the integral and proportional parts. With rate feedback you take the derivative of the output and add that to the error and the integral of the error. The advantage of this is you don’t have any effects from a changing setpoint so normally you have less overshoot.

There is no worng choice between the two but I chose to use rate feedback in my quadcopter. One thing to note with rate feedback is you need a negative Kd or to subtract it from the Integral and Proportional parts else you get positive feedback and an unstable loop. That took me a while to figure out…

A couple important thing I learned about implementing the integrator. The first is to have some sort of anti-windup scheme implemented in your integration. I did it the easiest way by setting a saturation limit on the output of the integrator:

if(I_Value_Pitch >100)

I_Value_Pitch = 100;

else if(I_Value_Pitch<-100)

I_Value_Pitch = -100;

This way the output of the integrator will never go over 100. A wound up integrator can be very dangerous especially when dealing with propellers spinning at thousands of RPM.The second thing is to always reset the integrator when stopping and restarting the PID loop or it will quickly shoot off in one direction the moment you restart it.

Anyway with two stable PID loops next step see if I can get it to fly!

Andrew