Run a tag value changed not changed

I am collecting out feed data. I have a tag called total_outfeed. Right now this is the only tag I can access on the plc. I have a Valuechanged script that calculates the current value by subtracting current value - previous value.

My issue is when the machine is down, total_outfeed does not change, so the script throws an error. How can I get this to work?
My current solution is to have three tags with offset scan settings.

I have
Tag A set to default scan class
Tag B set to scan every 10

Both reading total_outfeed.

Then every 60 sec I run the B-A to get the current outfeed.


I should clarify I have three outfeed tags on my device. Just because plc1 is down two and three could be running. So when plc1 is down it will throw off my total count.

Subtracting a value from itself is always racy. Use a memory tag that you snapshot from the current value on an appropriate time interval, and subtract that from current value the rest of the time to get the count during the interval. Use another memory tag to hold the timestamp when you last performed the snapshot, so you know when to do it again, even if the PLC has been down through a boundary. The tag change script on current value should do nothing when the tag quality isn’t Good.

1 Like