FB_BasicPID
The function block represents a simple discrete PID element.
Transfer function:
Action diagram:
VAR_INPUT
VAR_INPUT
fSetpointValue : LREAL; (* setpoint value *)
fActualValue : LREAL; (* actual value *)
bReset : BOOL;
fCtrlCycleTime : LREAL; (* controller cycle time in seconds [s] *)
fKp : LREAL; (* proportional gain Kp (P) *)
fTn : LREAL; (* integral gain Tn (I) [s] *)
fTv : LREAL; (* derivative gain Tv (D-T1) [s] *)
fTd : LREAL; (* derivative damping time Td (D-T1) [s] *)
END_VAR
fSetpointValue : Setpoint value of the controlled variable.
fActualValue : Actual value of the controlled variable.
bReset : TRUE at this input resets the internal state variables as well as the output of the controller.
fCtrlCycleTime : Controller cycle time for discrete-time implementation [s].
It is required to set this value equal to the task cycle time of the PLC task, if the function block is called every PLC cycle.
Otherwise the appropriate multiple of the PLC task cycle time has to be used.
fKp : Proportional amplification
fTn : Integral-action time [s]
fTv : Derivative action time [s]
fTd : Damping time [s]
VAR_OUTPUT
VAR_OUTPUT
fCtrlOutput : LREAL;
nErrorStatus : UINT
END_VAR
fCtrlOutput : output of thePID element.
nErrorStatus : Provides the error number, if an error exists (nErrorStatus <> 0).
0 = nERR_NOERROR : no error.
1 = nERR_INVALIDPARAM : invalid parameter
2 = nERR_INVALIDCYCLETIME : Invalid cycle time
Requirements
Development Environment | Target System | PLC Libraries to include |
---|---|---|
TwinCAT v2.7.0 Build > 519 | PC or CX (x86) | Standard.Lib; PLCSystem.Lib; TcPLCAds.Lib; PLCHelper.Lib; TcPlcUtilities.Lib |
TwinCAT v2.8.0 Build > 739 | PC or CX (x86) | TcUtilities.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib are included automatically ) |