You are on page 1of 1

Function blocks (FB)

Function blocks (FB)

Definition
Function blocks are code blocks that store their input, output and in-out parameters perma-
nently in instance data blocks, so that they remain available even after the block has been
executed. Therefore they are also referred to as blocks "with memory".
Function blocks can also operate with temporary tags. Temporary tags are will not be stor-
ed in the instance DB, but are available for one cycle only.

Application
Function blocks contain subroutines that are always executed when a function block is
called by another code block. A function block can also be called several times at different
points in a program. As a result, they simplify programming of frequently recurring func-
tions.

Instances of function blocks


A call of a function block is referred to as an instance. An instance data block is required
for each instance of a function block; it contains instance-specific values for the formal pa-
rameters declared in the function block.
The function block can store its instance-specific data in its own instance data block or in
the instance data block of the calling block.

Access modes
S7-1200 and S7-1500 offer two different access options for the instance data blocks, which
can be assigned to a function block when this is called:
• Data blocks with optimized access
Data blocks with optimized access have no firmly defined memory structure. The data
elements contain only a symbolic name in the declaration, no fixed address within the
block.
• Data blocks with standard access (compatible with S7-300/400)
Data blocks with standard access have a fixed memory structure. The declaration ele-
ments contain both a symbolic name in the declaration and a fixed address within the
block.

Note
To avoid errors when working with function blocks, refer to the section "Parameter
transfer at block call".

See also
Calling a function by another function
Creating functions and function blocks
Multi-instances
Instance data blocks
Basics of block access

-1-

You might also like