180 likes | 318 Views
The George Washington University Department of ECE ECE 002 - Intro: Electrical & Computer Engineering. Dr. S. Ahmadi Class 4/Lab3. ECE 001 Class 4. Agenda Practicing 90 degree turns. More Robot Building! Exercise on Using Bumpers BONUS: Using analog sensors. Maze Specs. 4’. 1.5’.
E N D
The George Washington University Department of ECE ECE 002 - Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4/Lab3
ECE 001Class 4 • Agenda • Practicing 90 degree turns. • More Robot Building! • Exercise on Using Bumpers • BONUS: Using analog sensors
Maze Specs 4’ 1.5’ 1.5’ 4’ End Point 1.5’ 1.5’ 1.5’ Start point
Project Description • The dashed green line defines the route of the robot. • The robot should run through the obstacle course from the start point till the end point. • After it hits each obstacle, it backs up and takes a turn in the direction of the route. • Project will be judged on smoothness of motion, accuracy of route (turns and final stop are very important), time of travel, and of course a strong robot • It is the student responsibility to make sure that the Handy Board is fully charged • Each group will have one chance to demonstrate their project to the judges. Therefore, fully test your project before demonstration.
Start Button? General Flowchart No Yes Count=0 Go Straight Sensor hit? Turn Right Turn Left No Yes Count < 2? Backup Backup Yes No
Bumper Implementation - Touch Sensors • Refer to the slides 39-52 in the documentation file. • Is a type of digital sensor: – Return a 0 or a 1 – Switches or bumpers are an example (open: 0, or closed: 1)
Touch Sensor • Digital sensor • Connect to ports 7-15 • Access with function digital(port#) • 1 indicates switch is closed • 0 indicates switch is open
Sample code To Use Bumpers // Program to make a robot go forward. // If hit detected, go backwards for 4 seconds. void main() { while(start_button()==0){ }; // Waits for use press start button. while(1) { motor (1,80); // Turn on motor 1, @ 80% of speed. motor (3,80); // Turn on motor 3, @ 80% of speed. if (digital(13)= =1) // Check sensor connected to port { motor (1, -80); // Turn on motor 1, @ 3% of speed in opposite direction. motor (3, -80); // Turn on motor 1, @ 3% of speed in opposite direction. sleep(4.0); off(4); sleep (5.0); } }
Project Requirement • Making your robot escape from the maze Successfully (90 Points) • Optional (10 points for implementing either 1 or 2) 1.Using analog sensors, i.e. sonar or optical range finder, program your robot so that it is able to find its own path out of the maze. 2.Adjusting your robot to make a perfect 90 degree turn with the reference of the black paper strip GOOD LUCK!
Optional Requirement #1Implementation Example Install your sonar/ranger finder on one side of your robot While the front digital sensor is zero Go forward If the robot is closer to the right wall turn left; Else turn right;
Optional Requirement #2Implementation Example While the front digital sensor is zero Go forward - Install light sensors on the bottom of your robot If the robot is closer to the right wall turn left; Else start to turn right; If the left ground sensor detects the strip then turn off the left motor until the right ground sensor detects the strip If the right ground sensor detects the strip then turn off the right motor until the left ground sensor detects the strip
while(analog(SENSOR_LB) > TURN_BTH && analog(SENSOR_RB) > TURN_BTH) { printf("\n going straight, looking for the line"); } //Left sensor hit the line first, so stop the left motor if (analog(SENSOR_LB) < TURN_BTH) { off(LEFT_MOTOR); while(analog(SENSOR_RB) > TURN_BTH) { printf("\nCorrecting for turn inaccuracy-Sharp Left"); } MoveStraight(); } else { off(RIGHT_MOTOR); while(analog(SENSOR_LB) > TURN_BTH) { printf("\nCorrectin for turn inaccuracy-Sharp Right"); } MoveStraight(); }