Skip to content

No Anti-Windup Logic in PIDLoop #2938

@KrazyKerbalnaut

Description

@KrazyKerbalnaut

In the PIDLoop function, the kerboscript equivalent code has no logic for anti-windup on the integram term. There is minimum and maximum output logic, but it would be nice if we could also set parameters for anti-windup. The code for such logic would be as follows:

...
if Ki <> 0 {
     set ITerm to (ErrorSum + Error * dt) * Ki.

     if ITerm > KiMax set ITerm to KiMax.
     if ITerm < KiMin set ITerm to KiMin.
}
...

And then edit this maximum/maximum section to:

...
if Output > MaxOutput {
    // we already took care of ITerm windup in previous section
    set Output to MaxOutput.
} else if Output < MinOutput {
    // we already took care of ITerm windup in previous section
    set Output to MinOutput.
}
...

This reduces the number of math operations as well, retains the output limiting function and clamps the integral term. It also lets the user select a clamping value for the max/min integral term independent of the max/min output functions of the controller as a whole.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions