# system.tag.writeAsync

**URL:** <https://forum.inductiveautomation.com/t/system-tag-writeasync/42138>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 11, 2021, 11:39pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138 "2021-01-11T23:39:12Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![dd1](https://avatars.discourse-cdn.com/v4/letter/d/c0e974/32.png) [@dd1](https://forum.inductiveautomation.com/u/dd1)\
**Post date:** [January 11, 2021, 11:39pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/1 "2021-01-11T23:39:12Z")

</div>

Hello

I´m new to Ignition and this is my first post in this forum  
I`m from Denmark so I hope you understand my English  
Background, I have made Automation software for over 25 years, mostly Siemens PLC/HMI/SCADA, for scripting mainly VB/VBA/VBS and a very little C++

I really have problems setting a bit in the PLC with a Button  
I can find to types for this “Button” & “One shot Button”  
One shot Button is not the right one because of its feedback bit

In the Button I have made a event with call of a script  
The only instruction for setting a tag I can find is “system.tag.writeAsync”

I can write a value to a REAL tag

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/a/5ac49097c358fb9e44fe373fa4f057fd2cc70ff5.png)

I can NOT write to a BIT tag (part of a Array[32] tag

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/4/7463ce7512f1bc63d6a203ba26dc594d0fcf13ef.png)

In both cases, no error is reported, but should “Done” not be written in the right window ?  
I really don`t understand this “Callback” thing, can anyone explain to me what the idea is with this

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [January 12, 2021, 12:15am UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/2 "2021-01-12T00:15:30Z")

</div>

`writeAsync` sends off the write request and keeps going with the script. The callback function gives you an opportunity to analyze/log/respond to the write results when the write completes. What do you get if you change your call back function to something like this?

```auto
# Check write results and print failure quality codes.
def callback(writeResults):
	if not all(x.good for x in writeResults):
		print "Async write failed with quality code(s) " + str(writeResults) + "."
	else:
		print "Success!"

```

