Indirect addressing of an array

lauwerstim

Member
Join Date
Apr 2006
Location
Kontich
Posts
93
I'm creating an FB with a variable input and I would like to copy all of the bits to an array (declared as temp)

I've declared the array in TEMP: Array_TEMP;Array [1..100] of bool
I've declared the input pointer: First_SI; pointer

I read in the pointer and can get its data, but copying to the array doesn't work. This is my code so far:

Code:
 L     P##First_SI
      LAR1  
      L     W [AR1,P#0.0]
      T     #iDB
      OPN   DB [#iDB]
      L     D [AR1,P#2.0]
      L     P#0.0
      +I    
      T     #TempPoint
      A     DBX [#TempPoint]
      =     #Array_TEMP[ [I][COLOR="Red"]what goes here?[/COLOR][/I]]

When I read the first BOOL (A DBX [#TempPoint]) the outcome is correct but I can't pass it on to the array in indirect fashion. (the goal is to create a loop to copy all 100tags)
 
You cannot specify a variable array index in s7-300, you must use another pointer and indirectly address the array elements that way.
 
Another question then:

I have an FB that needs a STRUCT as IN/OUT, how can "indirectly" adress this IN/OUT.

The FB needs to be called 20 times and it would be handy to have this STRUCT as a variable.
 
Why do you want to access the struct indirectly - one of the benifits of a struct is the ability to access the elements by name?
 
I'll explain in short.

I have 24 elements (automated circuit breakers), each element has 64 single informations (every information needs to be attached to a FB so timestamp and quality can be added and sent to a dispatching), it has 32 double informations (attached to a different type of FB), 3 commands (different FB) and 2 measurements (yet another FB)

So now I'm trying to make 1 multi-instance FB per element so that the program would be easily scaleble (next project will have 48 elements)
 
why not make a udt of type element? ID as INT, PassFail as BOOL, TIMESTAMP AS DATE_TIME

and then access the udt inside your FB

Either that or have a global DB of elements so you can easily add more if required
 
I'm creating an FB with a variable input and I would like to copy all of the bits to an array (declared as temp)

Here's an example implementation. I've used SFC20 to perform the copying of the data from the input to the arrray in the temp area.

I've added some test code that copies the temp array to a db as it is not easy to monitor data in the temp area for testing.
 
The attached file doesn't seem to be complete, I can't open it in Step7 v5.5

edit: Sorry, my bad. Opens perfectly.

Will try it, looks promising. Thanks.
 
Last edited:

Similar Topics

Hi Guys, I have an int array of 500 elements and would like to display them on a panel view plus 6. Now I can't make 500 numerical displays, so I...
Replies
2
Views
2,809
I've got a rung that uses the first pass bit to initiate a For argument. In the Routine named 'Alarm' I have something like this...
Replies
15
Views
9,986
Hi guys, Is it possible to decalre a variable then use it on Arry such as: In DB100, I decalred an array as Array1 is Array[1..100] of UDT1...
Replies
3
Views
6,760
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
621
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
668
Back
Top Bottom