Drawbridge control with one button on each side
A drawbridge over a river and only two push buttons, one on each bank. The press on your side closes the bridge, the press on the far side opens it again, and it must work in both directions. The trick is to make the PLC remember who is crossing.
Loads the panel and the ladder program from the video. Press RUN PLC and try it.
The task
A drawbridge crosses a river. It normally stays open (raised) so boats can pass. There is one push button on each bank, PB A and PB B, and nothing else for the people crossing:
- A person on side A presses PB A: the bridge closes (comes down). They cross and press PB B on the other side: the bridge opens again.
- The same works the other way round: PB B closes it, PB A opens it.
- If the same button is pressed again before the person has crossed, nothing happens, so nobody can raise the bridge while someone is still on it.
The bridge has a drive with two directions (CLOSE and OPEN) and a limit switch at each end of its travel. In the PLC Sim Lab Playground this is the Drawbridge part in the parts list.
Inputs and outputs
| Siemens | TOYOPUC | Signal |
|---|---|---|
I0.0 | X000 | PB A, side A |
I0.1 | X001 | PB B, side B |
I0.2 | X002 | LSC: bridge fully closed |
I0.3 | X003 | LSO: bridge fully open |
Q0.0 | Y000 | drive: CLOSE |
Q0.1 | Y001 | drive: OPEN |
M0.0 | M000 | a person from A is crossing |
M0.1 | M001 | a person from B is crossing |
Thinking it through
Both buttons can open and close the bridge, so the button alone does not tell the PLC what to do. What decides it is who is on the bridge. Two memory bits store that: M0.0 means someone from side A is crossing, M0.1 someone from side B.
- Ask to cross. While the bridge is fully open, PB A sets M0.0 and PB B sets M0.1. Each also checks that the other bit is off, so two people cannot both "own" the bridge.
- Only the far side opens it. While the bridge is fully closed, PB B resets M0.0 (the person from A has arrived on side B), and PB A resets M0.1. A second press on the near side finds no matching rung, so it is ignored.
- Drive to the limits. If either bit is on, close until the closed limit switch; if neither is on, open until the open limit switch. Each direction is blocked while the other one runs, so the motor can never get both.
Use edges (one-shots) on the buttons. Without them, a single long press on side B could reset M0.0 and, as soon as the bridge is open again, immediately set M0.1 and close it again.
The ladder program (Siemens style)
| Rung | Contacts | Output | What it does |
|---|---|---|---|
| 1 | P I0.0, I0.3, NOT M0.1 | S M0.0 | A asks to cross |
| 2 | P I0.1, I0.3, NOT M0.0 | S M0.1 | B asks to cross |
| 3 | P I0.1, I0.2, M0.0 | R M0.0 | A has crossed, B opens |
| 4 | P I0.0, I0.2, M0.1 | R M0.1 | B has crossed, A opens |
| 5 | (M0.0 OR M0.1), NOT I0.2, NOT Q0.1 | Q0.0 | close until LSC |
| 6 | NOT M0.0, NOT M0.1, NOT I0.3, NOT Q0.0 | Q0.1 | open until LSO |
The same on a TOYOPUC
On a JTEKT TOYOPUC the one-shot is a rise differential placed after the contact, and each differential needs its own P edge relay (P000 to P003) to remember the previous state. Inputs are X, outputs Y, internal relays M, all numbered in hexadecimal.
| Rung | Instructions | Output |
|---|---|---|
| 1 | STR X000, rise diff. P000, AND X003, ANDN M001 | SET M000 |
| 2 | STR X001, rise diff. P001, AND X003, ANDN M000 | SET M001 |
| 3 | STR X001, rise diff. P002, AND X002, AND M000 | RST M000 |
| 4 | STR X000, rise diff. P003, AND X002, AND M001 | RST M001 |
| 5 | (M000 OR M001), ANDN X002, ANDN Y001 | OUT Y000 |
| 6 | STRN M000, ANDN M001, ANDN X003, ANDN Y000 | OUT Y001 |
Loads the panel and the ladder program from the video. Press RUN PLC and try it.
Test it
- RUN: the bridge is open and LSO is on.
- Press PB A: M0.0 is set and the bridge comes down until LSC.
- Press PB A again: nothing happens.
- Press PB B: M0.0 is reset and the bridge opens.
- Now start from side B: PB B closes, PB A opens.
Common mistakes
- A simple toggle (every press flips the bridge). It passes the first test but fails the "same side again" rule: a second press on side A would raise the bridge under the person.
- No limit switches in the motor rungs, so the drive keeps running at the end of travel.
- No interlock between CLOSE and OPEN. In a real drive, both directions together means a short circuit across the reversing contactors.
- Level contacts instead of edges on the buttons, which makes one long press count twice.
Variations to try
- Add warning lamps and a buzzer that run for 3 s before the bridge moves.
- Add a timeout: if the far button is not pressed within 2 minutes, sound an alarm.
- Add a third button in a control room that can open the bridge for a boat only when nobody is crossing.
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.
Frequently asked questions
Why not just toggle the bridge on every press?
A toggle cannot tell the near button from the far one, so a second press on the starting side would open the bridge while the person is still on it. Remembering who is crossing makes only the far button open it.
Why are the CLOSE and OPEN outputs interlocked?
Each output has a normally closed contact of the other one. Even during a programming mistake the drive cannot be told to run both ways at once, which on a real reversing starter would be a short circuit.
More: all PLC exercises · free PLC course with certificate · PLC timers and counters · ladder logic basics