Function Call

A  FunctionClosed A function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances.:

  • 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

To call a function in FBDClosed "Function Block Diagram" A function block diagram describes a function between input variables and output variables. A function is described as a set of elementary blocks or FFLDClosed "Free Form Ladder Diagram" languages:

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

IL Language

To call a function in the ILClosed "Instruction List" This is a low-level language and resembles assembly language:

  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: LDClosed "Ladder diagram" Ladder logic is a method of drawing electrical logic schematics. It is now a very popular graphical language for programming Programmable Logic Controllers (PLCs). It was originally invented to describe logic made from relays. The name is based on the observation that programs in this language resemble ladders, with two vertical "rails" and a series of horizontal "rungs" between them   iValue
     ODD
     SEL   iValue, 0
     ST    iResult

ST Language

To call a function in STClosed "Structured text" A high-level language that is block structured and syntactically resembles Pascal:

  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