3/7/2012 2:04 AM | |
Posts: 108 Rating: (2) |
Hi, I have been learning how to use FB81 to operate a PLC as a modbus slave. I would like to be able to use an instance of FB81 within another FB. Is this possible? It seems to me that although FB81 is identified as multiple instance capable, it does not work unless it has its own instance data block. I have successfully used FB81 to make a PLC act as a modbus slave, calling it from OB1 with its own instance data block, DB81. However, when I try to create an FB in SCL that contains an instance of FB81, the modbus communications do not work. It seems that when an instance of FB81 is embedded in another FB, it cannot accurately determine the location of the receive data of the modbus communications. When FB81 has its own instance data block, the receive data location starts at DBB 188. When an instance of FB81 is embedded in another function block, FB81 still tries to use this same location for the receive data, which is incorrect if the function block that it resides in has other data before the instance data for FB81. In this case the area used for the receive data should begin at a higher data block byte number. Is there a way to use an instance of FB81 within another FB, or is this not possible? AttachmentModbslav.zip (64 Downloads) |
3/7/2012 8:11 AM | |
Joined: 10/7/2005 Last visit: 5/20/2024 Posts: 3005 Rating: (1048)
|
Hello jasonr from what you describe, it appears that FB81 is indeeed NOT Multi-Instance capable. Being Know How protected, one can of course not look into itslogic () to verify if the programmer has for example used indirect addressing for the STAT's but"overlooked" to take AR2's Multi Instance offset value into account. This wouldexplain though the problem you observeand would be an "undocumented feature" of FB81. Assuming the above is the case, here's what you can do: 1.) Send a support request to Siemens to inform them about the issue who should at least be able to confirm the "undocumented feature" and may then also be able to get a corrected versionprogrammed (or alternative at least remove the Muli Instance capability from FB81). 2.)Embedd FB81 into another FB at the start of its STAT variables and make sure that thatFB does NOT have any IN, OUT or IN_OUT parameters. In the case of your FB400 which has two IN parameters, you can easilyget rid of theTIMER IN parameter by replacing it withan SFB4 based timeras a Multi Instance call(to be located after FB81's Multi Instance call). To removethe LADDR IN Parameter, you couldmake it a STAT in FB400 and then manually write the correct value into FB400's IDB it before you call FB400. I know this is a"nasty" way of doing it, but it will work as FB81's STAT variables now sit at the same location as if it has it's own Instance DB. I hope this helps and please let us know what you find out when you contact Siemens Support P.S: I took the liberty of sending a "suggestion for entry" at the download link for the "Function Blocks, Examples and User Manuals of the Serial Interface ET200S 1SI" entryto inform them about FB81's possible non-Multi Instance capability. |
Cheers |
|
3/8/2012 12:31 AM | |
Joined: 10/7/2005 Last visit: 5/20/2024 Posts: 3005 Rating: (1048)
|
oops, didn't check what you use the TIMER Input of FB400 for. Asyou need to pass it on asan S5 Timer numberto FB81, thiswill unfortunately throw a Spanner in the works of using SFB4 instead. Sorry, no "nasty trick" from my side to solve this one (you can NOT declare a STAT variable asdata type TIMER, so I can't think of way to have it located behind FB81's multi instanciated STAT variables). Come to think of it, ifFB81's developer would have used a multi instance SFB4 inside FB81 there'd be no need for FB81 to have this TIMER input at all, feel free to pass this improvement suggestion on to them while they fix up the other issue. On the bright side, I got feedback from Siemens too, confirming thatFB81 is NOT Multi Instance capable and that they will "take care of the problem" (which hopefully means making it Multi Instance capable rather than removing the Multi Instance capable property from it). I hope this helps |
Cheers |
|
Follow us on