Author Topic: Date & Time to PLC  (Read 1984 times)

Steve Etter

  • Newbie
  • *
  • Posts: 26
    • View Profile
Date & Time to PLC
« on: November 02, 2017, 04:08:14 PM »
Is there an easy way to send the Date and Time data from the HMI application to the PLC?  I figure I can scratch out some code and a timebased update routine if I have to, but I imagine someone is already doing this.  Thanks in advance.

Phrog30

  • Guest
Re: Date & Time to PLC
« Reply #1 on: November 02, 2017, 04:19:48 PM »
Most applications I use are the other way, the PLC is the master and sends to the HMI.  But, if you did do this, I would only update once a minute.  So, create a timer in a form that is always open and on the tick event send the current time to the PLC.  Example, getting current hour:

Code: [Select]
DateTime.Now.TimeofDay.Hours

Steve Etter

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Date & Time to PLC
« Reply #2 on: November 03, 2017, 07:25:27 AM »
I will give this a try.

There are two reasons I want to do this from the HMI to the PLC rather than the other way around.  First, I am using this HMI to control two completely separate but mirror-imaged machining cells.  Each cell has its own PLC and, with a couple of minor exceptions, the two PLC programs a virtually identical.  One feature the HMI then has is production monitoring which, in turn, is time based and uses each of the PLC's internal clocks.  Since both show up on the same HMI page, discrepancies in the two clocks become obvious.  Second, the time tracking of a PLC is notably less accurate than a PC based HMI.  Operations uses these clocks pretty faithfully and I'm frequently having to update clocks on other similar systems where there the PLC clock is the master.  I'd like to begin eliminating that issue.

Hope that makes sense.

Noe

  • Full Member
  • ***
  • Posts: 205
    • View Profile
Re: Date & Time to PLC
« Reply #3 on: November 03, 2017, 10:09:48 AM »
Which PLC are you using?

Steve Etter

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Date & Time to PLC
« Reply #4 on: November 03, 2017, 11:04:50 AM »
AB CompactLogix.

Ok.  This method seems to work well.  Because the Timer.Interval is an integer, the max setting is 65,536 or (65.536 seconds), I chose to set my updates for every 65 seconds.  This should be plenty often for my needs and allows the clock to cycle all the way through so that I should never miss a "minute" of timing has passed.