30.8.1.1 Creating a New Function Block

To create a new Function Block (FB), do the following:

  1. From the [Screen] menu, select [New Screen] to create a Function Block.

  2. 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.

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

D1: Bit Output

  1. From the [Screen] menu, select [New Screen] or click to open the New Screen dialog box.

  2. In the [New Screen] dialog box, select [Function Block] from [Screens of Type].

  3. Enter the name of the Function Block in [Name] and click [New]. (Example: FB_0000)

  4. The Function Block is registered in the Screen List window, and the editing screen opens.

  5. 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.

  6. 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.)

  7. 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.)

  8. In the FB's editing screen, insert rows and create a program as shown below.

  9. The FB_0000 is now completed.

  10. Open the Logic Screen, select [Function Block Instruction] from [Insert Instructions], and insert the FB.

    • You can also insert the FB by selecting FB_0000 in the [Screen List] window and dragging and dropping it to the Logic Screen.

  11. 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.