Design of intelligent control system for traffic lights
[Copy link]
1. Overview At present, an information revolution led by microelectronics technology, computer and communication technology, centered on information technology and information industry is in the ascendant worldwide. How to combine computer technology with practical applications more effectively and play its role effectively is the hottest topic in the scientific community and an unprecedentedly active field in computer applications today. This paper mainly uses the application of single-chip microcomputers to realize the intelligent management of traffic lights at intersections to control the normal operation of passing vehicles. 2. Process Analysis Figure 1 is a schematic diagram of an intersection. 1 , 2 , 3 , and 4 are used to indicate the main lanes of the four directions, and A , B , C , and P are used to represent the left lane, straight lane, right lane, and sidewalk of each main lane. A , b , c , and p are used to represent the traffic lights for left turn, straight, right turn, and sidewalk, respectively, as shown in Figure 2 . The process of traffic lights flashing: the situation of all indicator lights when the car at intersection 1 goes straight is: 3a3b2p green 3c red + 4a4b4c 3p all red + 1c green 1a1b4p red + 2c green 2a2b1p red The situation of all indicator lights when the car at intersection 2 goes straight is: 4a4b3p green 4c red + 1a1b1c 4p all red + 2c green 2a2b1p red + 3c green 3a3b2p red Therefore, the situation of all indicator lights when the car at intersection 3 goes straight is: 1a1b4p green 1c red + 2a2b2c 1p all red + 3c green 3a3b2p red + 4c green 4a4b3p red Therefore, the situation of all indicator lights when the car at intersection 4 goes straight is: 2a2b1p green 2c red + 3c3a3b2p all red + 4c green 4a4b3p red + 1c green 1a1b4p red
Figure 1 : Traffic diagram of the intersection
Figure 2 : Schematic diagram of the traffic sequence at the intersection
Figure 3 : Schematic diagram of traffic lights at an intersection
Figure 4 : Traffic light control system hardware block diagram
3. Hardware Design This system uses AT89C52 single-chip microcomputer and programmable parallel interface chip 8155 to control the four combinations shown in Figure 2. AT89C52 single-chip microcomputer has MCS-51 core, 8KB Flash , 256 bytes RAM , 6 interrupt sources, 1 serial port, and the highest operating frequency can reach 24MHz , which can fully meet the needs of this system ; compared with other control methods, the devices used can be said to be relatively simple and economical.
4. Software Flowchart
Figure 5 : Traffic light control system flow chart
5. Traffic light control system software
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN:
MOV SP,#60H
; LCALL DIR ; Call date and time display subroutine
LOOP:
MOV P1,#0FFH
LJMP TEST
LCALL ROAD1 ; When the car at intersection 1 goes straight, the lights at each intersection are on
LCALL DLY30s ; Delay 30 seconds
MOV P1,#0FFH ; Restore P1 port to high level
LCALL RESET ; Restore 8155 ports to high level
LCALL YELLOW1 ; When the car at intersection 1 goes straight --> When the car at intersection 2 goes straight, the yellow light is on LCALL DLY5s ; Delay 5 seconds LCALL RESET ; Restore 8155 ports to high level MOV P1,#0FFH ; Restore P1 port LCALL ROAD2 ; When the car at intersection 2 goes straight, the lights at each intersection are on LCALL DLY30s ; Delay 30 seconds LCALL RESET ; Restore 8155A and B ports to high level ?
MOV P1,#0FFH ; Restore P1 port to high level LCALL YELLOW2 ; The car at intersection 2 goes straight --> The car at intersection 3 goes straight and the yellow light is on LCALL DLY5s ; Delay 5 seconds LCALL RESET ; Restore 8155A and B ports to high level ?
MOV P1,#0FFH ; Restore P1 port to high level LCALL ROAD3 ; When the car at intersection 3 goes straight, the lights at each intersection are on LCALL DLY30s ; Delay 30 seconds LCALL RESET ; Restore 8155A and B ports to high level ?
MOV P1,#0FFH ; Restore P1 port to high level LCALL YELLOW3 ; The car at intersection 3 goes straight --> The car at intersection 4 goes straight and the yellow light is on LCALL DLY5s ; Delay 5 seconds LCALL RESET ; Restore 8155 ports to high level MOV P1,#0FFH ; Restore P1 port high level LJMP TEST
LCALL ROAD4 ; When the car at intersection 4 goes straight, the lights at each intersection are on LCALL DLY30s ; Delay 30 seconds SETB P1.5 ; Restore P1.5 high level SETB P1.4 ; Restore P1.4 high level MOV DPTR,#0FFFFH ; Restore 8155 ports to high level LCALL YELLOW4 ; The car at intersection 4 goes straight -->
The yellow light is on when the car goes straight at intersection 1LCALL DLY5s; delay 5 seconds SETB P1.6; restore P1.6 high level SETB P1.3; restore P1.3 high level MOV DPTR,#0FFFFH; restore each port of 8155 to high level LJMP LOOP
; when the car goes straight at intersection 1 , the lights of each intersection are on 3a3b2p green 3c red + 4a4b4c3p all red + 1c green 1a1b4p red + 2c green 2a2b1p red ROAD1:
MOV DPTR,#7F00H; set the address of 8155 command port; irrelevant bits are 1 ) MOV A,#03H; output from port A and port B , port A and port B are basic input and output mode MOVX @DPTR,A; write the working mode control word INC DPTR; point to port AMOV A,#79H ;1a1b4p red 1c green 2a2b1p red MOVX @DPTR,A
INC DPTR ; point to port B MOV A,#0E6H ;3a3b2p green 3c red 4a4b3p red MOVX @DPTR,A
MOV P1,#0DEH ;4c red 2c green
RET
6. Conclusion This system has a simple structure and is easy to operate. It can realize automatic control and has a certain degree of intelligence. It is of certain significance to optimize urban traffic.This design subdivides and packages each task to keep each task relatively independent. It can effectively improve the program structure and facilitate modular processing, so that the readability, maintainability and portability of the program are further improved. 6. References [1] Han Tailin, Li Hong, Yu Lintao; Principles and Applications of Single-Chip Microcomputers (3rd Edition ). Publishing House of Electronics Industry, 2005
[2] Liu Leshan, Ouyang Xingming, Liu Xueqing; Microcomputer Interface Technology and Application. Huazhong University of Science and Technology Press, 2003
[3] Hu Hancai; Principles and Interface Technology of Single-Chip Microcomputers. Tsinghua University Press, 2000
|