Vous êtes sur la page 1sur 22

ProjectReporton

MicrocontrollerBased
TrafficLight
Controller

CONTENTS
1. ABSTRACT
2. INTRODUCTION
3. BLOCK DIAGRAM AND EXPLANATION
4. CIRCUIT DIAGRAM
5. HARDWARE DESCRIPTION
MICROCONTROLLER UNIT
LIGHT EMITTING DIODE (LED)
DISPLAY
6. SOFTWARE
7. DATA SHEETS
8. COMPONENTS REQUIRED
9. FUTURE SCOPE
10. BIBLIOGRAPHY

Acknowledgement

I take this opportunity to express my deep gratitude and sincerest thank to my


project mentor, Mr. SANJOY BANERJEE for giving most valuable suggestion, helpful
guidance and encouragement in the execution of this project work.

I will like to give a special mention to my colleagues. Last but not the least I am
grateful to all the faculty members of Ardent Computech Pvt. Ltd. or their support.

ABSTRACT
Vehicular traffic at intersecting streets is typically controlled by traffic control lights.
The function of traffic lights requires sophisticated control and coordination to
ensure that traffic moves as smoothly and safely as possible.

In recent days electro-mechanical controllers are replaced by electronic circuits.


The accuracy & fault tolerant drive towards electronic circuits.

This project is developed to meet the requirements of solid state traffic light
controller by adopting microcontroller as the main controlling element, and leds as the
indication of light. A micro controller is interfaced to leds provide for centralized control
of the traffic signals. Microcontroller is programmed in such a way to adjust their timing
and phasing to meet changing traffic conditions. The circuit besides being reliable and
compact is also cost effective.

INTRODUCTION
Traffic congestion is a severe problem in many modern cities around the world.
Traffic congestion has been causing many critical problems and challenges in the
major and most populated cities. To travel to different places within the city is becoming
more difficult for the travelers in traffic. Due to these congestion problems, people lose
time, miss opportunities, and get frustrated. Traffic congestion directly impacts the
companies. Due to traffic congestions there is a loss in productivity from workers, trade
opportunities are lost, delivery gets delayed, and thereby the costs goes on increasing.
To solve these congestion problems, we have to build new facilities &
infrastructure but at the same time make it smart. The only disadvantage of making
new roads on facilities is that it makes the surroundings more congested. So for that
reason we need to change the system rather than making new infrastructure twice.
Therefore many countries are working to manage their existing transportation systems
to improve mobility, safety and traffic flows in order to reduce the demand of vehicle
use.
The project uses simple Electronic components such as LED as TRAFFIC
LIGHT indicator and a MICROCONTROLLER for auto change of signal after a prespecified time interval.
Microcontroller AT89c51 is the brain of the project which initiates the traffic
signal at a junction. The leds are automatically on and off by making the corresponding
port pin of the micro controller high. A seven segment display also connected to display
the timing of each signal. At a particular instant only one green light holds and other
lights hold at red. During transition from green to red, the present group yellow led and
succeeding group yellow led glows and then succeeding group led changes to green.
This process continues as a cycle.

BLOCK DIAGRAM

POWER
SUPPLY
(+5v)

8051

MICRO
LED

CONTROLL
ER
(AT89C51)

HARDWARE DESCRIPTION

MICRO-CONTROLLER UNIT:
Micro-controller unit is constructed with ATMEL 89C51 Micro-controller chip. The
ATMEL AT89C51 is a low power, higher performance CMOS 8-bit microcomputer with
4K bytes of flash programmable and erasable read only memory (PEROM). Its highdensity non-volatile memory compatible with standard MCS-51 instruction set makes it
a powerful controller that provides highly flexible and cost effective solution to control
applications.

Fig-Block Diagram

Pin Description:Pins 1-8: Port 1: Each of these pins can be configured as an input or an output.
Pin 9: RS A logic one on this pin disables the microcontroller and clears the contents of
most registers. In other words, the positive voltage on this pin resets the
microcontroller. By applying logic zero to this pin, the program starts execution from the
beginning.

Pins10-17: Port 3 Similar to port 1, each of these pins can serve as general input or
output. Besides, all of them have alternative functions:
Pin10: RXD Serial

asynchronous

communication

input

or

Serial

synchronous

