S7 - Variable to access an array in STAT area

PeterW

Member
Join Date
Jun 2006
Location
Calgary, AB
Posts
2,531
Having issues finding how to have a variable tag as an array offset, when that array is part of the FB STAT area and the array is being passed into an FC.

Basically I have a master FB, from that FB I am calling the same FB twice unconditionally, ie I am sharing the masters DB. Each call is for one of two identical areas. I have a STAT INT tag, Track, which I write a 1 or 2 into before the UC call.

The STAT area has a two UDT tags, each an array[1..2], in these UDTs are all the data needed for the areas. One is called sCalcs, so I have sCalcs[1] and sCalcs[2].

Within the UDT I have a number of tags, including other UDT's. One of these UDT's is a 4 point UDT, ARRAY[1..4] or REAL, called inflight.

So I have sCalcs[1].Inflight[1] all the way up to sCalcs[2].Inflight[4]

Inside the second FB, I call an FC programmed in SCL and I pass a number of tags in and out, a few need offsetting to the correct array, the one I showed above is one.

the problem I get, is it allows me to directly program the offset #sCalcs[1].Inflight as a parameter into the FC, but won't allow #sCalcs[#Track].Inflight, it says syntax error.

I have tried creating a TEMP Int and passing the offset, Track, into that, then use the Temp. Same error.

I've tried different formats of pointer DINT, WORD, nothing works. I can only program the direct offset.

I'm beginning to think there is no way, hopefully someone can show me a solution and let me know why you cannot do this.

I'm trying not to use ANY pointers, I have made alternative logic this way, I'm trying to keep it simple for the others who will use this logic.
 
the problem I get, is it allows me to directly program the offset #sCalcs[1].Inflight as a parameter into the FC, but won't allow #sCalcs[#Track].Inflight, it says syntax error.


May I summerize the problem to the above which is basically indexing problem. Set your index #Teack data type to INT and see what happens.
A simple screenshot of the code and error would suffice.
 
Set your STAT tags to a multi dimensional array. I've use an array of REals but it's possible to make an array of your UDT

Then to index,

sCalcs[#index1,#index2]

Where #index1 and 2 are ints


Edit - Apologes, I had assumed with SCL you were using TIA portal, not S7 classic

image_2022-10-07_124529847.png
 
Last edited:
I've uploaded a cut down version.

FB153 is the master FB that calls FB154 twice.

Edit: I should add, the array IO at FC301 calls are OK because they are directly addressed. It won't let me index with a stat or temp Int.
 
Last edited:
Set your STAT tags to a multi dimensional array. I've use an array of REals but it's possible to make an array of your UDT

Then to index,

sCalcs[#index1,#index2]

Where #index1 and 2 are ints


Edit - Apologes, I had assumed with SCL you were using TIA portal, not S7 classic

Its a new install project, it uses TIA for the graphics but not the PLC's. I believe its because they are S7-400 redundant pairs, not sure if 1500 has redundancy yet, can't think any other reason to use 400's.
 
Thanks, I'll look at that solution.

I have quite a few calculation FC's I will need to create and call.

I can only assume the original programmer has little PLC experience as well as Siemens. programmed the entire program in ladder, including all the complex calculations, not a single UDT even though the program contains many identical components. He has two destinations and one big block with both mixed in the logic. Nightmare.

So looking for easy solutions to break it down a bit and make it readable.
 
Its a new install project, it uses TIA for the graphics but not the PLC's. I believe its because they are S7-400 redundant pairs, not sure if 1500 has redundancy yet, can't think any other reason to use 400's.


slightly off topic, but:

S7-1500 does have a redundant variant, but it's relatively new, only a couple versions of Portal old. It still has some gaps between it and the 400H system (Profibus is one of the big ones).
 
I have an STL solution that works with 2D arrays? If that would be any service.

Never did much with STL in S7, but this would be a lot simpler task in TIA.

As mentioned above, the s7-1500s don't yet have all of the capabilities of the S7-400 series regarding redundancy.

Although you mention the original programmer being inexperienced, 400H redundant systems aren't exactly bread and butter work.
 

Similar Topics

I am currently trying to integrate a Red Lion G3 display with a Wago 750-881 PLC. I have the bulk of the screens fleshed out, and I have most of...
Replies
0
Views
1,803
Hi All, It has been a long, long time. But in times of crisis this is somewhere I hold in the highest regard for accurate and swift responses...
Replies
3
Views
4,344
Has anyone using this drive been able to access variable by index variables? I can access V0 by its access number 100 using the @100. However, I...
Replies
0
Views
1,710
dear all.. i am designing the Sea Water Intake pump which the 4 pumps will be operated parallel, and 1 pump will be as stand by pump The pump data...
Replies
3
Views
127
I have a old lathe with a 120 VCA 9.5 AMP motor. Has white, black and red wires. I need to find a way to connect it to a variable speed controler...
Replies
0
Views
89
Back
Top Bottom