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
Opening: 0 %
Shown at rest. In the simulator the plant moves according to your program's outputs.
Inputs and outputs
| Address | Name | Description |
|---|---|---|
| I0.0 | OPEN | Open push button (NO) |
| I0.1 | CLOSE | Close push button (NO) |
| I0.2 | LS_OPEN | Gate open limit switch (plant) |
| I0.3 | LS_CLOSED | Gate closed limit switch (plant) |
| I0.4 | PHOTOCELL | Photocell: 1 when clear, 0 with an obstacle (plant) |
| Q0.0 | MOTOR_OPEN | Motor, opening direction |
| Q0.1 | MOTOR_CLOSE | Motor, closing direction |
| Q0.2 | BEACON | Warning beacon |
| S0.2 | CLOCK_1HZ | System bit that toggles once per second |
Program
Ladder diagram (LD)
Rung 1 — Opening: by the push button, or automatically with an obstacle. It stops at the limit switch.
Rung 2 — Closing: only with a clear path. It stops at the limit switch.
Rung 3 — The beacon flashes while the gate moves.
Function block diagram (FBD)
Network 1 — Opening: by the push button, or automatically with an obstacle. It stops at the limit switch.
Network 2 — Closing: only with a clear path. It stops at the limit switch.
Network 3 — The beacon flashes while the gate moves.
Structured text (ST)
(* Automatic gate — converted from Ladder *)
(* Rung 1: Opening: by the push button, or automatically with an obstacle. It stops at the limit switch. *)
MOTOR_OPEN := (OPEN OR MOTOR_OPEN OR NOT PHOTOCELL) AND NOT LS_OPEN AND NOT MOTOR_CLOSE;
(* Rung 2: Closing: only with a clear path. It stops at the limit switch. *)
MOTOR_CLOSE := (CLOSE OR MOTOR_CLOSE) AND NOT LS_CLOSED AND PHOTOCELL AND NOT MOTOR_OPEN;
(* Rung 3: The beacon flashes while the gate moves. *)
BEACON := (MOTOR_OPEN OR MOTOR_CLOSE) AND CLOCK_1HZ;Instruction list (IL)
(* Automatic gate — converted from Ladder *) (* Rung 1: Opening: by the push button, or automatically with an obstacle. It stops at the limit switch. *) LD OPEN OR MOTOR_OPEN ORN PHOTOCELL ANDN LS_OPEN ANDN MOTOR_CLOSE ST MOTOR_OPEN (* Rung 2: Closing: only with a clear path. It stops at the limit switch. *) LD CLOSE OR MOTOR_CLOSE ANDN LS_CLOSED AND PHOTOCELL ANDN MOTOR_OPEN ST MOTOR_CLOSE (* Rung 3: The beacon flashes while the gate moves. *) LD MOTOR_OPEN OR MOTOR_CLOSE AND CLOCK_1HZ ST BEACON
Step by step
- 1Press ▶ Run (F5) and press OPEN: the gate opens until the LS_OPEN limit switch stops it. The beacon flashes while it moves.
- 2Press CLOSE: the gate goes down to LS_CLOSED.
- 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.
- 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.