clockWeekAlarm (Functionblock)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Firmware version:

1.00 / 1.00.00


clockWeekAlarm is a convenient way of setting an alarm at a specific time on a specific weekday.

 

Input:

 

enable : BOOL

The timer will be initialized and started on the leading edge of the enable input.

 

dayofweek : SINT (1 .. 7)

The day of the week the alarm should trigger. 1 is Monday, 7 is Sunday.

 

hour: SINT (0 .. 23)

The hour for the alarm.

 

minute : SINT (0 .. 59)

The minute for the alarm.

 

second : SINT (0 .. 59)

The second for the alarm

 

Output:

q : BOOL

When the alarm time is reached, q will be TRUE.

 

Declaration:

FUNCTION_BLOCK clockWeekAlarm;
VAR_INPUT
   enable    : BOOL R_EDGE;    
   DayOfWeek : SINT;   // 01..31     
   Hour      : SINT;   // 00..23     
   Minute    : SINT;   // 00..59     
   Second    : SINT;   // 00..59     
END_VAR;
VAR_OUTPUT
   q         : BOOL;     
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR
   Alarm_1 : clockWeekAlarm;
   Alarm_2 : clockWeekAlarm;
   Alarm_3 : clockWeekAlarm;
   Alarm_4 : clockWeekAlarm;
END_VAR;
 
PROGRAM test;
 
Alarm_1(enable:=TRUE, DayOfWeek:=1, Hour:=18); 
Alarm_2(enable:=TRUE, DayOfWeek:=2, Hour:=18); 
Alarm_3(enable:=TRUE, DayOfWeek:=4, Hour:=18); 
Alarm_4(enable:=TRUE, DayOfWeek:=6, Hour:=18); 
 
BEGIN
   Alarm_1(); 
   Alarm_2(); 
   Alarm_3(); 
   Alarm_4(); 
 
   IF Alarm_1.THEN
      DebugMsg(message:="Alarm 1");
   END_IF;
   IF Alarm_2.THEN
      DebugMsg(message:="Alarm 2");
   END_IF;
   IF Alarm_3.THEN
      DebugMsg(message:="Alarm 3");
   END_IF;
   IF Alarm_4.THEN
      DebugMsg(message:="Alarm 4");
   END_IF;
END;
 
END_PROGRAM;