Function Blocks

Define function blocks in the
Function Blocks
section of the device in the
Application View
.
For function blocks, specify these properties:
Property
Description
Comment
Plain text
Description
Rich text
In-line
For Ladder Diagram (LD) function blocks, duplicates the code of a function block for each instance used in the application, providing a faster execution time. In-line LD function blocks increase the size of the application TIC code.
To use an in-line LD function block in another LD function block, known as nested blocks, set the
In-line
property for both blocks to
True
.
  • Set the
    In-line
    property to
    False
    for LD function blocks that generate an undeclared identifier error.
  • Set the
    Generate debug information
    property to
    False
    if a build error occurs when the In-line property is
    True
    for LD function blocks.
Language
(Read-only) Programming language of the program organization unit (POU)
Name
Name of the function block. Function block names are limited to eight (8) characters beginning with a letter or single underscore followed by letters, digits, and single underscores. Names cannot be reserved words, defined words, or data types. Use unique names for POUs within a project.
Type
(Read-only) Type of POU. Possible values are program, user-defined function, or user-defined function block.
Perform these tasks for function blocks:
Task
Procedure
Add function blocks
  1. In the
    Application View
    , right-click the
    Function Blocks
    element, point to
    Add Function Blocks
    , and then click the required programming language for the function block.
  2. To define the parameters for the function block, right-click the function block, and then click
    Parameters
    .
Set properties of function blocks
In the
Application View
, right-click the function block, and then click
Properties
.
Copy and paste function blocks
Copying and pasting a function block includes local variables and local defined words.
  1. In the
    Application View
    , right-click the function block, and then click
    Copy
    .
  2. Right-click the
    Function Blocks
    element, and then click
    Paste
    .
    TIP: POU comments are not copied during a copy and paste operation.
Rename function blocks
In the
Application View
, right-click the function block, then click
Rename
, and then type a name for the function block.
Delete function blocks
In the
Application View
, right-click the function block, and then click
Delete
TIP: When deleting a function block, save the project before making subsequent changes.
.
TIP: When adding function blocks, define parameters. Function blocks can have a maximum of 32 parameters (inputs and outputs). When defining parameters, consider these limitations:
  • Parameter names are limited to 32 characters and must begin with a letter or single underscore followed by letters, digits, and single underscores. Do not use reserved words, defined words, or data types for names. Use unique names for the parameters of a function block.
  • Possible data types for parameters are BOOL, DINT, REAL, TIME, MESSAGE
  • For Message type variables, string capacity is limited to 255 characters
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal