30.8.2 Function Block Variables

In the Function Block screen editor, use function block (FB) exclusive variables and system variables to create programs.

There are 3 types of FB-specific variables: one type of variables can be used within FBs only, and other 2 types of variables function as operands for Function Block Instructions, passing and receiving FB data to/from logic programs. You create variables in the Function Block screen's variable list, and they can be used within the FB where they were created.

Local Variables

Local variables are variables used within FBs only. You cannot write to local variables directly from Logic Screens where FBs are inserted.

You can register up to 512 local variables per FB.

Input Variables/Output Variables

You can use input variables and output variables to pass and receive data between FBs and logic programs. When you insert a FB in the Logic Screen, input variables created in the FB display as S operands, and output variables display as D operands.

You can register up to 63 input variables and 63 output variables per FB.

For operands, specify addresses or variables that match the variable type of input variables or output variables. The values stored in the addresses or variables of S operands are passed to input variables, and used in FBs. Also, the values of output variables in FBs are stored in addresses or variables set for D operands.

Notes

When creating or using FBs, please consider the following behaviors for creating logic programs.

When the display unit is switched ON, FBs are not reset even when the conducting state is finished, and variables in FBs retain the last values. Please reset FBs as necessary.

When using an identical FB multiple times in the logic program as instructions, the amount that logic variables are used and the operation of local variables within the FB will depend on the setting for [System Settings]-[Logic Program]-[Share Local Variables in Function Blocks]. Because the behavior of local variables is different, the processing results of the logic program will also be different.

The following example describes the differences in behavior according to the settings:

Example:

Prepares a FB (FB_0000) adds 1 every time the instruction is executed. The FB passes a value to the output variable (Output) equal to the value of a local variable (Count) plus 1.

FB_0000 is used twice in the logic program, and the D1 Operand for each is D100 and D2000 respectively.