Sei sulla pagina 1di 23

Project Report on

Microcontroller
Based Traffic Light
Controller
Name IDNO
1- Liban Mohamud Ali 788
2- Mohamed Abdinor Ahmed 837
3- Yahye Muse Dahir 1567
4- Zakariye Osman Ahmed 848
5- Abdimalik Dahir Ahmed 812
6- Sead Abdikadir husien 844
CONTENTS

1. ABSTRACT

2. INTRODUCTION

3. BLOCK DIAGRAM AND EXPLANATION

4. HARDWARE DESCRIPTION

™ MICROCONTROLLER UNIT
™ Traffic Light
™ Light Emitting Diode (LED)
™ DISPLAY

5. SOFTWARE

6. BIBLIOGRAPHY
Acknowledgement

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

project mentor, EngSaed 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 led’s as the

indication of light. A micro controller is interfaced to led’s 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 pre-specified
time interval.

Microcontroller AT89c51 is the brain of the project which initiates the traffic signal
at a junction. The led’s 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
CONTROLLER
LED
(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 high-
density 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 8051’s on-chip memory consists of 256 memory
bytes organized as follows:
First 128 bytes: 00h to 1Fh Register Banks
20h to 2Fh Bit Addressable RAM
30 to 7Fh General Purpose RAM
Next 128 bytes: 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 (SFR’s) 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.
Traffic Light

TRAFFIC LIGHT CONTROL MODULE USING SENSORS


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.
The emission of these photons occurs when the diode junction is forward
biased by an external voltage allowing current to flow across its junction, and
in Electronics we call this process electroluminescence.
The actual colour of the visible light emitted by an LED, ranging from blue to
red to orange, is decided by the spectral wavelength of the emitted light which
itself is dependent upon the mixture of the various impurities added to the
semiconductor materials used to produce it.

7-segment Display
Light emitting diodes have many advantages over traditional bulbs and lamps,
with the main ones being their small size, long life, various colours, cheapness
and are readily available, as well as being easy to interface with various other
electronic components and digital circuits.
But the main advantage of light emitting diodes is that because of their small
die size, several of them can be connected together within one small and
compact package producing what is generally called a 7-segment Display.
The 7-segment display, also written as “seven segment display”, consists of
seven LEDs (hence its name) arranged in a rectangular fashion as shown.
Each of the seven LEDs is called a segment because when illuminated the
segment forms part of a numerical digit (both Decimal and Hex) to be
displayed. An additional 8th LED is sometimes used within the same package
thus allowing the indication of a decimal point, (DP) when two or more 7-
segment displays are connected together to display numbers greater than ten.
Each one of the seven LEDs in the display is given a positional segment with
one of its connection pins being brought straight out of the rectangular plastic
package. These individually LED pins are labelled from a through
to g representing each individual LED. The other LED pins are connected
together and wired to form a common pin.
So by forward biasing the appropriate pins of the LED segments in a particular
order, some segments will be light and others will be dark allowing the desired
character pattern of the number to be generated on the display. This then
allows us to display each of the ten decimal digits 0 through to 9 on the same
7-segment display.
The displays common pin is generally used to identify which type of 7-
segment display it is. As each LED has two connecting pins, one called the
“Anode” and the other called the “Cathode”, there are therefore two types of
LED 7-segment display called: Common Cathode (CC) and Common
Anode (CA).
The difference between the two displays, as their name suggests, is that the
common cathode has all the cathodes of the 7-segments connected directly
together and the common anode has all the anodes of the 7-segments
connected together and is illuminated as follows.
1. The Common Cathode (CC) – In the common cathode display, all the
cathode connections of the LED segments are joined together to logic “0” or
ground. The individual segments are illuminated by application of a “HIGH”, or
logic “1” signal via a current limiting resistor to forward bias the individual
Anode terminals (a-g).

Common Cathode 7-segment Display

2. The Common Anode (CA) – In the common anode display, all the anode
connections of the LED segments are joined together to logic “1”. The
individual segments are illuminated by applying a ground, logic “0” or “LOW”
signal via a suitable current limiting resistor to the Cathode of the particular
segment (a-g).
Common Anode 7-segment Display

In general, common anode displays are more popular as many logic circuits
can sink more current than they can source. Also note that a common cathode
display is not a direct replacement in a circuit for a common anode display
and vice versa, as it is the same as connecting the LEDs in reverse, and
hence light emission will not take place.
Depending upon the decimal digit to be displayed, the particular set of LEDs is
forward biased. For instance, to display the numerical digit 0, we will need to
light up six of the LED segments corresponding to a, b, c, d, e and f. Thus the
various digits from 0 through 9 can be displayed using a 7-segment display as
shown.

7-Segment Display Segments for all Numbers.

Then for a 7-segment display, we can produce a truth table giving the
individual segments that need to be illuminated in order to produce the
required decimal digit from 0 through 9 as shown below.

SOFTWARE
NG BIT P2.4
NY BIT P2.3
NR BIT P2.5
SG BIT P0.4
SY BIT P0.5
SR BIT P0.3
WG BIT P2.1
WY BIT P2.2
WR BIT P2.0
EG BIT P0.1
EY BIT P0.0
ER BIT P0.2

ORG 0000H
MOV P0,#0FFH
MOV P2,#0FFH
NORTH: 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
EAST: CLR EG
CLR SR
CLR WR
CLR NR
ACALL DELAY
CLR EY
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
SOUTH: 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
WEST: 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: MOV R0,#0FFH


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

DELAY1: MOV R0,#0FFH


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

BIBLIOGRAPHY

[1] 8051 Microcontroller

-V Udayshankar & M S mallikarjunaswamy

[3] www.wikipedia.org

[4] www.microcontroller.com

Potrebbero piacerti anche