Design of Traffic Light Control System Based on Single Chip Microcomputer

Publisher:phi31Latest update time:2022-03-28 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This system uses STC89C51 single-chip microcomputer and single-chip microcomputer minimum system and 74HC245 drive circuit as well as peripheral buttons and digital tube display components to design a traffic light design based on single-chip microcomputer. The design uses a two-in-one common cathode digital tube display and can set the timing through buttons.

This design can simulate the basic traffic control system, using red, green and yellow lights to indicate the occurrence of no-go, go and wait signals, and can also display countdown. The buttons can control the no-go, late night mode, reset, east-west traffic, north-south traffic, time addition, time subtraction, switching and other functions.


There are four two-digit cathode digital tubes, one for each of the east, south, west and north to display the time. The cathodes of the four digital tubes are connected to the P1 port of the STC89C51, and the anodes are connected to the 74HC245 chip. The 74HC245 chip is controlled through the P0 port to play a driving and amplifying role. There are 12 light-emitting diodes in total, and each of the four intersections has a red (no entry) and yellow (warning) light-emitting diode. The diodes of the four intersections are connected to the P2 port, and the buttons are connected to the P3 port.


It is located at the intersection, divided into east-west and north-south directions. At any time, only one direction is open, and the other direction is prohibited. This lasts for a certain period of time. After a short transition period, the direction of traffic is reversed. Its specific status is shown in the figure below. Note: Black means on, and white means off. The traffic state changes from state 1 to state 6 and then cycles to state 1, and repeats until state 6 and then cycles to state 1. Through the demonstration and analysis of the specific state of the traffic light at the intersection, we can summarize these four states as follows:

The red light in the east-west direction is off and the green light is on at the same time, and the yellow light in the north-south direction is off and the red light is on at the same time, with a countdown of 20 seconds. In this state, east-west traffic is prohibited, while north-south traffic is allowed.


The green light in the east-west direction is off, the yellow light is on, and the red light in the north-south direction is on, with a countdown of 5 seconds. In this state, all vehicles except those that are already passing need to wait for the state to change.


The red light in the north-south direction is off and the green light is on at the same time, and the yellow light in the east-west direction is off and the red light is on at the same time, with a countdown of 30 seconds. In this state, east-west traffic is allowed, while north-south traffic is prohibited.


The green light in the north-south direction is off, the yellow light is on, and the red light in the east-west direction is on, with a countdown of 5 seconds. In this state, all vehicles except those that are already passing need to wait for the state to change.

Display module function


The display module is divided into digital tube display and LED display. The digital tube countdown display can remind the driver to make the appropriate choice between "stop" and "go" when the signal light changes color. Drivers and pedestrians are generally willing to choose the signal control method with countdown display, and believe that intersections with countdown display are safer.


The countdown display is a method used to reduce the complex judgments that drivers have to make at the critical moment when the traffic light changes color. It can remind the driver when the light color changes and help the driver make the appropriate choice between "stop" and "go". The combination of the two displays makes this design more reasonable and reliable.


Button module function


This system requires few key controls and has enough I/O ports, so it can be directly used in an independent style. The key can set the system's operating status. The prohibited status is when all digital tubes display "00" and all red lights are on; the reset key can reset the entire system; the east-west traffic is when the green light is on in the east-west direction and the red light is on in the north-south direction; the north-south traffic is when the green light is on in the north-south direction and the red light is on in the east-west direction; the time addition and subtraction can set the time for passing and waiting for passing; the switch key can switch the direction of addition and subtraction. Through the control of the security inspection module, the entire system is flexible and practical.


Basic structure and principle


Improve the quality and efficiency of traffic in the same time. And adjust the traffic time of main and secondary roads according to the actual situation in peak hours by combining the equation control button to reduce traffic congestion. And make the traffic control system have emergency control, so that when ambulances pass, the red lights in both directions will be turned on. After the ambulances and fire trucks pass, the lights will be restored to the original state, increasing the ability to handle special situations.


