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.
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
- Popular Resources
- Popular amplifiers
- A review of learning-based camera and lidar simulation methods for autonomous driving systems
- Control strategies for advanced driver assistance systems and automated driving functions
- Brakes, brake control and driver assistance systems (BOSCH)
- Key technologies for inverter control of new energy access to smart grids
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- CATL releases October battle report
- Battery industry in October 2024: growth momentum remains unabated!
- Mercedes-Benz will launch the eCitaro equipped with NMC4 batteries to provide high energy density and long life
- Many companies have announced progress on solid-state batteries. When will solid-state batteries go into mass production?
- Xsens Sirius Series Inertial Sensors Enable 3D Inertial Navigation in Harsh Environments
- Infineon's Automotive Landscape: From Hardware to Systems
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- [Popular Science] The difference between microwave radar sensing and human infrared sensing
- FPGA to SD card storage
- What is the difference between NFC and Bluetooth?
- Creative Modification Competition: The moderator gave me two booster boards, and I used both of them.
- Award-winning live broadcast: Graphical interface facilitates rapid development, this is the MSP430 general-purpose MCU you want! Registration is open~
- Comparison of response time between Toshiba photorelay and mechanical relay
- A Practical BOOST Circuit
- A brief talk about RISC-V GCC: Linker script learning notes (Part 2)
- Dad’s logic: Buying a car is like finding a partner~~
- PCB Design Issues