Professional Documents
Culture Documents
Thesis Paper ''Design of Traffic Light Controller Based On Single Chip Microcomputer''.
Thesis Paper ''Design of Traffic Light Controller Based On Single Chip Microcomputer''.
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.
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.
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.
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.
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.
As indicated by the above plot, the last decision is Scheme 2, which is more effective
and straightforward.
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.
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.
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.
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.
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.
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
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.
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.
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.
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:
Traffic Light
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.
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
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