Presentation is loading. Please wait.

Presentation is loading. Please wait.

Robotics Week 3 beginning wheel control

Similar presentations


Presentation on theme: "Robotics Week 3 beginning wheel control"— Presentation transcript:

1 Robotics Week 3 beginning wheel control
Compiled from various Internet sources Presented by Mr. Hatfield Robotics Week 3 beginning wheel control

2 Motor Control Motor control is both easy and difficult in ROBOTC.
In it’s simplest form Motor[motorC] = 50; Will cause motorC to run at 50% power, unfortunately only for one millisec. Power can be between -100 and 100

3 How Long to Run So we add a sleep command to cause Motor command to continue. Motor[motorC] = 50; sleep(5000); //5000 miliseconds or 5 sec. Now motorC will run for 5 seconds, the sleep command causes it to do what it was doing for as long as it is told.

4 What About 2 Wheels Easy, just add another Motor command
Motor[motorB] = 50; Motor[motorC] = 50; sleep(5000); //5000 miliseconds or 5 sec. Now both motorB and motorC will move at 50% power for 5 seconds

5 Can I Go Backwards Yes, reverse the power in the Motor command
Motor[motorB] = -50; Motor[motorC] = -50; sleep(5000); //5000 miliseconds or 5 sec. Now both motorB and motorC will move backwards at 50% power for 5 seconds

6 Can I Go a Certain Distance
Not directly with a ROBOTC command however with a little math and a couple ROBOTC commands you can. ROBOTC offers the ability to turn as specific number of degrees of rotation. If you know the circumference of your wheel then a simple calculation will give you a distance.

7 Distance to Travel Equals
Rotations * Circumference (Degrees / 360) * Circumference (MotorEncoder / 360) * Circumference Which leads us to: MotorEncoder = (360 / Circumference) * Distance to travel

8 Show Me an Example First lets look at making the motor go a specific number of degrees, say 720 or two full rotations (this will cause the robot to turn) //Resets the motor encoder using the resetMotorEncoder command resetMotorEncoder(motorC); //While the encoder for the motorC is less than 720 while(getMotorEncoder(motorC) < 720) { //Move the wheel motor[motorC] = 50; } //Stop the motors motor[motorC] = 0;

9 Show Me an Example Lets make the robot move forward by moving both wheels at the same time (it is not necessary to reset the motor encoder on both wheels.) //Resets the motor encoder using the resetMotorEncoder command resetMotorEncoder(motorC); //While the encoder for the motorC is less than 720 while(getMotorEncoder(motorC) < 720) { //Move the wheel motor[motorC] = 50; motor[motorB] = 50; } //Stop the motors motor[motorC] = 0; motor[motorB] = 0;

10 Move the Robot 10 cm //causes the robot to move forward 10 cm
float d = 10; //Distance for robot to travel in cm float dia = 5.6; //Standard EV3 wheel diameter in cm float pi = 3.14; //PI approximation float circ = pi * dia; //calculate the circumference float deg = (360 / circ) * d; //calculate the circumference //Resets the motor encoder using the resetMotorEncoder command resetMotorEncoder(motorC); //While the encoder for the motorC is less than 720 while(getMotorEncoder(motorC) < deg) {//move until requested deg motor[motorC] = 50; motor[motorB] = 50; } motor[motorC] = 0; motor[motorB] = 0;

11 Try To: Move the robot forward 20 cm Move the robot backward 20 cm
Do both of the above Make the robot turn left then right Make the robot turn left 90 degrees Make the robot travel in a square Make the robot dance

12 Congratulations!!! I am assuming that you have a functioning EV3 with ROBOTC I am assuming that you were able to make your robot move according to the instructions in the previous slide


Download ppt "Robotics Week 3 beginning wheel control"

Similar presentations


Ads by Google