arm and gripper programming guide (labview for · pdf file121 arm and gripper programming...

3
121 Arm and Gripper Programming Guide (LabVIEW for LEGO ® MINDSTORMS ® ) Introduction: In this guide, the Ranger Bot will be programmed to follow a line, pick up an object, and put it in a box. This guide is for use with the LabVIEW for LEGO ® MINDSTORMS ® programming language. Review: • To review the basic principles of connecting to the NXT Brick and configuring LabVIEW for LEGO MINDSTORMS for use with various sensors and motors, review the Programming Guides and Tutorial Videos from Lessons 2 and 3. •To review the basic principles of programming in LabVIEW for LEGO MINDSTORMS, review the Programming Guides and Tutorial Videos from the Line Follower Programming Extension. • These materials contain detailed information about how to use the Schematic Editor and how to create the structures, functions, constants, and wires that are presented in this guide. • This program makes use of the Screen Update SubVI, provided on the TETRIX ® Getting Started Guide DVD. This function uses the NXT to display custom text as well as light and ultrasonic sensor readings. • Use these steps to add the function to the program: a. Within the block diagram, right-click to bring up the Functions palette and choose Select a VI. b. Then navigate to where the Screen Update SubVI is saved. Note: If the Screen Update SubVI has not been saved on the computer in a specific location already, download it from the DVD by navigating to the Resources tab and selecting the Screen Update SubVI Program (LabVIEW for LEGO MINDSTORMS) button. c. Once the Screen Update SubVI has been located, open it and place it on the block diagram. Getting Started: 1. Create a new Ranger robot project and name it “Arm and Gripper.” 2. Using the Schematic Editor, configure the robot to have two TETRIX 180° Servo Motors attached to Servo Ports 1 and 2. The first servo will be called Gripper, the second servo will be called Arm. 3. Create a new VI. TETRIX ® Getting Started Guide Extensions

Upload: hatram

Post on 02-Feb-2018

229 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Arm and Gripper Programming Guide (LabVIEW for · PDF file121 Arm and Gripper Programming Guide (LabVIEW™ for LEGO® MINDSTORMS®) Introduction: Inhisuide, t g the Ranger Bot will

121

Arm and Gripper Programming Guide (LabVIEW™ for LEGO® MINDSTORMS®)

Introduction:

Inthisguide,theRangerBotwillbeprogrammedtofollowaline,pickupanobject,andputitinabox.ThisguideisforusewiththeLabVIEWforLEGO®MINDSTORMS®programminglanguage.

Review:

•To reviewthebasicprinciplesofconnectingtotheNXTBrickandconfiguringLabVIEWforLEGOMINDSTORMSforusewithvarioussensorsandmotors,reviewtheProgrammingGuidesandTutorialVideosfromLessons2and3.

•ToreviewthebasicprinciplesofprogramminginLabVIEWforLEGOMINDSTORMS,reviewtheProgrammingGuidesandTutorialVideosfromtheLineFollowerProgrammingExtension.

•ThesematerialscontaindetailedinformationabouthowtousetheSchematicEditorandhowtocreatethestructures,functions,constants,andwiresthatarepresentedinthisguide.

•ThisprogrammakesuseoftheScreen Update SubVI,providedontheTETRIX®GettingStartedGuideDVD.ThisfunctionusestheNXTtodisplaycustomtextaswellaslightandultrasonicsensorreadings.

•Usethesestepstoaddthefunctiontotheprogram:

a.Withintheblockdiagram,right-clicktobringuptheFunctionspaletteandchooseSelect a VI.

b.ThennavigatetowheretheScreen Update SubVIissaved.

Note:IftheScreenUpdateSubVIhasnotbeensavedonthecomputerinaspecificlocationalready,downloaditfromtheDVDbynavigatingtotheResourcestabandselectingtheScreen Update SubVI Program (LabVIEW for LEGO MINDSTORMS)button.

c.OncetheScreenUpdateSubVIhasbeenlocated,openitandplaceitontheblockdiagram.

Getting Started:

1.CreateanewRangerrobotprojectandnameit“Arm and Gripper.”

2.UsingtheSchematicEditor,configuretherobottohavetwoTETRIX180°ServoMotorsattachedtoServoPorts1and2.ThefirstservowillbecalledGripper,thesecondservowillbecalledArm.

3.CreateanewVI.

TETRIX®GettingStartedGuideExtensions

Page 2: Arm and Gripper Programming Guide (LabVIEW for · PDF file121 Arm and Gripper Programming Guide (LabVIEW™ for LEGO® MINDSTORMS®) Introduction: Inhisuide, t g the Ranger Bot will

122

Arm and Gripper Programming Guide (LabVIEW™ for LEGO® MINDSTORMS®)

Initialize the Servos:

4.Thecodeinvolvesfirstinitializingtheservopositions,delayingfor1second,andthenenteringthemaincodeWhileLoop.

a.Createthecodeshown,beginningwiththeMove Servosfunction,thentheWait for Time (sec)function.

b.NotethatthereisalargeWhileLoopenclosingtheremainderofthecode.CreatethisWhile Loop andensurethatitiswideenoughtocontainallofthecodethatfollows.

Check for an Object, Grip When Found Code:

5. InsidetheWhileLoop,thecodeupdatesthedisplayandthencheckstheultrasonicreadingtodetermineifanobjectisnearby.Iftheobjectisnearby,thecodestopstherobotandlowersthearm.Toachievethis:

a.Createthecodeshown,beginningwiththeScreen Update SubVI,followedbyaLess? comparisonfunction,andwiretheresulttotheconditionalterminalofaCasestructure.

b.TheTruecaseoftheCasestructureindicatesthatanobjecthasbeenfound.InsidetheCasestructure,firstplaceanotherScreen Update SubVIandthena Move Motorsandthena Wait For Time (sec)asshown.

c.Next,aFor Loopisusedtolowertheservofrom100to190unitsinstepsof1witha10-milliseconddelaybetweensteps.

Note:A+1(increment)functionisusedbecausethevalueoftheindexterminalstartsatzero.

6.Afterloweringthearm,therobotdelaysfor0.5seconds,closesthegripperservo,delaysagain,andthenraisesthearm.Toachievethis:

a.Createthecodeshown,beginningwiththeWait For Time (sec)function,followedbyaFor Looptoclosethegripperservofrom180to80unitsinstepsof1witha10-milliseconddelaybetweensteps.

b.Then,createasecondFor Looptoraisethearmservofrom160to25unitsinstepsof1witha10-milliseconddelaybetweensteps.

Note:A+1(increment)functionisusedbecausethevalueoftheindexterminalstartsatzero.

ExtensionsTETRIX®GettingStartedGuide

Page 3: Arm and Gripper Programming Guide (LabVIEW for · PDF file121 Arm and Gripper Programming Guide (LabVIEW™ for LEGO® MINDSTORMS®) Introduction: Inhisuide, t g the Ranger Bot will

123

7. TheCasestructurecodecompleteswithaverificationthattheobjectwassuccessfullygripped,usingthetouchsensor.

a.UseaRead Touch Sensor (pressed) functionandconnecttheresulttotheconditionalterminalofanotherCasestructure.

b.IntheTruecase,usethe“Screen Update SubVI”todisplay“Status: Got It!,”thenplayatoneanddelayonesecond,asshown.

c.IntheFalsecase,display“Status: Missed It!”anddelay0.5seconds.

Note:The Read NXT ButtonsfunctioniswiredtotheconditionterminaloftheouterWhileLoop.ThiswillensurethatthecoderunsuntiltheEnterbuttonoftheNXTispressed.

Line Follower When No Object Detected Code:

8.Finally,theFalsecaseoftheouterCasestructureexecutesaspeed-adjustedlinefollowercodewhennoobjectisdetectedincloseproximity.Toachievethis:

a.Usea Greater?comparisonfunctionontheultrasonicreading,aCase structuretodeterminespeed,andthenaLess? comparison functiononthelightsensorreadingtodeterminewhichmotortodrive,asshown.

Arm and Gripper Programming Guide (LabVIEW™ for LEGO® MINDSTORMS®)

TETRIX®GettingStartedGuideExtensions