Setting the date from a CLX to Red Lion HMI

Bullzi

Lifetime Supporting Member
Join Date
Jun 2012
Location
Colorado
Posts
1,530
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.
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;
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!!
 
No idea but interesting enough google seems to know..when searching "how many seconds has passed since 1-1-97"

I would think something like doing the math up to the day before you were going to download then adding current time in seconds to your count, but likely someone has a better option.
 

Similar Topics

Below is how I set my PID LoopUpdate time, feel free to make suggestion or comments. The PID loop is used to regulate water back pressure. Since...
Replies
0
Views
1,249
Redlion Graphite G07 Crimson 3.0 Build 624.005 How can you set the time and date from the HMI in a user friendly format? I know theres the...
Replies
23
Views
14,139
Greetings In our plant we use a ControlLogix5563 as our main data handling PLC. Recently I noticed that the controller date/time setting differs...
Replies
3
Views
4,172
Hey, hows it going? I was wondering if anyone can help me with setting the time and date on a q-series plc. I used the time settings window in GX...
Replies
3
Views
4,242
Hello, Does anybody know how I can save the changed date of a Siemens TP170-b so that when I put the power on again its is still the date and...
Replies
12
Views
4,011
Back
Top Bottom