当前位置:网站首页>51 Single Chip Microcomputer Design of traffic light system (with Proteus simulation, C program, schematic diagram, PCB, thesis and other complete data)

51 Single Chip Microcomputer Design of traffic light system (with Proteus simulation, C program, schematic diagram, PCB, thesis and other complete data)

2022-04-23 14:23:00 Jiang Yuzhi

The design requirements
(1) utilize 51 Single chip microcomputer designs a traffic light control system , To realize the diversion of pedestrians and traffic flow . The system is mainly used at intersections , Longitudinal main road , Laterally, it is a branch road ;
(2) Lord 、 Branch roads alternate , The traffic lights on the two main roads work simultaneously , Every time the main road is green 15 second , Every time the branch road is released 10 second , The release time can be changed by pressing the key ;
(3) Every time the green light turns red , The yellow light flashes first 3 second , here , The red light remains on the other main road ;
(4) The function of traffic control at intersections is realized by pressing buttons ;
(5) The structure diagram of the whole system is given 、 Software and hardware flow chart ;

Design Overview
The east-west trunk road and the North-South branch trunk road are controlled by a group of three-color traffic lights , They are the red in the direction of the main road 、 yellow 、 Green and red in the direction of the main road 、 yellow 、 green .

Logical analysis shows that , When the main road is green , Branch roads must be red and forbidden ; After the green light , The main road enters the yellow light flashing waiting state , Branch Road red light ; After the yellow light , The main road turns red and no traffic is allowed , The branch road turns green ; After the green light on the branch road ends , The branch road enters the yellow light flashing waiting state , The main road is red , So circular .

From this process we can see that , Traffic light control is divided into 4 Status , Respectively :S1 state , The main road is the green light , The direction of the branch road is red ;S2 state , The yellow light flashes in the direction of the main road , Branch Road red light ;S3 state , The direction of the main road is red , The direction of the branch road is green ;S4 state , The yellow light flashes in the direction of the branch road , The main road is red . These four states continue to cycle . From this we can list 4 A list of States and make 4 A flow chart of States .
 Insert picture description here

 Insert picture description here
The system has 4 A button , They are the setting keys , Add the key , Minus keys and traffic control keys . The setting key is used to start and confirm the setting , Adding and subtracting keys is to adjust the travel time , The traffic control key is a mandatory setting for the traffic light system .

When the system is powered on or manually reset , In the default mode, it will run according to the parameters recorded in the program before power failure . If the setting key is pressed at this time , Then enter the setting state of traffic time , The time originally recorded is displayed on the nixie tube and flashes , You can add or subtract keys to things 、 The waiting time of the north-south trunk road is modified , After the modification is completed , Press the set key to save the new parameter .

Traffic control key , Used for traffic control at intersections . There are five modes : thing 、 Red light on the North-South main road ; Things are red , North South green light ; Things green , North south red light ; Things green , North South green light ; Things are yellow , North and south yellow lights .

Simulation circuit diagram
 Insert picture description here
 Insert picture description here
Schematic diagram and PCB
 Insert picture description here
 Insert picture description here
Physical drawing of hole board
 Insert picture description here
Analysis of simulation results
In the real traffic lights , It's a vertical operation , The vertical direction is north-south ; In the simulation circuit diagram , From the front view, the vertical is something , It's the same as the real thing when viewed obliquely from the left . therefore , Physical and simulation are one-to-one correspondence !

load “ Based on graduation 51 Single chip microcomputer traffic light design .hex” File to MCU , Click on the run , The traffic lights began to work ( The diode displays red 、 yellow 、 Green tricolor lamp ,LED Show countdown ).

In the program, we set , The green light passing time of the east-west trunk road is 15S, The traffic time of the North-South branch road is 10S. The system automatically enters the state S1: The green light on the East-West main road is on , The red light of the North-South branch road is on .
 Insert picture description here
It can be seen that , The green light passing time of the east-west trunk road is 15S, The waiting time for the red light on the North-South branch road is 15S. thing 、 North south trunk road LED count down 12S after , System entry S2 state : The yellow light on the East-West main road flashes 3S, The red light of the North-South Branch Road .
 Insert picture description here
3S after , System entry S3 state : Red light on the East-West main road , The green light of the North-South green trunk road , The passage time is 10S. The simulation results are as follows .
 Insert picture description here
7S after , System entry S4 state : The yellow light on the north-south trunk road flashes 3S, The east-west trunk road is still red . Then enter S1 state , Keep cycling .
 Insert picture description here
Press down “ Set up ” Post key , The system enters setup mode , adopt “ Add ” Key sum “ reduce ” Key to set the green light passage time of the east-west trunk road . Press again “ Set up ” key , You can set the passage time of the north-south trunk road . After setting the travel time , Press again “ Set up ” key , The system returns to the running state .
 Insert picture description here
 Insert picture description here
As you can see from the picture above , The traffic time of the east-west trunk road is changed from the original 15S Set to 16S. Can pass “ Traffic control ” key , Control the traffic light system .
 Insert picture description here
part C Code

