Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Dean on November 02, 2015, 01:43:27 PM

Title: Daylight Savings Time Protocol
Post by: Dean on November 02, 2015, 01:43:27 PM
I've written a program block to monitor the state of DST and set or reset the $Summertime control bit. I think it will do what its supposed to, but manually manipulating the PLC clock is giving me a headache. If anyone has the time to give it a once over and provide feedback or critique I would appreciate it. If you don't know them already, here are the DST rules for North America. DST starts at 0230 on the second Sunday in March, and ends at 0230 on the first Sunday in November.
Title: Re: Daylight Savings Time Protocol
Post by: franji1 on November 02, 2015, 02:09:28 PM
For simple manipulation, use the SETTIME instruction.  Just set a User Date/Time structure (e.g. UDT0) to your desired date/time values via a Data View, then trigger the SETTIME instruction.
Title: Re: Daylight Savings Time Protocol
Post by: b_carlton on November 02, 2015, 02:22:15 PM
Instead of counting Sundays, why not just test the date of the month? 1st - 7th = first occurrence, 8th - 14th = second occurrence.

This also helps if the PLC program wasn't running during the first occurrence if you are looking for the second.
Title: Re: Daylight Savings Time Protocol
Post by: Dean on November 02, 2015, 02:34:50 PM
Thanks Bernie that is a better way. I hadn't thought of that possibility (Edit/ And its only two rungs instead of 6 /Edit). franji, thanks for that work around.
Title: Re: Daylight Savings Time Protocol
Post by: Controls Guy on November 02, 2015, 02:46:00 PM
Had to write my own DST one time in a Control Logix, which HAS a DST checkbox in its time master setup.  But, any changes in the system master clock require a program-to-run mode transition, and they couldn't shut down the plant.  I agree with Bernie -- check that it's Sunday, check the Day of Month range, and write to the system clock.  (Make sure to set a flag showing you've done it on "fall back", so you don't keep doing it every hour till the end of time, then clear the flag after the system time is out of the triggering window)
Title: Re: Daylight Savings Time Protocol
Post by: Dean on November 03, 2015, 11:59:50 AM
This is better I think. Sure is simpler, and as Bernie said, more error proof.