So, like the title says is there any type of work around for PLC tags whose data types are multi-dimensional arrays?
I'm working with a Control Logix L33ER PLC. I have a tag named "LS" with its Datatype as an INT[40,100].
My goal is to be able to write to this tag's specific bits within this array of the LS for example: LS_0_3[0] or LS_0_3[15] and so on. When I bring the tag over into ignition, I can see the first dimension of the tags "LS"
I can place a value into these arrays, but I cannot specifically address to the individual bits. Is there any possible way see these bits? I've tried changing the data type to string array, and every other data type but that still doesn't work.
The use of these arrays is that they are acting as pushbuttons for the clients HMI screen to enable / disable something. My idea of a work around was trying to create set of 16 pushbuttons to act as an encoder. With each of the button's values corresponding with their position in the word. For example,
I am able to create the pushbuttons and send their value to a newly created expression tag which holds the total value, but for some reason If I try to read/write the data from this newly created tag to LS array it will not work. I've been using write.Blocking and write.Asynchonous. Any tips or help is much appreciated. Thank you.
Just want to say that 60,000 is a lot of push buttons if that is all this array will be doing. I have trouble imagining any application that needs that many push buttons.
If you are intending to write to a specific bit these functions do not have really anything to do with it, unless the OPC path in the tag is set up correctly. Adding the tags as you have, it would appear that the LS folder has 4000 tags, each of which will be addressed to an Integer value, not a bit. If you want them to be addressed to a bit, then you have to manually edit the OPC path.
I would highly recommend developing a UDT structure that you can use for this purpose so that you can build the OPC Item paths with UDT Parameters, rather than using single OPC tags as you have.
You can write to an a specific bit, by writing an expression which will mask out all of the bits that you do not want to write to.
For instance, if I want to toggle the 5th bit in an integer that could be accomplished like this:
{PropertyBoundToLS_0_0_} xor 16
In script that would look like this:
value = system.tag.readBlocking(['[default]_Compact Logix_/Controller:Global/LS/LS_0_0_'])[0].value
system.tag.writeBlocking(['[default]_Compact Logix_/Controller:Global/LS/LS_0_0_'],[value ^ 16])
Though I would recommend using an expression if you can.
Also, it looks as though you may have drug the entire device tag structure into Ignition from the OPC Browser. If that is the case, you're probably doing yourself more harm than good. If not then disregard this.
Thank you for the help! Ill give that a try right now.
Also, yes, it's a lot of tag total, but there's only around 20 pushbuttons that this whole array is using which I want to address too. I don't know why the client has such a massive array in the program, but I'm trying a few work arounds on the SCADA side before I try to make any type of code changes.
You should make just those twenty bits as tags in Ignition. You should not have tags in Ignition pointing at stuff in the PLC that you aren't using in Ignition.
Putting aside the PLC program, which absolutely should be addressed due to memory concerns, if this is all the buttons you have, you may be better off, just addressing the specific bits.
For instance, the OPC Item path that you currently have would look something like this:
ns=1;s=[DeviceName]LS[0,0]
You can set the tag to read at the bit level by changing it to something like this:
ns=1;s=[DeviceName]LS[0,0].PushButtonBitNumber
So for instance, if you wanted the 0th bit, then you would write LS[0,0].0
Yea currently the arrays LS[0,2], and LS[0,3] are having their bits used for Pushbutton controls. The rest of the arrays are being used for a variety of other controls such as message handlers for reading and writing. It seems to me whoever wrote the original code wanted to try to use a single massive array for everything in the program.
Also, that would be the personal preference is to change the tag to read at the bit level. But when I try to do so I and write a value of 1 to a specific bit I get an error message:
Sorry about the delay in response, got called out into the field last week. The UDT method worked like charm, and I am able to address to the individual bits easily. Thank you for the help and the quick responses, it's very much appreciated.