User-defined function blocks
FactoryTalk Design Workbench
supports creating and managing user-defined function blocks (UDFB). UDFB supports a subset of object-oriented programming techniques, such as defining a class and instantiating the class multiple times.
TIP:
A user-defined input parameter cannot be used to enable or disable UDFBs; it only controls the instructions inside the UDFB.
To enable or disable a UDFB, turn on or turn off
EN/ENO
in the Properties
pane.When
EN/ENO
is turned off, the UDFB does not execute and the output parameters are not overwritten.Benefits of using UDFBs are as follows:
- Code reuseUse UDFBs to promote consistency between projects by reusing commonly used control algorithms.For algorithms that are used multiple times in the same or across multiple projects, add the code inside a UDFB to make it modular and easier to reuse.
- Using UDFBs instead of user-defined functions (UDF)
- UDFBs support complex calculations that have multiple outputs.
- When multiple instances are required, a UDFB might use less memory than a UDF because a UDFB in a project does not exist in a program until it is instantiated as a variable.
- UDFBs are useful when saving local variable values from execution to execution (saves state) is required.
- Easy-to-understand interfaceUDFBs provide an easy-to-understand interface by showing only the essential or required parameters of complicated algorithms.UDFBs support inserting comments anywhere, which reduces documentation development time. Comments are for documentation purposes only and are not acted upon by the program.
- Simple maintenanceUDFBs simplify code maintenance because UDFB logic is monitored inFactoryTalk Design Workbench, which displays the input and output values relative to the specific instance of the UDFB.
- Simple steps to reset the initial value of instancesUse theSet initial values of instancesdialog to reset the initial value of instances with one click.
Provide Feedback