Table of Contents

Advanced PI Controller

Full Name

Lib.Mervis.v1_0.AdvancedPiController

Required Project References

Description

This auxiliary block is used to implement a PI controller with the ability to track a control variable.

Usage in ST

program test
    var
        pi: lib.mervis.v1_0.AdvancedPiController := (Xp := ..., Ti := ..., Min := ..., Max := ...);
    end_var

    pi(Input := ..., SetPoint := ..., Enable := ..., TrackingEnable := ..., TrackingValue := ..., Output => ...);
end_program

Inputs

Name Data TypeAllowed RangeRetainRequired Meaning
Input real No Yes Actual value
SetPoint real No Yes Desired value
Enable bool No No Function enable, if false the output is 0
TrackingEnable bool No No Enable tracking mode
TrackingValue real No No Tracked value
Min real ⇐ 0 No No Minimum output value
Max real >= 0 No No Maximum output value
Xp real > 0 No No Proportional gain
Ti real > 0 No No Integral time constant
TrackingDontIncludePPart bool No No Determines the method of calculating the new control action in tracking mode - see description below
TrackingThreshold real No No Value for converting the input variable to the control action size (e.g., how many percent of output corresponds to one degree Celsius)

Outputs

Name Data TypeMeaning
Output real Output
TrackingCalculatedThresholdreal Value for converting the input variable to the control action size (e.g., how many percent of output corresponds to one degree Celsius)
InvalidParameters bool Indicates invalid controller settings (Xp, Ti, Min, or Max out of allowed range)

Block Methods

Name Meaning
Adjust Used to adjust the integral component so the output reaches the maximum value
AdjustToValueUsed to adjust the integral component so the output reaches the desired value
Restart Used to reset internal values and restart the calculation

Detailed Function Description

The functional block implements a PI controller with the ability to operate in tracking mode, where the control variable can be obtained from another controller. The following formulas are used for output calculation:

e = SetPoint - Input

PPart = (Max - Min) / Xp * e

IPart = IPart + (Max - Min) / (Xp * Ti) * e * ΔT

Output = PPart + IPart

The controller includes algorithms to limit the size of the integral component in case of saturation - Anti-windup

Tracking Mode

When the TrackingEnable input is set to true, the controller's behavior changes. In each calculation cycle, the TrackingValue is used as the basis for calculating the new control action. The usage method varies according to the setting of the TrackingDontIncludePPart parameter:

Then, the new control action (including the current P-part) is calculated and set to the Output. For easier use with the TrackingPiSelector block, the TrackingThreshold input and TrackingCalculatedThreshold output are provided to determine the hysteresis for selecting the controller whose output will be used.

Usage Notes