Purpose:

The purpose of this lab is two fold. First to verify that you can talk to and control each of the mtors on the wheels of your Qbot. Once we have verified that you can control the motors you will then develop a strategy to calibrate the speed of your robot for different motor 'settings'. This will be important as we develop a method for keeping track of where the robot is via dead reckoning.

You are asked to make a number of measurements for this lab and calculate some speeds. Because this is a science class we will make these measurements in cm and s. Because you may not have a metric tape measure (although many have both cm and inches) you can make your measurement in inches and multiply by 2.54 cm/inch to convert. You will need express any fractional measurements (i.e. 6 1/4 " = 6.25") in decimal form before converting.

Procedure:

As you begin each lab from here on out the assumption is that you have connected your Qbot to your computer and you have the IDE running and talking to the Qbot. This is what we did previously and becomes the starting point for all future labs. While it seems like there shouldn't be any problems once you get the process to work the first time I have had some experiences that have been surprising.

You are asked to make your Qbot make a couple of movements including straight lines and 90 degree corners. These do NOT need to be perfect. The goal is to understand the concepts needed to achieve linear motion and 90 degree turns.

  • If your IDE didn't load up the QBlink sketch from our previous lab find it and open it up. If you didn't save it last time as it's own file you will need to recreate it from the instructions in the Blinky Lab.
  • QBlink is a useful starting point because it's an easy way to test an individual pin to see what it's connected to. With the power on the Qbot off set the testPin to 5 and then upload the sketch (remember to watch for the flashing blue communication lights). Hold the Qbot off the ground and turn it on. Look at what the wheels are doing. If your Qbot is like mine the right hand wheel will be turning for 1 s and then resting for 1 s. This tells you pin 5 is connected to the right hand wheel motor. Now test pin 6. If all goes well you will confirm that you know which pins control which motor.
    • NOTE: From this point forward the Qbot will usually do nothing while it's power is off. The connection between the sketch and pins is essentially disabled while the power is off.
  • QBlink is useful for testing a single pin but to drive our Qbot around we need to run both motors and once. I'm sure some of you are wondering about the possibility of reverse as well. Open a new sketch and paste this motor control code into that sketch. Use 'Save As' from the file menu to save this sketch to your computer.
  • After you upload the motor control code to your robot you can approach the next two steps in either order. Perhaps I have a slight preference for the suggested order but I understand that you may want to see your Qbot run around the floor first.
    • Read through this section by section discussion of what the code in the Motor Control sketch is saying/doing. In order to make thoughtful changes during future sections of the lab you need to have a basic conceptual understanding of what the code is doing.
    • Disconnect your Qbot from the computer, turn it on, and set it down on a smooth hard floor. After waiting for a few seconds it will roll forward, pause, roll backwards, pause and then repeat the cycle until you pick it up and stop it.
  • Verification: A couple of things to notice about your Qbot. Does it go forward first or in reverse? Does it roll straight going forward and in reverse? Does it curve differently in forward and reverse? Because each wheel has it's own motor you would expect those motors to behave slightly differently leading to the robot not going quite straight. There are correction terms in the code that allow you to speed up/slow down one of the motors to help it go straight. Going straight will be important in the next lab where you will need to drive in a rectangle. You are likely to find that you need to adjust the motors differently for forward and for reverse. Determine what those corrections are and document them in a comment in your Motor Control code.
  • Speed: Now that the robot will go forward and backward in a straight line the question is how fast is it going? To do this you will experimentally measure how far it travels in the 5 s it goes forward and back. From x = v*t you can calculate v if you know x and t. Calculate the speed separately for forward and reverse. Check to see if the robot goes the same distance each time it goes forward and back (tape on the floor is a possible method). If it changes make a note of how much and under which circumstances.
  • Turning: No doubt you are clear about the idea that running one wheel faster than the other makes the robot turn. Your final task is to figure out how to turn the robot 90 degrees in place (not moving forward or backwards). To do this one wheel motor will be off and the other will run at some speed for some period of time and then stop. You will notice two comments in the sample code that indicate where I want you to insert your code to make the turn. The concepts and tools you need are contained in the earlier section by section discussion of the motor control code.
  • With the turning code loaded up turn on the Qbot and watch it move about the floor. Think about the shape of the path the Qbot makes on the floor and why.
  • What you have been doing through out this lab is execute an experimental process of testing, analysis (did it turn too much or too little or the wrong way?), implement a new test, rinse and repeat until you're happy. This is how many things in science get figured out.

 

LAB DELIVERABLES: (Turn in on Bb)

I) Paste your Motor Control code (with turns) into a word document.

II) Show your calculation of the speed of your robot for a particular motor speed.

III) Describe the shape of the path your robot makes across the floor with the turning code in the locations indicated. Describe how you woud change the direction the robot turns from turning right to turning left or vica versa.

IV) Turn all of the above into the Bb assignment