Menu
CoddyTech

Project: Crossing in Text

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

The pedestrian crossing from section 3, now in Structured Text. It is a step sequence, so it is a CASE on a Step variable, with one timer per timed step.

Call every timer before the CASE, on every scan, with IN on its own step:

AmberTime(IN := Step = 1, PT := T#3s);

The timer runs while Step is 1 and resets the moment the step moves on, ready for the next walker. Then set every lamp after the CASE, one line each.

The one rule that must never break: Walk is never lit while cars have green or amber.

challenge icon

Challenge

Hard
  • Step 0: cars Green, walkers DontWalk, until WalkButton.
  • Step 1: Amber for 3 s, with Wait lit.
  • Step 2: Red and Walk for 5 s.
  • Step 3: Red and DontWalk for 2 s, then step 0.

Try it yourself

VAR
    Step : INT;
    AmberTime : TON;
    WalkTime : TON;
    ClearTime : TON;
END_VAR

// Call the three timers here, IN on their own step

// The CASE: steps 0 to 3

// The lamps, one line each

All lessons in Structured Text

Practice on your own: PLC playground