ROLL & PITCH - PID Tuning

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
User avatar
jaysonragasa
Posts: 53
Joined: Wed Jan 28, 2015 6:40 am
Location: Philippines
Contact:

ROLL & PITCH - PID Tuning

Post by jaysonragasa »

Hi,

I was implementing this ROLL & PITCH - PID Tuning in MW2.4 code but I have to say, my implementation may be lame for most of you but I need some help.

ROLL & PITCH - PID Tuning are done using sticks and when disarmed.. sorry but that's all I can do right now. I'm not a C++ guru but I know programming.

YAW LEFT is for ROLL
YAW RIGHT is for PITCH

incrementing the PIDs:
P = ROLL LOW + PITCH HIGH
I = ROLL CENTER + PITCH HIGH
D = ROLL HIGH + PITCH HIGH

decrement the PIDs:
P = ROLL LOW + PITCH LOW
I = ROLL CENTER + PITCH LOW
D = ROLL HIGH + PITCH LOW

so if you want to increase the ROLL P
you have to do this
THROTTLE CENTER + YAW LEFT + ROLL LOW + PITCH HIGH

here's the entire code

Code: Select all

/*
   ROLL and PITCH PID tuning when disarmed
   THR_HI, THR_LO
   YAW_LO, YAW_CE, YAW_HI

   ROL_LO, ROL_CE, ROL_HI
   PIT_LO, PIT_CE, PIT_HI
*/
uint8_t PID_INC = 1; // this can be moved after the "i" variable
// ROLL PID
// PPPPPPPP
if (rcSticks == THR_CE + YAW_LO + PIT_HI + ROL_LO) // increase P
{
   conf.pid[ROLL].P8+=PID_INC;
   blinkLED(2,40,1);
   i=1;
}
else if (rcSticks == THR_CE + YAW_LO + PIT_LO + ROL_LO) // decrease P
{
   conf.pid[ROLL].P8-=PID_INC;
   blinkLED(2,40,1);
   i=1;
}
// IIIIIIIII
else if (rcSticks == THR_CE + YAW_LO + PIT_HI + ROL_CE) // increase I
{
   conf.pid[ROLL].I8+=PID_INC;
   blinkLED(2,40,1);
   i=1;
}
else if (rcSticks == THR_CE + YAW_LO + PIT_LO + ROL_CE) // decrease I
{
   conf.pid[ROLL].I8-=PID_INC;
   blinkLED(2,40,1);
   i=1;
}
// DDDDDDDDD
else if (rcSticks == THR_CE + YAW_LO + PIT_HI + ROL_HI) // increase D
{
   conf.pid[ROLL].D8+=PID_INC;
   blinkLED(2,40,1);
   i=1;
}
else if (rcSticks == THR_CE + YAW_LO + PIT_LO + ROL_HI) // decrease D
{
   conf.pid[ROLL].D8-=PID_INC;
   blinkLED(2,40,1);
   i=1;
}

// PITCHC PID
// PPPPPPPP
if (rcSticks == THR_CE + YAW_HI + PIT_HI + ROL_LO) // increase P
{
   conf.pid[PITCH].P8+=PID_INC;
   blinkLED(2,40,1);
   i=1;
}
else if (rcSticks == THR_CE + YAW_HI + PIT_LO + ROL_LO) // decrease P
{
   conf.pid[PITCH].P8-=PID_INC;
   blinkLED(2,40,1);
   i=1;
}
// IIIIIIIII
else if (rcSticks == THR_CE + YAW_HI + PIT_HI + ROL_CE) // increase I
{
   conf.pid[PITCH].I8+=PID_INC;
   blinkLED(2,40,1);
   i=1;
}
else if (rcSticks == THR_CE + YAW_HI + PIT_LO + ROL_CE) // decrease I
{
   conf.pid[PITCH].I8-=PID_INC;
   blinkLED(2,40,1);
   i=1;
}
// DDDDDDDDD
else if (rcSticks == THR_CE + YAW_HI + PIT_HI + ROL_HI) // increase D
{
   conf.pid[PITCH].D8+=PID_INC;
   blinkLED(2,40,1);
   i=1;
}
else if (rcSticks == THR_CE + YAW_HI + PIT_LO + ROL_HI) // decrease D
{
   conf.pid[PITCH].D8-=PID_INC;
   blinkLED(2,40,1);
   i=1;
}
/*PID tuning end */


my problem right now is, the only thing that is working there is decreasing the I and D and I am not about the other problem I am having but I know the stick command is correct.

So here's what is working (FOR ME)
THR_CE + YAW_LO + PIT_LO + ROL_LO = decreases the ROLL I -- This is wrong, it should decrement the P .. not sure what's going on
THR_CE + YAW_LO + PIT_LO + ROL_CE = decreases the ROLL I -- This is correct
THR_CE + YAW_LO + PIT_LO + ROL_HI = decreases the ROLL D -- This is correct

THR_CE + YAW_HI + PIT_LO + ROL_LO = decreases the PITCH I -- This is wrong, it should decrement the P .. not sure what's going on
THR_CE + YAW_HI + PIT_LO + ROL_CE = decreases the PITCH I -- This is correct
THR_CE + YAW_HI + PIT_LO + ROL_HI = decreases the PITCH D -- This is correct

and all other stick commands regarding PID tuning doesnt work.

Please help?

User avatar
jaysonragasa
Posts: 53
Joined: Wed Jan 28, 2015 6:40 am
Location: Philippines
Contact:

Re: ROLL & PITCH - PID Tuning

Post by jaysonragasa »

ok I think I found the problem.. It's my Tx subtrims. I'll make a video after I perfected it.

User avatar
jaysonragasa
Posts: 53
Joined: Wed Jan 28, 2015 6:40 am
Location: Philippines
Contact:

Re: ROLL & PITCH - PID Tuning

Post by jaysonragasa »

so I made an update.

I can now tune my ROLL & PITCH PIDs usng my AUX channel inflight!

Post Reply