There are two SFCs available for viewing and setting the time from the user program:
· SFC0 SET_CLK : set time
· SFC1 READ_CLK : view time
The following is an example for parameterizing and calling these SFCs:
Configuration of date and time (=parameters PDT and CDT)
Byte n YEAR MONTH Byte n+1
Byte n+2 DAY HOUR Byte n+3
Byte n+4 MINUTE SECOND Byte n+5
Byte n+6 MS_HUNDREDS MS_TENS MS_UNITS DAY OF WEEK Byte n+7
.
The values are to be specified in BCD-code.
Day of week code: 1 = Sunday ... 7 = Saturday
Example SFC 0 SET_CLK
The "date_time" variable is defined as local variable as of LB20 and is of the type DATE_AND_TIME (DT).
Date: 19th November 1996; Tuesday => code = 3
Time: 07:05:00
L DW#16#96111907;
T LD20;
L DW#16#05000003;
T LD24;
CALL SFC 0 (
PDT := date_time,
RET_VAL := MW0
);
Example SFC1 READ_CLK
The "date_time" variable is defined as local variable as of LB20 and is of the type DATE_AND_TIME (DT).
CALL SFC 1 (
CDT := date_time,
RET_VAL := MW2
);
Date and time are to be entered in BCD code in the "date_time" variable according to the table given above.