4/7/2012 11:38 AM | |
Posts: 41 Rating:
|
Hello Colleagues, I spent a long time trying to solve the problem without success. Here is a detailed description with a sample project in the attachement: 1. I wrote FB_Motor (FB1) to be called several times inside a multi-instance host FB called FB_HOST (FB2). the latter is called in OB1 with its IDB DB_HOST (DB2). OB1 --->( FB_HOST,DB_HOST) ----> (FB_Motor,#Motor1) and (FB_Motor,#Motor2) Where #Motor1 and #Motor2 are local instances of FB_Motor declared in the STAT area of FB_Host. 2. FB_Motor consists of only one IN/OUT byte called "HMI_Interf_Byte" and serves as HMI interfacing tag that gathers several binary info in order to save tag count (license). 3. The code of FB_Motor also contains a single line of code that copies the fisrt bit in "HMI_Interf_Byte" in its last bit: DIX0.0 ----> DIX0.7 4. In the variable table, the two bytes from the two instances are shown. Normally if we write 16#01 in any of them ,they should become 16#81. BUT this works only for theFIRST instance and never for theSECOND EVEN if we delete the FIRST instance (#Motor1) from the code and let only the SECOND one (#Motor2). --------------------- I think that the access to the instance DB ( DIX0.0 ----> DIX0.7) lies behind the problem. Would you please help me fix the issue. Best regards. AttachmentMultiinstanceProblem.zip (49 Downloads) |
Last edited by: NA Simatic at: 4/7/2012 11:40 AM |
|
4/7/2012 2:23 PM | |
Joined: 10/7/2005 Last visit: 6/5/2023 Posts: 2966 Rating:
|
Hello NA Simatic the "simple" explanation for your problem is that you use an absolute Instance DB address (e.g. DIX1.0) in a Multi Instance FB which will not work. What happens behind the scenes is this: When you do a call of a Multi Instance capable FB, itsMulti Instance DB start addressis stored in AR2. Any symbolic access that you have programmed inside the FB willautomatically use the AR2 related offset into account and thus find the correct address in the Multi Instance DB (Step 7will take care of this for you). If you however "bypass"symbolic addressing and use an absolute Instance DB addressinstead, you will always access this absolute address in the Multi Instance DB and thus have the problem that you observe. Possible Solutions: 1.) Use only symbolic access to the FB's variables. 2.) Use indirect addressing and take the AR2 related Multi Instance offsetinto account (have a look at THIS entry, specifcially at the end of it on how to take AR2into accountand note too the other indirect addressing related links at the top). I hope this helps |
Cheers |
|
4/9/2012 7:18 AM | |
Posts: 41 Rating:
|
Many thanks Dear Fritz for your valuable advice! I solved the problem using symbolic addresses. Best Regards. |
This contribution was helpful to
1 thankful Users |
Follow us on