I am in deep confusion, i am balancing my quadcopter robot but it isnt going towards balancing. i have no remote control so that i change the kp ki kd values from that, i connect arduino to laptop then i change the kp and others and then test. i am not aware that what is the range of kp ki and kd in which i should keep changing and checking them. please atleast tell me that. the attachment given is my arduino file for quadcopter.
void PIdD()
{
float error;
error = (atan2(AcY,AcZ)180/3.14);
if(error>0)error=180-error;
else error = -(180+error);
//Serial.print("acy is ");
//Serial.print(AcY);
//Serial.print(int(error));
//Serial.print('\n');
error=0-error;
integ = integ+(errordt/1000) ;
der = (error - prerror)1000/dt ;
prerror=error;
pidx = (kperror);
pidx+=(kiinteg);
pidx+=(kdder);
if(pidx>1000)pidx=1000;
if(pidx<-1000)pidx=-1000;
//delay(dt);
}
This my pid() function, i call it in every loop. i have set dt = 1000; The AcY and AcZ are accelometer values. pidx is added used as.
esc2.writemilliseconds(700-pidx);
esc3.writemilliseconds(700+pidx);
esc2 and esc3 are symeterical motors escs. above 700 the motors starts spinning so i offset that.
My Mpu 6050 is placed upside down so the error signal is in refrence to that. Please help. whould be apreciated.
sketch_sep11d.ino (3.09 KB)