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

**URL:** <https://forum.inductiveautomation.com/t/solved-minimum-time-to-wait-between-writing-2-values-over-opc-that-are-dependent-on-each-other/65289>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [October 17, 2022, 4:10pm UTC](https://forum.inductiveautomation.com/t/solved-minimum-time-to-wait-between-writing-2-values-over-opc-that-are-dependent-on-each-other/65289 "2022-10-17T16:10:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [October 17, 2022, 4:10pm UTC](https://forum.inductiveautomation.com/t/solved-minimum-time-to-wait-between-writing-2-values-over-opc-that-are-dependent-on-each-other/65289/1 "2022-10-17T16:10:47Z")

</div>

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?

```auto
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?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 17, 2022, 4:14pm UTC](https://forum.inductiveautomation.com/t/solved-minimum-time-to-wait-between-writing-2-values-over-opc-that-are-dependent-on-each-other/65289/2 "2022-10-17T16:14:34Z")

</div>

Use  
[https://docs.inductiveautomation.com/display/DOC80/system.tag.writeBlocking](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](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.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [October 17, 2022, 4:19pm UTC](https://forum.inductiveautomation.com/t/solved-minimum-time-to-wait-between-writing-2-values-over-opc-that-are-dependent-on-each-other/65289/3 "2022-10-17T16:19:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [October 17, 2022, 4:22pm UTC](https://forum.inductiveautomation.com/t/solved-minimum-time-to-wait-between-writing-2-values-over-opc-that-are-dependent-on-each-other/65289/4 "2022-10-17T16:22:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 17, 2022, 4:44pm UTC](https://forum.inductiveautomation.com/t/solved-minimum-time-to-wait-between-writing-2-values-over-opc-that-are-dependent-on-each-other/65289/5 "2022-10-17T16:44:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 17, 2022, 4:50pm UTC](https://forum.inductiveautomation.com/t/solved-minimum-time-to-wait-between-writing-2-values-over-opc-that-are-dependent-on-each-other/65289/6 "2022-10-17T16:50:51Z")

</div>

> [@bmeyers](#):
>
> What does system.tag.writeBlocking return if a timeout occurs?

> Returns:  
> List - A List of [QualityCode](http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.12/com/inductiveautomation/ignition/common/model/values/QualityCode.html) 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](https://docs.inductiveautomation.com/display/DOC81/Quality+Codes+and+Overlays#QualityCodesandOverlays-QualityCodeReferenceTable)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 17, 2022, 5:19pm UTC](https://forum.inductiveautomation.com/t/solved-minimum-time-to-wait-between-writing-2-values-over-opc-that-are-dependent-on-each-other/65289/7 "2022-10-17T17:19:54Z")

</div>

> [@Kevin.Herron](#):
>
> You could maybe check the result of the first call is good before doing the second, if that matters.

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.)