communication output.
Pin 11: TXD Serial asynchronous communication output or Serial synchronous
communication clock output.
Pin 12: INT0 Interrupt 0 input.
Pin 13: INT1 Interrupt 1 input.
Pin 14: T0 Counter 0 clock input.
Pin 15: T1 Counter 1 clock input.
Pin 16: WR Write to external (additional) RAM.
Pin 17: RD Read from external RAM.
Pin 18, 19: X2, X1 : Internal oscillator input and output. A quartz crystal which specifies
operating frequency is usually connected to these pins. Instead of it, miniature
ceramics resonators can also be used for frequency stability. Later versions of
microcontrollers operate at a frequency of 0 Hz up to over 50 Hz.
Pin 20: GND Ground.
Pin 21-28: Port 2 If there is no intention to use external memory then these port pins
are configured as general inputs/outputs. In case external memory is used, the higher
address byte, i.e. addresses A8-A15 will appear on this port. Even though memory with
capacity of 64Kb is not used, which means that not all eight port bits are used for its
addressing, the rest of them are not available as inputs/outputs.
Pin 29: PSEN If external ROM is used for storing program then a logic zero (0)
appears on it every time the microcontroller reads a byte from memory.

Pin 30: ALE Prior to reading from external memory, the microcontroller puts the lower
address byte (A0-A7) on P0 and activates the ALE output. After receiving signal from
the ALE pin, the external register (usually 74HCT373 or 74HCT375 add-on chip)
memorizes the state of P0 and uses it as a memory chip address. Immediately after
that, the ALU pin is returned its previous logic state and P0 is now used as a Data Bus.
As seen, port data multiplexing is performed by means of only one additional (and
cheap) integrated circuit. In other words, this port is used for both data and address
transmission.
Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and address
transmission with no regard to whether there is internal memory or not. It means that
even there is a program written to the microcontroller, it will not be executed. Instead,
the program written to external ROM will be executed. By applying logic one to the EA
pin, the microcontroller will use both memories, first internal then external (if exists).
Pin 32-39: Port 0: Similar to P2, if external memory is not used, these pins can be
used as general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7)
when the ALE pin is driven high (1) or as data output (Data Bus) when the ALE pin is
driven low (0).
Pin 40: VCC +5V power supply.

Micro-controller works according to the program written in it. The program is


written in such a way, so that this controller energizes or de-energizes the relays
according to the information received by the pushbuttons and the sensing probe.
The 8051 series of microcontrollers are highly integrated single Chip
microcomputers with an 8-bit CPU, memory, interrupt controller, timers, Serial I/O and
digital I/O on a single piece of silicon. The 8051 is an 8-bit Machine. Its memory is
organized in bytes and practically all its instruction deal with byte quantities. It uses an
Accumulator as the primary register for instruction Results. Other operands can be

accessed using one of the four different addressing modes available: register implicit,
direct, indirect or immediate. Operands reside in one of the five memory spaces of the
8051.
The five memory spaces of the 8051 are: Program Memory, External Data
Memory, Internal Data Memory, Special Function Registers and Bit Memory.

Fig: 8051 Memory Representation

The Program Memory space contains all the instructions, immediate data and
constant tables and strings. It is principally addressed by the 16-bit Program Counter
(PC), but it can also be accessed by a few instructions using the 16-bit Data Pointer
(DPTR). The maximum size of the Program Memory space is 64K bytes. Several 8051
family members integrate on-chip some amount of either masked programmed ROM or
EPROM as part of this memory.
The Internal Data Memory of 8051s on-chip memory consists of 256 memory
bytes organized as follows:

First 128 bytes:

Next 128 bytes:

00h to 1Fh

Register Banks

20h to 2Fh

Bit Addressable RAM

30 to 7Fh

General Purpose RAM

80h to FFh

Special Function Registers

The first 128 bytes of internal memory is organized as shown in figure and is
Referred to as Internal RAM, or IRAM.

Fig: Organisation of Internal RAM (IRAM) memory


Register Banks 00h to 1Fh:

The 8051 uses 8 general-purpose registers R0 through R7 (R0, R1, R2, R3, R4,
R5,R6, and R7).
Bit Addressable RAM: 20h to 2Fh:
The 8051 supports a special feature which allows access to bit variables. This is
Where individual memory bits in Internal RAM can be set or cleared. In all there are
128 bits numbered 00h to 7Fh. Being bit variables any one variable can have a value 0
or 1. A bit variable can be set with a command such as SETB and cleared with a
Command such as CLR.
General Purpose RAM: 30h to 7Fh:
These 80 bytes of Internal RAM memory are available for general-purpose data
storage. Access to this area of memory is fast compared to access to the main memory
and special instructions with single byte operands are used. However, these 80 bytes
are used by the system stack and in practice little space is left for general storage. The
general purpose RAM can be accessed using direct or indirect addressing modes.
SFR Registers:
The SFR registers are located within
the Internal Memory in the address range 80h
to FFh. Not all locations within this range are
defined. Each SFR has a very specific
function. Each SFR has an address (within
the range 80h to FFh) and a name which
reflects the purpose of the SFR. Although 128
byes of the SFR address space is defined
only 21 SFR registers are defined in the
standard 8051. Undefined SFR addresses
should not be accessed as this might lead to
some unpredictable results. Note some of the
SFR registers are bit addressable. SFRs are
accessed just like normal Internal RAM
locations.
PSW Program Status Word:

