Basic
40 min

Car Parking System PLC Ladder Diagram (Run It Free Online)

A car parking gate is one of the most complete beginner PLC projects: it combines inductive loop detectors, a CTUD up/down counter for occupancy tracking, a gate motor interlock, a timed close-delay and a FULL lamp that locks out new entries when the lot is at capacity. Below is the full I/O table, the key ladder rungs, the timing diagram and the build flowchart — and because this is a live scenario, you can write the logic and watch the gate move in your browser without installing anything.

countersequencepartial-wiringedge-detection
Parking Gate Controller scenario preview

Ready to build this?

Sign up free — no credit card required. This scenario requires the Basic plan.

Sign up to play this scenario →

Already have an account? Log in

Briefing

An entry gate for a small parking lot with five bays. When a car rolls onto the inbound loop the ticket dispenser pulses until the driver pulls a ticket. Once the ticket is taken AND the lot is not already at capacity the gate raises; as soon as the car clears the loop a 3-second close-delay starts, after which the gate lowers again. A counter tracks how many cars are inside — incremented each time the gate tops-out (one more car passed through) and decremented each time the outbound loop sees a car leaving. When the counter reaches five the FULL lamp lights and the dispenser is inhibited so no new cars queue behind a closed gate. If a driver reverses while the gate is already lowering, the ENTRY_LOOP trips again — the controller must immediately kill the down-motor and reverse back up. GATE_UP_MOTOR and GATE_DN_MOTOR must never be energised together.

Objectives

  • Dispense a ticket (TICKET_DISPENSE) whenever ENTRY_LOOP is made, the lot is not full, and the driver has not yet pulled the ticket
  • Raise the gate (GATE_UP_MOTOR) on ENTRY_LOOP AND TICKET_PULLED AND not-full; cut the motor at GATE_UP_LIMIT
  • Count occupancy up on the rising edge of GATE_UP_LIMIT (car passed through) and down on the rising edge of EXIT_LOOP
  • Light FULL_LAMP when occupancy reaches five, and refuse to raise the gate or dispense a ticket while full
  • 3-second close-delay: once GATE_UP_LIMIT is made AND ENTRY_LOOP has cleared, start GATE_DN_MOTOR; cut at GATE_DN_LIMIT
  • If ENTRY_LOOP re-asserts while lowering, immediately reverse — GATE_DN_MOTOR off, GATE_UP_MOTOR on
  • GATE_UP_MOTOR and GATE_DN_MOTOR must never be energised simultaneously

Hints

  • Use R_TRIG on GATE_UP_LIMIT (car entered) and EXIT_LOOP (car left) to feed a CTUD counter with PV = 5 — CTUD.QU is the "full" signal
  • State bits RAISING and LOWERING as SET/RESET latches keep the two motor coils disjoint by construction
  • Close-delay: T_CLOSE(IN := GATE_UP_LIMIT AND /ENTRY_LOOP, PT := 3000) — T_CLOSE.Q SETs LOWERING
  • Reverse priority: | ENTRY_LOOP AND LOWERING | R= LOWERING ; | ENTRY_LOOP AND LOWERING | S= RAISING ;
  • TICKET_DISPENSE := ENTRY_LOOP AND /TICKET_PULLED AND /FULL_LAMP — the /FULL_LAMP term enforces the lot-full interlock

I/O Table

Inputs

ENTRY_LOOP

Inbound loop detector (car sitting on entry)

BOOL · %I0.0

EXIT_LOOP

Outbound loop detector (car leaving the lot)

BOOL · %I0.1

TICKET_PULLED

Driver pulled the ticket (take-ticket button made)

BOOL · %I0.2

GATE_UP_LIMIT

Gate fully-open limit switch

BOOL · %I0.3

GATE_DN_LIMIT

Gate fully-closed limit switch

BOOL · %I0.4

Outputs

GATE_UP_MOTOR

Gate raise motor contactor

BOOL · %Q0.0

GATE_DN_MOTOR

Gate lower motor contactor

BOOL · %Q0.1

TICKET_DISPENSE

Ticket-dispenser solenoid

BOOL · %Q0.2

FULL_LAMP

Lot-full indicator lamp

BOOL · %Q0.3

Your program will be tested against:

