FB_BARPICtrl

FB_BARPICtrl 1:

Simple PI controller. The control gain has no influence on the I-component.

This PI controller does not work directly with an adjustable gain factor Kp, but with the so-called proportional band (input rXp) in relation to the control value limits (rYmin and rYmax), from which Kp is then determined internally.

VAR_INPUT

eDataSecurityType : E_HVACDataSecurityType;
bSetDefault       : BOOL;
bEnable           : BOOL;
rW                : REAL;
rX                : REAL;
tTaskCycleTime    : TIME;
uiCtrlCycleCall   : UINT;
bSync             : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent, the persistent VAR_IN_OUT variables of the function block are stored in the flash of the computer if a value changes. For this to work, the function block FB_HVACPersistentDataHandling must be instanced once in the main program, which is called cyclically. Otherwise the instanced FB is not released internally.

A change of value can be initiated by the building management system, a local operating device or via a write access from TwinCAT. When the computer is restarted the saved data are automatically read back from the flash into the RAM.

Application example: example_persistent.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

Notice

A cyclically changing variable must never be linked with the IN_OUT variable of a function block, if eDataSecurityType:= eHVACDataSecurityType_Persistent. It would lead to early wear of the flash memory.

bSetDefault: If the variable is TRUE, the default values of the VAR_IN_OUT variables are adopted.

bEnable: Controller activation

rW: Setpoint.

rX: Actual value.

tTaskCycleTime: Cycle time with which the function block is called. If the function block is called in every cycle this corresponds to the task cycle time of the calling task.

uiCtrlCycleCall : Call cycle of the function block as a multiple of the cycle time. A zero entry is automatically evaluated as uiCtrlCycleCall =1.
Example: tTaskCycleTime = 20ms, uiCtrlCycleCall =10 -> The control algorithm is called every 200 ms. Thus the outputs are also updated only every 200 ms.

bSync: A rising edge at this input sets the (internal) I-component such that rSyncValue is output at the control value output. If the I-component is deactivated by tTn=0 ms, however, then this command is ignored.

VAR_OUTPUT

rY         : REAL;
rE         : REAL;
bARW       : BOOL;
bMaxLimit  : BOOL;
bMinLimit  : BOOL;
bError     : BOOL;
udiErrorId : UDINT;

rY: Control value.

rE: Control deviation (calculation dependent on control direction)

rEMin: lower control deviation limit value, which results from the input proportional band.

rEMax: upper control deviation limit value, which results from the input proportional band.

bARW: Anti-Reset-Windup function is active.

bMaxLimit: The control value has reached its upper limit value.

bMinLimit: The control value has reached its lower limit value.

bError: This output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: Contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

bDirection      : BOOL;
rXp             : REAL;
tTn             : TIME;
rYMin           : REAL;
rYMax           : REAL;
rSyncValue      : REAL;

bDirection: The control direction of the controller can be changed with the parameter bDirection. If bDirection is TRUE, then the direct control direction is active for cooling operation of the controller. If bDirection is FALSE, then the indirect control direction of the controller is activated for heating operation. The variable is saved persistently. Preset to FALSE.

rXp: Proportional band. This defines the internal proportional factor, see below. The proportionality factor or gain affects only the P-component. The variable is saved persistently. Preset to 100.0.

tTn: Integral action time in seconds. The I-component corrects the residual control deviation following the correction of the P-component. The smaller tTi is set, the faster the controller corrects. The control loop becomes unstable if the time is too short. Larger tTi-times must be entered in order to reduce the integration component. The integral action time should be selected to be longer than the stroke time of the valve or damper actuator. A zero value at this input deactivates the I-component. The variable is saved persistently. Preset to 30 s.

rYMin / rYMax: Limit the working range of the controller. Several other function blocks, e.g. sequencers, require a symmetrical control range (-100 to +100). In the case of a cascade structure, the working range of the master controller determines the setpoint of the slave controller. For example, 15° to 25° as the limitation of the supply air setpoint for an exhaust/supply air cascade control. The variable is saved persistently. Preset to 0.0 or 100.0 respectively.

rSyncValue: The control value rY is set to this value on a rising edge at the input bSync. In addition, the I-component is changed internally. If the I-component doesn't exist (PD controller), the D-component is changed. The variable is saved persistently. Preset to 0.0.

