Activity #6: Programming the Basebot to Move on Its Own

Total Page:16

File Type:pdf, Size:1020Kb

Activity #6: Programming the Basebot to Move on Its Own

Introduction to Robotics Name: Activity #6: Programming the BaseBot to Move on its Own

Activity #6: Programming the BaseBot to Move on its Own

Purpose:

In this activity you will use the Easy C™ to program your BaseBot to move on its own.

Goals:

At the end of this activity you should be able to:

1. Calculate the values needed to make the BaseBot go forward, reverse, and turn at different speeds.

2. Identify the MOTOR BLOCK.

3. Explain what a WAIT statement does.

4. Identify common errors is movement programming.

5. Program the BaseBot to move forward, reverse, turn, and stop.

Materials:

BaseBot with Vex Controller

Computer Workstation with Easy C™ installed.

Orange Serial interface cable.

Hazards: Always make sure the controller is turned off when plugging in or removing cables!

Never plug the orange interface cable into the Rx1 or Rx2 Port!

Make sure that the battery is plugged in properly.

Make sure the Transmitter Frequency and the Receiver Frequency Match.

Make sure that the other BaseBots are using a different frequency. Procedure: Part A: MOTOR MODULES and SPEED

1. Your BaseBot has two motors. One is mounted on the left side of the robot and one is mounted on the right side of the robot. Because they are mounted on opposite sides, they must rotate in opposite directions at the same speed for the robot to move forward or for that matter reverse. When they rotate in the same direction the robot pivots either to the left or to the right. The diagram below illustrates the motion of the robot as determined by the motor rotation.

2. The BLOCKS in the above diagram are called MOTOR MODULES. Any time you want to program a motor a MOTOR MODULE is used. A MOTOR MODULE includes two numbers; the first number represents the MOTOR, the second represents the SPEED. In the diagram below the two motors are moving in opposite directions at the same speed. As a result the robot will move forward.

2 1

2 3. The speed scale for the robot represents both the speed and direction. 255 Full Speed Clockwise

127 No Motion

Full Speed Counter Clockwise 0 4. If you want to make the robot move forward or reverse at a slower speed, the speed values you chose must be an equal distance from 127-(no motion.)

2 1 Speed1 = 127-77= 50

Speed2 = 127-177= -50

Same speed, opposite rotation, robot goes forward at slower speed. 2 1

5. If the motors are rotating in the same direction and at the same speed the robot will pivot around central axis. Speed1 = 127-0 = 127

Speed2 = 127-0 = 127

Same speed, same direction, robot pivots around central axis. 6. If the motors are rotating in the opposite direction, but they are not rotating at the same speed, the robot will turn in the opposite direction of the motor with the highest speed.

1 2 Speed1 = 127-25 = 102 Speed2 = 127-177 = -50

The motor on the right is 2 1 moving faster than the 3 motor on the left. The robot will turn left. 7. Complete questions 1-3 on your activity sheet.

PART B: Programming the Robot to Move Forward

1. Make sure the robot is turned OFF.

2. Make sure the right-side motor is plugged into port #1.

3. Make sure the left-side motor is plugged in to port #2.

4. Plug in the orange serial cable into the SERIAL port on the controller.

5. Prop the Base-Bot up on the spare wheels so that THE ROBOT’S WHEELS ARE NOT TOUCHING THE TABLE.

6. Open Easy C™.

7. Select FILE, NEW PROJECT.

8. Select OUTPUTS on the left hand side of the screen.

9. Drag and drop a MOTOR MODULE into the space below the variable box.

10. Select MOTOR 1.

4 11. Select value 0.

12. Place the comment “Makes motor one move robot forward.” A comment is a post-it note for code. It leaves a note but does not affect the code.

13. Click OK.

14. Repeat STEPS 8 and 9 for MOTOR 2. Select value 255.

15. In the comment box type “Makes motor 2 move robot forward.”

16. Click OK.

17. Your MOTOR MODULES should look like this:

18. Turn robot ON.

19. Select BUILD&DOWNLOAD.

20. Select YES.

21. After program has been downloaded, turn robot OFF.

5 22. Unplug the orange serial cable.

23. Place the robot on the ground.

24. Turn on the robot. What happens?

25. You may have noticed that the robot kept moving. You need to tell your robot how long to go forward by using a block called the WAIT statement.

Part C: THE WAIT BLOCK

1. Select HELP from the menu bar at the top of the screen.

2. Select SEARCH.

3. Type WAIT, scroll down to the bottom of the list and select wait from the choices that appear.

4. Read the description of the WAIT block.

5. Answer question #4 on your activity sheet.

6. Select PROGRAM FLOW on the left side of the screen.

7. Place a WAIT block between the VARIABLE box and the MOTOR MODULE boxes.

6 8. Time is measured in milliseconds. Five seconds would be 5000 milliseconds.

9. Input 5000 into the WAIT block.

10. Type “Delay before start” in the comment box.

11. Click OK.

12. This statement will give you five seconds to move out of the way after turning on the robot.

13. Prop the Base-Bot up on the spare wheels so that THE ROBOT’S WHEELS ARE NOT TOUCHING THE TABLE.

14. Turn robot ON.

15. Select BUILD&DOWNLOAD.

16. Select YES.

17. After program has been downloaded, turn robot OFF.

18. Unplug the orange serial cable.

19. Place the robot on the ground.

20. Turn on the robot. What happens?

PART D: STOPPING THE ROBOT

1. Drag and Drop a WAIT block to the space between the MOTOR MODULES and the END block.

2. Set the time to 5 seconds (5000 ms).

3. Type “Makes robot go forward for 5 sec” in the comment box.

7 4. Click OK.

5. Drag and Drop a MOTOR MODULE between the second WAIT block and the END block.

6. Set MOTOR 1 to 127.

7. Type “Stops Motor” in the comment box.

8. Select OK.

9. Repeat steps 3-5 for MOTOR 2.

10. Your program should now look like this.

11. Prop the Base-Bot up on the spare wheels so that THE ROBOT’S WHEELS ARE NOT TOUCHING THE TABLE.

12. Turn robot ON.

13. Select BUILD&DOWNLOAD.

8 14. Select YES.

15. After program has been downloaded, turn robot OFF.

16. Unplug the orange serial cable.

17. Place the robot on the ground.

18. Turn on the robot. What happens?

PART E: FORWARD, STOP, REVERSE, STOP Challenge

1. Use what you learned to make the robot travel forward one foot, stop, reverse one foot, and stop at its starting point.

2. Demonstrate your working program to your instructor.

3. Sketch your program in the space for question 6 on your activity sheet.

PART F: TURNS

1. Program the robot to make a 90° pivot turn and stops.

2. Demonstrate your program to your instructor.

3. Sketch the program in the space for question #7.

4. Program the robot to make a 180° pivot turn and stops.

5. Demonstrate your program to your instructor.

6. Sketch the program in the space for question #7.

7. Program the robot to make a moving turn to the left that traces a circle.

8. Demonstrate your program to your instructor.

9. Sketch the program in the space for question #7.

10. Complete and turn in your activity sheet.

9

Recommended publications