u8 Key_Scan()
{
        
    static u8 key_up=1;// Press the key to release the sign 
    if(key_up&&(Key1==0||Key2==0||Key3==0||Key4==0))
    {
    
        delay_1ms(10);// To shake  
        key_up=0;
        if(Key1==0)         return 1;
        else if(Key2==0)return 2;
        else if(Key3==0)return 3;
        else if(Key4==0)return 4;
    }
    else if(Key1==1&&Key2==1&&Key3==1&&Key4==1)
        key_up=1;       
    return 0;//  No key press 
}


uchar flag_s;
uchar menu_1;// Vertical and horizontal addition and subtraction marks 


/******************** Set function *****************/
void key_with()
{
    
    if(key_can == 4)   // Traffic control button 
    {
    
        flag_jdgz ++;
        if(flag_jdgz > 5)
            flag_jdgz = 0;  
        if(flag_jdgz == 1)   //  All the red lights are on  
        {
    
            dx_red    = 0;  // bright  
            nb_red    = 0;  // bright  
            dx_green  = 1;  // destroy 
            dx_yellow = 1;  // destroy 
            nb_green  = 1;  // destroy 
            nb_yellow = 1;  // destroy  
        }
        if(flag_jdgz == 2)   //  Things green   North south red light 
        {
    
            dx_red    = 0;  // bright  
            nb_green  = 0;  // bright 
            dx_green  = 1;  // destroy 
            dx_yellow = 1;  // destroy 
            nb_red    = 1;  // destroy  
            nb_yellow = 1;  // destroy  
        }
        if(flag_jdgz == 3)   //  North South green light   Things are red 
        {
    
            dx_green  = 0;  // bright 
            nb_red    = 0;  // bright  
            dx_red    = 1;  // destroy  
            dx_yellow = 1;  // destroy 
            nb_green  = 1;  // destroy 
            nb_yellow = 1;  // destroy  
        }
        if(flag_jdgz == 4)   //  North South green light   Things green 
        {
    
            dx_green  = 0;  // bright 
            nb_green  = 0;  // bright 
            dx_red    = 1;  // destroy  
            dx_yellow = 1;  // destroy 
            nb_red    = 1;  // destroy  
            nb_yellow = 1;  // destroy  
        }
        if(flag_jdgz == 5)   //  North and south yellow lights   Things are yellow 
        {
    
            dx_red    = 1;  // destroy  
            dx_green  = 1;  // destroy 
            nb_red    = 1;  // destroy  
            nb_green  = 1;  // destroy 
            nb_yellow = 0;  // bright  
            dx_yellow = 0;  // bright 
        }
    }
    if(key_can == 1)      // Set the key 
    {
    
        menu_1 ++;
        if(menu_1 >= 3)
        {
    
            menu_1  = 0;
        }
    }

    if(menu_1 == 1)    // Set the time of things 
    {
    
        if(key_can == 2)
        {
    
            dx_time ++ ;        // Add 1
            if(dx_time > 99)// The maximum time is 99s
                dx_time = 99;
        }
        if(key_can == 3)
        {
    
            dx_time -- ;        // reduce 1
            if(dx_time <= 5)// The minimum time is 5s
                dx_time = 5;
        }
        dis_smg[0] = DisplayOther[2] ;  // Is shown as B
        dis_smg[1] = DisplayOther[2] ;  // Is shown as B
        dis_smg[2] = smg_du[(dx_time-1) % 10] ;     // When displaying the settings of things 
        dis_smg[3] = smg_du[(dx_time-1) / 10] ; 
    }

    if(menu_1 == 2)    // Set the North-South time 
    {
    
        if(key_can == 2)
        {
    
            nb_time ++ ;        // Add 1
            if(nb_time > 99)    // The maximum time is 99s
                nb_time = 99;
        }
        if(key_can == 3)
        {
    
            nb_time -- ;        // reduce 1
            if(nb_time <= 5)// The minimum time is 5s
                nb_time = 5;
        }
        dis_smg[0] = smg_du[(nb_time-1) % 10] ; // Is shown as A
        dis_smg[1] = smg_du[(nb_time-1) / 10] ; // Is shown as A
        dis_smg[2] = DisplayOther[2] ;      // When displaying the settings of things 
        dis_smg[3] = DisplayOther[2] ;  
    }   

}

The shared resources are
(1) be based on 51 MCU traffic light system graduation design thesis complete version ;
(2)Proteus Simulation file ;
(3)Keil C Program files ;
(4) Reference material ;
(5)Visio flow chart ;
(6)PCB Documents and schematic diagrams ;
(7) Introduction and list of components ;
(8) Reference design 1: Design of traffic lights based on single chip microcomputer ( Another set of traffic light design )

The screenshot of resources is as follows
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
Get the traffic light system design paper 、Proteus Simulation 、C Program 、PCB And schematic diagram 、Visio flow chart 、 A complete set of information such as component list .
Please search WeChat for official account : Jiaoyuan Xiaozhi

版权声明
本文为[Jiang Yuzhi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231412472325.html