FB_BACnet_PidControl
PID controller block in parallel configuration (Kp has no effect on I and D component). The controller block serve as a basis for the object "LOOP" (FB_BACnet_Loop).
Block diagram
Use
The controller block must be called cyclically in the PLC program. Please ensure that the cycle time of the call at input fCtrlCycleTime is transferred as precisely as possible. The cycle time can be determined from the global structure "SystemTaskInfoArr", for example. A possible controller configuration is presented under Example.
VAR_INPUT
fSetpoint : REAL; (* setpoint value *)
fPresentValue : REAL; (* actual value *)
bReset : BOOL; (* reset flag *)
fCtrlCycleTime : REAL; (* controller cycle time in seconds [s] *)
fBias : REAL; (* bias also active when reset is set to 1 *)
fKp : REAL; (* proportional gain Kp (P) *)
fKi : REAL; (* integral gain Ki (I) *)
fKd : REAL; (* derivative gain Kd (D) *)
fMaxOutput : REAL;
fMinOutput : REAL;
fSetpoint: setpoint value input (e.g. temperature specification for a room in [°C])
fPresentValue: actual value (e.g. actual room temperature in [°C])
bReset: resets the controller, the output is set to fBias for the duration and limited through fMaxOutput and fMinOutput.
If fMinOutput is set to 5% and fBias to 0%, for example, the output fY is set to 5% for the duration of the reset. |
fCtrlCycleTime: cycle time with which the controller is called in seconds [s].
fBias: output offset. This value is offset with the output. The unit must match the unit of the control value (e.g. heating capacity in [%]).
fKp: gain factor P. The control deviation is multiplied with P and added to the output (output behaves proportional to the input deviation).
fKi: integral gain I. The control deviation is multiplied with I (taking into account the cycle time), added to the previous result and added to the output (high control deviation = fast increasing output).
fKd: differential gain D. The control deviation is offset with the previous controller difference, the result multiplied with D (taking into account the cycle time) and added to the output (strong controller variation = strong response).
fMaxOutput: upper limit of the output value fY. The unit must match the unit of the control value (e.g. heating capacity maximum 90%).
fMinOutput: lower limit of the output value fY. The unit must match the unit of the control value (e.g. heating capacity minimum 5%).
VAR_OUTPUT
fY : REAL; (* controller output command *)
nErrorStatus : UINT; (* controller error output (0: no error; >0:error) *)
fY: Control value (e.g. heating capacity in [%]).
nErrorStatus: Error status (0 = no error, 1 = invalid parameters: 2 = invalid cycle time). Error messages do not have to be acknowledged.
Example
Note re. P = 10 --> a temperature difference of 1 K results in 10% heating capacity, for example
Note re. I = 0.01 --> a temperature difference of 1 K results in 0.01% heating output increase per second, for example
Note re. D = 0 --> no D part.