I have a tag that turns to zero and actual number every few second. how can I have a tag to just show me the Max value (Filter "0")?
Hello,
You could utilize a tag value change script on this tag, that writes to another tag.
Frank
Frank,
I wrote script as you said but I get "null" in my second tag. i have attached what I did. did I something wrong?
I interpreted the question differently. It seemed to me like you would want to just ignore a value of 0, and pass on the value otherwise. Is that correct?
Either way, I would suggest making a UDT, and do it in an expression without any scripting:
(my "raw" tag is memory in this case, but it works with OPC as well)
I think this expression would also work outside of a UDT. (in fact, it does).
There is a typo in your script. It should be currentValue.value
you are right. I had typo error. but this script gave me the MAX tag value and stuck on that number. which I want to have the Max for each Cycle. For example: when tag turns to 0 and 850 and turns to 0 and 843 and turns to 0 and 844 I want to have a tag to show me:
850, 843, 844 and ........
That's how I interpreted it as well. In that case, a similar expression will work:
UDT:
if(isNull({[.]Filtered_Raw}) || {[.]Raw} != 0, {[.]Raw}, {[.]Filtered_Raw})
or non-UDT:
if(isNull({[~]Filtered_Raw}) || {[~]Raw} != 0, {[~]Raw}, {[~]Filtered_Raw})
No need for the onChange script
Thank you. it works. I wrote it in Expression tag and solved the issue.