The following is my thesis. The countdown is made by LED, and the traffic lights are made by LED.
Cut it yourself in there.
Design of traffic lights controlled by single chip microcomputer
Paper catalogue
I. Abstracts, keywords and references
Second, the scheme design and demonstration
Three. Text: 1. Function description
Secondly, the design of the hardware circuit of the system.
Thirdly, the design of the main program of the system
Four. General schematic diagram of circuit
Verb (abbreviation for verb) main program
Summary:
The system consists of single chip microcomputer, keyboard, LED display screen and traffic light demonstration system. This paper designs a traffic management system for vehicles and pedestrians at intersections. The system includes the functions of turning left and right, and driving basic traffic lights. The time board shows the remaining time of traffic transfer at the intersection. In case of emergency, the traffic can manually realize the state of prohibiting vehicles from passing and allowing pedestrians to pass. In addition, when special vehicles such as 1 19 and 120 pass through the intersection, the system can automatically switch to the state of allowing special vehicles to pass and prohibiting other vehicles from passing. After 15s, the system will automatically resume normal management. Other functions include traffic management conversion between 84s and 60s. The display mode of combining digital tube and dot matrix LED requires not only countdown digital output, but also status light output.
Key words:
Single chip microcomputer system (AT89C5 1) controls 8255, traffic rules, LED display, dynamic scanning, key input, and adjustment in different time periods.
Reference: Guide to Curriculum Design of Single Chip Microcomputer, Beijing University of Aeronautics and Astronautics Press.
Application design of single chip microcomputer principle based on MCS-5 1 series, National Defense Industry Press.
"Single Chip Microcomputer Training Course" Peking University Publishing House
Principle and application of single chip microcomputer system
Principle and application of microcomputer
Second, the scheme design and demonstration
1 power supply scheme:
The scheme adopts independent regulated power supply, which is stable and reliable, and there are many mature circuits to choose from.
2 display interface scheme
The method of combining digital tube and dot matrix LED is adopted, because in practice, it is necessary to count down both the donor output and the status light output. In order to view and consider the actual situation conveniently, digital tube and LED are used to display the time and prompt information respectively. This scheme not only meets the functional requirements of the system, but also reduces the complexity of system implementation.
3 input scheme
Connect the keyswitch directly to the IO port. Because the circuit has been simplified and optimized in the design, there are still many resources left.
4 Main control schemes
Taking AT89C5 1 single chip microcomputer as the controller, 8255 is controlled to realize the traffic countdown, and a single LCD dot matrix display is used to indicate the left, right, straight and pedestrian traffic. This scheme takes up the least number of MCU ports and less hardware. The power consumption is also extremely small;
System frame diagram
Upper guide bearing
First, the function description
The system consists of single chip microcomputer system, keyboard, light emitting diode and traffic light display system. Single-chip microcomputer is used as the main controller to manage the traffic of vehicles and pedestrians at the intersection. There are four traffic lights in each direction: left, right, straight and pedestrian, and the time board shows the remaining time of traffic conversion at the intersection. In addition, when special vehicles such as 1 19 and 120 pass through the intersection, the system can automatically switch to the state of allowing special vehicles to pass and prohibiting other vehicles from passing. After 15s, the system will automatically resume normal management. It also has the function of manually controlling the traffic management transition between 84s and 60s in different time periods.
Secondly, the design of the hardware circuit of the system.
The whole circuit system consists of control system module, traffic light output control display module, time display module, time display module and automatic special vehicle control module.
1, master control system
The P0 port of MCU is used to control 8255. The PA port and PB port of 8255 are used to control the traffic lights in the east, west, north and south. The PC port and P3.0~P3.2 ports are used for the control of four groups of 2-bit LED timers. External interrupt 1 port (P3.3) is used when special vehicles pass, and P 1.0 button is used for manual automatic conversion.
Select the working mode 0 of 8255. In this case, all three ports can be programmed as input and output.
2. Traffic light output control
Traffic lights at intersections indicate the use of high-brightness red and green LEDs, one turning left, one going straight, one turning right and one pedestrian. When the luminous current is 6mA, according to the formula R=(5- 1.8)/0.006, the current limiting resistance should be 510 Ω. Since the two-way signs are the same when passing north and south, each port should have the current absorption capacity of 12mA. Figure 7.4 shows the circuit diagram of the indicator lamp.
3. Time display module
The remaining time of crossing the road is displayed by bright red 7-segment LED light-emitting digital tube and by * * * positive digital tube. If it is driven by single chip microcomputer to absorb current, the column scanning drive is driven by triode. If the figure "8" is fully displayed, each digital tube needs 6mA×8=48mA. Because the time shows that each crossing is the same, four groups need 192mA, so the medium power transistor 90 12 is used in the design. Because each decoding output port of the single chip microcomputer needs to absorb 24mA of current, the driver integrated block 74HC244 is also used in the circuit design. Shows the driving circuit as shown in the figure.
4. Automatic control module for special vehicles
Automatic street lights can automatically turn off all green lights when special vehicles arrive and let special vehicles pass. In the design, infrared generator is used as the generator of special vehicles, and real-time interruption is used to affect the traffic requirements of special vehicles. The infrared receiver generally adopts the integrated infrared receiver for TV, which has high sensitivity and strong anti-interference ability.
5. Power supply circuit
Because the power supply voltage used by the whole system needs +5V, the requirements of the system power supply can be met by using the non-adjustable three-terminal regulator and the commonly used lm7850. LM7850 three-terminal integrated regulated power supply consists of eight parts: quasi-voltage circuit, constant current source, over-current protection, over-voltage protection and short-circuit protection circuit. It has the advantages of low power consumption, high efficiency, small ripple coefficient and stable output voltage.
Thirdly, the design of the main program of the system
The program of intersection traffic control system is mainly divided into the following modules: initialization program, main program, timed interruption program and real-time response program of special vehicles.
1, initialization program
The initialization program mainly completes the temporary storage of memory, the setting of timer working mode and interrupt mode. Because there are many subroutine calls, the stack pointer is set to 80H during initialization. Timers T0 and T 1 are set to 16-bit timer mode, the timing bit is 50ms for counting seconds, and T 1 is used for flashing at the end of traffic.
2. Main program
The main program should be responsible for the overall program management function and realize the man-machine exchange setting. Because the time is dynamically scanned and displayed, the main program calls the scanning and displaying program most of the time. The main program flow chart is shown below.
3. External interrupt 1 interrupt service program
When passing by, the car emits an infrared signal, which is received by the receiver on the crossing control panel and outputs a low-level external interrupt 1. The flow chart of the interrupt handler is shown in the following page.
4. Timed service interruption program
Sequence is mainly used for traffic indication of traffic and pedestrians. According to the traffic rules, the logic table of traffic light control conversion is listed in Table 7. 1.
Control function of north and south ports120 ~1/kloc-0 ~ 70s70 ~ 60s60 ~10s.
P*.7 left transition red 0 0 0 1 1.
P*.6 Turn left and turn green11100/1
P*.5 Direct Red 1 1 1 000
P*.4 Go straight green 0 0 0/ 1 1 1
P*.3 Turn right at the red light 0111/
P*.2 Turn right and turn green 1 0 0 0/ 1.
P*. 1 pedestrian red11000
P*.0 pedestrian green 0 0 0/ 1 1 1
Cross control word 66H 6AH 6AH/7BH 99H 99H/DDH
East-west direction P*.7 turn left and the red light is 0 0 0 0 0.
P*.6 Turn left and turn green1111.
P*.5 Direct Red 0 0 0 0 0
P*.4 Go straight green11111
P*.3 Turn right at the red light 0111
P*.2 Turn right and turn green 1 0 0 0/ 1.
P*. 1 pedestrian green 0 0 0 0 0
P*.0 pedestrian red1111
Cross control word 55H 59H 59H 59H 59H 59H/5DH
The traffic rules are as follows:
(1) Vehicles go straight north and south, turn right in all directions, and pedestrians pass north and south. North-south transit time 1min, each right turn lags behind the straight line 10s.
(2) Vehicles turn left from north to south, all roads turn right, and pedestrians are prohibited. The transit time is 1 min.
(3) Vehicles go straight east and west, turn right in all directions, and the traffic flows east and west to pedestrians. East-west transit time 1min, each right turn lags behind the straight line 10s.
(4) Vehicles turn left from east to west, all roads turn right, and pedestrians are prohibited. The transit time is 1 min.
The traffic rules in the table are realized by sending control codes to control traffic lights. Its principle is to turn the lights on and off at various intersections according to different traffic rules into port control codes of single chip microcomputer. Its indicator function is realized by T0 timer interrupt service program.
The timer T0 counts to obtain the interruption period of 1 0 ms. When the interruption is accumulated for 20 times (i.e. 1), the countdown unit of 120s is operated by subtracting1. In the design, four traffic rules are divided into different lighting modes, and different control data codes are sent to the control port in different time periods by querying the data of the second countdown unit. The control code is divided into five time periods: 84-74 seconds, 74-58 seconds, 58-48 seconds, 48-10-0 and10-0. The flow chart of traffic management timing function program is shown in the following page.
5. Debugging and performance analysis
In the design, the test is carried out according to the red and green traffic light control procedures and special vehicle interruption procedures.
1, red and green traffic light control program
Timer T0, directly according to the data code calculated in Table 7. 1, sends out the control lamp to observe whether its logic state meets the requirements. Debugging can be repeated many times until the logical relationship is correct. It is worth noting that the indicators in the north-south direction and the east-west direction should be debugged at the same time.
2. Debugging of infrared detection circuit when special vehicles pass.
Put an infrared emitting module on the simulation car, and connect the input end of the oscilloscope to the output pin of the infrared receiving module of the traffic light to detect whether the car receives infrared when passing through the intersection. If the output of this pin is low, it means that the signal can be received and the circuit is normal.
This system takes AT89C5 1 single chip microcomputer as the core, and uses W78E5 16B for online programming and modification in the debugging stage of the development program, which can greatly speed up the debugging progress. The designed traffic lights can be used for traffic management of vehicles and pedestrians at intersections, and the display adopts 2-bit 7-segment digital tubes, which can directly display the switching time of traffic lights. Two countdown display modes are adopted in the design. 84S countdown is suitable for cities with heavy traffic, and 60s countdown can be used for small and medium-sized cities. It has complete functions, not only the indication function of ordinary traffic lights, but also the automatic passage function of special vehicles. Its control function and effect are completely consistent with the real intersection management traffic lights.