PLC Case Study: Parking Lot Counting Made Easy with Increment/Decrement Instructions

PLC Case Study: Parking Lot Counting Made Easy with Increment/Decrement Instructions

In the daily management of small parking lots, manually counting parking spaces is not only inefficient but also often leads to issues such as “allowing cars in after full capacity” and “delayed notifications for available spaces”.

By using an increment/decrement counter combined with sensors and a three-color light system, we can achieve automatic +1 for incoming cars, automatic -1 for outgoing cars, and precise alerts for parking space status. This setup corresponds perfectly with the actual points and program logic, allowing for quick implementation with ease and accuracy.

1. Control Requirements of the Case

1. Automatic Counting: The “incoming car detection sensor” triggers an automatic +1 for parking space count; the “outgoing car detection sensor” triggers an automatic -1 for parking space count;

2. Manual Control: Supports a “reset parking count” button to clear the current parking space count, and a “set total parking spaces button” to quickly set the total number of parking spaces (default is 50);

3. Tiered Alarms:

  • When the current parking spaces = 50 (full capacity), the “full capacity red light” turns on, indicating no entry for cars;

  • When the current parking spaces ≤ 40, the “available space green light” turns on, indicating that cars can enter;

  • When the current parking spaces < 10, the “tight space yellow light” turns on, providing an early warning of insufficient parking spaces.

2. Actual Points and Variable Table

PLC Case Study: Parking Lot Counting Made Easy with Increment/Decrement Instructions

3. Program Writing in One Step

The core logic: Use an increment/decrement counter (CTUD) to achieve parking space statistics, linking the three-color light system through value comparison instructions, while also implementing edge detection to avoid duplicate counting.

Operation Steps:

1. Counting Trigger Processing:

  • Add a rising edge (P_TRIG) processing to the signal from the “incoming car detection sensor”, connecting the trigger signal to the “CU terminal” (counting up terminal) of the increment/decrement counter, ensuring that each incoming car triggers +1 only once;

  • Add a rising edge (P_TRIG) processing to the signal from the “outgoing car detection sensor”, connecting the trigger signal to the “CD terminal” (counting down terminal) of the increment/decrement counter, ensuring that each outgoing car triggers -1 only once.

2. Counter Parameter Configuration:

  • Press the “reset parking count” button, connecting the signal to the “R terminal” (reset terminal) of the counter, clearing the current value (CV) of the counter;

  • Press the “set total parking spaces button”, connecting the signal to the “LD terminal” (load terminal) of the counter, while setting the “PV terminal” (preset value) to 50, completing the total parking space setting.

3. Tiered Alarm Logic:

  • Use the “equals instruction” to check if the current value (CV) of the counter = 50, triggering the “full capacity red light alarm”;

  • Use the “less than or equal to instruction” to check if the current value (CV) of the counter ≤ 40, triggering the “available space green light prompt”;

  • Use the “less than instruction” to check if the current value (CV) of the counter < 10, triggering the “tight space yellow light alarm”.

PLC Case Study: Parking Lot Counting Made Easy with Increment/Decrement Instructions

4. Core Logic (Two Points for Beginners)

1. Rising Edge to Prevent False Counting: When the sensor detects a vehicle, signal jitter may occur. By adding rising edge processing, counting is triggered only at the moment the signal transitions from “0 to 1”, preventing a single vehicle from triggering multiple +1/-1 counts;

2. Bidirectional Statistics of the Increment/Decrement Counter: The CTUD counter supports both “CU terminal counting up” and “CD terminal counting down”, perfectly matching the scenario of “incoming car +1, outgoing car -1” without needing additional logic.

Learn technology solidly, improve a little every day! Do my best to help more people!

Leave a Comment