Hi Everyone,
PLC: 1769-L30 V32
HMI: CR3000 Crimson 3.1 Current Version
Years ago someone on this Forum gave me this program that will set the Date and Time in the PLC from the Red Lion HMI.
This has worked great with no issues.
Recently I added a AOI that will take care of the time change due to DST. Now I would like to the PLC to be the Time Taster and write the time to the HMI a couple times a day. I am doing this mostly so the log files on the HMI happen at the exact same time as the day change on the PLC. That way my data matches properly.
Looking at the Red Lion manual to set the date you have to use the SetNow(Time)command. The "Time" in the command is the number of seconds that have elapsed since 1-1-1997.
My question is what is the best way to compute the number of seconds that have elapsed since 1-1-1997?
Thanks for any help you can provide!!
PLC: 1769-L30 V32
HMI: CR3000 Crimson 3.1 Current Version
Years ago someone on this Forum gave me this program that will set the Date and Time in the PLC from the Red Lion HMI.
Code:
/*
Synchronize PLC time to match HMI local time
Write time values to the TIME_DATE_ARRAY array.
A flag tag is used to trigger PLC update of the RTC.
*/
TIME_DATE.TIME_DATE_ARRAY[0] = GetYear(GetNow());
TIME_DATE.TIME_DATE_ARRAY[1] = GetMonth(GetNow());
TIME_DATE.TIME_DATE_ARRAY[2] = GetDate(GetNow());
TIME_DATE.TIME_DATE_ARRAY[3] = GetHour(GetNow());
TIME_DATE.TIME_DATE_ARRAY[4] = GetMin(GetNow());
TIME_DATE.TIME_DATE_ARRAY[5] = GetSec(GetNow());
/*
Set a the Flag Tag to a 1 or 0. This will set a bit
in the PLC to move the time and date into the PLC
Real Time Clock
*/
TIME_DATE.SET_TIME_DATE = 1;
TIME_DATE.SET_TIME_DATE = 0;
Recently I added a AOI that will take care of the time change due to DST. Now I would like to the PLC to be the Time Taster and write the time to the HMI a couple times a day. I am doing this mostly so the log files on the HMI happen at the exact same time as the day change on the PLC. That way my data matches properly.
Looking at the Red Lion manual to set the date you have to use the SetNow(Time)command. The "Time" in the command is the number of seconds that have elapsed since 1-1-1997.
My question is what is the best way to compute the number of seconds that have elapsed since 1-1-1997?
Thanks for any help you can provide!!