Steve Boyko

Lifetime Counters

Discussion created by Steve Boyko Champion on Dec 19, 2012
Latest reply on Dec 19, 2012 by MIPAC

One of our clients has a set of PI tags that count the total amount of electricity consumed (in kWh or MWh). They reset occasionally to zero and we want to have PI tags that contain a non-resetting value, e.g. they keep accumulating even after the source tag resets to zero.


I built some Performance Equations to handle this, and they work pretty well, but not perfectly.


The basic algorithm is:

if 'source' = PrevVal('source', '*') then    ' no change
   if 'source' < PrevVal('source', '*') then   ' reset
      'lifetime' + 'source'
   else    ' normal accumulation
      TagVal('lifetime', PrevEvent('source', '*')) + 'source' - PrevVal('source', '*')
   end if
end if



The problem is that the 'source' tag will reset to zero for a few minutes when they update the PLC that is generating these values. This causes the lifetime counter to reset and then jump ahead when the source value returns to a normal value.


Am I overcomplicating this? Is there a better way / better tool for this in PI?