PSW, the Program Status Word is at address D0h and is a bit-addressable register.
The status bits are listed in table.

Table: Program status word (PSW) flags


Carry flag. C
This is a conventional carry, or borrows, flag used in arithmetic operations. The carry
flag is also used as the Boolean accumulator for Boolean instruction operating at the
bit level. This flag is sometimes referenced as the CY flag.
Auxiliary carry flag. AC
This is a conventional auxiliary carry (half carry) for use in BCD arithmetic.
Flag 0. F0
This is a general-purpose flag for user programming.
Register bank select 0 and register bank selects 1. RS0 and RS1
These bits define the active register bank (bank 0 is the default register bank).
Overflow flag. OV
This is a conventional overflow bit for signed arithmetic to determine if the result of a
signed arithmetic operation is out of range.
Even Parity flag. P
The parity flag is the accumulator parity flag, set to a value, 1 or 0, such that the
number of 1 bits in the accumulator plus the parity bit add up to an even number.

The register implicit, indirect and direct addressing modes can be used in
different parts of the Internal Data Memory space.
The Special Function Register space contains all the on-chip peripheral I/O
registers as well as particular registers that need program access. These registers
include the Stack Pointer, the PSW and the Accumulator. The maximum number of
Special Function Registers (SFRs) is 128, though the actual number on a particular
8051 family member depends on the number and type of peripheral functions
integrated on-chip.
The External Data Memory space contains all the variables, buffers and data
structures that can't fit on-chip. It is principally addressed by the 16-bit Data Pointer
(DPTR), although the first two general purpose register (R0, R1) of the currently
selected register bank can access a 256-byte bank of External Data memory. The
maximum size of the External Data Memory space is 64Kbytes. External data memory
can only be accessed using the indirect addressing mode with the DPTR, R0 or R1.

REGULATOR
They maintain a constant voltage level independent of load condition or
variation in the amplitude of the Ac supply .An example of
regulator is LM78xx series It is the three terminal device
with input (1) , ground(2), output(3) as its terminals. The
voltage required for micro controller is 5V. Hence LM7805
voltage regulator is used. These devices require no
adjustments and have an output preset by manufactures to
industry standard voltages of 5, 6, 8, 12, 15, 18, 24V.
Zener regulator is incorporated for maintaining 12v regulated output used for sensing
probes and Electromagnetic relay.

Light Emitting Diode (LED):


A light-emitting diode (LED) is a semiconductor light source. The color of the
light is determined by the energy gap of the semiconductor.

PRINCIPLE:
When a light-emitting diode is forward biased electrons are able to recombine
with electron holes within the device, releasing energy in the form of photons. This
effect is called electroluminescence. Electroluminescence (EL) is an optical and
electrical phenomenon in which a material emits light in response to the passage of an
electric current or to a strong electric field. The wavelength of the light emitted, and
thus its color depends on the band gap energy of the materials forming the p-n
junction. The materials used for the LED have a direct band gap with energies
corresponding to near-infrared, visible or near-ultraviolet light.

CONSTRUCTION:
LEDs are usually built on an n-type substrate, with an electrode attached to the p-type
layer deposited on its surface. P-type substrates, while less common, occur as well.
Many commercial LEDs, especially GaN/InGaN, also use sapphire substrate. Most

materials used for LED production have very high refractive indices. Light extraction in
LEDs is an important aspect of LED production.

SOFTWARE
NG
NY
NR
SG
SY
SR
WG
WY
WR
EG
EY
ER

NORTH:

EAST:

BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT

P2.4
P2.3
P2.5
P0.4
P0.5
P0.3
P2.1
P2.2
P2.0
P0.1
P0.0
P0.2

