A traffic light PLC program is a ladder logic or structured text routine that cycles a programmable logic controller’s outputs through red, yellow, and green states with precise timing. Most programs use internal timers (TON or TOF) and a counter or a sequence shift register to step through the light phases, with the PLC’s scan cycle updating the outputs each pass.
Background: Why PLCs Control Traffic Lights
Before PLCs, traffic lights ran on electromechanical cam timers—motor-driven drums with cams that closed contacts at set intervals. Those worked but were hard to retime, bulky, and wore out. PLCs arrived in the late 1960s for factory automation, and by the 1970s municipalities began using them for intersections because they offered:
- Easy timing changes in software instead of rewiring
- Multiple timing plans for peak vs. off-peak hours
- Integration with vehicle detection loops and pedestrian push buttons
- Diagnostics and remote monitoring via SCADA
Today, most modern intersections use specialized traffic controllers (like NEMA TS-2 or ITS cabinets) that are essentially PLCs with traffic-specific firmware, but generic PLCs are still used in training, small intersections, and simulation projects.
How a Basic Traffic Light PLC Program Works
A standard four-way intersection with two roads (North/South and East/West) has 8 lamp outputs (or 4 if using 3-lamp heads per direction). The typical sequence is:
- NS Green, EW Red (e.g., 10 seconds)
- NS Yellow, EW Red (3 seconds)
- NS Red, EW Green (10 seconds)
- NS Red, EW Yellow (3 seconds)
In ladder logic, you can implement this with four timer instructions (TON) and a counter, or with a sequencer instruction if your PLC supports it. A simple method uses a counter that increments every second and a set of comparison instructions to determine which phase is active. For example, with a 1-second pulse generator (using a TON that toggles a bit), a counter counts from 0 to 25. Then:
- If count 0–9 → NS Green ON, EW Red ON
- If count 10–12 → NS Yellow ON, EW Red ON
- If count 13–22 → NS Red ON, EW Green ON
- If count 23–25 → NS Red ON, EW Yellow ON
When the counter reaches 25, it resets to 0. This is a clean, scalable method.
Choosing PLC Hardware and Software
For a real intersection, you need a PLC with at least 8 discrete outputs (relay or solid state) and enough inputs for pedestrian push buttons and vehicle detectors. Common choices for training or small projects:
- Allen-Bradley MicroLogix or CompactLogix (RSLogix/Studio 5000)
- Siemens S7-1200 (TIA Portal)
- Modicon M221 (EcoStruxure)
- AutomationDirect Click or Productivity (free software)
For simulation only, you can use PLC simulation software or even an Arduino with a PLC-like shield, but that is not a real PLC. When selecting, consider the number of I/O, the programming environment’s cost, and whether you need Ethernet for remote monitoring.
Common Programming Mistakes and How to Avoid Them
New programmers often make these errors:
- Forgetting to reset timers – TON timers need a reset condition; otherwise they stay done.
- Output overlap – Ensure only one color per direction is on at a time; use interlocking logic (e.g., NS Green is not on if NS Red is on).
- Scan cycle issues – If you use a counter that increments on every scan, it will run too fast. Use a timed pulse (e.g., 1 second) to increment.
- Not accounting for all states – During startup or reset, all outputs might be off, causing a dark intersection. Add a power-up default state (e.g., NS Red, EW Green).
A robust program uses a state machine pattern: each state has an entry condition, a timer, and a transition to the next state. This avoids complex comparison logic and is easier to debug.
Real-World Extensions: Sensors, Pedestrians, and Coordination
Basic fixed-time control is fine for isolated intersections, but real systems need:
- Vehicle detection – Inductive loops or cameras feed inputs to extend green if traffic is present.
- Pedestrian push buttons – When pressed, the program shortens the green and adds a pedestrian walk phase.
- Coordination – Multiple intersections are synchronized using time-of-day plans or GPS-based clocks (e.g., using NTP).
- Preemption – Emergency vehicle or transit priority can override normal sequencing.
These features require additional logic, but the core timing structure remains the same.
Safety and Reliability Considerations
Traffic signals are safety-critical. A PLC program must include fail-safe features:
- Conflict monitoring – If two conflicting greens are detected (e.g., NS and EW both green), the controller should go to flashing red or all-red.
- Watchdog timer – If the PLC stops scanning, a hardware watchdog should force a safe state.
- Redundancy – Many jurisdictions require redundant controllers or at least a backup plan.
- Power loss behavior – On restart, the program should start in a safe state (e.g., all red for a few seconds) before cycling.
Always follow local traffic signal standards (e.g., MUTCD in the US) and consult a licensed traffic engineer for real installations.
Alternatives to PLCs for Traffic Control
While PLCs are common, other technologies exist:
- Specialized traffic controllers – These are purpose-built computers with traffic-specific firmware (e.g., Econolite, Siemens). They are easier to configure for complex intersections.
- Microcontrollers (Arduino, Raspberry Pi) – For hobby projects or prototyping, they are cheap and flexible, but not suitable for safety-critical real-world use without extensive hardening.
- Relay logic – Older systems, still in some rural areas, but hard to modify.
For learning, a PLC simulator or a small PLC with a demo board is the best balance of realism and safety.
Frequently Asked Questions
What ladder logic instructions are used for a traffic light?
Typically, TON (timer on-delay) and CTU (count up) are used. For a simple two-phase light, you might use two timers: one for green duration, one for yellow. A counter can also be used to cycle through states.
How do I make a traffic light PLC program for a 4-way intersection?
Define a sequence of states (NS green, NS yellow, EW green, EW yellow) and use a timer for each state. When a timer finishes, transition to the next state and reset the previous timer. Ensure output interlocking to prevent conflicts.
Can I simulate a traffic light PLC program without hardware?
Yes. Most PLC software includes built-in simulation (e.g., Studio 5000 Logix Emulate, TIA Portal PLCSIM). You can also use third-party simulators like PLCLogix or online ladder logic simulators.
What is the difference between a PLC and a traffic signal controller?
A traffic signal controller is a specialized PLC with pre-programmed traffic functions, such as coordination, preemption, and conflict monitoring. It is designed to meet transportation standards, whereas a general-purpose PLC requires you to implement those functions yourself.
How do I handle pedestrian push buttons in a PLC program?
Add a digital input for the push button. When pressed, set a latch (or use a pulse) to request a pedestrian phase. The program then shortens the current green, transitions to yellow, then red, and activates the walk signal (a separate output) for a set time before returning to normal.
What is a safe default state for a traffic light PLC on power-up?
All-red (or flashing red) for a few seconds is the safest. Many controllers start with all red for 2–5 seconds, then begin the normal cycle. This prevents any conflicting greens from appearing during startup.
Related
- SPLIT Function in Google Sheets: How to Use It
- Shortcut Keys Save As: The Full Guide
- Is SELECT a Clause in SQL? Yes, Here’s Why
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Add Chapter Page Numbers in Word: A Step-by-Step GuideTo add chapter page numbers in Word, format your chapter titles with the numbered Heading 1 style, then…
- How to Run Goal Seek in Excel to Find a Target ValueTo run Goal Seek in Excel for Microsoft 365 on Windows, select the cell containing the formula you…
- Commercial Invoice Template in Excel: What to IncludeYes—you can make a commercial invoice template in Microsoft Excel by setting up seller and buyer details, shipment…
- Excel Print Zoom to Fit Page: Setup and Common FixesTo make an Excel worksheet fit on one printed page in Microsoft 365 for Windows, select the sheet,…
- Google Sheets COUNTIF: Count Cells Containing TextWith the text to check in A2:A100, count cells containing a word or phrase anywhere in the cell…
- How to Show Negative Numbers in Brackets in ExcelTo show negative numbers in brackets in Excel without changing their values, select the cells, press Ctrl+1, choose…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.