Step7: Sectioning a large FB

AReSGodOfWar

Member
Join Date
Feb 2009
Location
Ontario
Posts
3
Let me begin by saying that I am a PLC programming newbie.

Currently I have a multi instance FB, let’s call it Robot, which I am using to control two identical robots. The FB has 28 inputs and 25 outputs, a number of static variables, and consists of 89 networks. What I would like to do is break this large Robot FB into a number of smaller FB or F and then call each one of these smaller function blocks from within the parent Robot FB but avoid passing I/O and static variables around.

Is there a way to read/write to a parent FB I/O and static variables without having to pass them as Input, Output, or In/Out parameters? I know I can load a DB using the OPN instruction but then I’m stuck referencing data using DBX 0.0 instead of descriptive variable names such as “SystemReady”. Perhaps I can pass a UDT around but then in the parent Robot FB I’ll need to copy all the FB I/O to the UDT so it can be passed to child FB calls.

Any help on how to keep this small and tidy would be greatly appreciated. This should be easy to do but I imagine that there something simple that I am overlooking.

Thank you,

AReS
 
One method as follows:

Each of your child FB's must have exactly the same interface(IN,IN_OUT,OUT,STAT) as the parent FB (i.e. they will start out as a copy of the parent FB but with all the executable code removed. You will add the processing required)

When you call a child FB, use the UC FBx method. The child FB will execute as if had been placed "in-line" inside the calling FB because the UC method does not modify address register 2 or the instance DB. All variables in the interface will be available.

To make things easier to maintain, use S7Guy's method and use a UDT in the stat area. If you need to change the interface, change the UDT (extend it) and it will be updated in all places where it is used. Pass inputs in using logic the conditions the instance DB data before the call, and then drive your outputs from the instance DB after the call.

Whether you consider this "simple" though, is another matter :)

Here's an example project showing the principle described above.
 
Last edited:

Similar Topics

This is the first time I am working with Simatic Manager Step7 as I started my siemens journey with TIA which is pretty easy and do a lot of stuff...
Replies
3
Views
143
When you download a DB, the values get overwritten by what is in the "actual" column in offline DB. Does this happen at the start of the PLC...
Replies
6
Views
142
Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
128
Hi all, I am trying to convert RSLogix 5000 program to Step7. I need to bit shift left my array of double integers for tracking the product on...
Replies
2
Views
520
I have a word in some DB which I want to load to AR1 and use as a pointer. In order to do this I need to write L DBxy.DBW xy SLD 3 LAR1 I...
Replies
3
Views
533
Back
Top Bottom