ORG 0000H
MOV P0,#0FFH
MOV P2,#0FFH
CLR NG
CLR SR
CLR WR
CLR ER
ACALL DELAY
CLR NY
ACALL DELAY1
SETB NY
ACALL DELAY1
CLR NY
ACALL DELAY1
SETB NY
ACALL DELAY1
CLR NY
ACALL DELAY1
SETB NY
ACALL DELAY1
SETB NG
SETB SR
SETB WR
SETB ER
CLR EG
CLR SR
CLR WR
CLR NR
ACALL DELAY
CLR EY

SOUTH:

WEST:

ACALL DELAY1
SETB EY
ACALL DELAY1
CLR EY
ACALL DELAY1
SETB EY
ACALL DELAY1
CLR EY
ACALL DELAY1
SETB EY
ACALL DELAY1
SETB EG
SETB SR
SETB WR
SETB NR
CLR SG
CLR ER
CLR WR
CLR NR
ACALL DELAY
CLR SY
ACALL DELAY1
SETB SY
ACALL DELAY1
CLR SY
ACALL DELAY1
SETB SY
ACALL DELAY1
CLR SY
ACALL DELAY1
SETB SY
ACALL DELAY1
SETB SG
SETB ER
SETB WR
SETB NR
CLR WG
CLR SR
CLR ER
CLR NR
ACALL DELAY
CLR WY
ACALL DELAY1
SETB WY
ACALL DELAY1
CLR WY
ACALL DELAY1
SETB WY
ACALL DELAY1
CLR WY
ACALL DELAY1

SETB WY
ACALL DELAY1
SETB WG
SETB SR
SETB ER
SETB NR
AJMP NORTH
DELAY:
HERE2:
HERE1:
HERE:

MOV R0,#0FFH
MOV R1,#0FFH
MOV R2,#20H
DJNZ R2,HERE
DJNZ R1,HERE1
DJNZ R0,HERE2
RET

DELAY1:
HERE5:
HERE4:
HERE3:

MOV R0,#0FFH
MOV R1,#0FFH
MOV R2,#02H
DJNZ R2,HERE3
DJNZ R1,HERE4
DJNZ R0,HERE5
RET

FUTURE SCOPE
This project can be enhanced in such away as to control automatically the
signals depending on the traffic density on the roads using sensors like IR
detector/receiver module extended with automatic turn off when no vehicles are
running on any side of the road which helps in power consumption saving.
This proximity detector using an infrared detector shown in fig.1 can be
used in various equipment like automatic door openers and burglar alarms. The
circuit primarily consists of an infrared transmitter and an infrared receiver. The
transmitter section consists of a 555 timer IC functioning in astable mode. It is
wired as shown in the fig. 2. The output from astable is fed to an infrared LED
via resistor R4, which limits its operating current. This circuit provides a
frequency output of 38 kHz at 50 per cent duty cycle, which is required for the
infrared detector/receiver module.

The receiver section comprises an infrared receiver module, a 555


monostable multivibrator, and an LED indicator. Upon reception of infrared
signals, 555 timer (mono) turns on and remains on as long as infrared signals
are received. When the signals are interrupted, the mono goes off after a few

seconds (period=1.1 R7xC6) depending upon the value of R7-C6 combination.


Thus if R7=470 kilo-ohms and
C6=4.7F, the mono period will be around 2.5 seconds.
Both the transmitter and the receiver parts can be mounted on a single
breadboard or PCB. The infrared receiver must be placed behind the infrared
LED to avoid false indication due to infrared leakage. An object moving nearby
actually reflects the infrared rays emitted by the infrared LED. The infrared
receiver has sensitivity angle (lobe) of 0-60 degrees, hence when the reflected
IR ray is sensed, the mono in the receiver part is triggered. The output from the
mono may be used in any desired fashion. For example, it can be used to turn
on a light when a person comes nearby by energizing a relay. The light would
automatically turn off after some time as the person moves away and the mono
pulse period is over. The sensitivity of the detector depends on current-limiting
resistor R4 in series with the infrared LED. Range is approximately 40 cm. For
20-ohm value of R4 the object at 25 cm can be sensed, while for 30-ohm value
of R4 the sensing range reduces by 22.5 cm.

IR RECEIVER CIRCUIT

TRAFFIC LIGHT CONTROL MODULE USING SENSORS

BIBLIOGRAPHY

1) Microprocessor & microcontroller


-Soumitra Kumar Mandal
2) 8051 Microcontroller
-V Udayshankar & M S mallikarjunaswamy

3) www.wikipedia.org

4) www.microcontroller.com

Vous aimerez peut-être aussi