
PLC Programming Exercise – Traffic Light Control System
Introduction
In this exercise, we will design and implement a PLC-based traffic light control system using a ladder logic program. The goal is to control a three-way traffic light system with Red, Yellow, and Green lights, simulating a real-world intersection.
Learning Objectives
By completing this exercise, you will:
- Understand basic PLC programming concepts and ladder logic.
- Learn how to use timers and counters in PLC programming.
- Develop logic to control a sequential system.
- Simulate and test a traffic light control system.
Tools and Components
To complete this exercise, you will need:
- A PLC with a programming environment (e.g., Siemens TIA Portal, Allen-Bradley RSLogix, or any compatible software)
- PLC simulator (if no physical PLC is available)
- Input/output (I/O) devices including three output lamps (Red, Yellow, Green) and one start push button.
Background & Definitions
- PLC (Programmable Logic Controller): An industrial computer used to automate electromechanical processes.
- Ladder Logic: A graphical programming language that represents electrical control circuits.
- Timers (TON/TOF): Used to introduce delays in the execution of logic.
- Counters (CTU/CTD): Used to count the number of events or cycles.
Step-by-Step Guide
Step 1: Define System Operation
The traffic light should follow a predefined sequence:
- Green ON for 10 seconds
- Yellow ON for 3 seconds
- Red ON for 10 seconds
- Repeat cycle continuously The system should start when a push button is pressed.
Step 2: Assign I/O Addresses
- Start Button: I0.0
- Green Light: Q0.0
- Yellow Light: Q0.1
- Red Light: Q0.2
Step 3: Implement Ladder Logic
- Initialize System: Use a push button to trigger the cycle and a memory coil (M0.0) to latch the system ON.
- Green Light Timer (T1): Set a TON (Timer ON Delay) with 10 seconds duration. When the timer expires, activate the yellow light.
- Yellow Light Timer (T2): Set another TON with 3 seconds delay. Once expired, switch to red light.
- Red Light Timer (T3): Set a TON with 10 seconds delay. When completed, reset to green light, restarting the cycle.
Step 4: Ladder Logic Code
| I0.0 M0.0 |
|----| |--------( )----|
| M0.0 T1 |
|----| |--------TON T1, 10s----|
| T1 Q0.0 |
|----|/|--------( )----| (Green ON)
| T1 T2 |
|----| |--------TON T2, 3s----|
| T2 Q0.1 |
|----|/|--------( )----| (Yellow ON)
| T2 T3 |
|----| |--------TON T3, 10s----|
| T3 Q0.2 |
|----|/|--------( )----| (Red ON)
| T3 M0.0 |
|----| |--------( )----| (Restart Cycle)
Step 5: Simulation and Testing
- Run the program in the PLC simulator.
- Observe the timing of each light and verify the correct sequence.
- Press the start button to initiate the cycle.
- Adjust timer values to test different timing scenarios.
Common Issues & Troubleshooting
- If lights are not changing, check if timers are triggering correctly.
- If the sequence stops unexpectedly, verify the latching condition of M0.0.
- If timers are not working, ensure correct addressing and time settings.
Extensions & Modifications
- Implement a pedestrian crossing button that extends the red light duration.
- Add a flashing yellow light during off-peak hours.
- Integrate a real-time clock (RTC) for automatic mode switching.
Conclusion
By completing this exercise, you have learned how to implement a basic traffic light control system using PLC programming. This exercise enhances your understanding of sequential control logic, timers, and ladder logic programming.