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!

HI Aaron,

I am having the same issue in ignition database, complete data is not updating in the data base as the boolean bit in plc trigered and many times i have just the duplicate data in the database. can you please help me if you have made any change in plc program also for the post trigger?

Thanks a lot

Hi Sophie,

So I ended up using the system.opc.readValues() function in my gateway scripts to read my OPC values then writing them into the database. But also just to make sure I don't get any duplicate data due to the OPC tags not updating fast enough, I also have a 200ms delay in my PLC code between unloading each set of data to Ignition. 200ms is the scan time I've set on the tag I use to trigger my gateway script.

This might not be the most efficient way of doing it, but it's been running reliably for the past 4 years...

Hope this helps.

2 Likes