Menu
CoddyTech

CASE for Steps

Part of the Structured Text section of Coddy's PLC Programming journey. Lesson 10 of 17.

A step sequence keeps its step number in an INT. In text, CASE picks the statements for the step the machine is in:

CASE Step OF
    0: IF Start THEN Step := 1; END_IF;
    1: IF High THEN Step := 2; END_IF;
    2: IF NOT Low THEN Step := 0; END_IF;
END_CASE;

Each label (0:, 1:) says which step its statements belong to; only that step's statements run. Each step waits for its condition, then moves on. The list ends with END_CASE;.

Write the outputs after the CASE, one statement each. Fill := Step = 1; makes Fill TRUE exactly while Step is 1, so it turns off by itself when the step moves on. Compare with = <> < > <= >=, the same signs as the compare box.

challenge icon

Challenge

Easy
  • Step 0: wait for Start.
  • Step 1: Fill until High.
  • Step 2: Drain until Low goes off, then back to step 0.

Write the outputs after END_CASE.

Try it yourself

VAR
    Step : INT;
END_VAR

CASE Step OF
    0: IF Start THEN Step := 1; END_IF;
    // step 1: fill until High
    // step 2: drain until Low is off
END_CASE;

// The outputs

All lessons in Structured Text

Practice on your own: PLC playground