FB_HVACOptimizedOff

FB_HVACOptimizedOff 1:

Function block for the optimized switch-off (pre-stop) of boilers and air conditioning systems in conjunction with switching time function blocks.

The explanations in this document relate to the heating behavior. The function block is used in the same way in conjunction with cooling devices.

Calculating the PrestopTime

Buildings and parts of buildings which are used at a certain and projectable time, e. g. schools and conference rooms, don´t need to be heated for the whole using-time. Because the buildings save thermal energy, it is possible to shut off the heating earlier. The room temperature declines till the end of usage to a lower niveau which is hardly noticed. This is a desired declining to an objective temperature - the difference of declining is an input of the function block and is called rRequestedTempDeviation.

The flow temperature of the boiler refers to the outdoor temperature. Therefore there are different declining processes for different outdoor temperatures which meet basically an exponential function:

FB_HVACOptimizedOff 2:

To determine the prestop time, the area between the functions of room temperature start value and room temperature target value is assumed linear. So for each outdoor temperatue there is a characteristic temperature change ΔT/Δt, which is illustrated here in a dotted line.

The function block FB_HVACOptimizedOff refers with the variable stTempChangeFunction to a table, in which there are 10 outdoor temperatures with their corresponding room temperature changes. When commissioning or starting the system for the first time, the pre-start function must be roughly pre-defined, firstly to define the external temperature range and secondly to accelerate the adaptation process. This entry is made with the block FB_HVACTempChangeFunctionEntry. With these values you can approximately determine the prestop temperature. Typically this temperature-change-function f(OT) has the following course: (the change is positive illustrated):

FB_HVACOptimizedOff 3:

Function values inside these 10 points are determined via equation of line, values outside correspond to the function value f( OT1 ) resp. f(OT10):

Thus the prestop time is calculated:

FB_HVACOptimizedOff 4:

The input and output variables of the module are illustrated in red. The internal flag uiActualPrestopTime which holds always the actual prestop time is illustrated in violet. The output uiPrestopTime corresponds to this flag, but becomes "freezed" during the prestop phase. This will be explained in detail in the following chapter.

Function block linking and pre-stop phase

From these parameters the function block will then continuously calculate a pre-stop time, which it specifies to the timer function block. Then if, for example, a heating boiler is to be switched off at 8 pm and the pre-stop function block determines at 7 pm that the temperature level would drop by the desired value rRequestedTempDeviation on switching off the boiler in 60 minutes, the boiler is switched off immediately. The cooling behavior is then observed in a reference room over the pre-stop phase and the temperature change curve is corrected accordingly.


FB_HVACOptimizedOff 5:

The pre-stop function block specifies a pre-stop time for the timer. If the timer switches the output bOutput back to FALSE, this is indicated to the pre-stop function block via its input bSchedulerOff . The pre-stop function block then internally starts a countdown with the previously output pre-stop time uiPrestopTime [min]. The countdown either runs to the end or is prematurely ended on reaching the requested or tolerated room temperature. The bPrestopActive output is set during the countdown.
The output uiPrestopTime continuously follows the calculation shown above, but is kept constant during a started countdown so that a fluctuation in the outside temperature does not specify a shorter pre-stop time and the boiler is suddenly switched on again.

If, in the case of a pre-stop, the timer function block still sends the adaptation order as an edge (red line) to the optimization function block, then the latter will decide following the pre-stop phase whether the previously determined pre-stop time was precisely within a tolerance, or too short or too long, and correct the temperature change function accordingly. In doing so the pre-stop time of the point whose outside temperature was nearest to the actual one at the beginning of the countdown is corrected upwards or downwards respectively. This process is called "adaptation".

FB_HVACOptimizedOff 6:

Temperature changes are only corrected if the outside temperature was within the interpolation points, i.e. the function range, at the beginning of the pre-stop; see "Adaptation".

If adaptation is desired, the inputs bWithAdaption and bSchedulerOff must be set simultaneously. A pure trigger pulse is sufficient for bWithAdaption. A previously started countdown is interrupted immediately if the input bSchedulerOff releases. The adaptation can be suppressed by the input bDisableAdaption. This option should be selected if the temperature change function is no longer to be changed after a certain number of adaptation procedures.

The following program flowchart is intended to better illustrate the behavior; the input and output variables of the function block are shown in red here:

The internal flag "Current pre-stop time" is the continuously refreshed result of the calculation in accordance with the diagram shown above.

FB_HVACOptimizedOff 7:

FB_HVACOptimizedOff 8:

The input bEnable, whose mode of operation is not shown here, factually deactivates the function block when FALSE. "0" is output as the pre-stop time uiPrestopTime and the sequence shown above is not started or is immediately reset as the case may be.

Adaptation

The goal of the adaptation is to adapt the temperature change function so precisely that the requested or tolerated temperature decrease rRequestedTempDeviation is reached in the determined pre-stop time (in cooling mode it would be the temperature increase after switching off the cooling devices).

If an adaptation is selected and the pre-stop phase has ended (countdown = 0 or room temperature reached), then three cases can occur:

  1. The countdown has elapsed and the requested deviation rRequestedDeviation is exhausted up to a tolerance rAdaptionTolerance -> no adaptation takes place.
  2. The countdown has not yet elapsed, but the requested deviation rRequestedDeviation has been exceeded -> the pre-stop time uiPrestopTime was too long.
  3. The countdown has elapsed, but the requested deviation rRequestedDeviation is not yet fully exhausted -> the pre-stop time uiPrestopTime was too short, i.e. switch-off can take place even earlier.

FB_HVACOptimizedOff 9:

