Working with Rotation Sensors PART I What if you wanted Roverbot, or any other robot, to travel 66 inches and then stop? Working with touch or light sensors you got it to stop when the sensor state changes (pressed or released for the touch sensor; light or dark for the light sensor). Using the On For command, you estimated the amount of time it would take the robot to travel a certain distance, then tested it in a program. In this activity, you will figure out how to program a robot to travel a certain distance using input from a rotation sensor. What you will need: • Rotation Sensor • Hand-cranked wheel • A calculator (optional) What to do: If this is the first time that you are working with a rotation sensor, you will have to add the sensor to the Sensors bin and prepare your RCX to display rotation sensor data. To add the rotation sensor to the Sensors bins, do the following: 1. Click on Settings in the Main Menu. 2. Click on Advanced. 3. Select the Rotation Sensor by clicking the box next to it. 4. Click on Accept. B-5 In order to use the View button to check rotation (axle turning) information that is being read by the sensor, you must first download a program that uses a rotation sensor, and run it at least once, similar to what you’ve done with the light sensor. To prepare your RCX to display rotation sensor data, do the following: 2. Download the program onto your RCX. 3. Run it. 1 © 2002 The LEGO Group. Scree n shots used here with permission . 1. Recreate the following program. Note that each Sensor Watcher is connected to a different input port, 1, 2, or 3 as shown by the numbers on the lower right hand side of each watcher. Your RCX is now ready to display rotation sensor data when the View pointer points at the rotation sensor input port. About the Rotation Sensor When we say that an axle (or a wheel) completed 1 rotation, it means that it turned one full circle, returning to its starting position. A Rotation Sensor measures how much an axle connected to it turns. In the starting position, as you turn on the RCX, the sensor value is 0. When the axle turns in one direction, the sensor value displayed on the RCX increases; it decreases (indicating a negative number in some cases) as the axle turns in the opposite direction. A. Taking Rotation Sensor measurements using a hand-cranked wheel. 1. Build the hand-cranked wheel. Follow the building instructions below. x1 10 Rotation Sensor x1 x1 x1 x3 x1 x1 x1 x1 2. Turn on the RCX. 3. Press the View button until you see a small arrow pointing to input port 1. 4. Crank the wheel clockwise and watch the number change on the display window. 5. Crank the wheel counterclockwise. Look at the display window. How does the number change? 2 B. What is the rotation sensor value when an axle (or a wheel) turns a full circle, called a rotation? 1. Place your hand-cranked wheel and RCX on a clean sheet of paper the size of a notebook page. 2. Mark a short line on the paper perpendicular to the wheel as shown in the illustration. 3. Turn off the RCX. 4. Turn the wheel so that the handle is exactly above the line (move your head side-to-side as you check it). 5. Turn on the RCX and set it to View Port #1. (It should read 0). 6. Turn the wheel clockwise until the handle returns to its original position (a complete turn). 7. Record the rotation sensor value shown on the display window on the 1st reading line below. 8. Repeat steps 3 through 7 two more times. Rotation Sensor values: ___________ 1st reading ___________ 2nd reading ___________ 3rd reading __________ average Important Note: It’s important to turn Off the RCX, and then On again before each trial so each reading starts at 0. 9. Calculate the average sensor value and write it on the line above. How close are you to 16? In fact, when an axle turns full circle—1 rotation—the sensor value is 16. You can think of it as the rotation sensor counting 16 ticks as it goes around one rotation, similar to the seconds hand on a clock, counting 60 ticks per minute, a tick for each second. In other words, when the sensor value is 16, you know the wheel (or axle) has completed exactly one rotation—one full circle. C. Will it matter if you turned the wheel quickly or slowly—will the sensor value change as you turn the wheel full circle ? Turn the wheel so that the handle is exactly aligned with the line on your sheet. Turn on the RCX and have the View arrow pointing to Port #1. (Sensor value should be 0). 3 Turn the wheel slowly until the handle is back to its original position. Write down the sensor value. Sensor value when turning slowly: __________ Sensor value when turning fast: __________ Now, do the same, only this time turn the wheel fast but accurately, stopping at the line (you can go back a bit if you turned too much). Does it look as if the speed you turn the wheel affects the rotation sensor value? D. Will the wheel size matter—will the sensor value change if you replaced the large wheel with a smaller one? Remove the large wheel and mount a small wheel instead. Remove this wheel: Replace it with this wheel: Turn the wheel full circle clockwise. What is the sensor value? _________ 4 Working with Rotation Sensors PART II Programming a Vehicle to Move a Certain Distance So far you have programmed your robots to go certain distances by telling them how much time they should travel. This worked well for many problems you solved, but it has its limitations. For example, as the batteries grow weaker and the robot slows down, it’s going to go a shorter distance for the same amount of time. The same can happen as you move from hardwood or vinyl floors to carpeted floors. Using input from a rotation sensor can help you overcome some of these problems. What you will need: • Gearbot with a rotation sensor(Ask your teacher for building instructions) • A calculator (optional) • Measuring tape or a ruler • A marker or whiteout liquid to mark a dot on a tire • 2 sheets of paper (8 ½ X 11 printer paper or any notebook paper), taped together along their short sides. What to do: You will now measure the distance GEARBOT travels first with a set of large wheels in the back and then with a pair of smaller back wheels. For each set of wheels, you will push GEARBOT twice—first until the sensor value reads 16 and then until it reads 32. You will then record your measurements in a chart on the next page. 1. Build Gearbot with a rotation sensor attached to the back wheel that is not on the same side as the motor. 2. Mount 2 large wheels (the largest in the kit) in the back and 2 medium-size wheels with yellow hubs in the front. 3. Use a marker or whiteout liquid to mark a dot on the tire of the wheel connected to the rotation sensor. 4. Place Gearbot so that the marked dot on the wheel is lined up with the short side of the paper. Make a pencil mark where the dot meets the edge of the paper. 5. Turn on the RCX and have the View arrow pointing to the Rotation Sesnsor input port. Be sure the starting sensor value is 0. If it is not, turn off the RCX, and repeat Steps 4 and 5. 6. With your hand, push Gearbot forward in a straight line on the paper until the sensor value reads 16. The marked dot on the tire should be in its original position, touching the paper. 7. Using a pencil, without moving Gearbot, mark a short line where the dot on the tire meets the paper. Repeat these measurements and see if you get the same distance each time. Be sure to align the dot with the edge of the paper and check that the starting value is 0. 8. Using a ruler and a pencil, connect the starting point at the edge of the paper with the end point. What is the length of that line? __________ Now, complete the column “distance traveled” in the chart on the next page. You already have the measurement for the first trial. Get the second measurement for the 5 large wheel (32 sensor ticks), then move the front wheels to the back, replacing the large wheels. Use the smallest wheels in the kit for the front. Be sure to draw a new line when you replace the large wheels with the smaller ones. Important note: You have only one set of medium size wheels in your kit. When you replace the large wheels with the smaller ones, move the front wheels to the back and place the smallest wheels in the kit in the front. Wheel Sensor value (Number of sensor ticks) Number of rotations (turning full circle) 16 1 Distance Traveled Wheel Measured Circumference Calculated* 32 Remove back wheels. Move front wheels to the back. Mount smallest wheels in front. 16 32 * The last page of this worksheet will remind you of how to calculate the circumference of a wheel. You may choose to do it now or later, after you have finished the rest of the activity. Ask your teacher, if needed. Figure out how the distance traveled is related to the wheel size (circumference). Fold the sheet of paper along the line traveled by the large wheel. Place one end of the line at the dot on the tire and wrap the line around the tire. Stop at the dot when one end of the line touches the other. Think about it: What is the wheel circumference? How is it related to the length of the line traveled? Look at the illustrations of a rolling wheel, page 8. Suppose the circumference of the wheel is 3”. Use the illustrations to help you think about how to figure out the number of rotations a wheel made, the number of sensor ticks, or the distance the wheel traveled. 6 • In the first 3 examples, the Distance Traveled is given. Figure out how many rotations the wheel made in each trial and how many sensor ticks that would be. • In the rest of the examples, the wheel circumference is given to you plus one other value. Figure out the rest. Wheel Circumference 3” 3” 3” 3” 3” 3” 3” Distance Traveled Number of Rotations Number of Ticks (sensor value) 3” 6” 9” 5 64 21” 45” Find a way to explain to someone how to figure out the number of sensor ticks to enter in a program if you know the wheel circumference and you know the distance you want it to travel. In short: • You know the circumference and the distance • You need to figure out the number of sensor ticks that would be. How to use the number of sensor ticks in a program. Now that you know how to figure out the number of sensor ticks, learning how to use it in a program is very simple. If you remember how you used input from a light sensor in a program, this is about the same. Roverbot will go forward for an unlimited amount of time. When the sensor value reads 161 it will stop, because it is its first reading that is greater than 160. What is the distance Roverbot would travel if its wheel circumference is 6”? _____________ 7 © 2002 The LEGO Group. Screen shots used here with permission . Here is a sample program, telling Roverbot to go forward and to stop after 160 sensor ticks. Circumference = 3” Distance Traveled = 3” What’s the number of rotations? _____ How many sensor ticks would that be? ________ Circumference = 3” Distance Traveled = 6” What’s the number of rotations? _____ How many sensor ticks would that be? ________ Circumference = 3” Distance Traveled = 9” What’s the number of rotations? _____ How many sensor ticks would that be? ________ 8 How to calculate the circumference of a wheel. In the previous problem you measured the circumference of your robot’s wheels. There is also a way to calculate the circumference of a wheel (or a circle), which you may have learned in geometry classes. For every circle, the circumference is 3.14 times bigger than its diameter. This number is called Pi, and its common symbol is π . To calculate the circumference of a wheel, you will have to accurately measure the diameter first. Once you know the diameter, multiply it by 3.14 to get the circumference. ____________ X 3.14 = ___________ Diameter circumference ____________ X 3.14 = ___________ Diameter circumference Write the circumferences you calculated here in the chart “calculated” column in the chart on page 5. Are they the same as the circumferences you measured? If they are different, what do you think could be the reason? 9
© Copyright 2026 Paperzz