S7 question - FC's vs FB's

PLCKeef

Member
Join Date
Nov 2005
Location
Australia
Posts
68
Just wondering what the adantages are or reasons for using a Function Block and it's associated Instance DB over a Function and a Global DB?
 
A FB allows you to have multiple calls to it, each with its own data set - the instance DB.
A FC does not.
 
You can have multiple calls to FC's and FB's, no difference there.

The main advantage I can see is the fact that the STAT's gives you the ability to remember states without needing to pass data in and out.

A multi-called FC generally would be for logic where you pass data in and perform some sort of operation which is complete that scan, you do have the IN_OUT which can remember states but this would normally be quite small, you wouldn't want too much although I have seen FC's and FB's with rediculous amounts of data passed in and out.

With a FB the STAT area gives you unique memory for that call, an area which can be quite large if required.
 
I'm still not sure.
An FC can be programmed using formal operands as does an FB.
It's the Instance DB that I don't understand.

I'm thinking each time I call an FB , I have to set up it's DI with the values that the FB is going to use ?

I will have to experiment a bit.
 
You program the FB and then you call the FB.

When you program in the call you are prompted to enter a DB number for the IDB, the system then creates the IDB, it will contain any IO parameters plus the STAT parameters.

I've seen some inexperienced programmers create a FB and don't have any IO or STAT's, they still have to create the IDB which is empty. A classic case of 'SHOULD HAVE BEEN A FC'.

The IDB at the end of the day is JUST A DB, you can access and change data anywhere in the program within the IDB in just the same manner as a global DB. The main difference is the fact that you cannot modify the DB make-up, i.e. you cannot open the IDB and add a few words.
 
Whilst Siemens allow you to use functions with IN_OUT and OUT parameters, one method of making a distinction is to use FCs where a set of inputs to the FC produce a return value (RET_VAL) from the FC (i.e. do not use FCs with IN_OUT and/or OUT parameters).

For everything else, use an FB
 

Similar Topics

Hello again..trying something on an existing poorly written program and just wanted to double check something system is an A-B MicroLogix 1200 In...
Replies
5
Views
169
Good morning! Let me start by saying, I am still learning about this type of HMI programming. I recently watched a video about recipes and how it...
Replies
0
Views
71
I have some logic that I have written within a 5380 series controller that tracks the time an event is started, while the event is running an RTO...
Replies
2
Views
93
I have an HMI 2711R - T4T Series B, and I want to know which PLCs, besides Micro 820, can communicate with it.
Replies
2
Views
90
HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
82
Back
Top Bottom