Function Blocks

Define function blocks in the Function Blocks section of the . Program functions using Function Block Diagram (FBD), Ladder Diagram (LD), Sequential Function Chart (SFC), or Structured Text (ST).
Specify these properties for function blocks:
Function Block Properties
Property
Description
Code Generation
Generate Debug Info
Generate information required for debugging using step-by-step execution.
Generate Monitoring Symbol
For graphical program organization units (POUs), generate information required for graphically displaying the output values of elements when debugging or simulating
Instance Symbols Extra Bytes
Size of memory reserved for each function block instance for adding symbols monitoring information during updates. A string-type output takes up 260 bytes.
Info
Comment
Plain text
Description
Rich text
Full Name
(Read-only) Full name of the function indicating the project and controller to which it belongs
Language
(Read-only) Programming language of the POU
Name
(Read-only) Name of the function block. Function block names are limited to 128 characters beginning with a letter followed by letters, digits, and single underscores. The last character for a function block name must be a letter or digit; function block names cannot end with an underscore character. Reserved words, defined words, or data types, such as elementary, structures, or arrays are not valid names. The same type of elements within a scope must have unique names.
Order
Position of the function block within the execution order
Password Protected
(Read-only) Function is protected by a password controlling its access
Path
(Read-only) Complete path where the function block files are stored on the computer
When adding function blocks, define required parameters. Function blocks can have a maximum of 128 parameters (inputs and outputs). When defining parameters, consider these limitations:
  • Parameter names are limited to 128 characters beginning with a letter followed by letters, digits, and single underscores. The last character for a parameter name must be a letter or digit; parameter names cannot end with an underscore character. Reserved words, defined words, or data types, such as elementary, structures, or arrays are not valid names. The same type of elements within a scope must have unique names.
  • Possible data types for parameters are BOOL, SINT, USINT, BYTE, INT, UINT, WORD, DINT, UDINT, DWORD, LINT, ULINT, LWORD, REAL, LREAL, TIME, DATE, STRING, Array types, Structure types, Function blocks
  • For String type variables, string capacity is limited to 255 characters excluding the terminating null character (0), a byte for the current length of the string, and a byte for the maximum length of the string
  • For user defined addresses, the format is hexadecimal and the value ranges from 1 to FFFF
  • For dimensions, example: [1..10] for a one dimensional array, [1..4,1..7] for a two dimensional array
For instances of function blocks, reset the initial values defined for individual instances.
Perform these tasks for function blocks:
Function Block Tasks
Task
Procedure
Add a function block
  1. In the , right-click the
    Function Blocks
    element, point to
    Add Function Blocks
    , and then select the programming language for the function block.
  2. To define the parameters for the function block, right-click the function block, and then select
    Parameters
    .
Export a function block
Export function blocks as exchange files (*.pxf). Also export functions from libraries.
  1. In the , right-click the function block, and then select
    Export...
    .
  2. In the dialog box, browse for the location in which to store the function block exchange file, and then select
    Save
    .
    TIP: If a user-defined structure contains user-defined structures, create at least one variable for each user-defined structure to support a successful POU export.
Add a function block from an exchange file
Import function blocks previously saved as exchange files (.pxf). For program organization units (POUs) in version control, check out the POU before importing the exchange file (.pxf).
Avoid renaming POUs in the dialog box when importing. Renaming may cause a loss of function block references or broken binding links for local variables. Rename the POU from the .
  1. In the , right-click the
    Function Blocks
    element, point to
    Add Function Blocks
    , and then select
    Existing Function Block...
    .
  2. In the
    Select Exchange File
    dialog box, locate the exchange file containing the function, and then select
    Open
    .
  3. In the dialog box, select the element to import, and then select
    Import
    .
Reset the initial values of function block instances
  1. In the , right-click the function block, then point to
    Refactor
    , and then select
    Reset Initial Values
    of Instances.
  2. From the dialog box, select the function block instances to reset, and then select
    OK
    .
Copy and paste a function block
  1. In the , right-click the function block, and then select
    Copy
    .
  2. Right-click the
    Function Block
    element, and then select
    Paste
    .
Rename a function block
In the , right-click the function block, then select
Rename
, and then type a name for the function block.
Delete a function block
In the , right-click the function block, and then select
Delete
.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal