[SCM graduation project] [cl-014] Intelligent traffic lights | Intelligent traffic lights | Time-variable traffic lights

1. Basic introduction

Item name:
Design of intelligent traffic light monitoring system based on microcontroller
Design of intelligent traffic light monitoring system based on microcontroller
Design of time-variable traffic light detection system based on microcontroller

Project name: traffic light
Project number: mcuclub-cl-014
Microcontroller type: STC89C52
Specific functions:
1. There are four directions: east, west, north and south. Each direction has a two-digit digital tube and three LED lights (red, green and yellow).
2. You can press the button to set the total time in each direction
3. You can press the button to control the evergreen in a certain direction to clear the road for fire trucks and fire trucks.
4. Use 4 pairs of separate infrared tubes to measure the traffic flow in four directions to automatically adjust the green light time.
5. Use four infrared tubes to detect whether pedestrians run through the red light. If the pedestrian runs through the red light, the buzzer will alarm.

2. Data Overview

Physical information

Please add an image description

Simulation data

Please add an image description

3. Display of some information on 51 microcontroller

1. Physical picture display

Microcontroller model: STC89C52
Power supply interface: TYPE-C
Board type: PCB integrated board, thickness 1.2, two-layer board (upper and lower layers are copper-clad and grounded)
Device type: The components are basically pin type, and some buck chips will use SMD type.

2. Simulation diagram display

Simulation software version: proteus8.9
Circuit connection method: network label connection method
Note: Some physical components are not included in the simulation. They will be replaced by other components with similar working principles in the simulation. This may cause the physical program to be different from the simulation program.

3. Schematic display

Software version: AD2013
Circuit connection method: network label connection method
Note: The schematic diagram only shows the pin diagram of the module, not the internal structure diagram of the module.

4. PCB diagram display

Exported from the schematic diagram, there is a project number in the middle, which is hidden under the base of the microcontroller and will not be seen after inserting the microcontroller.
Two-layer board, top and bottom covered with copper and grounded.

IV. Display of some information on 32 microcontroller

1. Physical picture display

Microcontroller model: STM32F103C8T6
Power supply interface: TYPE-C
Board type: PCB integrated board, thickness 1.2, two-layer board (upper and lower layers are copper-clad and grounded)
Device type: The components are basically pin type, and some buck chips will use SMD type.

2. Schematic display

Software version: AD2013
Circuit connection method: network label connection method
Note: The schematic diagram only shows the pin diagram of the module, not the internal structure schematic diagram of the module.

3. PCB diagram display

Exported from the schematic diagram, there is a project number in the middle, which is hidden under the base of the microcontroller and will not be seen after inserting the microcontroller.
Two-layer board, top and bottom covered with copper and grounded.

5. System block diagram

Drawing software: VISIO

This design uses a single-chip microcomputer as the core controller, plus other modules to form the entire system of the traffic light design, including the central control part, the input part and the output part. The central control part adopts a single-chip microcomputer controller, whose main function is to obtain the data of the input part, and finally control the output part after internal processing and logical judgment. The input consists of four parts. The first part is the infrared tube module, which detects whether someone runs the traffic light; the second part is the infrared counting module, which detects the current vehicles that need to pass; the third part is the button module. You can set the passage time and whether the direction is evergreen; the fourth part is the power supply module, through which the entire system can be powered. The output consists of three parts. The first part is the display module, through which the countdown time of the current traffic light can be displayed; the second part is the indicator module, which indicates the operating status of the current traffic light; the third part is the alarm module. When someone is detected to run through a traffic light, a buzzer alarm will be issued. The specific system block diagram is shown in Figure 3.1.

6. Partial program display

Software version: keil5
Note: The logic program and driver are separated and distributed in main.c and other .c files

*******Display function
*****/
void Display_function(void)
{<!-- -->
switch(flag_display) //Display different interfaces according to different display mode flags
{<!-- -->
case 0: //Interface 0: display countdown time
Tube_Show_Num2(2,time_all);
Tube_Show_Num2(1,time_all);
break;
\t\t
case 1: //Interface 1: Display and set the north and south green light time
Tube_Show_Num2(2,time_NS);
break;
\t\t
case 2: //Interface 2: Display and set the green light time of the east and west
Tube_Show_Num2(1,time_WE);
break;

default:
break;
}
}

