14
Function Blocks
Section 1-2
Instances
To use an actual function block definition in a program, create a copy of the
function block diagram and insert it in the program. Each function block defini-
tion that is inserted in the program is called an “instance” or “function block
instance.” Each instance is assigned an identifier called an “instance name.”
By generating instances, a single function block definition can be used to pro-
cess different I/O data with the same function.
Note
Instances are managed by names. More than one instance with the same
name can also be inserted in the program. If two or more instances have the
same name, they will use the same internal variables. Instances with different
names will have different internal variables.
For example, consider multiple function blocks that use a timer as an internal
variable. In this case all instances will have to be given different names. If
more than one instance uses the same name, the same timer would be used
in multiple locations, resulting in duplicated use of the timer.
If, however, internal variables are not used or they are used only temporarily
and initialized the next time an instance is executed, the same instance name
can be used to save memory.
Number of Instances
Multiple instances can be created from a single function block definition. Up to
either 256 or 2,048 instances can be created for a single CPU Unit depending
on the CPU Unit model. The allowed number of instances is not related to the
number of function block definitions and the number of tasks in which the
instances are inserted.
a
b
c
a
b
c
Not yet in program
and memory not yet
allocated
(abstract).
1. Algorithm
Function Block Definition FB1
2. Parameters
Standard
program unit
with variable
names a, b, c,
etc.
Program
Instance
Block instance in program with memory
allocated. (object)
Instance FB1_1 of function block definition FB1
Memory
used
Input
data
Output data
Output data
Automatic
allocation
Automatic
allocation
Memory
for FB1_1
Memory
for FB1_2
Different I/O data
can be processed
with the same
function.
Instance FB1_2 of function block definition FB1
Input
data
Output data
Output data
Insert in
program.
Insert in
program.
Table defining usage
and properties of
variables a, b, c, etc.
TIMER_FB
TIMER_FB
TIMER_FB
instance_A
instance_A
instance_B
Function Block Definition
TIMER_FB
Variable Definitions
Internal variable: WORK_NUM
Use same internal variables.
Use different internal variables.
Summary of Contents for SYSMAC CX-Programmer 9
Page 2: ......
Page 4: ...iv ...
Page 6: ...vi ...
Page 8: ......
Page 16: ...xvi ...
Page 20: ...xx ...
Page 26: ...xxvi Application Precautions 4 ...
Page 27: ...Part 1 Function Blocks ...
Page 28: ......
Page 154: ...128 Procedures Section 3 2 ...
Page 155: ...Part 2 Structured Text ST ...
Page 156: ......
Page 160: ...134 CX Programmer Specifications Section 4 2 ...
Page 206: ...180 Procedures Section 6 1 ...
Page 208: ...182 System defined external variables supported in function blocks Appendix A ...
Page 230: ...204 Revision History ...
Page 231: ......