Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

2021 undergraduate graduation design

Title: Design of traffic light controller based on single


chip microcomputer

Department Name: School of Physics and Communication


Student name: MD MAJADUR RAHMAN (王逸)
Student ID: 201762000142
Instructor: 张国平(Guoping Zhang)
Complete time: 05/12/2021
Statement

This is to certify that the work presented in this thesis is the outcome
of the investigation carried out by MD Majadur Rahman under the
supervision of Prof Guoping Zhang, Professor, Department of School of
Physics and Communication at Jiangxi Normal University (JXNU),
Nanchang, Jiangxi, China.

The results of this graduation project (Thesis) are obtained under the
guidance of the instructor during my study in Jiangxi Normal University,
and the results belong to Jiangxi Normal University
Contents
Abstract............................................................................................................................................ 5
1 Introduction .................................................................................................................................. 6
2 Design requirements .................................................................................................................... 6
3. Project Demonstration ................................................................................................................ 6
3.1 MCU module ......................................................................................................................... 7
3.2 Key Control Module ............................................................................................................. 8
3.3 Display module .................................................................................................................. 8
4 Design Principle ........................................................................................................................... 9
4.1 SCM Module.......................................................................................................................... 9
4.1.1 Introduction of MCU ..................................................................................................... 9
4.1.2 AT89C52 Introduction ................................................................................................... 9
4.1.2 AT89C52 Function Profile ........................................................................................... 10
4.1.3 SCM Minimum System................................................................................................ 11
4.2 74HC245 Driver Module .................................................................................................... 13
4.3 Key module .......................................................................................................................... 14
4.4 Digital Display Module ....................................................................................................... 15
4.5 Traffic light display module ............................................................................................... 17
4.5.1 LED Introduction ......................................................................................................... 17
4.5.2 Traffic lights .................................................................................................................. 18
4.6 Buzzer Alarm Module ......................................................................................................... 18
5 Software components ................................................................................................................. 19
5.1 Introduction to development tools ..................................................................................... 19
5.2 Block diagram ..................................................................................................................... 19
5.2.1 main program box ........................................................................................................ 20
5.2.2 key module block diagram .......................................................................................... 21
5.2.3 timing interrupt block.................................................................................................. 21
6 Debugging and Simulation ........................................................................................................ 22
7 Concluding remarks .................................................................................................................. 24
References ...................................................................................................................................... 25
Appendix I: Circuit diagram ........................................................................................................... 26
Appendix II: Source ........................................................................................................................ 26
抽象的
本方案依靠单片微机洞察交通信号架构,工作共有两个主要观点:普通交通
流,分别控制南北向和东西向的红、绿、黄灯熄灭,南北交叉时 点流量巨大,
可以构建南北衔接的绿灯时间,当东西衔接流量巨大时,可以扩大衔接的绿灯
时间,结束后恢复典型。 该计划以 AT89C52 为中心,完成智能交通信号架构
的计划与执行。 该计划符合巧妙的框架、可靠性和恒定的先决条件。

关键词: AT89C52、交通灯、7SEG-MPX2-CA-BLUE、Respack-8、
arm Keil 和手动设置时间。
Abstract
This plan depends on a solitary chip microcomputer insightful traffic signal
framework, work total two primary viewpoints: ordinary traffic stream, separately
control the north-south and east-west course of red, green, and yellow lights out, When
the north-south crossing point traffic is enormous, can build the north-south
convergence of the green light time, when things convergence traffic is huge, can
expand the convergence of the green light time, back to typical after the end. This plan
AT89C52 is the center, to finish the plan and execution of the clever traffic signal
framework. This plan meets the clever framework, dependability, and constant
prerequisites.

Keyword:AT89C52, Traffic light, 7SEG-MPX2-CA-BLUE, Respack-8, arm


keil and Manually set the time.
1 Introduction
With the advancement of the social economy, the expectation for everyday
comforts of individuals increasingly elevated, vehicle utilization is likewise quick
increment. As indicated by the service of public security traffic the board authority
insights, as of November 27, 2014, hit the 300 million imprint number of engine vehicle
drivers in China, remembering 244 million individuals for vehicle drivers. The public
common engine vehicles have effectively added up to 264 million vehicles, among
them 154 million vehicles. Various drivers on the planet first, vehicle number positions
second just to the United States. Expansion in the quantity of vehicles, street blockage
show up in like manner. Busy time, we have a great deal of time is squandered in rush
hour gridlock, particularly north generally in our country. For every city, tackle the issue
of street blockage, is inescapable.

2 Design requirements
Plan a traffic signal control framework dependent on AT89C52 single-chip
microcomputer, which can understand the reason for walker stream and vehicle stream
control. The framework primarily incorporates a solitary chip PC section, a catch part,
and a showcase part. These three sections together control the showcase and change of
the traffic signals every which way of the street cross bifurcation. The fundamental plan
necessities are as per the following

1. The north-south line is the primary trunk street and the east-west line is the branch
street on the other hand. The traffic signals on the two lines work simultaneously. The
north-south trunk street will be delivered for 15 seconds each time, and the east-west
trunk street will be delivered for 10 seconds each time.

2. The acceptable time can be changed by squeezing the catch.

3. Before every status light changes from green light to red light, the yellow light should
streak for 5 seconds. Right now, the red-light remaining parts on the other principal
street.

