Time Elapsed

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #20462
      Karma: 25
      Rank: Padawan

      how do you calculate time elapsed between two dates



        Hi Ranga and welcome to the forums.

        Since you did not specify the type of controller you’re using, I’m going to assume it is a ControlLogix platform of controller. In this case, you can use the GSV (Get System Value) instruction to get the current date/time from your CPU. You can parameterize the GSV as follows:

        Class Name: WallClockTime

        Instance Name:

        Attribute Name: LocalDateTime

        Dest: Get_Date_Time[0]

        The Get_Date_Time[] tag is setup by creating an array of DINT[7] with each element of the array holding a corresponding portion of the date/time. Below is the actual array assignment:

        DINT[0] = Year
        DINT[1] = Month (1..12)
        DINT[2] = Day (1..31)
        DINT[3] = Hour (0..23)
        DINT[4] = Minute (0..59)
        DINT[5] = Seconds (0..59)
        DINT[6] = Microseconds (0..999,999)

        Once you have the tag setup and the GSV parameterized and added to your logic to execute every scan you can build the additional logic you’ll need to grab the time stamps. This could get tricky when your dates span different months, but hopefully this will get you started in the right direction.

        If you provide more information, perhaps we can get more community involvement to help solve your issue.


          Karma: 20
          Rank: Padawan

          If it is AB we are discussing there is a neat AOI you can use to calculate time between dates. It is in the sample code library. Just search something like “time between”. It should be one of the top hits from the search.

            Karma: 25
            Rank: Padawan

            It is an AB controller. i need to set a reminder to replace UPS batteries after every 2 years. thanks for the suggestions. i will try them and give feedback once i get back to office early next year.

            Cheers. A happy Festive season.

              Karma: 21
              Rank: Padawan

              Used that AOI it’s easy to implement and does the job.  Search for “Elasped Time Add-on Instruction” (Yes, Elapsed is spelled wrong ?)

            Viewing 5 posts - 1 through 5 (of 5 total)
            • You must be logged in to reply to this topic.