All test cases run automatically when you submit. Assertions are hidden until you pass.

  1. #1Single car enters, gate raises, holds, then lowers after 3 s delay

    ENTRY_LOOP+TICKET_PULLED → GATE_UP_MOTOR → UP_LIMIT trips; ENTRY clears; 3 s delay; GATE_DN_MOTOR → DN_LIMIT

  2. #2FULL_LAMP lights after 5 cars and further entries are refused

    Five full entry cycles (ENTRY+TICKET → UP_LIMIT → clear → DN_LIMIT) fill the lot; the 6th is blocked

  3. #3Car reverses mid-close: down-motor drops, up-motor engages

    Complete one open cycle, wait through the 3 s delay + ~1.5 s of lowering, then re-assert ENTRY_LOOP to reverse the gate

  4. #4Dispenser pulses while ENTRY_LOOP is made and the ticket is untaken

    ENTRY_LOOP alone lights TICKET_DISPENSE; pulling the ticket drops it

  5. #5UP and DOWN gate motors are never simultaneously energised

    Exercise a normal open/close cycle plus a mid-close reversal; assert the interlock invariant was never violated

Car parking PLC I/O: inputs and outputs

A five-bay car parking controller needs five digital inputs and four digital outputs. The inbound loop detector (ENTRY_LOOP) signals that a car is waiting; EXIT_LOOP detects a car leaving. TICKET_PULLED confirms the driver collected the dispensed ticket. Two limit switches — GATE_UP_LIMIT and GATE_DN_LIMIT — tell the PLC when the gate has fully opened or fully closed.

On the output side, GATE_UP_MOTOR and GATE_DN_MOTOR drive the gate mechanism and must never be energised together. TICKET_DISPENSE pulses the dispenser solenoid while the driver is waiting. FULL_LAMP lights when the occupancy counter reaches the capacity preset of five.

car parking PLC I/O table — entry loop, exit loop, gate motor, full lamp
The parking gate I/O: five inputs (ENTRY_LOOP, EXIT_LOOP, TICKET_PULLED, GATE_UP_LIMIT, GATE_DN_LIMIT) and four outputs (GATE_UP_MOTOR, GATE_DN_MOTOR, TICKET_DISPENSE, FULL_LAMP).

CTUD up/down counter: tracking occupied bays

The heart of any car parking PLC program is an up/down counter (CTUD) that tracks how many cars are inside the lot. The counter increments on the rising edge of GATE_UP_LIMIT — that is, the moment the gate reaches its fully-open position and a car has passed through. It decrements on the rising edge of EXIT_LOOP — the moment a car is detected leaving.

The counter preset (PV) is set to five, matching the five available bays. When the count equals the preset, the CTUD.QU bit goes true, which lights the FULL_LAMP, disables the TICKET_DISPENSE output and blocks the gate from raising for the next entry. Using R_TRIG edge-detection blocks on both GATE_UP_LIMIT and EXIT_LOOP converts the level signals into one-shot pulses, preventing the counter from counting twice on a single event.

PLC ladder rung CTUD up/down counter for car parking occupancy
The occupancy-counting rung: R_TRIG on GATE_UP_LIMIT drives CU (count up); R_TRIG on EXIT_LOOP drives CD (count down). CTUD.QU energises FULL_LAMP when the count reaches five.

Gate open/close ladder logic and interlock

The gate raise rung is gated on three conditions: ENTRY_LOOP must be true (a car is present), TICKET_PULLED must be true (the driver has a ticket) and FULL_LAMP must be false (the lot is not full). When all three are satisfied, GATE_UP_MOTOR energises and the gate rises until GATE_UP_LIMIT trips the motor coil off.

Once the gate is fully open and ENTRY_LOOP clears (the car has driven through), a 3-second TON close-delay starts. When that timer expires, GATE_DN_MOTOR energises and the gate lowers until GATE_DN_LIMIT cuts it off. If a car reverses under the gate while it is still lowering, ENTRY_LOOP re-asserts mid-close — the controller must immediately reset GATE_DN_MOTOR and set GATE_UP_MOTOR. Because GATE_UP_MOTOR and GATE_DN_MOTOR are implemented as SET/RESET latches, only one can ever be active at a time, making the interlock structural rather than relying on extra contacts.

