Skip to main content
Projects created in OTee adhere to the software model as described in the international IEC 61131-3 standard for programmable logic controllers (PLCs). Essential building blocks that together make a PLC project are program organization units, or POUs. The different types of POUs are functions, function blocks, and programs.

Functions

A function can be thought of as a subprogram (often an equation) that has no internal memory, so it returns a value rather than an output. This means that any time a function is invoked, if the same inputs are used, the same value will be returned, regardless of the number of times the function is used. Below is a simple example of a function defined in the Code Editor, together with the according variables and return type defined in the Tag Editor.
difference := minuend - subtrahend;

IF difference < 0 THEN
    ResultIsNegative := TRUE;
ELSE
    ResultIsNegative := FALSE;
END_IF;

CalcDifference := difference;
The name of the function POU (as it appears in your project browser on the left-hand side of the screen) must be the same as the return statement inside the code, in this example “CalcDifference”.
Function Tags Light When calling the function from your program, you can assign the return value directly to a variable, but you can also make use of other output values as defined in your function:
diff := CalcDifference(
    minuend := 5,
    subtrahend := 42,
    ResultIsNegative => myBoolVar
);

Function Blocks

Function blocks are segments of reusable code that have internal memory and can return different outputs even when the same inputs are used. In other words, the results of a function block are conditional on the previous output of the function block or the current state of the process. Below is a simple and shortened example of a function block defined in the Code Editor, together with the according variables defined in the Tag Editort.
IF interlocks > 0 THEN
  interlocked := TRUE;
END_IF;

IF commands.HMI_set_manual THEN
  status.mode_manual := TRUE;
  status.mode_program := FALSE;
END_IF;
Note that in this example, “status” and “commands” are a custom structure data types. The code snippet is only an illustration of function block syntax.
FB Tag Editor Light To call a function block from within another POU (e.g. in your main program), you’ll have to create a variable (in this example, FB_instance) and select your function block as a data type. Then, start typing “FB_instance” in the Code Editor and refer to the auto-complete suggestions to either call or refer to the instance of your function block: Call FB 1 Light Calling the function block will list all available inputs and outputs for you to link to other variables or enter values directly: Call FB 2 Light

Programs

Programs are the highest level POUs and can be written in Structured Text in the Editor. Each program is a network of functions and/or function blocks that controls a machine or process. Therefore, at least one program is required in any project. Shown here is a very simple and shortened section of a program controlling a compressor. Note that variables, function blocks and data types required to run this program are not shown here.
motor_compressor.HMI_api := api;
motor_compressor(); (* Calling a function block from within a program *)

DO_compressor := motor_compressor.outputs.forward;
Programs can then be organized to be run in sequences as defined in your projects resource configuration. Read more about that in the next chapter.