0% found this document useful (0 votes)
87 views

Midterm Final

The document summarizes a midterm report for a team's BE 1200 class project to design and build a NXT robot. The robot is tasked with using various sensors to follow a line, detect and circumnavigate a red object twice, and stop on a green square while playing a sound. The team's report outlines their objectives, user requirements, constraints, functions, design specifications, alternatives considered, and modeling of their tri-bot design with added sensors. It also includes their program code and contributions from each group member.

Uploaded by

api-281375188
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views

Midterm Final

The document summarizes a midterm report for a team's BE 1200 class project to design and build a NXT robot. The robot is tasked with using various sensors to follow a line, detect and circumnavigate a red object twice, and stop on a green square while playing a sound. The team's report outlines their objectives, user requirements, constraints, functions, design specifications, alternatives considered, and modeling of their tri-bot design with added sensors. It also includes their program code and contributions from each group member.

Uploaded by

api-281375188
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Team 9

Fadi Basheer
Chris Mann
John Heinonen
BE 1200 Prof. Gina Shreve
Midterm Report

1. Clarify Objectives

Design and build a NXT robot


Write a code to perform the following tasks:
o Use a light sensor to follow a line
o Use a touch sensor to detect a red object
o Use an ultrasonic sensor to circumnavigate the red object twice
o Re-find the line and follow it again
o Use a light sensor to stop on a green square and play a sound for
at least 5 seconds

2. Establish User Requirements


After the user designs and builds the robot, as well as writes the code, all he has
to do is download the program to the NXT robot, place it on the track and press
RUN.
3. Identifying Constraints
We could only use the limited amount of parts from the Lego NXT Mindstorm set
to build our robot. We are also limited by the number of sensor ports on the
brick, as well as all the wires from our sensors interfering with our tires. We are
also limited by the software limitations of NQC programming language.
4. Establish Functions
Robot must use a light sensor to follow a black line
Robot must be able to detect an obstacle using either a touch or ultrasonic
sensor
Robot must be able to re-find the line after avoiding the obstacle
Robot must be able to use a light sensor to stop when it detects a green
square
Robot must play a sound for at least 5 seconds after it stops on the green
sqare.

5. Establish Design Specifications


NXT brick
Two lego motors
One light sensor
One touch sensor with a release type bumper
One ultrasonic sensor
Two wheels
One small track wheel
Various other small parts from Lego Mindstorms set
We used the original tri-bot design that we built during the first couple
days of class, and we already had the light sensor on the front for line
following from or previous homework assignment. We added a touch
sensor with a release type bumper to the front of the bot to detect the red
can. We used the release type bumper because our group decided that it
seemed like the more consistent way to trigger the touch sensor. We then
added an ultrasonic sensor on the same side as our right motor to detect
the can and maneuver around it.
6. Generate Alternatives
Our group discussed either using another light sensor or a touch
sensor to maneuver around the can instead of the ultrasonic sensor.
7. Modeling
We mostly left our bot the same as our previous line-following
assignments. All we added was the release type bumper on our touch sensor,
and we added the ultrasonic sensor for wall following
Program Table:

#define EYE
#define LEFT
#define RIGHT
#define TOO_DARK
#define TOO_BRIGHT

main ()

Definitions
This defines SENSOR_1 as EYE
This defines OUT_C the name LEFT
This defines OUT_A the name RIGHT
This defines TOO_DARK as the
constant value of 48
This defines TOO_BRIGHT as the
constant value of 69
Tasks
This tasks strats the line following and
bump tasks, as well as sets the input
for the ultrasonic sensor

line_follow ()

ultrasonic ()

green ()

line count ()

bump ()

timer()

Pictures:

This task commands the robot to


follow a black line by monitoring the
value measured by the light sensor
This tasks has the robot drive in a
circle around the red can by using the
ultrasonic sensor to detect its
proximity to the can, and adjusting the
output of the motors accordingly.
This task uses the light sensor to
detect the green square and stop
immediately. We also command our
robot to play a sound when it stops.
This task is performed simultaneously
with task ultrasonic, it counts how
many times the robot drives over the
black line while following the red can,
allowing it to go around the can as
many times as we want before refinding the line.
This task begins after the touch
sensor it triggers. It commands the
robot to stop following the line, back
up, and then begin task ultrasonic.
This tasked calculated a certain
amount of time before the robot
started a certain command. It counted
160 seconds before it started looking
for the green square. Allowed the
robot to go around the square twice.

Video:
The video will be posted on the website.
Refine and Optimize Design:

While constructing the robot, there was few changes that had to be made;
however, the biggest change had to be moving the ultrasonic sensor lower on the robot.
When the ultrasonic sensor was moved lower, it was positioned at a different angle
which made the detection of the barrier a lot easier than it was. The ultrasonic sensor
was really high on the robot, and we moved it a lot lower near the wheels of the robot
which made it easier for detection.
Advanced Strategies:
The main advanced strategy that was used for this robot was using the ultrasonic
sensor. Even though it was used by many students, it was a difficult sensor to use
since there was not a lot of knowledge about it. After reading the NXT tutorial, it was
easier to get an idea of. Ultimately, it was the main reason why the robot was able to
detect the barrier and go around it.
Data Table:
1

