DigitalFarmBoy

AT Specification for Arrays

4 posts in this topic

I'm having trouble specifying a memory location using the AT specification for an array in the Global Variable tab. I've tried a number of different ways to do so, and searched around online but haven't been able to find anything about how to do this. All I have to go from is the rather cryptic "AT specifications are specified separately for each variable. Set them for all elements and members
of array, structure, and union variables.
" from page 6-62 of the Software User's Manual (W501).

That seems to imply that it can be done somehow, but I am not sure how. Right now I have created array elements as independent variables, and then use a FOR loop with a CASE statement to put the proper variable into the array for use later in the program. This doesn't seem particularly efficient, and I have to imagine there is a better way.

Any advice on this is greatly appreciated. Thanks!

Share this post


Link to post
Share on other sites

5e1c8ea40a97e_ArrayAT.jpg.ae73e768cb9d38

You just need to put a % sign in front of the address.  Why do you need to assign an address to the variable?  This is only necessary if you have a very specific need to do so.  

Share this post


Link to post
Share on other sites

I am aware of using the % symbol for addressing with a single variable, but wasn't sure how the program handled that when used for an array. In the example above, I am assuming that the PLC will assign testArray[0] to location %W0, testArray[1] to %W1 and so on, is that correct? This was my initial assumption but...

I built a quick sample program where I created a single UINT and an array of UINTs and mapped them both to fixed memory:

5e1ca44590961_Annotation2020-01-13110231

When I run the simple program (sets Test := i in a FOR loop through 16 and sets ROS_OP_MODE to 1), I looked at the variable watch, and while it shows my AT specification for the single UINT (%E0_0), it doesn't show any AT specification for the elements of the array. This is why I wasn't sure if I was defining the array AT specification correctly.

5e1ca4463f7f9_Annotation2020-01-13110323

I don't have hardware on hand currently, so I can't verify if the simulator is not showing this correctly or if the array isn't actually mapped to the memory as expected. Either way, I would like to be sure before I spend a bunch of time programming and then find out that it does or doesn't work.

1 hour ago, Michael Walsh said:

Why do you need to assign an address to the variable?  This is only necessary if you have a very specific need to do so.  

I'm working with a couple HMIs that talk to the PLC using the FINS Ethernet protocol, so I need to map variables used by the HMI to specific memory locations in order to access them remotely.

Edited by DigitalFarmBoy
Fixed accidental Italics

Share this post


Link to post
Share on other sites

Aha.  yes, using HMIs that use FINS will indeed require using the AT assignment.  Your other assumptions are true in your case.  The memory areas are all 16 bit addresses, so for each  UINT, it uses one of the addresses in the E0 Memory bank.  If you had an array of UDINTs or REAL numbers, each index would use two addresses consecutively. So, Array[0] would be E0_0 and E0_1 and Array[1] would be E0_2 and E0_3.  You are doing things correctly. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now