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
Содержание SYSMAC CX-Programmer 9
Страница 2: ......
Страница 4: ...iv ...
Страница 6: ...vi ...
Страница 8: ......
Страница 16: ...xvi ...
Страница 20: ...xx ...
Страница 26: ...xxvi Application Precautions 4 ...
Страница 27: ...Part 1 Function Blocks ...
Страница 28: ......
Страница 154: ...128 Procedures Section 3 2 ...
Страница 155: ...Part 2 Structured Text ST ...
Страница 156: ......
Страница 160: ...134 CX Programmer Specifications Section 4 2 ...
Страница 206: ...180 Procedures Section 6 1 ...
Страница 208: ...182 System defined external variables supported in function blocks Appendix A ...
Страница 230: ...204 Revision History ...
Страница 231: ......