To create a new Function Block (FB), do the following:
From the [Screen] menu, select [New Screen] to create a Function Block.
In the editing screen for the Function Block, insert instructions and register variables.
Setup Procedure
The following explains how to create an FB which outputs flicker signals.
The FB outputs a flicker signal which toggles between ON and OFF with specified durations, when a specific bit (S1 operand) is ON.
Input
S1: Bit Flicker start bit
S2: Integer Specifies flicker signal's OFF duration in seconds
S3: Integer Specifies flicker signal's ON duration in seconds
Output
D1: Bit Output
From the [Screen] menu, select [New Screen] or click to open the New Screen dialog box.
In the [New Screen] dialog box, select [Function Block] from [Screens of Type].
Enter the name of the Function Block in [Name] and click [New]. (Example: FB_0000)
The Function Block is registered in the Screen List window, and the editing screen opens.
In the Function Block screen's variable list, select the [Input Variable] tab and register one bit variable and two integer variables. They will be used as input operands (S1 to S3) for the FB. (For example: enter "Start" for name and select "Bit Variable" for type.)
In the Input Variable and Output Variable tabs, you can change the order of operands by pressing [Move up] and [Move down] buttons. For example, select the second row, OffTime, and click on the [Move down] button. OnTime becomes the S2 operand and OffTime becomes the S3 operand.
To change the variable type for a registered variable, select the variable, right-click it, and select the desired variable type from the pop-up menu.
In the Function Block screen's variable list, select the [Output Variable] tab and register one bit variable. This will be used as output operand (D1) for the FB. (For example: enter "Output" in the name, and select "Bit Variable" in the type.)
In the Function Block screen's variable list, select the [Local Variable] tab and register two bit variables and two timer variables. They are used within the FB only. (For example: enter "Bit1" in the name, and select "Bit Variable" in the type.)
In the FB's editing screen, insert rows and create a program as shown below.
The FB_0000 is now completed.
Open the Logic Screen, select [Function Block Instruction] from [Insert Instructions], and insert FB_0000.
You can also insert the FB by selecting FB_0000 in the [Screen List] window and dragging and dropping it to the Logic Screen.
Depending on the settings for [System Settings]-[Logic Program]-[Share Local Variables in Function Blocks], the operation of the function block instruction varies.
30.8.2 Function Block Variables
Set addresses and/or variables for the inserted FB.
Variables for FB instructions' operands should have the same variable types as the input/output variables with which the values are passed.
Double click the FB inserted in the Logic Screen to open the [Operand Settings] dialog box, where you can set addresses/variables while displaying the list of operands.