Technical data

Basics of Creating Logic Blocks
10.3 Multiple Instances in the Variable Declaration
Programming with STEP 7
248 Manual, 05/2010, A5E02789666-01
10.3.2 Rules for Declaring Multiple Instances
The following rules apply to the declaration of multiple instances:
Declaring multiple instances is only possible in function blocks that were created with STEP 7
from Version 2 onwards (see Block Attribute in the properties of the function block).
In order to declare multiple instances, the function block must be created as a function block
with multiple instance capability (default setting from STEP 7 Version x.x; can be deactivated in
the editor using Options > Customize).
An instance data block must be assigned to the function block in which a multiple instance is
declared.
A multiple instance can only be declared as a static variable (declaration type "stat").
Note
You can also create multiple instances for system function blocks.
If the function block was not created as being able to have multiple instances and you want it to have
this property, you can generate a source file from the function block in which you then delete the block
property CODE_VERSION1 and then compile the function block again.
10.3.3 Entering a Multiple Instance in the Variable Declaration Window
1. Open the function block from which the subordinate function blocks are to be called.
2. Define a static variable in the variable declaration of the calling function block for each call of a
function block for whose instance you do not want to use an instance data block.
- In the variable table, select hierarchy level "STAT".
- Enter a name for the FB call in the "Name" column of the variable detail view
- Enter the function block you want to call in the "Data type" column as an absolute address
or with its symbolic name.
- You can enter any explanations required in the comment column.
Calls in the Code Section
When you have declared multiple instances, you can use FB calls without specifying an instance
DB.
Example: If the static variable "Name: Motor_1, Data type: FB20" is defined, the instance can be
called as follows:
Call Motor_1 // Call of FB20 without instance DB