:)

John Morris

Lifetime Supporting Member
Join Date
Sep 2015
Location
San Antonio
Posts
689
Riddle me this

Original issue, AOI looses day of the week when powered down.

Solution ( presumably) downloaded Zeller Calculation (day of the week) AOI

set MOV instruction Zeller to Seven_day_timer_Day_of week

Result Day_of_week in the date time AOI toggles from one to three
 
I just always calculate the DOW myself. There are several versions of the calculations out there, I generally just use an INT array of 12 to hold the base offsets per month.

To use this routine, create a DINT array of 12 elements called "MonthValue", and assign it as follows:
MonthValue[0] := 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5
The final value, DayOfWeek is just that, Sunday = 0, Monday = 1, etc.
*)

Year := PLC_TIME[0];
Month := PLC_TIME[1];
DayOfMonth := PLC_TIME[2];
Curr_Hour := PLC_TIME[3];
Curr_Minute := PLC_TIME[4];


IF (((Year MOD 4) = 0) AND NOT ((Year MOD 100) = 0)) OR ((Year MOD 400) = 0)
THEN
MonthValue[0] := 6;
MonthValue[1] := 2;
ELSE
MonthValue[0] := 0;
MonthValue[1] := 3;
End_If;

DayOfWeek := (DayOfMonth + MonthValue[Month-1] + (Year MOD 100) + ((Year MOD 100) / 4) + 6) MOD 7;
 
rdrast

I need to re-read your "How to ask a question the SMART way", or learn to practice more patience.

Several hours after the post, I did more digging and found out the clock was not sync'd, to the "Grandmaster Clock" . Spent the next hour reading about the UTC.

After that the DOW now retained in the AOI after a power cycle. Ditched the Zeller and the MOV.

Any ideas on a seven day other than writing 30 lines of code for each day.

I found some old code out of another machine, former programmer for this company, scratch wrote a seven day, ( this is in rslogix micro ) 30 lines ( for each day M-S) to disseminate date and start/stop time entered from the HMI global parameters.

I'll keep searching for something a little more modern,

By modern.....................I mean easier.

Thanks rdrast.
 
Back
Top Bottom