4. The traffic light capacity of the fork intersection can be acknowledged by squeezing
the catch.

5. Show digits: 2 digits.

Broadened work: each time the green light finishes, the yellow light glimmers, the bell
sounds alongside the yellow light blazing to help the people on foot to remember
passing vehicle.

3. Project Demonstration
Dissect the issue, and afterward characterize the general square chart of the
framework as per the plan necessities, as demonstrated in Figure 1.
Figure: 1 Block Diagram of SCM

As demonstrated in the schematic square graph of the circuit (Figure 1), with the single-
chip microcomputer as the center, the force supply part is controlled by a 5V force
supply to produce a planning clock, and LED lights are utilized to mimic traffic signal
showcase, which can be consistently changed by the settings and shown by an advanced
cylinder Countdown time and other status show time circumstance. At the point when
the catch is squeezed, the single-chip microcomputer examines the catch and conveys
the catch work, and the catch capacities as per the setting. A one-second hinder is
acknowledged by programming to acknowledge timing. At the point when a specific
mode (night mode) is set to work, it will be joined by a signal notice.

3.1 MCU module


Plan 1: Use 74LS192 counter as the control center of the traffic light framework,
through 4069 NOT entryway and 74LS08 AND door, the state is decoded into the set
number needed by the commencement mini-computer, to understand the set number
control. The red and green lights are consistently lit. This strategy utilizes numerous
and repetitive chips and requires high equipment, bringing about decreased precision
and helpless adaptability.

Plan 2: Use a solitary chip microcomputer as the framework regulator. The single-
chip microcomputer enjoys the benefits of high dependability, great expense adequacy,
low force supply voltage required, and high productivity. Presently it has been broadly
spread and utilized in the hardware business. The single-chip microcomputer has
incredible math and rationale works that can be modified by programming, is adaptable,
and has many progressed capacities, for example, the single-chip microcomputer
framework can create a planning clock inside. It tends to be utilized to acknowledge
different rationale capacities through programming. It enjoys the benefits of little size
and minimal effort with clocks and counters that can be utilized for timing and then
some.

As per the examination of the above conspire, the subsequent plan is the most
straightforward and solid, so the STC89C52 single-chip microcomputer is utilized as
the center framework control focus.
3.2 Key Control Module
Plan 1: Use a network console whose keys are situated at the convergence of
lines and segments, and the line and section lines are separately associated with the
CPU through two interfaces. Since there are numerous keys, you can straightforwardly
enter the tally esteem.

Plan 2: Use the overall level judgment key catch, since this framework doesn't
have to utilize numerous keys, and doesn't have to enter the tally esteem precisely, just
utilize the "+", "- " keys and state exchanging keys, so no one but It can be finished
with five catches. At the point when the catch is squeezed, the I/O port level is decided
to figure out which catch, and afterward the comparing capacity is executed.

Plan 3: A self-locking switch is embraced. The guideline of oneself locking


switch is like that of an overall key switch. It very well may be decided if it is associated
by high and low levels. Be that as it may, oneself locking switch is comparable to a
switch shut circuit. After it is associated, it is shut and not associated., separate. Oneself
locking switch keeps this state hooked by equipment, yet this plan needn't bother with
state locking, and the solidness of oneself locking switch is more fragile than that of the
catch.

As indicated by the above plot, the last decision is Scheme 2, which is more effective
and straightforward.

3.3 Display module


Plan 1: Use LCD1602, LCD1602 is a sort of modern character LCD, LCD1602
can show different characters like numbers, images, letters, and text simultaneously, the
limit range is 32 characters. LCD1602 is a sort of dab grid fluid precious stone module,
which acknowledges byte show by programming to light specific focuses. Its showcase
range has opportunity to get better, and it has a wide scope of substance. It tends to be
straightforwardly associated with the MCU interface, and the circuit association is
generally simple.

Plan 2: Using a computerized tube show, the advanced cylinder shows numbers,
letters, and images as indicated by needs, which is helpful and straightforward, and is
advantageous to drive. Nixie tubes are isolated into two kinds: basic cathode and regular
anode. They just drive the distinction of the given level. The activity is straightforward
and straightforward.

Despite the fact that LCD1602 fluid gem can meet the showcase needs of this plan, it
can likewise show numerous things simultaneously, yet the program and circuit are
more muddled than simply utilizing a computerized cylinder to address the issues of
showing numbers. In the event that four fluid gem shows are utilized If the screen
demonstrates the four-heading check show, the cost is high. In this plan, the LCD screen
is simply used to show numbers, and the advanced cylinder can show numbers all the
more instinctively and just. The technique is basic, and just the I/O port yield is high
and low. It can handle the presentation of the computerized tube, so contrasted and the
advanced cylinder, it is more practical and easier to control, and the expense is lower.
Hence, the subsequent arrangement is embraced.

4 Design Principle
This framework includes a sum of 6 modules, to be specific the single-chip
microcomputer module, 74HC245 drive module, key module, advanced showcase
module, traffic signal presentation module, and bell alert module. Presently we will
expound on these 6 circuit modules in detail. See supplement 1 for the particular circuits.

4.1 SCM Module


The single-chip module is the center piece of this plan. It sends guidelines to the
single-chip microcomputer through the programming, the single-chip executes the
directions, begins the single-chip counter, clock interfere, and different capacities to
understand the control of the traffic signals. The well-known one-chip microchip
available is STC89C52, its unit cost is around five-yuan, flexibility is solid, the activity
is straightforward.

