![background image](http://html1.mh-extra.com/html/omron/sysmac-cx-programmer-9/sysmac-cx-programmer-9_operation-manual_744241192.webp)
166
ST-language Program Example
Section 5-6
• ST-language Algorithm
If bCheck is true, function block 2 is called to calculate the average value.
The 3 values data1, data2, and data3 are passed to function block 2 input
variables input1, input2, and input3 respectively. The result of the calcula-
tion (
average
) is returned to AVG.
Note
The following diagram shows the Average_FB function block called
with specification method A (both function block’s variables listed).
IF bCheck = TRUE THEN
Average(input1:=data1,input2:=data2,input3:=data3,aver-
age=>AVG);
ELSE
RETURN;
END_IF;
Function Block 2
• Variable Table
• ST-language Algorithm
Calculates the average value of input1, input2, and input3 and stores the
result in
average
.
average:=(input3)/3;
5-6
ST-language Program Example
5-6-1
Using an ST Program in a Function Block
Converting an Integer
to BCD and
Outputting It as a Text
String
Input Variable
INT Input_Num;
Input-Output Variable
STRING Output_String;
Internal Variable
WORD Num_BCD;
(*Check Input_BCD input parameter (BCD data)*)
IF(Input_BCDNum>=0 & Input_BCD<=16#Num<=9999) THEN
Variable type
Variable name
Data type
Passage to/from FB1
Input variable
EN
BOOL
---
Input variable
input1
INT
Received from data1
Input variable
input2
INT
Received from data2
Input variable
input3
INT
Received from data3
Output variable
ENO
BOOL
---
Output variable
average
INT
Passed to AVG
FB
(BOOL)
EN
(BOOL)
ENO
(INT)
Input_Num
(STRING)
(STRING)
Output_String
−
Output_String
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: ......