s7 software

adx

Member
Join Date
Feb 2008
Location
Dubai
Posts
4
Hi everybody.I am new to s7 programs.could anybody let me know what is the advantage of using FUNCTION instead of FUNCTION BLOCKS in the s7 SIMATIC MANAGER. Thanks.
 
Functons are used where you don't need memory attached, all data needed to complete the logic is passed as IN or IN_OUT parameters and the result is passed as a OUT or IN_OUT.

Good practice would dictate that you do not attempt to set parameters sent in as IN parameters and you don't user the OUT parameters as conditions until after you have conditioned them in the block.

Function Blocks are as they call them, blocks with memory, that is when called from the code, you must assign an Instance Data Block, where all IN, OUT, IN_OUT and STAT parameters are saved and can be used external to the FB if required.


I have seen code where they have created an FB as a distribution block, where there was no input or output parameters and no STAT's created. When the block was called they had to create an Instance DB, the only time I have seen empty DB's. That was a definate case where the block should have been a Function.
 
adx said:
Hi everybody.I am new to s7 programs.could anybody let me know what is the advantage of using FUNCTION instead of FUNCTION BLOCKS in the s7 SIMATIC MANAGER. Thanks.
Like Peter says, the fundamental difference between the two is the fact that an FB has associated memory whereas an FC does not have associated memory. For example, if you ran a totalizer that said
NewCount := OldCount+Delta;
you can use an FC provided OldCount and NewCount are IN / OUT parameters and are connected to DB or to Global variables. But if you have these as internal TEMP variables, you are doomed when you call the FC a 2nd time. The 2nd instance of the FC will reuse the OldCount value from the 1st instance of the FC (of the same program cycle) and there's going to be havoc with the various instances interfering with each other.
If you had used an FB for this, you could uses STAT for the OldCount. All STAT, IN, OUT, IN_OUT are assigned memory space (DB) whenever an FB is instantiated. So no 2 instances of an FB will interfere with each other.

A good rule of the thumb is: Use an FC when the data flow is forward only (e.g. OUT1 := IN1 + IN2; ). If there is any reuse of data from one program cycle to the next (e.g. totalizers, RS / SR flip flops, etc) use an FB. If you are still stuck up about using an FC for such cases, make sure that the variable that is to be reused in the next cycle is stored external to the FC. Test the FC by instantiating it twice and make sure that these don't interfere with each other.
 
Friends, I am still not clear with difference between F and FB.
You say data is lost in F.Its not clear how.Whenever we are calling a function we are assigning actual parameters to the formal parameters.If there is another instance then another set of acutal parameters which are global variables. So data will be stored in the actual parameters...where is the question of data getting lost !!!!

Peter you are online can u clarify my cofusion please
 
adx said:
Friends, I am still not clear with difference between F and FB.
You say data is lost in F.Its not clear how.Whenever we are calling a function we are assigning actual parameters to the formal parameters.If there is another instance then another set of acutal parameters which are global variables. So data will be stored in the actual parameters...where is the question of data getting lost !!!!

Peter you are online can u clarify my cofusion please

The difference is, those parameters that you pass to a FC, the ONLY ONES SAVED are the IN_OUT and the OUT parameters and even then you cannot rely on the OUT parameter data internally until you have manipulated it internaly.

For instance a simple starter circuit, IN = START, STOP and OUT = RUN, then internally program

Code:
 A(
 A START
 O RUN
 )
 AN STOP
 = RUN

You could not rely on the RUN output to maintain the cicuit unless you changed the OUT to an IN_OUT.

The only additional internal memory available for the FC are TEMP memory, which is temporary scratch flags that are not memorised.

In an FB, the above logic will work, even with RUN as an OUT, as all IN, OUT and IN_OUT parameters are stored in the Instance DB that you assign to the block. Additionally you have STAT's as well as TEMP as internal memory, the TEMP as with the FC is scratch area and must be manipulated prior to use and is lost once the block is exited. The STAT is real memory whose status is stored in the instance DB, so this can be used to remember the state of things you need next time you call the block.
 

Similar Topics

Hi! So my problem is a little funky, I had Studio 5000 v 24 and 30 installed, but forgot to install RSLogix (which I cannot go without). Is there...
Replies
2
Views
112
Hello, As part of our project, we are using an M241 controller. This controller interfaces with an industrial computer and a router via a switch...
Replies
2
Views
99
Hi, I cannot find the DLCA1764.EXE utilty software for data retrieving. Can someone share the link to download this software. Thanks!
Replies
4
Views
115
Hi everyone, I am an omron plc tec , lately I came across a siemens s7 200 cn plc . Can someone help me regarding the software required and...
Replies
26
Views
630
Hi everyone, I'm in search of software for electrical drawings, preferably free but also interested in paid options. Any recommendations or...
Replies
33
Views
1,565
Back
Top Bottom