You are on page 1of 17

Traffic Light Controller

Final Report
Submitted By:

Kris Danek, Austin Batten, Brandon Maciel, Jonathan Thompson

Team 6

Technical Report Submitted In Partial Fulfillment of the


ETEE3255 Lab VII

Fall Semester, 2010

Instructor: Barry Sherlock

Submitted: October 14th, 2010


Lab 7-Team 4
Final Report
1
Abstract:
With today’s economy and lifestyles, the average number of vehicles on
highways and rural streets has significantly increased over the past 20 years.
With the high demand of vehicles that commute amongst working citizens and
students in school, changes in traffic patterns and roadways are imperative to
meet the demands of today’s society.
The concentration of this study is focusing on controlling traffic patterns on
rural streets throughout the United States via traffic lights. This design could be
used in multiple applications across the United States in thousands of working
environments located within cities and in rural regions of the country. Two
streets will be used to model typical American traffic intersections, Main Street
and Easy Street. Nighttime and daytime driving conditions differ drastically from
each other, and this project will endeavor to make each condition efficient.
During the day, one street will be allowed to proceed while the other is stopped,
and vice versa. At night, Main Street will normally allow traffic to proceed until the
rare need for Easy Street traffic to proceed.
Lab 7-Team 4
Final Report
2
I. Background History:

“The first four-way, three-color traffic light was created by police officer

William Potts in Detroit, Michigan in 1920”(History of Traffic Light,2004). What he

had in mind was figuring out a way to adapt railroad signals for street use. Potts

used red, amber, and green railroad lights and about thirty-seven dollars worth of

wire and electrical controls to make the world’s first 4-way three color traffic light.

It was installed in 1920 on the corner of Woodward and Michigan Avenues in

Detroit. Within a year, Detroit had installed a total of fifteen of the new automatic

lights.

Easy and Main Streets have raised issues in the community of Gastonia

regarding efficiency and safety. The community has stated that it needs an

intersection traffic light system that allows normal traffic to proceed safely

throughout the day. At night, traffic volume through this area is substantially less

than during the day. Therefore, the community has proposed that a design be

made to normally allow Main Street traffic to proceed while only allowing Easy

Street traffic to proceed when a vehicle is at the intersection. This can be

addressed by using sensors that can activate/deactivate the traffic signal when a

vehicle is detected at Easy Street.

The ATmega 128 is a low-power CMOS 8-bit microcontroller based on the

AVR enhanced RISC architecture. By executing powerful instructions in a single

clock cycle, the ATmega128 achieves throughputs approaching 1 MIPS per MHz

allowing the system engineer to optimize power consumption versus processing

speed. The AVR core combines instruction set with 32 general purpose working
Lab 7-Team 4
Final Report
3
registers. All the 32 registers are directly connected to the Arithmetic Logic Unit

(ALU), allowing two independent registers to be accessed in one single

instruction executed in one clock cycle. The resulting architecture is more code

efficient while achieving throughputs up to ten times faster than conventional

CISC microcontrollers. The device is manufactured using Atmel’s high-density

nonvolatile memory technology. The boot program can use any interface to

download the application program in the application Flash memory.

II. Review of Current Literature

1. ATMega 128 Uses

http://www.atmel.com/dyn/products/product_card.asp?part_id=2018 , by Atmel

AVR Products, provides multiple PDF files for uses of the ATMega 128

microcontroller chip and programming logic.

The authors show keys points of programming for the microcontroller chip.

Engineering specifications, such as inputs and outputs, can be found in the

documentations provided by Atmel.

III. Experimental Method

The experiment was completed successfully by defining the necessary

steps needed in order to fulfill the project requirements. A network diagram

was created in order to demonstrate the method that was used throughout the

experiment and is shown on page 4.


Lab 7-Team 4
Final Report
4

Fig. 1 Experimental Method Network Diagram

The first step of the experiment was to integrate the project objectives

into a tangible experimental process. The specific guideline of the

simulated traffic light has two operational modes; daytime and nighttime.

The daytime mode will follow a strict, reoccurring pattern that will allow

each direction of traffic to continue through the intersection without

incident. Nighttime mode will streamline the traffic light function, using

sensors that detect vehicles and change the light to allow for continuation.

The traffic light will be in the center of an intersection of two streets,

representing the four major points of direction. There will be three lights:

red, green, and yellow. There will also be a 5 second delay between one

light switching on and one switching off. The assigned specifications are

shown below in Figure 2.


Lab 7-Team 4
Final Report
5

Fig.2 Project Constraints


Lab 7-Team 4
Final Report
6
With the objectives clearly defined, decisions were made regarding

which hardware and software to use. The microprocessor board required

as per project requirements was an AVR ATmega 328. A toolbox

containing an ATmega 328, AVR Joint Test Action Group (JTAG) USB

adapter, and computer installation software was checked out of UNCC’s

Engineering Technology department. In order to differentiate between

night and day, a photodiode circuit was created. A Radio Shack Cadmium

Sulphide (CdS) photo cell was decided upon to be used by the team. Port

7 was designated on the AT Mega 328 that ran from the photodiode circuit

that would trigger nighttime mode. It must be noted that daytime mode

was the “always on unless disabled” convention of circuit. To regulate

voltage to the AT Mega 328 that enabled/disabled nighttime mode a 741

op amp was used. In addition to the 741 op amp, #!@ resistors were used

to regulate voltages. Resistance amounts were calculated using

mathematical formulas. The base voltage was found using

Eq. 4-1

where VB is base voltage, VRDAY is daytime voltage, and VRNIGHT is

nighttime voltage. Using Eq. 4-1, the nighttime voltage was found to be

4.7V while the normal or daytime voltage was also found to be 4.7V.

