Can any one please help me with this code and PID tuning
void stabilize(){
P_x = (x_a+rad_tilt_LR)*0.48;
P_y = (y_a+rad_tilt_TB)*0.48 ;
I_x = I_x + (x_a+rad_tilt_LR)*dt_*0.0;
I_y = I_y + (y_a+rad_tilt_TB)dt_0.0;
D_x = x_vel0.0;
D_y = y_vel0.0;
//2.4 3.7 0.75
//YAW
P_z = (z_ang + wanted_z_ang)*0.4; //2.0
I_z = I_z + (z_ang + wanted_z_ang)*dt_0.0; //0.8
D_z = z_vel0.0; //0.3
if(P_z>160){
P_z = 160;
}
if(P_z<-160){
P_z = -160;
}
// D_z = 0;
// P_z = 0;
//3.2,4,0.6 works
//stop I from going berserk;
if(I_x>30){
I_x = 30;
}
if(I_x<-30){
I_x = -30;
}
if(I_y>30){
I_y = 30;
}
if(I_y <-30){
I_y = -30;
}
if(I_z>30){
I_z = 30;
}
if(I_z <-30){
I_z = -30;
}
x_adder = P_x + I_x + D_x;
y_adder = P_y + I_y + D_y;
}
I have found this code in this link and dont know how to tune the PID for my project.