Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming - Motion Intro to Robotics. Motors and Sensors Setup The first thing we need to do is tell ROBOTC that we have motors on our robot. Choose.

Similar presentations


Presentation on theme: "Programming - Motion Intro to Robotics. Motors and Sensors Setup The first thing we need to do is tell ROBOTC that we have motors on our robot. Choose."— Presentation transcript:

1 Programming - Motion Intro to Robotics

2

3 Motors and Sensors Setup The first thing we need to do is tell ROBOTC that we have motors on our robot. Choose ROBOT, then MOTORS AND SENSORS SETUP.

4 Motors and Sensors Setup You will notice that there are THREE tabs. One for Motors, Analog Sensors, and Digital Sensors. Choose the Motors Tab. In port 2 “Name” type in Rmotor and for ports 3 type in Lmotor. Then select MOTOR EQUIPPED from the type drop down menu. Click APPLY, then OK.

5 Motor Command The motor command tells the robot to run a motor at a given power level. The example below sets the motor on port 3 to run at full power forwards. Remember, every command ends with a semicolon.

6 Wait Command The comment wait1Msec tells the robot to wait before it executes the next command, for a given time in milliseconds. The value in parenthesis is the amount of time you want the robot to wait. 3000Ms is equal to 3 seconds.

7 Let’s Begin You will notice that at the top there are PRAGMA statements. These are automatically generated configuration statements and will ALWAYS be at the very top of the program.

8 Let’s compile If it asks you to save, call it motion lesson 1. WHAT HAPPENED?

9 Compile Errors Errors have different colors and are displayed next to the code line number where there is a problem. Here we see a problem in line 9. Errors are explained in a little bit more detail below. If you have no errors, then the program compiled correctly.

10 Compiled Correctly

11 Attaching to a PC Use a USB cable to connect the robot to the PC. It is often an ORANGE cable. Turn the Cortex on.

12 Check the platform type

13 Check the download method

14 Compile and download Possible errors: Cortex power on? If not, RobotC may ask you to turn on the battery. Can’t find the COM port? If not, unplug the USB cable with the cortex powered on, then re-insert and try again.

15

16 What happened????

17 Motors and Sensors Setup

18 Check here! (or port 3?) RobotC will make the change in the #PRAGMA statement.

19

20

21 Modify this code. Since we are moving at half power lets double our time.

22 Modify the code, then compile and download. Note what happens.

23 Modify the code below, then compile and download each time. Note what happens.

24

25 Manual Straightening To compensate for the differences between the motors, we could either speed up the slower motor or slow down the faster one. Let’s slow down the faster one.

26 Save your code Save the code with a filename you will remember in your MY DOCUMENTS folder.

27 Challenge Using what you have learned, write a program that will allow you navigate the labyrinth in the arena. You MUST use comments to explain in the code what you are doing. Place group member names in the comments at the bottom of the code.


Download ppt "Programming - Motion Intro to Robotics. Motors and Sensors Setup The first thing we need to do is tell ROBOTC that we have motors on our robot. Choose."

Similar presentations


Ads by Google