how to balance quadcopter
i bought gy-521 imu balance quadcopter.
now use value angle_x gyro control motors symmetric each other pid algorithm.
i roll , cant blance, me pls , thanks.
now use value angle_x gyro control motors symmetric each other pid algorithm.
i roll , cant blance, me pls , thanks.
code: [select]
void loop()
{
esc1.write(u1);
esc2.write(u2);
esc3.write(u3);
esc4.write(u4);
delay(200);
if (serial.available() > 0) {
cmd = serial.read();
}
if (cmd == 'a')
{
// value enough make quadcopter lift off ground
u1=46;
u2=110;
u3=115;
u4=113;
}
if (cmd == 'b')
{
//// stop motors
u1=0;
u2=0;
u3=0;
u4=0;
}
/////////////////////////////////// pid, balance quadcopter
unsigned long = millis();
double timechange = (double)(now - lasttime);
if(timechange>=sampletime)
{
errx= abs(0-angle_x);
err_del= errx - last_err;
if (angle_x < -9)
{
u1= u1 + kp*errx + kd*err_del;
u4= u4 + kp*errx + kd*err_del;
}
if (angle_x > 3)
{
u2= u2 + kp*errx + kd*err_del;
u3= u3 + kp*errx + kd*err_del;
}
last_err = errx;
//***********************************
delay(5);
}
}
what changes angle_x ? interrupt routine ? nothing in code posted seems update value based on sensor input .
ps.
you need tidy code.
i've never seen complex code, worked, messy.
sort out indentation, remove swathes of adjacent newlines, etc.
also. why use both blocking , non-blocking in same code ie have delay(5);
and code
if code works @ all, suspect delay pointless
ps.
you need tidy code.
i've never seen complex code, worked, messy.
sort out indentation, remove swathes of adjacent newlines, etc.
also. why use both blocking , non-blocking in same code ie have delay(5);
and code
code: [select]
unsigned long = millis();
double timechange = (double)(now - lasttime);
if(timechange>=sampletime)
if code works @ all, suspect delay pointless
Arduino Forum > Using Arduino > Project Guidance > how to balance quadcopter
arduino
Comments
Post a Comment