Editing/Replacing/Updating FUs and FBs
This topic applies to code worksheets in FBD/LD, NOLD and SFC.
Editing functions/function blocks
Select a function/function block
To select a function/function block, click on the block header.
The in-place buttons shown above the selected object provide the commands that can be applied. Which commands are available depends on the selected object. Each in-place button provides a tooltip explaining the respective command.
Individual inputs and outputs of a block can be selected with a left-click.
Add/Delete function inputs
 | To add additional inputs to a function, left-click the function and click the 'Extend' in-place button below the function.To delete an added function input, left-click the input and click the 'Delete' command button or press the <Del> key. Only inputs added by the user can be deleted. Already connected lines are automatically removed too. |
Negate inputs of functions/function blocks
 | To negate an output or input of a function/function block, left-click the input or output to be negated and click the 'Negate' in-place button. A bold circle on the function input/output indicates the negation.To remove a negation, perform the same steps again.
Note
The negation of formal parameters is not supported in safety-related code (SNOLD). |
|
Change the instance name of a function block
 | To change the instance name of a function block, select the function block and click the 'Edit' in-place button. Alternatively, double-click the function block or press <F2>. In the appearing input field enter the desired name and press <Enter> to confirm it.If the function block instance is not already declared in the related variables table, right-click the function block and select 'Create New Function Block Instance' from the context menu or press <Ctrl>+<Shift>+<B>. |
Note
If the instance name of a function block will be changed, the corresponding instance variable in the associated variables table will be renamed too if there exists exactly one variable with the old name and no variable with the new name. |
Further Info
You can use the refactoring function provided with PLCnext Engineer to rename an instance name of a function block or to modify the type of a function block project-wide. For details, see the topic "Refactoring Variables and FB Types". |
Open the editor group of a function/function block
To open the editor group of a function/function block POU from the graphic editor, double-click the function/function block in the worksheet. Alternatively, right-click the function/function block and select 'Go to Implementation' from the context menu.
Display help for a function/function block
 | To display the online help for a particular function/function block, left-click the object and click the 'Show help' in-place button. Alternatively, select the object and press <F1>. |
Replacing/updating functions/function blocks
Replacing an existing function/function block (herein referred to as "block") in the graphical code worksheet can be done by dragging a block from the COMPONENTS area into the code worksheet and dropping it on the block to be replaced or via context menu of the existing block.
When replacing a block, observe the following:
- A function can only be replaced by another function and a function block by another function block.
- The block symbol and the formal parameters
(inputs and outputs of the function/function block) are re-arranged in the code worksheet if the new object contains other formal parameters than the block to be replaced (see example below).
- If the data type or name of a formal parameter
(input or output) of the replacing block differs, an already existing connection line to this FP is deleted. The FP has to be connected newly.
When keeping connection lines, they are automatically re-routed by the editor. Auto-connectors are used if no clear arrangement of the connection line is possible.
Example for the replacement of a function block
In the following example, the CTUD function block is replaced by the CTU function block. Any connection line to formal parameters of the replacing CTU function block with different names are deleted.
Replace a function/function block via drag & drop
- In the COMPONENTS area, open the respective 'Functions and Function Blocks' folder and select the desired subfolder.
- Drag the function/function block into the code worksheet from the COMPONENTS area and drop it on an existing function/function block.
- If you have inserted a function block, the FB instance name has to be declared in the related variables table.
- To accept and apply the instance name proposed by the programming system (shown at the top of the function block; in the following figure 'CTD_1'), right-click the function block and select 'Create New Function Block Instance' from the context menu or press <Ctrl>+<Shift>+<B>.
- To assign an already declared instance name or define a new name, double-click the function block in the code worksheet and enter the instance name in the appearing input field. Alternatively, click the 'Edit Instance Name' in-place button or press <F2> and enter the instance name.
Replace a function/function block via context menu
- In the code worksheet, right-click the function/function block to be replaced and select 'Replace Function / Function Block' from the context menu.
- In the appearing selection box, either type the name of the function/function block to be inserted or open the selection box and browse the drop-down list for the desired object. Press <Enter> to confirm your selection.
Update user-defined functions/function blocks
The 'Update Function / Function Block' command available in the context menu of a user-defined block is used to update the object if its configuration has changed.
If you have, for example, inserted a user-defined function block into a code worksheet and you
have added or deleted formal parameters of this function block, the block (i.e., its instance) must be updated in the code worksheet where the function block is called. If the width or height of the function/function block is affected by the modifications, this is considered accordingly when replacing the Fu/FB in the code worksheet.
To update a user-defined block, open the code worksheet where it is called, right-click the function/function block instance and select 'Update Function / Function Block' from the context menu. Alternatively, left-click the element in the code worksheet and click the 'Update Function / Function Block' in-place button of the element (the in-place button is only available if the function/function block has changed).