/****
*******Handling function
*****/
void Manage_function(void)
{<!-- -->
if(flag_display == 0) //Measurement interface
{<!-- -->
if(flag_mode_NS == 0 & amp; & amp; flag_mode_WE == 0) //Not evergreen mode, normal operation
{<!-- -->
if(flag_exchange == 0) //Green light in east-west direction
{<!-- -->
if(time_all > 5) //If the time is greater than 5s, the green light will turn on, and when a pedestrian runs the red light in the north or south direction, the buzzer will sound for 1s
{<!-- -->
LEDNB_G = 1;
LEDNB_Y = 1;
LEDNB_R = 0;
LEDDX_G = 0;
LEDDX_Y = 1;
LEDDX_R = 1;

if(IR1_N == 1 || IR1_S == 1)
{<!-- -->
timer1_count = 0;
flag_timer_begin_5s = 1;
}
if(flag_timer_begin_5s == 1)
{<!-- -->
if(timer1_count < 10)
BEEP = 1;
else
{<!-- -->
flag_timer_begin_5s = 0;
BEEP = 0;
}
}
}
else //The time is less than or equal to 5s, the yellow light turns on, and when a pedestrian runs the red light in any direction, the buzzer sounds for 1s
{<!-- -->
LEDNB_G = 1;
LEDNB_Y = 1;
LEDNB_R = 0;
LEDDX_G = 1;
LEDDX_Y = 0;
LEDDX_R = 1;

if(IR1_W == 1 || IR1_E == 1 || IR1_N == 1 || IR1_S == 1)
{<!-- -->
timer1_count = 0;
flag_timer_begin_5s = 1;
}
if(flag_timer_begin_5s == 1)
{<!-- -->
if(timer1_count < 10)
BEEP = 1;
else
{<!-- -->
flag_timer_begin_5s = 0;
BEEP = 0;
}
}
}
}
else //green light in north-south direction
{<!-- -->
if(time_all > 5) //If the time is greater than 5s, the green light will turn on, and when a pedestrian runs the red light in the east-west direction, the buzzer will sound for 1s
{<!-- -->
LEDNB_G = 0;
LEDNB_Y = 1;
LEDNB_R = 1;
LEDDX_G = 1;
LEDDX_Y = 1;
LEDDX_R = 0;

if(IR1_W == 1 || IR1_E == 1)
{<!-- -->
timer1_count = 0;
flag_timer_begin_5s = 1;
}
if(flag_timer_begin_5s == 1)
{<!-- -->
if(timer1_count < 10)
BEEP = 1;
else
{<!-- -->
flag_timer_begin_5s = 0;
BEEP = 0;
}
}
}
else //The time is less than or equal to 5s, the yellow light turns on, and when a pedestrian runs the red light in any direction, the buzzer sounds for 1s
{<!-- -->
LEDNB_G = 1;
LEDNB_Y = 0;
LEDNB_R = 1;
LEDDX_G = 1;
LEDDX_Y = 1;
LEDDX_R = 0;

if(IR1_W == 1 || IR1_E == 1 || IR1_N == 1 || IR1_S == 1)
{<!-- -->
timer1_count = 0;
flag_timer_begin_5s = 1;
}
if(flag_timer_begin_5s == 1)
{<!-- -->
if(timer1_count < 10)
BEEP = 1;
else
{<!-- -->
flag_timer_begin_5s = 0;
BEEP = 0;
}
}
}
}
}
else //Evergreen mode, when a pedestrian runs a red light in any direction, the buzzer will sound for 1s
{<!-- -->
if(IR1_W == 1 || IR1_E == 1 || IR1_N == 1 || IR1_S == 1)
{<!-- -->
timer1_count = 0;
flag_timer_begin_5s = 1;
}
if(flag_timer_begin_5s == 1)
{<!-- -->
if(timer1_count < 10)
BEEP = 1;
else
{<!-- -->
flag_timer_begin_5s = 0;
BEEP = 0;
}
}
}
if(IR_N == 1) //The north direction infrared tube is triggered once, the number of vehicles in the north direction + 1
flag_carn = 1;
else
{<!-- -->
if(flag_carn == 1)
{<!-- -->
flag_carn = 0;
car_N + + ;
}
}
if(IR_S == 1) //The infrared tube in the south direction is triggered once, and the number of vehicles in the north direction + 1
flag_cars = 1;
else
{<!-- -->
if(flag_cars == 1)
{<!-- -->
flag_cars = 0;
car_S + + ;
}
}
if(IR_W == 1) //The infrared tube in the west direction is triggered once, and the number of vehicles in the north direction + 1
flag_carw = 1;
else
{<!-- -->
if(flag_carw == 1)
{<!-- -->
flag_carw = 0;
car_W + + ;
}
}
if(IR_E == 1) //The infrared tube in the east-west direction is triggered once, the number of vehicles in the north direction + 1
flag_care = 1;
else
{<!-- -->
if(flag_care == 1)
{<!-- -->
flag_care = 0;
car_E + + ;
}
}
}
}