Reviving thread as I'm having trouble using the real time clock. I'm trying to keep a runtime count of a process and reset this every 6AM and 6PM. Here is my code (took from another thread):
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 "Daily Reset DB".Year
L LB 1
T "Daily Reset DB".Month
L LB 2
T "Daily Reset DB".Day
L LB 3
T "Daily Reset DB".Hour
L LB 4
T "Daily Reset DB".Minute
L LB 5
T "Daily Reset DB".Second
L LB 6
T "Daily Reset DB".MillisecMSB
L LB 7
SLW 12
SRW 12
T "Daily Reset DB".DayofWeek
//***************************
//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 600 hours (6AM) OR 1800 hours (6PM) . If it is not, then I don't jump
//to label "rst", and I end the block.
//***************************
O(L "Daily Reset DB".Hour
BTI
L 6
==I)
O(L "Daily Reset DB".Hour
BTI
L 18
==I)
AN "Daily Reset DB".ResetComplete
JC rst
BEU
//***************************
//If it has reached 6AM or 6PM, I jump to
//"rst", transfer my runtime values to historian, then transfer
//a zero to the runtime variables. 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 "RUNTIME”.Hours
T "Hist_Real”.Hours
L "RUNTIME”.Minutes
T "Hist_Real”.Minutes
L 0
T "RUNTIME”.Hour
T "RUNTIME”.Minutes
SET
= "Daily Reset DB".ResetComplete
- In the OR statements I'm getting a syntax error at "Daily Reset DB"
- At the rst statement I'm getting S identifier goes beyond end of row?
EDIT: I just realized for the OR statements I will need to use not only hours but minutes and seconds if I only want to reset right at 6:00:00AM and 6:00:00. Doing AND/OR is confusing to me in STL so any help would be appreciated.