Rockwell Logix5000 Booleans Reading as Array

I am interfacing with existing Logix5000 programs and am trying to toggle a Boolean value with a button in perspective. The tag is built into the script, as it will differ depending on other factors, but that is working. I read in the tag and, at first, did a “not”, which did not work. I then did an if for 0 and 1, but that did not work. For testing, I displayed the value in a label, which turns the text property from a value to an array.

Boolean arrays are represented internally in the controller as DINT (DWORD?) arrays, 32 booleans per element, and unfortunately this is how the driver represents them as well.

There isn't actually any metadata available that tells us whether it's supposed to be a DINT array or a bool array, and for whatever historical reason we ended up just passing it on as DINT array and now we're a little stuck with it.

1 Like

How do I handle this? Also, it isn’t a Boolean array, just a Boolean tag.

oh I totally misread this.

You're just not handling the fact that system.tag.readBlocking accepts and returns an array of values; you need to dereference the element you want, e.g.

tagState = system.tag.readBlocking(tagToChange)[0]

though you may actually want

tagState = system.tag.readBlocking(tagToChange)[0].value

because the readBlocking gives you QualifiedValue objects.

1 Like

All of the non-deprecated tag read/write system calls expect arrays of tag paths, arrays of values (for writes) and deliver arrays of results (QVs for reads, quality codes for writes).

Some functions will accept non-arrays arguments for ease of conversions. (But are not documented to do so, and you should follow the docs as much as practical.)

That worked! Thank you