Chapter 2. Program OrganizationGFK-2950C February 2018 11User-Defined Function Blocks (UDFBs)Users can define their own blocks, which have parameters and instance data, instead of beinglimited to the standard and built-in function blocks provided in the PACSystems instruction set. Inmany 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 theprogram logic. Each instance has its own unique copy of the function block’sinstance data, which consists of the function block’s internal member variables and all of its inputand output parameters except those that are passed by reference. When a UDFB is called on a giveninstance, the UDFB’s logic operates on that instance’s copy of the instance data. The values of theinstance 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 isused 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 ofPACSystems 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-3requirements for user defined function blocks.Defining a UDFBTo create a UDFB in the programming software, create an LD, FBD or ST block in the Program Blocksfolder. 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 outputparameters are defined in the same way as for parameterized blocks. In the following example, threeinternal member variables are defined: temp, speed, and modelno.Figure 3: Defining Member Variables for a User-Defined Function Block