A function block groups an algorithm and a set of private data. It has inputs and outputs. A function block can be:

  • A standard function block (RS, TON...).
  • A block written in "C" language and embedded on the target.
  • A User Defined Function Block (UDFB) written in ST, FBD, LD or IL.

To use a function block, you have to declare an instance of the block as a variable, identified by a unique name. Each instance of a function block as its own set of private data and can be called separately. A call to a function block instance processes the block algorithm on the private data of the instance, using the specified input parameters.

ST Language

To call a function block in ST, you have to specify the name of the instance, followed by the input parameters written between parenthesis and separated by comas. To have access to an output parameter, use the name of the instance followed by a dot '.' and the name of the wished parameter. The following example demonstrates a call to an instance of TON function block (MyTimer is declared as an instance of TON):

example Example

MyTimer (bTrig, t#2s);
TimerOutput := MyTimer.Q;
ElapsedTime := MyTimer.ET;

FBD Language and LD Language

To call a function block in FBD or LD languages, you just need to insert the block in the diagram and to connect its inputs and outputs. The name of the instance must be specified upon the rectangle of the block.

Calling a function block

IEC 61131-3 Automation platform > Programming - Reference guide > Basic Operations > Calling a function block

Previous chapterNext chapter


Created with the Personal Edition of HelpNDoc: Generate EPub eBooks with ease