OPC Tags not updating at the same time?

Hello,

I am working on a project at the moment where I am using Gateway Event (tag value change) scripting to read some OPC tags and then write the values into a database.

In the PLC I have a sequence where it unloads the data from a buffer into the tags I am reading in Ignition then the PLC turns on a boolean bit to signal that new data available to be read. The tag value change script is triggered by this boolean bit.

The issue I am having at the moment is that I have to have a long enough delay in the PLC before I set the boolean bit high after unloading the buffer otherwise I sometimes end up having duplicated data in the database. All the tags are in the same scan class so I thought they would update at the same time.

It’s not too big of major to have that delay in the PLC as it will still be fast enough for the process but I am curious to find out as to why this is happening and if there are alternative solutions (maybe something to do with my gateway settings?) that doesn’t require the delay in the PLC therefore optimizes the system.

The only reason I can think of is that maybe when the tag change script gets triggered the scan class hasn’t complete updating the whole tag block but I am not sure if my understanding is correct.

Details:
Ignition Version: 7.9.10
OPC Driver: Legacy AB compactLogix
PLC: CompactLogix v.20
Scan Class: 200ms, 130 tags on this scan class
Database: MySQL
Amount of delay required in PLC: 200ms tested to be reliable

Any suggestions would be much appreciated. Thanks.

If you are scripting it anyway, I would form the tags into a system.opc.readValues call and then write the returned values to the database.
This way you are guaranteed fresh values no matter the scan class.

3 Likes

This is not true. When tags are subscribed to OPC items, the OPC server makes a best effort to deliver the data at the pace indicated in the scan class, but makes no guarantee. No guarantees for order of delivery, either. Tag change events can and do start executing right away, while other tags on the scan class are still updating, if updating at all at that time.

In your case, I would have a tag subscribed to the PLC trigger item as you describe, with tag change script, but I would use system.opc.read*() calls to retrieve the rest of the data. That’s the only way to be sure the rest of the data is post-trigger. This is precisely what “OPC Read” mode does in transaction groups, fwiw.

3 Likes

Thanks a lot! system.opc.readValues() is working great!