Anda di halaman 1dari 9

LEGO Mindstorms Class: Lesson 2

Build A Mindstorms Vehicle - 5 Minute Bot:


(Copied from http://www.nxtprograms.com/five_minute_bot/steps.html)

We will build a 3-wheeled robot vehicle with two motorized wheels, and an extra wheel that can pivot, called
a "caster". It is possible to build a robot with 4 or 6 wheels, or with treads, like a tank, but the 3-wheeled
robot is the easiest to program, so that's what we'll use. A robot with a caster generally runs best on very
smooth, flat surfaces, so that the caster can glide easily. For rougher surfaces, 4 wheels or treads may work
better. Follow the steps below to build the robot vehicle.

Step 1: Attaching Wheels to the Motors

Step 2: Attaching Angled Beams to the Motors

Step 3: Adding Wheels and Motors to the Bot

Step 4: The Attachment Bar

Step 5: The Caster

Step 6 - The Wiring: Use two medium length (35 cm) wires to connect the motors to ports B and C on the NXT. Make
sure that the motor on each side is connected to the port on that side.

That's it! You made a robotic vehicle!

Making the Robot Move:

Move Block vs. Motor Block

To make the motors turn, we can either use the Move

Block or the Motor

Block.

There are several differences between the two blocks, but the biggest is that the Move block can control one,
two, or three motors at one time, while the Motor block can only control one motor at a time. The Motor
block allows you to control the motor in more detail, but for driving, you usually want to have at least two
motors running two wheels at the same time. This is why we'll stick with the Move block to drive our robot.
The Move Block

The Move block controls one, two or three motors simultaneously.

Look at the settings for the move block. Let's figure out what each one does:

Port: This tells the Move block which of the A, B and C ports are connected to motors to control
Direction: This determines whether the wheels turn forwards or backwards.
Steering: Depending on where the slider is, this gives more power to one motor or the other (you
specify which of the two motors to use).
Power: This specifies how much power overall to send to the motors. More power makes the motors
turn faster, less power turns them slower
Duration: This determines how many turns the motors make, or how long in seconds they run for. The
duration can be specified in rotations, degrees, seconds or unlimited (run forever).
Next Action: Brake means the motor will stop after it is finished. Coast means it will keep turning,
though without any additional power. We will almost always use Brake.

Q: What happens to the vehicle if the motor on the left side runs faster than the motor on the right side
6
(assume both motors are turning forwards)? A:_______________________________________________

Moving in a Straight Line


Let's figure out how far the car will go when we input certain data to the Move Block. Create a simple program in NXTG, consisting of a single Move Block. Save it in your folder on the S drive with the name "Move Test".

Use this program to answer some of the questions below. You may need a calculator:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

What is the circumference (distance around) of a tire on your robot (in inches)? _____________ inches
How far do you think the car will go (in inches) when the wheel turns one time? ______________ inches
Try it. How far did it go? _____________ inches
How far do you think the car will go (in inches) when the wheel turns 5 times? _____________ inches
Try it 3 times and compare your results: How far did it go?
______________ inches _______________ inches ______________ inches
How accurate do you think the Move block is? __________________________
If you want the robot to travel 20 inches, how many turns should the wheel make? __________ turns.
Try it. Did it work? ________________
How many degrees correspond to one rotation of the wheel? ____________ degrees
How far will the car go if the wheels turn 720 degrees? _______________ inches
Try it. How far did the car go for at 720 degree rotation? _______________ inches

Turning:
The robot will always turn when its wheels spin at different rates. In most cases, it's hard to predict where it
will go when both wheels are turning at different rates, so we'll focus on two kinds of turns that we can
predict: Pivoting in Place, and Turning with One Motor. You can control which kind of turn you make with the
steering setting. The following steering values give you the following different kinds of turns:
Steering Value
100
50
0
-50
-100

Steering Results
Pivot in place to the right
Turn to the right using one motor
Go straight
Turn to the left using one motor
Pivot in place to the left

Pivoting in Place

If you turn both motorized wheels in opposite directions at the same power (speed),
the vehicle will pivot around a point halfway between the two powered wheels, as
7

shown in the picture below. The wheels travel around a circle whose diameter is the length of the axle.
The tricky part is to figure out how many rotations the wheels need to complete a single turn. Let's do the
calculation, and then compare it to real life by programming our vehicle. You will probably need a calculator:
1. What is the distance across the circle the car makes when it turns? ____________________ inches
2. The circumference (distance around) the turning circle is about 3.14 x diameter =_______ ___________ inches
3. How many rotations does the tire have to make to travel the circumference of the circle? The formula for the
answer is: (Circumference of turning circle) (circumference of tire) = ________________________rotations

Let's program our Move Block to test our answer. Slide the Steering slider all the way to the right to specify a
right turn about the center of the vehicle. Put the number of rotations from answer 3 above into the Duration
setting to specify how far around the vehicle will turn.
Download and run your program. Did it work? Check with your instructor if you're not sure of the answer.

Turning with One Motor

If you give power to only one motorized wheel, while holding the other one still,
the vehicle will pivot around the unpowered wheel. Let's do a calculation like we
did above. Remember, in this case, the diameter of the circle the car makes is
two times the length of the axle.

4. What is the diameter (distance across) the circle the car makes when it turns? ____________________ inches
5. The circumference (distance around) the turning circle is about 3.14 x diameter =_______ ___________ inches
6. How many rotations does the tire have to make to travel the circumference of the circle? The formula for the
answer is: (Circumference of Circle) (Circumference of Tire) = ___________________________ rotations

Let's program our Move Block to test our answer. Slide the Steering slider to value 50 to specify a turn to the
right using one motor. Put the number of rotations from answer 6 above into the Duration setting to specify
how far around the vehicle will turn.
Download and run your program. Did it work? Check with your instructor if you're not sure of the answer.

Commenting your program:


Now that you know how to go straight and turn, you can combine a series of move blocks in a row to make your robot
follow a certain path. When you have a lot of Move blocks in a row that look similar, it is a good idea to place
comments near each move block so that you know what it's doing. That way if you have to make any changes, it's easy
to find the right place. You can add comments to your program using the comment tool
window. An example of a commented program is below:

at the top of the NXT

Challenges for You


(1) Can you write a program to make the Robot travel in a 12 inch square, using only 2 move blocks?
(2) Your instructor has set up a maze lined by blocks. Can you program your robot to navigate the maze without
knocking over any blocks? Note: Before you start programming, measure the distances in the maze to predict where
you want your robot to go. You will probably have to adjust your program afterwards, but you will have a good starting
point.
(3) Your instructor has set up a "parking garage" made of blocks. Can you drive your vehicle from the starting point to
park in the garage, without knocking over any of the blocks?

Anda mungkin juga menyukai