Step7 Indirect Addressing DBX

Peter Quiring

Member
Join Date
Sep 2016
Location
Detroit, MI
Posts
31
If I have a DB like this:
DB180:
field1 ARRAY[1..96] BYTE
field2 ARRAY[1..96] BOOL

How would I indirectly address a bit in field2?
Would this work in my function?

IN : #offset : DWORD = bit offset into field2

OPN DB180
L P#96.0
L #offset
+D
T #offset
A #some_condition
= DBX[#offset]

Would that work?
 
Last edited:
Yes, just be aware that as your arrays are not zero based, the offset will refer to array element offset+1

e.g.

popl.jpg
 
Using registry:
OFFSET : DWORD;
CONDITION: BOOL;
Code:
      LAR1  #OFFSET
      +AR1  P#96.0
      OPN   DB   180
      A     #CONDITION
      =     DBX [AR1,P#0.0]
 
You need to convert your DWORD offset into pointer format using SLD 3 instruction

The "L P#96.0" is already shifted 3 bits (the P indicates it's a pointer). So adding the #offset should give the correct "bit" offset.
field1 was BYTEs
field2 was BITs
 
Last edited:

Similar Topics

Hi all In a step7 SCL FB (NOT TIA portal) , I have declared many variables as IEC timers (SFB4). Now I need to iterate this variables (hundreds...
Replies
15
Views
7,866
Hi, I am trying to copy a set of strings from an array in to a different DB CALL "BLKMOV" SRCBLK :=SMP#DB50.DBX ["SMS_ALM_2_POINTER"] Byte160...
Replies
2
Views
3,800
Hello, Could you please write a simple example for indirect addressing with Simatic S7-300? Can you show it in ladder, because this is the...
Replies
5
Views
9,738
Hi everyone, I hope you can help me. Im working with get the production parts of all hours-day using STL. My idea is to use an array [0..23] of...
Replies
9
Views
3,817
This is the first time I am working with Simatic Manager Step7 as I started my siemens journey with TIA which is pretty easy and do a lot of stuff...
Replies
3
Views
110
Back
Top Bottom