Chapter 2. Program Organization
GFK-2950C
February 2018
11
User-Defined Function Blocks (UDFBs)
Users can define their own blocks, which have parameters and instance data, instead of being
limited to the standard and built-in function blocks provided in the PACSystems instruction set. In
many cases, the use of this feature results in a reduction in total program size.
Once defined, multiple instances of a UDFB can be created by calling it within the
program logic. Each instance has its own unique copy of the function block’s
instance data
, which consists of the function block’s internal member variables and all of its
input
and output parameters except those that are passed by reference. When a UDFB is called on a given
instance, the UDFB’s logic operates on that instance’s copy of the instance data. The values of the
instance data persist from one execution of the UDFB to the next.
Note: A member variable is not passed into or out of a UDFB as a parameter. A member variable is
used only within the logic of that function block.
A UDFB cannot be triggered by an interrupt.
UDFB logic is created using FBD, LD or ST. UDFB logic can make calls to all the other types of
PACSystems blocks (blocks, parameterized blocks, external blocks and other UDFBs). Blocks,
parameterized blocks, and other UDFBs can make calls to UDFBs.
Unless otherwise stated, the PACSystems implementation of UDFBs meets the IEC 61131-3
requirements for user defined function blocks.
Defining a UDFB
To create a UDFB in the programming software, create an LD, FBD or ST block in the Program Blocks
folder. In the Properties for the block, select Function Block.
To define instance data for a UDFB, select Parameters in the block’s properties. Input and output
parameters are defined in the same way as for parameterized blocks. In the following example, three
internal member variables are defined:
temp,
speed,
and
modelno.
Figure 3: Defining Member Variables for a User-Defined Function Block
Summary of Contents for PACSystems RSTi-EP
Page 357: ......
Page 466: ...Chapter 9 Diagnostics GFK 2950C February 2018 451 ...