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

I have never had the pleasure of working with a "Thermistor" until now and have a question. The Thermistor is a 10KOhm 4-20mA 2-wire device and I...
Replies
3
Views
73
Hi All, So I have a main routine with an instruction that's executed by XIC "Run" I have a JSR located on a rung below it. In the logic for that...
Replies
6
Views
153
I have a 120V relay, 120V DI card and a analog input. I was wanting to know if i could put a 24V DI and well as a 120V DI card on the same plc...
Replies
1
Views
89
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
197
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
4
Views
198
Back
Top Bottom