Detailed Analysis of Mitsubishi PLC Traffic Light Control Program – Comparison of Two Methods

Detailed Analysis of Mitsubishi PLC Traffic Light Control Program

Statement List (STL) Format – Two Programming Methods for Automatic Control of Intersection Traffic Lights

1. System Overview

This article uses the Mitsubishi PLC Statement List (STL) format to write a traffic light control program for intersections, providing two different implementation methods. The system controls the traffic signals for east-west and north-south directions, operating in a preset time sequence.

Control Requirements

  • East-West Direction: Green light for 25 seconds → Yellow light for 5 seconds → Red light for 30 seconds
  • North-South Direction: Red light for 30 seconds → Green light for 25 seconds → Yellow light for 5 seconds
  • Total Cycle Period: 60 seconds

I/O Allocation Table

Address Function Description
X0 Start Button System Start Signal
Y0 East-West Green Light Control East-West Green Light
Y1 East-West Yellow Light Control East-West Yellow Light
Y2 East-West Red Light Control East-West Red Light
Y3 North-South Red Light Control North-South Red Light
Y4 North-South Green Light Control North-South Green Light
Y5 North-South Yellow Light Control North-South Yellow Light

2. Method 1: Timer Control Method

Program Structure and Principle

This method uses multiple timers to directly control the state transitions of each light, with each time period using an independent timer. When the timer reaches its set time, it triggers a state transition.

Statement List Program Code

//==========================================

// Mitsubishi PLC Traffic Light Control Program – Timer Method

// Using FX Series PLC, Statement List (STL) format

//==========================================

// System Start Control

LD X0// Load Start Button Signal

OR M0// Or Run Flag

ANI T5// And Not Cycle End Flag

OUT M0// Output to Run Flag// East-West Green Light Timer (25 seconds)

LD M0// Load Run Flag

OUT T0 K250// Start East-West Green Light Timer, Set Value 250 (25 seconds)

// East-West Yellow Light Timer (5 seconds)

LD T0// Load East-West Green Light Timer Contact

OUT T1 K50// Start East-West Yellow Light Timer, Set Value 50 (5 seconds)

// East-West Red Light Timer (30 seconds)

LD T1// Load East-West Yellow Light Timer Contact

OUT T2 K300// Start East-West Red Light Timer, Set Value 300 (30 seconds)

// North-South Red Light Timer (30 seconds)

LD T2// Load East-West Red Light Timer Contact

OUT T3 K300// Start North-South Red Light Timer, Set Value 300 (30 seconds)

// North-South Green Light Timer (25 seconds)

LD T3// Load North-South Red Light Timer Contact

OUT T4 K250// Start North-South Green Light Timer, Set Value 250 (25 seconds)

// North-South Yellow Light Timer (5 seconds)

LD T4// Load North-South Green Light Timer Contact

OUT T5 K50// Start North-South Yellow Light Timer, Set Value 50 (5 seconds)

// East-West Green Light Output Control

LD M0// Load Run Flag

AND T0// And East-West Green Light Timer

ANI T1// And Not East-West Yellow Light Timer

OUT Y0// Output to East-West Green Light

// East-West Yellow Light Output Control

LD M0// Load Run Flag

AND T1// And East-West Yellow Light Timer

ANI T2// And Not East-West Red Light Timer

OUT Y1// Output to East-West Yellow Light

// East-West Red Light Output Control

LD M0// Load Run Flag

AND T2// And East-West Red Light Timer

ANI T0// And Not East-West Green Light Timer

OUT Y2// Output to East-West Red Light

// North-South Red Light Output Control

LD M0// Load Run Flag

AND T3// And North-South Red Light Timer

ANI T4// And Not North-South Green Light Timer

OUT Y3// Output to North-South Red Light

// North-South Green Light Output Control

LD M0// Load Run Flag

AND T4// And North-South Green Light Timer

ANI T5// And Not North-South Yellow Light Timer

OUT Y4// Output to North-South Green Light

// North-South Yellow Light Output Control

LD M0// Load Run Flag

AND T5// And North-South Yellow Light Timer

ANI T3// And Not North-South Red Light Timer

OUT Y5// Output to North-South Yellow Light// Cycle Reset Control

LD T5// Load North-South Yellow Light Timer Contact

RST T0// Reset East-West Green Light Timer

RST T1// Reset East-West Yellow Light Timer

RST T2// Reset East-West Red Light Timer

RST T3// Reset North-South Red Light Timer

RST T4// Reset North-South Green Light Timer

RST T5// Reset North-South Yellow Light Timer

// ================ Program End ================

Note:The time base for Mitsubishi FX series PLC timers is 0.1 seconds, so the set value K250 corresponds to 25 seconds, K50 corresponds to 5 seconds, and K300 corresponds to 30 seconds.

3. Method 2: 0.1 Second Timer + Counter Comparison Method

Program Structure and Principle

