FB_HVACScheduler7ch

FB_HVACScheduler7ch 1:

Application

This function block is a weekly timer switch with 7 timer switch channels. Any desired combination of days of the week can be assigned to any timer switch channel. The timer switch channels can be defined for non-recurring or recurring events. Besides the switching signal, the switch-on and switch-off edges plus the next switch-on or switch-off time as a countdown are available as outputs. The data of the timer switch channels is transferred as a reference. The function block is therefore able to check the data for changes and to save it as persistent data. After booting, the data are thus available to the BMS again. The switch-on and switch-off points can be specified to the exact second via the variables tiOn_ss and tiOff_ss of the respective time channel.

FB_HVACScheduler7ch 2:

If the input variable bEnable = FALSE, then the output bOutput = FALSE. The timer switch channels arrTimeChannel remain active.

VAR_INPUT

eDataSecurityType: E_HVACDataSecurityType;
bSetDefault      : BOOL;
bEnable          : BOOL;
dtSystemTime     : DT;
uiOffsetBefore   : UINT;           0 .. 240    min
bReset           : 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: FB_HVACScheduler7ch 3: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: the function block is enabled with bEnable. If bEnable = FALSE there is no switching at the output bOutput.

dtSystemTime: the variable dtSystemTime transfers the computer system time to the timer program.

uiOffsetBefore: the switch-on time is brought forward by this number of minutes. This function is useful for the time-optimized switching on of heating circuits. A maximum of 240 min, i.e. 4 hours, may be entered. If the resulting switch-on time is before midnight on the previous day, then midnight will be chosen as the switch-on time. The switch-off time is not affected.

bReset: acknowledge input in the event of a fault. Resets the flag bInvalidParameter.

Example 1

Switch-on time from 1:30 to 5:30, uiOffsetBefore has the value 150 min. The switch-on time is only advanced by 90 min to 00:00.

FB_HVACScheduler7ch 4:

Example 2:

Switch-on period from 13:30 to 17:30; uiOffsetBefor has the value 150 min. The switch-on time is brought forward by 150 minutes to 11:00.

FB_HVACScheduler7ch 5:

VAR_IN_OUT

arrTimeChannel    : ARRAY[1..7] OF ST_HVACTimeChannel;

arrScheduleWeekly: the variable arrScheduleWeekly is an array with 7 declarations of the structure variable ST_HVACTimeChannel. It is possible to generate 1 switch-on time per day of the week with the 7 channels.

TYPE ST_HVACTimeChannel :
STRUCT
  uiOn_hh      : UINT;
  uiOn_mm      : UINT;
  uiOn_ss      : UINT;
  uiOff_hh     : UINT; 
  uiOff_mm     : UINT;
  uiOff_ss     : UINT;
  bEnable      : BOOL;
  bAllDays     : BOOL;
  bMonday      : BOOL;
  bTuesday     : BOOL;
  bWednesday   : BOOL;
  bThursday    : BOOL;
  bFriday      : BOOL;
  bSaturday    : BOOL;
  bSunday      : BOOL;
  bResetAfterOn: BOOL;
  bQ           : BOOL;
END_STRUCT
END_TYPE  

Special notes regarding time input

The following applies:

FB_HVACScheduler7ch 6:

The following applies:

If the switch-on time is later than the switch-off time, the switch-on period is extended through midnight into the next day, regardless of whether the next day is selected.

FB_HVACScheduler7ch 7:

This setting produces:

FB_HVACScheduler7ch 8:

For each instance of the function block FB_HVACSchedulerWeekly it is necessary to create an array of type ST_HVACTimeChannel. The size of the array must be 7, since the function block processes a total of 7 weekly timer switch cycles and expects these as a reference (VAR_IN_OUT).

Sample

VAR_GLOBAL 
    arrTimeChannel : ARRAY[1..7] OF ST_HVACTimeChannel;
END_VAR

Within the weekly planner each timer switch channel is enabled via the variable bEnable (On/Off). If bEnable = FALSE, then the timer switch channel is deactivated and the times entered have no effect. If bAllDays (Mon-Sun) = TRUE, then the times set in uiOn_hh, uiOn_mm, uiOff_hh and uiOff_mm apply to all days of the week from Monday to Sunday. If bAllDays is FALSE, then the days of the week can be selectively assigned to a timer switch channel using the variables bMonday to bSunday. For one-shot events, the variable bResetAfterOn (non-recurring) is activated. After the time set in this channel has elapsed, the entries created under uiOn_hh, uiOn_mm, uiOff_hh, uiOff_mm and the days of the week are retained. However, the variable bEnable (On/Off) is reset to FALSE. In this manner a one-shot event can be defined once and reactivated whenever it is required.

Example

FB_HVACScheduler7ch 9:

Monday switched on from 07:20 until 17:30

Tuesday switched on from 16:40 until 00:00

Wednesday switched on from 00:00 until 23:59:59 (around the clock – 24 hours!)

Thursday switched on from 15:00 until 03:00 Friday morning, non-recurring!

Friday Timer switch channel not activated, always switched off!

VAR_OUTPUT

bOutput          : BOOL;
bEdgeOn          : BOOL;
bEdgeOff         : BOOL;
tNextOn          : TIME;     0 .. 10080    min     (* Nächster Einschaltpunkt, max 7 Tage * 24 h * 60 min = 10080 *)
tNextOff         : TIME;     0 .. 1440     min     (* Nächster Ausschaltpunkt, max gleicher Tage 24 h * 60 min = 1440 *)
bInvalidParameter: BOOL;

bOutput: is TRUE if one of the timer switch channels has switched on.

bEdgeOn: is TRUE for one PLC cycle after bOutput switches on.

bEdgeOff: is TRUE for one PLC cycle after bOutput switches off.

tNextOn: time until the next switch-on of the timer program. Maximum value 10080 minutes (1 week).

tNextOff: time until the next switch-off of the timer program. Maximum forecast until midnight.

bInvalidParameter: an error occurred during the plausibility check. It is deleted again by bReset.