Concept Flow - IF-THEN-ELSE statement
Start
Evaluate Condition
Execute THEN block
Continue
Execute ELSE block
Continue
The PLC checks a condition. If true, it runs the THEN part; if false, it runs the ELSE part, then continues.
IF sensor_input = TRUE THEN motor_output := ON; ELSE motor_output := OFF; END_IF;
| Step | Condition (sensor_input = TRUE) | Branch Taken | Action | motor_output |
|---|---|---|---|---|
| 1 | TRUE | THEN | Set motor_output to ON | ON |
| 2 | FALSE | ELSE | Set motor_output to OFF | OFF |
| Variable | Start | After Step 1 | After Step 2 |
|---|---|---|---|
| sensor_input | TRUE | TRUE | FALSE |
| motor_output | OFF | ON | OFF |
IF-THEN-ELSE checks a condition. If TRUE, runs THEN block. If FALSE, runs ELSE block. Only one branch runs per cycle. Used to control outputs based on inputs.
IF-THEN-ELSE statement do in PLC programming?IF SensorInput = TRUE THEN Motor := ON; ELSE Motor := OFF; END_IF;
SensorInput is FALSE initially.IF Temperature > 100 THEN Alarm := TRUE ELSE Alarm := FALSE; END_IF;
Pass the test and this pattern moves unknown