The value ΔT/Δt can now be re-determined on the basis of the elapsed countdown time and the change in the room temperature difference that has taken place

  1. no change.
  2. too much time was calculated – new value: "requested deviation rRequestedDeviation" / "time elapsed so far"
  3. too little time was calculated – new value: ("requested deviation rRequestedDeviation" - "Deviation at the end") / "Countdown time"

The temperature change function is now corrected at the interpolation point whose outside temperature value was nearest to that at the beginning of the pre-stop phase. To this end the point concerned was saved before the start of the countdown, see program flowchart.

However, the previously calculated value ΔT/Δt is not necessarily adopted 100% as the new value at the interpolation point. In fact there is an option to mix the new value from a weighting of old and calculated value. This weighting takes place with the aid of the so-called adaptation factor rAdaptionFactor:

FB_HVACOptimizedOff 10:

With an adaptation factor of 100% the newly calculated value is adopted fully, while with 0% the old value is retained.

FB_HVACOptimizedOff 11:

Note: Because the pre-stop time is always changed at the nearest point, an adaptation can only take place if the outside temperature at the beginning of the pre-stop phase lies inside AT1 to AT10.

VAR_INPUT

eDataSecurityType       : E_HVACDataSecurityType;
eCtrlFct                : E_BARCtrlFct;
bEnable                 : BOOL;
bSchedulerOff           : BOOL;
bWithAdaption           : BOOL;
bDisableAdaption        : BOOL;
rOutsideTemperature     : REAL;
rRoomTemperature        : REAL;
rRequestedTempDeviation : REAL;

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.

eCtrlFct: eCtrlFct = eBARCtrlFct_Heating indicates to the function block that it is to be used in heating mode (see E_BARCtrlFct). Cooling mode is indicated by eCtrlFct = eBARCtrlFct_Cooling. Any other entry at this input is impermissible and leads to an error message. The two possible entries are for the different evaluation of the deviation rRequestedTempDeviation.

bEnable: A FALSE signal at this input suppresses the optimized switch-off of the connected timers. The output value of the pre-stop time is also set directly to "0". No countdown starts, nor is an adaptation carried out – the function block is reset.

bSchedulerOff: A rising edge at this input starts the internal countdown of the pre-stop time. The output bPrestopMode is set to TRUE while the countdown of a pre-stop time is running down. If the output bSchedulerOff is switched to FALSE again during the countdown, the countdown is interrupted immediately and the output bPrestopMode is set to FALSE. The countdown is also stopped and bPrestopMode set to FALSE when the room setpoint is reached.

bWithAdaption: If this input is set simultaneously with the input bSchedulerOff, an adaptation takes place after the countdown has elapsed. A trigger pulse together with the rising edge of bSchedulerOff is sufficient for this. This input can only be used in conjunction with bSchedulerOff; setting it alone has no effect at all.

bDisableAdaption: A TRUE signal at this input merely suppresses the adaptation that follows the countdown.

rOutsideTemperature: Outside temperature in degrees Celsius.

rRoomTemperature: Room temperature in degrees Celsius.

rRequestedTempDeviation: Tolerated downward (heating mode) or upward (cooling mode) temperature deviation after switching off the boiler or the air conditioning system respectively until leaving the room.

VAR_OUTPUT

uiPrestopTime      : UINT;
bPrestopActive     : BOOL;
udiCountdownTime   : UDINT;
bError             : BOOL;
udiErrorID         : UDINT;

uiPrestopTime: Output value of the optimized pre-stop time to the timers concerned in minutes. This value is formed continuously from the pre-stop function that is dependent on the outside temperature. Conversely, if the input bDisableOptimization is set to TRUE, then this output is set to "0".

bPrestopActive: The function block is in pre-stop mode as long as the internal countdown is running and has not been ended by the pre-stop time elapsing, by the room temperature setpoint being reached or by an interruption (bSchedulerOff = FALSE). This is indicated by a TRUE signal at this output.

udiCountdownTime: This output indicates the elapsing of the internal countdown in seconds. This output is set to "0" if the function block is no longer in pre-stop mode (see bPrestopMode).

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

uiMaxPrestopTime      : UINT;
rAdaptionFactor       : REAL;
rAdaptionTolerance    : REAL;
stTempChangeFunction  : ST_HVACTempChangeFunction;

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: example_persistent.zip.

uiMaxPrestopTime: Due to the adaptation the pre-stop times are shortened and lengthened within the temperature change function. While they are logically automatically limited to 0 minutes in the downward direction, the upward limit in minutes can be defined by this input.

rAdaptionFactor: In the adaptation step the temperature change ΔT/Δt that has taken place is calculated for the nearest outside temperature interpolation point. However, this is not necessarily adopted 100% as the new value. In fact there is an option to mix the new value from a weighting of old and calculated value. The adaptation factor (in percent) thereby represents the weighting.

FB_HVACOptimizedOff 12:

With an adaptation factor of 100% the newly calculated value is adopted fully, while with 0% the old value is retained.

rAdaptionTolerance: If the countdown has elapsed and the requested deviation rRequestedDeviation is exhausted, no adaptation is carried out because the pre-stop time is precisely right. The value rAdaptionTolerance defines an additional tolerance range:

FB_HVACOptimizedOff 13:

stTempChangeFunction: Structure variable of the type ST_HVACTempChangeFunction that contains the 10 value pairs (outside temperature, inside temperature change). These value pairs, which have to be entered in the field variable in ascending order of the outside temperature, define the 9 pitch lines of the temperature change function. Initial entry through FB_HVACTempChangeFunctionEntry.

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