News:

  • May 05, 2026, 11:56:07 AM

Login with username, password and session length

Author Topic: Daylight Savings Time Protocol  (Read 9218 times)

Dean

  • Sr. Member
  • ****
  • Posts: 73
Daylight Savings Time Protocol
« 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.
10 Lather
20 Rinse
30 GOTO 10

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
Re: Daylight Savings Time Protocol
« Reply #1 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.

b_carlton

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 606
    • thePLCguy
Re: Daylight Savings Time Protocol
« Reply #2 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.
« Last Edit: November 02, 2015, 02:26:47 PM by b_carlton »
An output is a PLC's way of getting its inputs to change.

Dean

  • Sr. Member
  • ****
  • Posts: 73
Re: Daylight Savings Time Protocol
« Reply #3 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.
« Last Edit: November 02, 2015, 03:03:26 PM by Dean »
10 Lather
20 Rinse
30 GOTO 10

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: Daylight Savings Time Protocol
« Reply #4 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)
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Dean

  • Sr. Member
  • ****
  • Posts: 73
Re: Daylight Savings Time Protocol
« Reply #5 on: November 03, 2015, 11:59:50 AM »
This is better I think. Sure is simpler, and as Bernie said, more error proof. 
10 Lather
20 Rinse
30 GOTO 10