Using a User Function
This topic assumes you have done Creating a User Function or already have a program with a User Function . You should also be familiar with Structured Text - Programming or Ladder - Summary and Fundamentals.
Step | Action |
---|---|
1 | Create or Open your project that contains a User Function. |
2 |
In the Project window panel locate the Ladder Scan Program. If one is not present, then create one as shown in Ladder - Summary and Fundamentals.
|
3 |
Open the Program file under the Ladder Scan Program.
|
4 |
Insert User Function into your Ladder Diagram Program. Select a Ladder Line Panel such as L0.
Select the pane in the Ladder Diagram and press keyboard key F10, or press the Function/FB toolbar option to highlight it. Select the pane in the Ladder Diagram Program to add function.
Find the User Function in the <‘PLC Name’> section.
Add a descriptive Instance Name. This will be a variable instance of the User Function.
Press OK to create the variable or Select one that has already been created.
Create your instance variable of the Function.
|
5 |
Add Input and Output variables to your function.
|
6 |
After finishing the process of adding the Function, press Check Program to check your code for errors.
|
Step | Action |
---|---|
1 | Create or Open your project that contains a User Function. |
2 |
In the Project window panel locate the Structured Text Scan Program. If one is not present, then create one as shown in Structured Text - Programming.
|
3 |
Open the Program file under the Structured Text Scan Program.
|
4 |
In the Structured Text Code, press keyboard key F10 to add the User Function to the program,. or press the Function/FB toolbar option.
Find the User Function in the <‘PLC Name’> section.
Add a descriptive Instance Name. This will be a variable instance of the User Function.
Press OK to create the variable or select one that has already been created.
Create your instance variable of the Function.
|
5 |
Function instance is added to your code. Replace commented sections with variables of the type in the comment. Example of newly inserted Function instance. It contains comments to be replaced with values or variables of that type.
Example of finished Function instance. It contains the variables of the correct type in the Function call. Make sure to add the “;” at the end. The newly inserted code is missing it.
Note:
|
6 |
After finishing the process of adding the Function, press Check Program to check your code for errors.
|
LP306D