Function Call

A  Function:

  • Calculates a result according to the current value of its inputs.
  • It has no internal data and is not linked to declared instances, unlike a function block.
  • It has only one output: the result of the function.
    • Examples of standard functions include AND, SHL, SIN, etc.

FBD Language and FFLD Language Function Call

  1. Insert the function in the diagram.
  2. Connect its inputs and output.

IL Language Function Call

  1. Load its first input parameter before the call.
  2. Use the function name as an instruction followed by the other input parameters, separated by comas.
    The result of the function is then the current result.

This example demonstrates a call to ODD and SEL functions:

(* this statement converts any odd integer into "0" *)
Op1: LD   iValue
     ODD
     SEL   iValue, 0
     ST    iResult

ST Language Function Call

  1. Enter its name followed by the input parameters written between parentheses and separated by commas.
  • The function call can be:
    • Inserted into any complex expression.
    • Used as an input parameter of another function.

This example demonstrates a call to ODD and SEL functions:

(* This statement converts any odd integer value into the nearest even integer: *)
iEvenVal := SEL ( ODD( iValue ), iValue, iValue+1 );

See Also

Differences between Functions and Function Blocks