4.1.1 Introduction of MCU


Single-chip microcomputers are additionally broadly alluded to as
microcomputers or single-chip microcomputers, which have a place with the fourth era
of universally useful electronic microcomputers [3]. This framework accepts a solitary
chip microcomputer as the center, receives a STC89C52 chip, embraces C language
guidelines, sets up the program, makes the framework complete the assignment as
required. The fundamental elements of STC89C52, for example, 32-bit I/O port line,
clock interfere with, outside intrude, and reset circuit, were utilized in the plan
interaction. Interface the downloader to the PC, and download the program to the chip
by downloading the driver. After the download is effective, the framework has a
programmed insurance work in the programmed power-off closure mode, the substance
of RAM is saved, the counter and clock are shut, and the oscillator stops ceaselessly
wavering until the client resets the equipment or intrudes on the reset sometime later.
The framework accepts the single-chip microcomputer as the center, receives the
STC89C52 chip, embraces C language directions, sets up the program, and makes the
framework complete the assignment as required.

4.1.2 AT89C52 Introduction


The 51 arrangement of single-chip microcomputers by and large have 40 pins and
receive a double column direct-addition bundle. To address the issues of various
equipment items, STC89C52 has three bundle modes. The practical pin structure chart
of STC89C52 is appeared in Figure 2
Fig-2 pin diagram of AT89C52

4.1.2 AT89C52 Function Profile

◆P0.1~P0.7: 8-digit bidirectional port line of P0 port.

Port P0 can be utilized as an I/O port, or as an ordinarily accessible port for address and
information transports. At the point when port P0 shows up as a yield port, P0.0
addresses bit 0, and P0.1 addresses bit 1. The information sent from the P0 port can be
shipped off the addresses of A0~A7 in the wake of being hooked. Along with the
addresses of A8~A15 sent from the P2 port, it is known as a total 16-cycle address
transport, which can be situated to the 64K outside Memory.

◆P1.0~P1.7: 8-cycle semi bidirectional port line of P1 port.

Port 1 is a bidirectional I/O port. Pick whether this port is utilized as information info
or information yield as indicated by your necessities. On the off chance that this port is
utilized as information input, you should set port P1 to undeniable level "1"; on the off
chance that you need to choose this port as information To yield, set the P1 port to low
even out "0". Regardless of whether utilizing 51 or 32 single-chip microcomputers, the
P1.0 pin can give outside heartbeats to clock 2, and P1.1 can be utilized as a trigger pin
for outer interfere with input.

◆P2.0~P2.7: P2 port 8-cycle semi bidirectional port line.

Port 2 is likewise a bidirectional I/O port. Pick whether this port is utilized as
information info or information yield as indicated by your necessities. In the event that
this port is utilized as information input, you should set port P2 to undeniable level "1".
In the event that the P2 port is expected to give the upper eight pieces of the location
transport, at that point P2 is not, at this point utilized as an I/O port.

◆P3.0~P3.7: P3 port 8-cycle semi bidirectional port line.

Port 3 is additionally a two-way I/O port, which has numerous other unique capacities,
for example, programmed clock control and capacities, for example, perusing or
composing information content account and preparing control.

◆It is the 31st pin of STC89C52, it gets to the program memory control signal: when
the sign is low, the ROM read activity is restricted to the outside program memory;
when the sign is high, the ROM read activity is restricted to the inward Program
memory and can be stretched out to outer program memory.

◆ALE is the 30th pin of STC89C52, which is a control signal utilized for the location
hook. The element of Beer positive heartbeat yield can give an outside clock or timing
beat.

◆It is the 29th pin of STC89C52, it is the outer program memory read select sign.

◆XTAL1 and XTAL2 are outside precious stone lead terminals: if the inner clock of
the chip is utilized when making equipment or programming, at that point these two pin
ports are utilized to associate outer gem oscillators and trim capacitors. At the point
when an outside chip gives an outer clock to the microcontroller, it very well may be
utilized to interface an outside clock beat signal.

◆RST reset signal: Utilize this port to re-run the program when the single-chip
microcomputer is fleeing or running in a turmoil. Contributing a significant level to the
reset signal is to finished the reset instatement activity of the single-chip microcomputer,
and it tends to be reset adequately when it goes on for two mechanical cycles.

◆VSS: Force ground.

◆VCC: +5V power supply. 2

4.1.3 SCM Minimum System


The base force utilization control and the executive’s arrangement of the single-chip
microcomputer is the base arrangement of the single-chip microcomputer, which is for
the most part made out of the primary control single-chip microcomputer, the reset
control circuit, and the precious stone oscillator circuit.

Interface the 40th pin VCC of the single-chip PC to the positive 5V force supply,
and the twentieth pin GND to the force ground terminal to control the single-chip PC.
The force supply technique can be associated with an independent force supply through
a level link, or a 5V USB can be utilized for direct force supply, or a PC USB port, a
Versatile force supply, for example, power bank and other hardware for power supply,
the littlest single-chip microcomputer.
The module diagram of the system (Figure 3) is as follows

Fig-3 The smallest single-chip microcomputer system