PLC ladder rung car parking gate open close interlock logic
The gate control rung: ENTRY_LOOP AND TICKET_PULLED AND /FULL_LAMP raises the gate; GATE_UP_LIMIT cuts the motor; the 3 s close-delay then starts the down-motor, cut by GATE_DN_LIMIT.

Car parking timing diagram: occupancy and FULL output

The timing diagram traces two cars entering and one leaving, showing how the FULL_LAMP responds to the occupancy count. Each entry event (ENTRY_LOOP going true then clearing as the car passes through) triggers a gate raise cycle. Each EXIT_LOOP pulse decrements the count. When the cumulative count equals the preset the FULL_LAMP output goes true and stays true until a car leaves.

Notice that GATE_UP_MOTOR and GATE_DN_MOTOR never overlap in the diagram — the interlock holds at every transition. When you build this in the simulator, verifying this non-overlap is one of the five automated test cases the scenario runs.

car parking PLC timing diagram occupancy count FULL lamp output
The timing diagram: ENTRY_LOOP pulses increment the occupancy count; EXIT_LOOP pulses decrement it; FULL_LAMP goes true when count reaches the preset.

Building the car parking PLC program step by step

Start with the CTUD counter, giving it a preset of five and wiring R_TRIG blocks to both its CU and CD inputs. Once the counter counts correctly the rest of the program follows naturally: the FULL_LAMP rung simply mirrors CTUD.QU, the ticket dispenser rung checks ENTRY_LOOP AND /TICKET_PULLED AND /FULL_LAMP, and the gate raise rung adds TICKET_PULLED AND /FULL_LAMP to the entry condition.

The close-delay TON and the reverse-priority logic are the trickiest parts. Use a TON with a 3 000 ms preset, enabled by GATE_UP_LIMIT AND NOT ENTRY_LOOP, to trigger the down-motor. For the reversal, a normally-closed LOWERING state bit in the raise rung means that as soon as ENTRY_LOOP trips while the gate is descending, the raise rung goes true and the LOWERING latch resets automatically.

The simulator's partial-wiring mode for this scenario requires you to choose addresses for the limit switches and all four outputs — a realistic challenge that matches what you would face on a real commissioning job.

flowchart for building a car parking PLC program step by step
The build flowchart: start with the CTUD counter, add the FULL_LAMP, then the ticket-dispenser, gate-raise and gate-lower rungs, and finish with the close-delay and reverse-priority logic.

Troubleshooting your automatic car parking PLC program

If the FULL_LAMP never lights, check that you are triggering the counter on GATE_UP_LIMIT rather than on ENTRY_LOOP. Counting on the entry loop will fire the counter while the car is still outside; you want to count only once the gate has physically reached fully open.

If both motor coils ever energise at the same time, the physics engine will flag the everBothContactorsOn fault. The safest fix is to model RAISING and LOWERING as SET/RESET latches and add a normally-closed LOWERING contact to the raise rung — the structure prevents co-energisation without requiring you to remember extra interlock contacts.

If the gate never starts to lower after a car passes through, the TON close-delay rung is staying false: confirm that GATE_UP_LIMIT is wired to an input address and that the TON's enable rung correctly combines GATE_UP_LIMIT AND /ENTRY_LOOP.

Car parking system using PLC — the complete entry-to-exit program

A full car parking system using a PLC ties every rung above into one continuous control loop: a car trips ENTRY_LOOP, the dispenser pushes out a ticket, TICKET_PULLED confirms the driver took it, the gate raises until GATE_UP_LIMIT, the CTUD occupancy counter increments as the car drives through, the close-delay times out and the gate lowers — and the FULL_LAMP locks out new entries the moment the count reaches capacity. On the way out, EXIT_LOOP decrements the counter and clears the FULL state so the next car can enter. That entry-counter-exit cycle is the whole car parking PLC program, and it runs hands-off until the lot fills.

This is exactly the car parking plc ladder diagram you can write and watch execute in the live scenario on this page — the gate animates, the loop detectors fire and the FULL lamp responds in real time, with five automated test cases grading the counter, the interlock and the reverse-priority logic. To keep a copy of this car parking PLC ladder diagram (I/O table plus every rung) beside you while you build, press Ctrl/Cmd+P on this page and choose Save as PDF.

