Build and Test a Function

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.
  1. Start the FBEditor.
  2. Create a new function template in the editor by:
    • Opening a file containing an existing function, for example the X2Y2_FN file in the src\student folder; or
    • Clicking the New =>Function menu item as shown at right.
  3. Edit the function's elements:
    • Edit the function's interface.
      • Make sure that the function only has a single output, named OUT.
    • Edit the function's properties.
      • Enter package fb.rt.<mypkg>; in the Compiler Info header field, where <mypkg> is the name of the src subdirectory you are working in, for example, plc.functions.
      • In the Compiler Info classdef field, enter a parenthesized expression in the IEC 61131-3 ST language, expressing the value of OUT 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 )).
  4. 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!
  5. You can't save this element as a Java® file - It's used as a template for code generation in FBD algorithms.
  6. 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 and X2Y2_FN_FBD in the FBDK's src/student folder for an example.
Last updated: 2012-03-17.
©2012 Holobloc Inc.
Licensed under the Academic Free License version 3.0.
Java is a registered trademark of Oracle Corporation and/or its affiliates.