RSLogix Array Pains

BillRobinson

Member
Join Date
Oct 2006
Location
Sydney, Nova Scotia
Posts
185
My root problem is accessing data from a 3 dimensional array...lets call it MY_ARRAY[24,12,100]. Now I want to access the data in the array based upon three parameters... say x,y and z; In this example I'll only want one parameter, so I want the value of MY_ARRAY[24,12,z] where z is any integer between 0 and 99.

Now I can do this from a RSLogix5000 ladder program, but I can't do this from a function block program. I get an error:

Language element can not refer to a variable array index.

So my next venture is to create an structured text Add-On instruction, which I get to work, only problem is that I can't do this for every possible array. That is, the dimensions of array used to write the add-on must match the one used in the add-on code. So let say in my add-on code I use an array that is [10,10,10]; if I want to use the same code on a [20,20,20] array I can't.

So two questions:

1) Is there a better way to access array elements in a FB program?

2) Is there a way to write an Add-ON instruction that will handle any n-sized Array?
 
Are you saying that FB programming cannot index into arrays??

I don't have the other languages except ladder, so can't test this out, but i'd be surprised if you can't.

Why not create your add-on in ladder, and source-protect it so it can't be seen?
 
It will be helpful if you will either post a screen shot of what you are trying to do or zip your project ACD file and attach it to a post.
 
There is a "Size" (the mnemonic is SIZE, for ladder) instruction that will allow you to get the size of one of the array dimensions. So you would need an instruction for each dimension you need to know and store in a separate tag.

See these two manuals:

Logix5000 Controllers General Instructions
http://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1756-rm003_-en-p.pdf

Logix5000 Controllers Structured Text
http://literature.rockwellautomation.com/idc/groups/literature/documents/pm/1756-pm007_-en-p.pdf

I would think you may want to use structured text to write an Add-In for this.

Darren
 
Add on instructions accept n size array but only in ONE dimension
Dont forget to use the SIZE command in the AOI and limit the index to be range from 0 to LES than SIZE.

If you still want to use Function blocks then you may have to use a UDT with one large single dimensions array [Size = Dim1*dim2*dim3] and have extra Dints in the UDT for the array dimensions.
eg UDT.array[10000]
UDT.Dim1 = size of dimension 1 set in first scan
UDT.Dim2 = size of dimension 2 set in first scan
UDT.Dim3 = size of dimension 3 set in first scan

In the AOI use some maths to determine the single dimension array index
eg index = Index1 * dim2 * dim3 + Index2 * dim3 + Index3
to return the result


This method can also be extended used to have 4 or more dimension arrays
 

Similar Topics

Hi. Not the fist time I'm saying this but just to give a background. 95% of my PLC programming has used Schneider over the last 10 years on...
Replies
66
Views
4,862
Hey all, I am trying to figure out how to import some alarm messages without having to type them all in by hand. They are in the format of an...
Replies
4
Views
1,121
Hello i have been trying to figure out a good way to take hex and convert it to an array of SINT[]. Here is what my failed attempt looks like.
Replies
5
Views
1,259
I have a subroutine that gets called to copy a UDT In an array to a tag. This subroutine will be called around once per minute and has been...
Replies
4
Views
2,114
Hello! I have an application where I can only have 3 pumps running out of 6. I load the pumpRunning bits into an array. What I need to do is...
Replies
6
Views
3,121
Back
Top Bottom