Forcing a Tag to Rewrite Value 0 Every 10 Seconds

Hello, community!

I’m trying to ensure that a tag in Ignition continuously receives the value 0 every 10 seconds if its current value is 0.

Scenario:

  • The tag receives values from a PLC.
  • When the tag is 0, I need Ignition to keep rewriting 0 every 10 seconds.
  • This is necessary because the value 0 might be interpreted as an "unchanged state," and some external systems may not recognize that it is still valid.

What I've tried so far:

  • A Gateway Event Script (Timer) running every 10 seconds.
  • Using system.tag.writeBlocking() to rewrite the value.
  • Logging for debugging, where I can see that the script is executing correctly.

Problem:

  • The script runs and logs that the write operation was executed, but in Tag Diagnostics, the tag’s value does not change or show an updated timestamp.
  • It seems like Ignition is not rewriting 0 to the tag if it is already 0.

In short, I need the tag to be published in MQTT even if the value is zero.

Why would you expect it to change if it was zero and you write a zero to it?

Script the write/publish to Mqtt directly instead of using tag.write*? I believe the MQTT modules have some scripting methods available.

2 Likes

I just need it to be published even if the value doesn't change.

We use this tag to feed a dashboard into another system. If the value is 0 and it is not published, the other dashboard will not display the value correctly, and it is necessary to always send the data.

It must be a folder where the tags for this project have been mapped.

From this folder, when the tag is published, it is sent via MQTT Transmission to AWS IoT Core.

Ok so with system.tag.writeBlocking, can you try adding same tag path twice in list and write -1,0 in it

1 Like

MQTT and OPC are both designed to very deliberately and explicitly NOT do this, and cannot be configured to do it anyways. Your Ignition tag will not show a new timestamp without an actual change. Either to value or quality.

Your dashboard is broken.

8 Likes

Seems like those systems need to be fixed, not the tag.

Surely you can add a default value into your dashboard of 0.

Cluthering your db/mqtt/stream with empty useless data is inefficient and costly.
aws will charge more money if you send more (or bigger) messages, so don't do this.

You will want to use connectioning pings if your system thinks the connection is broken (check connectivity)

3 Likes

I agree with @ryan.white that you'll have to script a manual MQTT write. I also agree that the system requiring data every 10 seconds is broken. What if the value sits at a 1 or any other value for more than 10 seconds? Is it also assumed to be broken? Values don't naturally write to 0 in MQTT if a system goes down unless the LWT is configured to do so. In Sparkplug there's no control over the LWT but I haven't used AWS so not sure how it's handled with it.

1 Like

If the tag is reading directly from a PLC, I have found that it creates an error if I try to write to it since that puts it in a read only state.

A way I have had to do it in the past is put a tag change script on the PLC tag and write to another memory tag that you can then update if needed.

This is because that tag is set as read-only somewhere. PLC tags in general are not read-only by default.

The tag I used for the example isn't set to read only.