Indirect Pointer of another Pointer in S7

Apel

Member
Join Date
Aug 2007
Location
Singapore
Posts
98
Hi, Here I am in trouble I think, I have many Standard Blocks written in combination of STL and LAD, like following:

FB130:Valve(open/close)---100 numbers in total
FB230:Motor/Agitator------10 numbers
FB340:WeightScale---------10 numbers

Then I have called all this similar standard block in another FB to cleate a common Instance DB.

1.In FB100(,Instance DB 100) I have called all the valves with multiple instances.
2.In FB200(,Instance DB 200) I have called all the MOTOR/AGITATOR with multiple instances.
3.In FB300(,Instance DB 300) I have called all the WeightScale with multiple instances.

UPTO THIS I DIDN'T HAVE ANY PROBLEM.But now I need a procedural Standard Function Block FB100,(CLEAN).This FB will be standard & will be called 7 times.Just imagine Clean operation to be perfomed in 7 different Vessels with same logic but different Valve/Motor/Pump..etc.

4. In FB50( instance DB50), this FB 100 will be called multiple times(Instance-1 for Vessel-1, instance-2 for Vessel-2...& so on), then some parameters of different valve/motors need to be compared/checked or commanded to open/close/start/stop inside the FB100.I can do that if I use INPUT, OUTPUT, IN_OUT variable inside FB100 and then assign the corresponding parameters.But according to software specification we have more than 100s of things need to be passed into FB100 and dont want to many In/Out parameters to be seen when call them.So we have created a list of variable as STAT. So here I am in trouble. How I can send different parameters to FB100 in each call of FB100?

First I am thinking to use some indirect addressning like this:
When I will call this FB100(Vessel-1 as first instance) those STAT variales inside FB100 will indirectly read/write into/from destination defined in another DB(shared Db, DB10, 1st pointer Index table),When I will the 2nd Instance of FB100(Vessel-2) now the STAT variables will read/write indirectly from/into the destination that is defined in another(DB10, different location 2nd pointer Index table).And So on....


my english not so good, But I hope I cleared most of the things that this application needs.
 
You could make an UDT containing all the parameters you want to pass to FB100

And then declare the udt in a DB.

In fb100 you declare as an input/in_out the udt type you just created and then you can pass the whole udt with command,status,modes,parameters and so on to the fb100..

Am I making any sense due to my lack of writing in English this could be seen as jibberish...
 
I would do what bara_hence suggest but in addition...

I would declare a shared DB with an array of UDTs in it. There would be one element for each instance. Then I would have a bunch of FCs ( methods in C++ ) that are called with either the index of the UDT or a pointer to the UDT in the array. I haven't figure out what works best yet. If I were doing most of my code in LAD I would pass an index and do the indexing in just one place in the FC.

Then the FB doesn't need to be a FB. It can be a FC.

So far I haven't found much use for FBs except for simple things where there is is no little or need to get to the static information .

What I haven't figured out yet is if I can access fields in the UDT by specifying a symbolic offset. For instance
Code:
    L D [AR2,OFFSET_OF_VARIABLE]
The problem I see is that a pointer does not have a type that is a pointer is not declared as a pointer of type UDT2 so how is the called FC going to know about the symbolic offsets from the pointer?

If I must always hard code the offset like
Code:
    L D [AR2,P#0.0]
Then I would be extremely careful. If the UDT changes then you would need to search all your code and change the hardcoded offsets. An alternative would be to make accessor FCs just like there are accessor methods in C++ and Java. This way if the UDT changes you only need to change the accessor methods and not have to search the whole program to fix up offsets.

By now it is obvious that I am a java and C programmer with java and C like solutions.
 
So far I haven't found much use for FBs except for simple things where there is is no little or need to get to the static information .

Ninety percent of my projects are done in FBs. If you call them unconditionally, there is no IDB required, and a global data block of UDTs can be used instead. In the FB, just enter a UDT in the STAT area, and the current value of AR2 decides which UDT in the araray you are addressing. In each UDT, define pointers to themselves or other UDTs (calculated on startup) and you're off and running.
 
STAT UDT in S7

In each UDT, define pointers to themselves or other UDTs (calculated on startup) and you're off and running.


I am not sure how you link between the parameters of one function to the others, where all that function blocks are different in structure, different UDT length. Here in my case I also need some In/ Out variables to clear the operational picture of the FB,by looking into the Block in one shot picture should be clear what is inside.

I see the your example S7 plc program is very clever,may be I will use one day your method, but in this case I dont see any possibility.(Because may be my FBs are all in different in size & design,I dont want unneccesary variables in FB's var.declation table).

Thanks for cooperation
 
Indirect addressing

I would declare a shared DB with an array of UDTs in it. There would be one element for each instance.

Hi Peter Nachtway,
I have made attempt to link between parameters by using pointer indirect addressing , for that I have made a Share DB with index pointing to source & destination of parameters to be link, but finally I am convinced myself(Siemens forum expert are really good to guide)this way of doing it is like making simple things complicated...but any way am sending the Link of that forum..

<link>
https://www.automation.siemens.com/forum/guests/PostShow.aspx?PostID=154411&language=en&PageIndex=2

Thanks
 
Dear Manmeet, How are you? How is temp in Gurgaon, Delhi?

Thank you for your attemp to help me.I want something/ some logic may be indirectly to link between parameters of different blocks with different structure.S7Guy has one example, but he used same structured UDT, in my case UDTs are totally different.
for detail application please look into previous post.
 

Similar Topics

Hi I am stuck in making a small piece of program for an S7 300 Plc, I know exactly how to program it in an omron plc but I cannot convert it...
Replies
8
Views
3,971
Hi, I have a problem with addresses of a DB. I have two DBs. In one(DB 10) I keep the address of the element from the second one(DB1000). What I...
Replies
3
Views
4,819
Hi guys, Disappeared few weeks for writing code, I'm back with a problem. There is a repeating work for different group of signals, so I decide...
Replies
18
Views
15,125
Hi Guys, Hopefully attached is the code i could with some advice on. I believe this code controls the mapping of Internal memory to the...
Replies
8
Views
2,579
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
620
Back
Top Bottom