Proteus7.7+Keil2 simulation 80C51 control intersection signal light (with left turn signal light)

Publisher:BlossomJoyLatest update time:2021-08-04 Source: eefocusKeywords:proteus7  7  80C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In order to design a traffic light with a left turn signal at an intersection, one must first thoroughly understand the control logic of the circular traffic light.


In the design process of this example, I designed the signal control logic of this intersection: north-south straight-through release -> east-west straight-through release -> north-south left turn release -> east-west left turn release. If the display problem of the digital tube is not considered, it is only necessary to slightly modify the control program of the circular signal light. However, in actual applications, most intersections are equipped with digital display digital tubes to display the countdown seconds of the red, yellow and green lights in the straight direction to improve traffic efficiency - so it is very necessary to add the countdown display function to the design.


I drew the complete signal control logic as the following diagram.


In actual programming, since I did not fully understand the control logic at the beginning, the control program I wrote was completed by patching up the circular signal control system, which was somewhat accidental. When analyzing this example, I suggest that you first thoroughly understand the control logic, and then ignore the countdown display. After confirming that the design is correct, add the countdown display function. In addition, I have sent all the files of this example design to my resource area, and you are welcome to download and use it.

#include

#include

 

void delay()//delay 0.5s

{

short i, j;

for(i=0;i<124;i++)

for(j=0;j<500;j++)

;

}

void delay_night()//delay 1s

{

short i, j;

for(i=0;i<248;i++)

for(j=0;j<500;j++)

;

}

void main()

{

short int t=0, t1=0, t2=0; //t1 is responsible for timing the straight signal, t2 is responsible for timing the left turn signal, and t is responsible for the display of the digital tube

 

   P0=0;

P1=0;

   P2=0;

P3=0;

while(1)

{

//Straight module, in this module, the left turn signals in the north-south and east-west directions are all red

P0=0x12;

//Green light cycle in north-south direction

P2=0x14; //Green light on in north-south direction + red light on in east-west direction

t1=35;

while(t1>=0)

{

P1=t1/2/10*pow(2,4)+t1/2%10; //North-South direction digital tube setting

P3=(t1/2+3)/10*pow(2,4)+(t1/2+3)%10; //Set the digital tube in the east-west direction

if(t1<=5) //The green light in the north-south direction lasts for 3 seconds

{

if(t1%2!=0)

{

P2=0x10; //Green light in north-south direction is off + red light in east-west direction is on

}

else

{

P2=0x14; //Green light on in north-south direction + red light on in east-west direction

}

}

delay();

t1--;

}

// Yellow light cycle in north-south direction

P2=0x12; // Yellow light on in north-south direction + red light on in east-west direction

t1=5;

while(t1>=0)

{

P1=t1/2/10*pow(2,4)+t1/2%10; //North-South direction digital tube setting

P3=t1/2/10*pow(2,4)+t1/2%10; //Set the digital tube in the east-west direction

delay();

t1--;

}

//Red light cycle in north-south direction (need to add the time for turning left in both directions)

P2=0x41; //Red light on in the north-south direction + green light on in the east-west direction

t1=77;

t=t1+88; //The north-south digital tube displays 88=41+5+39+3

while(t1>=0)

{

if(t1/2>2)

{

P1=t/2/10*pow(2,4)+t/2%10; //North-South direction digital tube setting

P3=(t1/2-3)/10*pow(2,4)+(t1/2-3)%10; //Set the digital tube in the east-west direction

if(t1/2<=5) //The green light in the east-west direction lasts for 3 seconds

{

if(t1%2!=0)

{

P2=0x01; //Red light on in the north-south direction + green light off in the east-west direction

}

else

{

P2=0x41; //Red light on in the north-south direction + green light on in the east-west direction

}

}

}

else //Red light on in north-south direction + yellow light on in east-west direction

{

P2=0x21; //Red light on in the north-south direction + yellow light on in the east-west direction

P1=t/2/10*pow(2,4)+t/2%10; //North-South direction digital tube setting

P3=t1/2/10*pow(2,4)+t1/2%10; //Set the digital tube in the east-west direction

}

delay();

t1--;

t--;

}

 

//Left turn module, during which the lights for north-south and east-west directions are all red

P2=0x11; //Change the light for driving in the east-west direction to red P24=1, and change the light for driving in the north-south direction to red P20=1

//Green light cycle in north-south direction

P0=0x18; //Green light on in north-south direction + red light on in east-west direction P03=1, P04=1

t2=41;

while(t2>=0)

{

if(t2<=5) //The green light in the north-south direction lasts for 3 seconds

{

if(t2%2!=0)

{

P0=0x10; //Green light in north-south direction is off + red light in east-west direction is on

}

else

{

P0=0x18; //Green light on in north-south direction + red light on in east-west direction

}

}

P1=t/2/10*pow(2,4)+t/2%10; //North-South direction digital tube setting

P3=(t+46)/2/10*pow(2,4)+(t+46)/2%10; //Set the digital tube in the east-west direction

delay();

t2--;

t--;

}

// Yellow light cycle in north-south direction

P0=0x14; // Yellow light on in north-south direction + red light on in east-west direction P02=1, P04=1

t2=5;

while(t2>=0)

{

P1=t/2/10*pow(2,4)+t/2%10; //North-South direction digital tube setting

P3=(t+46)/2/10*pow(2,4)+(t+46)/2%10;;//Set the digital tube in the east-west direction 46=41+5

delay();

t2--;

t--;

}

//Red light cycle in north-south direction

P0=0x42; //Red light on in north-south direction + green light on in east-west direction P01=1, P06=1

t2=39;

while(t2>=0)

{

if(t2/2>2)

{

if(t2/2<=5) //The green light in the east-west direction lasts for 3 seconds

{

if(t2%2!=0)

{

P0=0x02; //Red light on in the north-south direction + green light off in the east-west direction

}

else

{

P0=0x42; //Red light on in the north-south direction + green light on in the east-west direction

}

}

}

else //Red light in north-south direction is on + yellow light in east-west direction is on P01=1, P05=1

{

P0=0x22; //Red light on in north-south direction + yellow light on in east-west direction

}

P1=t/2/10*pow(2,4)+t/2%10; //North-South direction digital tube setting

P3=(t+46)/2/10*pow(2,4)+(t+46)/2%10; //Set the digital tube in the east-west direction

delay();

t2--;

t--;

}

}

}