Changes
The wait time on
multiple OnRev
and OnFwd codes.
Adjusting the light
sensor on the
robot to get it to
detect the line.
Placing the
ultrasonic sensor
lower on the robot.
Getting the right
speed values for
the motors as it
went around the
barrier.
Inserted a line
count program to
get the robot to
continue following
the line after
circling the barrier.
Making the robot
turn to the left to
follow the line after
circling barrier.

New Result
During multiple parts of the project, changing the wait time
allowed the robots to act on different functions during
appropriate times. This allowed the robot to get around
the track.
By lowering the light sensor, the robot was able to follow
the line better and not stop on random places on the track.
It was easier for the robot to detect different colors as well
in this case
This was one of the biggest issues as the ultrasonic
sensor would not detect the barrier. After moving the
ultrasonic sensor lower, the sensor detected the barrier
much easier than when it was higher on the robot.
This was also a tough challenge because the motors had
to rotate at a certain value in order to keep the robot in an
even circle around the barrier. We used multiple values to
finally perfect the speed for each motor around the barrier.
Prior to this, the robot could not keep track of the line that
it was following. This function allowed the robot to count
the lines and after passing the line a certain of times, it
continued the following the line.

After the robot was counting the line, it had trouble


adjusting and focusing back on the line once it counted
them. Using OnRev(OUT_C), the robot turned left and
was able to continue back on the line.

10

Changing the
distance the robot
would be turning
around barrier.
Adding on Off
function to get the
robot to stop
immediately at
green when it
approaches it.
Added a timer
code to skip the
green square
once.
Increased the
frequency on the
Playtone.

Flowchart:

By getting the right distance for the robot, it allowed the


robot to stay consistent around the barrier and not hit it.
There was also enough space for the ultrasonic sensor to
detect the barrier as well.
Prior to doing this, the robot only stopped all of its tasks.
However, the Off function brought the robot completely to
a stop as it turned of both motors as soon as the light
sensor detected green.

Since we were aiming to make the robot go around the


track twice, we need to find a way to skip the green square
once. So we added a timer code so the robot can detect
green after a certain amount of time. This allowed the
robot to go twice around the track.
When the Playtone was first inserted into the NXT code,
there was no tone played when it stopped on green.
However, increasing the frequency allowed the noise to be
heard once the robot stopped on green.

Group Member Contributions:


Our group all worked together in putting our robot together, and John built the
release type bumper for our touch sensor as well as attached our ultrasonic sensor.
Fadi and John wrote most of our groups code, Chris helped the group get its code
working correctly by looking things up in the NQC tutorial, as well as other resources
from our class Blackboard site, during the debugging process. The groups web reports
on our design process were written by Fadi and Chris. John put together the flow chart
for the project. All and all, it was a team effort to get this done.
Program Code:
#define EYE SENSOR_1
#define LEFT OUT_C
#define RIGHT OUT_A
#define TOO_DARK 48
#define TOO_BRIGHT 69

task line_count();
task ultrasonic();
task green();
task bump();
task timer();
task line_follow(){

SetSensorLight(IN_1);
OnFwd(OUT_AC, 75);
while(true){
if(EYE <= TOO_DARK){
Off(LEFT);
OnFwd(RIGHT, 75);
}else if(EYE >= TOO_BRIGHT){
Off(RIGHT);

OnFwd(LEFT, 75);
}else{
OnFwd(OUT_AC, 75);
}
}
}

task ultrasonic()
{
while(true){
if(SensorUS(IN_4) > 12) {
OnFwd(OUT_C, 40);
OnFwd(OUT_A, 30);
}
else if(SensorUS(IN_4) < 9){
OnFwd (OUT_A, 40);
OnFwd(OUT_C, 30);
}
else{
OnFwd(OUT_AC, 50);
}
}

task timer()
{
long t0, time;

t0 = CurrentTick();
do
{
time = CurrentTick()-t0;
}
while (time<160000);
StartTask(green);
}

task green()
{
while(true)
if(EYE >=59 && EYE <=62){
//

OnFwd(OUT_AC,40);
Wait(50);

if(EYE >=59 && EYE <=62)


{

Off(OUT_AC);
StopTask(line_follow);
StopTask(ultrasonic);
StopTask(bump);
StopTask(line_count);
Off(OUT_AC);
PlayTone(1900,6000);
Wait(6000);
break;

}
}
}

task line_count()
{
int count = 0;
while(true){
if(SENSOR_1 < TOO_DARK){
count ++ ;
Wait(400);
}
if (count >= 5){
OnRev(OUT_C, 75);
Off(OUT_A);
StopTask(ultrasonic);
OnRev(OUT_C, 75);
Off(OUT_A);
Wait(700);
StartTask(line_follow);
break;
}
}
}

task bump(){

SetSensorTouch(IN_2);
while(true){
if(SENSOR_2 == 0)
{
StopTask(line_follow);
StopTask(ultrasonic);
Off(OUT_AC);
OnRev(OUT_AC, 75);
Wait(300);
Off(OUT_AC);
OnFwd(OUT_A, 75);
Wait(600);
StartTask(ultrasonic);
StartTask(line_count);
}
}
}

task main(){
start line_follow;
start bump;
start timer;
//

start ultrasonic;

//

start line_count;

SetSensorLowspeed(IN_4);
}

You might also like