The FBDK uses a functional programming paradigm for efficient runtime execution and easier formal validation of algorithms in the IEC 61131-3 FBD language:
- Algorithms in the FBD language are restricted to use only "pure" IEC 61131-3 functions, which have a single output and no internal state.
- A new file type "
*.fnt
" and icon are added for function templates, which are used for generation of code corresponding to IEC 61131-3 functions in FBD algorithms. - "Stateful" IEC 61131-3 function block types (
CTU
, etc.) and functions with multiple outputs (DIV_INT
, etc.) have been removed from the FBDK library. If it is desired to use the functionality of these FB types, IEC 61499 equivalents may be used in composite FBtypes.
Functions
- You can add named "instances" of IEC 61131-3 functions to the FBD algorithm by Drag and Drop from the Library Navigator, or by Copy and Paste of existing functions in the diagram. This will open an Instance Dialog in which you can name the element and add a comment to its declaration.
- You can select a function and see its declaration in the text pane by clicking on its instance name (the name that appears over the top of the block).
- You can change the position in the diagram of one of these elements by dragging on its instance name or by using the Rosette.
- You can edit the name and comment of the function by double-clicking on the instance name.
- You can perform other operations by using the pop-up menu that appears when you right-click on the instance name.
- You can delete a function using its pop-up menu.
- You can view the function template by double-clicking in its body.
Connections
- You can add connections to an FBD using the connect gesture.
- You can select a connection and see its declaration in the text pane by clicking on a vertical line segment or the middle segment of a 5-segment line.
- You can double-click on a connection's selection point (see above) to get a simple dialog for editing its comment.
- You can delete a connection from its pop-up menu.
Parameters
Parameters (constant inputs) of functions in FBD algorithms can be edited in the same manner as for function blocks, resources, etc. However, since these are active inputs to functions, the display of parameters cannot be turned off by the popup menu's Parameters item for FBD algorithms.Execution
- When the File Save As Java option
is selected for a function block type containing an FBD algorithm,
code is generated for evaluating the networks comprising the
algorithm following the rules for evaluation of networks given in
subclause 4.1.3 of IEC 61131-3. The networks are evaluated in the
following order:
- Networks producing values of internal variables, in the order in which the variables are declared in the FB interface;
- Networks producing values of output variables, in the order in which the variables are declared in the FB interface.
- For an example of this code generation, along with the use
of internal variables, see the
TEST_IV.fbt
example in thesrc/test
directory. - Feedback Loop Detection is incorporated in the code
generation algorithm. If a feedback path is detected as
described in subclause 4.1.3 of IEC 61131-3, an error message is
embedded in the generated code. This will cause the Java compilation
to fail at the line where the error message occurs. For an example
of this condition, try to generate the code for the
TEST_LOOP.fbt
example in the FBDK'ssrc/test
directory.