Background:
PI - 2012, with AF (not relevant, but maybe if someone thinks I should use AF or Event Frames to solve the problem).
PI is connected via OPC interface to an OPC server that is reading data from a Rockwell ControlLogix PLC.
The counter that I am dealing with a simple one. It takes a photo eye and counts boxes as they pass by. The value of this counter is read by PI. So the number starts at zero (after a reset) and increments by 1 as boxes go by. The scan time is set to 10 seconds, so most of the time it goes up by 1 every scan, but sometimes it might be 2 or 3 depending on which line and how fast it is.
The operator has a reset button to reset the counter (start a new order).
Exception deviation is set to 1, compression deviation is set to 2. Once a line is running steady, the boxes are failry consistent so compression does a pretty good job.
Now the problem:
I need to display to the operator the number of boxes made in the last hour (or any previous hour). This would be easy if there were no resets...but at any given time the operator resets the counter to zero when they start the new order.
For example, starting at hour 1 lets say the counter is 10, it runs up to 60 and is then reset. Runs up to 40 is reset and then continues to run and at the end of hour 1 is at 160.
The math I need is:
(60 - 10) = 50
50 + 40 + 160 = 250 counts in hour 1.
Let's call the counter tag "BoxCount"
I have setup a totalizer tag, using "BoxCount" as the SourceTag. I have set the type to Block Event Weighted Total with Natural sampling. Results are set to time period with schedule start at 0 and results every hour. I have set to do not write interim results, but I have tried it as ramp too and the issue is the same. I have set the option "Source tag is a DCS integrator" with conversion factor of 1.
This tag works perfectly when the counter is not reset during the hour, it counts up the total boxes during that hour.
The problem is when the counter reset during the hour, I get a negative value into the totalizer. For example if the counter is at 500 total, with 200 since the last hour, so the totalizer is at 200. Then the counter resets to zero and the totalizer subtracts 500 from 200 and I end up with -300 and it starts adding again until the next hour. So my count is off by -300.
I assumed that setting the "DCS integrator" option would tell the totalizer to ignore the reset to zero and just keep adding...but it doesn't.
I tried using a filter on the source data of PrevVal('BoxCount')<'BoxCount' but then I don't get anything...I also tried reversion the < to > and I still don't get anything.
Anyone have any idea how to make this work?
Thanks for the help.