PID-Beahvior of MW2.2

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
Goetz
Posts: 82
Joined: Sun Mar 04, 2012 3:40 pm

PID-Beahvior of MW2.2

Post by Goetz »

I know PID's in MW2.2 are 33/40 of earlier ones.

Normally I start at the Standard-PIDS and increase P step by step until the Kopter starts to wobble. My experience on different Kopters is: The Kopter doesnt wobble even on very high P-Values but in Flight sometimes suddenly comes an unexpected Roll...


Is ther a new way to determine right P in MW2.2?

alexia
Posts: 85
Joined: Sun Jun 17, 2012 10:23 pm
Contact:

Re: PID-Beahvior of MW2.2

Post by alexia »

same thing for me.
with previous release,i could see wooble when i increased the p but now i can t...are you an idea about this?

Goetz
Posts: 82
Joined: Sun Mar 04, 2012 3:40 pm

Re: PID-Beahvior of MW2.2

Post by Goetz »

The only thing I see is: put back MW2.1, experiece the P(ID)'s, calc it with 33/40, go back to MW2.2 (with erase of Eeprom) and put them in by Hand in Gui.... ....I cannot believe this is the only solution?

Peter
Posts: 82
Joined: Mon Jun 11, 2012 2:09 pm

Re: PID-Beahvior of MW2.2

Post by Peter »

Unexpected reactions are often due to vibrations. Play with lpf to see if there is a difference.
For fast flight the pids should be lower. Otherwise there will be oscillations. This can be done by setting the throttle pid attenuation. I always set it to 0.3.

Goetz
Posts: 82
Joined: Sun Mar 04, 2012 3:40 pm

Re: PID-Beahvior of MW2.2

Post by Goetz »

solved (maybe someone esle makes the same mistake as i did):
wrong: start with standard PID an increase P

right: set I and D to 0, THEN increase P until wobble.... ..yes, without I and D there comes an wobble:-) then increase D (perhaps down P a bit), then I..... ....to be honest I'm still not shure about I....

EmmeDi8
Posts: 18
Joined: Thu Sep 06, 2012 5:15 pm

Re: PID-Beahvior of MW2.2

Post by EmmeDi8 »

Hi,

I think, PID tuning of MW 2.2, is bit different from earlier version.
I have read & checkout various guide found on the web and all guide say same think : "before fly we must adjust gyroscope reaction".
We keep in mind, the gyroscope is used to set the "angular velocity" (and not "angular position") controlled by stick of TX.
More pinch/roll on stick of TX ==> more angular velocity on the axis of multirotor.
We can start to put I = 0 (or very low such as 0.010) and D = 0. Rise P looking for what value of P cause wobble.
When we find this value decrease it of 10% or 20%. Now we have found better P reaction without overshooting.
- "I" component. I have understand "I" is useful to compensate static error like wrong center of gravity or wind.
In fact in the PID controller "I" accumulate the error on the time, so P needs less cycle to reach requested angular velocity, because big amount of the
error is in the memory of "I". Now we have to amplify static error putting some weight under one arm of your multirotor. Raise "I" value until the multirotor
stop drift in the direction of the arm with the weight. Obviously more weight, more "I". This because "I" must contains more amount of static error. In the real flight "I" is useful to compensate wind action (I think).
The last setting is "D". "D" is like brake when we are near to the requested angular velocity. More "D" ==> more brake ==> less reactive ==> prevent overshooting. To setup this parameter we must see the multirotor in the flight. If we want more reactive we must decrease "D" value.
This is what I have learned about gyroscope tuning.

With MW 2.2, during this procedure, I have try to set Level P=0, I=0, D=0, in order to exclude accelerometer influence, but this cause the multirotor never listen stick movements of TX. So, I have follow this procedure with default "LEVEL" PID.

Now the question.
In order to setup gyroscope, in the MW 2.2, what is the right LEVEL pid, to minimize accelerometer influence ?

Thanks.

sorg
Posts: 34
Joined: Mon Apr 08, 2013 2:49 pm

Re: PID-Beahvior of MW2.2

Post by sorg »

As per my understanding of the PID formulas , with The gyro PID set to 0,0,0, in and when not in level mode, The copter should not have any response to a stick input (because of the zeroed PID parameters)... But as per my experience , the quad is moving( too slowly and softly of course) even with zero parameters.... I can't explain why... but this should definitely need a clarification.

User avatar
IceWind
Posts: 115
Joined: Fri Mar 25, 2011 2:11 am
Contact:

Re: PID-Beahvior of MW2.2

Post by IceWind »

When the Level is disabled the ACC should not be used in the calculations.

User avatar
IceWind
Posts: 115
Joined: Fri Mar 25, 2011 2:11 am
Contact:

Re: PID-Beahvior of MW2.2

Post by IceWind »

When the Level is disabled the ACC should not be used in the calculations.
Actually if you only have a GYRO the level values will still be there.

EmmeDi8
Posts: 18
Joined: Thu Sep 06, 2012 5:15 pm

Re: PID-Beahvior of MW2.2

Post by EmmeDi8 »

Hi,

looking into pid controller I have found

Code: Select all

    if ( !f.ANGLE_MODE || f.HORIZON_MODE || axis == 2 ) { // MODE relying on GYRO or YAW axis
      if (abs(rcCommand[axis])<500) error =          (rcCommand[axis]<<6)/conf.P8[axis] ; // 16 bits is needed for calculation: 500*64 = 32000      16 bits is ok for result if P8>5 (P>0.5)
                               else error = ((int32_t)rcCommand[axis]<<6)/conf.P8[axis] ; // 32 bits is needed for calculation

      error -= gyroData[axis];

      PTermGYRO = rcCommand[axis];
     
      errorGyroI[axis]  = constrain(errorGyroI[axis]+error,-16000,+16000);         // WindUp   16 bits is ok here
      if (abs(gyroData[axis])>640) errorGyroI[axis] = 0;
      ITermGYRO = ((errorGyroI[axis]>>7)*conf.I8[axis])>>6;                        // 16 bits is ok here 16000/125 = 128 ; 128*250 = 32000
    }


