-
Notifications
You must be signed in to change notification settings - Fork 239
Closed
Description
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
Labels
No labels