FB_WeeklyScheduler

Function block for triggering actions on certain weekdays in every nth week of the year.

FB_WeeklyScheduler 1:

FB_WeeklyScheduler 2:

The function block triggers switching when the switching time is passed. Subsequent modification of the switching events or the time is therefore not permitted.

VAR_INPUT

uiPeriodicity    : UINT;
uiBegin          : UINT;
arrActiveWeekday : ARRAY[0..6] OF BOOL;
eStartEnd        : ENUM;
stStartEnd       : TIMESTRUCT;
stSystemtime     : TIMESTRUCT;

uiPeriodicity: Periodicity or interval. May be within the range 1 to 52.

uiBegin: Start value for the week. May be within the range 1 to 52. Example: uiPeriodicity = 5, uiBegin = 2: Switching events in week 2, week 7, week 12 etc. - uiPeriodicity = 3, uiBegin = 1: Switching events in week 2, week 7, week 12 etc.

arrActiveWeekday: Day of the week on which an action is to be triggered - arrActiveWeekday[0] => Sunday .. arrActiveWeekday[6] => Saturday. Multiple selections are possible.

eStartEnd: Selection of start/end definition.

TYPE E_StartEnd : ( eSTARTTIME_ENDTIME := 1, eSTARTTIME_DURATION := 2, eSTARTTIME_ENDEVENT := 3, eSTARTEVENT_ENDTIME := 4, eSTARTEVENT_DURATION := 5, eSTARTEVENT_ENDEVENT := 6 ); END_TYPE

eSTARTTIME_ENDTIME: Selection of start/end time. If the start time is equal or greater the end time, the end is allocated to the next day.

eSTARTTIME_DURATION: Selection of start time/duration.

eSTARTTIME_ENDEVENT: Selection of start time/end event.

eSTARTEVENT_ENDTIME: Selection of start event/end time. If the start time is equal or greater the end time, the end is allocated to the next day.

eSTARTEVENT_DURATION: Selection of start event/duration.

eSTARTEVENT_ENDEVENT: Selection of start event/end event.

stStartEnd: Structure with the parameters defining the start and end. Unused variables are ignored internally, e.g. the duration for the selection of start/end time.

TYPE ST_StartEnd : STRUCT todStartTime : TOD; bStartEvent : BOOL; tDuration : TIME; todEndTime : TOD; bEndEvent : BOOL; END_STRUCT END_TYPE

todStartTime: Start time.

bStartEvent: Start event

tDuration: Switching duration.

todEndTime: End time.

bEndEvent: End event.

stSystemtime: current time in TIMESTRUCT format. It is important to count every second.

VAR_OUTPUT

bOut               : BOOL;
bTriggerOn         : BOOL;
bNoEventNextYear   : BOOL;
bError             : BOOL;
nErrorId           : UDINT;

bOut: control output that is switched on or off by the start and end event.

bTriggerOn: trigger output for switch-on events. This output is used to detect switch-on events. If two switch-on events occur consecutively they would not be detected via the control output bOut, since this output would remain TRUE. See also time overlaps in the overview.

bNoEventNextYear: no day matching the parameterization was found within the next 366 days.

bError: this output is set to TRUE if the parameterization is faulty. The command-specific error code is contained in nErrorId. Reset to FALSE once the parameterization is correct.

nErrorId: contains the command-specific error code. Reset to 0 once the parameterization is correct. See error codes.