You can build custom functions for use in the functional programming of FBD algorithms in Basic function block types. Such functions do not themselves produce compilable code; rather, they serve as templates for the production of compilable code when they are used in FBD algorithms.
- Start the FBDK.
- Import library elements if and as needed.
- Create a new function type in the editor by double-clicking
on the Function element of
the
template
folder in the Library Navigator. - Edit the function's elements:
- Edit the function type's name and comment by double-clicking on the root node of the Element Navigator.
- Edit the function type's properties by double-clicking on
the corresponding entry in the Element
Navigator:
- Identification
- Versions
- CompilerInfo
- Be sure to enter
package fb.rt.<mypkg>;
in the header field, where<mypkg>
is the name of thesrc
subdirectory you are working in, for example,student
orbook
.
- Be sure to enter
- Compilers
- Edit the function type's
interface.
- Make sure that the function only has a single output,
named
OUT
.
- Make sure that the function only has a single output,
named
- Enter the functional expression to be evaluated.
- In the Compiler Info
classdef
field, enter a parenthesized expression in the IEC 61131-3 ST language, expressing the value ofOUT
in terms of the function's input variables. Each usage of an input variable name should be set off with a blank space, for instance
( IN1 + IN2 )
or(( X + Y )*( X - Y ))
.
- In the Compiler Info
- When your editing is complete, save your work with the Save As...=>XML
dialog.
It is a good idea to save your work from time to time while editing, too! - You can't save this element as a Java® file - It's used as a template for code generation in FBD algorithms.
- Since this element doesn't generate code, it can't be tested
by itself, but only as part of an FBD
algorithm of a Basic FB Type. See
X2Y2_FN
andX2Y2_FN_FBD
in the FBDK'ssrc/student
folder for an example.