This method uses a 0.1-second base timer in conjunction with a counter to achieve state switching by comparing the count value. Each 0.1-second timer triggers once, incrementing the counter by 1, and the output is controlled based on the current time point determined by comparison instructions.

Statement List Program Code

//==========================================

// Mitsubishi PLC Traffic Light Control Program – Counter Comparison Method// Using FX Series PLC, Statement List (STL) format

//==========================================

// System Start Control

LD X0// Load Start Button Signal

OR M0// Or Run Flag

ANI C0// And Not Counter Completion Flag

OUT M0// Output to Run Flag// 0.1 Second Base Timer

LD M0// Load Run Flag

OUT T0 K1// Start 0.1 Second Base Timer

// 60 Second Cycle Counter

LD T0// Load 0.1 Second Timer Contact

OUT C0 K600// Start 60 Second Cycle Counter, Set Value 600 (60 seconds)

// Counter Reset Control

LD C0// Load Counter Completion Contact

RST C0// Reset Counter

// East-West Green Light Output Control (0-25 seconds)

LD M0// Load Run Flag

AND <=C0 K250// And Counter Value ≤ 250 (25 seconds)

OUT Y0// Output to East-West Green Light

// East-West Yellow Light Output Control (25-30 seconds)

LD M0// Load Run Flag

AND >C0 K250// And Counter Value > 250 (25 seconds)

AND <=C0 K300// And Counter Value ≤ 300 (30 seconds)

OUT Y1// Output to East-West Yellow Light

// East-West Red Light Output Control (30-60 seconds)

LD M0// Load Run Flag

AND >C0 K300// And Counter Value > 300 (30 seconds)

OUT Y2// Output to East-West Red Light

// North-South Red Light Output Control (0-30 seconds)

LD M0// Load Run Flag

AND <=C0 K300// And Counter Value ≤ 300 (30 seconds)

OUT Y3// Output to North-South Red Light

// North-South Green Light Output Control (30-55 seconds)

LD M0// Load Run Flag

AND >C0 K300// And Counter Value > 300 (30 seconds)

AND <=C0 K550// And Counter Value ≤ 550 (55 seconds)

OUT Y4// Output to North-South Green Light

// North-South Yellow Light Output Control (55-60 seconds)

LD M0// Load Run Flag

AND >C0 K550// And Counter Value > 550 (55 seconds)

OUT Y5// Output to North-South Yellow Light

// ================ Program End ================

Time Setting Reference Table

Time Period Counter Range East-West Direction North-South Direction Comparison Value
0-25 seconds C0 ≤ 250 Green Light Red Light K250
25-30 seconds 250 < C0 ≤ 300 Yellow Light Red Light K300
30-55 seconds 300 < C0 ≤ 550 Red Light Green Light K550
55-60 seconds 550 < C0 ≤ 600 Red Light Yellow Light K600

Note:The counter C0’s counting range is 0-600, corresponding to 0-60 seconds. Each count value represents 0.1 seconds, so K600 corresponds to 60 seconds.

4. Comparison Analysis of Two Methods

Advantages and Disadvantages of Timer Method

Advantages:

  • Logic is intuitive, easy to understand and debug
  • Each time period is independently controlled, flexible to modify
  • Suitable for beginners to learn and use

Disadvantages:

  • Uses a larger number of timers
  • Program is relatively lengthy
  • Occupies more resources

Advantages and Disadvantages of Counter Comparison Method

Advantages:

  • Program structure is concise and compact
  • Only uses one timer and one counter
  • Occupies fewer resources, high efficiency
  • Time adjustments are convenient, only need to modify comparison values

Disadvantages:

  • Logic is relatively complex, requires calculation of comparison values
  • Not as intuitive as timer method during debugging
  • Higher requirements for programmers

5. Practical Application Recommendations

  • Small Systems: It is recommended to use the timer method for easier maintenance and modification
  • Large Systems: It is recommended to use the counter method to save PLC resources
  • High Time Precision Requirements: The counter method provides more precise time control
  • Frequent Timing Adjustments: The counter method is more convenient for modifications

》》》》》》》》》》》》》》Previous Reviews《《《《《《《《《《《《《《1. Detailed Explanation of Interrupt Control in Mitsubishi PLC2. Detailed Explanation of Floating Point Applications in Mitsubishi PLC3. Closed-loop Control System for Constant Pressure Water Supply Using Mitsubishi FX Series PLC with Analog Modules4. Detailed Explanation of Data Types and Array Types in Mitsubishi FX Series PLC5. Detailed Explanation of CC-Link Communication Technology in Mitsubishi Q Series PLC6. Detailed Explanation of Controlling Inverters via RS485 RTU Communication with Mitsubishi FX3U7. Detailed Explanation of Modbus Communication Protocol8. Detailed Explanation of ST Language Instructions in Omron NJ Series PLC9. Socket Communication Guide for Omron NJ Series PLC10. Programming Guide for Function Blocks (FB) in Omron NJ Series PLC》》》》》》》》》》》》》》END《《《《《《《《《《《

Leave a Comment