Functions

IEC has defined standard functions and also allows you to create your own functions (called user-defined functions). Typically, functions take several inputs and return a single output as the result of processing.

  • Standard functions are for example ADD (addition), ABS (absolute), SIN (sine), COS (cosine), GT (Greater Than),….
  • User-defined functions, as in the following example, can be used repeatedly once defined.
FUNCTION SIMPLE_FUN : REAL
	VAR_INPUT
		A, B : REAL;
		C : REAL := 1.0;
	END_VAR
	SIMPLE_FUN := A*B/C;
END FUNCTION