You are on page 1of 16

ASSIGNMENT

TECHNOLOGY PARK MALAYSIA


AENG012-4-2-MMS
MICROPROCESSOR & MICROCONTROLLER SYSTEM
UCD2F1409E&E

NAME : JOSHUA JEBARAJ A/L JOSEPH


TP NUMBER: TP032057
LECTURER : MR. VEERAIYAH THANGASAMY

Task : A Traffic light controller using 8085 microprocessor


interfacing with 8255 PPI.
Introduction
This assignment is about making a traffic light controller using a 8085 microprocessor trainer
kit. Traffic light is also known as stop light is used to ensure a smoother flowing traffic especially in
the cities. Therefore we need a program to control the traffic light as traffic light has three main colors
which are red , yellow and green. In a traffic light , the light color resembles a meaning. The red color
means stop , where as the yellow indicates the driver to slow his vehicle and the green resembles go.
Traffic lights are often found at junctions. This assignments comprises of a four junction traffic light.
A precise sequence is needed to ensure the traffic light works for a purpose. Therefore a program is
determined to ensure that there is a precise pattern of changes of light to ensure that the traffic light
serves its purpose. The program is done using a 8085 microprocessor kit. The reason we use a 8085
microprocessor kit is because it has sufficient memory for the given scenario , a simple kit to use , it
also has a simple coding instructions as well as supports the necessary instructions needed. The basic
units needed for this program is also supported by the 8085 microprocessor kit.
The steps were simple , as the information on how the traffic light worked on a four way
junction was thoroughly observed and the look up table was done. Once the look up table was verified
, we bought 12 LEDs of the traffic light colors and fitted onto the breadboard marking each four
corners. Once the LEDs were placed , other steps were taken such as getting the program ready and
executing the program. I learned that the program of the traffic light controller is long as well as the
program comprises of delays. Without the delays , some of what the traffic light would not be useful
to direct traffic. In a nutshell , without traffic lights , there is no proper flow of traffic and its not easy
to create a program for a traffic light. Many observations as well as time needed to ensure a perfect
traffic light is obtained.

Objective
1. To design , build and program a microprocessor or microcontroller band system
2. To construct a prototype for 4 way Traffic light controller using a microprocessor.

Block diagram

8085

8255 PPI

Traffic light

North/ South
Port A

East / West
Port B

Block diagram 1

