Functions
Define functions in the Functions section of a controller in the
Application
View
. Program functions with Function Block Diagram (FBD), Ladder Diagram
(LD), or Structured Text (ST).For functions, specify these properties:
Properties | Description |
---|---|
Code Generation | |
Generate Debug Info | Generate information required for debugging with step-by-step
execution. |
Info | |
Comment | Plain text |
Description | Rich text |
Full Name | (Read-only) Full name of the function with the project and controller
to which it belongs |
Language | (Read-only) Programming language of the program organization unit
(POU) |
Name | (Read-only) Name of the function. Function names are limited to 128
characters beginning with a letter followed by letters, digits, and
single underscores. The last character for a function name must be a
letter or digit; function 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 | Execution order of the POU |
Password Protected | (Read-only) Password controls access to the function |
Path | (Read-only) Complete path to the function files on the
computer |
When adding functions, define required parameters. Functions can have a maximum of 128
parameters (inputs and outputs). When defining parameters, consider the following
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. Use unique names for the same type of elements within a scope.
- 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
Perform these tasks for functions:
Task | Procedure |
---|---|
Add a function |
|
Export a function | Export functions as exchange files (*.pxf). Also export functions
from libraries.
|
Add a function from an exchange file | Import functions previously saved as exchange files (*.pxf).
TIP:
For POUs in version control,
check out the POU before importing the exchange file (*.pxf).
|
Set properties for a function | In the Application View , right-click the
function, and then select Properties . |
Copy and paste a function |
|
Rename a function | In the Application View , right-click the
function, then select Rename , and then type a
name for the function. |
Delete a function | In the Application View , right-click the
function, and then select Delete . |
Provide Feedback