Frequently asked questions

What PLC instructions are used in a car parking system?

The core instructions are a CTUD up/down counter (to track occupied bays), R_TRIG edge-detection blocks (to generate one-shot pulses from the loop detectors), a TON on-delay timer (for the 3-second close-delay), SET/RESET coils (for the RAISING and LOWERING state latches) and standard output coils for the gate motors, dispenser and FULL lamp.

How does the PLC count cars in a parking lot?

A CTUD bidirectional counter is incremented on the rising edge of the GATE_UP_LIMIT input (one car has passed through) and decremented on the rising edge of the EXIT_LOOP input (one car has left). The counter preset is set to the lot capacity — five in this scenario — and when count equals preset the CTUD.QU bit lights the FULL lamp and blocks new entries.

Can I run a car parking PLC program without a real PLC?

Yes. This page is a live browser scenario — write the ladder logic, press Run, and watch the gate, loop detectors and FULL lamp respond in real time. No PLC hardware, no software install and no licence are required.

Why must GATE_UP_MOTOR and GATE_DN_MOTOR never energise together?

Energising both gate motor contactors simultaneously would short the motor drive, potentially destroying the contactor coils and tripping protection devices. In the PLC program this interlock is enforced by implementing RAISING and LOWERING as mutually exclusive SET/RESET latches — only one can be set at a time — and adding a normally-closed LOWERING contact in series with the raise rung.

What is the purpose of the 3-second close-delay in the parking gate program?

The delay gives the car time to fully clear the gate before the barrier starts to descend. Without the delay, a slow-moving car could still be under the gate when the down-motor energises, causing the barrier to strike the roof of the vehicle. The delay is implemented with a TON timer, enabled once the gate is fully open (GATE_UP_LIMIT true) and the car has cleared the loop (ENTRY_LOOP false).

How does the reverse-priority logic work when a car backs up under the gate?

If ENTRY_LOOP goes true again while the gate is already lowering, the program must immediately stop the down-motor and start the up-motor. This is handled by placing a normally-closed LOWERING contact in the raise rung: the moment ENTRY_LOOP retrips, the raise rung evaluates true, the RAISING latch sets, and because RAISING and LOWERING are exclusive latches, LOWERING resets automatically — reversing the gate before the barrier can strike the car.

What does a car parking PLC ladder diagram look like?

A car parking PLC ladder diagram has five rung groups: a CTUD up/down occupancy counter (CU on the rising edge of GATE_UP_LIMIT, CD on the rising edge of EXIT_LOOP, preset to the lot capacity), a FULL_LAMP rung that mirrors the counter's QU done bit, a ticket-dispenser rung, a gate-raise rung (ENTRY_LOOP AND TICKET_PULLED AND NOT FULL), and a gate-lower rung gated by a TON close-delay. RAISING and LOWERING are SET/RESET latches so the two gate motors can never energise together. To keep a copy of this exact ladder diagram, press Ctrl/Cmd+P on this page and choose Save as PDF.

How do you write a car parking PLC program?

Start with the CTUD occupancy counter — preset it to the number of bays and wire R_TRIG edge detectors to its count-up and count-down inputs so each car is counted once. Then the rest follows naturally: FULL_LAMP mirrors the counter done bit, the ticket dispenser checks ENTRY_LOOP AND NOT TICKET_PULLED AND NOT FULL, the gate-raise rung adds TICKET_PULLED AND NOT FULL, and a TON close-delay drives the gate-lower rung with reverse-priority on ENTRY_LOOP. You can write and run exactly this car parking PLC program in the browser scenario on this page.

How do you build a car parking system using a PLC?

A car parking system using a PLC is built around occupancy tracking and gate sequencing: loop detectors sense cars entering and leaving, a CTUD counter holds the live occupancy, a FULL output locks out new entries at capacity, and an interlocked up/down gate motor pair (as mutually exclusive SET/RESET latches) raises and lowers the barrier with a timed close-delay and a reverse-priority safety. Build it counter-first — the live simulator on this page grades the counter, the motor interlock and the reverse-priority logic with five automated test cases.

Ready to build this?

Sign up free — no credit card required. This scenario requires the Basic plan.

Sign up to play this scenario →

Already have an account? Log in