Overview of Structured Text Programming
Rockwell Automation Publication MOTION-RM002H-EN-P-February 2018 649
To do something when all of the IF or ELSIF conditions are false, add an ELSE
statement.
The table summarizes different combinations of IF, THEN, ELSIF, and ELSE.
If you want to And Use this construct
Do something if or when conditions are true Do nothing if conditions are false IF_THEN
Do something else if conditions are false IF_THEN_ELSE
Choose from alternative statements (or groups of
statements) based on input conditions
Do nothing if conditions are false IF_THEN_ELSIF
Assign default statements if all conditions are false IF_THEN_ELSIF_ELSE
Affects Math Status Flags
No
Fault Conditions
None.
Examples
Example 1
IF…THEN
If you want this Enter this structured text
IF rejects > 3 then IF rejects > 3 THEN
conveyor = off (0) conveyor := 0;
alarm = on (1) alarm := 1;
END_IF;
Example 2
IF_THEN_ELSE
If you want this Enter this structured text
If conveyor direction contact = forward (1) then IF conveyor_direction THEN
light = off light := 0;
Otherwise light = on ELSE
light [:=] 1;
END_IF;
The [:=] tells the controller to clear light whenever the controller does the
following :