system.tag.writeAsync

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

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

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

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?

# 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 if you don’t want your script to continue past the write until the write is complete.

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

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

I believe you’ll see the print in the output console (not script console output) with writeAsync:
image
The callback value is a list of quality codes for the writes.

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

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

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

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

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

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?

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

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

No it is a array32 datatype

image

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.

[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…

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 :wink:

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 !!

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.

1 Like