Electronic – arduino – Quadcopter Balancing with PID algorithm

arduinoimupid controllerquad-copter

I am doing a project on self balancing quadcopter with Autonomous control. I am using Arduino Mega 2560 and MPU6050. I have obtained the roll and pitch angles from MPU6050 without the help of DMP and applied complementery filter to omit the noise due to vibration. Also Configured and able to run the BLDC motors with Flysky Transmitter and receiver with the help of arduino interrupts. Now for balancing I am focusing on only one axis(i.e. roll). I have also constructed a balancing stand for the free movement of roll axis by the motor.

For the controlling part, I am implementing PID algorithm. I tried using only the kp value so that, somehow I can balance and then move on to ki and kd term. But unfortunately, for Kp itself, the quadcopter is undergoing aggressive oscillation and is not settling at all.

Some of my queries are,

  • whether a single PID loop is enough, or we have to add another
  • what type of tuning method, i can implement, to find the kp, ki, kd
    other than trial and error
  • I programmed my ESC for 1000 to 2000 microseconds. My PID input
    angles will be within the range +/- 180. Whether I can directly set
    the pid output limits for range -1000 to 1000 or -180 to 180 or any
    other value.

The code can read from the url https://github.com/antonkewin/quadcopter/blob/master/quadpid.ino

Best Answer

PID isn't a magic tool to accomplish all tasks, rather an universal method of control. Your oscillations are probably due to too much high Kp setting. Probably your control loop is missing some trivial part which is feedforward control path that would help a lot.

The picture below is representing a static characteristics where two world differ: the closed loop control theory (ger. Regulierung) and open loop theory (ger. Steuerung) The small letters refer to closed loop, which is superimposed on static characteristics in the working point.

enter image description here

These two worlds can be combined together by means of feedforward control path. The closed loop is trying to reject the disturbance, while the feedforward path is injected to the output of the controller. This feedforward path could be a static value as well dynamically changing value. For example if you know the speed of the copter blades "a priori" then you can fed this information right at the output. This would now be your working point as depicted in above characteristics.

enter image description here