The first block shows a 8085 microprocessor. Microprocessors is known as a mass storage
device. They are very advanced forms of computers. They are also called microcomputers. The impact
of microprocessor in different lures of fields are very significant. Microprocessors are available of
low cost, low power and small weight, computing capability makes it useful in different applications.
Now a days, a microprocessor based systems are used in instructions, automatic testing product, speed
control of motors, traffic light control , and light control furnace.. It is very useful in the field of
instrumentation. Frequency counters, function generators, frequency synthesizers, spectrum analyses
and many other instruments are available, when microprocessors are used as controller. It is also used
in medical instrumentation. (255 interfacing - 8085 Microprocessor Course. 2015. 8255 interfacing
- 8085 Microprocessor Course. [ONLINE]

The second block is the 8255 PPI. The 8255A is a general purpose programmable input ouput
device designed for microprocessors. It consists of three 8-bit bidirectional input output ports. The
three ports are PORT A, PORT B & PORT C. Port A contains one 8-bit output latch or buffer and one
8-bit input buffer. Port B is same as PORT A. However, PORT C can be split into two parts PORT C
lower (PC0-PC3) and PORT C upper (PC7-PC4) by the control word. The three ports are divided in
two groups Group A (PORT A and upper PORT C) Group B (PORT B and lower PORT C). The two
groups can be programmed in three different modes. In the first mode (mode 0), each group may be

programmed in either input mode or output mode (PORT A, PORT B, PORT C lower, PORT C
upper). In mode 1, the seconds mode, each group may be programmed to have 8-lines of input or
output (PORT A or PORT B) of the remaining 4-lines (PORT C lower or PORT C upper. (2015. .
[ONLINE])
The block diagram shows the 8085 microprocessor interfacing with the 8255. 8085
microprocessor is defined as a silicon chip embedded with a Central Processing Unit or CPU. It is
also referred to as a computer's logic chip, microchip, and processor. The 8085 microprocessor is
interfaced with 8255 to produce a signal for the traffic light. This is by lowering the order of the 8-bit
address A0-A7 is separated from AD0-AD7 using address latch or known as buffer. The separated
address lines A0-A7 are connected to A0-A7 input pins of 8255 and the separated data bus D0-D7 are
connected to D0-D7 pins of 8255. The reset output of 8085 is connected to the reset output of 8255.
8255 does not have internal (separate) control logic generator, hence the IO/M(bar), RD(bar) and
WR(bar) control signals are not connected directly to 8255. These pins are 1st given to decoder and
decoded using 3:8 decoder (Ex: IC 74138). The generated control signals IOR(bar) and IOW(bar) are
connected to RD(bar) and WR(bar) input of 8155. An active low signal of chip select logic is
obtained decoding remaining address lines of lower order addresses A2- A7. (Applications of
Microprocessors. 2015. Applications of Microprocessors. [ONLINE])

Flow chart
Main program
Start

Load the stack


pointer for the
program

Move the data


into the
accumulator

Move the data into the control register of


8255

Convert data into


hexadecimals

Call the delay


pointer

Display the results

Delay program (Yellow)

8 seconds delay

(D)

(D) - 1

Is ctr=0?

YES

NO

Decrement
D

Delay program(Green)

10 seconds delay

(D)

(D) - 1

Is ctr=0?

YES

NO

Decrement
D

Program
Firstly the look up table was done for the four junction traffic light.

R
0
0
1
1
1
1
1
1

PORT A (PAO PA7)


N
S
Y
G
R
Y
0
1
1
0
1
0
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0

G
0
0
1
0
0
0
0
0

R
1
1
1
1
0
0
1
1

PORT B (PB0 PB7)


E
W
Y G R Y
0
0
1
0
0
0
1
0
0
0
1
0
0
1
1
0
1
0
1
0
0
0
0
0
0
0
0
1
0
0
1
0

G
0
0
0
0
0
1
0
0

HEX

HEX

0CH
14H
21H
22H
24H
24H
24H
24H
24H

24H
24H
24H
24H
0CH
14H
21H
22H
24H

Table 1 : Traffic light look up table

Then the main program was determined for the traffic light.
Main program :
Address

Opcod
e
3E
80
D3
43
3E
0C
D3
40
3E
24
D3
41
CD
00
85
3E
14
D3
40
3E
24
D3

Label

Mneumonics
MVI A , 80H
OUT 43H

BEGIN

MVI A , 0CH
OUT 40H
MVI A , 24H
OUT 41H
CALL DELAY 1

L.B
H.B
MVI A , 14 H
OUT 40H
MVI A , 24H
OUT 41H

Comments

41
CD
00
86
3E
24
D3
40
3E
0C
D3
41
CD
00
85
3E
24
D3
40
3E
1A
D3
41
CD
00
86
3E
21
D3
40
3E
24
D3
41
CD
00
85
3E
21
D3
40
3E
24
D3
41
CD
00
86
3E
24
D3
40
3E

CALL DELAY 2
L.B
H.B
MVI A , 21H
OUT 40 H
MVI A , 24H
OUT 41H
CALL DELAY 1
L.B
H.B
MVI A , 22H
OUT 40H
MVI A , 24H
OUT 41H
CALL DELAY 2
MVI A , 24H
OUT 40H
MVI A , 0CH
OUT 40H
CALL DELAY 1
MVI A , 24H
OUT 40H
MVI A , 14H
OUT 41H
CALL DELAY 2
MVI A , 24 H
OUT 40H
MVI A , 21H

21
D3
41
CD
00
85
3E
24
D3
40
3E
22
D3
41
CD
00
86
C3
04
80

OUT 41H
CALL DELAY 1
MVI A , 24H
OUT 40H
MVI A , 22H
OUT 41H
CALL DELAY 2
JMP BEGIN

Table 2 : Main program for Traffic light controller

Next the delay program was determined.


Call delay 1 program:
Address

Opcode
06
05
11
FF
FF
1B
7B
B2
C2
05
85
C2
02
85
C9

Label
DELAY 1

Mnuemonics
MVI B , 05

LOOP 2

LXI D , FFFF

LOOP 1

DCX D
MOV A , E
ORA D
JNZ LOOP 1
DCR B
JNZ LOOP 2

RET
Table 3 : Delay program 1

After that the second delay program was determined


Call Delay 2 program :

Comments

Address

Opcode
06
1E
11
FF
FF
1B
7B
B2
C2
05
86
C2
02
86
C9

Label
DELAY 1

Mnuemonics
MVI B , 30

LOOP 2

LXI D , FFFF

LOOP 1

Comments

DCX D
MOV A , E
ORA D
JNZ LOOP 1
DCR B
JNZ LOOP 2
RET

Table 4 : Delay program 2

Procedure
1. The look up table for the traffic light was determined for the four junction traffic light ; north ,
2.
3.
4.
5.
6.
7.

south , east and west.


The control word was determined.
The main program was written.
The opcode for the main program was determined
The delay program was written.
The opcode for the delay program was determined
The traffic light was set up on the bread board connecting 3 colors of LEDs ; red , green and
yellow for each position.

8.
9.
10.
11.
12.

13.

14.

15.
16.
17.

Each position is then connected using a connector to the microprocessor kit


For the North and South position, the LEDs were connected to port A.
For the East and West position , the LEDs were connected to Port B
Once the apparatus was set up , the 8085 microprocessor kit was started up.
The main program was inserted in the microprocessor kit using the following step
i)
RESET
ii)
EXAM MEMORY
iii)
8000
iv)
NEXT
v)
<opcode>
vi)
NEXT (repeated until end of program)
The delay program was inserted in the microprocessor kit using the following step
i)
RESET
ii)
EXAM MEMORY
iii)
8500
iv)
NEXT
v)
<opcode>
vi)
NEXT (repeated until end of program)
The second delay program was inserted in the microprocessor kit using the following step:
i)
RESET
ii)
EXAM MEMORY
iii)
8600
iv)
NEXT
v)
<opcode>
vi)
NEXT (repeated until end of program)
The program was then executed.
The results are compared with the look up table
Results and observation were

