Download presentation
Presentation is loading. Please wait.
Published byJonas Tyre Modified over 9 years ago
1
1 North Alabama Robotics Team Monkey Madness FLL Intro Programming Workshop 2012 Kim Daugherty bongju328@gmail.com256-955-9521
2
2 Goals Present NXT-G programming concepts that you can teach your FLL team Conduct a hands-on NXT workshop to facilitate learning Provide tips and strategies that have been learned through trial and error over five years
3
3 Agenda Introductions Our motivation NXT introduction Basic movement Sensors Control flow (loops and switches) Debugging
4
4 Our Motivation To help Alabama FLL teams be competitive at the national (US Open) and international level (World Festival) Robot design is typically not an obstacle for teams – programming is… Teams can design robust software if they are given a few tips… To help teams have a great FLL experience so they consider continuing into FTC/FRC
5
5 NXT Introduction Programming window Version checking NXT brick basics
6
6 Start a New Program 1. Enter “MoveTest” TIP: Use descriptive program names written in mixed case 2. Click on Go to open program
7
7 Programming Window 1 of 2 Common palette Move Record/play Sound Display Wait Loop Switch TIP: The common palette is usually sufficient for basic navigation
8
8 Programming Window 2 of 2 Complete palette Common Action Sensor Flow Data Advanced TIP: The complete palette contains advanced commands Move Record/play Sound Display Wait Loop Switch
9
9 Comment and Pan Tools Comment tool allows you to add documentation TIP: Document your program so you can remember what it does Pan tool allows you move the screen around Pointer tool allows you to select and insert blocks
10
10 NXT Version Number New Program V2.1.f3 Patch f3 located at http://education.lego.com/en-gb/preschool-and-school/secondary- 11-18/11plus-lego-mindstorms-education/downloads/ Help->About TIP: Patch f3 reportedly fixes the Error 1003 Broken Wire problem in NXT 2.x
11
11 Firmware Version Number Tools>Update NXT Firmware… Version 1.31 is the latest TIP: Check the NXT firmware on the brick by going to Settings->NXT Version
12
12 Before We Start The NXT Outputs for Motors/Lights (A,B,C) Inputs for Sensors (1,2,3,4) Buttons (Enter, Back, Left, Right) USB port Motors Middle (A), Left (B), Right (C) Sensors Light sensor (1), touch sensor (3), color sensor, ultrasonic sensor, rotation sensor BC A 1 – Light 3 – Touch
13
Practice Robot 13 Robot instructions obtained from Oregon Robotics Tournament and Outreach Program (ORTOP) http://www.ortop.org/Workshops/index2011.html Horizontal mount points High torque for lifting (small gear connected to large gear) Two light sensors Caster wheel Good balance and weight distribution over drive wheels Low center of gravity for stability
14
14 Name Your Robot This button brings up the NXT window This is where you name the brick This tab allows you to delete files from the brick TIP: You can delete sound files and demo programs to free up space on the NXT Connect robot to laptop using USB cable
15
15 Basic Movement The easiest way to get around is the Move block This is the block you will use the most
16
16 Most Basic Command 1. Click here and drag a Move block to the Start area Speed control Degrees OR rotations should be used; rarely use seconds It is usually better to brake than coast Steering control TIP: Get familiar with all aspects of the Move command Motor selection 2. Click here to download the program to the brick Direction control BC A 1 – Light 3 – Touch
17
17 Run the Program First menu is “My Files” Select with orange button Second menu is “Software Files” Select with orange button Use arrow keys to find “MoveTest” Select with orange button Press orange button to Run BC A 1 – Light 3 – Touch
18
Two Ways to Turn Use slider bar on steering control Middle position means robot will go straight The further the slider is from the middle (but not all the way to one side), the sharper the curve will be (swing turn) If the slider is all the way to one side, the robot will turn in place by turning one wheel forward and the other backward Make sure motors on steering control set to B and C Move one wheel only Click on either port B or C, but not both Only one wheel will turn; this is a pivot turn 18 TIP: Pivot turns are the most precise, but swing turns are faster BC A 1 – Light 3 – Touch
19
19 Experiment with Move Write a program to: Move forward 100% speed for 2 rotations Make a right pivot turn at 75% speed (hint 390 deg) Move backward 50% speed for 360 degrees Make a left swing turn at 75% speed for 1 second Turn in place clockwise all the way around at 25% speed (hint 800 deg) Move forward 100% speed for 1 rotation Observations? What could improve repeatability and accuracy? BC A 1 – Light 3 – Touch
20
20 Wait Block TIP: Waiting a short time after each move improves repeatability and accuracy BC A 1 – Light 3 – Touch 1. Click here, select 1 st block (time), and drag after Move block 2. Enter 0.25 seconds 3. Repeat until 5 Wait blocks have been added
21
21 Help Screen Move cursor over block to get short description in this window TIP: Access help for selected block by clicking on “More help” on NXT right bottom Click here to get detailed help screen
22
For Improved Navigation Use Wait blocks after Move blocks to allow robot motion to completely stop Start in the same position in base each time; it is common to have the robot bumper pressed again the wall 1 Use pivot turns instead of swing turns Don’t exceed 50% power when turning 22 1 In previous years, FLL mat is centered East West and flush with South wall; distance between East or West wall and mat can vary on different tables
23
Sensors Allows the robot to feel (touch), see (light), hear (sound), and measure distance (ultrasonic) Are often used to determine when to stop moving 23 TIP: Light and touch sensors are more useful in FLL than ultrasonic and sound BC A 1 – Light 3 – Touch
24
24 Developing an algorithm An algorithm is a step-by-step logical sequence Example: Move forward until robot runs into wall Step 1: Turn on motors 100% speed Step 2: Wait until touch sensor is pressed Step 3: Turn off motors TIP: It is a good idea to write an algorithm before you start writing the program BC A 1 – Light 3 – Touch
25
Touch Sensor 25 BC A 1 – Light 3 – Touch 2. Click here and drag a Move block to the Start area 1. Click here to start a new program 3. Select Unlimited for Duration of Move 4. Click here, select 2 nd block (touch), and drag next to Move block 5. Change port to 3 8. Save program and name it TouchTest 9. Click here to download the program to the brick 6. Click here and drag a Move block next to Wait block 7. Select Stop for direction TIP: Be sure to stop the motors after a Wait block
26
26 Experiment with Touch Write a program to: Move forward 100% speed until robot touches wall Move backwards 50% speed for 2 rotations Make a right turn at 50% speed (Hint 390 deg) Move forward 100% speed until robot touches wall Move backwards 50% speed for 2 rotations Make a right turn at 50% speed (Hint 390 deg) Move forward 100% speed until robot touches wall Move backwards 50% speed for 2 rotations Make a right turn at 50% speed (Hint 390 deg) Observations? BC A 1 – Light 3 – Touch
27
Questions? Did you use copy and paste? Did you remember to add waits after each move command? 27
28
One Way to Do It 28 Repeat these blocks 3 times BC A 1 – Light 3 – Touch TIP: Copy and paste can save you a lot of time Move forward 100% speed unlimited Move backwards 50% speed for 2 rotations Right pivot turn 50% speed for 390 degrees
29
The Loop Block (1 of 2) 29 BC A 1 – Light 3 – Touch 1. Click here and drag a Move block next to Wait block 2. Set Control to Count and set Count to 3 TIP: The Loop block allows you to repeat commands 3. Make sure Counter is not checked
30
The Loop Block (2 of 2) 30 BC A 1 – Light 3 – Touch 1. Click and drag these blocks inside the Loop block 2. Delete the remaining 12 blocks TIP: Wait for the Loop block to expand before you let go of the blocks 3. Save, download, and run TouchTest
31
Reusing Blocks You may have a specific block or a sequence of blocks that you want to repeat many times in the program Wait time block a) Move unlimited block followed by b) Wait sensor block followed by c) Move stop block followed by d) Wait time block One or more blocks can be captured in a MyBlock which can be reused 31
32
Create MyBlock (1 of 4) 32 BC A 1 – Light 3 – Touch TIP: Use mixed case and name MyBlock something descriptive 1. Select Wait block and then click on Create My Block 2. Name block WaitTimeBlock and click Finish
33
Create MyBlock (2 of 4) 33 BC A 1 – Light 3 – Touch TIP: When you edit a MyBlock, save it and download the main program 1. Select Custom palette 3. Select WaitTimeBlock and drag to previous locations of Wait blocks 2. Delete these Wait blocks 4. You can edit the MyBlock by double clicking on it
34
Why is this Better? Change the wait from.25 seconds to 1.0 seconds; you only need to change it in the MyBlock instead of changing every Wait block Don’t download the MyBlock; download the program that uses the MyBlock 34
35
Create MyBlock (3 of 4) 35 BC A 1 – Light 3 – Touch TIP: When selecting blocks in a Loop, click outside the loop then drag 1. Select first four blocks and then click on Create My Block 2. Name block MoveTouchBlock and click Finish
36
Create MyBlock (4 of 4) 36 BC A 1 – Light 3 – Touch TIP: There is no way to remove the space without redoing the Loop block
37
You Now Have Two MyBlocks WaitTimeBlock Wait a specified time MoveTouchBlock a) Move unlimited block b) Wait for touch sensor block c) Move stop block d) WaitTimeBlock 37 TIP: MyBlocks are useful for reusing specific blocks or sequences of blocks
38
Light Sensors 38 Optimum height above mat is between ¼ and 1 inch; too low saturates sensor and too high gets poor reading of reflected light Left light sensor connected to port 1 TIP: Light sensors should be calibrated and shielded from ambient light Turn on robot Use arrow keys to move to “View” Select with orange button User arrow keys to find “Reflected Light” Select with orange button Use arrow keys to find “Port 1” Select with orange button Read different areas of the mat – values will be 0 to 100
39
Light Sensor Readings Percent Mode: 5% = lowest dark, 100% = very bright Reflected Light Mode: shines a red light The light can be turned off – detecting ambient light (surrounding light) 39 TIP: The light sensor reads reflected light over an area determined by its height
40
Simple Line Following Does not actually follow the line… Then what does it follow? HINT: Line following would NOT work well on a very thin line 40
41
41 Another Algorithm Follows Left Edge of Line Two states: Left of desired position, Right of desired position Determine state to control robot movement If Sensor1 > Boundary (Left) Set Motor B to 60 Stop Motor C If Sensor1 < Boundary (Right) Set Motor C to 60 Stop Motor B BC 1 – Light 3 – Touch TIP: It is a good idea to write an algorithm before you start writing the program
42
Line Following 42 TIP: Make sure to set motor ports correctly when line following 2. Click and drag Loop block 3. Click Switch block and put into Loop 4. Select Control to be Sensor and Sensor to be Light Sensor 5. Make sure Port is 1 5. Add Move blocks 1. Start new program and name it LineFollow
43
Experiment with Line Following Write a program to: Test line following at 60 percent speed Test line following at 40 percent speed Test line following at 100 percent speed Observations? 43
44
Line Following Observations Faster line following makes large swerves back and forth and can lose the line Slower line following is smoother It is good to have a strategy to end line following 44
45
End Line Following 45 TIP: Use the rotation sensor to stop line following after a specified distance 1. Click on Loop block 2. Select Control to be Sensor and Sensor to be Rotation Sensor 3. Make sure Port is B 4. Set Until to be > 500 degrees
46
Put it All Together Use Line Following, WaitTimeBlock, and MoveTouchBlock to navigate robot from start of line to target area 46
47
A Possible Solution (1 of 2) Line follow for 1150 degrees at 60% speed WaitTimeBlock Right pivot turn at 50% speed for 390 degrees WaitTimeBlock MoveTouchBlock Move backward 50% speed for 1 rotation WaitTimeBlock Left pivot turn at 50% speed for 390 degrees WaitTimeBlock MoveTouchBlock 47
48
A Possible Solution (2 of 2) 48
49
Resources usfirst.org/roboticsprograms/fll – Official FLL site www.alabamafll.com – Official Alabama FLL site www.alabamafll.com www.nxtprograms.com – NXT designs (not all robots) and sample programs www.nxtprograms.com www.techbrick.com – Coaching tips and challenge worksheets www.techbrick.com www.forums.usfirst.org/forumdisplay.php?f=24 – Get help from the FLL community; must register to post www.forums.usfirst.org/forumdisplay.php?f=24 www.teammonkeymadness.com – Our team site www.teammonkeymadness.com www.ortop.org/Workshops/index2011.html – Coaches workshop materials www.ortop.org/NXT_Tutorial/index.html – Online NXT tutorial www.ortop.org/NXT_Tutorial/index.html www.education.rec.ri.cmu.edu/content/lego/curriculum/index.htm – Carnegie Mellon Robotics Academy www.education.rec.ri.cmu.edu/content/lego/curriculum/index.htm www.hightechkids.org/for-teams/coaches-library – Coaches materials www.hightechkids.org/for-teams/coaches-library http://www.legoeducation.us/eng/characteristics/ProductLine~LEGO%20Mind storms%20Education – NXT Education Base set and Resource set http://www.legoeducation.us/eng/characteristics/ProductLine~LEGO%20Mind storms%20Education 49 TIP: Be positive and always set a good example for your team
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.