Functional description

Step response of a simple PI controller; the control gain has no influence on the integral component.
Reaction of the output Y(t) to a control deviation jump by E: In the case of a jump of the control deviation by E, the output Y initially jumps to KP*E due to the proportional component and then grows by a further E in each interval TN.

The controller is designed so that it begins at 0, i.e. without the KP*E jump, each time the PLC is reset or restarted.

FB_BARPICtrl 2:

Basic Function

A TRUE signal at the input bEnable enables the module. Then the internal controlling algorithm is processed. The input value uiCtrlCycleCall indicates, after what number of PLC cycles the internal controlling algorithm is going to be processed.
If uiCtrlCycleCall =1, a recalculation is executed in each PLC cycle, if it is set to 100, a new calculation is executed only each 100 PLC cycles. The PLC cycle time is part of the calculation of the actuating variable. A wrong input value causes a wrong calculation.
The inputs rW (desired value), rX (actual value), rXp (proportional band) and rTn (reset time) are the input parameters of the PI-controller. Via them the output parameters rY (actuating variable) and rE (control deviation) are evaluated in each calculation cycle. The actuating variable can additionally be limited via the inputs rYMin and rYMax .

Setting via the proportional band

The adjustment of the gain factor Kp of a controller often includes the difficulty for the user that there is no size reference to the application. If a heating controller normally operates within the two-figure range, then a flow rate controller can accept values in the five-figure range. It therefore makes sense to represent the Kp factor in such a way that it has a reference to the possible control deviation and change of control value. The P-component of the controller is regarded for the dimensioning of the Kp factor.
The equation for this is:

This relationship also applies to the changes in the control deviation and the control value:

Referenced to the minimum and maximum value of the control value, Ymin and Ymax:

This difference, E(Ymax) - E(Ymin), is called the proportional band (Xp). Transposed, the equation is then:

The following diagram clarifies the functional interrelationship:

FB_BARPICtrl 3:

The proportional band Xp therefore indicates the size of the range of the control deviation that leads to an output of Ymin to Ymax from the controller.
A smaller Xp leads to a steeper function and thus to an increase in the Kp factor. However, the control deviation limit values E(Ymax)-E(Ymin) are shifted:

FB_BARPICtrl 4:

Control-direction

Control-direction

If bDirection is set to FALSE, the control-direction will be changed, so a negative control-deviation will cause a positive value at the control-output. This is done by changing the internal calculation of the control-deviation.

bDirection

rE (control-deviation)

control-direction

TRUE

lrX-lrW (actual value-setpoint)

direct (cooling)

FALSE

lrW-lrX (setpoint-actual value)

reverse (heating)

Anti-Reset-Windup (ARW)

If the controller runs in this limitation, the I-component is hold internally at the last value. Without this, the I-component-values could increase unhindered. In case of a direction reversal of the controller, a huge I-component has to be eliminated, before the controller can operate within its normal limitations again. If calculation of the I-component is stopped, the output bARW is set.

Special Case Tn=0 to switch-off the I-component

In the step response diagram above you see, that the I-component's influence is the weaker, the bigger the integral-time Tn has been set. If the integral-time goes to infinity, the I-component's influence goes to zero. Reverse a constantly decreasing reset time would nurture the I-component, by Tn=0 the actuating variable would go to infinity. This special case is used to switch-off the I-component. This is an internal exception, because the integral-time directly belongs to the I-component and should switch-off the I-component via "0-item" metaphorically.

Synchronisation

A rising edge at bSync sets the controller output rY directly to rSyncValue, if the controller has been activated via a TRUE signal at bEnable. If not, the rising edge at bSync is ignored.

Passive-behaviour (bEnable = FALSE or bError = TRUE)

If the controller is wrong parameterized, the execution is stopped, the output bError is set and the corresponding error code is provided to udiErrorID, see Error codes. The Module is also stopped, if the input bEnable is not set. In both cases the outputs are set as follows:

rY

0.0

rE

0.0

bARW

FALSE

bMaxLimit

FALSE

bMinLimit

FALSE

Requirements

Development environment

required library

required function

TwinCAT 3.1 build 4022.16 or higher

Tc2_HVAC V3.3.1.0

TF8000 | TC3 HVAC V1.0.0.0