Kaiyi — 2.8 Creating Function Blocks

Chapter 2 0BProgramming allowed to type the addresses by themselves. Users surely can use the addresses and the global symbols in the internal program. However, the use of the addresses or the uses of the global symbols will decrease the convenience of using the function block. (If a local symbol is the same as a global symbol, the local symbol used in the function block has high priority.) The local symbols created are as follows. VAR_INPUT When the program is executed, the value of the external variable is brought into the internal variable. If the value of the corresponding internal variable is altered, it is not transmitted to the external variable.

VAR_INPUT is often used if the value of the external variable should not be modified. Most of inputs in this example are digital inputs, and these inputs should not be modified. The modification of the values of these variables affects the execution of the program or the use of the function block. In order to prevent the values of these variables from being modified in the program, the declaration type should be VAR_INPUT. VAR_IN_OUT When the program is executed, the value of the external variable is brought into the internal variable. After the program comes to an end, the value is transmitted to the external variable.

VAR_IN_OUT is often used if the value of the variable should be modified. Generally speaking, Pump_Auto and Pump_Man_SW in this example are used in the SCADA system to set the control mode of the pump. It seems that VAR_INPUT meets the need. However, users need to switch the control mode of the pump from the automatic mode to the manual mode to stop the command from being outputted when the pump trips. Therefore, the declaration type for these two variables should be VAR_IN_OUT. VAR_OUTPUT When the program is executed, the value of the external variable is not brought into the internal variable, but the value memorized before is used instead.

After the program comes to an end, the value is transmitted to the external variable. Generally speaking, the variable appears at the output of the instruction. VAR When the program is executed, VAR is regarded as an internal variable, and the value memorized before is used. Generally speaking, the variable is used as a register when it is used in the program. If the same variable (function block type) is assigned to the function blocks which are called many times in the program, the initial value of VAR_OUTPUT and that of VAR are not necessarily the same as those used last time. Users can create the local symbols as follows.

2-21 Declaration type Identifier Data type VAR INPUT _ Tank B LSW _ _ BOOL VAR INPUT _ Tank R LSW _ _ BOOL VAR INPUT _ Tank R HSW _ _ BOOL VAR INPUT _ Pump Remote _ BOOL VAR INPUT _ Pump Run _ BOOL VAR INPUT _ Pump Trip _ BOOL VAR IN OUT _ _ Pump Auto _ BOOL VAR IN OUT _ _ Pump Man SW _ _ BOOL VAR OUTPUT _ Pump Start _ BOOL VAR Pump Out _ BOOL