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.
UDFB examples
Program
Instance Variable
UDFB instance - FBD
UDFB instance - FBD
The name appears at the top of the instruction block, followed by:
  • The instance variable name
  • Inputs
  • Outputs
UDFB instance - LD
UDFB instance - LD
The instruction block name is at the top, followed by:
  • The instance variable name
  • Inputs
  • Outputs
UDFB instance - ST
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
Have questions or feedback about this documentation? Please submit your feedback here.
Normal