Structured Text - Statements

The XEM CPU modules support the following statements that are defined in the standard.

Number Statement Type/Reference Examples
1 Assignment A:=B; CV:=CV+1; C:=SIN(X);
2 Function block Invocation and FB output usage CMD_TMR(IN:=%IX0.0.5, PT:=T#300ms, RST:= %IX0.0.6); A := CMD_TMR.Q;
3 RETURN RETURN;
4 IF D := B * B - 4 * A * C;
IF D < 0.0 THEN
NROOTS := 0;
ELSIF D = 0.0 THEN
NROOTS := 1;
X1 := - B / (2.0 * A);
ELSE NROOTS := 2;
X1 := (- B + SQRT(D)) / (2.0 * A);
X2 := (- B - SQRT(D)) / (2.0 * A);
END_IF;
5 CASE TW := WORD_TO_INT(THUMBWHEEL);
TW_ERROR := 0;
CASE TW OF
1,5: DISPLAY := OVEN_TEMP;
2: DISPLAY := MOTOR_SPEED;
3: DISPLAY := GROSS - TARE;
4,6..10: DISPLAY := STATUS(TW - 4);
ELSE
DISPLAY := 0 ; TW_ERROR := 1;
END_CASE;
QW100 := INT_TO_BCD(DISPLAY);
6 FOR J := 101;
FOR I := 1 TO 100 BY 2 DO
IF WORDS[I] = 'KEY' THEN
J := I;
EXIT;
END_IF;
END_FOR;
7 WHILE J := 1;
WHILE J <= 100 & WORDS[J] <> 'KEY’ DO
J := J+2;
END_WHILE;
8 REPEAT J := -1;
REPEAT
J := J+2;
UNTIL J = 101 OR WORDS[J] = 'KEY’
END_REPEAT;
9 EXIT
(The EXIT statement works with the FOR, WHILE, and REPEAT statements)
EXIT;
10 Empty statement ;
11 End of Program END_PROGRAM;
12 Subroutine CALL Subroutine1;
END_PROGRAM;
SBRT Subroutine1
iVal1 := iVal1 + 1;
END_SBRT;

 

 

 

 

 

 

LP304C