36
2016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz and Nathan Weisling EE495 Senior Project Seminar Facility: University of Evansville Advisor: Mark Randall 25 April, 2016

2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Embed Size (px)

Citation preview

Page 1: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

2016 Trinity College Home Fire Fighting Robot Competition

Submitted by Nick Schuetz and Nathan Weisling

EE495 Senior Project Seminar

Facility: University of Evansville

Advisor: Mark Randall

25 April, 2016

Page 2: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 1

Table of Contents:

Introduction

Problem Definition

Solution

Starting at Buzzer

Driving

Fire Recognition

Fire Suppression

Hardware

Software

Sustainability

Environmental Impact

Political Impact

Manufacturability

Safety and Standards

Cost

Results

Conclusions and Recommendations

Appendices

Appendix A

References

Page 3: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 2

List of Figures:

Figure 1. Basic Track Layout

Figure 2. Level 2 layout A

Figure 2. Level 2 layout B

Figure 2. Level 2 layout C

Figure 2. Level 2 layout D

Figure 6. Level 3 Arena

Figure 7. 8051 Pin Layout

Figure 8. Finished Robot

Figure 9. Pseudo Code

List of Tables:

Table1. Hardware Components

Table 2. Cost of Robot

Table 3. Travel Expenses

Page 4: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 3

Introduction

House fires are a terrifying problem that still exist in the developed world. Each year

thousands of citizens and hundreds of fire fighters are killed or injured by house fires. In addition

to deaths and injuries, house fires cost billions in lost property and clean up. The Trinity College

Home Fire Fighting Robot Competition hopes to solve this problem by bringing teams from

around the US and world to compete in an autonomous firefighting robot to spark ingenuity in

autonomously extinguishing house fires with a system within the house before the fire can grow

out of control. The senior project was to build a robot to compete for a podium position at the

2016 Trinity College Fire Fighting Robot Competition.

Problem Definition

The firefight robot needed to meet the requirements and rules as outlined by the 2016

Trinity College Fire Fighting Robot Competition Rulebook [1]. The robot had be fully

autonomous and could not receive outside changes during a trial. The robot could touch walls

during normal movement, but could not “crash” into walls at high speed. The robot was required

to fit into a bounding box 31cm x 31cm x 27cm. The only exemption to the bounding box was

the optional use of an extendable arm for level 3. The robot had to include a momentary start

button with a green background. This had to be the only start button. The microphone had to be

placed on the top of the robot. It had to have a blue background with the words MIC on the

background. An LED was required on top of the robot to indicate when the robot sees the flame.

A kill switch had to be included on the top of the robot to kill power to the sensors, motors, and

logic. The robot had to have an obvious handle for the judges to use in putting the robot in the

arena. The rules changed significantly in comparison to the 2015 rules. The competition had

Page 5: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 4

three levels within each division. The only way to compete in levels two and three was to

complete the level before it. For the first level, the robot needed to start the competition when a

fire alarm buzzer sounds. The robot then autonomously navigated through a course as outlined in

the rules to find a candle. When the candle was found, the robot used a versa valve controlled

CO2 canister to extinguish the candle. After extinguishing the candle, the robot navigated back to

its starting position. The robot earned points for completing each requirement and for how

quickly the robot is able to complete the course. The course had to be completed in under three

minutes. Figure 1 shows the basic layout and dimensions of the arena. There are 4 rooms

connected together by hallways.

Figure 1. Basic Track Layout [1]

Level two had the same requirements as level one, but added the complexity of rugs and

wall decorations as well as a dog obstacle and furniture. Level two also added a level of

complexity with four possible course layouts that were chosen at random when the robot was

turned over to the judges for a run. Level two had to be completed in under four minutes. Figures

Page 6: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 5

2, 3, 4, and 5 show the different layouts possible for the level 2 arenas. The differences between

these arenas were the entrances to rooms 1 and 4 are varied either separately or together.

