✓ Solution & Explanation
Reference Code
IF NOT In_EStop THEN
Out_Fault := TRUE; Out_CylExtend := FALSE;
Out_CylRetract := TRUE; Out_CapMotor := FALSE;
state := 0; RETURN;
END_IF;
Out_CycleComplete := FALSE;
CASE state OF
0: Out_CylExtend:=FALSE; Out_CylRetract:=TRUE; Out_CapMotor:=FALSE;
IF In_BottlePresent AND In_CylUp THEN state:=1; END_IF;
1: Out_CylExtend:=TRUE; Out_CylRetract:=FALSE;
IF In_CylDown THEN state:=2; END_IF;
2: Out_CapMotor:=TRUE;
IF In_TorqueOK THEN state:=3; END_IF;
3: Out_CapMotor:=FALSE; Out_CylExtend:=FALSE; Out_CylRetract:=TRUE;
IF In_CylUp THEN state:=4; END_IF;
4: Out_CycleComplete:=TRUE; state:=0;
END_CASE;
Steps
(1) CycleComplete is a 1-scan pulse: cleared at top of every scan, then state 4 sets it and transitions to 0, so next scan state 0 runs with it already FALSE. (2) Interlock is structural — no state ever writes both Extend and Retract TRUE. (3) Fault latch stays set because Out_Fault := TRUE is unconditional in the E-Stop guard.