Skip to content
PLCampus
All examples

09Level 3

Car park with space counter

An up/down counter keeps track of the cars inside. With all 10 spaces taken the FULL sign lights up and the entry barrier no longer opens.

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

Virtual plant

SPACESQ0.0Q0.1I0.0I0.1Waiting: 0Parked: 0 of 10

Parked: 0 of 10. Waiting: 0

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

Inputs and outputs

AddressNameDescription
I0.0ENTRY_SENSORDetects a car going in (plant)
I0.1EXIT_SENSORDetects a car going out (plant)
I0.2CAR_AT_BARRIERA car is waiting at the entry barrier (plant)
Q0.0FULL_SIGN“FULL” sign
Q0.1BARRIEREntry barrier
C0CARSCars inside the car park (maximum 10)

Program

Ladder diagram (LD)

  1. Rung 1 — Counts the cars going in and out. With 10 inside, FULL lights up.

    ENTRY_SENSORI0.0CTUDCARSPV 10FULL_SIGNQ0.0
  2. Rung 2 — The barrier opens for the waiting car if there is space.

    CAR_AT_BARR…I0.2FULL_SIGNQ0.0BARRIERQ0.1

Step by step

  1. 1Press ▶ Run (F5) and, in the plant, press “A car arrives” several times: the barrier opens for each one and the CARS counter adds when it passes the entry sensor.
  2. 2The CTUD counter counts up with the entry (CU) and down with the exit (CD). Its QU output turns on when the count reaches 10 (PV).
  3. 3With 10 cars inside, FULL lights up and the NC contact of FULL_SIGN keeps the barrier closed: new cars wait in line.
  4. 4Press “A car leaves”: the count drops to 9, FULL turns off and the next car in line goes in.