7/14/2012 11:06 AM | |
Posts: 8 Rating:
|
Hello Gentlemen, I have an interesting problem. In a Multi-Instance FB I call 2 new FBs in Network 1 and Network 2. (see picture call_minstance.jpg). The calls are made with different IN parameters (DB_ADR and OFFSET). DB_ADR is pointer type and OFFSET is INT type. When Program execution hits those 2 FBs weird stuff happens. The parameter OFFSET is correctly passed to the calling block - look at stl_example.jpg. First block has F (15 decimal) and second block has 14 (20 decimal) - which is correct. However, DB_ADR does not get correctly passed. Both called FBs have value of the first DB_ADR argument (218) - look at stl_example.jpg Why does this happen? Are pointers differenrly passed in Multiinstance as other values?? Rgds, Jure
Attachmentmulti_ptr.zip (167 Downloads) |
7/14/2012 3:58 PM | |
Joined: 10/7/2005 Last visit: 9/5/2024 Posts: 3018 Rating:
|
Hello Jure Petrovic
No, they are not.
It has to do with the multi instance call. Not onlySTAT variables, but also all IN, OUT, IN_OUTarelocated in the Instance DB of the calling FB (the IDB of FB163 in your case). In order for the program to get to those values when you do a Multi Instance call, Step 7puts an offset value into AR2 for every FB call which isthenused to get the correct values for that particular call. This is doneautomatically (and behind the scenes) for every symbolic access to any FB variable (which is why your "OFFSET" INT type FB Parameter receives the correct value). As you (quite rightly) access the individual values of your "DB_ADR" Pointer type FB Parameterindirectly, you must though manually take the AR2 stored Multi Instance offset into account. Two ways on how to this are explained in the Post Adress Absolut with multi instanceand I hope this helps. |
Cheers |
|
This contribution was helpful to
1 thankful Users |
7/15/2012 10:50 AM | |
Joined: 10/7/2005 Last visit: 9/5/2024 Posts: 3018 Rating:
|
Hello again Jure
Well, I suppose it is and my statement "for every symbolic access" should havehad an exception clause in it Nonetheless,there is still a difference between the two FB parameter accesses that you do. "L #OFFSET" will give you the value of the actual Parameter, "LP##DB_ADR"will give you a pointer address to the memorystart location of the actual Parameter. Since Multi Instance was only introduced at a later stage of the Step 7 development (with V4.something from memory), I guess the developers "overlooked" cateringfor "L P#<Parameter name>" based access. I'm sure this case too could have been implemented to automatically take the AR2 based offset into account. It is obviously too late to change this Step 7 behaviour now, as it would lead to making existing logic (that does "manually"take AR2 into account) no longer work correctly. Unfortunately yes, but I'm pleased to hear the changes that you made do the job now. |
Cheers |
|
This contribution was helpful to
1 thankful Users |
Follow us on