14
Team 8 Devin Rose Sarah Yee Nick Cowen BE 1200 – Basic Engineering Midterm Midterm Report [Clarify Objectives] The objective of the midterm project is to create a line following robot. The robot has to be able to follow the line then maneuver around an object (a red can) that was located about halfway on around and on the line. From there the robot would have to get back to the line, continue line following, and then stop on the green tile. Once it was stopped on the green tile it would then have to play some music for at least five seconds. Also, there was a way to earn extra credit. The extra credit came if we were able to make the robot go around the tin can more than once. Another way to earn more extra credit is if you made it run the whole course more than once. [Establish User Requirements] The user has to be able to press the orange button when it is highlighted to run the program and also be able to use the NXC program. [Establish Functions] The robot will read the numerical value of the green, white, and black to know what it is trying to follow. Then the robot is placed on the black line and it will follow the line using a sweeping program. It will continue to follow the line until the bumper is pressed, once the bumper is pressed it will then back up and open up to the ultrasonic sensor side. Once it is in position it will follow the red tin can and pass by the black line that it needs to go on twice (for every time it passes the line a sound will be

Team 8€¦  · Web viewThe touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Team 8€¦  · Web viewThe touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot

Team 8Devin RoseSarah YeeNick CowenBE 1200 – Basic EngineeringMidterm

Midterm Report[Clarify Objectives]

The objective of the midterm project is to create a line following robot. The robot has to be able to follow the line then maneuver around an object (a red can) that was located about halfway on around and on the line. From there the robot would have to get back to the line, continue line following, and then stop on the green tile. Once it was stopped on the green tile it would then have to play some music for at least five seconds.

Also, there was a way to earn extra credit. The extra credit came if we were able to make the robot go around the tin can more than once. Another way to earn more extra credit is if you made it run the whole course more than once.

[Establish User Requirements]The user has to be able to press the orange button when it is highlighted to

run the program and also be able to use the NXC program.

[Establish Functions]The robot will read the numerical value of the green, white, and black to

know what it is trying to follow. Then the robot is placed on the black line and it will follow the line using a sweeping program. It will continue to follow the line until the bumper is pressed, once the bumper is pressed it will then back up and open up to the ultrasonic sensor side. Once it is in position it will follow the red tin can and pass by the black line that it needs to go on twice (for every time it passes the line a sound will be made letting us know that it is counting). After it is done counting and it has gone around twice, then it will continue the sweeping line following program and run until it sees green. As soon as it reads on the light sensor that it is over the green then it will stop, thus completing the task.

[Establish Design Specifications]We modified our last line following bot to have a bumper on it, as well as an

ultrasonic sensor on the side. The ultrasonic sensor worked the best for us when we angled it instead of having it sideways or straight up and down. The ultrasonic sensor is used for reading how far away an object is from the sensor. The touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot.

Page 2: Team 8€¦  · Web viewThe touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot

[Generate Alternatives]In the beginning we tried to design a bot that followed the tin can using a

touch sensor, but we rejected that idea pretty quickly. We rejected it because we saw how easy another robot was moving using the ultrasonic sensor.

[Model or Analyze Design]The design was a simple one, we took the tri-bot and added a few sensors to

it. We added a light sensor up front so it could tell where it was going. Then, we added a touch sensor the front in front of the light sensor. The goal of putting the touch sensor there was to get it where as soon as it hit the can it had room to turn around and it actually knew it hit the can. Lastly, the ultrasonic sensor was added to the design of the bot to allow it to know how far it was from the can as it was going around the can. We put the ultrasonic sensor at the forty-five degree angle because that was the angle that the sensor worked best with our program. The robot overall was fairly balanced and ran effectively to accomplish the task.

Page 3: Team 8€¦  · Web viewThe touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot
Page 4: Team 8€¦  · Web viewThe touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot

[Program Table]#define EYE SENSOR_3 This defines the light sensor as sensor 3.void setup(){ This is a setup for the whole program;

this will help setup the light sensor to know what numbers are being read for the green, white, and black.

PlayTone() This function is letting us know that a sound will be played and on the inside of the parenthesis is what is played, a variable or a word describing what is played EX: SOUND_UP

#define LEFT OUT_C This defines which port controls the left motor and the left wheel.

int TOO_DARK This int allows us to put in places to let the sensor know that it is looking at something it is looking at and in our case it would be the black.

int count This counts how many times the light sensor sees a certain color.

int TOO_BRIGHT This int allows us to tell the light sensor that it is looking at the white

int Green This int is telling the light sensor that it is looking at the green.

task follow() This task just opens up the program and the bot and this will turn on the light sensor and let it follow the int

Page 5: Team 8€¦  · Web viewThe touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot

TOO_DARK and if it sees int TOO_LIGHT then it will search left and right to find the black line again.

task ultrasonic() Task ultrasonic() is a task that starts right after the task bump is done and will read how far it is away from the wall and then circle the can until the blackhunt task is done.

task blackhunt() This is a task that counts how many times it sees the black line while the ultrasonic sensor is on and moving the bot around the red can. Also for every time it sees the black line it will play a tone. As soon as it has seen the line 5 times then it will stop the ultrasonic and blackhunt and start the task follow again

task bump() This task is run all the time and will as soon as the bumper is pushed it will back up and turn open for the ultrasonic sensor to read where it is, and after it does that it will start blackhunt and ultrasonic tasks.

task green() This task is all about trying to find the green and as soon as it finds the green it will run a little bit more and then stop. Once it stops it will shut off all tasks to let us know it finished.

task main() This is pretty much the “ultimate” task in a sense that it controls everything in telling the program and the bot what is really in it.

#define RIGHT OUT_A This is a definition and it is defining which port the right motor is hooked up to and in this case the right motor is hooked up to the A port.

[Refine and Optimize Design]We had a few changes to the design but the biggest one had to have been the

change to the ultrasonic sensor. We changed it from a flat zero degree angle to about a forty-five degree angle. Changing the angle made it go from not working, to working, we believe it started working because it allowed a better angle for the ultrasonic sound to be received and read.

[Description of Advanced Strategies]

Page 6: Team 8€¦  · Web viewThe touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot

The one main advanced strategy that we had was by using the ultrasonic sensor. We used it with zero work with it. No one is the class to our knowledge had much if any experience with these sensors. Based on that fact we dove straight in and came up with a basic program with the help of Jim. This allows us to maneuver around the red can more free and look better with less jerking motions in it.

[Flowchart]

Page 7: Team 8€¦  · Web viewThe touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot

[Date Table]Version Fixes/ Changes Results

1 We changed the old line-follow we used in the Nurse Bot to a new sweeping line bot.

The line-follow for the black tape now works correctly.

2 Added a touch sensor and an ultrasonic sensor.

The touch sensor activated but then ran into the can, didn’t turn enough. The ultrasonic sensor did not work.

3 Increased OnRev time after the touch sensor is activated.

The robot backed up a sufficient amount after the touch sensor was activated but the robot still ran into the paint can for lack of turning distance.

4 Increased the Wait period for the turn time after the OnRev for the activated touch sensor.

The robot finally cleared the can and the Ultrasonic sensor can finally be added.

5 We set the distance interval for the Ultrasonic sensor for between 3 and 7 and added slight turns to the if-statement to keep the robot going around the can.

The robot either ran into the paint can and didn’t know what to do or went in circles around itself next to the paint can.

6 We increased the interval for the Ultrasonic sensor to between 10 and 7 and kept the same turning and OnFwd statements.

The robot showed the same behavior as before, so we had to read the code more carefully.

7 With review of the code, we found the robot was turning the wrong way for each interval. So we changed the outputs for turning so the robot would behave has we wanted (switched the A and C outputs on each turn) and tested again.

The robot finally worked as programed, it successfully circled the paint can.

8 We wrote a “Black Hunt” program to get the Ultrasonic sensor to stop and line follow to restart after circling the paint can twice. This was a simple count program.

The robot stopped after seeing one black line, because the count was only set to 5 with no wait period.

9 We added a Wait (1000) to the Black Hunt program so each tape line would only be counted once. There was also a tone added so we knew each time a line would be counted.

The robot successfully circled the paint can twice (beeping each time it saw a black line) and then started to line follow.

10 We restarted the previously cancelled “Green” task and tested the robot as a whole on the track.

THE ROBOT SUCCESSFULLY NAVIGATED THE TRACK 3 TIMES IN A ROW

Page 8: Team 8€¦  · Web viewThe touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot

[Description of Team Members Contribution]All of the members of the team really contributed a lot into this midterm.

Nick Cowen did a lot of mechanical work with the bot, in making sure that everything on the bot was the way it needed to be and helped make adjustments to the bot when needed. Also he helped with the report by making the flowchart. Sarah Yee helped with some programming and building of the bot, it was her idea for the angled ultrasonic sensor. She also helped with the report by making the test and evaluate chart. Devin Rose helped with the programming of the bot and helping run the bot. He also helped with the report by writing the remainder of the report that Sarah and Nick didn’t do.

[Code]

#define LEFT OUT_C#define RIGHT OUT_A

int TOO_DARK;int TOO_BRIGHT;

int Green;

void setup(){     Green = EYE;     PlaySound(SOUND_UP);     Wait(2000);     TOO_BRIGHT = EYE;     PlaySound(SOUND_UP);     Wait(2000);     TOO_DARK = EYE;     PlaySound(SOUND_UP);

     int delta = (TOO_BRIGHT - TOO_DARK)/3;     TOO_DARK += delta;     TOO_BRIGHT -= delta;}

task follow(){     OnFwd(OUT_AC, 75);     while(true){                 if(EYE <= TOO_DARK){

Page 9: Team 8€¦  · Web viewThe touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot

                        Off(LEFT);                        OnFwd(RIGHT, 75);                 }else if(EYE >= TOO_BRIGHT){                        Off(RIGHT);                        OnFwd(LEFT, 25);                 }else{                       OnFwd(OUT_AC, 25);                 }     }

}

task ultrasonic(){    while(true){        if(SensorUS(IN_4) > 10 ) {        PlayTone(600, 40);       OnFwd(OUT_C, 20);       OnFwd(OUT_A, 40);        }        else if(SensorUS(IN_4) < 7){        PlayTone(700, 40);        OnFwd (OUT_A, 20);        OnFwd(OUT_C, 40);        }        else{        OnFwd(OUT_AC, 40);        }       }

}

task blackhunt(){     int count = 0;

     while(true){      if(SENSOR_3 < TOO_DARK){      count ++ ;      PlayTone(1000, 30);      Wait(400);      }      if (count >= 5){        stop ultrasonic;

Page 10: Team 8€¦  · Web viewThe touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot

        start follow;        stop blackhunt;     }     }

}task bump(){     while(true){                 if (SENSOR_2 == 1)                 {                    stop follow;                    OnRev(OUT_AC, 70);                    Wait(300);                    OnFwd(OUT_C, 60);                    Wait(450);                    start blackhunt;                    start ultrasonic;                    }                 } }

 task green() {     int count = 0;     while(true){        if (SENSOR_3>=(Green-3)&&SENSOR_3<=(Green+3)){           count ++ ;           PlayTone(400,20);        }else{           count = 0;        }        if(count > 9){           Off(OUT_AC);           stop follow;           stop bump;           PlayTone(1900,2000);           Wait(2000);           PlayTone(500,2000);           Wait(2000);           StopAllTasks();

Page 11: Team 8€¦  · Web viewThe touch sensor is used to tell the bot when it hits something. Lastly the light sensor is used to read and follow the black line. It is also a tri-bot

        }        Wait(10);     }}

task main(){

     SetSensorLight(IN_3);     SetSensorTouch(IN_2);     SetSensorLowspeed(IN_4);     setup();     start follow;     start bump;     start green;

}