
g.mccormick (Customer) asked a question.
Productivity. Anyway to indirectly address bits of word?
Is there not a way to indirectly address the bit of a word other?
I can indirectly address array elements, but I'd really like to indirectly address the bits.
Example an array of 32bit ints. I'd like to set the bits of words true/false based on incomig logic. The array element and bit of word is being changed in a for loop.
In AB world
MyArray[ ArrayIndex ].[bitIndex]
Can I not do this in productivity???????
Its the same in Productivity as your example in AB, but slightly different syntax. In Productivity "." is used for structures, "(#)" is used for arrays, and ":" is used for bits.
If you have a tag that is an array, say "DoubleWord" (a 32 bit int array) with some number of columns columns, then each Int32 tag within the array is DoubleWord(1), DoubleWord(2), etc.. Then within that if you want to address each bit you can do so with DoubleWord(1):1, DoubleWord(1):2, DoubleWord(1):3, etc.. You can expand all this in Tag Database and write comments down for each bit as to what it is, then display comments in ladder view to see what everything is there.
I think that what @g.mccormick (Customer) is asking for is 'how to make the bit be taggable/indirect.' As it is now, the bit member of the bit of word must be explicit.
Thus:
Word:5 is valid (where the bit reference is hard-coded to the number 5)
Word:Bit is not valid (where 'Bit' is a tag)
Correct. I know how to (and use it) use pointer addressing in array indexing, I want to do the same with bit of word addressing.
I did a test to try different ways to indirectly SET a bit of a DINT, and it's a no go. You can SET a Boolean array element with an indirect bit reference.
Yep that's same conclusion. Automation direct can you make this improvement?
Try this bulky workaround.
That is something that I did not think of. I could have used an intermediate array of bools. As it is, I just long-way through using pack bits.
Thanks for the idea.
For anyone reading to here the answer is NO you cannot indirectly address the bit of an int/sint/dint.
Automation Direct can you look into this? While this is being added, how about:
MyArray( Index ) = xxxx
MyArray( Index + 1 ) = yyyyy
MyArray( Index + 2 ) = zzzzz
This is doable in AB and is quite handy. Added to the ability to indirectly address bits it is useful like this:
//Analog Active
Aa_Act_Alarms[Aa_index].[bit] := Sys.Aa.Alarms[idx].HH.Act;
Aa_Act_Alarms[Aa_index].[bit + 1] := Sys.Aa.Alarms[idx].H.Act;
Aa_Act_Alarms[Aa_index].[bit + 2] := Sys.Aa.Alarms[idx].L.Act;
Aa_Act_Alarms[Aa_index].[bit + 3] := Sys.Aa.Alarms[idx].LL.Act;
It also seems that the the index into an array cannot itself be an array.
For example say I have an array called indexArray in in the first element I have a value of 33. I cannot seemingly use that to access the 33rd element in MyArray.
indexArray(1) = 33
MyArray( IndexArray(1) ) = 5 this does not seem to work and confuses the editor.
This is what I typed in DigAlarms.Alarms( Da_Strt_Index(1) ).Act