Figure 2. Level 2 layout A [1] Figure 3. Level 2 layout B [1]

Figure 4. Level 2 layout C [1] Figure 5. Level 2 layout D [1]

Level three was the most challenging level. Level three had the same requirements and

obstacles as level two, but it added more complexity. In addition, the arena for level three was

made of two level two arenas put together. Figure 6 shows the level 2 arenas connected with a

hallway that was flat or inclined upon request for more possible points. Level three also featured

a search and rescue of a baby that had to be found and brought to a safe zone before the then

Page 7: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 6

three candles could be extinguished. The three candles were lit at different times throughout both

arenas during the run and all had to be extinguished. The time limit for level three was five

minutes.

Figure 6. Level 3 Arena [1]

Page 8: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 7

Scoring was based on time. Completing extra tasks took time off of the run and penalties

such as running into the dog added time onto the the total time of the run.

Requirements for this project included:

1. Produce a fully autonomous robot

2. Meet all size requirements

3. Include handle for easy transportation to arena

4. Include start button, Mic, “Fire Found” LED, and kill switch

5. Be competitive at the first and second levels and attempt the third level

Solution

The firefighting robot was to be built to meet the specifications as laid out in the 2016

Trinity College Fire Fighting Robot Competition Rulebook. Designing the robot to meet these

rules ensured that the robot was eligible for competition when completed. The robot was also

built to accomplish 4 main tasks.

Starting at buzzer: To accomplish the first task of the competition, starting, the

robot needed to start when the buzzer sounded. To start at the buzzer sound, the robot

used a microphone connected to an STM32F407 Discovery Board [2]

microcontroller. The microcontroller processed the sound to match the value of the

frequency to the starting frequency. When the frequency matched the given value, the

robot started the competition. To complete this requirement, a Parks-McClellan

bandpass filter was chosen with a bandpass of 3.8 kHz plus or minus 15%. The

Page 9: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 8

Discovery Board was chosen for this task due to its familiarity to the team and its

ability to process the sound where the 8051 was unable.

Driving: The robot used 2 DC motors with encoders to move about the arena looking

for the candles to put out. The DC motors were connected to an 8051 microcontroller

to coordinate function with the 3 Sharp sensors that were used to identify walls and

obstacles and help the robot in identifying its location in the arena in order to navigate

back to the starting square. The DC motors were chosen for their ease of use. The

Sharp sensors were chosen for their ability to sense the distance to walls and objects.

The 8051 was chosen for its familiarity to the team in addition to its meeting of the

minimum specifications for the project.

Fire recognition: In order to put out the fire, the robot needed to be able to identify

the fire when it entered the room where the candle is located. The robot used a UV

Tron [3] to accomplish this. The UV Tron had a very wide range of vision to be able

to identify the flame in a large room. The IR sensor next to the extinguisher nozzle

then took over flame detection as it had greater precision at a closer range. The IR

sensor was able to pinpoint the flame and trigger an LED to light on the robot

indicating a successful recognition.

Fire suppression: Fire suppression was accomplished through the use of a versa

valve system. The versa valve was designed to accept a CO2 cartridge, which was

ideal for fire suppression. CO2 is what is used in many fire extinguishers to suffocate

fires and the small cartridges were ideal for placement on a robot. The versa valve

system used a gate inside of the system to release CO2 when triggered. A servo motor

was used to sweep the nozzle back and forth over the flame to extinguish the candle.

Page 10: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 9

Hardware

Figure 7 shows the pin layout for the ATMEL 8051 microcontroller that were used in the

project. Port 1 was chosen for a number of task to fully utilize the Analog to Digital converters

and the pulse width modulation signals.

Figure 7. 8051 Pin Layout

Table 1 lists the hardware

components. Hardware was centered on

the choice to compete in the versa valve

challenge, use a small, open plastic

chassis, and be reused from a previous

year. This meant most components had to

come from what was already in the lab,

or in the stock room. Sharp sensors,

Hardware Components

