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
Hard- Step 0: cars
Green, walkersDontWalk, untilWalkButton. - Step 1:
Amberfor 3 s, withWaitlit. - Step 2:
RedandWalkfor 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