Technical data

Basics of Designing a Program Structure
4.2 Blocks in the User Program
Programming with STEP 7
90 Manual, 05/2010, A5E02789666-01
4.2.3.3 Function Blocks (FB)
Function blocks (FBs) belong to the blocks that you program yourself. A function block is a block
"with memory." It is assigned a data block as its memory (instance data block). The parameters
that are transferred to the FB and the static variables are saved in the instance DB. Temporary
variables are saved in the local data stack.
Data saved in the instance DB are not lost when execution of the FB is complete. Data saved in the
local data stack are, however, lost when execution of the FB is completed.
Note
To avoid errors when working with FBs, read Permitted Data Types when Transferring Parameters in
the Appendix.
Application
An FB contains a program that is always executed when the FB is called by a different logic block.
Function blocks make it much easier to program frequently occurring, complex functions.
Function Blocks and Instance Data Blocks
An instance data block is assigned to every function block call that transfers parameters.
By calling more than one instance of an FB, you can control more than one device with one FB. An
FB for a motor type, can, for example, control various motors by using a different set of instance
data for each different motor. The data for each motor (for example, speed, ramping, accumulated
operating time etc.) can be saved in one or more instance DBs.
The following figure shows the formal parameters of an FB that uses the actual parameters saved
in the instance DB.