FB_HVACOptimizedOn

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

FB_HVACOptimizedOn 1:
FB_HVACOptimizedOn

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 heating 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 set value 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. Shown in purple here is the internal flag uiActualPrestartTime which contains the current pre-start time at each point in time. The output uiPrestartTime corresponds to this flag, but is "frozen" during the pre-start phase. This is explained in more detail below.

Function block linking and pre-start phase

From these parameters the function block will then continuously calculate a pre-start time, which it specifies to the timer function block. If, for example, a boiler is then to have heated up the building at 6 o'clock on Monday morning and the pre-start function block determines 60 minutes pre-start time at 5 o'clock in the morning, the time switch will immediately set the boiler to the appropriate heating mode. The heating behavior is then observed in a reference room over the pre-start phase and the pre-start curve is corrected accordingly.


FB_HVACOptimizedOn 5:

The pre-start function block specifies a pre-start time for the time switch. If the timer switches the output bOutput, this is indicated to the pre-start function block via its input bSchedulerActive. Internally the pre-start function block then starts a countdown with the previously output pre-start time uiPrestartTime [min]. The countdown either runs through 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 , which can then be used, for example, for a quick start of the boiler.
The output uiPrestartTime follows continuously the above calculation - during a started countdown, however, it is kept constant so that a fluctuation in the outside temperature does not indicate a lower pre-start time and suddenly switch off the boiler.

If, in the case of a pre-start, 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-start phase whether the previously determined pre-start time was precisely within a tolerance, or too short or too long, and correct the temperature change function accordingly. In doing so the pre-start 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_HVACOptimizedOn 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-start; see "Adaptation".

If adaptation is desired, the inputs bWithAdaption and bSchedulerActive must be set simultaneously. A pure trigger pulse is sufficient for bWithApation. A previously started countdown is interrupted immediately if the input bSchedulerActive 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-start time" is the continuously refreshed result of the calculation in accordance with the diagram shown above.

FB_HVACOptimizedOn 7:

FB_HVACOptimizedOn 8:

The input bEnable, the function of which is not shown here, effectively disables the function block if it is set to FALSE: "0" is output as the pre-start time uiPrestartTime and the sequence shown above is not started or is immediately reset.

Adaptation

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 beginning" / "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 closest to that at the start of the pre-stop phase. The relevant point for this was saved before the start of the countdown, see program flow chart.

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 9:
With an adaptation factor of 100% the newly calculated value is adopted fully, while with 0% the old value is retained.

FB_HVACOptimizedOn 10:

FB_HVACOptimizedOn 11:

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.

Input/output variables

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:= eDataSecurityType_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: FB_HVACOptimizedOn 12:Example_PERSISTENT.zip

If eDataSecurityType:= eDataSecurityType_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:= eDataSecurityType_Persistenti. 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. 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 set value 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

The need for entered parameters to be preserved across a control failure makes it necessary for them to be declared as IN-OUT variables. A reference variable is then assigned to them in the program. Each change in the value of this reference variable is persistently saved in the function block and written back to the reference variable after a controller failure and restart. If the parameters were only declared as input variables, they would not be able to write a reference variable.
Application example: FB_HVACOptimizedOn 13:Example_PERSISTENT.zip.

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

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 14:

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 type ST_HVACTempChangeFunction, which contains the 10 value pairs (outside temperature, internal 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.