How to change Daylight saving time ON/OFF automatically in Crimson3.0&3.1/Redlion HMI

gzPLC

Member
Join Date
Oct 2018
Location
Texas
Posts
39
How to change Daylight saving time ON/OFF automatically in Crimson3.0&3.1/Redlion HMI

How to change Daylight saving time ON/OFF automatically in Crimson3.0&3.1/Redlion HMI?

T
 
As far as I know there is no automatic way to adjust DST. There is the 'UseDST' system variable but this just sets the time ahead or back one hour--the programmer has to set the variable.

Here is some code I've used in the past to control daylight savings time. I can't take full credit for this--I think I adapted it to Crimson from a snippet I found in some other forum. Put this in your global OnTick action to run once per second.

Code:
// Daylight Savings Time runs from 2nd Sunday of March to 1st Sunday of November
int month := GetMonth(GetNow());
int date := GetDate(GetNow());
int previousSunday := date - GetDay(GetNow());

// January, February, and December are out
if (month<3 || month>11) UseDST := false; 
// April to October are in
else if (month>3 && month<11) UseDST := true;
// In March, we are DST if our previous Sunday was on or after the 8th
else if (month==3) UseDST := (previousSunday >= 8);
// In November we must be before the 1st Sunday to be DST
// That means the previous Sunday must be before the 1st
else UseDST := (previousSunday <= 0);
 
Thanks for the code Kolyur, I just wanted to ask once I write this code I am not supposed to do anything right?

Till now we used to do send time from PC:doh: to all our HMIs every time DST turns ON/OFF.
 
As long as the DST code is executing regularly (in OnTick or some other action) and you have the time and date on the HMI set correctly, then yes the DST adjustment should occur as necessary without any further action. (y)
 
As far as I know there is no automatic way to adjust DST. There is the 'UseDST' system variable but this just sets the time ahead or back one hour--the programmer has to set the variable.

Here is some code I've used in the past to control daylight savings time. I can't take full credit for this--I think I adapted it to Crimson from a snippet I found in some other forum. Put this in your global OnTick action to run once per second.

Code:
// Daylight Savings Time runs from 2nd Sunday of March to 1st Sunday of November
int month := GetMonth(GetNow());
int date := GetDate(GetNow());
int previousSunday := date - GetDay(GetNow());

// January, February, and December are out
if (month<3 || month>11) UseDST := false; 
// April to October are in
else if (month>3 && month<11) UseDST := true;
// In March, we are DST if our previous Sunday was on or after the 8th
else if (month==3) UseDST := (previousSunday >= 8);
// In November we must be before the 1st Sunday to be DST
// That means the previous Sunday must be before the 1st
 else UseDST := (previousSunday <= 0);


I like that, and have "pinched" it.

Previously I had a long list of Years and Dates (Day of the month) that would trigger DST to be turned On or Off, so just checking the date for the Last Sunday in March (DST On in the UK), and Last Sunday in October (DST Off in the UK) is so much easier.

Since March and October both have 31 days, if it's a Sunday, and it's greater than the 25th of the month, that's when DST changes.

Here's what I have done for Logix5000...

2019-01-02_235253.jpg 2019-01-02_235227.jpg
 

Similar Topics

I am using a PanelView 600 and an L32E Processor. Recently the time has changed due to Daylight Savings Time. My PanelView is now an hour ahead...
Replies
6
Views
2,826
I have two identical machines running similar HMI projects, the only difference is one is done in FactoryTalk View Version 10 and the other is...
Replies
3
Views
154
Hoping someone can give me some guidance or confirmation of what I need to do. We have a FactoryTalk SE program that I need to change the IP...
Replies
2
Views
102
Hey all, i have a panelview screen (image attached), with 4 items on it. Program 1, Program 2, ...3, ...4. The PLC i am using is a compactlogix...
Replies
5
Views
186
Greetings I have a problem, my system is the following: wincc v8.0 (demo), logo8.3, abb m2m analyzer. I created some pages to display the...
Replies
0
Views
75
Back
Top Bottom