[SOLVED] Minimum time to wait between writing 2 values over OPC that are dependent on each other?

Is there a minimum time to wait between 2 consecutive PLC writes that are depending on each other?

I want to write a value to a PLC counter and then to a "take action" bit in the PLC.

  1. Does the following code guarantee order of operations?
  2. Is a time delay needed between the first OPC write to the second?
opcServer = "Ignition OPC UA Server"

#write to PLC counter
itemPaths = ["path to counter"]
values = [5000]
system.opc.writeValues(opcServer, itemPaths, values)

#write to "take action" bit
itemPaths = ["path to bit"]
values = [1]
system.opc.writeValues(opcServer, itemPaths, values)

Or is it necessary to have the PLC write back a value to me before performing the "action bit"?

@pturmel I think you are the unoffical expert on this; thoughts?

Use
https://docs.inductiveautomation.com/display/DOC80/system.tag.writeBlocking

Writes values to Tags at the given paths. This function will "block" until the write operation is complete or times out. Meaning, execution of the calling script will pause until this function finishes. This useful in cases where the tag write must complete before further lines in the same script should execute.

You might want to read it back to check in case of timeout. Use
https://docs.inductiveautomation.com/display/DOC80/system.tag.readBlocking

Running a sequence is always1 better than using timers.

1 Well most of the time, anyway.

I am aware of these functions... is it a given that I have to create Ignition tags to follow this route?

What does system.tag.writeBlocking return if a timeout occurs?

The script in your first post is fine, no need to wait. You could maybe check the result of the first call is good before doing the second, if that matters.

1 Like

Returns:
List - A List of QualityCode objects, one for each Tag path. Each quality code holds the result of the write operation for that Tag.

Quality codes are listed here:
https://docs.inductiveautomation.com/display/DOC81/Quality+Codes+and+Overlays#QualityCodesandOverlays-QualityCodeReferenceTable

1 Like

This. Check return values from the OPC write operations. (In case it isn't obvious all over the place, I hate using time in a sequence if I don't have to.)

1 Like