Keywords:proteus7  7  80C51 Reference address:Proteus7.7+Keil2 simulation 80C51 control intersection signal light (with left turn signal light)

Previous article:8051 single chip microcomputer (STC89C52) eight-segment digital tube displays 0~7 in turn
Next article:proteus7.7+Keil2 simulation 80C51 control intersection signal light (no green light countdown + green light countdown

Recommended ReadingLatest update time:2024-11-16 20:52

Global smartphone shipments fell 23% year-on-year in Q2, and 70% of 5G smartphone revenue came from China
According to the latest smartphone market report released by Counterpoint Research, the average selling price of smartphones in the second quarter of 2020 increased by 10% year-on-year. At the same time, smartphone shipments fell by 23% year-on-year, reaching a record high. The entire smartphone industry is expected t
[Mobile phone portable]
Application Case Analysis of Siemens S7-1500
S7-1500CPU generally does not have high-speed pulse counting, so a high-speed counting module must be selected. The most commonly used module is TMcount2X24, which provides two 24V high-speed pulse acquisition signals. Two high-speed pulse acquisition channels are a bit rare in general project applications.
[Embedded]
Application Case Analysis of Siemens S7-1500
Moto E7 core specifications revealed: Snapdragon 632 processor + 2GB memory
      As the successor of the Moto E6 launched last year, the entry-level Moto E7 recently appeared on the Google Play Console and revealed some key specifications, including memory, system, screen resolution, chipset, etc. Unfortunately, the website does not provide renderings of the phone.   According to the listi
[Mobile phone portable]
Received a 1 billion yuan order from a terminal company: Visionox suffered a huge loss of over 700 million yuan in the first half of the year!
Jiwei.com reported on July 14 that according to Visionox's first-half performance forecast, the company lost 720 million to 850 million yuan in the first half of the year, compared with a profit of 92 million yuan in the same period last year! 该公司介绍,报告期内,维信诺坚持技术创新,紧跟客户需求,在屏下摄像、高刷新率、柔性穿戴等领域不断实现技术突破;通过加强供应链管理,推进原材料国产化,以
[Mobile phone portable]
32-bit intelligent microcontroller AT91SAM7S512-AU data sheet
    AT91SAM7S512-AU Description     Controller series/series: AT91SAM7xxxx     Core size: 32bit     Number of inputs/outputs: 32     Program memory size: 512 KB     Memory capacity, RAM: 64KB     Processor speed: 55MHz     Oscillator Type: External, Internal     Number of timers: 3     Peripheral dev
[Microcontroller]
SIMATIC S7-1500 data block introduction and its application (1)
Introduction to Data Block (DB) (1) Introduction to Data Block (DB) Data blocks are used to store user data and program intermediate variables. When a new data block is created, the default state is the optimized storage mode, and the variables stored in the data block are non-retentive. Data blocks occupy
[Embedded]
SIMATIC S7-1500 data block introduction and its application (1)
Development of NO.7 signaling acquisition card based on PCI bus technology
At present, the NGN network is a complex network with soft switching as the core and PSTN network and VoIP network integrated together. There are multiple interfaces , multiple protocols, and multimedia coexisting. The compatibility of PSTN and VoIP equipment, the compatibility of equipment of different equi
[Analog Electronics]
Development of NO.7 signaling acquisition card based on PCI bus technology
Design of Data Acquisition System Based on ARM7+μC/OSII
In some industrial sites, equipment is prone to failure after long-term operation. In order to monitor these equipment, data acquisition devices are usually used to collect data from them during operation and send them to the PC. The data is analyzed by specific software running on the PC to determine the status of
[Microcontroller]
Design of Data Acquisition System Based on ARM7+μC/OSII
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号