I would like to know if there is a way to have a reference tag always write a value to an OPC tag. I am using this as a readback to the PLC for sequencing interlocks.
Essentially when I trigger a transaction group, I write to the OPC with a tag event based on the OPC trigger using the following on change:
if currentValue.value == 1:
system.tag.writeBlocking("[.]../DB_TO_PLC/ADD_TRIGGER_READBACK", "Triggered!")
if currentValue.value == 0:
system.tag.writeBlocking("[.]../DB_TO_PLC/ADD_TRIGGER_READBACK", "")
This works most times but I am finding times when the event either doesn’t fire or is not writing the correct value to the OPC tag. I am thinking this is a delay issue as this sequence is running pretty fast (+/- 0.5 Second) and the trigger may turn on and off before ignition reads the change.
My next step was going to write gateway event scripts based on timers that would run all the time but I am thinking this is not an efficient way of doing it.
Please describe your trigger and handshake items in more detail. I suspect you are suffering from race conditions. To “go fast”, you generally need a trigger that works on value change (incrementing byte or small integer is my preference), not a boolean rising edge. The subscription pace for boolean triggers must be more than twice as fast as for simple change-based triggers, since the boolean transition back to false must be “seen” before you have another rising edge.
Another common race condition is when writing a handshake from two directions. If the PLC sets true, and Ignition resets to false, the write to make false can be “lost” if the PLC sets true before the next OPC poll. No need to reset an on-change trigger, so this race is avoided.
The simplest handshake when using an on-change trigger is to echo the changed value back to the PLC in another tag. The PLC can trigger again as soon as it sees “equals” without creating an OPC race.
So in my sequence I have the roughly the following,
Step 0 - start
Step 10 - Verify Readback String Equals “” (Blank) and Trigger is Off
.
.
.
Step 40 - Trigger the Database Transaction (Trigger goes true or 1 as it is a bool on a latch)
Step 50 - Verify the Readback String has a Value of “Triggered!” (Only the tag event script on the trigger in ignition is writing to this OPC tag with the script posted earlier)
Step 60 - Unlatch Trigger when a handshake success, fail, or database timeout occurs.
.
.
Reset Sequence
This is done just as another verification that the database was triggered along with the handshake success and handshake fail statues from the transaction group. Where the issue is happening is the sequence gets to step 50 which means it saw the Readback as an empty string which tells me the trigger was off, but then gets hung up because the readback string is not reading “Triggered” even though the trigger is on.