Siemens Indirect Addressing Tag Reference

jagster21

Member
Join Date
Jun 2016
Location
Salmon Arm, BC
Posts
7
Hey all,

I am currently working on converting many of my company's standard Rockwell Code to Siemens S7, and have run into an issue with indirect addressing.

So currently, we have something along the lines of this


Valve.X
--| |---

In this example, the Tag 'Valve' is a Dint, and we are inquiring the Xth Bit of the valve Dint. Elsewhere in the code, the Tag 'X', which is also a Dint, is changed on a scan by scan basis.

From my understanding, if I were to continue to use ladder logic, I would code it in Siemens S7 like..
Valve.%X0 , however, that would forever be an inquiry on the 0 bit in that Dint, rather than referencing 'X'.

Does anyone have a way to use this method of indirect addressing in Siemens?

Thanks
 
Why do you want to peek a bit out of an integer?
Do the bits represent any function, then, why not use a struct/udt for this.
 
The actual code around this is much more complex; the process is random sequencing in respect to X, and the machine has upwards of 120 identical sections which we manipulate through one sample section of code, and depending on the Value of X, thats what section we determine operate on.

The preceeding Tag is infact a UDT array, and in some rungs I use compute instructions, which would be made much easier with this method of indirect addressing
 
Which S7 processor are you using? 1200/1500?

I'll 2nd what Thomas is asking. Is there a need for the bits to be part of a DINT? From what I understand about the Logix world, this is commonly done due to the memory structure reasons. In S7, this isn't necessary/typical.

Thomas suggested making a structure, but that still wouldn't give you indirect access. I'd suggest making an array of bools. It can be as large as you want (not limited to 32 like a DINT), and (if you are using one of the newer processors) then you'll be able to use indirect addressing (Array[index]) just like you'd expect.
 
An array [0..31] of bool instead of dint does not fit?

Nevertheless, in Step7 you can't do variable array indexing in ladder or even not in IL, like #myarray[#index]. This is only possible in SCL or with TIA portal and the new controllers.
Or you place the bit-accessing in a FC (two parameters, 1. dint variable, 2. bitindex, result is bool), you can call in ladder. FC code is written in IL.
 
I tried what you suggested with the Array of Bools as the reference tag for the single bit inquiry, and that seems to work, thanks!

I'm using the 1500 processor.

So in a situation as I've attached in the picture, we use "AD_SAIndex" as the pointer, which is a Dint. and "HMI_Bin[]" is an array of Dints. I wouldn't be able to do it in this method?

Capture.PNG
 
You could also look into the PEEK instruction in SCL. ( also easier to do for or while loops..)
 

Similar Topics

Hello guys, This works: L P#DBX 30.0 LAR2 But I need "DBX 30.0" to be input parameter to the function. I made pTag variable with data type...
Replies
19
Views
6,365
I have spent a couple of weeks now hunting around for information to step7 indirect addressing. There are many, many discussions relating to this...
Replies
5
Views
10,352
Yes, I did search for information first. Yes I looked through the limited help files that came with my Step 7. No I do not have any other books...
Replies
77
Views
20,981
I'm new to S7 programming and finding it a whole lot like running backwards through a corn field! I am helping my company develop our current...
Replies
44
Views
31,356
I have seen many posts relating to indirectly addressing arrays but none seem to fully explain how to do it simply. At the moment I have an...
Replies
5
Views
5,493
Back
Top Bottom