Arm and Gripper Programming Guide (LabVIEW for LEGO MINDSTORMS · 121 Arm and Gripper Programming...

1

Transcript of Arm and Gripper Programming Guide (LabVIEW for LEGO MINDSTORMS · 121 Arm and Gripper Programming...

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

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

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