FB_BasicPID
The function block is a simple discretized 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 : Set value of the controlled variable.
fActualValue : Actual value of the controlled variable.
bReset: TRUE at this input resets the internal state variables and the controller output.
fCtrlCycleTime: Cycle time with which the function block is called and with which the control loop is processed [s].
Here you must specify the cycle time of the PLC task, if the block is to be called in each PLC cycle,
otherwise the required multiple of the PLC task cycle time.
fKp : Controller amplification / controller coefficient
fTn : Integral action time [s]
fTv : Rate time [s]
fTd : Damping time [s]
VAR_OUTPUT
VAR_OUTPUT
fCtrlOutput : LREAL;
nErrorStatus : UINT
END_VAR
fCtrlOutput : Output of the PID-element.
nErrorStatus: Indicates the error number in the event of an error (nErrorStatus <> 0).
Error Codes:
Value | Constant | Error description |
---|---|---|
0 | nERR_NOERROR | No error |
1 | nERR_INVALIDPARAM | Invalid parameter |
2 | nERR_INVALIDCYCLETIME | Invalid cycle time. |
Requirements
Development environment |
Target platform |
PLC libraries to be integrated (category group) |
---|---|---|
TwinCAT v3.1.0 |
PC or CX (x86, x64, ARM) |
Tc2_Utilities (System) |