[Graduation project] 15-MCU-based traffic light system design (schematic diagram, simulation, source code project + answer essay + answer PPT)
Article Directory
mission statement
This design is based on the traffic light control system design of the single-chip microcomputer, through the control of the traffic light and time display device set at the intersection, it provides convenience for the passage of pedestrians and vehicles.
1. Design a timer or use a related timing chip to provide a time reference signal for the system.
2. According to the time signal, the single-chip microcomputer controls the on and off of the indicator light to control the passage of vehicles and pedestrians, and displays the time information at the same time.
3. Design related hardware circuits
4. Links to self-designed software programming materials Schematic
diagram
project files
Schematic diagram screenshots
Simulation model project files Simulation screenshots
design manual
Summary
Urban traffic has become an indispensable part of our life, and with the continuous development of society, traffic will become a key research topic. How to unblock traffic, prevent road traffic jams, casualties, and control of traffic accidents are the main research directions at present. With the in-depth research and development of micro-control technology, electronic technology and computer system, it must be a development trend to apply it to traffic management. Aiming at this phenomenon, this system designs a transportation system based on single-chip microcomputer.
This design uses AT89C51 single-chip microcomputer as the control core of the system, which mainly includes the main control module, traffic light indicator module, display module and button module. When the system is working, according to the working mode set by the buttons, the main control module starts the internal timer and starts to control the working status of the traffic lights at different intersections. When the timing is completed, the control system issues a switching command to control the switching status of the traffic lights at different intersections, so as to control the traffic conditions at different intersections. When the system is running, the digital tube displays the time of each intersection. In order to facilitate the operator to know the working mode of the system, an additional display is added to display the working mode of the system.
This design has the advantages of simple system structure, stable system performance, low cost, etc., and can better realize the traffic control function of the traditional traffic light system.
Design framework
Preface 1
Chapter 1 Introduction 2
Section 1 Research background 2
Section 2 Research status and development trend at home and abroad 2 Section 3
Significance of traffic light research 4
Section 4 Main research content of this paper 4
Section 5 Summary of this chapter 5
Second Chapter System Overall Scheme Design 6
Section 1 Traffic Light System Working Principle 6
Section 2 System Overall Structure Design 6
Section 3 Traffic Light Status Logic Scheme Determination 8
Section 4 Summary of This Chapter 9 Chapter
3 Traffic Light System Hardware Circuit Design
10 Section 1 Main Control Module Circuit Design 10
1. Single Chip Microcomputer Introduction 10
2. Minimum System Circuit Design 11 Section
2 Button Module Circuit Design 12 Section 2
Display Module Circuit Design 13
1. Digital Tube Display Circuit Design 13
2. LED Red, Yellow and Green Lights Circuit Design 14
Section 4 Power Circuit Design 15
Section 5 System General Circuit Diagram 15
Section 6 Summary of This Chapter 16
Chapter 4 System Software Design 18
Section 1 System Main Program Design 18
Section 2 Display Module Software Design 19
1. Digital tube Program Design 19
2. Program Design of Traffic Signal Light Status 20
Section 3 Button Module Software Design 21
Section 4 Summary of This Chapter 22
Chapter 5 System Debugging and Simulation 23
Section 1 Development Tools 23
1. Protues Software Introduction 23
2. Keil Software Introduction 24
Section 2 System Function Debugging 24
1. System Simulation Circuit Design 24
2. System Function Test 26
4. Test Summary 28
Section 3 Chapter Summary 29
Conclusion 30
Acknowledgments 31
References 32 Appendix
34
1. English original text 34
2. English translation 37
3. Overall circuit diagram 39
4. Source code 40
Design instructions and design documents
Word count: 19236 words
Source code display
/*****************************************************
十字路口交通灯控制 C 程序
******************************************************/
#define uchar unsigned char
#define uint unsigned int
#include <reg52.h>
/*****定义控制位**********************/
sbit Time_Show_LED2=P2^5;//Time_Show_LED2控制位
sbit Time_Show_LED1=P2^4;//Time_Show_LED1控制位
sbit EW_LED2=P2^3; //EW_LED2控制位
sbit EW_LED1=P2^2; //EW_LED1控制位
sbit SN_LED2=P2^1; //SN_LED2控制位
sbit SN_LED1=P2^0; //SN_LED1控制位
sbit SN_Yellow=P1^6;//SN黄灯
sbit EW_Yellow=P1^2;//EW黄灯
sbit EW_Red=P1^3;//EW红灯
sbit SN_Red=P1^7;//SN红灯
sbit EW_ManGreen=P3^0;//EW人行道绿灯
sbit SN_ManGreen=P3^1;//SN人行道绿灯
sbit Special_LED=P2^6;//交通正常指示灯
sbit Busy_LED=P2^7;//交通繁忙指示灯
sbit Nomor_Button=P3^5;//交通正常按键
sbit Busy_Btton=P3^6;//交通繁忙按键
sbit Special_Btton=P3^7;//交通特殊按键
sbit Add_Button=P3^3;//时间加
sbit Reduces_Button=P3^4;//时间减
bit Flag_SN_Yellow; //SN黄灯标志位
bit Flag_EW_Yellow;//EW黄灯标志位
char Time_EW;//东西方向倒计时单元
char Time_SN;//南北方向倒计时单元
uchar EW=60,SN=40,EWL=19,SNL=19; //程序初始化赋值,正常模式
uchar EW1=60,SN1=40,EWL1=19,SNL1=19;//用于存放修改值的变量
uchar code table[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};//1~~~~9段选码
uchar code S[8]={0X28,0X48,0X18,0X48,0X82,0X84,0X81,0X84};//交通信号灯控制代码
/**********************延时子程序************************/
void Delay(uchar a)
{
uchar i;
i=a;
while(i--){;}
}
/*****************显示子函数**************************/
void Display(void)
{
char h,l;
h=Time_EW/10;
l=Time_EW%10;
P0=table[l];
EW_LED2=1;
Delay(2);
EW_LED2=0;
P0=table[h];
EW_LED1=1;
Delay(2);
EW_LED1=0;
h=Time_SN/10;
l=Time_SN%10;
P0=table[l];
SN_LED2=1;
Delay(2);
SN_LED2=0;
P0=table[h];
SN_LED1=1;
Delay(2);
SN_LED1=0;
h= EW1/10;
l= EW1%10;
P0=table[l];
Time_Show_LED1=1;
Delay(2);
Time_Show_LED1=0;
P0=table[h];
Time_Show_LED2=1;
Delay(2);
Time_Show_LED2=0;
}
/**********************外部0中断服务程序************************/
void EXINT0(void)interrupt 0 using 1
{
EX0=0; //关中断
if(Add_Button==0) //时间加
{
EW1+=5;
SN1+=5;
if(EW1>=100)
{
EW1=99;
SN1=79;
}
}
if(Reduces_Button==0) //时间减
{
EW1-=5;
SN1-=5;
if(EW1<=40)
{
EW1=40;
SN1=20;
}
}
if(Nomor_Button==0)//测试按键是否按下,按下为正常状态
{
EW1=60;
SN1=40;
EWL1=19;
SNL1=19;
Busy_LED=0;//关繁忙信号灯
Special_LED =0;//关特殊信号灯
}
if(Busy_Btton==0) //测试按键是否按下,按下为繁忙状态
{
EW1=45;
SN1=30;
EWL1=14;
SNL1=14;
Special_LED=0;//关特殊信号灯
Busy_LED=1;//开繁忙信号灯
}
if(Special_Btton==0)//测试按键是否按下,按下为特殊状态
{
EW1=75;
SN1=55;
EWL1=19;
SNL1=19;
Busy_LED=0;//关繁忙信号灯
Special_LED =1;//开特殊信号灯
}
EX0=1;//开中断
}
/**********************T0中断服务程序*******************/
void timer0(void)interrupt 1 using 1
{
static uchar count;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
count++;
if(count==10)
{
if(Flag_SN_Yellow==1) //测试南北黄灯标志位
{SN_Yellow=~SN_Yellow;}
if(Flag_EW_Yellow==1) //测试东西黄灯标志位
{EW_Yellow=~EW_Yellow;}
}
if(count==20)
{
Time_EW--;
Time_SN--;
if(Flag_SN_Yellow==1)//测试南北黄灯标志位
{SN_Yellow=~SN_Yellow;}
if(Flag_EW_Yellow==1)//测试东西黄灯标志位
{EW_Yellow=~EW_Yellow;}
count=0;
}
}
/*********************主程序开始**********************/
void main(void)
{
Busy_LED=0;
Special_LED=0;
IT0=1; //INT0负跳变触发
TMOD=0x01;//定时器工作于方式1
TH0=(65536-50000)/256;//定时器赋初值
TL0=(65536-50000)%256;
EA=1; //CPU开中断总允许
ET0=1;//开定时中断
EX0=1;//开外部INTO中断
TR0=1;//启动定时
while(1)
{ /*******S0状态**********/
EW_ManGreen=0; //EW人行道禁止
SN_ManGreen=1;//SN人行道通行
Flag_EW_Yellow=0; //EW关黄灯显示信号
Time_EW=EW;
Time_SN=SN;
while(Time_SN>=5)
{P1=S[0]; //SN通行,EW红灯
Display();}
/*******S1状态**********/
P1=0x00;
while(Time_SN>=0)
{Flag_SN_Yellow=1; //SN开黄灯信号位
EW_Red=1; //SN黄灯亮,等待左拐信号,EW红灯
Display();
}
/*******S2状态**********/
Flag_SN_Yellow=0; //SN关黄灯显示信号
Time_SN=SNL;
while(Time_SN>=5)
{P1=S[2];//SN左拐绿灯亮,EW红灯
Display();}
/*******S3状态**********/
P1=0x00;
while(Time_SN>=0)
{Flag_SN_Yellow=1; //SN开黄灯信号位
EW_Red=1; //SN黄灯亮,等待停止信号,EW红灯
Display();}
/***********赋值**********/
EW=EW1;
SN=SN1;
EWL=EWL1;
SNL=SNL1;
/*******S4状态**********/
EW_ManGreen=~EW_ManGreen;//EW人行道通行
SN_ManGreen=~SN_ManGreen;//SN人行道禁止
Flag_SN_Yellow=0; //SN关黄灯显示信号
Time_EW=SN;
Time_SN=EW;
while(Time_EW>=5)
{P1=S[4]; //EW通行,SN红灯
Display();}
/*******S5状态**********/
P1=0X00;
while(Time_EW>=0)
{Flag_EW_Yellow=1;//EW开黄灯信号位
SN_Red=1;//EW黄灯亮,等待左拐信号,SN红灯
Display();}
/*******S6状态**********/
Flag_EW_Yellow=0; //EW关黄灯显示信号
Time_EW=EWL;
while(Time_EW>=5)
{P1=S[6];//EW左拐绿灯亮,SN红灯
Display();}
/*******S7状态**********/
P1=0X00;
while(Time_EW>=0)
{Flag_EW_Yellow=1; //EN开黄灯信号位
SN_Red=1;//EW黄灯亮,等待停止信号,SN红灯
Display();}
/***********赋值**********/
EW=EW1;
SN=SN1;
EWL=EWL1;
SNL=SNL1;
}
}