Writing value to tag from expression tag

I have an expression tag which simply takes the current time in seconds. I want to write this value to an OPC tag. I have the expression tag correctly updating based on the seconds. I read you could set an OPC tag directly from this tag but can’t seem to figure out how to do it. It almost looks like you could do it in an earlier version of ignition but not anymore? I tried writing a Value changed event script to write the value of the expression tag to an OPC tag but no luck.

You should be able to do this with a gateway tag change script for your currentseconds tag.

system.tag.write("ScadaHeartbeat",newValue.value)

sounds good but I would rather do it with the UDT. I have six identical machines and would like to keep it within that machine UDT. I dont understand why this wouldn’t work?

I don’t have enough experience with UDT’s to answer that one, hopefully someone who does will chime in.

It seems as if the script if dead on and should be changing the tag. I have a simulator set up and can change the value of the tag from the plc. If I try to change it from Ignition I get the following:
image.
I had the tag in the plc set to read/write and tried changing it to read only. The scadaheartbeat tag is set to read/write. Is it a matter of the tag only able to change values from the plc and that is why no matter what I do the value of the tag within ignition won’t change?

Can you write to the scada heartbeat tag manually?
Also, I don’t mean to preach, but I would consider reviewing the tag names in that UDT as you have a mix of at least 4 different standards (snake_case, Capital_Snake_Case, Title Case, and PascalCase) which will most certainly trip you up while developing the graphics

1 Like

Anytime I try to change the value manually I get that error. I just created a memory tag and changed the Value changed event script to write to the memory tag it works perfect. For some reason I am not able to write to the OPC tag. I tried deleting the tag and recreating it again within the UDT. The security is set to be able to read and write to it

I agree. This was my first project and someone else helped so things weren’t uniform but next project I will be more consistent

Is the OPC tag from the Ignition server? If so, what driver?

Yes it is from the Ignition server. The driver is the Allen-Bradley Logix Driver. I am on version 8.0.14 of Ignition.

Turn the logger drivers.LogixDriver.Requests.WriteTagsRequest to DEBUG, attempt the write again, and post the error you see in the gateway logs.

https://docs.inductiveautomation.com/display/DOC81/Diagnostics+-+Logs#DiagnosticsLogs-ChangingLoggingLevels

While waiting for response I went ahead and change tag on plc side from Read/Write to Read Only. Then changed it back to Read/Write. Then went ahead and changed logs like above. I then tried to change the value manually through ignition and it didn’t give me the error but it didn’t change the value at all when I try to manually change it so I didnt get anything in the logs.

Now if I change it through the plc it changes. If I then try to change it in ignition, not matter what I put, it always changes the value in ignition and the plc to 1. Weirdest thing I have ever seen.

Do you have your designer set to read/write comms? Do you have the right data type set in the tag?

I do. Now I went ahead and created a new tag in plc called heartbeat but made it a DINT. I then created the tag in ignition in my UDT called heartbeat and made it a double. Literally the same as the other tag except the only difference is the type. Now I can change it in plc and gets changed in ignition. Also if I change it in ignition it now changes and value also gets changed in plc.

As far as datatype I am only looking for numbers between 0 and 59 so INT should work

This is the code I have in the plc. The plc isn’t writing to this tag at all.

Thank god its Friday. Essentially started from scratch. Erased plc code. Deleted Scada_Heartbeat tag from plc. Erased from ignition. Created new plc tag called Heartbeat_Scada in plc. Created new ignition tag called Scada_Heartbeat and saved as a memory tag. Wrote the value changed script on currentseconds and the Scada_Heartbeat ignition tag correctly updated. Then changed Scada_Heartbeat tag from memory to OPC tag and linked to Heartbeat_Scada tag in plc. Everything is now working…WTH???

1 Like

You obviously had something wrong. :grin:

In the screenshot, you have the sense of Ignition_Comms_Faulted_Tmr backwards. The DN bit is ON when Scada_Heartbeat is steadily changing.

I think you are correct…when people tell me the code just started going haywire…99.9999% of the time its not when its worked for the last 5 years…glad the ignition side is working now haha