Adding an Algorithm to a Basic Function Block Type

You can add an algorithm to a basic FB type with the New item of the popup menu of the basic FB type's ECC (Execution Control Chart).

Deleting an Algorithm

You can delete an algorithm by:

  1. Deleting all references to the algorithm in EC actions, then
  2. Using the Delete item of the algorithm's dialog (see below).

Editing with the Algorithm Dialog

You can use this dialog both for adding a new algorithm to a basic FB type or for editing an existing algorithm. You invoke it by double-clicking the name of an existing algorithm in the Navigation area, or by selecting the New Algorithm item of the ECC popup menu. The dialog contains:

If you use the radio buttons to change languages, you will see different results depending on the original and new language selections:

You can save the changes to the algorithm by pressing the "OK" button, and if no errors are detected, the requested changes (if any) will be made and the dialog will close. If you changed the name of an existing algorithm, references to the algorithm in EC actions will be automatically updated to the new name.

If an error is detected when you press the "OK" button, the dialog does not close, the system "beeps" and an error message appears at the top line of the dialog in the same manner as for EC states.

You can close the dialog without making any changes to the algorithm by pressing the "Cancel" button or the in the upper right corner of the dialog.

Editing ST Algorithms

The figure above illustrates an algorithm written in the IEC 61131-3 Structured Text (ST) language. You do not need to enter the block delimiters ALGORITHM STOP IN ST...END_ALGORITHM.

Editing Java Algorithms

You can write algorithms in the Java programming language as shown below.

  • The delimiters of the Java method declaration are automatically generated and should not be included in the algorithm. These include the opening delimeter "public void alg_<ANAME>(){" where <ANAME> is the name of the algorithm, and the closing curly bracket "}".
  • Reference to the values of the variables contained in the function block instance is of the form X.value, where X is the name of the variable.
An algorithm may be written in Java without an ECC; in this case the name of the algorithm must be the same as the name of the associated input event, and appropriate output events must be generated as part of the algorithm as illustrated below. See the X2Y2_J and X2Y2_J2 function block types in the student subdirectory for further details of these examples.

Last updated: 2006-09-23.
©2006 Holobloc Inc. All rights reserved.