Tank Tread Full Extension - LEGO Education
Tank Tread Full Extension - LEGO Education
Tank Tread Full Extension - LEGO Education
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Overview<br />
In this extension, a tank tread will be assembled and attached to the Ranger Bot. The Ranger Bot will be programmed to move<br />
forward until it detects an obstacle in its path with the ultrasonic sensor. It will then rotate 180° in place and repeat the process.<br />
Estimated Time: 90 minutes<br />
Preparation:<br />
• Clear the workstation.<br />
• Organize the TETRIX ® and<br />
MINDSTORMS ® sets.<br />
• Organize the TETRIX <strong>Tank</strong> <strong>Tread</strong> Kit<br />
• Charge the TETRIX and NXT<br />
batteries.<br />
Building Objectives:<br />
• Learn how to use elements from the<br />
TETRIX <strong>Tank</strong> <strong>Tread</strong> Kit (tank tread<br />
chain links, tank tread idler wheels,<br />
tank tread sprockets)<br />
• Learn how to incorporate<br />
the TETRIX tank tread into a<br />
MINDSTORMS with TETRIX robot<br />
Materials:<br />
• Completed Ranger Bot from<br />
Lesson 3 of the TETRIX Getting<br />
Started Guide<br />
• TETRIX <strong>Education</strong> Base Set (739143)<br />
• <strong>LEGO</strong> ® MINDSTORMS ® <strong>Education</strong><br />
NXT Base Set (979797)<br />
• TETRIX <strong>Tank</strong> <strong>Tread</strong> Kit (736468)<br />
• Software (ROBOTC ® or LabVIEW <br />
for <strong>LEGO</strong> MINDSTORMS) installed on<br />
each computer<br />
Programming Objectives:<br />
• Learn to program a robot to react to<br />
a detected object in its path<br />
• Use an ultrasonic sensor to detect<br />
objects<br />
• Set threshold values to use when<br />
reading sensor values<br />
• Use While Loops and Case<br />
structures<br />
Resources:<br />
• Engineering Journal Worksheet<br />
• <strong>Tank</strong> <strong>Tread</strong> <strong>Extension</strong> Overview<br />
• <strong>Tank</strong> <strong>Tread</strong> <strong>Extension</strong> Building<br />
Guide<br />
• <strong>Tank</strong> <strong>Tread</strong> <strong>Extension</strong><br />
Programming Guide<br />
• <strong>Tank</strong> <strong>Tread</strong> <strong>Extension</strong> Reference<br />
Guide<br />
• <strong>Tank</strong> <strong>Tread</strong> <strong>Extension</strong> Sample<br />
Program<br />
• <strong>Tank</strong> <strong>Tread</strong> <strong>Extension</strong> - How It<br />
Should Work video<br />
• <strong>Tank</strong> <strong>Tread</strong> <strong>Extension</strong> 3-D Model<br />
Best Practices:<br />
Be sure to review the General Best Practices Guide in the Introduction section of the TETRIX Getting Started Guide.<br />
Building<br />
• Note that the Bracket Switch Mount and On/Off Switch need to be moved from where they were placed in Lesson 2 in<br />
order to incorporate the tank tread.<br />
• The DC Drive Motors and motor mounts will need to be moved from where they were placed in Lesson 2.<br />
• The 3” Wheels added in Lesson 2 will be replaced with tank tread sprockets and the Omni-wheels will be replaced with<br />
tank tread idler wheels.<br />
Programming<br />
• Ensure that the sensors are connected to the correct ports. Consult the wiring diagram in the Lesson 3 Building Guide<br />
for the proper configuration.<br />
• Because different sensors may have different values for the same objects, the threshold value of the ultrasonic sensor<br />
may need to be changed and tested.<br />
• Note that the wait function uses milliseconds.<br />
• Note that for debugging purposes, the NXT Brick displays the sensor values when running the provided sample program.<br />
• Try to keep the code linear and well organized. This makes the code much easier to follow and debug.<br />
1
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Start with the build completed in Lesson 3 of the TETRIX® Getting Started Guide.<br />
Steps 1 - 7 and 13 involve removing elements from the model. Some of them will be reattached later.<br />
Parts to be Removed<br />
Step 1<br />
1x Switch Plate<br />
Assembly<br />
4x 1/2" SHCS<br />
4 x Kep Nut<br />
Tips<br />
• Take care to ensure wires don’t get tangled.<br />
• The switch plate can remain dangling and unattached at this point.<br />
2
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts to be Removed<br />
Step 2<br />
1x Motor Assembly<br />
with Drive Wheel<br />
2x 1/2" SHCS<br />
2x Kep Nut<br />
Tips<br />
Make sure to disconnect the wire from the motor before removing it.<br />
3
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts to be Removed<br />
Step 3<br />
1x Motor Assembly<br />
with Drive Wheel<br />
2x 1/2" SHCS<br />
2 x Kep Nut<br />
Tips<br />
Make sure to disconnect the wire from the motor before removing it.<br />
4
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts to be Removed<br />
Step 4<br />
2x Omni-wheel 2x Axle Hub 2x 100mm Shaft 8x 1/2" SHCS 4x Bronze Bushing 2x Shaft Collar<br />
Tips<br />
• Be sure to keep the shaft collar and bronze bushing in a safe place when removing the wheels.<br />
5
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts to be Removed<br />
Step 5<br />
1x Servo Controller 2x 3/8" BHCS 2x Kep Nut<br />
Tips<br />
• The 5/64” hex key will need to be used to remove the Servo Controller<br />
• Make sure to disconnect the wire that connects the Servo Controller to the DC Motor Controller<br />
6
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts to be Removed<br />
Step 6<br />
4x 3-Module Connector Peg<br />
with Friction<br />
Tips<br />
• Set the pegs aside in a safe place. They will be re-added later.<br />
7
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts to be Removed<br />
Step 7<br />
1x NXT Mount<br />
Assembly<br />
Tips<br />
• Do not disassemble the <strong>LEGO</strong> ® elements that are used as the mount.<br />
• Set aside the whole assembly, as it will be re-added later.<br />
8
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts Needed<br />
Step 8<br />
1x Switch Plate<br />
Assembly<br />
4x 1/2" SHCS<br />
4 x Kep Nut<br />
Tips<br />
• It may be necessary to rearrange some wires or unwire and then rewire the switch to move the plate to the rear of<br />
the robot.<br />
9
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts Needed<br />
Step 9<br />
2x 32 mm Channel 4x 1/2" SHCS 4x Kep Nut<br />
Tips<br />
• Make sure to put one channel on the very end and the other in the middle of the other two channels.<br />
10
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts Needed<br />
Step 10<br />
2x 32 mm Channel 4x 1/2" SHCS 4x Kep Nut<br />
Tips<br />
• Make sure that the channels on both sides of the robot are aligned.<br />
11
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts Needed<br />
Step 11<br />
6x Idler Wheel 6x 100mm Shaft 24x Bronze Bushing 12x Shaft Collar 6x 3/8" Axle Spacer<br />
Tips<br />
• Add an idler wheel, as shown above and then repeat for the remaining five channels.<br />
12
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Step 12<br />
Tips<br />
• Tighten the set screw to couple the shaft collar with the axle, keeping everything in place.<br />
13
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts to be Removed<br />
Step 13<br />
2x 3" Wheel<br />
8x 1/2" SHCS<br />
Tips<br />
• Remove the four screws and set them aside to be used in the next step.<br />
• Remove the wheel from the motor, but do not remove the motor hub.<br />
• Repeat for the other motor that was removed.<br />
14
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts Needed<br />
Step 14<br />
2x <strong>Tank</strong> <strong>Tread</strong><br />
Sprocket<br />
8x 1/2" SHCS<br />
Tips<br />
• After adding the sprocket, use the four screws that were set aside in Step 13 to fasten the sprocket to the motor hub.<br />
• Repeat for the other motor.<br />
15
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts Needed<br />
Step 15<br />
2x 1.5" SHCS<br />
1x Motor Assembly<br />
with Sprocket<br />
Tips<br />
• Note that the motor assembly is NOT to be mounted directly above the middle idler wheel.<br />
• Be sure to use the longer 1.5" screws to reach all the way through the channel.<br />
16
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts Needed<br />
Step 16<br />
2x 1.5" SHCS<br />
1x Motor Assembly<br />
with Sprocket<br />
Tips<br />
• Note that the motor assembly is NOT to be mounted directly above the middle idler wheel.<br />
• Be sure to use the longer 1.5" screws to reach all the way through the channel.<br />
17
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts Needed<br />
Step 17<br />
1x Servo Controller 2x 3/8" BHCS 2x Kep Nut<br />
Tips<br />
• Be sure to use the smaller 3/8" screws.<br />
• Align the servo controller in the same orientation as the DC motor controller.<br />
• Daisy chain the two controllers.<br />
18
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts Needed<br />
Step 18<br />
1x NXT Mount<br />
Assembly<br />
Tips<br />
• Slide the NXT Brick and its mount into place.<br />
• Note that it is now facing the opposite direction from how it initially was.<br />
19
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts Needed<br />
Step 19<br />
4x 3-Module Connector Peg<br />
with Friction<br />
Tips<br />
• Use the four pegs that were set aside in Step 6.<br />
20
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Note: This step is optional. If the rubber traction elements are not available, continue without them.<br />
Parts Needed<br />
Step 20<br />
148x <strong>Tank</strong> <strong>Tread</strong> Chain Link<br />
148x Rubber Traction Element<br />
Tips<br />
• Inserting the rubber elements will add additional traction to the treads.<br />
21
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Parts Needed<br />
Step 21<br />
148x <strong>Tank</strong> <strong>Tread</strong> Chain Link 148x Rubber Traction Element<br />
(Optional)<br />
Tips<br />
• Use 74 links per side to assemble the two treads.<br />
22
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Step 22<br />
Tips<br />
• Loosen one of the motor mount screws in order to rotate the motor within the hub.<br />
• This will allow the treads to slide on.<br />
23
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Step 23<br />
Tips<br />
• Carefully slide the treads onto the set of idler wheels and the tank sprocket that is connected to the DC motor.<br />
• Make sure the sprocket gets firmly interlocked with the tank tread.<br />
• It may be required to rotate the mounted motor to provide more slack.<br />
24
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Step 24<br />
Tips<br />
• This step introduces more tension in the treads and will prevent the treads from slipping off.<br />
• After this is done, be sure to tighten the motor mount screw to prevent the motor from slipping in its hub.<br />
25
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Building Guide<br />
Final View<br />
26
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Programming Guide (LabVIEW for <strong>LEGO</strong> ® MINDSTORMS ® )<br />
Introduction:<br />
In this guide, the Ranger Bot with <strong>Tank</strong> <strong>Tread</strong> will be programmed to move forward until it detects an object within 30 cm.<br />
It will then rotate 180º in place and repeat the process. This guide is for use with the LabVIEW for <strong>LEGO</strong> ® MINDSTORMS ®<br />
programming language.<br />
Review:<br />
• To review the basic principles of connecting to the NXT Brick and configuring LabVIEW for <strong>LEGO</strong> MINDSTORMS for use with<br />
various sensors and motors, review the Programming Guides and Tutorial Videos from Lessons 2 and 3 in the TETRIX ® Getting<br />
Started Guide.<br />
• To review the basic principles of programming in LabVIEW for <strong>LEGO</strong> MINDSTORMS, review the Programming Guides and<br />
Tutorial Videos from the Line Follower Programming <strong>Extension</strong> in the TETRIX Getting Started Guide.<br />
• These materials contain detailed information about how to use the Schematic Editor and how to create the structures,<br />
functions, constants, and wires that are presented in this guide.<br />
• This program makes use of the Screen Update SubVI, provided on the TETRIX ® Getting Started Guide Resource page. This<br />
function uses the NXT to display custom text as well as light and ultrasonic sensor readings.<br />
• Use these steps to add the function to the program:<br />
a. Within the block diagram, right-click to bring up the Functions palette and choose Select a VI.<br />
b. Then navigate to where the Screen Update SubVI is saved.<br />
Note: If the Screen Update SubVI has not been saved on the computer in a specific location already, download it from the<br />
TETRIX Getting Started Guide by navigating to the Resources tab and selecting the Screen Update SubVI Program<br />
(LabVIEW for <strong>LEGO</strong> MINDSTORMS) button.<br />
c. Once the Screen Update SubVI has been located, open it and place it on the block diagram.<br />
Getting Started:<br />
1. Create a new Ranger robot project and name it <strong>Tank</strong> <strong>Tread</strong>.<br />
2. Check the Schematic Editor to make sure all the motors and sensors match the robot’s hardware setup.<br />
3. Create a new VI.<br />
4. Create a While Loop that will encase the code.<br />
5. Check if there is an object within 30 cm, and output sensor values to the screen.<br />
a. Use the Screen Update SubVI to read the ultrasonic sensor and automatically output sensor values.<br />
b. Use a Less? function to compare the sonar value (X terminal) with a constant value of 30 (Y terminal).<br />
27
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Programming Guide (LabVIEW for <strong>LEGO</strong> ® MINDSTORMS ® )<br />
6. Use a Case structure to execute code depending on the result of the comparison.<br />
a. Create a Case structure inside the While Loop and wire the output of the Less? function into the Case selector.<br />
7. If the robot detects an object within 30 cm, it will output a message to the screen, and then rotate 180-degrees.<br />
a. First, drag a Screen Update SubVI into the True case of the Case structure.<br />
b. Create 2 string constants for the “Line 5 Text” and “Line 6 Text” terminals.<br />
c. The first constant should say “Object Detected!” and the second one should say “Turning…”.<br />
d. Next, place a Move Motors function in the Case structure.<br />
e. Create a motors constant and re-wire it so that it is outside of the Case structure.<br />
f. Expand the constant and select “Left Wheel” and “Right Wheel”, respectively.<br />
g. Now, wire a constant of 30 into the power terminal for the left wheel and a constant of -30 into the power terminal for<br />
the right wheel.<br />
h. Finally, add a Wait For Time (msec) function and add a constant of 1700 (this turn duration may vary for each robot).<br />
i. Be sure to wire all NXT terminals in sequence.<br />
8. If no object is detected, the robot simply drives forward and a message is output to the screen.<br />
a. First, use the Screen Update SubVI to output a string of “No Object Detected” on line 5.<br />
b. Next, use a Move Motors function and wire it up to the motors constant.<br />
c. Now, create a constant of 15 and wire it into both power terminals.<br />
d. Finally, wire up the NXT wires.<br />
28
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Programming Guide (LabVIEW for <strong>LEGO</strong> ® MINDSTORMS ® )<br />
9. Finally, the program must stop if one of the NXT buttons is pressed.<br />
a. Drag a Read NXT Buttons function into the While Loop.<br />
b. Wire the Boolean value from the “Yes/No” terminal into the conditional terminal.<br />
29
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Programming Guide (ROBOTC ® )<br />
Introduction:<br />
In this guide, the Ranger Bot with <strong>Tank</strong> <strong>Tread</strong> will be programmed to move forward until it detects an object in its path. It will<br />
then rotate 180º in place and repeat the process. This guide is for use with the ROBOTC ® programming language.<br />
Getting Started:<br />
1. To start the program, type the Main Task function, followed by an opening brace.<br />
task main()<br />
{<br />
2. Declare four integer variables as seen in the code below. Set them to values shown. Beside each variable, there are two<br />
slashes (//) followed by what that variable is representing. These mark a comment. Notice that comments appear in green<br />
when code is typed into ROBOTC.<br />
Note: A comment is not part of the code that the NXT Brick will execute, but it helps the programmer by allowing the<br />
addition of notes to describe what has been done.<br />
int dValue = 15;<br />
int tValue = 30;<br />
int threshold = 30;<br />
int sonarValue;<br />
// Forward drive motor power<br />
// Turning motor power<br />
// Ultrasonic sensor threshold value<br />
// Ultrasonic sensor reading<br />
3. Add a While Loop to make the contained code repeatedly execute without pressing any of the buttons on the NXT Brick.<br />
while(nNxtButtonPressed == kNoButton)<br />
{<br />
4. Add a conditional statement that checks if the ultrasonic sensor reading is greater than or equal to the threshold variable.<br />
In this case, set both motors’ power to the dValue variable. This will make the robot move forward in a straight line.<br />
if(SensorValue(SonarSensor) >= threshold)<br />
{<br />
motor[motorD]= dValue;<br />
motor[motorE]= dValue;<br />
5. Update the display using the NXT write to screen command to show the current ultrasonic sensor value, as well as a message<br />
that reads “No object detected.” Also add a closing brace to the statement.<br />
The NXT write to screen command requires three pieces of information, called parameters, in order to write both text and a<br />
variable to the screen:<br />
i. The line number.<br />
ii. The text (in quotations) which includes a display variable caller.<br />
Note: In this case, %d is the display variable caller. In the place of %d, an integer variable is displayed on the screen.<br />
iii. The variable name.<br />
30
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Programming Guide (ROBOTC ® )<br />
This information is inside the brackets beside the command, separated by commas.<br />
sonarValue = SensorValue(SonarSensor);<br />
nxtDisplayTextLine(2, "Sonar Value: %d", sonarValue);<br />
nxtDisplayCenteredTextLine(4, "No object");<br />
nxtDisplayCenteredTextLine(5, "detected.");<br />
}<br />
6. If the statement above is not True, meaning the sensor reading is below the threshold value, the robot should rotate. Add an<br />
else to the Case structure and set both motors’ power to the tValue variable. One of these must be set to negative for the<br />
robot to turn.<br />
else<br />
{<br />
motor[motorD]= tValue;<br />
motor[motorE]= (tValue*-1);<br />
7. Update the display to read “Object detected! Turning…”<br />
nxtDisplayCenteredTextLine(4, "Object detected!");<br />
nxtDisplayCenteredTextLine(5, "Turning...");<br />
8. Add a Wait command, allowing the robot to turn for 1700 ms. This value can be changed when the program is tested to<br />
make the robot turn exactly 180°. Also, add a closing brace to the else statement.<br />
wait1Msec(1700);<br />
}<br />
9. Add a closing brace to end the infinite While Loop in Step 3.<br />
}<br />
10. Add a closing brace to end the program.<br />
}<br />
31
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Programming Guide (ROBOTC ® )<br />
Completed Code:<br />
task main()<br />
{<br />
int dValue = 15;<br />
int tValue = 30;<br />
int threshold = 30;<br />
int sonarValue;<br />
// Forward drive motor power<br />
// Turning motor power<br />
// Ultrasonic sensor threshold value<br />
// Ultrasonic sensor reading<br />
while(nNxtButtonPressed == kNoButton)<br />
{<br />
if(SensorValue(SonarSensor) >= threshold)<br />
{<br />
motor[motorD]= dValue;<br />
motor[motorE]= dValue;<br />
// Run while NXT buttons not pressed<br />
// If the ultrasonic sensor value is greater than<br />
or equal to the threshold, set motor power<br />
to dValue<br />
}<br />
sonarValue = SensorValue(SonarSensor);<br />
nxtDisplayTextLine(2, "Sonar Value: %d", sonarValue);<br />
nxtDisplayCenteredTextLine(4, "No object");<br />
nxtDisplayCenteredTextLine(5, "detected.");<br />
else<br />
{<br />
motor[motorD]= tValue;<br />
motor[motorE]= (tValue*-1);<br />
// Update sonarValue variable with current<br />
sensor value<br />
// If the value is less than the threshold,<br />
turn the robot<br />
nxtDisplayCenteredTextLine(4, "Object detected!");<br />
nxtDisplayCenteredTextLine(5, "Turning...");<br />
wait1Msec(1700);<br />
}<br />
}<br />
}<br />
// Turning duration<br />
32
<strong>Tank</strong> <strong>Tread</strong><br />
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong> Reference Guide<br />
Expectations<br />
Technology:<br />
• Develop an understanding of the core concepts of<br />
technology.<br />
• Develop and produce a product or system using a<br />
design process.<br />
• Develop an understanding of the engineering<br />
design process.<br />
Science:<br />
• Implement a proposed solution.<br />
Mathematics:<br />
• Understand measurable attributes of objects and the<br />
units, systems, and processes of measurement.<br />
Engineering:<br />
• Redesign what has been created.<br />
• Test and evaluate.<br />
Classroom Organization and Setup<br />
1. Set up a projector with a computer to show the <strong>Tank</strong> <strong>Tread</strong> <strong>Extension</strong> - How It Should Work video.<br />
2. Provide a copy of the Engineering Journal worksheet for each student.<br />
3. Ensure that the NXT Brick and TETRIX ® batteries have been adequately charged. Consult page 55 of the Lesson 2:<br />
Ranger Bot Movement Reference Guide for more detailed information.<br />
4. Obtain various objects to use as obstacles for the robot. The ultrasonic sensor detects objects with a flat surface much<br />
more effectively than those with a curved surface, so obstacles with flat surfaces are recommended. A wall can also be<br />
used as an obstacle for this activity.<br />
Lesson Progression<br />
1. Review the tasks and concepts from Lessons 1-3 of the TETRIX Getting Started Guide.<br />
2. Watch the <strong>Tank</strong> <strong>Tread</strong> <strong>Extension</strong> - How It Should Work video.<br />
3. Follow the <strong>Tank</strong> <strong>Tread</strong> <strong>Extension</strong> Building Guide to create the <strong>Tank</strong> robot.<br />
4. Download the <strong>Tank</strong> <strong>Tread</strong> sample program or create the program by following the <strong>Tank</strong> <strong>Tread</strong> Programming Guide.<br />
Note: For more information about how to do this, watch the Program Deployment video or consult the Program Deployment<br />
Programming Guide from Lesson 3.<br />
5. Follow the <strong>Tank</strong> <strong>Tread</strong> Programming Guide to have the robot move forward until it detects an object, at which point it turns<br />
around and repeats the process until a button on the NXT is pressed.<br />
6. Test the program and compare it to the way the robot behaved in the How It Should Work video.<br />
Frequently Asked Questions<br />
Q: Is it possible to view the sensor values while debugging programs?<br />
A: The sensor values can be viewed on the screen of the NXT Brick. The sensor values can also be viewed in LabVIEW for<br />
<strong>LEGO</strong> ® MINDSTORMS ® or ROBOTC ® if the robot is connected to the computer.<br />
Q: Why is a False Boolean constant not used as the stop condition for the main loop?<br />
A: By using the Read NXT Buttons function, we can safely stop the robot from executing the code and properly shut down the<br />
motors by pressing a button on the NXT Brick.<br />
Q: Why does the robot turn too close to or too far from the obstacle?<br />
A: The threshold value for the ultrasonic sensor may need to be adjusted in order for the robot to turn at the desired distance<br />
form an object. Different sensors and robots may require slightly different values for the threshold.<br />
33
TETRIX ® Add-On <strong>Extension</strong>s<br />
<strong>Tank</strong> <strong>Tread</strong><br />
<strong>Tank</strong> <strong>Tread</strong> Reference Guide<br />
Innovation and Inspiration<br />
Suggestion #1: “How does the tank tread affect how the robot turns?”<br />
• Measure and record the robot’s turning radius with the tank tread and with wheels. Do several tests with the motor power<br />
set to different values.<br />
• Discuss the differences and determine reasons for these differences.<br />
Suggestion #2: “How does the location of the motors affect the axis around which the robot turns?”<br />
• Try shifting the position of the motors on the robots.<br />
• Discuss how this affects the centre axis of the turn.<br />
• Discuss the differences between the turning axes in the tank tread robot vs the Ranger bot.<br />
Suggestion #3: “Towing challenge”<br />
• Stage a competition to pull different weights with the robot.<br />
• Try pulling weights on different surfaces.<br />
• If the rubber inserts are available for the tread, try pulling weights with or without the inserts.<br />
• Investigate ways to modify the weights to allow them to be pulled more easily. What happens if the weights are placed on<br />
a piece of paper and the piece of paper is firmly attached to the back of a robot?<br />
• Discuss which configuration allowed the robot to pull more weight. Why is this?<br />
34