1 ARM STM32F407 Discovery Board for sound processing

2 8051s for autonomous control

2 DC motors for movement

3 Sharp sensors for navigation

1 UV Tron for candle detection

1 IR detector for advanced candle detection

1 Versa Valve and CO2 for candle extinguishing

1 Servo for CO2 sweeping

Table 1. Hardware Components

Page 11: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 10

which emit IR light to measure the distance to objects were chosen for their precision in the

confined space of the arena. Sharp sensors were also used in previous robots and a substantial

supply were already on hand in the lab. The 8051, while not the most efficient choice for

processing power, was the most efficient use of time for the group due to the familiarity of its

operation. Both team members had 8051s that they had used in previous classes, so that no

microcontrollers had to be bought. The hardware choices the team made created the foundation

for a successful and low cost project.

Figure 8. Finished Robot

Page 12: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 11

Software

The project was written in the C language on the Keil µVision platform [4]. The benefits

of this were the team’s familiarity with the

language and the debugging environment on

µVision. On previous projects the team members

used the Atmel 8051 and the C language to utilize

external interrupts, analog to digital conversion,

and pulse width modulation. All of these methods

were used in this project and the team’s familiarity

with these in this language was very useful in the

completion and success of the project.

The software for this project was written in

a modular style. It used a switch statement to run

code to get to different rooms. Each room had

several ways to be approached. Using a switch

statement allowed rooms to be approached from

the most efficient ways. Each room could be

approached from a different direction, such as

entering from the left or from the right. This

ensured that tricky situations with the obstacles

and various room layouts could be simplified into a much more

approachable problem. Each room did not have to be pigeon holed into one approach such as

right wall following into a room. It could right wall follow into one room, and then left wall

Figure 9. Pseudo code

Page 13: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 12

follow into the next reducing extra travel length by solving the problem smarter. After entering

and searching a room, it updated a counter so that it would then enter the next case in the switch

statement. It would continue this until the candle was located.

After the candle was detected in the room, a separate function was called that determines

the exact location of the candle and moved towards it. This was done sweeping the servo across

the room and checking the value from the infrared sensor. After a complete sweep, the servo re-

centered and turned in the direction of the candle until the highest value found during the sweep

is matched or passed. The robot then knew it was facing the candle, moving forward until the IR

sensor or the front distance sensor detected an optimal distance. The versa valve was then opened

and the servo was swept across the candle, extinguishing the flame.

The analog to digital conversion functions were only called when they were needed. This

ensured that the conversions were not returning garbage values confused with the other value

conversions but had time to settle between operations. It also enabled the power individual

sensors used to be maximized since other sensors were not also operating simultaneously. The

functions were separated into a separate file as well to make viewing them more manageable.

Sustainability

The project was very sustainable as it is took advantage of as many parts as possible from

robots used in past competitions. The current year robot was purposefully designed to use the

components from last year’s robots instead of wasting money and resources on new parts.

Recyclability was the design inspiration and helped to make the project sustainable for years to

come.

Page 14: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 13

Environmental Impact

Continuing with the idea of recyclability, the robot had very little environmental impact.

The batteries were rechargeable battery packs in order to eliminate battery waste. Most of the

parts were recycled from past robots cutting the impact of newly manufactured parts and their

shipment.

Political Impact

The success of the firefighting robot could encourage the public and politicians to look

into starting petitions and bills to provide more funding for automated firefighting robots. The

successful implementation of firefighting robots in homes could keep taxpayers alive longer to

pay more taxes that would be available for the public good. The purchase of firefighting robots

by homeowners could also allow fire departments to cut budgets.

Manufacturability

The robot was designed to be very able to manufacture. Nearly all of the chassis, the

microcontrollers, the sensors, and the other components are readily available online through a

number of vendors for low prices. It would be very easy for a company to source the off the shelf

parts and assemble them in a small area with a limited number of employees.

Page 15: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 14

Safety and Standards

The use of fire in the completion of this project was a major source of concern, but it was