The reset circuit straightforwardly understands the info reset by applying a positive beat
of more than 20ms to the ninth pin RESET pin of the single-chip microcomputer. The
reset circuit additionally incorporates a 10K resistor and a 10uf polar capacitor. After
the circuit is controlled on, it will consequently reset. Interface a draw up resistor to the
reset circuit to upgrade the significant level worth of the yield signal. The reset circuit
of the microcontroller is like the restart part of the PC. On the off chance that your PC
has a dark screen or stuck and can't run during use, you can press the restart catch to
run the inner gathering program all along. This additionally applies to the single-chip
microcomputer. In the event that the single-chip microcomputer is working, yet the
program runs off because of the impact of the outer climate, the program will leave the
first state by squeezing the reset button and naturally re-run the program from start to
finish.

The precious stone oscillator circuit comprises of the nineteenth pin (XTAL1), the
eighteenth pin (XTAL2) of the single-chip microcomputer, the outer capacitors C2 and
C3, the two of which have a worth of 30pF and a 12M gem oscillator. The capacity of
the capacitor in the gem oscillator circuit is to help fire up. Its worth reach is 15pf to
33pf, where it helps the precious stone oscillator to fire up more without any problem.
The size of the gem oscillator can likewise be 24M. The size of the 12M gem oscillator
is the most well-known in little framework plan. The size and worth of the precious
stone oscillator straightforwardly influence the execution speed of a solitary chip
microcomputer working framework. The worth of the precious stone oscillator implies
a solitary chip microcomputer. The working velocity of the working framework. The
precious stone oscillator will be influenced by outside impacts. Hence, the precious
stone oscillator part ought to be just about as close as conceivable to the microcontroller,
with the goal that outside obstruction can be limited.

Notwithstanding the over three sections, the base control arrangement of the single-
chip microcomputer has some outside circuits.

Since the P0 port on the STC89C52 is an open-channel yield when we utilize numerous
gadgets, we need to utilize a great deal of I/O ports simultaneously, so we need to utilize
the P0 port as an ordinary I/O port. , So we need to interface a 10k size avoidance to
the P0 port with the goal that we can change over the P0 port to an ordinary I/O port
for use.

Give uncommon consideration to stick 31 (EA). In the event that this pin is associated
with a significant level, the microcontroller will begin ordinary activity from 0000H in
the interior ROM after reset. In the event that the EA pin is associated with a low level,
the typical execution will begin straightforwardly from 0000H in the outside ROM after
reset. In this manner, the motivation behind why EA should be associated with an
undeniable level is that the program is put away in the microcontroller, which is helpful
for the microcontroller to peruse and execute the program from within.

4.2 74HC245 Driver Module


74HC245 is a rapid CMOS transport handset viable with TTL gadget pins, broadly
useful CMOS three-state support entryway circuits, and 8-channel signal handsets.
Since the single-chip microcomputer or computer processor has a specific burden limit
on the transport ports of information transmission and gathering, address gathering, and
center control, when the heap surpasses the heap limit, it is normally important to add
a driver. It is mostly used to add drivers for huge screen shows and different gadgets.
74HC245 chip pin diagram is shown in the figure below (Figure 4)
Fig: 4 (74HC245 chip pin diagram)

The first pin is DIR (Abdominal muscle), which is utilized for info and yield port
change. As per the necessities, it tends to be contribution from terminal An and yield
from terminal B or contribution from terminal B and yield from terminal A. At the point
when AB="1" is significant level, the sign The information and yield mode is
characterized as from A to B, when Stomach muscle = "0" is low level, the sign
information and yield mode are characterized as from B to A.

The second to ninth pins are the information and yield terminals of the A sign, where
A0=B0, A1=B1, if the principal pin Stomach muscle is "1" and the nineteenth pin
empower terminal is "0", at that point input B0 from A0 and yield. A0 and B0 are a
gathering, A1 and B1 are a gathering, etc.

The eleventh to eighteenth pins are the information and yield terminals of the B signal,
where B0=A0, B1=A1, if the principal pin Abdominal muscle is "0" and the nineteenth
pin empower terminal is "0", at that point B0 is information and A0 is yield. Etc.

The nineteenth pin OE is the empower terminal. On the off chance that this pin is "1",
the switch sign of the A/B terminal isn't turned on, if this pin is "0", the switch sign of
the A/B terminal is turned on, and this pin assumes a part The job is the job of the switch.

On pin 10, GND addresses the force ground. The twentieth pin VCC addresses the
positive post of the force supply.

There are eight-route cushions with controllable bearing inside the 74HC245. To shield
the chip from over-burdening, because of the restricted burden limit of the single-chip
microcomputer, four computerized tubes are headed to run simultaneously in this plan,
for the most part, between the MCU interface and the outside, A cushion is added
between the equal interfaces of the controlled hardware to improve the yield drive
ability of the single-chip microcomputer. In this plan, 74HC245 is added between the
yield control computerized containers of the single-chip microcomputer to improve the
driving capacity, in order to make the splendor of the advanced cylinders more splendid.
In this plan, the principal pin is set to "1", so An end is information and B end is yield.

4.3 Key module


