No problem JvdV, always glad to help. I've added some comments. Keep in mind that "Weekly Reset DB" is an actual Data Block, so if you want to try this out, just substitute your own absolute addresses:
CALL "READ_CLK" //Call SFC 1, "Read System Clock"
RET_VAL:=#Return
CDT :=#ReadCurrentTime
//***************************
//Load each byte of #ReadCurrentTime and transfer
//them to data bytes. This wouldn't be
//absolutely necessary, but it's nice to go online
//with the block and see what the current time is.
//Use the Siemens Help to see the "Date and Time"
//format to see why I have to SLW12 and SRW12 on LB7.
//***************************
L LB 0
T "Weekly Reset DB".Reset.Year
L LB 1
T "Weekly Reset DB".Reset.Month
L LB 2
T "Weekly Reset DB".Reset.Day
L LB 3
T "Weekly Reset DB".Reset.Hour
L LB 4
T "Weekly Reset DB".Reset.Minute
L LB 5
T "Weekly Reset DB".Reset.Second
L LB 6
T "Weekly Reset DB".Reset.MillisecMSB
L LB 7
SLW 12
SRW 12
T "Weekly Reset DB".Reset.DayOfWeek
//***************************
//After I have executed the weekly event that
//occurs each Sunday (Sunday=1, Monday=2, etc),
//the next day I reset the "Reset Complete" bit
//in my data block. By comparing the current day
//against "1", you can see that it will be reset
//every Monday.
//***************************
A(
L "Weekly Reset DB".Reset.DayOfWeek
L 1
>I
)
R "Weekly Reset DB".Reset.ResetComplete
//***************************
//Siemens uses the BCD format in the Date And Time,
//so I have to use the BTI instruction to convert
//it to an integer. In this section, I check to see
//if it is 1400 hours (2PM) and if it is Sunday (day
//of week = 1). If it is not, then I don't jump
//to label "rst", and I end the block.
//***************************
A(
L "Weekly Reset DB".Reset.Hour
BTI
L 14
>=I
)
A(
L "Weekly Reset DB".Reset.DayOfWeek
L 1
==I
)
AN "Weekly Reset DB".Reset.ResetComplete
JC rst
BEU
//***************************
//If it has reached 2PM on Sunday, I jump to
//"rst" and transfer a zero to all of my weekly
//production counts for each machine as well as the
//total production. I also set the "ResetComplete" bit
//as a way to create a one-shot (see the comparison
//above) so this is only executed once.
//***************************
rst: L 0
T "Production”.TotalWeekly
T "Production”.Machine[1].Production.Weekly
T "Production”.Machine[2].Production.Weekly
T "Production”.Machine[3].Production.Weekly
T "Production”.Machine[4].Production.Weekly
SET
= "Weekly Reset DB".Reset.ResetComplete