Simplified Traffic Lights Using 8051 Maxim DS89C4XX Embedded Controller (MDE)
Simplified Traffic Lights Using 8051 Maxim DS89C4XX Embedded Controller (MDE)
net/publication/336020390
CITATIONS READS
0 149
2 authors:
Some of the authors of this publication are also working on these related projects:
PhD research in vision & image processing (Detection and tracking of non-linear moving and occlusion object) View project
All content following this page was uploaded by Rotimi-Williams Bello on 25 September 2019.
RESEARCH ARTICLE
the yellow light, it used buzzer sound to signal get Figure 1: (a) Traffic lights, (b) Traffic light control module
using sensors
ready status. The limitation found in the work of
Lester Wire motivated another policeman named
APPLICATION PROGRAM TRAFFIC
William Potts in Detroit, Michigan, to invent first
LIGHT
four-way and three-colored traffic lights that had
yellow/amber as the third color [Figure 1a]. Presented in this section is a program we wrote
The automated traffic lights were a huge success for the application simplified traffic light. The
toward the middle of the 19th century; lights application program traffic light is the foundation
were changed by themselves at a fixed interval on which the application simplified traffic lights in
though causing unnecessary queuing as the light Section 3 is based.
would be red even in the absence of traffic.
This also led to what motivated engineers and
scientists to think of a better traffic monitoring Simple traffic light program
system. Charles Adler Jr. had a brief contribution • THIS PROGRAM WILL MAKE THE
to traffic system with his invented machine
LED TURN OFF AND THEN ON. LED IS
that could detect vehicle’s honking and change
CONNECTED TO P1.1
signals accordingly, but the noise generated
1. ORG 00H
by this invention during its operation due to
THE ORG OOH TELLS THE
the unnecessary honking of vehicles, thereby
MICROCONTROLLER FROM WHERE
causing excruciating experience to passerby and
IT SHOULD START
people living around the place the machine was
mounted, this led to its ban.[1] 2. AGAIN: CLR P1.1; NOW THE BIT P1.1
Traffic lights started to become computer-aided IS LOW. THIS MEANS THAT THE LED
during the early 1960s [Figure 1b] making all the IS OFF
limitations experienced in the early inventions 3. MOV R1, #0FFH; MOVES FF HEXA I.E
perfected. Powerful software applications were 255 (DECIMAL) TO R1
designed that could predict and control the traffic 4. HERE: DJNZ R1, HERE; DECREMENTS
of congested cities. This paper contributes to R1 AND THEN CHECKS IF R1 IS ZERO
the traffic lights technology by writing program • OTHERWISE JUMPS TO HERE AND
for the MDE trainer kit to control the outputs of DECREMENTS R1
the microcontroller in a given sequence, thereby 5. SETB P1.1; SETB SETS THE P1.1 AND
simplifying traffic light. The remainder of the THE LED IS NOW TURNED ON
paper is structured as follows. In Section 2, the THE CODE BELOW IS TO ADD A LITTLE
programs involved in application simplified DELAY TO OBSERVE THE OUTPUT
traffic light are shown. Laboratory experimental 6. MOV R1, #0FFH
results and discussion of application simplified 7. HERE2: DJNZ R1, HERE2
traffic light are presented in Section 3. Section 4 • IMPROVE THE PROGRAM BY MAKING
concludes the paper. THE LED BLINK. THIS WILL MAKE
AJMS/Jul-Sep-2019/Vol 3/Issue 3 52
Bello and Olubummo: Simplified traffic lights using embedded controller
THE LED BLINK INDEFINITELY. LED IS 24. MOV P1, #0FFH; MAKES THE PORT
CONNECTED TO P1.1 1 AS INPUT PORT SO IT BEHAVE AS
8. ORG 30H; THIS ORG 30H TELLS THE INPUT
MICROCONTROLLER FROM WHERE 25. MOV P3, #00H; MOVES ALL ZEROS
IT SHOULD START TO PORT 3 MAKES THEM TO BEHAVE
9. CLR P1.1; NOW THE BIT P1.1 IS LOW. AS OUTPUTS
THIS MEANS THAT THE LED IS OFF 26. CHKSW1: JNB SW1, CHKSW2; IF
10. MOV R1, #0FFH; MOV COMMAND SWITCH 1 IS OFF P1.1 IS LOW THEN
MOVES FF HEXA I.E 255 (DECIMAL) CHECK IF SWITCH 2 IS ON
TO R1 27. CLR LED2; TO SWITCH OFF LED IF IT
11. DJNZ R1, HERE; DJNZ DECREMENTS WAS ON
R1 AND THEN CHECKS IF R1 IS ZERO 28. CPL LED1; MAKE THE LED BLINK.
OTHERWISE JUMPS TO HERE WHERE CPL IS THE COMMAND FOR
IT DECREMENTS R1 AGAIN COMPLIMENT WILL INVERT THE
12. SETB P1.1; SETB SETS THE P1.1 AND LED FROM ITS PREVIOUS STATE IF
THE LED IS NOW TURNED ON THE LED IS ON THEN NOW IT WILL
13. MOV R1, #0FFH BE OFF AND VICE VERSA
14. DJNZ R1, HERE2; DELAY TO OBSERVE 29. MOV R1, #0A0H
THE OUTPUT 30. DJNZ R1, HERE
15. JMP AGAIN; JUMPS THE PROGRAM • CALL DEADTIME; CALL A SUBROUTINE
BACK TO LINE 07 AND THE “DEADTIME.” AS THIS WILL BE USED
PROGRAM CONTINUES.IN THIS III. A COUPLE OF TIMES SO IT IS BETTER
WAY WE CAN MAKE THE LED BLINK TO MAKE SUBROUTINE RATHER THAN
16. END WRITING THE CODE AGAIN AND AGAIN
• THE NEXT PART OF THE LABORATORY 31. JMP CHKSW1; THIS CHECKS
IS TO READ THE INPUT SWITCHES, WHETHER THE SW1 IS STILL ON OR
ONE FROM THE WALK PUSH BUTTON NOT IF YES IT WIL MAKE THE LED
AND THE OTHER INDICATING A CAR BLINK
AT THE CROSSING. AS SWITCHES 32. CHKSW2: JNB SW2, CHKSW1
ARE MECHANICAL OBJECTS; SOME 33. CLR LED1; TO WITCH THE LED1 OFF
DEBOUNCE TIME (DEAD TIME) WILL IT WAS STILL ON
ALSO BE PLACED IN THE PROGRAM. 34. CPL LED2; MAKE THE LED BLINK.
EACH LED WILL BE CONTROLLED WITH CPL IS THE COMMAND FOR
ONE SWITCH; AS LONG AS THE SWITCH COMPLIMENT WILL INVERT THE
IS ACTIVE; THE RESPECTIVE LED IS ON LED FROM ITS PREVIOUS STATE IF
AND WHEN SWITCH IS INACTIVE, THE THE LED IS ON THEN NOW IT WILL
CORRESPONDING LED IS OFF. THEN, BE OFF AND VICE VERSA
THE LED WILL BE MADE TO BLINK AS 35. MOV R1, #0A0H
LONG AS SWITCH IS ON 36. DJNZ R1, HERE2
• THIS PROGRAM WILL TAKE THE INPUT 37. CALL DEADTIME; CALL A
FROM A SWITCH AND CONTROL THE SUBROUTINE “DEADTIME.” AS
LED THIS WILL BE USED A COUPLE OF
17. SW1=P1.1;SW2=P1.3; LED1=P3.1; TIMES SO IT IS BETTER TO MAKE
LED2=P3.2 SUBROUTINE RATHER THEN
18. EQU; TAKES THE INPUT AND WRITING THE CODE AGAIN AND
ASSIGNS IT A NAME AGAIN
19. SW1 EQU P1.1 38. JMP CHKSW2; THIS CHECKS
20. SW2 EQU P1.3 WHETHER THE SW2 IS STILL ON OR
21. LED1 EQU P3.1 NOT IF YES IT WIL MAKE THE LED
22. LED2 EQU P3.3 BLINK
23. ORG 00H 39. DEADTIME
AJMS/Jul-Sep-2019/Vol 3/Issue 3 53
Bello and Olubummo: Simplified traffic lights using embedded controller
AJMS/Jul-Sep-2019/Vol 3/Issue 3 54
Bello and Olubummo: Simplified traffic lights using embedded controller
54. disp(2);
55. }
56. }
Seven-segment display
A seven-segment display is an electronic display
device for displaying decimal numerals. A seven-
segment display is composed of seven elements.
Individually on or off, they can be combined to
produce simplified representations of the Arabic Figure 4: Cathode type display
numerals.
The set values and the selected time intervals are
shown on the seven-segment display [Figure 3].
There are two types of displays available. One
is common anode type display and the other is
common cathode type display. In common cathode
type display, all the cathodes of the segments are
tied together and connected to ground [Figure 4].
The supply will be given to the required segment Figure 5: Anode type display
from the decoder or driver.
In common anode type display, the anodes of Port 1 is used for the seven-segment data. The
all the segments are tied together and connected seven segments are arranged as a rectangle of two
to supply and the required segments will be vertical segments on each side with one horizontal
connected to ground from the decoder or driver segment on the top, middle, and bottom. In
[Figure 5]. addition, the seventh segment bisects the rectangle
AJMS/Jul-Sep-2019/Vol 3/Issue 3 55
Bello and Olubummo: Simplified traffic lights using embedded controller
horizontally. In a simple LED package, typically, false indication due to infrared leakage. An object
all of the cathodes (negative terminals) or all of moving nearby actually reflects the infrared rays
the anodes (positive terminals) of the segment emitted by the infrared LED.
LEDs are connected together and brought out to The infrared receiver has a sensitivity angle (lobe)
a common pin; this is referred to as a “common of 0–60°, hence, when the reflected IR ray is sensed,
cathode” or “common anode” device. Hence, a the mono in the receiver part is triggered. The
seven-segment plus decimal point package will output from the mono may be used in any desired
only require nine pins.[2-5] fashion. For example, it can be used to turn on a
A single byte can encode the full state of a
seven-segment display. The most popular bit Table 1: Hexadecimal reference for seven segments LED
encodings are gfedcba and abcdefg – both light on/off functions
usually assume 0 is off and 1 is on [Table 1]. Digit gfedcba abcdefg a b c d e f g
0 0X3F 0X7E On On On On On On Off
Figure 6 gives the hexadecimal encodings for
1 0X06 0X30 Off On On Off Off Off Off
displaying the digits 0–9.
2 0X5B 0X6D On On Off On On Off On
The timer of microcontroller is interfaced with
3 0X4F 0X79 On On On On Off Off On
seven-segment display to display the delay of
4 0X66 0X33 Off On On Off Off On On
light. The decoder enhances the capability of
5 0X6D 0X5B On Off On On Off On On
accommodation for more number of seven-
6 0X7D 0X5F On Off On On On On On
segment displays with the same number of port
7 0X07 0X70 On On On Off Off Off Off
pins. The current-limiting resistor associated with 8 0X7F 0X7F On On On On On On On
each segment limits the current at the cost of 9 0X6F 0X7B On On On On Off On On
illumination. The drop across each segment will
be 2 V approximately. The maximum current that
the segment can handle is 10 mA.
Current drawn by segment = (Supply voltage–
Drop across segment)/Resistance = (5 v–2 v)/
1k = 3 mA (1)
This proximity detector using an infrared detector
shown in Figure 5 can be used in various equipment
like alarm devices. The circuit primarily consists
of an infrared transmitter and an infrared receiver.
The transmitter section consists of a 555 timer
IC functioning in a stable mode. It is wired as
shown in Figure 7. The output from a stable is
fed to an infrared LED through resistor R4, which
limits its operating current. This circuit provides
Figure 6: A seven-segment display
a frequency output of 38 kHz at 50% duty cycle,
which is required for the infrared detector/receiver
module [Figure 8].
The receiver section comprises an infrared
receiver module, a 555 monostable multivibrator,
and an LED indicator. On reception of infrared Figure 7: Serial interrupt example
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 R7 × C6) depending
on the value of R7–C6 combination. Thus, if
R7 = 470 kΩ and C6 = 4.7 μF, the mono period
will be around 2.5 s.[6,7]
Both the transmitter and the receiver parts can
be mounted on a single breadboard or printed
circuit board. The infrared receiver [Figure 9]
must be placed behind the infrared LED to avoid Figure 8: A proximity detector using an infrared detector
AJMS/Jul-Sep-2019/Vol 3/Issue 3 56
Bello and Olubummo: Simplified traffic lights using embedded controller
light when a person comes nearby by energizing a For example, in our LED flashing program, the
relay. The light would automatically turn off after LED was turned on for a specific length of time
sometime as the person moves away and the mono and then turned off for a specific length of time.
pulse period is over. The sensitivity of the detector We achieved this through the use of time delays.
depends on current-limiting resistor R4 in series Since the microcontroller operates at a specific
with the infrared LED. Range is approximately frequency, we could work out exactly how many
40 cm. For 20-ohm value of R4, the object at 25 cm iterations of the time delay were needed to give us
can be sensed, while for 30-ohm value of R4, the the desired delay. However, this is cumbersome
sensing range reduces by 22.5 cm. and prone to error. Moreover, there is another
disadvantage; the central processing unit (CPU) is
occupied, stepping through the loops. If we use
CONCLUSION the on-chip timers, the CPU could be off doing
something more useful while the timers take on
This article has exposed the use of microprocessor the menial task of keeping track of time.
and various electronic components used in For the control and program of the serial port of
developing an embedded system found in traffic the microcontroller in a given sequence, we left
lights. We studied the application of 8051 that as future work.
microcontroller to traffic lights. The basic 8051
has two on-chip timers [Figure 10] that can be
used for timing durations or for counting external REFERENCES
events. Interval timing allows the programmer to 1. Mazidi MA, Mazidi JG, McKinlay RD. The 8051
perform operations at specific instants in time. Microcontroller and Embedded Systems: Using
AJMS/Jul-Sep-2019/Vol 3/Issue 3 57
Bello and Olubummo: Simplified traffic lights using embedded controller
AJMS/Jul-Sep-2019/Vol 3/Issue 3 58
View publication stats