After the framework is associated with the force supply, the catch is controlled
on, and the framework enters the programmed activity mode. The capacity of the catch
work territory is to change the wonder of the circuit through the catch, and the hour of
the circuit traffic signal can be changed by the catch, and the setting catch can be utilized
prior to squeezing the catch each time. Switch the heading of the key, and afterward
utilize the in addition to and less keys to add or deduct the time that the red and green
lights are on, and afterward press the enter key to finish the time setting. On the off
chance that you need to get back to the underlying time control, press the reset catch to
clear it. The time will naturally get back to the primary street for 15 seconds and the
branch street for 10 seconds, and it will run consequently. If there should be an
occurrence of crises, for example, significant auto collisions, crisis salvage by
ambulances and fire engines, or street harm that makes vehicles unfit to pass, the crisis
mode can be actuated, red lights every which way will be on, and vehicles won't be
permitted to pass. On the off chance that there is little traffic at a crossing point, or there
is no traffic at a convergence, empower the night mode and every one of the yellow
lights are on to remind the passing vehicles and walkers to focus.

As demonstrated in the catch module chart in Figure 5, the catches perform various
capacities. The night mode button is associated with the P1.5 port of the microcontroller.
In the night mode, the yellow lights in four ways will be lit and glimmer once every 0.5
seconds. As of now, the four headings of the advanced cylinders show "00"; the crisis
mode key is associated with the P3.1 port, and the red lights in the four ways will
illuminate in a crisis. Right now, the four bearings of the advanced cylinders show "00";
east-west course The green light north-south red light key is associated with port P3.2.
For this situation, the east-west green light is on and the north-south shows green light.
As of now, the computerized tubes in the four ways show "00"; For this situation, the
north-south course shows a green light, and the east-west heading shows a red light.
Right now, the four headings show "00"; the affirm key is associated with the P3.4 port,
the in addition to key is associated with the P3.5 port, and the short key is associated
with P3 .6 port, the switch key is associated with the P3.7 port, the switch key can
switch the course of the adjustment time. After the catch is squeezed, discharge it to
begin the execution of the set undertaking, and the catch will understand the counter
shake work through delay in the product setting. In crisis mode and night mode, you
need to press the Affirm key to leave these two modes. After you press the set time
button, you can change the time give or take of the primary street and branch street all
together. After the setting is finished, press alright to finish the setting.

Fig-5 Button module diagram

4.4 Digital Display Module


The nixie tube has a sum of eight field parts, to be specific a, b, c, d, e, f, g, dp
sections, and each part is made out of a light-discharging diode, and the nixie tube is
made out of their particular fragments. Furthermore, these diodes have the qualities of
unidirectional conductivity, the current is normally 5mA. There is a round decimal point
dp in the lower right corner of the advanced cylinder show, which is likewise addressed
by light-transmitting diodes. Through the relating program code, and as per the various
kinds of computerized tubes, to set up different numbers and letter codes, to control the
on and off of the 7 light-producing diodes.

For the most part, there are two different ways to associate the computerized tube:
regular anode and basic cathode [6]. The association technique in which the anodes of
all the light-radiating diodes inside the advanced cylinder are associated with one
another is known as the regular anode association strategy. During use, the normal
anode is associated with the force supply +5V. The cathode is straightforwardly inputted
the comparing low level through programming or "NAND door" rationale change, the
light-producing diode is likewise turned on and lit, and the section with the cathode
input significant level isn't lit. Regular cathode association alludes to interfacing the
cathodes (negative anodes) of light-transmitting diodes together to frame a typical
cathode. During use, the basic cathode is associated with the ground terminal of the
force supply. At the point when the anode terminal is inputted relating to the significant
level light-emanating fragment through programming or "NAND door" rationale
change, the light-radiating diode is turned on and illuminates. On the off chance that
the anode area inputs a low level, it won't illuminate. The framework utilizes a typical
cathode association strategy. In this plan, the nixie tube is set in four ways to show the
commencement time toward every path. The default time for principle streets is 15
seconds, and the default time for branch streets is 10 seconds. At the point when the
time is adjusted, the altered time can be shown continuously. The computerized tube
module chart (Figure 6) is as per the following:

The sections A, B, C, D, E, F, G, and DP of the advanced cylinder are associated with


the B port of the 74HC245 chip. At the point when an undeniable level is an info, the
comparing fragment illuminates. Since this plan utilizes a two-digit advanced cylinder,
the two-digit computerized tube has a pin port that recognizes the high and low
positions. S1 is the one digit of the two-digit computerized cylinder, and S2 is the tens
digit of the two-digit advanced cylinder. The high and low places of the advanced
cylinder the east-west way and the high and low places of the computerized tube the
north-south way are associated with the P1 port. Through the hinder to produce 1-
second intrude on planning, P1.0 of the single-chip microcomputer controls the low
digit of the principle street, P1.1 controls the high digit of the primary street, P1.2
controls the low situation of the branch computerized cylinder, and P1.3 controls the
elevated place of the branch advanced cylinder. Two-digit advanced cylinders can show
up to 99. The A0~A7 ports of the 74HC245 chip are associated with the P0.0~P0.7
ports of the single-chip microcomputer, and the high and low levels are yield through
the I/O port of the single-chip microcomputer. At the point when each portion yields a
significant level to the comparing section, the relating fragment illuminates to show the
number. Drive the nixie tube through 74HC245 to make the single-chip microcomputer
have a more grounded load limit, in this way making the nixie tube more splendid. As
demonstrated in Figure 6, four advanced cylinders are put in four ways to show the time
toward every path. The computerized tubes the east-west way change simultaneously,
and the advanced cylinders the north-south way change simultaneously. The high and
low places of the east-west bearing are something similar, and the north-south heading
is something very similar. The high and low associations are steady. In the typical
express, the machine will show the force on sign "- - ", and afterward it will time
ordinarily, the advanced cylinder will show the coordinated time progressively. When
changing to an uncommon mode, the four-bearing computerized cylinder will continue
to show "00".

