Sign in to follow this  
Followers 0
tommu56

sharing data blocks with 2 fb s7-300 plc

13 posts in this topic

I need to modify the logic on one of our s7/300’s I figured I could share data block between 2 conditional function blocks If I copy the network I can’t figure out how to modify the function block in the copied block. Or If I create a new block in net work I can get the new FB inside the block but the DB10 comes up red and says some thing like illegal entry. Attached are screen shots with comments Thanks tom S7FBHELP.bmp

Share this post


Link to post
Share on other sites
2nd attachment for above thanks for the patience!!! tom S7FBHELP2.bmp

Share this post


Link to post
Share on other sites
Hi Tom. Not sure what you want to do. For troubleshooting FBs with IDBs, you can use "Monitor with call-up path". In that way you will be looking at only that particular instance. You may need to enable Test Mode on the CPU. And the offline code must be 100% synced with the online code. Right-click on the block and select "Called Block.." and then "Monitor with Call-up path". If the Monitor with call-up path does not appear in the menuitems in the dialog that appear when you right-click on the block, then check if Test mode is enabled and maybe download FB and IDB again, even if you are convinced the offline and online blocks are identical. If you want to make a new modified FB, with the previous FB a template, then copy the 1st FB to a new FB, and edit the new FB. Call the new FB and assign a new IDB to it. In your case, you may get away with simply doing an "Check and update accesses".

Share this post


Link to post
Share on other sites
Thanks for the reply. I am a retaliative newbie to the s7 thing. The original function block was from oem and it doesn't work for us. Instead of butchering their block I wanted to use the same data block for theirs and my new one with a input to switch between them that way I could test my new logic on the fly by throwing the toggle switch to alternate between the 2 FB's The help screen shows sharing the data blocks but I am missing how to do it or convert it to shared one. In S7 help type shared data blocks. The one now is only associated with it is DB10/FB10 witch is a instance block it only works with FB10 how would I convert it to a shared data block? tom Edited by tommu56

Share this post


Link to post
Share on other sites
When you create the instance DB it is linked to the FB, if you look at the symbol table, you would see the FB with the DB. You cannot call another FB with that same DB, you have to create a new DB.

Share this post


Link to post
Share on other sites
Hi again Tom. So you want to switch programs on the fly. Would have been easy with an FC, but not so easy with an FB. If it does not have to be "on the fly", then you can merely have two separate FB+IDB pairs. If it has to be on the fly, then it will be possible, IF the size of the IDBs are exactly the same. ALSO, the extra i/o pins on the FB must leave the previous FBs pins untouched. The new IDB must be exactly the same, except for that some of the DB content of the previous ID that was not used, is used for the extra i/o pins. It may be possible because a DB is always setup in whole WORDs, so if only 5 input pins are used, then there will be 11 unused BOOL addresses where the new input pins can fit in. If that is OK, you can copy the content of the IDB back and forth when you switch FBs. Use one-shots to trigger a SFC20 BLKMOV from one IDB to the other. Not sure if the is a "smarterer" way.

Share this post


Link to post
Share on other sites
Thanks for the help As I said I am a newbie no formal s7 programing training (logix 500 and logix 5 are a piece of cake to me) and this is my first foray in to the s7 world. The ladder logic in the function block looks pretty straight forward and I copied the old fb renamed it and could edit the ladder to do what I feel is correct. The reason I am doing this is to help eliminate the night and week end calls I wanted to switch it on while I was at work for a week or 2 to prove logic or if we had a problem the shift electrician (we run 7/24/365) could switch back if he had a problem on the off shift. and I could look at it when I got back in Groo I under stand that the data block is tied to the function block. But on the other hand the help sections says I can share it help index "Shared Data Blocks (DB)" doesn't explain how to do it the graphic has 2 function calls (FC10, 11)one fb (FB12) one shared db (DB20) one instance db (DB112) is going only to the FB12 The shared data block has a box alongside it that says "shared by all blocks" and I am trying to figure out how to share them. JesperMP How would use use the function calls to switch be tween the logic in ob1 nothing is conditional in this program? thanks again tom

Share this post


Link to post
Share on other sites
Something like this: Pseudocode: Oneshot of (Bit_new_FB=OFF) --> Call SFC20 to copy from new IDB to old IDB. Oneshot of (Bit_new_FB=ON) --> Call SFC20 to copy from old IDB to new IDB. Bit_new_FB=OFF --> Call old FB/IDB, ignore new FB/IDB. Bit_new_FB=ON --> Call new FB/IDB, ignore old FB/IDB.

Share this post


Link to post
Share on other sites
A Data Block can be an 'instance' or a 'shared' Data Block [NOT BOTH]. An Instance Data Block is one that is created automatically by the system when first putting in a Function Block call. You cannot modify the make-up of an Instance Data Block, it is the combination of the IN, OUT, IN_OUT and STAT variables of the FB that its created for. The only way to modify the IDB is to modify those parameters in the FB. Once that has been done you have to re-create the DB (I often delete the DB and then go to the FB call and cut and paste the call, the DB is re-built). A shared Data Block, is one where you create the Data Block, ie a store for presets or recipe's etc. You can look and modify the shared DB in the step 7 editor. I would do as Jesper suggested (create a new FB with a new IDB) and use SFC20 to pass parameters between them, such as: AN M 500.0 // one way JC OV1 CALL "BLKMOV" SRCBLK :=P#DB1.DBX0.0 BYTE 100 RET_VAL:=MW600 DSTBLK :=P#DB2.DBX 0.0 BYTE 100 OV1: AN M 500.1 // and the other JC OV2 CALL "BLKMOV" SRCBLK :=P#DB2.DBX0.0 BYTE 100 RET_VAL:=MW600 DSTBLK :=P#DB1.DBX 0.0 BYTE 100 OV2: nop 0 Edited by Groo

Share this post


Link to post
Share on other sites
a method you will able to use OPN DI 10 A M 0.0 CC FB10 AN M0.0 CC FB15 CC = Conditional Call. you have no parameters at IO so this will be OK Edited by Groo

Share this post


Link to post
Share on other sites
I'm at home now Thanks for the help is SFC20 a command or a block you create? When I get in on Monday I'll look it up, Thanks again

Share this post


Link to post
Share on other sites
Don't bother with SFC20 do the code I put up after, the following post, it will allow you to switch between blocks using the same IDB, as you originally requested. The IN, OUT, IN_OUT, and STAT areas MUST be the same to do this. If you add anything to the above parameters you would need to add it to the original block as well, even if its not used, as it may move the offsets to bits and bytes in the IDB. What it is doing is making the IDB the current IDB and then calling the block without parameters, it will use any DB that is the current IDB, as its called before, then DB10 will be that DB. Both FB calls will use DB10. Edited by Groo

Share this post


Link to post
Share on other sites
For info SFC20 is a library block.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0