Appendix C
Structured Text Programming
If you want to
Do something if or when conditions are
true
Choose from alternative statements (or
groups of statements) based on input
conditions
Arithmetic Status Flags
Fault Conditions:
If you want this
IF rejects > 3 then
conveyor = off (0)
alarm = on (1)
If you want this
If conveyor direction contact = forward (1) then
light = off
Otherwise light = on
682
The table summarizes different combinations of IF, THEN, ELSIF,
and ELSE.
Not affected
None
Example 1:
IF...THEN
Example 2:
IF...THEN...ELSE
Rockwell Automation Publication 1756-RM003N-EN-P - October 2011
And
Do nothing if conditions are false
Do something else if conditions are false
Do nothing if conditions are false
Assign default statements if all conditions
are false
Enter this structured text
IF rejects > 3 THEN
conveyor := 0;
alarm := 1;
END_IF;
Enter this structured text
IF conveyor_direction THEN
light := 0;
ELSE
light [:=] 1;
END_IF;
Use this construct
IF...THEN
IF...THEN...ELSE
IF...THEN...ELSIF
IF...THEN...ELSIF...ELSE