Aliasing Array Elements

OOPer

Member
Join Date
Jun 2011
Location
CA
Posts
35
RSLogix 5000

How do I alias an array?

Here is an Example:
Controller Tag:
CTag DINT[6]

Routine Tag:
_cTag Alias for CTag (<-- this doesn't work)

or alteast

_cTag[0] Alias for CTag[0] (<-- This doesn't work either)


So, in essence if you create arrays for efficient/tidy programming, you are hosed because you have to flatten them out at Program level if you need to alias them. Is there a solution to this? :confused:

Thanks!
 
_cTag0 works as an alias for CTag[0] - however it aliases only element 0 in the array.

Except for data that you want to move/process together arrays don't necessarily make for tidy programming. If you have a group of DINTS and you want them to have meaningful names and be grouped together then define a UDT instead of an array.
 
I don't quite understand what your thought process was behind attempting the alias:

_cTag Alias for CTag

It really wouldn't do anything for you, you are better off just doing a COP statement in that instance.

Here is an example of an alias I might use.

Base Array: Analog_Outputs[10] as REAL

Then I will create alias tags which are aliased to an element within that base array.

Alias: AnalogOutput0 Base: Analog_Output[0]
Alias: AnalogOutput1 Base: Analog_Output[1]
Alias: AnalogOutput2 Base: Analog_Output[2]
.
.
.

As Alaric mentioned, this doesn't mean "tidy" code, BUT, it does mean efficient code. Especially if these arrays need to communicate with an HMI as arrays are compacted data, so as packets are transmitted to and from the HMI, the data in each packet is full of useful information. RSLinx has a good guide on explaining how data is transmitted.

Also, as Alaric mentioned, UDTs can be a better option than arrays, I say "can" as in my example if I created a UDT which only contained a single data array (Analog_Output[10]), the UDT really doesn't give you anything.
 
OK. I will re-phrase.

I need arrays for iteration.

I have an array of UDT_xyz_interface[] as my interface tags.

I want my EM_xyz to iterate through each of these tags.

These tags are defined at the Controller level so my EPs can access them.

I want to alias them at EM_xyz level, but I can't alias an array.

How do PLC coders do iterations with out copy and paste? :unsure:

Relatively new to PLC coding, so please bare with me.
 
I am missing something here in the acronym soup.

Forgive me for asking, what is an EP?

Are you saying you have created a UDT and defined a three dimensional array tag (dim0, dim1 and dim2) with the UDT? Is so, then yes, you are correct, you can not create an alias to a specific array element (probably not right terminology, hopefully you'll get what I am trying to say) in that array, BUT you can use indirect addressing (along with a copy) to get the data in and out of the array. It will be one dimension of the array, for how ever many elements you are looking for a specific dim0, dim1 and an array of dim2.

Are you using this as recipe storage or data collection? If so this is fairly common and someone may be able to suggest something more typically used in a PLC to get what you are after.

Darren
 
Last edited:
I reread your original post and I am more confused. You should be able to alias from a program scoped tag to a controller scope tag. I have done something similar for a tank management system. Each program was the same, it only changed in what element of the tanks array it operated on.

So you might have TankProg1 and inside there it has a local scoped TankTag that is an alias of a controller scoped tag that is Tank[1].

Then for TankProg2 there would be the same logic an local scoped tags, but the alias TankTag would now point to Tank[2].

Rockwell has quite a few examples of this style of program. Not a big fan, but it can have it's uses. We can now commission a new processing tank in a day, where it used to take almost a week of reviewing the program to make sure all the changes were picked up to add a new processing unit.

Since I did that though there are now add on instructions. I would have to go back and look to see if there isn't a better way to do that application now.
 
EP - Equipment Phase
EM - Equipment Module

^ has nothing do with my question though.


I will lay out more explicitly, see if this makes sense:

Controller Tags:
Name Type
+test UDT_XYZ[6]

So from the above thing we have an array of 6 UDT_XYZ types

Now, alias those in my program tag
Program Tags:
Name Alias For Type
+pgmtest test UDT_XYZ[6]

^ This above part is not possible

I basically want to alias one to one pgmtest[0] = test[0]

am I making sense now?
 
You are right. As I stated above, you have to go in the reverse. In the program scope create an alias to the controller scope tag, that way your program and equipment modules can swap data, but keep same program with local scope tags.
 
An alias must point to a single item, either an atomic type (BOOL, SINT, DINT etc), a complex pre-defined type or a UDT. It can't alias to a whole array ... unless ... that whole array is itself a type.

You have the UDT_XYZ type defined.

Now define ARR_UDT_XYZ as containing one element which is an array of type UDT_XYZ with a length of 6.

Create a variable of type ARR_UDT_XYZ with controller scope

NOW you can have a program scoped alias point to that tag.
 
Last edited:
An alias must point to a single item, either an atomic type (BOOL, SINT, DINT etc), a complex pre-defined type or a UDT. It can't alias to a whole array ... unless ... that whole array is itself a type.

You have the UDT_XYZ type defined.

Now define ARR_UDT_XYZ as containing one element which is an array of type UDT_XYZ with a length of 6.

Create a variable of type ARR_UDT_XYZ with controller scope

NOW you can have a program scoped alias point to that tag.

Thank you. That's what I was looking for. (y) Kinda awkward, but much better than flattening out the array.

I wonder why A-B restricted aliasing arrays, but that's for a different discussion.
 
Hey fellas,

Sorry for blowing the dust off an old thread but I have a similar question. Unfortunately I'm having a hard time following the existing Q & A, so if I may, do ya mind if I dumb it down a little so I can follow?

Lets say I create a UDT called MyUDT that contains:
StartTag BOOL input
StopTag BOOL input
RunTag BOOL output
SpeedTag REAL input

I then create a tag array called MOTOR which I assign the type MyUDT.

Normally I would create these as individual tags ["flattened out" as OOPer puts it] making them aliases for hardware input/output tags created by RSL5000 when I did my IO config. However, once I gather them together in a UDT, I can no longer make them aliases. I think that's what the OOPer meant, right?

That's where I get stuck and, as mentioned, don't quite follow the previous explanations. Could someone please rephrase their reply so a mortal like me can understand? How do you connect elements within a Tag array that uses a UDT type to the real world?
 
... How do you connect elements within a Tag array that uses a UDT type to the real world?

You can't alias an array or individual items of an array or a UDT type.

You can't alias Real world I/O points to UDT elements. You will have to write your logic for that (which is actually a nicer way of doing it with the IO anyway)
 
You will have to write your logic for that (which is actually a nicer way of doing it with the IO anyway)
I'm sorry but I must be missing something here. What do you mean by that? Use IO points directly in the logic?

I ask because in some previous threads of mine in which I've asked for peoples advice on how to best write "cookie cutter" type logic for a current project of mine, many have come back suggesting using UDTs. If the elements within a UDT can't reference real world IO, then what's the point?
 

Similar Topics

Is there a way to make 1 bit in a BOOL array an alias? I have not had any luck doing this yet. I have several UDT that I would like to be able to...
Replies
11
Views
5,299
Hi all, I currently have a rejection conveyor belt with 4 lanes and with 1 paddle per lane to sort the quality of a particular agricultural...
Replies
7
Views
1,653
Hello Every one, This question came around in my place of work (MOAWP). It appears very simple on the surface, but I could not get right when I...
Replies
1
Views
1,900
Hello Every one, This question came around in my place of work (MOAWP). It appears very simple on the surface, but I could not get right when I...
Replies
12
Views
3,507
I'm a big fan of aliasing I/O channels to P&ID device names, but with all the new built-in I/O features, how are the cool kids aliasing? The...
Replies
8
Views
3,620
Back
Top Bottom