You can also use [system.tag.writeBlocking](https://docs.inductiveautomation.com/display/DOC81/system.tag.writeBlocking) if you don’t want your script to continue past the write until the write is complete.

---

<div class="post-metadata">

**Author:** ![dd1](https://avatars.discourse-cdn.com/v4/letter/d/c0e974/32.png) [@dd1](https://forum.inductiveautomation.com/u/dd1)\
**Post date:** [January 12, 2021, 11:09pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/3 "2021-01-12T23:09:10Z")

</div>

Thanks for your description of the writeAsync function, now I think I understand the function  
I have search for description/example of the callBack values, but can not find anything

Still the same, no print

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/6/26be478caa829feb72ee65bf7feb0a1e8e021e0e.png)

writeBlocking gives a failure whentrying to write a bit in a array, function is ok with REAL and INT values

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [January 12, 2021, 11:34pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/4 "2021-01-12T23:34:34Z")

</div>

I believe you’ll see the print in the output console (not script console output) with writeAsync:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/2/b27d1183d31d9f9df7caf5261afabc3a647085aa.png)  
The callback value is a list of [quality codes](https://docs.inductiveautomation.com/display/DOC81/Tag+Quality+and+Overlays) for the writes.

What error are you getting with writeBlocking? I expect writeAsync will have the same issue.

---

<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:** [January 13, 2021, 1:21pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/5 "2021-01-13T13:21:54Z")

</div>

> [@dd1](#):
>
> failure whentrying to write a bit in a array, function is ok with REAL and INT values

Not all processors can accept bit writes in a word. What type of processor is this?

---

<div class="post-metadata">

**Author:** ![dd1](https://avatars.discourse-cdn.com/v4/letter/d/c0e974/32.png) [@dd1](https://forum.inductiveautomation.com/u/dd1)\
**Post date:** [January 13, 2021, 10:09pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/6 "2021-01-13T22:09:57Z")

</div>

unfortunately nothing in Output console window  
Error when writing to a bit in a array

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/9/c93a997031fe3f12b6dd40239de759b530bc3eba.png)

---

<div class="post-metadata">

**Author:** ![dd1](https://avatars.discourse-cdn.com/v4/letter/d/c0e974/32.png) [@dd1](https://forum.inductiveautomation.com/u/dd1)\
**Post date:** [January 13, 2021, 10:19pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/7 "2021-01-13T22:19:54Z")

</div>

> [@pturmel](#):
>
> Not all processors can accept bit writes in a word. What type of processor is this?

PLC  
Siemens S7-1200 - CPU 1214C DC/DC/DC - 6ES7 214-1AG40-0XB0 - Firmware V04.04.01

PC  
Intel-NUC (old one)  
Intel(R) Core(TM) i3-5010U CPU @ 2.10GHz, 2100 Mhz, 2 Core(s), 4 Logical Processor(s)||OS Windows 10 Pro Version 10.0.18363 Build 18363

---

<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:** [January 13, 2021, 10:19pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/8 "2021-01-13T22:19:56Z")

</div>

What is the tag path of the array tag you’re trying to write to? To what element are you trying to write a bit to, and at what position?

---

<div class="post-metadata">

**Author:** ![dd1](https://avatars.discourse-cdn.com/v4/letter/d/c0e974/32.png) [@dd1](https://forum.inductiveautomation.com/u/dd1)\
**Post date:** [January 13, 2021, 10:23pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/9 "2021-01-13T22:23:46Z")

</div>

Tag path (dword / Array32)  
[edge]GaragePLC/Test/STSdw  
Bit path (this I am trying to write to)  
[edge]GaragePLC/Test/STSdw[5]

---

<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:** [January 13, 2021, 10:24pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/10 "2021-01-13T22:24:39Z")

</div>

Is the tag at `[edge]GaragePLC/Test/STSdw` just an Int4 as far as the Ignition tag datatype?

---

<div class="post-metadata">

**Author:** ![dd1](https://avatars.discourse-cdn.com/v4/letter/d/c0e974/32.png) [@dd1](https://forum.inductiveautomation.com/u/dd1)\
**Post date:** [January 13, 2021, 10:26pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/11 "2021-01-13T22:26:22Z")

</div>

No it is a array32 datatype

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/2/9221721c23eb5cd1e070065bc057ebabe09f2389.png)

---

<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:** [January 13, 2021, 10:29pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/12 "2021-01-13T22:29:12Z")

</div>

Yeah I see. I’m not sure those elements are individually writable. You may need to write the entire array. Array support in Ignition’s tag system is not very good.

Alternatively you can do this via system.opc.write, and in the OPC Item Path append “.0” or “.1” to the address of the DWord and it will target individual bits.

---

<div class="post-metadata">

**Author:** ![dd1](https://avatars.discourse-cdn.com/v4/letter/d/c0e974/32.png) [@dd1](https://forum.inductiveautomation.com/u/dd1)\
**Post date:** [January 13, 2021, 10:43pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/13 "2021-01-13T22:43:18Z")

</div>

[quote="Kevin.Herron, post:12, topic:42138"]  
eah I see. I’m not sure those elements are individually writable. You may need to write the entire array. Array support in Ignition’s tag system is not very good.[/quote]

This is also my experience so far, I think you are right, unfortunately...............

> [@Kevin.Herron](#):
>
> Alternatively you can do this via system.opc.write, and in the OPC Item Path append “.0” or “.1” to the address of the DWord and it will target individual bits.

This is want I have done to move on, write the bits with a number, 1-2-4-8-16 and so on, you can only push one button at time 😉

The History is that we have a big customer (10-30 systems pr. year) who want to move from Siemens HMI/SCADA to Ignition  
To not change everything; I wanted to keep the structure of PLC program in the first few ignition projects and make the Ignition HMI to fit the present PLC structure, maybe a wrong decision !!

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [January 13, 2021, 11:38pm UTC](https://forum.inductiveautomation.com/t/system-tag-writeasync/42138/14 "2021-01-13T23:38:33Z")

</div>

Try making an Ignition tag that references only one of the bool items (rather than the array). If you can write to that–I’m guessing so–you can make a UDT with the bool members needed (all 32, if that’s the case) as individual tags in the UDT. Then you can setup each UDT instance with a root address and it’ll be about as easy as using the array tags.
