Using a User Function Block
Step | Action |
---|---|
1 |
In the Project window panel locate the Ladder program. If one is not present, then create one.
|
2 |
Open the Program file under the Ladder program.
|
3 |
Insert User Function Block into your Ladder Diagram program. Select a Ladder line panel such as L0.
|
4 |
Select the pane in the Ladder Diagram and press keyboard key F10 . Alternate Method: press the Function/FB toolbar option to highlight it. Select the pane in the Ladder Diagram program to add function block.
|
5 |
Select your PLC's name under Category, then select the User Function under Function List. In the example below, the PLC name is 'NewPLC'.
|
6 |
Add a descriptive Instance Name. This will be a variable instance of the User Function Block.
|
7 |
Press OK to create the variable or select one that has already been created.
|
8 |
Create your instance variable of the Function Block.
|
9 |
Add Input and Output variables to your function block.
|
10 |
After finishing the process of adding the function block, press Check Program to check your code for errors.
|
Step | Action |
---|---|
1 |
In the Project window panel locate the Structured Text program. If one is not present, create one.
|
2 |
Open the Program file under the Structured Text program.
|
3 |
In the Structured Text code, press keyboard key F10 to add the User Function Block to the program. Alternate Method: Press the Function/FB toolbar option.
|
4 |
Select your PLC's name under Category, then select the User Function Block under Function List. In the example below, the PLC name is 'NewPLC'.
|
5 |
Add a descriptive Instance Name. This will be a variable instance of the User Function Block.
|
6 |
Press OK to create the variable or select one that has already been created.
|
7 |
Create your instance variable of the Function Block.
|
8 |
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:
*This example has no outputs in the function call only the return value of the function. |
9 |
After finishing the process of adding the Function Block, press Check Program to check your code for errors.
|
LM121-2