Using a User Function Block
This topic assumes you have done Creating a User Function Block or already have a program with a User Function Block. 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 Block. |
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 Block 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 block.
Find the User Function Block in the <‘PLC Name’> section.
Add a descriptive Instance Name. This will be a variable instance of the User Function Block.
Press OK to create the variable or Select one that has already been created.
Create your instance variable of the Function Block.
|
5 |
Add Input and Output variables to your function block.
|
6 |
After finishing the process of adding the Function Block, press Check Program to check your code for errors.
|
Step | Action |
---|---|
1 | Create or Open your project that contains a User Function Block. |
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 Block to the program,. or press the Function/FB toolbar option.
Find the User Function Block in the <‘PLC Name’> section.
Add a descriptive Instance Name. This will be a variable instance of the User Function Block.
Press OK to create the variable or select one that has already been created.
Create your instance variable of the Function Block.
|
5 |
Function Block instance is added to your code. Replace commented sections with variables of the type in the comment. Example of newly inserted Function Block instance. It contains comments to be replaced with values or variables of that type.
Example of finished Function Block instance. It contains the variables of the correct type in the Function Block 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 Block, press Check Program to check your code for errors.
|
LP306C