difference between"function" and "function block"

Dutchie

Guest
D
Hi, could someone explain the exact difference between a function and a function block (plc s7 314 siemens). In english or dutch please :D
 
FCs and FBs are fundamentally the same, except for one very important thing:

In addition to all the other possible symbols that can be defined for the block, FB has a new one called "STAT". The STAT means that it is static (memorized between scans). The FB will need an associated DB to store the STAT values.
Compare with the TEMP variables that are lost when you leave the Fc or FB.

You should use FBs with DBs when you need to make reusable objects. With reusable objects I mean program code that need to have many STAT variables.

If you only need to keep a few variables in memory between scans, then you can still use FCs. Just define the variables as INPUT/OUTPUT.
 
Last edited:
One thing to remember, while running "smaller" PLCs. There is a limited number of DB's, 314 is 126. (I think). Each one uses 38 bytes of header information. You may want to consider using a FC as Jesper said and use IN/OUT and setup a "STRUCT" in a DB that is called for every time you call the FC. I have attached a sample.
 
Using Structures to Access Data

Structures

A structure combines various data types (elementary and complex data types, including arrays and structures) to form one unit. You can group the data to suit your process control. You can therefore also transfer parameters as a data unit and not as single elements. The following figure illustrates a structure consisting of an integer, a byte, a character, a floating-point number, and a Boolean value.




A structure can be nested to a maximum of 8 levels (for example, a structure consisting of structures containing arrays).

Creating a Structure

You define structures when you declare data within a DB or in the variable declaration of a logic block.

The following figure illustrates the declaration of a structure (Stack_1) that consists of the following elements: an integer (for saving the amount), a byte (for saving the original data), a character (for saving the control code), a floating-point number (for saving the temperature), and a Boolean memory bit (for terminating the signal).




Assigning Initial Values for a Structure

If you want to assign an initial value to every element of a structure, you specify a value that is valid for the data type and the name of the element. You can, for example, assign the following initial values (to the structure declared in the above figure):

Amount = 100
Original_data = B#(0)
Control_code = 'C'
Temperature = 120
End = False

Saving and Accessing Data in Structures

You access the individual elements of a structure. You can use symbolic addresses (for example, Stack_1.Temperature). You can, however, specify the absolute address at which the element is located (example: if Stack_1 is located in DB20 starting at byte 0, the absolute address for amount is DB20.DBW0 and the address for temperature is DB20.DBD6).

Using Structures as Parameters

You can transfer structures as parameters. If a parameter is declared as STRUCT in the variable declaration, you must transfer a structure with the same components. An element of a structure can, however, also be assigned to a parameter when you call a block providing the element of the structure corresponds to the data type of the parameter.

If you use structures as parameters, both structures (for the formal parameters and the actual parameters) must have the same components, in other words the same data types must be arranged in the same order.
 
My understanding is that a function can only have one output value, a function Block can have several.

In some PLC's functions can be strung together and FB's can't.
 
You can call FC's from FB's, FB's from FC's, SFB's (System Function Blocks) or SFC's (System Function Calls) from FC's or FB's. I think the limit is 7 or 9 nested depth's. You are also limited by the amount of memory and scan time.
 
FC's can have many output values.
And also many input/output values.

Dont really know what the maximum number of inputs and outputs is, but there probably is a max value.

Rick, which PLCs is it that cannot have input/output values ?
 
You can save from eating up databases when calling the same DB frequently if the block calling the FB's is also a FB by making the repeated one multiple instance capable and therefore defining them in the master FB's STAT area inder one DB.
 

Similar Topics

Hello, I have a problem with AO- and AA-Tags. When I use for example the tag AO_Test with the address 200 and type the value 1,2 in, the AA-Tag...
Replies
7
Views
1,411
As per the title. This might seem like a basic question to many, but I'm unclear about the difference between a coil ( ) and an application...
Replies
28
Views
4,034
Good Morning , I have 2 Frequency Drive panels to build and commission . It is for 2 pump systems . Just wondering , what is the...
Replies
4
Views
1,971
Hi Experts, Good day! What are the differences between PCS7 SIMATIC Batch and PM Control? Do you have any manual like "Getting Started "...
Replies
0
Views
809
I have a Automation Direct Click Plus that you can buy option CPU slot modules for input/outputs. The slot modules have the options of sinking...
Replies
9
Views
2,819
Back
Top Bottom