# Run a tag value changed not changed

**URL:** <https://forum.inductiveautomation.com/t/run-a-tag-value-changed-not-changed/16253>\
**Category:** Ignition\
**Created:** [December 7, 2017, 10:04pm UTC](https://forum.inductiveautomation.com/t/run-a-tag-value-changed-not-changed/16253 "2017-12-07T22:04:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jhahn](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@Jhahn](https://forum.inductiveautomation.com/u/Jhahn)\
**Post date:** [December 7, 2017, 10:04pm UTC](https://forum.inductiveautomation.com/t/run-a-tag-value-changed-not-changed/16253/1 "2017-12-07T22:04:18Z")

</div>

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.

Edit

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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 8, 2017, 12:05pm UTC](https://forum.inductiveautomation.com/t/run-a-tag-value-changed-not-changed/16253/2 "2017-12-08T12:05:19Z")

</div>

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.
