Home
NXT-G Programming Workshop for FLL Coaches
Contents
1. Program BLOCK pp a programming i instruction for the Brick controller used to robot download programs to ete ee 24 seaen the NXT brick Palette selector 08 31 12 Basic Programming Tony Ayad LEGO MINDSTORMS NXT Interface IA LEGO MINDSTORMS NXT g a OO Eile Edit Tools Help Comment tool allows you to create new Pointer tool to select objects by ow Pan tool to move the comment boxes BUGS gia EEE display You can also use Use these to describe he left or right arrows what the robot is o move the display doing on the field for each step of the program r i ooo 08 31 12 Basic Programming Tony Ayad Steps to add a Programming Block 1 Click and hold block with left mouse button to drag it 2 Drag the block to place it on the sequence beam Start 3 When you see the white bar release the mouse this is the location for placing the block 4 Update the options of the selected block in its control panel LE Pot Oa Me Me Bi Power Dy i 75 SB Steering lp e e te Net Acton pl Brake Be Coast e E A Control Panel io 08 31 12 Basic Programming Tony Ay
2. The arm is used to manipulate objects For FIRST LEGO League the NXT robot eys use the A port usually has two Motors to control the movement of the robot e Move Forward or Backwards mostly using the MOVE block e Turn Left or Right using either the left or right motors always use the MOTOR block e Spin Left or Right using both motors which are moving in opposite direction always use the MOTOR block e The Arm is usually the third motor which is used to manipulate mission models by scooping pushing pulling or turning actions 08 31 12 Basic Programming Tony Ayad 12 NXT Motors and control BLOCKS e NXT Motors have a built in rotation sensors that continuously measure and monitor the number of degrees rotations while it is moving forward or backwards e You can manipulate the motors using the MOTOR MOVE and ROTATION SENSOR Blocks MOTOR BLOCK e Controls one motor e No Synchronization e No Acceleration 08 31 12 MOVE BLOCK Controls 2 motors Synchronize motor movement to ensure robot moves straight Automatically corrects errors Applies power gradually accelerate Slows down decelerate Basic Programming Tony Ayad ROTATION SENSOR BLOCK e Counts the number of motor degrees one full rotation is 360 degrees that your motor turns e Used to reset the rotation counter to O The MOVE Block explained Port Select motors to Duration used
3. e The MOVE block has several data hubs that correspond to its input fields e Data wires connect data hubs you create a data wire by drawing it out of a block s data hub rey CB Jes Data Wire 08 31 12 Advanced Programming Tony Ayad fal Riel Right Motor ral ue Other Motor a fe Duration degrees a e Next Action brake or coast 38 Variable Math Blocks Examples e Earlier we learned that for each inch of robot movement 50 motor degrees are required In this example we will make the robot move 12 inches convert the inches into motor degrees LE Pot Oa We He SB Power BE nf 75 Wp Acton O S Read 5 Gy Write ED Steering Ge TF e he Next Action Bll Brake O Bb Coast al Vale HE E s 4 y Mowe Block that uses inches instead of Degrees The robot s wheel circumference is 2 28 3 14 of 7 16 inches In order to move 1 inch the motor degrees ts 50 360 7 16 The result is available through this output hub Set Inches Input the Hal T tol Inches value into math block Multiply the input Wi The value is supplied to the duration input hub i 1 ee inches X 50 Advanced Programming Tony Ayad 39 08 31 12 5 Now for the best part of NXT G My Block In the previous example we programmed the robot to move forward 12 inches what if we wanted to use thi
4. forumdisplay php f 24 e The questions should be generic and not specific to strategy 08 31 12 Basic Programming Tony Ayad 24 Tips e For moving straight the MOVE block has a built in PID Proportional Integral Derivative controller to synchronize the movement of B amp C motors If one motor falls behind the MOVE block compensates by applying more power to that motor The MOVE block is ideal for moving the robot straight e For driving the robot use the B amp C motor ports the A port should be used for the robot s arm Using full motor power 100 may cause erratic robot movement use 75 or less Conversely too little power below 25 may cause the robot to stall Brake at the end of each MOVE block to take advantage of the PID which self corrects to achieve more precise moves e Using Degrees is a more accurate way to move motors using time will be inconsistent when the batteries become weak e The MOVE block also keeps track of errors that accumulate in multiple blocks and adjusts itself e Use the brake option and also use the RESET block e REMEMBER the tradeoff between speed and accuracy Watch battery voltage If you are using the rechargeable Lithium Ion battery stop programming and recharge it when the it falls below 7 8 volts the highest voltage is 8 3 e If you use Alkaline batteries replace them at 7 8 volts their highest voltage is 9 4 08 31 12 Basic Programming Tony Ay
5. sensor over the darkest spot on the mat e g black line and you ll notice the Min Value changes Press the enter key to select the Min Value which is the darkest spot on the mat e Then move the sensor over the brightest spot white area on the mat and press the enter button to capture the Max Value which is the brightest spot on the mat If you use 2 light sensors you do not need to calibrate both The calibration will apply to all light sensors attached to the NXT 08 31 12 Advanced Programming Tony Ayad 29 Installing the Light Sensor Calibration Program B LEGO MINDSTORMS NXT e Ensure that the robot is connected to the PC e In the Mindstorms Software select Tools E then Calibrate Sensors e Select Light Sensor and choose the port number to which the light sensor is connected in the example to the right it is port 3 e Press the Calibrate button to download the Calibrate program into the NXT brick e After the program is downloaded it will run see previous slide 08 31 12 Advanced Programming Tony Ayad 30 WAIT for light value block e The WAIT block keeps checking for the specified light value and when the condition is met the next step in the program continues Port identify the NXT port where the light sensor is connected w Control ar el Sensor gag j F DW j Ont ara Enter value you would like to test Sel
6. Brick e Up to 3 motors two for moving the third is for the arm e Any number of LEGO manufactured MINDSTORMS type sensors touch light color rotation or ultrasonic However you only have 4 sensor ports on the NXT e You can use as many non electric LEGO pieces as you need e You may NOT use ANYTHING that is not made by LEGO e Instructing the robot to move and turn is accomplished by the NXT Motors which rotate in a predetermined direction Allexamples used in this document assume the robot Clockwise configuration with motors mounted as shown N B Motor C Motor 08 31 12 Basic Programming Tony Ayad LEGO MINDSTORMS Education NXT Software e The FLL Robot Set includes the LEGO MINDSTORMS Education NXT Software e The current NXT G software version is V 2 1 6 e This icon based easy to use software is based on LabVIEW e LabVIEW is powerful system design software for engineering and science e The Education version includes Robot Educator step by step guide e 46 tutorials from beginner to advanced levels e The Education version also includes data logging functionality e Collect and analyze data from sensors e Includes comprehensive digital user manual e Includes team license 08 31 12 Basic Programming Tony Ayad Programming the NXT Robot e NXT software uses different programming BLOCKS Lz Here are some of the most commonly used blocks O Programming Block Itis a specific step or action the robo
7. NXT G Programming Workshop for FLL Coaches Developed by Tony Ayad Updated by LeRoy Nelson California Los Angeles Region FLL September 2012 Outline e Purpose e This workshop is intended for FIRST LEGO League FLL coaches who are interested in learning about LEGO MINDSTORMS NXT and the NXT G programming language e Basic Programming Agenda Introductory Workshop NXT Controller aka the brick Blocks The NXT G Interface The MOVE MOTOR amp RESET Blocks Turns there is more than one way to turn Geometry and Math for the Robot Resources e Advanced Programming for Advanced Workshop e Light Sensors e Program Control WAIT LOOP SWITCH Blocks e Math VARIABLES MATH and COMPARE Blocks e My Block e Touch Sensors 08 31 12 Basic Programming Tony Ayad NXT Controller The robot s brain The USB port is used to connect to a ka the Brick The PC so you can download the Programs into NXT Controller 3 Output ports used for the motors Icons representing menu options Use this button to turn on the NXT and select the shown option SELECT menu option right SELECT menu option left 4 Menu Level Back off I MXT 4 sensor Input ports used to attach sensors i ee 08 31 12 Light Sensor Basic Programming Tony Ayad Touch Sensor FLL Robot Configuration e For FLL Competition you are allowed e 1 NXT Brick or the discontinued RCX yellow
8. ad 25 Finally the NXT Programming Resources e The most popular NXT programming tutorial http www ortop org NXT Tutorial e Several other excellent NXT Programming tutorials are available on FLL Team Resources http www firstlegoleague org challenge teamresources e Good books on NXT programming are available for beginners and more advanced e Laurens Valk The LEGO MINDSTORMS NXT 2 0 Discovery Book A Beginner s Guide to Building and Programming Robots San Francisco No Starch Press 2010 e James Floyd Kelly LEGO Mindstorms NXT G Programming Guide 2nd ed Berkeley CA Apress 2010 e Download great worksheets for planning missions http www techbrick com e FLL Forum where you can find answers to your questions from other coaches http forums usfirst org forumdisplay php f 24 e Update the NXT firmware to the latest version currently 1 31 http mindstorms leqo com en us support files Firmware aspx e Purchase or sell extra LEGO pieces www bricklink com 08 31 12 Basic Programming Tony Ayad 26 Advanced Programming Why light sensors One of the ways for the robot to know its location is to take advantage of the markings on the field mat Every year the Robot Game s mat has lines or dark markings that can be detected by the light sensor In this section we will cover the following e How do light sensors work e How to calibrate lights sensors e How to install the light sensor calibration program Commonly used Pr
9. ad 9 Your First Program Te o RE xu l F LEGO MINDSTORMS Education NXT Programming Som L File Edit Tools Help EEC EEE DS eee ee ee tec x Wi Click on the new program icon Drag and drop MOVE block on the sequence beam Enter the MOVE block options Click on the download button and wait for the beep On the NXT press the Orange butt e My Files e Software Files e Untitled 1 e Press the orange button twice to run nah Move the cursor over an object to read about its function For sew Duration additional help click the More help link More help ep B Er Net Acton bl Brake BB Coast 08 31 12 Basic Programming Tony Ayad 10 Where are the programs stored a Documents e Once you install the Mindstorms software a it will create a Lego Creations _ gt E di LEGO Creations and other subdirectories in your do Addin Documents Folder as shown J Building Instructions E d MINDSTORMS Projects All the programs will be created in the El Profiles Default Folder E S Defaut El Blocks All My Blocks will be created in the My Blocks My Blocks folder Web Blocks e Save programs with descriptive names e Backup all your programs at the end of each session e Use the Print command to print copies of your best programs to show the Judges at tournaments 08 31 12 Basic Programming Tony Ayad 11 Robot Actions
10. ation 7 inches A 08 31 12 Basic Programming Tony Ayad 22 Measuring turn travel distance More Geometry e When the robot turns using one motor it will make a circle whose Radius is the distance between the wheels In this case the radius is 5 5 inches Circumference mXC 2XnNXR 2 X 3 14 x 5 5 34 5 inches 2 2 inches SS Renee la d If the robot is using the wheel whose diameter is 2 2 inches and therefore its circumference is 7 inches how many wheel rotations will it take to make a complete robot turn rotation 34 5 inches Circumference of Robot Turn Circle Diameter Xm 11X x14 49 Circumference of Robot s Wheel 7 Diameter XM 2 2 x 314 Note it takes 4 9 wheel rotations to make a complete 360 turn or 4 9 motor degrees to travel 1 degree of turn circle e Example to make a 90 robot turn e Motor Degrees 90 X 4 9 441 Motor Degrees 08 31 12 Basic Programming Tony Ayad 23 Programming Process e Analysis and Planning Steps e Define the problem e Brainstorm solutions and select one e KEEP IT SIMPLE e Plan and create a flowchart and take measurements e Programming suggestions e Divide the program into small steps e Program one step at a time e Example Move the robot to black line e Once the step is consistently repeatable go to the next step e Whenever possible reuse repeatable combinations of blocks using MY BLOCK Ask for help e http forums usfirst org
11. ect gt greater than or lt less than If you check the Generate Light Example if you select lt and entered 50 and checkbox the light sensor will the light sensor encounters a black block the turn on its own small light source result will be the test is True use it always FLL teams sometimes design Robots with light sensors to detect amp dark blocks on the mat or for following a line 08 31 12 Advanced Programming Tony Ayad 31 Wait Block Examples Exam ple 1 Wait until Light Move until the robot detects a black dark line and stop Move sensor value is Unlimited less than 50 fee aia Ww 4 Example 2 Align the robot with a black line Wart until Light Move B Walit until Light Stop C Move sensor value is Unlimited sensor value is Unlimited less than 50 This program assumes the left light sensor will reach the black line first The comment for step 3 should say Stop B and C The comment for step 4 should say Move C Unlimited C is the right motor Both light sensors should end up near the edge of the black line 08 31 12 Advanced Programming Tony Ayad 32 Advanced Blocks and Example e To create a line follower program you will need to use the light sensor and repeatedly check the light value and adjust the robot s position LOOP Block e COMPARE Block Line follower examples Additional B
12. he B reading is motor rotation gt 50 eg Read the B moter rotation sensor sensor to 0 on white and if it exceeds 1200 end the loop Ol wi aaa ie Light sensor O Go reading is iz FET on black C Power 50 L Por OA Ge Oc Z Unt Ou tue X Fake LE Por A e Oc We Action O e Read D d Reset or ty Action D er Read Reset gt f Show ONES Counter 515 Compare faj T gt m E Hp Compare i T L z o Dewees Ea Operation 360 Degrees J LE Port Ci Mz oE Da 2 E 12 BBY comiare 0 T Ligh s JP Funcion D AE Generate light 08 31 12 Advanced Programming Tony Ayad 52 Challenges e What is the fastest way to follow the line to the T end e A move My Block that can move forward or back at a different power level e Simultaneously move and raise or lower the arm e A My Block that moves a certain number of inches as input e A My Block to turns left using turn angle degrees as input 08 31 12 Advanced Programming Tony Ayad 53
13. is pressed E come c Oe O 02 Os Os 2 eee Se ea 3 Sree 08 31 12 Advanced Programming Tony Ayad 48 Sensors Light Sensor Block This sensor detects ambient Surrounding light For example you might program your robot to move forward and stop whenever the light level falls below 50 Touch Sensor Block This block checks a touch sensor s condition pressed released or bumped at a specific point in the program It sends out its finding as a logic signal true or false through a data wire Rotation Sensor Block This block counts the number of degrees one full rotation is 8360 degrees that your motor turns Through data wires this block can send out the current number of degrees to be used The rotation sensor can also be used to reset the rotation counter to 0 Advanced Programming Tony Ayad 49 08 31 12 TOUCH SENSOR block e The touch sensor is used to detect conditions to help the robot recognize its position and through programming take action The touch sensor recognizes these three conditions e Pressed pushed in and stays pushed in e Released not pushed in Bumped Pushed and then released Beware of using bumped condition within a loop it may happen so fast that your program may not catch it e Note Using this block and reading whether the action is met true or false will be covered in detail later Touch 1 Si Port identify the NXT port where Se
14. l if resistance is met LE Port A B c ts Control O MBA Motor Power je Direction Tr TY Dasr Unlimited Ae Acton sJ Wait es wee a Wait check the box so other blocks Action there are three options in the program can proceed while Constant power is consistent for the duration Ramp UP slowly increase speed until desired power is reached the motor completes its action Ramp Down slowly decrease speed until it reaches zero power 15 08 31 12 Basic Programming Tony Ayad ROTATION SENSOR block The NXT s motor has a built in rotation sensor counter that tracks the exact number of degrees as the motor spins The information is available through the ROTATION SENSOR block You can reset rotation sensor counter to zero or read the information in the rotation sensor counter Port identify the NXT port where the motor is connected Action you can either read the value of the sensor or reset it to zero Compare select arrow which identifies the direction that motor is spinning Note There is an advanced feature with the rotation sensor that allows you to compare the degrees or rotation to a specified value and provide a True or False response This will be covered in the advanced workshop 08 31 12 Basic Programming Tony Ayad More about Motors Accumulated Errors sI e As the motors move
15. locks e VARIABLE MATH e COMPARE e Data Hubs 08 31 12 Advanced Programming Tony Ayad 33 The LOOP Block e Sometimes there are actions that you want to repeat The LOOP block allows you to repeat those actions until an end condition is met or becomes TRUE gt e Example make the robot move around a box and return to its starting position To move along the box sides it takes 8 blocks as follows Move along third wall Move along fourth wall Move along Turn Right Move along first wall Turn Right Turn Right Turn Right second Wall pag da Frown eer Using the LOOP block only eee Mi ala ll Turn Right o0 les love along wal Turn Right Loop Control Caw Ej wf Count Logi wa t Warning Deleting the LOOP block will also delete all the blocks within the loop You can move the blocks out of the loop then delete it 08 31 12 Advanced Programming Tony Ayad 34 SWITCH block e The SWITCH block will check for a condition and will take different action if the condition is true and another action if the condition is false The light sensor value is more than 50 Le tt sees white The left motor moves faster than right motor so the robot moves toward the black line If light Intensity i greater If light Intensity IS NOT greater than 50 The light sensor value is 50 or less Le it sees black The right motor moves faster
16. lockwise use the MOTOR blocks where the the C motor will turn counter clockwise and B motor will turn clockwise NY Forward S C Backward TIP for turning in a tight spot use the two motors 08 31 12 Basic Programming Tony Ayad 19 Turns Continued e To make 180 degree right turn using a single motor Start Position End Position e To make 180 degree right turn using two motors spin in place Start Position End Position P om We e Note that the distance travelled by the two wheels is shorter exactly half when using two motors 08 31 12 Basic Programming Tony Ayad 20 f Geometry and Math Fun way to see that what is learned in school can be applied to the FIRST LEGO League s robots Note it may be a stretch for younger teams that have not covered these concepts in school Circumference T X Diameter 08 31 12 Basic Programming Tony Ayad 21 Inches to Motor Degrees e The Circumference of the robot s wheel determines the number of inches it will travel in 1 rotation e Circumference of wheel mx Diameter e Degrees traveled per inch 360 circumference of wheel 3 2 inches e Circumference of wheel mx Diameter 3 14 x 3 2 10 0 inches e Degrees traveled per inch 360 10 0 36 motor degrees 1 Rotation 10 inches e Circumference of wheel mx Diameter 3 14 x 2 2 6 9 inches e Degrees traveled per inch 360 6 9 52 motor degrees ERN z N 1 Rot
17. nsor r i k the touch sensor is connected i Released 5 8 Bumped Action select the desired action pressed released or bumped _ FLL teams sometimes design Robots with touch sensors to detect if the robot hits an object e g wall then stop This is a common way to align the robot with one of the table s walls 08 31 12 Advanced Programming Tony Ayad 50 LIGHT SENSOR block e The LIGHT SENSOR block is used to READ the detected light intensity level i e dark or bright Port identify the NXT port where the light sensor is connected Enter value you would like to test Select gt greater than or lt less than Example if you select lt and entered 50 and the light sensor encounters a black block the result will be the test is True If you check the Generate Light checkbox the light sensor will turn on its own small light source use it always Advanced Programming Tony Ayad 51 08 31 12 Advanced Line Follower Example e The COMPARE block can determine if a number is greater than gt less than lt or equal to another number Similar to the MATH block the input A and B values can be typed in or supplied by data wires e Example You are using a light sensor and want to follow a black line for 1200 degrees Loop until the rotation sensor of B motor reaches 1200 degrees Light sensor CPower 10 B Power 50 Reset t
18. ogram they can t tell which way the robot is turning if you are only using MOTOR block Solution create a Turn Left My Block to make it easy to understand the program e Example 3 One you ve fine tuned a perfect 90 degree turn you can create your own My Blocks for the perfect 90 degree left and right turns 08 31 12 Advanced Programming Tony Ayad 42 My Block Example Moving Forward using inches e Objective OY i e Build a move My Block that takes oy fie one input called duration which represents the number of inches IE LEGO MINDSTORMS Education File Tools Help 1 Select the Math amp Move block ut Ctrl Copy Ctrl C Paste Ctrl V 2 Select Edit and Make A New My Bloc Nake Alvewe iy Block Manage Custom Palette Manage Profiles Define Variables Define Constants 08 31 12 Advanced Programming Tony Ayad 43 _ BJ LEGO MINDSTORMS Education NXT Programm Using My Block File Edit Tools Help HAJO eo e Once you ve created My Block it will become available on the custom pallet 1 Select the custom pallet 2 Move the mouse over the top My Blocks icon 3 Drag and drop the My Block named MBMove into the program e When you click on the My Block MBMove youll see its control with the input value named inches You can enter the value into this field 08 31 12 Advanced Programming Tony Ayad 44 More My Block Examples e Reset e Move Forwa
19. ogramming Examples Move until a dark line is encountered by the robot e Align the robot with a black line Follow a line 08 31 12 Advanced Programming Tony Ayad 27 Light Sensors F e The LIGHT SENSOR shines a light on the mat and reads the reflected brightness level intensity level i e dark or bright to help the robot recognize its position and through programming take action e The light sensor doesn t see colors it only sees level of brightness or intensity e Light intensity ranges from 0 100 On a bright white area of the mat the light intensity value will be above 50 e On darker area blue black green the light intensity value will be below 50 Black Violet Dark Blue Dark Red Brown To obtain more accurate readings make sure the light sensor is close to the mat less i than inch and shielded from bright external light sources like the sun e Calibrate the sensor whenever light conditions change see next slide 08 31 12 Advanced Programming Tony Ayad 28 Calibrate Sensor e The Calibrate program should be available on the NXT e To use it 1 Select My Files then Software Files 2 Navigate back and forth using the left or right arrows until you encounter the Calibrate program 3 Select the Calibrate program by pressing the orange button 4 Run the Calibrate program by pressing the orange button and follow the instructions e Once you see the menu move the
20. rd e Move Back e Turn Left e Turn Right e Spin Left e Spin Right e Curve Forward e Curve Back e Line Follower e Align Robot With Black Line e Square to Wall 08 31 12 Advanced Programming Tony Ayad 45 My Block Tips e Use My Block to break down a large program into two or more My Blocks If you create a My Block with one input and decided later to add another input you ll have to start over e If you create a My Block with two inputs and decided later to remove one you cannot delete the extra input either start over or ignore the extra input e You can rename a data port by double clicking its text label inside the My Block e The order of the inputs and outputs is unpredictable Do not use Save As to create new My Blocks instead use the file system to create a copy and edit that one If you move a My Block between computers the program that uses the My Block may not work 08 31 12 Advanced Programming Tony Ayad 46 Touch Sensor WAIT block for touch sensor and example e TOUCH SENSOR block LIGHT SENSOR block e ROTATION SENSOR block e The difference between WAIT blocks orange and SENSOR blocks yellow e Advance Line Follower My Block example using Rotation Sensor and compare block 08 31 12 Advanced Programming Tony Ayad Wait Block Touch Sensor example Wait for Touch Example stop when the touch sensor is pressed Wart until Touch Move Sensor on Port 3 Unlimited
21. s and specify different distances NXT G allows you to create your own block and it is called My Block 08 31 12 Advanced Programming Tony Ayad 40 What are the typical commands e NXT G blocks are hardware component focused MOVE MOTOR SENSOR etc e MyBlock allows the creation of meaningful actions such as Turn Left Spin Left Move Forward Arm Up Follow Line etc Command names should be self explanatory so any team member can understand and debug programs e Which program is easier to read 08 31 12 Advanced Programming Tony Ayad 41 My Block e My Block is a combination one or more blocks that are grouped into a single Block Once created it can be used in many programs My Block can be used in the following ways 1 Minimize the coding if certain actions are repeated in multiple programs Often you need to repeat certain steps for example different programs may require the robot to back into the wall to re orient itself This process can be placed into a My Block 2 Divide a program into smaller manageable pieces 3 Reduce the amount of memory used 4 Clarify the action taken in programs by creating self explanatory My Blocks e Example 1 your program already includes 22 MOVE MOTOR LOOP blocks and you re not finished It is time to consider breaking up the program into chunks i e My Blocks e Example 2 For turning left or right you use the MOTOR block When someone is reviewing the pr
22. t will perform Motor Program Control 08 31 12 Basic Programming Tony Ayad LEGO MINDSTORMS NXT Interface Program name Programming Palette menu E LEGO MINDSTORMS Education NXT Se gt eal al Each option has Eile Edt Tools Help a set of program zua a ALA ES E a blocks move the rr i mouse over it to ih Your Program You can add and see the available nie configure blocks to instruct actions blocks oo such as moving forward or turning on ah Sequence beam is where the blocks are placed and it is in the order in which they will be run
23. than left motor so the robot moves away from white Loop for 5 seconds EW Control LE Por OL OS 03 Control Tere Gl sem glg amp P comae E 0 IL zaak 0 Light l LJ 08 31 12 Advanced Programming Tony Ayad 35 Advanced Blocks VARIABLE block e The variable block is a bucket where you can store information and retrieve it at a later time e There are three types Number Text and Logic MATH block Inputs ai e The math block allows the addition subtraction pass a6 multiplication or division of two numbers through to outputs oY Output result result COMPARE block e The compare block allows you to determine if Inputs p one number is greater than less than or equal sans to another number through to outputs F Output result Output result True or False or False 08 31 12 Advanced Programming Tony Ayad 36 VARIABLES how to create your own variables e To create your own variables 1 Select Edit Menu and Define Variables option Ctrl V 2 Type the name of the variable then select its type _ F Edit Variables Manage Custom Palette Manage Profiles Define Variables Define Constants 08 31 12 Advanced Programming Tony Ayad 37 Data Hubs and Data Wires Data Hub is another way of providing input data into a Block e Most blocks have a tab at the bottom ni when clicked the block expands to show its data hubs
24. the rotation sensors of the motors keeps tracks the number of degrees between moves and makes corrections to correct accumulated error e Example 200 degrees 220 degrees 20 degrees 200 degrees 230 degrees 50 degrees 200 degrees 210 degrees 60 degrees 200 degrees 140 degrees 800 degrees 800 degrees 0 e Note that the fourth MOVE was adjusted by the NXT to correct the accumulated error e While this might be a helpful feature it often causes undesirable results in FLL programs 08 31 12 Basic Programming Tony Ayad 17 How to correct the accumulated error e First the Rotation Sensor block allows you to set the rotation counters to zero J A B DEt Port select the ports for which you would like to turn off the auto error correction Reset C Motor ResetB Motor Stop Automatic counters to 0 counters to 0 correction gt TIP use the RESET block before each move or motor block 08 31 12 Basic Programming Tony Ayad 18 Turn vs Spin e There are two ways in which you can make the robot turn e Make ONLY one motor move or e Using both motors moving in opposite direction and this is referred to as spinning e One Motor move NY Right e Right Turn Use motor block and select the B motor e In this case the robot s right wheel will be stationary and the brake left wheel will move C e Turning with two motors in opposite direction e To turn the robot right spin c
25. to specify the interval move These correspond to the ports on the NXT brick one rotation 360 degrees in Degrees time seconds or rotations Power Amount of power to use to control the motor The default is 75 Control Panel Direction Steering instructs the robot to apply more the direction power to one of the motors to control turns in which you NOTE This is useful for rotating the robot in want to turn place or when you wish to make tight the motor turns forward up or backwards down BEWARE that using steering may not be consistent at low power IT IS UNRELIABLE SO AVOID USING IT LJ A 7 B m Cc Ah Power S 75 l z of oF og Duration 360 Degrees tata i Mele c ili e hp Nest Action f Brake Be Coast Ia as oe y Next Action instructs the motor to either brake or coast at the end of the action NOTE brake will provide a more accurate travel distance while coast will cause motor robot to roll to a stop as the power is cut off and therefore overshoot the target 08 31 12 Basic Programming Tony Ayad 14 The MOTOR block e The MOTOR block controls a single motor with slightly different configuration options than the MOVE block e The MOTOR block is ideal for controlling the robot s arm and for controlled turns E f Power Increases power ort Select motor
Download Pdf Manuals
Related Search
Related Contents
Hayter Mowers 401C001001 Lawn Mower User Manual Metrix 4.5 User Manual Manuel d`utilisation Hypertec N17138NHY User's Manual NEC MultiSync EX231Wp User's Guide Model KX-TDA30/KX-TDA100/KX JTCー。ーー ー ー533 クランクシャフ ト固定レンチ取扱説明書 Copyright © All rights reserved.
Failed to retrieve file