Upload
amit-sharma
View
221
Download
0
Embed Size (px)
Citation preview
7/30/2019 Project Report on Dynamic Traffic System
1/46
DENSITY BASED TRAFFIC CONTROL
SYSTEM
DARA MANOJ
Department of Electrical and Electronics Engineering
MAHATMA GANDHI INSTITUTE OF TECHNOLOGY
(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.)
Chaitanya Bharathi P.O., Gandipet, Hyderabad 500 075
2012-2013
7/30/2019 Project Report on Dynamic Traffic System
2/46
DENSITY BASED TRAFFIC CONTROL SYSTEM
INDUSTRY ORIENTED MINI PROJECT REPORT
SUBMITTED IN PARTIAL FULFILLMENT
OF THE REQUIREMENTS FOR THE DEGREE OF
BACHELOR OF TECHNOLOGY
IN
ELECTRICAL AND ELECTRONICS ENGINEERING
BY
DARA MANOJ(09261A0215)
Department of Electrical and Electronics Engineering
MAHATMA GANDHI INSTITUTE OF TECHNOLOGY
(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.)
Chaitanya Bharathi P.O., Gandipet, Hyderabad 500 075
2012-2013
7/30/2019 Project Report on Dynamic Traffic System
3/46
MAHATMA GANDHI INSTITUTE OF TECHNOLOGY
(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.)
Chaitanya Bharathi P.O., Gandipet, Hyderabad-500 075Department of Electrical and Electronics Engineering
CERTIFICATE
This is to certify that the mini project work entitledDENSITY BASED TRAFFIC
CONTROL SYSTEM is being submitted by DARA MANOJ bearing Roll
No.09261A0215 in partial fulfillment for the award of Degree ofBACHELOR OF
TECHNOLOGY in ELECTRICAL & ELCTRONICS ENGINEERING by the
Jawaharlal Nehru Technological University, Hyderabad during the academic year 2012-
13.
The results embodied in this report have not been submitted by the student to any
other University or Institution for the award of any degree or diploma.
Mini Project Supervisor
Dr. P Chandra Sekhar
Associate professor
EEE Department
Head Of The Department
Dr. P Ram Kishore Kumar Redd
Associate professor & Head
EEE Department
7/30/2019 Project Report on Dynamic Traffic System
4/46
CERTIFICATE OF THE ORGANISATION
7/30/2019 Project Report on Dynamic Traffic System
5/46
ACKNOWLEDGEMENT
I express my deep sense of gratitude to my beloved Principal Dr. G Chandra
Mohan Reddy, for the valuable guidance and for permitting us to carry out this project.
I express my deep sense of gratitude to my beloved professor Dr. P.Ram
Kishore Kumar Reddy, Professor and Head, Department of Electrical & Electronics
Engineering for the valuable guidance and suggestions, keen interest and through
encouragement extended throughout period of project work.
I express my deep sense of gratitude to my beloved project guide
Mr.V.Ramakrishna for the valuable guidance and suggestions, keen interest and
through encouragement extended throughout period of project work.
I take immense pleasure to express my deep sense of gratitude to our beloved
Guide Dr.P.Chandrasekhar,Associate professor in Electrical and Electronics
Engineering, for his valuable suggestions and rare insights, for constant source of
encouragement and inspiration through out my project work.
I express my thanks to all those who contributed for the successful
completion of my project work.
With gratitude,
DARA MANOJ ________________
7/30/2019 Project Report on Dynamic Traffic System
6/46
CONTENTS
CHAPTER NO. TITLE PAGENO
ABSTRACT i
LIST OF FIGURES ii
LIST OF TABLES iii
1 INTRODUCTION
1.1 INTRODUCTION 1
1.2 AIM 1
1.3 METHODOLOGY 11.4 SIGNIFICANCE 1
2 LITERATURE REVIEW
2.1 AIM 2
2.2 BLOCK DIAGRAM 3
2.3 METHODOLOGY 4
2.4 IR TRANSMITTER & IR RECEIVER 4
2.5 SCHEMATIC DIAGRAM 7
2.6 SCHEMATIC DIAGRAM EXPLANATION 8
3 HARDWARE COMPONENTS
3.1 AT89S52 MICROCONTROLLER 9
3.1.1 DISCRIPTION 9
3.1.2 FEATURES 10
3.1.3 BLOCK DIAGRAM 11
3.1.4 PIN DIAGRAM 12
3.1.5 PIN DISCRIPTION 13
7/30/2019 Project Report on Dynamic Traffic System
7/46
3.2 POWER SUPPLY 21
3.3 REGULATOR 21
3.4 TRANSFORMER 22
3.5 CAPACITOR FILTER 233.6 LEDS 24
3.6.1 FUNCTION 24
3.6.2 CONNECTING 24
3.6.3 TESTING AN LED 25
3.7 IR LED 25
3.7.1 DESCRIPTION 26
3.7.2 FEATURES 26
3.8 LCD INTEERFACING 26
3.8.1 INTRODUCTION 26
3.8.2 PIN DISCRIPTION 26
4 WORKING FLOW OF PROJECT
4.1 BLOCK DIAGRAM 31
4.2 CIRCUIT DESCRIPTION 32
4.3 SOFTWARE 33
4.3.1 KEIL VISION 33
4.3.2 EMBEDDED 34
5 CONCLUSION 35
REFERENCES 36
7/30/2019 Project Report on Dynamic Traffic System
8/46
ABSTRACT
Traffic is formally organized in many jurisdictions, with marked lanes, sjunctions,
intersections, interchanges, traffic signals, or signs. Traffic is often classified by type:
heavy motor vehicle (e.g., car, truck); other vehicle (e.g., moped, bicycle); andpedestrian. Different classes may share speed limits and easement, or may be segregated.
Some jurisdictions may have very detailed and complex rules of the road.
One of the main problems in our citys is traffic, this project proposed new
solution to traffic control. The main design accept of this project is to control the traffic
automatically and adding human inelegancy to that automatic controller. "Four-way"
intersection is the most common configuration for roads that cross each other, and the
most basic type. If signals do not control a 4-way intersection, signs or other features are
typically used to control movements and make clear priorities.
In this project we are going to use IR communication to analyze traffic density.
IR signals from IR receiver are given to microcontroller and microcontroller gives
appropriate result according to traffic. For better result we are going to use some bunch of
IR transmitters and IR receivers in all directions. When there is a more traffic in one side
more no. of IR receivers will not get the signals and result will compare with all other
directions and microcontroller gives green signals at one side where more no of IR
receivers will not get the signals.
For IR communication we are using an IR transmitter and IR receiver. Here IR
LED will acts as a transmitter. As we know microcontroller having inbuilt I/O ports and
we are interfacing IR receivers to those I/O ports. For controlling of traffic we are using
red, green and yellow color LEDs. These LEDs are connected to different I/O ports of
microcontroller. When there is a more traffic microcontroller gives signal to green LED
and it will glow. So by using this project we can control the traffic automatically like a
human being.
i
7/30/2019 Project Report on Dynamic Traffic System
9/46
LIST OF FIGURES
FIG.NO TITLE PAGE.NO
1 A JUNCTION WITH LED & IR SENSORS 1
2 BLOCK DIAGRAM 2
3 CIRCUIT OF IR TRANSMITTER 4
4 CIRCUIT OF IR RECEIVER 4
5 SCHEMATIC DIAGRAM OF CIRCUIT 6
6 AT89S52 MICROCONTROLLER 9
7 BLOCK DIAGRAM OF AT89S52 MICROCONTROLLER 10
8 PIN DIAGRAM OF AT89S52 119 OSCILLATOR CONNECTIONS 18
10 EXTERNAL CLOCK DRIVE CONFIGURATION 19
11 REGULATED POWER SUPPLY 20
12 EXAMPLE CIRCUIT SHOWING 5V DC OUTPUT 21
13 AN ELECTRICAL TRANSFORMER 22
14 LED 23
15 CIRCUIT DIAGRAM OF LED 2316 IR LED 24
17 SCHEMATIC DIAGRAM OF IR LED 24
18 BLOCK DIAGRAM OF WORKING OF PROJECT 30
ii
7/30/2019 Project Report on Dynamic Traffic System
10/46
LIST OF TABLES
TABLE.NO TITLE PAGE.NO
1 PORTS SHOWING THE ALTERNATE FUNCTIONS ATPORT 1
12
2 PORTS SHOWING THE ALTERNATE FUNCTIONS ATPORT 3
14
3 TIMER 2 OPERATING MODES 17
4 PIN DISCRIPTION OF LCD 26
5 EMBEDDED C DATA TYPES 33
iii
7/30/2019 Project Report on Dynamic Traffic System
11/46
Chapter-1
INTRODUCTION
1.1 Introduction:
In this system IR sensors are used to measure the density of the vehicles which are fixed within a fixed
distance.All the sensors are interfaced with the microcontroller which in turn controls the traffic signal
systemaccordingtodensitydetectedbythesensors
If the traffic density is high on particular side more priority is given for that side. The sensors
continuously keep sensing density on all sides and the green signal is given to the side onpriority basis,
where the sensors detect highdensity. The side with next priority level follows the first priority
level. Byusing thissystemtraffic can becleared without irregularitiesand timedelayseven thoughthere
isnotrafficontheother side canbeavoided
1.2 Aim:
ThemainAimofthisproject istocontrol the traffic lightsbasedonthe densityofthevehicles.
1.3 Methodology:
The project is to solve traffic congestion which is a severe problem in many modern
cities all over the world. To solve the problem, we have designed a framework for a
dynamic and automatic traffic light control system and developed a simulation model
with codes in to help build the system on hardware. Generally, each traffic light on anin te rsecti on is assi gned a const ant green signal time. It is possible to propose
dynamic time-based coordination schemes where the green signal time of the traffic
lights is assigned based on the present conditions of traffic. The intelligent work which is
done by traffic inspector will be perfectly done by the microcontroller in the circuit with
the help of sensors and the program which is coded to themicrocontroller.
1.4 Significance Of The Project:
This type of project is used in heavy traffic roads and the junction because this type of
project is based on the time as well as the density and the time will be controlled by
programme coded in microcontroller and the density will be controlled by IR sensors and
they are controlled by microcontroller
1
7/30/2019 Project Report on Dynamic Traffic System
12/46
Chapter-2
LITERATURE REVIEW
2.1 Introduction:
The project intelligent traffic management system for metro cites, is based on the
microcontroller which will provide the controlling of the traffic depending upon the
density.
According to the signaling i.e. continuity between the IR transmitter and IR receiver the
Timing of the green, red lights will be glown for the particular time depending upon the
density.
The micro controller will monitor the all control functionalities. According to the
controller signalling the density will be monitored by lights.
Microcontroller based traffic control system is an application specific project, which is
used to control the traffic. An embedded system is developed which consists of a
microcontroller, IR transmitter and receiver, LEDs
This project is implemented by placing IR transmitters, receivers and leds at the 4 way
junction, the four paths are represented as R1,R2,R3,R4
FIG 1: A JUNCTION WITH LED & IR SENSORS
Transmitters and receivers are placed at either sides of the four paths, and 4 leds at
corner of the junction When there is a traffic along the paths,value of R would be 000
which are the values of IR sensors and if there is no traffic the value is 111
7/30/2019 Project Report on Dynamic Traffic System
13/46
2
2.2 Block Diagram:
FIG 2: BLOCK DIAGRAM
3
Micro
controller
(ATS8952)
POWER
SUPPLY
Signals from IR
receivers from
all directions
RED
GREEN
ROAD 3
RED
GREEN
ROAD 4
RED
GREEN
ROAD 1RED
GREEN
ROAD 2
IRTransmitter
signals
From all
directions
7/30/2019 Project Report on Dynamic Traffic System
14/46
2.3Block Diagram Explanation:
The main objective of this project is to control the traffic depending upon
the density .As there is much time wastage with the traffic lights which involves the
Time, we are designing the new system which controls the traffic depending upon the
density.
Here we place IR transmitter and the IR receivers at both ends of the roads. Whenever
the vehicles pass in-between them the continuity will be lost. Hence the microcontroller
senses the density is high.
Then the microcontroller will be making the light (green) to be glow much time at the
place where the traffic is high.
The same procedure will be followed by four sides of the road. The signalling from the
four sides will be taken into consideration and depending upon the density controller will
make the decision .
The system uses a compact circuitry build around flash version of AT89S52
Microcontroller with a non-volatile memory. Programs will be developed in
EMBEDDED C language. FLASH MAGIC is used for loading of programs into
microcontroller.
2.4 IR Transmitter & Receiver:
The purpose of the transmitter is to transform the information we want to send into a
signal that can be propagated by the channel. In the case of our wired copper channel, this
means we want the information to be transformed into a modulated voltage level,
something like the pulse train. For a wireless channel, however, the transmitter needs to
encode the information onto an EM wave that can be easily propagated.
4
7/30/2019 Project Report on Dynamic Traffic System
15/46
IR Transmitter:
FIG 3: CIRCUIT OF IR TRANSMITTER
The IR transmitter part consists of an Infra red light emitting diode that can capable of
sending modulated data within infra red band. To match the receiver frequency the the
data is modulated at 38.7 KHZ by configuring 555 timer at astable mode of operation,
which generates frequency using the components R2 and C2 as shown in above fig. This
frequency can be varied over a long range just by varying the preset R1 and C1.
IR Receiver:
FIG 4: CIRCUIT OF IR RECEIVER
5
7/30/2019 Project Report on Dynamic Traffic System
16/46
The IR receiver consists of TSOP 1738 module which is a simple yet effective IR
proximity sensor built around the TSOP 1738 module. The TSOP module is commonly
found at the receiving end of an IR remote control system; e.g., in TVs, CD players etc.
These modules require the incoming data to be modulated at a particular frequency and
would ignore any other IR signals. It is also immune to ambient IR light, Such modules
are available for different carrier frequencies from 32 kHz to 42kHz.
In this particular proximity sensor, we will be generating a constant stream of square
wave signal using IC555 centered at 38 kHz and would use it to drive an IR led. So
whenever this signal bounces off the obstacles, the receiver would detect it and change its
output. Since the TSOP 1738 module works in the active-low configuration, its output
would normally remain high and would go low when it detects the signal (the obstacle).
Basically an ir sensor is used for detecting an obstacle, there are some areas where
valuable things are placed, an IR transmitter and receiver is placed there, an infrared path
is established and if any person comes into that path the buzzer gets on which gives out a
long beep Similarly a fire sensor is used to detect fire
The sensed data is given to the microcontroller, processing is done according to the logic
in the microcontroller and then writes onto GSM which will further send sms to the
mobile at the user
A buzzer is interfaced to microcontroller to give out a beep sound whenever an obstacle
and fire is detected
6
7/30/2019 Project Report on Dynamic Traffic System
17/46
2.5 Schematic Diagram:
FIG 5: SCHEMATIC DIAGRAM OF CIRCUIT
7
7/30/2019 Project Report on Dynamic Traffic System
18/46
2.6 Schematic Explanation:
Power Supply:
The schematic diagram gives the basic hardware connections used in the
project. Beginning from the power supply the secondary of the step-down transformer
wires are given to the two ends (2,4) of bridge rectifier which is having the four diodes in
the bridge formate.The other two ends 1,3)are connected to the input(pin 1) and output
pin 3 of the 7805 regulator and pin no 2 is connected to ground as shown in schematic
diagram. The 1000 micro farad capacitor is connected in between the bridge rectifier
and regulator to eliminate the ac ripples presented in the rectified output. The 100 micro
farad capacitor is used to eliminate the noise at regulator output. Now 5V is available at
the pin no 3 of regulator and connected to pin no 40 of micro controller.
AT89S52 micro controller :
The 8051 micro controller consists 40 pins and every pin has its own functionality as
shown in the schematic diagram.
The port 0 is having the pull up resistor which is having eight 10K resistors in
parallel each connected to the each pin of it.
IR Led:
The IR LED is arranged with a resistor ,in such a way that Vcc is applied to the positive
terminal of the IR LED.These are connected to the port 1 of the microcontroller.
IR Receiver:
The IR receivers are arranged with the transistor logic as shown in the diagram.
The two transistors are connected in such a manner that collector terminal is connected to
the base terminal of the other. The photo diode is connected to the base of the transistor
along with the combination of the resistor.
The IR Receivers are connected to the port 2 P2.0,,P2.1,P2.2,P2.3 pins of the
microcontroller.
8
7/30/2019 Project Report on Dynamic Traffic System
19/46
Chapter-3
HARDWARE COMPONENTS
3.1 AT89S52 Microcontroller:
3.1.1 Description:
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller
with 8K bytes of in-system programmable Flash memory. The device is
manufactured using Atmels high-density nonvolatile memory technology and is
compatible with the indus-try-standard 80C51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a
conventional nonvolatile memory pro-grammer. By combining a versatile 8-bit
CPU with in-system programmable Flash on a monolithic chip, the Atmel
AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-
effective solution to many embedded control applications. The AT89S52 provides
the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O
lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector
two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and
clock circuitry. In addition, the AT89S52 is designed with static logic for
operation down to zero frequency and supports two software selectable power
saving modes. The Idle Mode stops the CPU while allowing the RAM,
timer/counters, serial port, and interrupt system to continue functioning. The
Power-down mode saves the RAM con-tents but freezes the oscillator, disabling
all other chip functions until the next interrupt or hardware reset.
9
7/30/2019 Project Report on Dynamic Traffic System
20/46
FIG 6: AT89S52 MICROCONTROLLER
3.1.2 Features :
Compatible with MCS-51 Products
8K Bytes of In-System Programmable (ISP) Flash Memory
4.0V to 5.5V Operating Range
Fully Static Operation: 0 Hz to 33 MHz
Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters
Eight Interrupt Sources
Full Duplex UART Serial Channel
Low-power Idle and Power-down Modes
Interrupt Recovery from Power-down Mode
Watchdog Timer
Dual Data Pointer
10
7/30/2019 Project Report on Dynamic Traffic System
21/46
Power-off Flag
Fast Programming Time
Flexible ISP Programming (Byte and Page Mode)
Green (Pb/Halide-free) Packaging Option
3.1.3BlockDiagram:
FIG 7: BLOCK DIAGRAM OF AT89S52 MICROCONTROLLER
11
7/30/2019 Project Report on Dynamic Traffic System
22/46
3.1.4 Pin Diagram:
FIG 8: PIN DIAGRAM OF AT89S52
12
7/30/2019 Project Report on Dynamic Traffic System
23/46
Pin Description:
VCC: Supply voltage.
GND: Ground.
PORT 0: Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each
pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as
high-impedance inputs. Port 0 can also be configured to be the multiplexed low-order
address/data bus during accesses to external program and data memory. In this mode, P0
has internal pull-ups. Port 0 also receives the code bytes during Flash programming and
outputs the code bytes dur-ing program verification.
PORT 1:
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers
can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high
by the inter-nal pull-ups and can be used as inputs. As inputs, Port 1 pins that are
externally being pulled low will source current (IIL) because of the internal pull-ups. In
addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input
(P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in
the follow-ing table. Port 1 also receives the low-order address bytes during Flash
programming and verification.
TABLE 1: PORTS SHOWING THE ALTERNATE FUNCTIONS AT PORT 1
13
7/30/2019 Project Report on Dynamic Traffic System
24/46
PORT 2:
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers
can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high
by the inter-nal pull-ups and can be used as inputs. As inputs, Port 2 pins that are
externally being pulled low will source current (IIL) because of the internal pull-ups. Port
2 emits the high-order address byte during fetches from external program memory and
dur-ing accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In
this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to
external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents
of the P2 Special Function Register. Port 2 also receives the high-order address bits and
some control signals during Flash program-ming and verification.
Port Pin Alternate Functions:
P1.0 T2 (external count input to Timer/Counter 2), clock-out P1.1 T2EX (Timer/Counter
2 capture/reload trigger and direction control) P1.5 MOSI (used for In-System
Programming) P1.6 MISO (used for In-System Programming) P1.7 SCK (used for In-
System Programming)5 1919DMICRO6/
PORT 3:
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers
can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high
by the inter-nal pull-ups and can be used as inputs. As inputs, Port 3 pins that are
externally being pulled low will source current (IIL) because of the pull-ups. Port 3
receives some control signals for Flash programming and verification. Port 3 also serves
the functions of various special features of the AT89S52, as shown in the fol-lowing
table.
14
7/30/2019 Project Report on Dynamic Traffic System
25/46
7/30/2019 Project Report on Dynamic Traffic System
26/46
PSEN: Program Store Enable (PSEN) is the read strobe to external program
memory.When the AT89S52 is executing code from external program memory, PSEN is
activated twice each machine cycle, except that two PSEN activations are skipped
XTAL1: Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2 :Output from the inverting oscillator amplifier.
Program Memory:
If the EA pin is connected to GND, all program fetches are directed to external memory.
On the AT89S52, if EA is connected to VCC, program fetches to addresses 0000H
through 1FFFH are directed to internal memory and fetches to addresses 2000H through
FFFFH are to external memory.
Data Memory: The AT89S52 implements 256 bytes of on-chip RAM. The upper 128
bytes occupy a parallel address space to the Special Function Registers. This means that
the upper 128 bytes have the same addresses as the SFR space but are physically separate
from SFR space. When an instruction accesses an internal location above address 7FH,
the address mode used in the instruction specifies whether the CPU accesses the upper
128 bytes of RAM or the SFR space. Instructions which use direct addressing access the
SFR space. For example, the following direct addressing instruction accesses the SFR at
location 0A0H (which is P2). MOV 0A0H, #data Instructions that use indirect addressing
access the upper 128 bytes of RAM. For example, the following indirect addressing
instruction, where R0 contains 0A0H, accesses the data byte at address 0A0H, rather than
P2 (whose address is 0A0H). MOV @R0, #data Note that stack operations are examples
of indirect addressing, so the upper 128 bytes of data RAM are available as stack space.
16
7/30/2019 Project Report on Dynamic Traffic System
27/46
Watchdog Timer (One-Time Enabled With Reset-Out):
The WDT is intended as a recovery method in situations where the CPU may be
subjected to software upsets. The WDT consists of a 14-bit counter and the Watchdog
Timer Reset (WDTRST) SFR. The WDT is defaulted to disable from exiting reset. To
enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST register
(SFR location 0A6H). When the WDT is enabled, it will increment every machine cycle
while the oscillator is running. The WDT timeout period is dependent on the external
clock frequency. There is no way to disable the WDT except through reset (either
hardware reset or WDT overflow reset). When WDT over-flows, it will drive an output
RESET HIGH pulse at the RST pin.
Using The WDT:
To enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST
register (SFR location 0A6H). When the WDT is enabled, the user needs to service it by
writing 01EH and 0E1H to WDTRST to avoid a WDT overflow. The 14-bit counter
overflows when it reaches 16383 (3FFFH), and this will reset the device. When the WDT
is enabled, it will increment every machine cycle while the oscillator is running. This
means the user must reset the WDT at least every 16383 machine cycles. To reset the
WDT the user must write 01EH and 0E1H to WDTRST. WDTRST is a write-only
register. The WDT counter cannot be read or written. WhenWDT overflows, it will
generate an output RESET pulse at the RST pin. The RESET pulse dura-tion is
98xTOSC, where TOSC = 1/FOSC. To make the best use of the WDT, it should be
serviced in those sections of code that will periodically be executed within the time
required to prevent a WDT reset.
UART :The UART in the AT89S52 operates the same way as the UART in the
AT89S52 and AT89C52.
17
7/30/2019 Project Report on Dynamic Traffic System
28/46
Timer 0 and 1:
Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and Timer 1 in
the AT89S52 and AT89C52.
Timer 2:
Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter.
The type of operation is selected by bit C/T2 in the SFR T2CON (shown in Table 5-2).
Timer 2 has three operating modes: capture, auto-reload (up or down counting), and baud
rate generator. The modes are selected by bits in T2CON, as shown in Table 10-1. Timer
2 consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is
incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods,the count rate is 1/12 of the oscil-lator frequency.
TABLE3: TIMER 2 OPERATING MODES
In the Counter function, the register is incremented in response to a 1-to-0 transition at its
corre-sponding external input pin, T2. In this function, the external input is sampled
during S5P2 of every machine cycle. When the samples show a high in one cycle and a
low in the next cycle, the count is incremented. The new count value appears in the
register during S3P1 of the cycle following the one in which the transition was detected.
Since two machine cycles (24 oscillator periods) are required to recognize a 1-to-0
transition, the maximum count rate is 1/24 of the oscillator frequency.
18
7/30/2019 Project Report on Dynamic Traffic System
29/46
To ensure that a given level is sampled at least once before it changes, the level should be
held for at least one full machine cycle.
Oscillator Characteristics:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that
can be configured for use as an on-chip oscillator, as shown in Figure 16-1. Either a
quartz crystal or ceramic resonator may be used. To drive the device from an external
clock source, XTAL2 should be left unconnected while XTAL1 is driven, as shown in
Figure 16-2. There are no requirements on the duty cycle of the external clock signal,
since the input to the internal clock-ing circuitry is through a divide-by-two flip-flop, but
minimum and maximum voltage high and low time specifications must be observed.
FIG9: OSCILLATOR CONNECTIONS
19
7/30/2019 Project Report on Dynamic Traffic System
30/46
FIG 10: EXTERNAL CLOCK DRIVE CONFIGURATION
Programming The Flash Parallel Mode:
The AT89S52 is shipped with the on-chip Flash memory array ready to be programmed.
The programming interface needs a high-voltage (12-volt) program enable signal and is
compatible with conventional third-party Flash or EPROM programmers. The AT89S52
code memory array is programmed byte-by-byte.
Programming Algorithm:
Before programming the AT89S52, the address, data, and control signals should be set upaccording to the Flash Programming Modes (Table 22-1) and Figure 22-1 and Figure
22-2. To program the AT89S52, take the following steps: 1. Input the desired memory
location on the address lines. 2. Input the appropriate data byte on the data lines. 3.
Activate the correct combination of control signals. 4. Raise EA/VPP to 12V. 5. Pulse
ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write
cycle is self-timed and typically takes no more than 50 s. Repeat steps 1 through 5,
changing the address and data for the entire array or until the end of the object file is
reached.
20
7/30/2019 Project Report on Dynamic Traffic System
31/46
3.2 Power Supply:
The power supplies are designed to convert high voltage AC mains electricity to a
suitable low voltage supply for electronics circuits and other devices. A power supply can
by broken down into a series of blocks, each of which performs a particular function. A
d.c power supply which maintains the output voltage constant irrespective of a.c mains
fluctuations or load variations is known as Regulated D.C Power Supply
FIG 11: 5V REGULATED POWER SUPPLY
3.3 Voltage Regulator:
Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable output
voltages. The maximum current they can pass also rates them. Negative voltage
regulators are available, mainly for use in dual supplies. Most regulators include some
automatic protection from excessive current ('overload protection') and overheating
('thermal protection'). Many of the fixed voltage regulator ICs have 3 leads and look like
power transistors, such as the 7805 +5V 1A regulator shown on the right. The LM7805 is
simple to
21
7/30/2019 Project Report on Dynamic Traffic System
32/46
use. You simply connect the positive lead of your unregulated DC power supply
(anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the
Common pin and then when you turn on the power, you get a 5 volt supply from the
output pin.
FIG 12: EXAMPLE CIRCUIT SHOWING 5V DC OUTPUT
3.4 Transformer:
A transformer is an electrical device which is used to convert electrical power from one
Electrical circuit to another without change in frequency.
Transformers convert AC electricity from one voltage to another with little loss of
power. Transformers work only with AC and this is one of the reasons why mains
electricity is AC. Step-up transformers increase in output voltage, step-down
transformers decrease in output voltage. Most power supplies use a step-down
transformer to reduce the dangerously high mains voltage to a safer low voltage. The
input coil is called the primary and the output coil is called the secondary. There is no
electrical connection between the two coils; instead they are linked by an alternating
magnetic field created in the soft-iron core of the transformer. The two lines in the middle
of the circuit symbol represent the core. Transformers waste very little power so the
power out is (almost) equal to the power in. Note that as voltage is stepped down current
is stepped up. The ratio of the number of turns on each coil, called the turns ratio,
determines the ratio of the voltages. A step-down transformer has a large number of turns
on its primary (input) coil which is connected to the high voltage mains supply, and a
small number of turns on its secondary (output) coil to give a low output voltage.
22
7/30/2019 Project Report on Dynamic Traffic System
33/46
FIG 13: An Electrical Transformer
Turns ratio = Vp/ VS = Np/NS
Power Out= Power In
VS X IS=VP X IP
Vp = primary (input) voltage
Np = number of turns on primary coil
Ip = primary (input) current
3.5 Capacitor Filter:
We have seen that the ripple content in the rectified output of half wave rectifier is
121% or that of full-wave or bridge rectifier or bridge rectifier is 48% such high
percentages of ripples is not acceptable for most of the applications. Ripples can be
removed by one of the following methods of filtering.
(a) A capacitor, in parallel to the load, provides an easier by pass for the ripples voltage
though it due to low impedance. At ripple frequency and leave the d.c.to appears the load.
(b) An inductor, in series with the load, prevents the passage of the ripple current (due to
high impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c)
(c) Various combinations of capacitor and inductor, such as L-section filter section
filter, multiple section filter etc. which make use of both the properties mentioned in (a)
and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and
another with full wave rectifier.
23
7/30/2019 Project Report on Dynamic Traffic System
34/46
Filtering is performed by a large value electrolytic capacitor connected across the
DC supply to act as a reservoir, supplying current to the output when the varying DC
voltage from the rectifier is falling. The capacitor charges quickly near the peak of the
varying DC, and then discharges as it supplies current to the output. Filtering
significantly increases the average DC voltage to almost the peak value (1.4 RMS
value).
To calculate the value of capacitor(C),
C = *3*f*r*Rl
Where,
f = supply frequency,
r = ripple factor,
Rl = load resistance
Note: In our circuit we are using 1000F. Hence large value of capacitor is placed
to reduce ripples and to improve the DC component.
3.6 Light Emitting Diodes (LED'S):
Example: Circuit symbol:
FIG 14: LED FIG 15: CIRCUIT OF LED
3.6.1 Function:
LEDs emit light when an electric current passes through them.
3.6.2 Connecting And Soldering:
LEDs must be connected the correct way round, the diagram may be labelled a or
+ for anode and k or- for cathode (yes, it really is k, not c, for cathode!). The cathode is
the short lead and there may be a slight flat on the body of round LEDs. If you can see
inside the LED the cathode is the larger electrode (but this is not an official identification
method). 24
7/30/2019 Project Report on Dynamic Traffic System
35/46
LEDs can be damaged by heat when soldering, but the risk is small unless you are
very slow. No special precautions are needed for soldering most LEDs.
3.6.3 Testing An Led:
Never connect an LED directly to a battery or power supply!
It will be destroyed almost instantly because too much current will pass through and burn
it out. LEDs must have a resistor in series to limit the current to a safe value, for quick
testing purposes a 1k resistor is suitable for most LEDs if your supply voltage is 12V or
less. Remember to connect the LED the correct way round!
3.7 IR Led:
3.7.1 Description:The QED233 / QED234 is a 940 nm GaAs/AlGaAs LED encapsulated in a clear untinted,
plastic T-1 3/4 package.
FIG16: IR LED FIG17: SCHEMATIC OF IR LED
25
7/30/2019 Project Report on Dynamic Traffic System
36/46
3.7.2 Features:
Lambda= 940 nm
Chip material =GaAs with AlGaAs window
Package type: T-1 3/4 (5mm lens diameter)
Matched Photo sensor: QSD122/123/124
Medium Emission Angle, 40
High Output Power
Package material and color: Clear, untinted, plastic
Ideal for remote control applications
3.8 LCD Interfacing:
3.8.1 Introduction:
The most commonly used Character based LCDs are based on Hitachi's HD44780
controller or other which are compatible with HD44580. In this tutorial, we will discuss
about character based LCDs, their interfacing with various microcontrollers, various
interfaces (8-bit/4-bit), programming, special stuff and tricks you can do with these
simple looking LCDs which can give a new look to your application.
3.8.2 Pin Description:
The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line
LCDs which have only 1 controller and support at most of 80 characters, whereas LCDs
supporting more than 80 characters make use of 2 HD44780 controllers.
Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two
pins are extra in both for back-light LED connections). Pin description is shown in the
table below.
26
7/30/2019 Project Report on Dynamic Traffic System
37/46
TABLE 4: PIN DISCRIPTION OF LCD
27
Pin No. Name Description
Pin no. 1 VSS Power supply (GND)
Pin no. 2 VCC Power supply (+5V)
Pin no. 3 VEE Contrast adjust
Pin no. 4 RS0 = Instruction input
1 = Data input
Pin no. 5 R/W
0 = Write to LCD module
1 = Read from LCD
module
Pin no. 6 EN Enable signal
Pin no. 7 D0 Data bus line 0 (LSB)
Pin no. 8 D1 Data bus line 1
Pin no. 9 D2 Data bus line 2
Pin no. 10 D3 Data bus line 3
Pin no. 11 D4 Data bus line 4
Pin no. 12 D5 Data bus line 5
Pin no. 13 D6 Data bus line 6
Pin no. 14 D7 Data bus line 7 (MSB)
7/30/2019 Project Report on Dynamic Traffic System
38/46
DDRAM - Display Data RAM:
Display data RAM (DDRAM) stores display data represented in 8-bit character codes. Its
extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM
(DDRAM) that is not used for display can be used as general data RAM. So whatever
you send on the DDRAM is actually displayed on the LCD. For LCDs like 1x16, only 16
characters are visible, so whatever you write after 16 chars is written in DDRAM
CGROM - Character Generator ROM:
Now you might be thinking that when you send an ASCII value to DDRAM, how the
character is displayed on LCD? So the answer is CGROM. The character generator ROM
generates 5 x 8 dot or 5 x 10 dot character patterns from 8-bit character codes (see Figure5 and Figure 6 for more details). It can generate 208 5 x 8 dot character patterns and 32 5
x 10 dot character patterns. User defined character patterns are also available by mask-
programmed ROM.As you can see in both the code maps, the character code from 0x00
to 0x07 is occupied by the CGRAM characters or the user defined characters. If user
wants to display the fourth custom character then the code to display it is 0x03 i.e. when
user sends 0x03 code to the LCD DDRAM then the fourth user created character or
pattern will be displayed on the LCD.
CGRAM - Character Generator RAM:
As clear from the name, CGRAM area is used to create custom characters in LCD. In the
character generator RAM, the user can rewrite character patterns by program. For 5 x 8
dots, eight character patterns can be written, and for 5 x 10 dots, four character patterns
can be written.
BF - Busy Flag:
Busy Flag is a status indicator flag for LCD. When we send a command or data to the
LCD for processing, this flag is set (i.e. BF =1) and as soon as the instruction is executed
28
7/30/2019 Project Report on Dynamic Traffic System
39/46
successfully this flag is cleared (BF = 0). This is helpful in producing and exact amount
of delay for the LCD processing.To read Busy Flag, the condition RS = 0 and R/W = 1
must be met and The MSB of the LCD data bus (D7) act as busy flag. When BF = 1
means LCD is busy and will not accept next command or data and BF = 0 means LCD is
ready for the next command or data to process.
Instruction Register (IR) and Data Register (DR):
There are two 8-bit registers in HD44780 controller Instruction and Data register.
Instruction register corresponds to the register where you send commands to LCD e.g.
LCD shift command, LCD clear, LCD address etc. and Data register is used for storing
data which is to be displayed on LCD. When send the enable signal of the LCD is
asserted, the data on the pins is latched in to the data register and data is then moved
automatically to the DDRAM andhenceisdisplayedontheLCD.
Data Register is not only used for sending data to DDRAM but also for CGRAM, the
address where you want to send the data, is decided by the instruction you send to LCD.
4-Bit Programming Of LCD:In 4-bit mode the data is sent in nibbles, first we send
the higher nibble and then the lower nibble. To enable the 4-bit mode of LCD, we need to
follow special sequence of initialization that tells the LCD controller that user has
selected 4-bit mode of operation. We call this special sequence as resetting the LCD.
Following is the reset sequence of LCD.
Wait for about 20mS
Send the first init value (0x30)
Wait for about 10mS
Send second init value (0x30)
Wait for about 1mS Send third init value (0x30)
Wait for 1mS
Select bus width (0x30 - for 8-bit and 0x20 for 4-bit)
29
7/30/2019 Project Report on Dynamic Traffic System
40/46
The busy flag will only be valid after the above reset sequence. Usually we do not use
busy flag in 4-bit mode as we have to write code for reading two nibbles from the LCD.
Instead we simply put a certain amount of delay usually 300 to 600uS. This delay might
vary depending on the LCD you are using, as you might have a different crystal
frequency on which LCD controller is running. So it actually depends on the LCD
module you are using. In 4-bit mode, we only need 6 pins to interface an LCD. D4-D7
are the data pins connection and Enable and Register select are for LCD control pins. We
are not using Read/Write (RW) Pin of the LCD, as we are only writing on the LCD so we
have made it grounded permanently. If you want to use it, then you may connect it on
your controller but that will only increase another pin and does not make any big
difference. Potentiometer RV1 is used to control the LCD contrast. The unwanted data
pins of LCD i.e. D0-D3 are connected to ground.
Sending data/command in 4-bit Mode:
We will now look into the common steps to send data/command to LCD when working
in 4-bit mode. In 4-bit mode data is sent nibble by nibble, first we send higher nibble and
then lower nibble. This means in both command and data sending function we need to
separate the higher 4-bits and lower 4-bits.The common steps are:
Mask lower 4-bits
Send to the LCD port
Send enable signal
Mask higher 4-bits
Send to LCD port
Send enable signal
30
7/30/2019 Project Report on Dynamic Traffic System
41/46
Chapter-4
WORKING FLOW OF THE PROJECT&CONCLUSION
4.1 Block Diagram:
FIG 18: BLOCK DIAGRAM OF WORKING OF PROJECT
This project is mainly designed to reduce traffic problems. i.e. in general the four sides of
the road at a signal point are controlled at regular intervals of time with a certain time
delay. But in order to reduce the time at one side of the signal point with respect to the
other side where there is more traffic we use IR sensors. It mainly consists of a
microcontroller.
31
8051
MICRO
CONTROLLER
LCD
IR
RECIEVER
IR
TRANSMITTER
REGULATED
POWERSUPPLY
7/30/2019 Project Report on Dynamic Traffic System
42/46
IR transmitter placed nearer to the signal point and when it detects more density of traffic
at any side it and it transmits signal to the receiver. The receiver receives this signal to the
microcontroller. Thus accordingly the LCD displays the time depending on the density of
traffic. Here the regulated power supply is used to drive the microcontroller. Hence with
the help of IR transmitter we can easily control traffic.
4.2 Circuit Description:
In this project we required operating voltage for Microcontroller 89C51 is 5V. Hence the
5V D.C. power supply is needed for the ICs. This regulated 5V is generated by stepping
down the voltage from 230V to 18V now the step downed a.c voltage is being rectified
by the Bridge Rectifier using 1N4007 diodes. The rectified a.c voltage is now filtered
using a C filter. Now the rectified, filtered D.C. voltage is fed to the Voltage Regulator.
This voltage regulator provides/allows us to have a Regulated constant Voltage which is
of +5V. The rectified; filtered and regulated voltage is again filtered for ripples using an
electrolytic capacitor 100F. Now the output from this section is fed to 40thpin of 89C51
microcontroller to supply operating voltage. The microcontroller 89C51 with Pull up
resistors at Port0 and crystal oscillator of 11.0592 MHz crystal in conjunction with
couple of 30-33pf capacitors is placed at 18th
& 19th
pins of 89s52 to make it work
(execute) properly.
One of the main problems in our citys is traffic, this project proposed new
solution to traffic control. The main design accept of this project is to control the traffic
automatically and adding human inelegancy to that automatic controller. "Four-way"
intersection is the most common configuration for roads that cross each other, and the
most basic type. If signals do not control a 4-way intersection, signs or other features are
typically used to control movements and make clear priorities.
For IR communication we are using an IR transmitter and IR receiver. Here IR
LED will acts as a transmitter. As we know microcontroller having inbuilt I/O ports and
we are interfacing IR receivers to those I/O ports. For controlling of traffic we are using
red, green and yellow color LEDs.
32
7/30/2019 Project Report on Dynamic Traffic System
43/46
These LEDs are connected to different I/O ports of microcontroller. When there is a
more traffic microcontroller gives signal to green LED and it will glow. So by using this
project we can control the traffic automatically like a human being.
4.3 Software:
Software used is:
*Keil software for C programming
*Express PCB for lay out design
*Express SCH for schematic design
4.3.1 Keil Vision:
What's New in Vision3?
Vision3 adds many new features to the Editor like Text Templates, Quick Function
Navigation, and Syntax Coloring with brace high lighting Configuration Wizard for
dialog based startup and debugger setup. Vision3 is fully compatible to Vision2 and
can be used in parallel with Vision2.
What is Vision3?
Vision3 is an IDE (Integrated Development Environment) that helps you write, compile,
and debug embedded programs. It encapsulates the following components:
A project manager.
A make facility.
Tool configuration.
Editor.
A powerful debugger.
Express PCB: Express PCB is a Circuit Design Software and PCB manufacturing
service. One can learn almost everything you need to know about Express PCB from the
help topics included with the programs given.
Details: Express PCB, Version 5.6.0
33
7/30/2019 Project Report on Dynamic Traffic System
44/46
Express SCH:
The Express SCH schematic design program is very easy to use. This
software enables the user to draw the Schematics with drag and drop options. A Quick
Start Guide is provided by which the user can learn how to use it.
Details: Express SCH, Version 5.6.0
4.3.2 Embedded C:
The programming Language used here in this project is an
Embedded C Language. This Embedded C Language is different from the generic C
language in few things like
a) Data types
b) Access over the architecture addresses.
The Embedded C Programming Language forms the user friendly language with access
over Port addresses, SFR Register addresses etc.
Data Types Size in Bits Data Range/Usage
unsigned char 8-bit 0-255
signed char 8-bit -128 to +127
unsigned int 16-bit 0 to 65535
signed int 16-bit -32,768 to +32,767
sbit 1-bit SFR bit addressable only
Bit 1-bit RAM bit addressable only
sfr 8-bit RAM addresses 80-FFH
only
TABLE5: EMBEDDED C DATA TYPES
34
7/30/2019 Project Report on Dynamic Traffic System
45/46
Chapter-5
CONCLUSION
The project density based traffic control system has been successfully designed
and tested. Integrating features of all the hardware components used have developed it.
Presence of every module has been reasoned out and placed carefully thus contributing to
the best working of the unit. Secondly, using highly advanced ICs and with the help of
growing technology the project has been successfully implemented.
35
7/30/2019 Project Report on Dynamic Traffic System
46/46
References:
[1]. The 8051 Micro controller and Embedded Systems-Muhammad Ali Mazidi,Janice
Gillispie Mazidi
[2]. The 8051 Micro controller Architecture Programming & Applications-KennethJ.Ayala
[3]. Fundamentals Of Micro processors and Micro computers -B.Ram
[4]. Micro processor Architecture, Programming & Applications -Ramesh
S.Gaonkar
[5]. Electronic Components -D.V.Prasad
[6]. Wireless Communications - Theodore S. Rappaport
[7]. Mobile Tele Communications - William C.Y. Lee
REFERENCE ON WEB:
www.national.com
www.nxp.com
www.8052.comwww.microsoftsearch.com
www.geocities.com