User-Defined Function Blocks (POU)

The list of programs is completed with User-Defined Function Blocks (UDFBs).

  • UDFBs are described using FBD, FFLD, IL Language SFC, ST Language.
    • They can be used as other function blocks in the programs of the application.
    • Input and output parameters plus private variables of a UDFB are declared in the variable editor as local variables of the UDFB.
  • There is no restriction when using any operation in a UDFB.
    • A UDFB can call standard functions and function blocks.
  • A UDFB can call another UDFB.
    • The called UDFB must be declared before the calling one in the program list.
  • A UDFB can have one or more methods.
    • Methods are used to organize and encapsulate functionality within a UDFB by breaking complex logic into smaller, reusable operations.
    • Similar to methods in object-oriented programming, a method is a reusable block of logic that belongs to a specific UDFB and can access the UDFB’s internal data and variables.
    • See Methods (POU).

Each time a UDFB is instantiated, its private variables are duplicated for the declared instance.

  • The code of the UDFB is duplicated on each call in parent programs.
  • This leads to higher performances at run-time, but consumes code space.
  • It is recommended to package small algorithms in UDFBs.
    • Large parts of code must be managed in programs.

    • A UDFB can have a maximum of 255 input parameters and 255 output parameters.
    • Compiler issue an error message when this limit is exceeded.