a manageable source. A fire extinguisher was located in the room near the track in case of an

emergency. There was also a first aid kit in the room if needed. The school clinic was nearby and

St. Mary’s Hospital was a short distance away in the event of serious injury. Nathan is

wilderness first aid trained in addition to being CPR and defibrillator certified. Proper safety

considerations were taken at all times and safety was priority number one.

In order to ensure a safe robot was built, several international standards were followed.

IEEE C2-2012 [5] was followed to ensure that circuitry was handled in a safe and proper

manner. Attempts were made to follow IEEE standard 1680-2009 [6] in an effort to keep the

project as sustainable and ecofriendly as possible. IEC 60950-1 standard of 2012 [7], the

standard for safe use of the robot by the operator was followed to ensure that neither the

teammates nor faculty and staff were injured by the robot.

Cost

Table 2. Cost of Robot

Cost of Robot . .2

Microcontrollers x2 $60 Provided

Motors x2 $110 Provided

Wheels x2 $10 Provided

Caster $7 Provided

Electronics (Sensors, mic, LED's, etc.) $175 Provided

Hardware $50 Purchased

Total $412

Total excluding parts from past years $50

Travel Expenses .

Hotel $285.20

Flights $1,005.40

Car Rental $109.72

Airport Parking $21

Poster $25

Event Registration $90.24

Checked Luggage $25

CO2 and Batteries $22.94

Team shirts $67.50

Total $1,662.00

Table 3. Travel Expenses

Page 16: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 15

The cost for this project were minimal. The team utilized equipment from previous years’ robots.

The benefits of this was that the majority of the expensive parts had already been purchased. The

majority of the cost that remained were a 3D printed handle, CO2 cartridges, and travel to

Connecticut. Travel was set up by Vicky Hasenour, and these costs came to $1845.63. Attached

are the costs of travel. The costs for parts was around $512, but through reusing parts from past

years, our cost were about $50.

Results

The robot was able to meet all project requirements. The robot was able to autonomously

navigate through level 1 and all layouts of level 2. The robot was able to identify a flame using

the long distance UV Tron, and was also able to navigate to the flame using the IR sensor. The

versa valve was able to extinguish candles in all four rooms on each course layout. The robot

was able to start at 3.8 kHz and not at ambient noise. The robot also met all rulebook

requirements for size and labeling. The robot was very reliable in its operation, being able to find

and extinguish candles on seventy percent of runs. Unfortunately, the robot was not able to

compete at competition. The rulebook stated that the robot must start when a 3.8 kHz buzzer

sounds and must not start when it hears ambient noise. The examples given for ambient noise

were given as whistling, clapping, snapping, and other noises that could be made in the large

gym where the competition took place. At the competition, the judges required robots to pass a

sound start check. For this check, a 3.2 kHz buzzer was sounded to check if the robot would start

when it heard ambient noise. Due to the teams choice to use a Parks-McClellan bandpass filter

with a bandpass of 3.8 kHz plus or minus 15%, the robot passed the 3.2 kHz sound, and therefore

Page 17: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 16

failed tech inspection. Many attempts were made to fix this problem, but none were successful.

However, the team did come in first place in the poster presentation competition.

Conclusions and Recommendations

The team considers the project a success. The project was a great learning opportunity for

the team. The team believes that it would have been in there best interest to have started earlier

and the team would suggest any interested team to begin earlier than they did. The team

members would suggest this project to any interested rising seniors as a challenging, but

rewarding project. Having the added pressure of competition is intimidating on the surface, but it

later becomes a source of comfort that the students have defined and achievable goals. The team

would suggest using their model of staying simple and less is more. This philosophy allows for

easy troubleshooting and for students to be able to keep a great handle on all of the components

that go into the robot. Overall, this project represents a successful capstone to two wonderful

college careers.

Page 18: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 17

Appendix A: Project Code

Main Code:

// main.c

#include <AT89C51CC03.h>

#include "header.h"

// int enc_count; possibly for room exiting

int line;

int room;

int IRret;

signed char temp;

unsigned char tmp;

unsigned int encoderL;

unsigned int encoderR;

unsigned int R, L, F, k;

unsigned int check;

unsigned char high1;

unsigned char right = 200, left = 180;

int soundStart = 0;

void rightEncoder(void) interrupt 0 using 1 { encoderR++; }

void leftEncoder(void) interrupt 2 using 1 { encoderL++; }

void main(void)

{

P3_7 = 1;

P0_4 = 1;

P0_7 = 1;

P0_6 = 1;

P3_1 = 1;

P3_5 = 1; // sound activation led,

P3_6 = 1; // flame led

Initialize();

ADC();

// findFire();

while (soundStart == 0) {

if (P3_1 == 0) {

Delay(10000);

if (P3_1 == 0) {

soundStart = 1;

P3_5 = 0; // light up sound led

}

Page 19: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 18

}

}

checkLeftFirst();

while (1) {

}

}

void checkLeftFirst()

{

ADCL();

if (L > 0x4000) {

ADCR();

ADCFront();

if (R > 0x3200) {

encoderL = 4000;

while (1) {

findCandle1(0);

}

}

else if (R <= 0x3200 && F > 0x3200) {

turnAround(90);

encoderL = 4000;

while (1) {

findCandle1(0);

}

}

}

else {

turnLeftN();

}

line = 0;

ADCFront();

encoderR = 0;

while (F < 0x5800 && encoderR < 2900) {

ADCFront();

wallFollowLeft();

line = 0;

}

CCAP0H = 0;

CCAP1H = 0;

Delay(10000);

ADCR();

line = 0;

if (R < 0x3900) {

turnAround(90);

Page 20: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 19

CCAP0H = 200;

CCAP1H = 180;

while (line == 0) {

ADCLine();

}

CCAP0H = 0;

CCAP1H = 0;

Delay(10000);

if (P0_4 == 0) {

room = 6;

}

else {

reverse();

CCAP0H = 0;

CCAP1H = 0;

Delay(1000);

turnAround(90);

}

encoderL = 0;

while (1) {

findCandle1(1); // checked room 4

}

}

else {

encoderL = 0;

CCAP0H = 0;

CCAP1H = 0;

Delay(1000);

turnAround(180);

while (1) {

findCandle1(0);

}

}

}

void findCandle1(unsigned int four_first)

{

switch (room) {

case 1:

wallFollowRight();

if (encoderL > 10000) {

ADCLine();

}

else {

line = 0;

Page 21: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 20

}

if (line == 1) {

CCAP0H = 0;

CCAP1H = 0;

Delay(10000);

if (P0_4 == 0) {

room = 6;

break;

}

else {

line = 0;

reverse();

CCAP1H = 0;

CCAP0H = 0;

Delay(1000);

turnAround(90);

room++;

}

}

break;

case 2:

wallFollowRight();

ADCLine();

if (line == 1) {

CCAP0H = 0;

CCAP1H = 0;

Delay(10000);

if (P0_4 == 0) {

room = 6;

break;

}

else {

line = 0;

turnAround(180);

Delay(10000);

room++;

}

}

break;

case 3:

wallFollowRight();

ADCLine();

if (line == 1) {

CCAP0H = 0;

CCAP1H = 0;

Page 22: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 21

Delay(10000);

if (P0_4 == 0) {

room = 6;

break;

}

else {

line = 0;

turnAround(180);

if (four_first == 0) {

room++;

}

else {

room = 7;

}

}

}

break;

case 4:

encoderR = 0;

encoderL = 0;

CCAP0H = 180;

CCAP1H = 190;

while (encoderL < 700)

;

CCAP0H = 0;

CCAP1H = 0;

Delay(1000);

turnAround(90);

CCAP0H = 0;

CCAP1H = 0;

Delay(1000);

ADCL();

if (L > 0x4500) { // wall

encoderL = 0;

encoderR = 0;

CCAP0H = 200;

CCAP1H = 180;

Delay(1000);

while (encoderL < 2580) {

wallFollowRight();

}

CCAP0H = 0;

CCAP1H = 0;

Delay(1000);

}

Page 23: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 22

else { // no wall, drive farther

encoderL = 0;

encoderR = 0;

CCAP0H = 200;

CCAP1H = 180;

Delay(1000);

while (encoderL < 6000) {

wallFollowRight();

}

}

CCAP0H = 0;

CCAP1H = 0;

Delay(10000);

ADCL();

if (L < 0x6600) {

turnToLeft();

while (line == 0) {

CCAP0H = 200;

CCAP1H = 180;

ADCLine();

}

}

else {

while (line != 1) {

wallFollowLeft();

ADCLine();

}

}

if (line == 1) {

CCAP0H = 0;

CCAP1H = 0;

Delay(10000);

if (P0_4 == 0) {

room = 6;

break;

}

else {

line = 0;

reverse();

turnToLeft();

room = 7;

}

}

Page 24: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 23

break;

case 5: // after retHome

wallFollowRight();

ADCLine();

if (line == 1) {

Delay(1000);

CCAP0H = 0;

CCAP1H = 0;

while (1);

}

break;

case 6:

CCAP0H = 0;

CCAP1H = 0;

findFire();

// one = 1;

line = 0;

turnAround(180);

while (line == 0) {

wallFollowRight();

ADCLine();

}

line = 0;

room++;

break;

case 7:

CCAP0H = 0;

CCAP1H = 0;

while(1);

break;

}

}

void wallFollowRight()

{

CCAP0H = right; // right wheel

CCAP1H = left; // left wheel

ADCR();

ADCFront();

if (F >= 0x5800) {

CCAP0H = 0;

CCAP1H = 0;

Delay(1000);

Page 25: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 24

turnToLeft();

}

else if (R >= 0x6400) {

right = 200 + (R * k);

if (right >= 255)

right = 255;

left = 180 - (R * k);

if (left <= 130)

left = 130;

// away from wall

}

else if (R < 0x6400 && R > 0x4700) {

left = 180 + (R * k);

if (left >= 230)

left = 230;

right = 200 - (R * k);

if (right <= 150)

right = 150;

// to wall

}

else {

turnRight();

}

}

void wallFollowLeft()

{

CCAP0H = right; // right wheel

CCAP1H = left; // left wheel

ADCL();

if (L < 0x6400 && L > 0x4700) {

right = 190 + (L * k);

if (right >= 255)

right = 255;

left = 190 - (L * k);

if (left <= 130)

left = 130;

}

else if (L >= 0x6400) {

left = 200 + (L * k);

if (left >= 255)

left = 255;

right = 180 - (L * k);

if (right <= 130)

right = 130;

Page 26: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 25

}

else {

turnLeft();

}

}

void turnAround(int deg)

{

P0_7 = 0;

encoderL = 0;

CCAP0H = 50; // right

CCAP1H = 180;

if (deg == 180) {

while (encoderL < 1540);

}

else if (deg == 90) {

while (encoderL < 780);

}

P0_7 = 1;

CCAP0H = 0;

CCAP1H = 0;

Delay(1000);

}

void turnToLeft()

{

CCAP0H = 0;

CCAP1H = 0;

Delay(1000);

P0_6 = 0;

encoderR = 0;

CCAP0H = 200;

CCAP1H = 70;

while (encoderR < 960);

P0_6 = 1;

CCAP1H = 180;

}

void turnRight()

{

ADCR();

while (R < 0x4700 && line == 0) {

ADCR();

ADCLine();

Page 27: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 26

CCAP1H = 180;

CCAP0H = 100;

}

CCAP0H = 200;

}

void turnLeft()

{

ADCL();

while (L < 0x4700 && line == 0) {

ADCL();

ADCLine();

CCAP1H = 100;

CCAP0H = 200;

}

CCAP1H = 180;

}

void turnLeftN()

{

ADCL();

while (L < 0x4700) {

ADCL();

CCAP1H = 0;

CCAP0H = 200;

}

CCAP1H = 180;

}

void reverse()

{

P0_7 = 0;

P0_6 = 0;

CCAP0H = 55;

CCAP1H = 70;

Delay(7500);

P0_7 = 1;

P0_6 = 1;

}

void findFire()

{

unsigned int value;

int m = 0;

int pos;

EX0 = 0;

Page 28: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 27

EX1 = 0;

IRret = fireIR(0xFF00);

Delay(10000);

pos = (IRret >> 8);

value = (IRret << 8);

ADCir();

if (pos >= 150) {

while (ADCir() < value) {

CCAP0H = 150; // right

CCAP1H = 0; // left

}

}

else if (pos < 150) {

while (ADCir() < value) {

CCAP0H = 0;

CCAP1H = 150;

}

}

CCAP0H = 200;

CCAP1H = 185;

while (ADCir() < 0x9A00) {

ADCFront();

if (F > 0x5500)

break;

}

CCAP0H = 0;

CCAP1H = 0;

IRret = fireIR(0x9900);

P3_6 = 0; // flame led

Delay(10000);

putOut();

EX0 = 1;

EX1 = 1;

}

void putOut()

{

P3_7 = 0;

count = 41;

while (found == 0) {

search(2);

}

P3_7 = 1;

}

Page 29: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 28

void Initialize()

{

CKCON = 0x01;

CMOD = 0x02;

CCON = 0x40;

CCAPM0 = 0x42;

CCAPM1 = 0x42;

CCAP0H = 0;

CCAP1H = 0;

EX1 = 1;

EX0 = 1;

IT0 = 1;

IT1 = 1;

EA = 1;

line = 0;

room = 1;

IRret = 0;

k = 0;

encoderL = 0;

encoderR = 0;

}

void ADC()

{

ADCF = 0xa7;

ADCON = 0x20;

ADCLK = 0x00;

}

void Delay(int x)

{

int i, j;

for (i = 0; i < x; i++)

for (j = 0; j < 100; j++);

return;

}

Page 30: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 29

Header:

//header.h

#ifndef _HEADER_H_

#define _HEADER_H_

sbit output=P3^0;

extern int found;

extern int count;

extern int line;

extern int room;

extern int IRret;

extern signed char temp;

extern unsigned char tmp;

extern unsigned int encoderL;

extern unsigned int encoderR;

extern unsigned int R, L, F, k;

extern unsigned int check;

extern unsigned char high1;

extern int fireIR(int stop);

extern void putOut();

extern void search(signed int j);

extern void timer(int msec);

extern void Delay(int x);

extern void ADCFront();

extern void ADC();

extern void ADCR();

extern void ADCL();

extern void ADCLine();

extern void Initialize();

extern void turnRight();

extern void turnLeft();

extern void turnLeftN();

extern void wallFollowRight();

extern void wallFollowLeft();

extern void reverse();

extern void findFire();

extern void findCandle1(unsigned int four_first);

extern void reverse();

extern void checkLeftFirst();

extern void turnAround(int deg);

extern void turnToLeft();

extern unsigned int ADCir();

#endif

Page 31: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 30

FireIR Code:

#include <at89c51cc03.h>

#include "header.h"

int count;

int found = 0;

signed int g = 2;

void delay1(unsigned int msec)

{

int i,j;

for(i=0;i<msec;i++)

for(j=0;j<1275;j++);

}

void timer(int msec)

{

int i;

TR1=1;

for(i=0;i<msec;i++)

{

while(TF1==0);

TF1=0;

}

TR1=0;

}

int fireIR(int stop)

{

unsigned char Highest=0;

int pos1=0;

unsigned int leftright=0;

EA = 0;

TMOD=0x20;

TH1= -46;

output=0;

count=41;//150 is middle

while(found == 0)

{

delay1(1);

check = ADCir();

if(high1>Highest){

pos1=count;

Highest=high1;

}

Page 32: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 31

if(check>stop){

found=1;

}else{

search(g);

}

}

found = 0;

check = 0;

return ((pos1<<8)+Highest);

}

void search(signed int g)

{

int i;

if(count>255){

count = 150;

for(i=0;i<5;i++)

{

output=1;

timer(count);

output=0;

timer(2200);//2200

}

found=1;

}else{

count=count+g;

for(i=0;i<2;i++)

{

output=1;

timer(count);

output=0;

timer(2200);//2200

}

}

}

Page 33: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 32

Analog Code:

//adc file

#include <at89c51cc03.h>

#include "header.h"

void ADCR()

{

ADCON &= 0xF8;

ADCON |= 0x00;

ADCON |= 0x20;

ADCON |= 0x08;

tmp = (ADCON & 0x10);

while(tmp != 0x10)

tmp = (ADCON & 0x10);

R=(ADDH<<8)+ADDL;

ADCON &= 0xEF;

}

void ADCL(){

ADCON &= 0xF8;

ADCON |= 0x01;

ADCON |= 0x20;

ADCON |= 0x08;

tmp = (ADCON & 0x10);

while(tmp != 0x10)

tmp = (ADCON & 0x10);

L=(ADDH<<8)+ADDL;

ADCON &= 0xEF;

}

void ADCFront(){

ADCON &= 0xF8;

ADCON |= 0x02;

ADCON |= 0x20;

ADCON |= 0x08;

tmp = (ADCON & 0x10);

Page 34: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 33

while(tmp != 0x10)

tmp = (ADCON & 0x10);

F=(ADDH<<8)+ADDL;

ADCON &= 0xEF;

}

void ADCLine(){

//line

ADCON &= 0xF8;

ADCON |= 0x05;

ADCON |= 0x20;

ADCON |= 0x08;

tmp = (ADCON & 0x10);

while(tmp != 0x10)

tmp = (ADCON & 0x10);

if((((ADDH<<8)+ADDL) >= 0x9900)){

line = 1;

}

ADCON &= 0xEF;

}

unsigned int ADCir(){

ADCON &= 0xF8;

ADCON |= 0x07;

ADCON |= 0x20;

ADCON |= 0x08;

temp = (ADCON & 0x10);

while(temp!=0x10)

temp = (ADCON & 0x10);

//high1=(ADDH<<8)+ADDL;

high1=ADDH;

check = (ADDH<<8)+ADDL;

ADCON &= 0xEF;

return check;

}

Page 35: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 34

References

[1] (18 September 2015) Trinity College Fire-Fighting Home Robot Competition. [Online].

Available: http://www.trinityrobotcontest.org/rules-1.html

[2] http://www.st.com/st-web-

ui/static/active/cn/resource/technical/document/user_manual/DM00039084.pdf

[3] http://www.hamamatsu.com/resources/pdf/etd/R2868_TPT1008E.pdf

[4] http://www2.keil.com/mdk5/uvision/

[5] IEEE. “C2-2012-IEEE 2012 National Electrical Safety Code” IEEE Standards Association.

Web. 12 Sept. 2013. http://standards.ieee.org/findstds/standard/C2-2012.html

[6] IEEE. “1680-2009-IEEE Standard for Environmental Assessment of Electronic Products”

IEEE Standards Association. Web. 25 Nov. 2013.

https://standards.ieee.org/findstds/standard/1680-2009.html

Page 36: 2016 Trinity College Home Fire Fighting Robot Competition Submitted by · PDF file · 2016-09-052016 Trinity College Home Fire Fighting Robot Competition Submitted by Nick Schuetz

Trinity College Fire-Fighting Robot 2016 35

[7] IEEE. “IEC 60950-1 Second edition 2005-12 Information Technology Equipment Safety”

IEE Standards Association. Web. 2005.