Indirect addressing in TIA Portal (1500)

DairyBoy

Member
Join Date
Jun 2007
Location
UK
Posts
393
Well I've looked at the faqs and searched the forum for examples or pointers (no pun) but can't find a "simple" way (is there one) in siemens to match the RSLogix way of doing it. Looks like square brackets are out and not even sure if ladder can do it. I need to create an array (where?) of integers and pick them out one by one for use as, say, a timer preset. Having given up on indirect add, I looked at the MUX instruction but as there's 30 ints to pick, the rung is getting huge. Any help would be much appreciated. Thanks.
 
You can use indirect array addressing.

Create an array [1..10] of INT in a DB, or in your block interface. In this example, I'll call the tag data_array, and assume it is a local tag in the block interface. We also need to create an index tag; I'll very imaginatively call it "index".

in the code you can reference #data_array[7] to access a specific element of the array, or #data_array[#index] for indirect access.

Note that the auto tag selection pop-up assumes you want a specific element of the array, and it isn't much help in selecting the index tag. You have to type it in directly, with no errors.
 
Thanks mk42. That looks promising. I've created a DB of 32 entries called Ch1_Paras and an integer called index. I tried it with a move instruction with the input as: "#Ch1_Paras"[#index] but it gave the error "#Ch1_Paras"[#index] not defined. Same result without the " ". Must be missing the obvious but can't see it!

Edit: The absolute addressing works: "Ch1_Paras".THIS[7] is not rejected.
 
Last edited:
Edit: The absolute addressing works: "Ch1_Paras".THIS[7] is not rejected.

How about "Ch1_Paras".THIS[#index]or "Ch1_Paras".THIS["Ch1_Paras".index]? Use the first if the index tag is local, use the 2nd if the index tag is in the DB.
 
Thanks mk42. :geek: This doesn't get thrown out: "Ch1_Paras".THIS["index"]

BTW, the tag index is in one of a few tag tables that I've added under PLC tags.

Next stop: Two-dimensional arrays :eek: If it was AB I'd go with 3 (channel/route/parameter) but I think under the circumstances I'll lop off one layer of complexity.
 
That's interesting; mine won't pass with the # used. Is that to do with the location (tag table) of the tag index? When I use # the quotes are removed automatically.
 
That's interesting; mine won't pass with the # used. Is that to do with the location (tag table) of the tag index? When I use # the quotes are removed automatically.

It's the difference between a local tag and a global tag. This is sort of like the difference between a program tag and a controller tag in Logix, but scope works a bit differently in a Siemens PLC.

If you declare the index tag like LD did, in the interface of the block, then it is a local tag. You use # to indicate that a tag is local. The advantage to index tags is that you can then call your FB/FC multiple times, and all the tags are automatically duplicated, but still independent of the others.

If you declare the index tag in a tag table, like you did, then it is a global tag. You can use the the same name for both a global and local tag (and with local tags, you can use it once in each block), and the system keeps them separate because of the #.
 

Similar Topics

Hi All Working with Tia v16 on a PLC 1515F I am getting older by the minute, beating on indirect addressing for a DB I have a DB with 65 row of...
Replies
7
Views
3,746
Hi all, I have been asked to implement a simple recipe function on a system running an S7-1200 on TIA Portal. In Allen-Bradley land, my method...
Replies
19
Views
35,558
Hi guys. Looking for some advice. I have a device in profinet that will be giving me 124bytes of information (I believe they will be chars). I...
Replies
0
Views
4,269
Howdy folks, I am an Allen Bradley guy currently living in an Emerson world. Working with Rx3i on PacSystems Machine Edition v. 9.6? i think...
Replies
3
Views
578
Hello, I'm very new to programming with absolutely zero schooling in this field and pretty hands off training in my new role, it's been fun...
Replies
4
Views
649
Back
Top Bottom