Function Block Diagram (FBD) Algorithms
In versions of the FBDK after 2006-09-01,
the functional programming paradigm has been adopted
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.
- IEC 61499 equivalents may be
substituted for the removed types, e.g., E_CTU for CTU
and FB_DIV_INT for DIV_INT.
Functions
- You can add named "instances" of IEC 61131-3 functions
to the FBD algorithm by using the New option of the worksheet
popup menu (they aren't really instantiated at runtime - see Execution). This opens a dialog similar to the New dialog for function blocks (FBs), with the
following differences:
- Only function templates identified by the file type "*.fnt"
and icon can be used.
- The initial directory is the FBDK's src/plc
directory, whose subdirectories contain these templates.
- 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 .
- You can edit the name, type 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 or by
using the Alt+Del keychord when the instance is selected.
- You can view the function template by double-clicking in its
body.
Connections
- You can add connections to an FBD using the Alt+Drag 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 delete a connection with the Alt+Del keychord
when the connection is selected.
- You can toggle between 3- and 5-segment representations of a
connection using 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 the src/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's src/test directory.
Last updated: 2011-01-20.
©2011 Holobloc
Inc. All rights reserved.