Introduction
An IF-THEN-ELSE statement helps a PLC decide what to do based on conditions. It lets the program choose between two paths.
IF condition THEN
// actions if condition is true
ELSE
// actions if condition is false
END_IFIF sensor_input = TRUE THEN
motor := TRUE;
ELSE
motor := FALSE;
END_IFIF temperature > 50 THEN
alarm := TRUE;
ELSE
alarm := FALSE;
END_IFPROGRAM Main
VAR
sensor_input : BOOL := TRUE;
motor : BOOL := FALSE;
END_VAR
IF sensor_input THEN
motor := TRUE;
ELSE
motor := FALSE;
END_IF
END_PROGRAMIF-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