Fig-6 Digital Display


4.5 Traffic light display module

Fig-7 Traffic Light Display module

4.5.1 LED Introduction

Conductor light-transmitting gadgets fundamentally incorporate semiconductor


light-radiating diodes (alluded to as LEDs) [7], nixie tubes, image tubes, rice-molded
cylinders and speck grid show screens (called framework tubes, etc. Indeed, every one
of their light-transmitting units is a light-radiating diode. The converse breakdown
voltage of the light-transmitting diode is around 5 volts, and its forward volt-ampere
trademark bend is extremely steep. The positive post of the light-transmitting diode is
for the most part associated with the positive shaft of the force supply, and the negative
post is by and large associated with the ground. By and large, the functioning current
of the Drove is 10-10mA, and the functioning current scope of the low-current Drove
is under 2mA, and its brilliance is equivalent to that of the customary circular segment
tube. In the event that the current to the diode surpasses a specific reach, the light-
discharging diode will copy out because of extreme current, so a current of under 2mA
ought to be given to the light-transmitting diode. The light-discharging diodes utilized
in the traffic signal presentation module are standard light-emanating diodes.

4.5.2 Traffic lights


Traffic lights (or traffic signals) are lights used to control the movement of traffic.
They are placed at road intersections and crossings.[1] The different colors of lights
tell drivers what to do.
The world's first traffic light was a manually operated gas-lit signal installed
in London in December 1868. It exploded less than a month after it was implemented,
injuring its policeman operator.[3] Earnest Sirrine from Chicago patented the first
automated traffic control system in 1910. It used the words "STOP" and "PROCEED",
although neither word was illuminated.
Traffic lights change their colors in the same order every time. In most English-
speaking countries, traffic lights usually change in this order:

⚫ Red light on: This tells drivers to stop.


⚫ Green light on: This means the driver can start driving or keep driving.
⚫ Yellow light on: This tells drivers to stop when it is safe to, because the light is
about to turn red.

Traffic Light

4.6 Buzzer Alarm Module


The alert circuit is made out of a signal, a semiconductor (PNP) and an electrical
gathering. It is constrained by the P3.0 pin of the single-chip microcomputer, and the
signal is enhanced by the semiconductor. After the green light in the ordinary state,
when the yellow light blazes, the bell will sound alongside the yellow light. The
program will control the P3.0 port of the microcontroller to yield a low level, the
semiconductor will be turned on, and the bell will sound a caution.
The caution circuit chart (Figure 8) is as the Following.

Fig-8 Buzzer alarm circuit diagram

5 Software components
5.1 Introduction to development tools
C language is our usually utilized PC programming language. Contrasted and low
level computing construct, it is simpler to communicate and can execute more
unpredictable rationale in work. It for the most part utilizes sensible capacity
explanations in structure, for example, "if", "Else" or "for" circles, and so forth, while
low level computing construct should unmistakably communicate the running cycle of
every assertion, and circle back to one of the above assertions to pass judgment. C
language additionally enjoys clear benefits in intelligibility and practicality. It tends to
be utilized as a product configuration programming language for the functioning
framework, or it very well may be utilized with different dialects to compose free
framework application programs scattered with different dialects, or it tends to be
utilized as a plan language for application projects to compose application programs
autonomous of PC equipment frameworks. This plan utilizes the Keil C51 single-chip
C language programming improvement framework. Keil furnishes a total improvement
program with incredible reenactment and troubleshooting capacities. When utilizing
Keil, you can utilize low level computing construct for programming, however when
utilizing C programming, Keil is practically the most ideal decision. Keil likewise
upholds the utilization of low-level computing construct and C language to cooperate,
and the driver documents of C51 are modified in low level computing construct. Keil
has a wide scope of viable chips, which can be viable with the activity of STC MCU
arrangement and STM32 arrangement programs.

5.2 Block diagram


A block diagram is a diagram of a system in which the principal parts or
functions are represented by blocks connected by lines that show the relationships of
the blocks. They are heavily used in engineering in hardware design, electronic
design, software design, and process flow diagrams.
Block diagrams are typically used for higher level, less detailed descriptions that are
intended to clarify overall concepts without concern for the details of implementation.
Contrast this with the schematic diagrams and layout diagrams used in electrical
engineering, which show the implementation details of electrical components and
physical construction.

5.2.1 main program box


The main program itself does not have any function but to regulate subprograms.
initialized the main program only contains a system and an infinite loop, which
regulates the sub-function . The main function is shown in Figure-9

Fig-9 Main block diagram


5.2.2 key module block diagram

Fig-10 Key module block diagram


The control of the catch module embraces the if articulation to understand the control.
The technique normally used to decide whether the catch is squeezed is to peruse the
yield level worth of the I/O port of the single-chip microcomputer to which the catch is
associated. In this plan, one finish of the keys should have been utilized is totally
grounded, and the opposite end is associated with the P3 and P1.5 ports of the
microcontroller. Toward the start of the program, all I/O ports associated with the keys
are set to significant level "1". At the point when no catch is squeezed, the associated
I/O port actually keeps an undeniable level. At the point when a catch is squeezed, in
light of the fact that the opposite finish of the catch is grounded, the I/O port is
compelled to be set to low even out "0", and The force ground is shortcircuited. At the
point when the key is delivered, the draw up resistor inside the microcontroller keeps
the I/O port at an undeniable level "1". We can question the level of this I/O port through
the if articulation to decide if the catch is squeezed, and which catch is squeezed by
deciding the key worth.
Usually the switches we use are mechanical switches, and the mechanical jitter of the
switch will cause a series of jitters when switching or pressing. The length of the jitter
time depends on the mechanical characteristics of the switch, usually 5ms to 10ms [9].
Therefore, we need to use software or hardware devices to implement the debounce
function. This design uses software programming to eliminate jitter. Compared with
hardware, the software is easier to test and modify, and has stronger stability. The
hardware circuit has poor scalability and is not easy to modify, and the stability is not
known without testing. The design realizes the debounce through the delay program.
Whenever the key is pressed, after judging the key is pressed, the delay then judges
whether the key is pressed because of the jitter, if it is confirmed that the key is pressed,
the corresponding program is executed

5.2.3 timing interrupt block


Timer interrupts allow you to perform a task at very specifically timed intervals
regardless of what else is going on in your code. In this instructable, I'll explain how to
set up and execute an interrupt in Clear Timer on Compare Match or CTC Mode.
Fig-11 Timed interrupt block diagram
Set the underlying worth in the primary program. To meet the setting of the
yellow light blazing, the underlying season of T0 can be set to 50 milliseconds. So every
50 milliseconds the computer processor will give a flood intrude on ask for and enter
the interfere with administration subroutine. In the intrude on assistance subroutine, the
computer processor first adds 1 to the product counter worth and afterward decides if it
is 10, in the event that it isn't 10, it keeps on entering the interfere with, 10 implies that
10 50 milliseconds have passed, that is, a large portion of a second, which is 20 It
implies that 20 50 milliseconds or 1 second have passed, and afterward it gets back to
the yield time show and clears the product counter to 0.

6 Debugging and Simulation


Addendum 1 shows the reproduction of the whole traffic signal control framework
[11] in the PROTEUS reenactment outline [10]. Proteus is the world-acclaimed EDA
instrument (reenactment programming). It is the lone plan stage on the planet that joins
circuit reenactment programming, PCB plan programming and virtual model
reproduction programming.

This plan reproduction acknowledges two-way traffic, and the commencement is shown
by a 2-digit advanced cylinder. As per the planned circuit chart, make another
undertaking, at that point place the parts, at that point interface, lastly mimic.
After many debugging and verification, the system has realized the following functions:
(1) After power on, press the framework start catch to begin running. Force on
defaults the green light for 10 seconds the east-west way and the red light the north-
south way for 15 seconds. At the point when the green light the east-west way tallies
down to "01", the following state is that the yellow light the east-west way streaks for
5 seconds, and the ringer follows the glimmering recurrence. Keep the red light the
north-south way. After the east-west yellow light, enter the following mode, the red
light the east-west way for 20 seconds, and the green light the north-south way for 15
seconds. At the point when the green light the north-south way checks down to "01",
the following state is that the yellow light the north-south way streaks for 5 seconds
with The signal sounds with the glimmering recurrence, and the light the east-west way
stays red. However long no key is squeezed in this cycle mode, it will cycle along these
lines.
(2) At the point when the crisis button is squeezed, the red lights in the four ways
will illuminate, and the circumstance will stop. The computerized tube doesn't show the
ordinary planning time, and the circumstance time is shown as nothing. Just when the
affirm button is squeezed, the typical state will be reestablished.
(3) At the point when the night mode button is squeezed, the yellow lights in the
four ways will illuminate, and the circumstance will stop. The advanced cylinder
doesn't show the ordinary planning time, and the circumstance time is shown as nothing.
The typical state must be reestablished in the wake of squeezing the affirm button.
(4) When the "East-West" mode button is pressed, the direction of the east-west
branch road is forced to be green, and the direction of the north-south trunk road is
forced to be red. The timing stops, the digital tube does not display the normal timing
time, the timing time displays zero, and the normal state is restored after pressing the
confirm button .
(5) When the "North-South" mode button is squeezed, the heading of the north-
south blood vessel street is compelled to be green, and the bearing of the east-west
branch street is compelled to be red. The clock stops, the advanced cylinder doesn't
show the ordinary planning time, the circumstance time shows zero, and the typical
state is reestablished subsequent to squeezing the affirm button
(6) When the plus key is pressed, the green light for east-west direction is added
by default, and the digital tube displays the plus time.
(7) When the minus button is pressed, the green light duration of the east-west
direction is subtracted by default, and the digital tube displays the minus duration. If
you want to modify the time in the north-south direction, you need to press the switch
key
(8) When the switch key is not pressed, the default direction of the modified
duration is the east-west direction. After the switch key is pressed, the modified
duration direction switches to the north-south direction, and press it again to switch
back to the east-west direction. After confirming the direction, you need to modify,
press the switch key Switch the direction, then press the plus or minus key to modify
the time, and finally press the confirm key to confirm the modification. The modified
time will realize the newly set time cycle when the next traffic light cycle is completed
7 Concluding remarks
The improvement of town traffic conditions is generally reliant upon present day
methods of traffic the executives and control. Progressed traffic light regulators and
control frameworks add to the improvement of the metropolitan traffic issue. The
knowledge of traffic light regulator that is presented in this task with incredible
capacities and equipment interface. Great quality social advantage has been made
through the application of the shrewd traffic regulator practically speaking, and the
application result shows that the keen traffic light regulator will improve.

This project is based on a very effective way of optimizing traffic, with redefinition of
threshold values for a real time application.This works to control traffic on four-way
roads according to traffic control barricades. This proposed system will build a
developed country with fewer traffic jams and it will also help the emergency vehicle
reach in time to the destination. So, this intelligent system will help us to control
traffic more autonomously.The traffic light controller has simple structure, complete
functions, stable work, easy maintenance and operation, and can be widely used.
Traffic control management in small and medium cities.
References

[1] Aditi Agrawal, Rajeev Paulus. Intelligent traffic signal plan and control
in savvy urban areas: a study on strategies and
methodologies[J].International Journal of Vehicle Information and
Communication Systems, 2020,5(4).
[2] Pan Lin. Design of intelligent traffic light control system based on
STC89C52 single-chip microcomputer [J]. Information Research, 2018,
44(3): 74-77.
[3] Su Jiajian, Cao Borong, Wang Zhifeng. Principle and Application
Technology of Single Chip Microcomputer [M]. Beijing: Higher Education
Press, 2004.
[4] Huabing. MCS-51 Single Chip Microcomputer Principle Application
[J]. Wuhan: Wuhan Huazhong University of Science and Technology Press,
2002.
[5]Hu Ruinan. Design of intelligent traffic light system based on 51
single chip microcomputer[J]. Communication World, 2018, (08): 252-253.
[6] Yan Shi. Fundamentals of Digital Electronic Technology (Third Edition)
[M]. Beijing: Higher Education Press, 1989.
[7] Li Weicu, Guo Qiang. Application technology of liquid crystal
display[M]. Beijing: Electronic Industry Press, 2000.
[8] Deng Rubing. Research on the application of C language in single-chip
microcomputer [J]. Electronic World, 2021, (01): 21-22.
[9] Yu Mengchang. Fundamentals of Digital Electronic Technology [M].
Beijing: Higher Education Press, 1999.
[10] Zhu Qinghui. Proteus Tutorial-Electronic Circuit Design, Plate
Making and Simulation [M]. Beijing: Tsinghua University Press, 2008.
[11] Liu Pengjuan, Song Qixian, Intelligent traffic light design based on
single-chip microcomputer [J]. Electronic Production, 2020, (21): 79-81.
Appendix I: Circuit diagram

Appendix II: Source


ORG 00H
LJMP MAIN
ORG 300H
TBL: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H ;7seg data for comm.
anode type
ORG 30H

MAIN: MOV P2,#00H


MOV P3,#00H
ACALL FRONT
MOV DPTR,#TBL
CLR A
MOV 40H,#10
MOV 43H,#10
MOV 46H,#20
MOV 49H,#20
MOV R0,#35
MOV R6,#30
MOV R7,#40

X1: MOV A,40H


MOV B,#10
DIV AB
MOV 41H,A
MOV 42H,B

A1: SETB P3.0


CLR P3.1
MOV A,41H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
SETB P3.1
CLR P3.0
MOV A,42H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
SJMP X3
X2: SJMP X1
X3: MOV A,43H
MOV B,#10
DIV AB
MOV 44H,A
MOV 45H,B
SETB P3.2
CLR P3.3
MOV A,44H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
SETB P3.3
CLR P3.2
MOV A,45H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H

MOV A,46H
MOV B,#10
DIV AB
MOV 47H,A
MOV 48H,B
SETB P3.4
CLR P3.5
MOV A,47H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
SETB P3.5
CLR P3.4
MOV A,48H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H

MOV A,49H
MOV B,#10
DIV AB
MOV 50H,A
MOV 51H,B
SETB P3.6
CLR P3.7
MOV A,50H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
SETB P3.7
CLR P3.6
MOV A,51H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H

DJNZ R0,X2
MOV R0,#35

DJNZ 40H,Q1
MOV 40H,#20

Q1: DJNZ 43H,Q2


MOV 43H,#10
ACALL RIGHT

Q2: DJNZ 46H,Q3


MOV 43H,#20
MOV 46H,#10

Q3: DJNZ 49H,Q4


MOV 49H,#10
ACALL BACK

Q4: DJNZ R6,X4


ACALL LEFT
MOV 40H,#10
MOV 43H,#10
MOV 46H,#30

X4: DJNZ R7,L1


LJMP MAIN
L1: LJMP X1

DELAY: MOV R4,#5


H2: MOV R5,#0FFH
H1: DJNZ R5,H1
DJNZ R4,H2
RET

FRONT: MOV P1,#54H


MOV P0,#02H
RET

RIGHT: MOV P1,#0A1H


MOV P0,#02H
RET

BACK: MOV P1,#09H


MOV P0,#05H
RET

LEFT: MOV P1,#4AH


MOV P0,#08H
RET

You might also like