I have built quadcopter but the problem is of balancing. It doesn't goes up. I am using PID technique for balancing. But I am not finding the suitable values for PID tuning. I am using mpu6050 as a sensor. I get the accelerometer values of x and y axis and find the error from them. That is lets say if accel on x is not zero then it error cause it should be zero if balanced. I am using +-2g sensitivity scale of accelerometer. The motors I am using are DJI 920 kva. What values for kp
, ki
, and kd
should I set? I cant set them while in flight cause it completely out of balance.
This is the design. Completely homemade. I have modified it a little after this photo. An accelerometer is at 2g so at balance z will be 32768/2.
short PID()
{
short error,v;
error = desired-current;
//error/=390;
integ += error;
der = error - perror;
x = error;
x2 = integ;
x3 = der;
x* = kp;
x2* = ki;
x3* = kd;
v = kpi;x/=100;
v = kii;x2/=1000;
v = kdi;x3/=1000;
x = x+x2+x3;
//x/=390;
perror = error;
return x;
}
There are also few more questions, should I scale error or PID output? Because, the error is ranging from 0 to 16380 at 2g setting, so I am scaling it from 0 to 42. So should I divide error or PID by some value?
v=kpi
,v=kii
andv=kdi
statements intended to do? $\endgroup$