Sunday, 5 February 2012

How to Find PID Constant For Quadrocopter? How to Tune PID For Quadrocopter?

Well, I am not really in to control systems and considering my limited knowledge, I can't say much about it. I have read a lot of sources but I can easily tell you that many of them is not as good as the version, I made. This is totally a practical way of finding and tuning constants. (I wrote this post few days ago and I was thinking that this is not a good post because I did not tell you anything about PID itself and the rest of control loop. Don't worry I will)

What you have to do at first is holding one of the axis and let it rotate over it.

Now make a the following line of code:
Speed = Trust + Kp(error) + Ki(delta_error)*(delta_time)  + Kd *(delta_error)/(delta_time)
so the problem is solved now you have Kp, Ki and Kd. I was just joking now the main part will start.

I would like to suggest you to make a program which lets you change the values of Kp, Kd and Ki in an appropriate resolution while running the PID . I used my computer key bored to increase and decrease each constant.

Set Kp and Ki to zero. Increase Kd to the point that your quad does not rotate in any direction. For testing make trust as high as the speed which gives enough trust to your quad to fly with 4 motors. Keep in mind right now you are just using two motors which are placed in one axis. The other axis is hold. In this situation, you should have something like the structure here.

Now keep increasing Kd till the point that your quad does not rotate. It does not need to stay at flat angle but it should remain in one angle. You should be able to change the direction by adding extra force.

Now, increase Kp to the point that your quad will be able to get to certain angle, if you rotate it has to come back to the same angle. Keep in mind that this angle should not necessarily be zero (flat).

Now increase Ki, to get to the zero angle which is your desired. This always worked for me.

Let me know your result if you tried. Thanks.

1 comment:

  1. I was looking for something like this..Really a nice post... Good one

    How to make a Quadcopter

    ReplyDelete