Author Topic: Daylight Saving Time with ML1400  (Read 2406 times)

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Daylight Saving Time with ML1400
« on: November 05, 2018, 01:48:42 PM »
Would you have any ideas how to implement a Daylight Saving time in ML1400? 
I currently use the Set Date & Time button to set it to the correct time.

TIA



My idea, .NET PC will generate DST event , then PC will write to PLC to change its time:

Code: [Select]
S:37 0 Clock Calendar Year
S:38 0 Clock Calendar Month
S:39 0 Clock Calendar Day
S:40 0 Clock Calendar Hours
S:41 0 Clock Calendar Minutes
S:42 0 Clock Calendar Seconds
S:43 0 STI Interrupt Time
S:44 0 I/O Event Interrupt Time
S:45 0 DII Interrupt Time
S:46 0 Discrete Input Interrupt-


I was able to change the hour as a test:



« Last Edit: November 05, 2018, 02:24:37 PM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Phrog30

  • Guest
Re: Daylight Saving Time with ML1400
« Reply #1 on: November 05, 2018, 06:27:10 PM »
Look at this, https://stackoverflow.com/questions/22297089/get-internet-time-instead-of-pc-time-in-vb-net, I would use the. Net app to be the master, then send to the plc.

Since you already got the hour to work, the rest is easy.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Daylight Saving Time with ML1400
« Reply #2 on: November 05, 2018, 07:22:25 PM »
This may work:

Code: [Select]
Dim localZone As TimeZone = TimeZone.CurrentTimeZone
'
AddHandler SystemEvents.TimeChanged, AddressOf SystemEvents_TimeChanged


Private Sub SystemEvents_TimeChanged(ByVal sender As Object, ByVal e As EventArgs)
      'Occurs when user manually changes the time or due to daylight saving time.
       Dim daylight As DaylightTime = localZone.GetDaylightChanges(DateTime.Now.Year)
       If localZone.IsDaylightSavingTime(DateTime.Now) Then           
            'If daylight.Start = DateTime.Now Or daylight.End = DateTime.Now Then
                'DST occur write to PLC
                PLC.Write("B3:0/14", 1)                 'TimeChange Enable bit
                PLC.Write("N9:3", DateTime.Now.Hour)
                PLC.Write("N9:4", DateTime.Now.Minute)
                PLC.Write("N9:5", DateTime.Now.Second)
                PLC.Write("B3:0/14", 0)
            'End If
       End If
End Sub


« Last Edit: November 05, 2018, 08:41:35 PM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Daylight Saving Time with ML1400
« Reply #3 on: November 27, 2018, 10:15:01 AM »
Attached is an updated DST version for Micrologix without PC. Other versions out there are not using the current rule of DST.
Noted that without a PC, the PLC clock will drift overtime.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================