Hardware

Picture 1 : Shows the traffic light at attempt two

Picture 2 : The whole apparatus needed

Results
As the program was tested , our objectives were achieved. The traffic light lighted as per the look up
table as below :

R
0
0

PORT A (PAO PA7)


N
S
Y
G
R
Y
0
1
1
0
1
0
1
0

G
0
0

PORT B (PB0 PB7)


E
R Y G R Y G
1
0
0
1
0
0
1
0
0
1
0
0

HEX

HEX

0CH
14H
21H

24H
24H
24H

1
1
1
1
1
1

0
0
0
0
0
0

0
0
0
0
0
0

0
0
1
1
1
1

0
1
0
0
0
0

1
0
0
0
0
0

1
1
0
0
1
1

0
0
1
0
0
0

0
1
0
0
0
0

1
1
1
0
0
1

0
0
0
0
1
0

0
0
0
1
0
0

22H
24H
24H
24H
24H
24H

24H
0CH
14H
21H
22H
24H

Table 5 : Traffic light look up table


On the first try our traffic light did not light up. This was due the opcode that was wrongly
written. Once the opcode was changed , the traffic lighted up and took a delay of 5 seconds.

The traffic light followed these sequences as it lighted up. The changes were at 5 seconds
each. Then we increased the delay to 10 seconds and observed the traffic light. 10 seconds
seemed to long for it to change so we proceeded with 8 seconds.

After that , we observed that the delay wasnt accurate with the programmed delay. The delay
took more longer time than the programmed delay.

Discussion
The experiment was a success as the traffic lit up according to the look up table. However , as
we were inserting the delay program , few issues were noticed. When the delay program was set at 5
seconds , the delay wasnt actually 5 seconds but 7 seconds. This is because the time the machine
checks for the program allocated in the memory also affects the time of the delay therefore causes the
delay to be longer than the usual. To prove this statement , we tried increasing the delay to 12
seconds , and instead of delaying for 12 seconds , it delayed for 17 seconds.
Besides that , the light lit up according the look up table. However the last part of the look up
table had to be removed. This is due to the that the final part of the look up table was all green. In a
junction theres no light with all red. At least at one corner , the light should be green.

Besides all these , this was a successful lab task.

Conclusion
In a nutshell , a traffic light is very important use in our daily lives. To make it a simple , the
8085 microprocessor is used to make it a simple coding for easy understanding. It is also cheap and
affordable. This assignment has made me understand the use of programs , opcodes and how is the
applications of all.

Reference
255 interfacing - 8085 Microprocessor Course. 2015. 8255 interfacing - 8085 Microprocessor Course.
[ONLINE]

Available

at:

http://www.zseries.in/embedded

%20lab/8085%20microprocessor/8255%20interfacing.php#.VVMGKfmqqko. [Accessed 10 May


2015].

2015. . [ONLINE] Available at: http://nptel.ac.in/courses/108107029/module9/lecture1/lecture1.pdf.


[Accessed 12 May 2015].

Applications of Microprocessors. 2015. Applications of Microprocessors. [ONLINE] Available at:


http://scanftree.com/microprocessor/Applications-of-Microprocessors. [Accessed 13 May 2015].

You might also like