Functions

Functions (FUN) are Program Organization Units (POUs) that upon execution deliver a data element as a result and any number of output values of the classes VAR_OUTPUT and VAR_IN_OUT. By specifying the result type VOID the function has no result.

They can also access global variables via VAR_EXTERNAL, VAR_EXTERNAL_RETAIN or VAR_EXTERNAL_CONSTANT.

Functions do not contain any internal status information, i.e. calling a function with the same input values for the classes VAR_INPUT, VAR_IN_OUT and VAR_EXTERNAL will always yield the same result and the same output values for the classes VAR_OUTPUT, VAR_IN_OUT and VAR_EXTERNAL.

Control FPWIN Pro7 provides two types of functions:

  1. System instructions of the system libraries

    • IEC standard library

    • FP library

    • FP tool library

    • FP pulsed library

  2. User-defined functions

    You can also program your own functions and store them in a user library. The new functions will then be available in all projects in which the user library is installed.

    Functions can be written in the following programming languages:

    • Ladder diagram (LD) or Function block diagram (FBD)

    • Structured text (ST)

    • Instruction list (IL)

NOTE
  • Functions cannot be assigned to a task as they can only be loaded by a program, function or function block.

  • A function cannot be called recursively.

  • The maximum of 5 nested function calls, e.g. Fun1 (Fun2 (Fun3 (Fun4 (Fun5 (x))))), may not be exceeded.

  • Except for ST or IL functions without formal parameters, function results and function outputs can be left unconnected.

  • When calling a function with formal parameters in the ST editor, the following conditions apply:

    • For arguments with formal parameters, the order of parameters does not matter.
    • With user functions, the EN input and output can be omitted. Omitted EN will be interpreted as TRUE.
Related topics:

Modified on: 2019-12-10Feedback on this pagePanasonic hotline