Baro althold and vario. Delay aint good.

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
Plüschi
Posts: 433
Joined: Thu Feb 21, 2013 6:09 am

Baro althold and vario. Delay aint good.

Post by Plüschi »

Alt delay is roughly about 200ms. Too much for my taste. Very bad for althold and vario.

Code: Select all

    vel += accZ * ACC_VelScale * dTime;
    vel = vel * 0.985f + baroVel * 0.015f;

should be changed to

Code: Select all

    vel = vel * 0.985f + baroVel * 0.015f;
    vel += accZ * ACC_VelScale * dTime;

so we dont actually delay the acc effect on alt.
This should result in much better althold and less sensitivity to suboptimal althold PID values.

my implementation of the stuff

Code: Select all

float PredictedAlt;
float EstimatedAlt;
float EstAltVel = 0.0;

float KP = 0.040; // Position factor
float KV = 0.004; // Velocity factor
float KZ = 0.995; // velocity decrease factor to supress ringing
 
    // input baroalt is totally unfiltered, output EstAlt
    float diff = BaroAlt - PredictedAlt;
    // estalt in cm
    EstimatedAlt = PredictedAlt + diff * KP;
    // estaltvel in cm/s
    EstAltVel = EstAltVel * KZ + diff * KV + accZ * 0.025; // 0.025 = 25ms
    PredictedAlt = EstimatedAlt + EstAltVel*0.025;
    EstAlt = (int32_t)EstimatedAlt;




Right?

carlonb
Posts: 210
Joined: Sun Apr 03, 2011 6:29 pm

Re: Baro althold and vario. Delay aint good.

Post by carlonb »

Hi Pluschi, thaks for this tip,
any further detail about the code mod? I will try it.

Anybody else wants try it ?

Bye

User avatar
Plüschi
Posts: 433
Joined: Thu Feb 21, 2013 6:09 am

Re: Baro althold and vario. Delay aint good.

Post by Plüschi »

I have test flown that now, and it doesent kill the althold problem. Still likes to heavily oscillate.

I have made P = 3, I = 0, and D = 100. Oscillations are gone with above settings. Obviously since its a PD (I=0) error is not zeroed.
I think the >>4 in D calculation should be changed to >>3 to give better range for D parameter.

My dry simulation shows D is supposed to prevent oscillations on very slow reaction devices like copter height. It prevents overshoot from the speed build-up. The default althold PID factors are pretty bad for my 250 quad. Any experts to comment this?

Post Reply