What I never understand is

Code: Select all

 PTermGYRO = rcCommand[axis];


PTermGYRO never use conf.P8[axis] or error.
How is possible?

EmmeDi8
Posts: 18
Joined: Thu Sep 06, 2012 5:15 pm

Re: PID-Beahvior of MW2.2

Post by EmmeDi8 »

Playing with pid controller I have modify the code as is:

Code: Select all

    if ((f.ANGLE_MODE || f.HORIZON_MODE) && axis<2 ) {
      //*********************
      //*     ERROR         *
      //*********************
      errorAngle = constrain(rcCommand[axis] + GPS_angle[axis],-500,+500) - angle[axis] + conf.angleTrim[axis];

      //*********************
      //*         P         *
      //*********************
      PTermACC = ((int32_t)errorAngle*conf.P8[PIDLEVEL])>>7;
      PTermACC = constrain(PTermACC,-conf.D8[PIDLEVEL]*5,+conf.D8[PIDLEVEL]*5);

      //*********************
      //*         I         *
      //*********************
      errorAngleI[axis]     = constrain(errorAngleI[axis]+errorAngle,-10000,+10000);
      if (abs(gyroData[axis])>640) errorAngleI[axis] = 0;
      ITermACC              = ((int32_t)errorAngleI[axis]*conf.I8[PIDLEVEL])>>12;
    }

    //GYRO
    if ( !f.ANGLE_MODE || f.HORIZON_MODE || axis == 2 ) { // MODE relying on GYRO or YAW axis
      //*********************
      //*     ERROR         *
      //*********************
      error = constrain(rcCommand[axis], -500, +500) - gyroData[axis];

      //*********************
      //*         P         *
      //*********************
      PTermGYRO = ((int32_t)error*conf.P8[axis])>>6;

      //*********************
      //*         I         *
      //*********************
      errorGyroI[axis]  = constrain(errorGyroI[axis]+error,-16000,+16000);
      if (abs(gyroData[axis])>640) errorGyroI[axis] = 0;
      ITermGYRO = ((errorGyroI[axis]>>7)*conf.I8[axis])>>6;

    }



Maybe Is only my impression, but seems have less drift.
Is very important use "I term" of LEVEL less or equal 0.10.
The parameter I've used IS P7 I0.20 D30 for Pitch/Roll and P20 I0.10 D100 for Level.

If tomorrow never rain, I will post short video.

Happy Fly.

User avatar
alll
Posts: 220
Joined: Fri Dec 07, 2012 9:53 am

Re: PID-Beahvior of MW2.2

Post by alll »

Haa, this is a more readable standard PID implementation. I am curious about the result. Maybe the final mwii yaw cure ;)
I will play with it too.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: PID-Beahvior of MW2.2

Post by copterrichie »

alll wrote:Haa, this is a more readable standard PID implementation. I am curious about the result. Maybe the final mwii yaw cure ;)
I will play with it too.


Just out of curiosity, which gyro and YAW PID settings are you using?

Thanks.

User avatar
alll
Posts: 220
Joined: Fri Dec 07, 2012 9:53 am

Re: PID-Beahvior of MW2.2

Post by alll »

copterrichie wrote:
alll wrote:Haa, this is a more readable standard PID implementation. I am curious about the result. Maybe the final mwii yaw cure ;)
I will play with it too.


Just out of curiosity, which gyro and YAW PID settings are you using?

Thanks.


What do you mean? Do you need values, or the way i tune them?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: PID-Beahvior of MW2.2

Post by copterrichie »

alll wrote:
What do you mean? Do you need values, or the way i tune them?



The Values and which gyro, just curious.

User avatar
alll
Posts: 220
Joined: Fri Dec 07, 2012 9:53 am

Re: PID-Beahvior of MW2.2

Post by alll »

MPU6050, ITG3205, ... (LPF_42HZ even if i balance everything quite well and isolate the board )
I often leave the default values for yaw, there i never could get the yaw behavior i want, so i often just increase P.
Gyro for roll and pitch do behave as a standard PID and every copter has complete other values!
manu

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: PID-Beahvior of MW2.2

Post by copterrichie »

Thank you, FYI I have never been able to get the YAW to hold using the default on any of my copters. Always requires the I to be set to at less .02 to .04

User avatar
alll
Posts: 220
Joined: Fri Dec 07, 2012 9:53 am

Re: PID-Beahvior of MW2.2

Post by alll »

This is an old KK PID (standard, gyro only!) implementation i made (long time ago when i started with KK), this is impossible to get with the mwii, for the moment ;) , i hope.
manu
http://youtu.be/WAf_utDpKNw

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: PID-Beahvior of MW2.2

Post by copterrichie »

Follow-up question, which gyro is the KK board using in the above demonstration?

User avatar
alll
Posts: 220
Joined: Fri Dec 07, 2012 9:53 am

Re: PID-Beahvior of MW2.2

Post by alll »

copterrichie wrote:Follow-up question, which gyro is the KK board using in the above demonstration?


Sorry, went flying this late afternoon.
It is a Invensese mpu3050 (i2c) on a N6V2 board http://www.hobbyeagle.com/n6v2/?lang=en

Post Reply