![background image](http://html1.mh-extra.com/html/omron/sysmac-cx-programmer-9/sysmac-cx-programmer-9_operation-manual_744241191.webp)
165
Statement Descriptions
Section 5-5
Instance_FB(FB_IN1:=IN1,FB_IN2:=IN2,FB_IN3:=IN3,
FB_OUT1=>OUT1,FB_OUT3=>OUT3)
• Different order of entry:
Instance_FB(EN:=A,FB_IN1:=IN1,FB_OUT1=> OUT1,FB_IN2:=IN2,
FB_OUT2=>OUT2,FB_IN3:= IN3,FB_OUT3=> OUT3,ENO=>B)
■
Example of Entry Method 2
In this example, only parameter variables (including constants) of a new
instance are entered.
Instance_FB(IN1, IN2, IN3, OUT1, OUT2, OUT3)
Instance_FB(IN1, IN2, IN3, OUT1)
• The arguments and return values must be listed in a fixed order.
Input variable 1, Input variable 2, ..., Output variable 1, Output variable 2,
...
• The input variables’ arguments must be at the beginning of the list, or just
after the EN variable if the EN variable is listed.
• An output variable can be omitted if the data is not actually being used
and the output variable is not in the middle of the list of output variables.
Example: Instance_FB(IN1, IN2, IN3, OUT1, OUT3)
In this case, the OUT3 at the end of the list would return the value from
FB_OUT2.
• The EN and ENO data cannot be entered as an argument or return value.
• Specification method 1 cannot be used together with specification method
B in the same function block call statement.
■
Example 2
In the following example, function block 1 calls function block 2, which calcu-
late the average value by calling a function block from within a function block.
Function Block 1
• Variable Table
FB1
Instance_FB1
FB1 (ST)
FB2 (ST)
average := ( input3 ) / 3 ;
Program
Average_FB( input1 := data1, input2 := data2,
input3 := data3, average => AVG );
The data1, data2, and data3 values are
passed to input1, input2, and input3.
The average value is
returned in AVG.
Average_FB is an instance name with data type FUNCTION BLOCK.
Variable type
Variable name
Data type
Passage to/from FB2
Input variable
EN
BOOL
---
Input variable
data1
INT
Passed to input1
Input variable
data2
INT
Passed to input2
Input variable
data3
INT
Passed to input3
Input variable
bCheck
BOOL
---
Output variable
ENO
BOOL
---
Output variable
AVG
INT
Received from average
Internal variable
Average_FB
FUNCTION BLOCK
Called function block definition:
Function block 2
---
Summary of Contents for SYSMAC CX-Programmer 9
Page 2: ......
Page 4: ...iv ...
Page 6: ...vi ...
Page 8: ......
Page 16: ...xvi ...
Page 20: ...xx ...
Page 26: ...xxvi Application Precautions 4 ...
Page 27: ...Part 1 Function Blocks ...
Page 28: ......
Page 154: ...128 Procedures Section 3 2 ...
Page 155: ...Part 2 Structured Text ST ...
Page 156: ......
Page 160: ...134 CX Programmer Specifications Section 4 2 ...
Page 206: ...180 Procedures Section 6 1 ...
Page 208: ...182 System defined external variables supported in function blocks Appendix A ...
Page 230: ...204 Revision History ...
Page 231: ......