Omron CX-PROGRAMMER 5.0-FUNCTION BLOCK OPERATION Operation Manual page 170

Function blocks
Table of Contents

Advertisement

Structured Text (ST Language) Specifications
Note
(1) The condition can also be specified as a boolean variable (BOOL data type) only rather than an
equation.
(2) Even if the condition equation is true before the expression has been executed, the expression will
be executed.
Example
Processing is repeated from when variable n = 1 until 50 in increments of 1 and n is added to array variable
DATA[n]. If DATA[n] exceeds 100, however, processing will end.
FOR n:=1; TO 50 BY 1 DO
DATA[n]:=DATA[n]+n;
IF DATA[n]>100 THEN EXIT;
END_IF;
END_FOR;
RETURN Statement
Summary
This statement is used to execute the next instruction following the location that called the function block in the
program when the function block in the structured text must be forced to end before it has been completed.
Reserved Words
RETURN
Statement Syntax
RETURN;
Usage
Use the RETURN statement when a function block has been forced to end.
Examples of Structured Text Programming
Example 1: Conversion of BCD Data (#0000-#9999) to BIN Data
(*Check the input parameter "Input_BCD" (BCD data) *)
IF (Input_BCD>=0 & Input_BCD<=16#9999) THEN
ENO:=true;
ELSE
ENO:=false;
RETURN;
END_IF;
(*BCD data is divided by 16 four times to get each digit of the BIN data converted from the BCD data*)
DIV_1:=Input_BCD/16;
DIV_2:=DIV_1/16;
DIV_3:=DIV_2/16;
DIV_4:=DIV_3/16;
(*Calculate each digit of the BIN data converted from the BCD data*)
BIN_1:=Input_BCD-16*DIV_1;
BIN_2:=DIV_1-16*DIV_2;
BIN_3:=DIV_2-16*DIV_3;
BIN_4:=DIV_3-16*DIV_4;
(*Calculate the BIN data "Output_BIN" (output parameter) *)
Output_BIN:=BIN_1+BIN_2*10+BIN_3*10*10+BIN_4*10*10*10;
Input_BCD
(*a number of 16
1
(*a number of 16
digit*)
2
(*a number of 16
digit*)
3
(*a number of 16
digit*)
Output_BIN
0
digit*)
Appendix B
155

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the CX-PROGRAMMER 5.0-FUNCTION BLOCK OPERATION and is the answer not in the manual?

This manual is also suitable for:

Cx-programmer 5.0Sysmac ws02-cxpc1-e-v50Cs1-hCj1-hCj1m

Table of Contents

Save PDF