Next, base current was found using

Eq.4-2

where IB is base current and R is the resistor. The team used a 65 K


Lab 7-Team 4
Final Report
7
resistor for daytime mode and a 3 M resistor for nighttime mode. Using

Eq. 4-2, the nighttime base current needed was found to be 1.5 nA while

the daytime base current needed was found to be 72 nA.

The collector voltage was found by measuring the voltage over the

collector with a digital multi-meter. The daytime collector voltage was

measured 4.897 V and the nighttime collector voltage was measured at

309 mV.

Next, the collector current was found by using

Eq. 4-3

where VC was a measured collector voltage, IC was the collector current,

and Rd was a decided upon resistance due to resistors the team had on

hand. Using Eq. 4-3, the nighttime collector current needed was found to

be 309 nA and the daytime collector current needed was found to be

4.897 mA.

Next, Beta was found using

Eq. 4-4

where is Beta or the current gain. Using Eq. 4-4, the nighttime Beta

needed was found to be 206 and the daytime Beta needed was found to

be 68.

Eq. 4-5

When the nighttime and daytime currents obtained from using Eq. 4-3 and

using Eq. 4-5, the collector voltage VC for daytime mode was 4.897 V for a
Lab 7-Team 4
Final Report
8
logical 1. The logical 1 would be used in the C program for normal

operation, or daytime operation. Collector voltage for nighttime mode was

found to be 309 mV using the collector current IC from Eq. 4-3 and Eq. 4-5.

The collector voltage VC for nighttime mode was 309 mV for a logical 0

which would be used in the C program for nighttime operation.

The next step in the experimental method was for the team to decide

on which software, and therefore computer language which would be used

for the project. The CodeVision AVR C compiler was decided to be used

due to overall AVR JTAG USB adapter compatibility with the software.

Next, a C program was designed in order to meet the constraints of

the project. Using CodeVision AVR Windows Vista software, a program

was designed using C language and is shown on pages 8 and 9 in Figure

3 and 4.

Lines 15 and 16 in Figure 3 demonstrate the two Amtel AVR header files

that were used to access the libraries used throughout the program. The

program begins in Figure 3, lines 18-20, via an initialization sequence.

The program used was a basic “while” loop (Figure 3, line 22), with an

“if” statement (Figure 4, line 33) functioning as daytime mode and an

“else” statement (Figure 4, line 48) functioning as nighttime mode. An

additional “if” statement (Figure 4, line 55) was added to the program in

order to activate the car sensor that enabled Easy Street’s green light to

be activated at night.
Lab 7-Team 4
Final Report
9

Fig. 3 Program Code Section 1


Lab 7-Team 4
Final Report
10

Fig. 4 Program Code Section 2.

IV. Experimental Results

To demonstrate proper operation of the program code shown in Figures 3

and 4, the program was loaded onto the AT Mega 328 circuit board. First, the

daytime mode was tested in lab and the results were entered into Table 1 on

page 11.
Lab 7-Team 4
Final Report
11

Table I: Daytime Light Status Table

Table I demonstrates the sucessful operation of the circuit and the program by

indicating what LED’s are on or off during the experimental procedure. For

example, when the green LED for Main Street was on, Easy Street’s red LED

was on, and vice versa. There is also a delay before either streets green LED’s

turn on, during which the red LED’s for Main and Easy streets remain on for five

seconds. The program was tested with small LED’s in the laboratory and with a

simulated traffic intersection model. Results of the LED’s were the same for both

tests and and are shown in the Daytime Light Status Table shown above.

Next, nighttime mode was tested. This was done with small LED’s in the

laboratory and with a simulated traffic intersection model. Table II was filled out

with results from the tests in the laboratory on the simulated traffic intersection
Lab 7-Team 4
Final Report
12
model and results for both tests were the same. A magnet was placed over a

sensor approximatly two inches before Easy Street’s LED. Approximately 10

seconds later, Main Street’s LED went from green to yellow to red, then Easy

Street’s LED turned green. One function was missing from the program that was

stated in the requirements, but was not detected until project presentation. Easy

Street’s LED was supposed to remain green until a vehicle was detected at Main

Street. Next, Easy Street’s LED was supposed to turn from green to red to

yellow and Main Street’s LED was supposed to turn green. This mistake was

due to lack of clarity during the teams assessment of the project’s requirements.

Table II: Nighttime Light Status Table

V. Conclusion

Upon successful integration of the designed program at the intersection of

Main and Easy streets, traffic is now flowing better at Easy and Main streets.
Lab 7-Team 4
Final Report
13
The traffic light project went as planned and was completed on time and

product costs were within reasonable limits. With the project complete,

looking back the team could have finished earlier than expected which could

have saved time as well as labor expenses.

Within the programming design itself, a minor mistake was made in the

program for the traffic light. At an instant, both streets are “red” at the same

time. This was an added step by the team that was thought to be a safety

design to allow cars an interval time between lights incase other cars decide

to “run a light”. This added step was not in the scope handed to the team by

Dr. Sherlock and should have been addressed before inserting the added

design into the program.

VI. List of References


Lab 7-Team 4
Final Report
14
1. AVR Products,” ATMega Specs”

http://www.atmel.com/dyn/products/product_card.asp?part_id=2018

2. William Summerfield Dubel IV, “ATmega 128 Resources”

http://dubel.org/atmel/

3. Wikipedia “History of Traffic Light” , http://en.wikipedia.org/wiki/Traffic_light

4. Barry Sherlock’s Webpage for Project Specifications

http://www.coe.uncc.edu/~sherlock/etee3255/index.html

VII. Bibliography
Lab 7-Team 4
Final Report
15

VIII. Appendices
Lab 7-Team 4
Final Report
16

You might also like