Program organization units

An application is a list of programs. Programs are executed sequentially within the target cycle, according to the following model:

    Begin cycle
    | exchange I/Os
    | execute first program
    | ...
    | execute last program
    | wait for cycle time to be elapsed
    End Cycle 

Programs are executed according to the order defined by the user. All SFC programs must be grouped (it is not possible to insert a program in FBD, LD, ST or IL in between two SFC programs). The number of programs in an application is limited to 32767. Each program is entered using a language chosen when the program is created. Possible languages are Sequential Function Chart (SFC), Function Block Diagram (FBD), Ladder Diagram (LD), Structured Text (ST) or Instruction List (IL).

Programs must have unique names. The name cannot be a reserved keyword of the programming languages and cannot have the same name as a standard or "C" function or function block. A program should not have the same name as a declared variable. The name of a program should begin by a letter or an underscore ("_") mark, followed by letters, digits or underscore marks. It is not allowed to put two consecutive underscores within a name. Naming is case insensitive. Two names with different cases are considered as the same.

Child SFC programs

You can define a hierarchy of SFC programs, entered as a tree in the list of programs. A child program is controlled within action blocks of the parent SFC program.

User Defined Function Blocks

The list of programs may be completed by "User Defined Function Blocks" (UDFBs). UDFBs are described using SFC, FBD, LD, ST or IL language, and can be used as other function blocks in the programs of the application. Input and output parameters plus private variables of a UDFB are declared in the variable editor as local variables of the UDFB.

There is no restriction using any operation in a UDFB. A UDFB can call standard functions and function blocks.

A UDFB can call another UDFB. The called UDFB must be declared before the calling one in the program list.

Each time a UDFB is instantiated, its private variables are duplicated for the declared instance. The code of the UDFB is duplicated on each call in parent programs. This leads to higher performances at run time, but consumes code space. It is advised recommended to package small algorithms in UDFBs. Large parts of code should be managed in programs.

A UDFB cannot have more than 32 input parameters or 32 output parameters.

Sub-programs

The list of programs may be completed by "Sub-programs". Sub-programs are described using FBD, LD, ST or IL language, and can be called by the programs of the application. Input and output parameters plus local variables of a sub-program are declared in the variable editor as local variables of the sub-program.

A sub-program may call another sub-program or a UDFB.

Unlike UDFB, local variables of a sub program are not instantiated. This means that the sub-program always work on the same set of local variables. Local variables of a sub-program keep their value among various calls. The code of a sub-program is not duplicated when called several times by parent programs.

A sub-program cannot have more than 32 input parameters or 32 output parameters.