Calling a user-defined function block instance
Call an instance of a user-defined function block (UDFB) in your ladder diagram (LD), function block diagram (FBD), or structured text (ST) programs, or use UDFBs to call other instruction blocks or UDFBs.
When a UDFB is referenced by another UDFB and the main program calls the nested UDFB more than twice, the input variable values might display incorrectly in the container when monitoring the UDFB.
- This is the expected behavior when passing by reference, because function block inputs are pointers.
- Although the function block is not called during the execution cycle, the inputs continue to point the previous positions from the last execution of the function block instance.
- The function block outputs always correspond to the last instance execution.
The following examples show an instance of a UDFB called in ST, FBD, and LD programming languages. Each UDFB has two inputs and two outputs.
Program | Instance Variable |
---|---|
UDFB instance - FBD ![]() | The name appears at the top of the instruction block, followed by:
|
UDFB instance - LD ![]() | The instruction block name is at the top, followed by:
|
UDFB instance - ST ![]() | The instance variable name is used at the beginning of a call. The instruction block name does not appear in the call. |
Provide Feedback