Arithmetic status flags, Fault conditions, Example 1 – Rockwell Automation Logix5000 Controllers Structured Text Programming Manual User Manual
Page 23: Example 2
Publication 1756-PM007D-EN-P - November 2012
23
Program Structured Text Chapter 1
This table summarizes combinations of IF, THEN, ELSIF, and ELSE.
Arithmetic Status Flags:
Not affected
Fault Conditions:
None
Example 1:
IF…THEN
Example 2:
IF…THEN…ELSE
The [:=] tells the controller to clear light whenever the controller:
•
enters the Run mode.
•
leaves the step of an SFC if you configure the SFC for Automatic reset.
(This applies only if you embed the assignment in the action of the step
or use the action to call a structured text routine via a JSR instruction.)
If you want to
And
Then 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…ESLE
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
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;
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;