Pedestrian crossing: a chain of on-delay timers
A push button, a three-colour car signal and a walk signal: the classic exercise for learning how a chain of on-delay timers turns one button press into a timed sequence. Fully solved, in four PLC families.
Loads the panel and the ladder program from the video. Press RUN PLC and try it.
Other PLC families:
The task
A road has a pedestrian crossing with a push button. The car signal is a three-colour tower light and the walk signal has two lamps, WAIT (red) and WALK (green). Normally the cars have green and the walk signal shows WAIT. When a pedestrian presses the button:
- the cars keep green for 2 seconds, so a car that is already close can pass;
- the cars get amber for 3 seconds;
- the cars get red, and the walk signal shows WALK for 6 seconds;
- WAIT comes back, and after 2 seconds of all red (so the last pedestrian can clear the road) the cars get green again.
A press while the sequence is running must not restart or lengthen it. This is one of the most common PLC exercises, because it teaches the single most useful pattern in sequential control: a chain of on-delay timers.
Inputs and outputs
Here with Siemens-style addresses; the other three PLC families are in the solution below.
| Address | Signal | Device |
|---|---|---|
I0.0 | PUSH button (input) | green push button, normally open |
Q0.0 | CARS red | tower light R |
Q0.1 | CARS amber | tower light Y |
Q0.2 | CARS green | tower light G |
Q0.3 | WAIT | red lamp |
Q0.4 | WALK | green lamp |
M0.0 | crossing requested | internal memory bit |
T0 / T1 / T2 / T3 | the four timers | on-delay timers |
Thinking it through
The button is only pressed for a moment, but the sequence takes 13 seconds. So the first job is to remember the request: the button sets a memory bit, and the bit stays on until the sequence is finished. A set / reset pair is clearer here than a seal-in, because the bit is switched on and off in two different places.
Next, the time steps. Instead of one timer with many comparisons, use four on-delay timers in a chain: the request bit starts the first timer, the done bit of each timer starts the next one. Each timer is one step of the sequence, so the times can be read and changed directly: 2 s, 3 s, 6 s and 2 s. When the last timer is done, it resets the request bit. That switches off the first timer, which switches off the second, and so on: the whole chain falls back to zero by itself, ready for the next press.
The lights then need no memory of their own. Each one is just a combination of timer bits:
| Light | On when | Why |
|---|---|---|
| Cars green | first timer not done | covers normal running and the first 2 s |
| Cars amber | first timer done and second not done | the 3 s amber step |
| Cars red | second timer done | walk time and the 2 s clearance |
| WALK | second timer done and third not done | the 6 s walk step |
| WAIT | WALK off | always the opposite of WALK |
Writing the outputs this way has a safety benefit: cars green and WALK can never be on together, because one needs the first timer off and the other needs the second timer on, and the second timer cannot run before the first is done.
The solution in four PLC families
The logic is identical; only the addresses, the instruction names and the way the timer preset is written change. Siemens counts presets in milliseconds, the FX-style Mitsubishi and TOYOPUC timers count in 0.1 s steps (K20 = 2 s), and the MicroLogix-style timers here use a 0.01 s time base. On Allen-Bradley the contact for a finished timer is its /DN (done) bit.
Siemens S7-1200 style
| Rung | Contacts | Output | What it does |
|---|---|---|---|
| 1 | NO I0.0 | S (set) M0.0 | the button stores the request |
| 2 | NO M0.0 | TON T0, PT 2000 ms | 2 s more green |
| 3 | NO T0 | TON T1, PT 3000 ms | 3 s amber |
| 4 | NO T1 | TON T2, PT 6000 ms | 6 s walk |
| 5 | NO T2 | TON T3, PT 2000 ms | 2 s all red |
| 6 | NO T3 | R (reset) M0.0 | sequence done: every timer resets |
| 7 | NC T0 | coil Q0.2 | cars green |
| 8 | NO T0, NC T1 | coil Q0.1 | cars amber |
| 9 | NO T1 | coil Q0.0 | cars red |
| 10 | NO T1, NC T2 | coil Q0.4 | WALK |
| 11 | NC Q0.4 | coil Q0.3 | WAIT whenever WALK is off |
Mitsubishi MELSEC FX style
| Rung | Contacts | Output | What it does |
|---|---|---|---|
| 1 | LD / AND X0 | SET M0 | the button stores the request |
| 2 | LD / AND M0 | OUT T T0, K20 | 2 s more green |
| 3 | LD / AND T0 | OUT T T1, K30 | 3 s amber |
| 4 | LD / AND T1 | OUT T T2, K60 | 6 s walk |
| 5 | LD / AND T2 | OUT T T3, K20 | 2 s all red |
| 6 | LD / AND T3 | RST M0 | sequence done: every timer resets |
| 7 | LDI / ANI T0 | OUT Y2 | cars green |
| 8 | LD / AND T0, LDI / ANI T1 | OUT Y1 | cars amber |
| 9 | LD / AND T1 | OUT Y0 | cars red |
| 10 | LD / AND T1, LDI / ANI T2 | OUT Y4 | WALK |
| 11 | LDI / ANI Y4 | OUT Y3 | WAIT whenever WALK is off |
Allen-Bradley MicroLogix style
| Rung | Contacts | Output | What it does |
|---|---|---|---|
| 1 | XIC I:0/0 | OTL B3:0/0 | the button stores the request |
| 2 | XIC B3:0/0 | TON T4:0, PRE 200 (0.01 s) | 2 s more green |
| 3 | XIC T4:0/DN | TON T4:1, PRE 300 (0.01 s) | 3 s amber |
| 4 | XIC T4:1/DN | TON T4:2, PRE 600 (0.01 s) | 6 s walk |
| 5 | XIC T4:2/DN | TON T4:3, PRE 200 (0.01 s) | 2 s all red |
| 6 | XIC T4:3/DN | OTU B3:0/0 | sequence done: every timer resets |
| 7 | XIO T4:0/DN | OTE O:0/2 | cars green |
| 8 | XIC T4:0/DN, XIO T4:1/DN | OTE O:0/1 | cars amber |
| 9 | XIC T4:1/DN | OTE O:0/0 | cars red |
| 10 | XIC T4:1/DN, XIO T4:2/DN | OTE O:0/4 | WALK |
| 11 | XIO O:0/4 | OTE O:0/3 | WAIT whenever WALK is off |
JTEKT TOYOPUC
| Rung | Contacts | Output | What it does |
|---|---|---|---|
| 1 | STR / AND X000 | SET M000 | the button stores the request |
| 2 | STR / AND M000 | TMR T000, K20 (0.1 s) | 2 s more green |
| 3 | STR / AND T000 | TMR T001, K30 (0.1 s) | 3 s amber |
| 4 | STR / AND T001 | TMR T002, K60 (0.1 s) | 6 s walk |
| 5 | STR / AND T002 | TMR T003, K20 (0.1 s) | 2 s all red |
| 6 | STR / AND T003 | RST M000 | sequence done: every timer resets |
| 7 | STRN / ANDN T000 | OUT Y002 | cars green |
| 8 | STR / AND T000, STRN / ANDN T001 | OUT Y001 | cars amber |
| 9 | STR / AND T001 | OUT Y000 | cars red |
| 10 | STR / AND T001, STRN / ANDN T002 | OUT Y004 | WALK |
| 11 | STRN / ANDN Y004 | OUT Y003 | WAIT whenever WALK is off |
Test it
- Press RUN PLC. CARS shows green, WAIT is lit.
- Press PUSH. Nothing changes for 2 s, then amber for 3 s.
- Cars red and WALK green for 6 s. Open the monitor (Tag monitor) and watch the four timers count one after another.
- WAIT comes back, 2 s later the cars are green again. Press PUSH during the sequence: nothing changes.
Common mistakes
- Using the button directly as the timer condition. The timer resets as soon as the button is released. Store the request in a bit first.
- Resetting the request too early, for example when WALK ends. The last timer then never finishes and the cars stay red. Reset only from the last timer of the chain.
- Giving each light its own set / reset. It works, but it is easy to leave a light on in a corner case. Deriving the lights from timer bits keeps them consistent automatically.
- Forgetting the all-red clearance. A real crossing gives slow pedestrians time to finish before cars move.
Variations to try
- Flash the WALK lamp during its last 2 seconds (an extra timer and a clock bit).
- Add a minimum green time for the cars, so pedestrians cannot stop the traffic every few seconds.
- Use the tower light's buzzer as an audible signal for blind pedestrians while WALK is on.
Try it yourself
Build it from scratch in the free PLC Sim Lab Playground, or open the finished solution and change it:
Loads the panel and the ladder program from the video. Press RUN PLC and try it.
Other PLC families:
Frequently asked questions
Why use four timers instead of one?
Each timer is one step of the sequence, so every time can be read and changed on its own, and the light logic stays simple: each light depends only on which timers are done. With one timer you would need several comparisons of its elapsed time.
How does the chain reset?
The last timer resets the request bit. That switches off the first timer, whose done bit then switches off the second, and so on, so the whole chain returns to zero within a few scans.
What happens if the button is pressed during the sequence?
The request bit is already set, so setting it again changes nothing. The sequence is neither restarted nor lengthened.
More: all PLC exercises · free PLC course with certificate · PLC timers and counters · ladder logic basics