Skip to content
PLCampus
All examples

05Level 2

Automatic gate

A gate that opens and closes with limit switches, stops and reopens if a photocell detects an obstacle, and warns with a flashing beacon while it moves.

The simulator is designed for computers (screens 1024 px or wider).

Virtual plant

Q0.2I0.4 · PhotocellI0.3I0.2Q0.0 ▶◀ Q0.1Opening 0 %

Opening: 0 %

Shown at rest. In the simulator the plant moves according to your program's outputs.

Inputs and outputs

AddressNameDescription
I0.0OPENOpen push button (NO)
I0.1CLOSEClose push button (NO)
I0.2LS_OPENGate open limit switch (plant)
I0.3LS_CLOSEDGate closed limit switch (plant)
I0.4PHOTOCELLPhotocell: 1 when clear, 0 with an obstacle (plant)
Q0.0MOTOR_OPENMotor, opening direction
Q0.1MOTOR_CLOSEMotor, closing direction
Q0.2BEACONWarning beacon
S0.2CLOCK_1HZSystem bit that toggles once per second

Program

Ladder diagram (LD)

  1. Rung 1 — Opening: by the push button, or automatically with an obstacle. It stops at the limit switch.

    OPENI0.0MOTOR_OPENQ0.0PHOTOCELLI0.4LS_OPENI0.2MOTOR_CLOSEQ0.1MOTOR_OPENQ0.0
  2. Rung 2 — Closing: only with a clear path. It stops at the limit switch.

    CLOSEI0.1MOTOR_CLOSEQ0.1LS_CLOSEDI0.3PHOTOCELLI0.4MOTOR_OPENQ0.0MOTOR_CLOSEQ0.1
  3. Rung 3 — The beacon flashes while the gate moves.

    MOTOR_OPENQ0.0MOTOR_CLOSEQ0.1CLOCK_1HZS0.2BEACONQ0.2

Step by step

  1. 1Press ▶ Run (F5) and press OPEN: the gate opens until the LS_OPEN limit switch stops it. The beacon flashes while it moves.
  2. 2Press CLOSE: the gate goes down to LS_CLOSED.
  3. 3Open it again, close it and, while it goes down, press “Place obstacle” in the plant: the photocell stops the closing and the gate opens again.
  4. 4Look at the NC contacts of MOTOR_OPEN and MOTOR_CLOSE: they prevent ordering both directions at once. The beacon uses system bit CLOCK_1HZ to flash.