0

Time Since False

I've got a use case where I want to keep a running timer of how long a piece of equipment has been off. There is a tag for status: 1 = running, 0 = off. How long the unit has been off will affect how long it takes to start the unit up, so operations wants to know at a glance how long it's been since status went from 1 to 0. Any thoughts on how to do this?

My current plan: Have a calculation that writes the current timestamp to a tag whenever the status goes from 1 to 0 (using PreviousValue to check). Then a new calculation(or maybe just a new expression) that does durationsincetimestamp of the previously defined tag and outputs that to a 2nd tag.  Thoughts?

8 replies

null
    • smason
    • 3 wk ago
    • Reported - view

    Hi ,

    If you just used DurationSinceLastTVQ, that would output the number of milliseconds since the last value. You would want to make this a periodic calculation. If you use this function in conjunction with the Value Change frequency, it would always output 0. So maybe you run it every minute??? It would depend on how granular you want the time elapsed to be.

    This would also return the amount of time it was running so you may want to build in something to ignore that time or output nothing if it is in the running state.

    if([StatusTag]=0, DurationSinceLastTVQ('[StatusTag]'), NoOutput())

      • damon_vinciguerra.1
      • 3 wk ago
      • Reported - view

       thanks for the quick reply. I thought about that. But what if the Collector restarts and there's a NoData followed by another 0? Would DurationSinceLastTVQ start from the first 0? or the latest one? Similarly, what if (somehow) a 2nd 0 was written, it would just count from the 2nd 0, right?

      • smason
      • 3 wk ago
      • Reported - view

      You're right. I think it would use the latest 0 timestamp. I don't think your initial method will work because we don't have any function that outputs a timestamp as a value, but I think we could still make something work using that same logic. I think you need two tags. The first marks the time it initially goes to 0.

      if([StatusTag]=0 and PreviousValue('[StatusTag]')=1, True, SetOutputQuality(NoData))

      I'm using the "SetOutputQuality" instead of "NoOutput" because that will actually create a break in the data between times it is not running. If we use NoOutput, it will maintain the last value which I don't think will work for the next calc. I think this will also help to guard against the scenario if the collector is stopped and a NoData is recorded followed by a subsequent 0. This calc will just output a NoData in those scenarios.

      The second calc will use the output of the first, which I'll call [NotRunningTag].

      DurationSinceLastTVQ('[NotRunningTag]', 'true')

      The "true" parameter tells the function to ignore Bad qualities. So even if the first calc produces NoData qualities, it will not reset the duration.

      I think this will work...

      • damon_vinciguerra.1
      • 2 wk ago
      • Reported - view

       I think I 90% get it.  On the first calc, why would NoOutput not work? Is that because the system will extend the last known value which will make DurationSinceLastTVQ always see something in the last minute?

      • smason
      • 2 wk ago
      • Reported - view

      Yeah, the last value would just continue and I think we want to create a break. Test it out and see if it works for you.

    • damon_vinciguerra.1
    • 2 wk ago
    • Reported - view

    I just did a test on a different tag, it seems DurationSinceLastTVQ  doesn't look at the extended value.

    Shows last TVQ 6.3 hours ago:

    Right now it's 1:07 PM and last real value was 6:43 AM. The extended value is 3 minutes ago and seems to be ignored. I tried both true and false in the 2nd parameter of the DurationSinceLastTVQ function and it didn't seem to matter.

      • smason
      • 2 wk ago
      • Reported - view

      That is correct. It looks at the last raw value, not the time-extended value. Setting the 2nd parameter to true or false would have no bearing in this scenario as it is only used to ignore Bad quality changes.

    • damon_vinciguerra.1
    • 2 wk ago
    • Reported - view
     said:
    the last value would just continue

     I guess I misunderstood what you meant by 👆. I thought you were talking about how Canary extends the value if it hasn't gotten one in a while. But I guess you were talking about how Canary won't store the same value two times in a row.

     

    Either way, I'm on board now. I tried using NoOutput() to prove it to myself. It worked at first, but then it never wrote again. 😬

    Now if I can just figure out why turning on this calculation breaks SaF. (Nicklaus is looking into it)

    if(PreviousValue('[Mountain Creek.%Asset%.Energy Production Status]') = 1 && [Mountain Creek.%Asset%.Energy Production Status] = 0, 'Shutdown', SetOutputQuality(NoData))

Content aside

print this pagePrint this page
  • 2 wk agoLast active
  • 8Replies
  • 16Views
  • 2 Following