This single-chip microcomputer controls the traffic light system. The single-chip microcomputer can directly control the state change of the signal light, which can basically direct the specific passage of traffic. Of course, the LED digital tube can be connected to display the countdown to remind the traffic person, which is more humane. Based on this, the single-chip microcomputer of this system performs specific processing and adjusts the control command in time.


The keyboard setting module inputs the system mode selection and specific traffic time setting signals, and the system enters the normal working state, executes the traffic light status display control, and inputs the time data countdown to the LED digital tube for real-time display. In this process, it is also necessary to capture the violation detection and emergency key signal in real time to achieve the purpose of real-time control of abnormal status. Emergency stop button and violation detection can be called interrupt at any time.

Design of the Minimum System of Single Chip Microcomputer

STC89C51 has 4 8-bit parallel I/O ports, denoted as P0, P1, P2, and P3. Each port contains a latch, an output driver, and an input buffer. In fact, they have been classified as special registers and have byte addressing and bit addressing functions. When accessing the off-chip extended memory, the lower 8-bit address and data are transmitted by the P0 port in time-sharing, and the higher 8-bit address is transmitted by the P2 port. In a system without an off-chip extended memory, each of these 4 ports can be used as a bidirectional I/O port.

Signal display drive circuit design


The 74HC245 decoder accepts 3-bit binary weighted address inputs (A0, A1, and A2) and, when enabled, provides 8 mutually exclusive low-active outputs (Y0 to Y7). The 74HC245 features 3 enable inputs: two low-active (E1 and E2) and one high-active (E3). The 74HC138 will hold all outputs high unless E1 and E2 are set low and E3 is set high.


By using this composite enable feature, only four 74HC245 chips and one inverter are needed to easily achieve parallel expansion and combine them into a 1-32 (5-line to 32-line) decoder. By selecting any low-active enable input as the data input and the remaining enable inputs as the strobe, the 74HC245 can also act as an 8-output multiplexer. The unused enable inputs must be kept bound to their appropriate high-active or low-active states.


The working principle of 74HC245 is used in high-performance storage decoding or data transmission systems that require short transmission delay time. In high-performance storage systems, using this decoder can improve the efficiency of the decoding system. When the fast enable circuit is used for high-speed memory, the delay time of the decoder and the enable time of the memory are usually less than the typical access time of the memory, which means that the effective system delay caused by the Schottky clamped system decoder can be ignored.


HC138 decodes a low-level output from 8 output terminals according to the three-bit binary input code and enable input conditions. Two low-level effective enable input terminals and one high-level effective enable input terminal reduce the external gates or inverters required for expansion. No external gates are required to expand into a 24-line decoder; only one external inverter is needed to expand into a 32-line decoder. In demodulator applications, the enable input terminal can be used as a data input terminal.


 

In the design, pin 1 is connected to VCC and pin 19 is grounded. The entire chip has a high output when the input is high, and a low output when the input is low. This is just a driving function.


Keyboard input circuit design


The implementation method of the independent keyboard is to use the level of the microcontroller I/O port to read the port to determine whether a key is pressed. One end of the normally open key is grounded and the other end is connected to an I/O port. When the program starts, this I/O port is set to a high level. When no key is pressed, the I/O port protects the high level.


When a key is pressed, the I/O port is short-circuited to the ground, forcing the I/O port to be at a low level. After the key is released, the pull-up resistor inside the microcontroller keeps the I/O port at a high level. All we have to do is to check the level of the I/O port in the program to know whether we have pressed a key.

Program main body design


The entire control program is actually divided into several modules: keyboard setting processing program, status light control program, LED display program, de-jitter delay program, sub-state judgment and processing program, emergency stop or violation judgment program, interrupt service subroutine, vehicle flow counting program, traffic light time adjustment program, etc. The entire software program is mainly divided into two parts: key processing program and 50ms scanning program.

[1] [2]
Reference address:Design of Traffic Light Control System Based on Single Chip Microcomputer

Previous article:Design of digital calendar system based on single chip microcomputer
Next article:Design of intelligent temperature control fan system based on single chip microcomputer

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号