guitargeekrich (Customer) asked a question.

Productivity series PLC - events based on clock time

I have an application (using the Productivity 2000) where I want to control 6 separate outputs based on the time of day, as well as the day of the week. Each output requires a minimum of 12 user configurable "on times" and "off times" per day of the week. Currently the only path I see to building out this logic is:

 

  1. to have the user enter in the hour and minute for every on and off time as integer values
  2. convert the on and off time integers and convert it to a ratio of the total number of minutes in a day (for example: a number of 60 would be 1 a.m., 120 would be 2 a.m., etc.
  3. Then take the current clock time and convert it to the total number of minutes surpassed thus far in the day ala step 2.
  4. Then finally, using compare instruction and many, many rungs of code - compare if the current time of day is between each on time and off time entered by the user. For each day of the week. For each of the 6 outputs...

 

Someone please tell me there's a better way 😁


    • guitargeekrich (Customer)

      Thanks Garry - this is similar to what I was originally thinking, but my issue is with the minutes. If I want an output to come on at 3:00 a.m. and go off at 4:30 a.m., the compare instructions work fine for the hours. But for the minutes, as soon as it hits 3:31 a.m. the output would go off (as both the hours and minutes logic would need to be "AND." Maybe I'm missing something with your recommendation? This is why I came up with having the RTC hours and minutes combined into one continual number that starts at 0 (midnight) and ends at 23:59 (11:59 PM).

      Expand Post
      • Durallymax (Customer)

        Garry's shows the hours and accounts for times that roll over midnight.

         

        This snip is the same with additional instructions for minutes and also shows if you were to convert the times into seconds. IMO This would be a mess and a lot of work to repeat a minimum of 72 times, but I'm lazy.Clock CMP

        Expand Post
      • Garry (Customer)

        Here is the same logic with the minutes added.

        Productivity Clock Compare Hours MinutesIf the current hour from or to is equal, then compare the minutes.

        I hope this helps you out.

        Regards,

        Garry

         

        Expand Post
      • guitargeekrich (Customer)

        Thank you guys - now it makes sense. I can simplify it further as the requirements don't need to allow start/end dates to be different (monday can't carry over into tuesday). And entering in military time will also be fine (and prevent confusion). I appreciate the prompt response!

  • PouchesInc (Customer)

    Do not forget to give the P2k internet access or at least access to a network time server on your own LAN where it can pull time updates from to keep the clock accurate. Otherwise the RTC will drift too much to be useful after a while and require manual correction.

  • Durallymax (Customer)

    If I understand you correctly there are 6 outputs with 12 time start/end set points that are unique to each day? That would be a lot of rungs using compares.

     

    This is one way to accomplish it. 2D arrays with the row as the day of the week (remember Monday is 1), and the column as the user entered set point for the various arrays. The loop will look through every set point and if they are met, the output will be on.

     

    Edited for correct photo.

    Clock Array Loop4

    Expand Post
    • Durallymax (Customer)

      Whoops that snip had some errors in it, updated the photo to the correct one.

      • guitargeekrich (Customer)

        I'm gonna take some time to unpack this - I don't use arrays very often. Thank you!

10 of 15