How to write to an OPC tag from an Expression tag

Sorry if this question is very simple, but I can’t think of a good way to do it.
I have an OPC tag (Coming from a PLC) and also an Expression tag with the expression below:
Both of them are boolean data types.

if ({[~]model.value}=1171, 1,
	     		0
)

I want to be able to write the current value of this expression tag to the OPC tag, and I do not want to use the value change event, since the value of my expression tag may not change a couple of times (so it would be true,true,true,false,true)

Thank you!

You need a script. A value change event would be simplest. But it could be a gateway timer event that simply reads from the expression and writes to the OPC tag.

1 Like

Thank you very much, Phill.
So the value change script executes only if we have changes in the value, correct? So it would be useless to use it when we have multiple unchanged values, right?

You made a really good point here. I never thought about gateway timers and actually never used them before.

So you mean I can simply use this to be able to write to the OPC tag, correct?

image

and in the timer script:

ExpressTag = system.tag.readBlocking("[default]ExpressionTag")[0].value system.tag.writeBlocking(["[default]PLCTag.value"], [ExpressTag]

1 Like

Yes, plus once more on tag definition edits (initial change). But you can also respond to timestamp changes with no value change. Tag events have the advantage of quick response.

1 Like

Thank you, Phill. Appreciate the information.