Creating a User Function

Step Action
1 Create or Open your project.
2

In the Project window panel locate the User Function/Function Block section.

3 Right-click on the User Function/Function Block section. Select Add ItemèFunction…

4

Enter in information for your function in the window that pops up.

Give your function a descriptive name.

Choose the language of the function block’s code.

Choices:

  1. LD – Ladder Diagram

  2. ST – Structured Text

  3. IL(IEC) – Instruction List

Select or de-select the Use EN/ENO option.

Choose a Return data type.

Choose a value for Width (columns).

Add a Program Description to let other users know what the function does.

5

Select Password tab to add security options to your Function . Using the password function is optional.

Use New Password section to password protect your function. This step is optional.

Enable or disable Protect Program check box. This step is optional.

6

Open the Local Variables file for your function.

A blank variable window should open.

Note: A pre-created return variable will be added automatically when creating a function.

7

Add Local Variables to your function.

Choose Variable Kind for your local variable.

Variable Kind Definitions:

  • VAR: This is a local variable for the function block. Can not be accessed outside of it.

  • VAR_INPUT: This is a read only input variable to your function block.

  • VAR_OUTPUT: This is an output variable from your function block. It is read only to outside programs.

  • VAR_IN_OUT: This in an input variable that has read and write access from your function block.

Enter a name for your variable in the Variablecolumn.

Choose the data type of your variable in the Type column.

Available data types:

Used check box is checked if variable is used in the code.

Add a Comment to the variable to let other users know what the variable is used for.

8

Open Function Program to add code.

The chosen language editor will appear. This example is Ladder Diagram.

Note: The value type set to the return variable in the function code must match the type defined when creating a function. An error will be generated at Check Program if there is an issue.

9

After adding Function code, press Check Program to check your function for errors.

10

Fix any errors that appear or proceed to Using a User Function to start using your function.

 

 

 

 

 

 

 

LP306B