How to write to a memory tag through the value changed from another tag?

I’m new on ignition and I have created a memory tag named “tag_test” which is an Int4, I want to increment the value of this tag by 1 every second. Once the tag is greater than 29999 I want to reset it back to 0.

I added the no value changed lineup of the expression tag called “tag_master”, and in the expression I put the lineup" now () “, so that every time the value in” tag_master changes, it would add +1 to tag_test. but I’m not having success. where am i going wrong?

You have a couple potential problems. First, depending on scan class, this may not update every second as you expect. Consider ensuring the scan class updates more than once per second, changing your master tag data type to integer, and changing your expression to:


In your script, indentation matters; that red underline is because the line is indented further than it should be (put your mouse over the underline in the editor and you’ll see the error message–a script with red underlines in it won’t work).

You can make it easier for others to help with your code by posting it as preformatted text (use the button in the post editor that looks like this image).

The below code should do what you’re looking for:

count ='tag_test').value
newCount = (count + 1) % 30000
system.tag.write('tag_test', newCount)
1 Like

thanks for the excellent explanation!!!