FB_HVACOptimizedOn

FB_HVACOptimizedOn 1:

Function block for the optimized switch-on 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.

Calculation of the pre-start time

Company buildings and public facilities are generally unoccupied overnight and at weekends, so the heating boilers there often run only in standby mode. The goal of optimized switch-on is to start the boiler early enough for the building to have been heated sufficiently at a certain point in time. Conversely, this also applies to the cooling of the building during the summer months. This pre-start time is in fact not constant, but always dependent on various factors, such as outside temperature, room temperature difference (actual value to setpoint), and structural conditions, for example the building mass and the thermal insulation. The development of a universal equation valid for all buildings would be a very complex task and would fail just on account of the input of innumerable parameters. A self-learning (adaptive) approximation method is simpler and ultimately absolutely sufficient.

The flow temperature of the heating boiler depends on the outside temperature. Thus, different outside temperatures result in different heating curves, which essentially correspond to an exponential function:

FB_HVACOptimizedOn 2:

The flow temperature is always considerably higher than the room temperature to be reached. To determine the pre-start time it is assumed that the area of the functions between the room temperature start value and room temperature setpoint is linear. This results in a characteristic temperature change ΔT/Δt for each outside temperature, which is shown here by the dotted line.

With the structure variable stTempChangeFunction, the function block FB_HVACOptimizedOn is based on a table in which the respectively expected room temperature change is assigned for 10 discrete outside temperatures. During the commissioning or the initial starting of the system, the pre-start function must be coarsely predefined - firstly to define the outside temperature range and secondly to accelerate the adaptation procedure. This entry is done with the function block FB_HVACTempChangeFunctionEntry. The pre-start time can be determined approximately with these values. This temperature change function f(AT) typically adopts the following course:

FB_HVACOptimizedOn 3:

Function values within these 10 points are defined by linear equations, while values outside correspond to the function value f(AT1) or f(AT10) respectively:

The pre-start time is then determined in accordance with the following sequence:

FB_HVACOptimizedOn 4:

The input and output variables of the function block are shown here in red. The internal flag uiActualPrestartTime, which always contains the current pre-start time, is shown here in violet. The output uiPrestartTime corresponds to this flag, but is "frozen" during the pre-start phase. This is explained in more detail below.

Connection of Modules and Prestart Phase

Based on these specifications the module will calculate a prestart time and provide it to the time switch module. If the boiler should have warmed up the buildung at monday morning at 06:00 a.m. and the prestop module calculates at 05:00 a.m. a prestart time of 60 minutes, the boiler will be started immediately. The heating-up behaviour is watched in a reference room during the prestart time phase and the function of the temperature change is corrected.


FB_HVACOptimizedOn 5:

The prestart module provides a prestart time to the time switch module. If this switches the output bOutput, the prestart module gets informed by its input bSchedulerActive. Then the prestart module starts an internal countdown with the previously output prestart time uiPrestartTime [min]. The countdown either runs to the end or is completed prematurely when the room setpoint temperature is reached and represents the pre-start phase. During the countdown the output bPrestartActive is set. It can be used e. g. for the quickstart of the boiler.
The output uiPrestartTime follows continously the above described calculation - but when a countdown has been started it is kept constant, in order to inhibit a fluctuation in the outdoor temperature to specify a lower prestart time and switch off the boiler.

If the time-switch-module requests an adaption of the prestart-function (rising edge at bWithAdaption, red line) the prestart module will decide after the prestart phase, whether the calculated prestart time has been exact, too short or too long (within a tolerance) and will correct the temperature change. For this the prestart time of the point whose outdoor temperature is nearest to the actual (at start of the countdown) is corrected upward or downward. This process is called "Adaption".

Note: Temperature changes are only corrected, when the outdoor temperature has been within the function range at the beginning of the prestart-phase, see "Adaption".

When adaption is requested, the input bWithAdaption has to be set at the same time as the input bSchedulerActive. For bWithApation a simple trigger impulse is sufficient. When the input bSchedulerActive drops down, a started countdown is immediately aborted. The adaption can be disabled via the input bDisableAdaption. This option should be selected, when the temperature change function should not be changed any more after a sufficient number of adaptions.

The following program flow chart is to illustrate the behaviour, in red you see the input- and output variables of the module:

The internal flag "actual prestart time" is the always actual result of the calculation described obove.

FB_HVACOptimizedOn 6:

FB_HVACOptimizedOn 7:

The input bEnable (not described here), sets the module out of function if it is FALSE: the prestart time uiPrestartTime is set "0" and the prestart is not started resp. is immediately reset.

Adaptation

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

  1. The countdown has elapsed and the room temperature difference lies below the tolerance limit value rAdaptionTolerance -> no adaptation takes place.
  2. The countdown has not yet elapsed, but the set temperature for the room has been reached -> the pre-start time uiPrestartTime was too long.
  3. The countdown has elapsed, but there is still a positive temperature difference -> the pre-start time uiPrestartTime was too short.

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: "Room temperature difference at the start" / "Time elapsed so far"
  3. too little time was calculated – new value: ("Room temperature difference at start" - "Room temperature difference at 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_HVACOptimizedOn 8:

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

FB_HVACOptimizedOn 9:

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

VAR_INPUT

eDataSecurityType    : E_HVACDataSecurityType;
eCtrlFct             : E_BARCtrlFct;
bEnable              : BOOL;
bSchedulerActive     : BOOL;
bWithAdaption        : BOOL;
bDisableAdaption     : BOOL;
rOutsideTemperature  : REAL;
rRoomTemperature     : REAL;
rRoomSetpointValue   : 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 calculation of the temperature difference between actual room value and set room value.

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

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

bWithAdaption: If this input is set simultaneously with the input bSchedulerActive, an adaptation takes place after the expiry of the countdown. A trigger pulse together with the rising edge of bSchedulerActive is sufficient for this. This input can only be used in conjunction with bSchedulerActive; 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.

rRoomSetpointValue: Room temperature setpoint in degrees Celsius.

VAR_OUTPUT

uiPrestartTime   : UINT;
bPrestartActive  : BOOL;
udiCountdownTime : UDINT;
bError           : BOOL;
udiErrorID       : UDINT;

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

bPrestartActive: The function block is in pre-start mode as long as the internal countdown is running and has not been ended by the expiry of the pre-start time, by the reaching of the room temperature setpoint or by an interruption (bSchedulerActive = 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-start mode (see bPrestartMode).

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

uiMaxPrestartTime     : 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.

uiMaxPrestartTime: Due to the adaptation the pre-start 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_HVACOptimizedOn 10:

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 expired and the room temperature setpoint has been reached with adaptation activated, no adaptation is carried out because the pre-start time is precisely right. The value rAdaptionTolerance defines a tolerance range: If the actual value lies within the range rRoomSetpointValue .. rRoomSetpointValue + rAdaptionTolerance, then this is regarded as reaching the setpoint.

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