Programs

With the above-mentioned basic building blocks, a program can be seen as a network of functions and function blocks. Each of them being written in any of the defined programming languages.


  • Programs and Subprograms can be reordered by drag-and-drop.
    Dragging an item up the list places it above the program you drop it on, while dragging down places it below.

Sub-programs

The list of programs is completed with "Sub-programs". Sub-programs are written in FBD, FFLD, ST or IL languages, 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 function type sub-program can call another function type subprogram.
  • A UDFB type sub-program can call another UDFB type subprogram or a function type subprogram

Unlike UDFB, local variables of a sub-program are not instantiated. This means that the sub-program always works 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.

A good programming practice is to break up your programs into smaller modules.

See also Application Software Structure - Definitions.

Program Guidelines

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, FFLD, ST or IL between two SFC programs). Each program is entered using a language chosen when the program is created. Possible languages are Sequential Function Chart (SFC), Function Block Diagram (FBD), Free Form Ladder Diagram (FFLD), Structured Text (ST) or Instruction List (IL). The maximum number of programs in an application is 32767.

Program Name

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 must not have the same name as a declared variable. The name of a program must 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.


  • Even if you do not want to split your FFLD program, at least separate FFLD from SFC. Simply make a sub-program in FFLD called from the SFC step, and keep only the state machine in the SFC program. This makes everything simpler and more comfortable for editing and debugging.

Program Limitations

When creating your application you have to consider the following important limitations.

For SFC programs:

  • Actions in SFC steps cannot be more than 32kB
  • Condition in SFC transition cannot exceed 32kB
  • Total PLC code size of the program cannot exceed 64kB

For FFLD programs:

  • Width of any network is limited to 255 columns
  • Height of any network is limited to 255 rows

For any program, sub-program or UDFB written in other languages:

  • Jump limit is 64kB
    For example, in a Free Form Ladder program, if you create a UDFB or program which is over 64kB and then decide to add a jump to label in the first network to the last network, this jump reaches the limit.
  • Total PLC code size of the program, sub-program or UDFB cannot exceed 64kB