INTERMEDIATE PROGRAMMING LESSONINTERMEDIATE PROGRAMMING LESSON MOVE DISTANCE MY BLOCK (MOVE_CM)...

Preview:

Citation preview

BySanjayandArvindSeshan

INTERMEDIATEPROGRAMMINGLESSON

MOVEDISTANCEMYBLOCK(MOVE_CM)

LessonObjectives1. CreateausefulMyBlock

2. LearnwhycreatingaMyBlockthattakesmeasurementsmadewitharulercanbeuseful

3. MakeaMove_CMMyBlock

Prerequisites:MovingStraight,PortView,MyBlockswithInputsandOutputs,MathBlocks,DataWires

COPYTIGHT©2015EV3LESSONS.COM,LASTEDIT7/06/2016 2

WhyaMoveDistanceMyBlock?Built-inmoveblockswillnottakeinputs(values)incentimetersorinches.

Itismucheasiertomeasuredistancewitharulerthandegreesorrotations.

Ifyouchangeyourrobotdesigntohavebiggerorsmallerwheelslateron,youdon’thavetore-measureeverymovementofyourrobot◦ Insteadofchangingdistancesineverysingleprogramyouwrote,justgointoyournewMoveDistanceBlockandchangethevalueforhowmanyinches/cmonemotor rotationwouldtake.

COPYTIGHT©2015EV3LESSONS.COM,LASTEDIT7/06/2016 3

MOVE_CMINTHREEEASYSTEPSSTEP1:Determinehowmanymotordegreesyourrobotmovesin1cm

STEP1A:WheelMeasurement

STEP1B:Programtherobottomove1cm

STEP2:AddaMathBlocktoconvertcentimeterstodegrees

STEP3:CreateaMove_CMMyBlockwith2inputs(poweranddegrees)

COPYTIGHT©2015EV3LESSONS.COM,LASTEDIT7/06/2016 4

Step1A:HowManyDegreesDoesTheRobotMovein1CM?

COPYTIGHT©2015EV3LESSONS.COM,LASTEDIT7/06/2016 5

Method1:1. Lookupthewheelsizeinmmprintedonyourtireanddivideby10toconvertto

cm(because1cm=10mm)2. Multiplytheanswerinstep1byπ (3.1415…)tocomputecircumference3. Divide360degreesbyvaluefromstep2.Thiscomputesdegreesin1cmsinceyou

travelonecircumferencein1rotationand1rotationis360degrees

ExamplecalculationusingthestandardEV3Edu45544setwheels:

1. EV3EDU(45544)wheelsare56mm=5.6cmindiameter

2. 5.6cm× π =17.6cmperrotation3. 360degrees÷ 17.6cm=20.5motordegreespercm

Helpful chartwithcommonLEGOwheelsandtheir

diameters.

http://wheels.sariel.pl/

Step1A:AlternativeMethod

COPYTIGHT©2015EV3LESSONS.COM,LASTEDIT7/06/2016 6

AlternateMethod:UsePortViewtofindtheMotorDegreesvalue.Usethismethodifyoucannotfindthediametervalueprintedonyourwheel.

1. Putyourrulernexttoyourwheel/robot at0centimeters(whateverpartoftherobotyouusetoalignwith0,youshouldusetousetomeasuredistanceinstep2)

2. Rollyourrobotforwardanyamountofcentimeters,makingsureyourrobotdoesnotslip.

3. Takethedegreereadingyouseeonthescreenforthemotorsensoranddividebytheamountofcentimetersyoumoved.

4. Theanswerwillbethenumberofdegreesyourrobot'swheelsturn in1centimeter.

Step1B:ProgramMove1CM

COPYTIGHT©2015EV3LESSONS.COM,LASTEDIT7/06/2016 7

UsetheMotorDegreesvalueyouobtained foryourrobot inslides5or6

Step2:DegreetoCMConversion

COPYTIGHT©2015EV3LESSONS.COM,LASTEDIT7/06/2016 8

CreatetheCalculatorthatcovertsdegreestocentimeters

Step3A:SetuptheMyBlock• A.HighlightthetwoblocksinStep2

andgotoMyBlockBuilder

• B.Addtwoinputs:PowerandCentimetersandcompletethesetupprocess.

• IfyouneedhelpintheMyBlockBuilder,refertotheMyBlockwithInputsandOutputsLessoninIntermediate

COPYTIGHT©2015EV3LESSONS.COM,LASTEDIT7/06/2016 9

B

A

Step3B:WiretheMyBLOCK

COPYTIGHT©2015EV3LESSONS.COM,LASTEDIT7/06/2016 10

C.Wiretheinputs inthegreyblock.ThecentimetersinputconnectstotheMathBlock.ThepowergoesintotheMoveSteeringBlock’spowerinput.TheresultoftheMathBlockiswiredintothedegreesinput intheMoveSteeringBlock.

Step3C:CompletedMove_CM

COPYTIGHT©2015EV3LESSONS.COM,LASTEDIT7/06/2016 11

DiscussionWhyisaMove_CMMyBlockuseful?◦ Youcanmeasuredistancesincentimetersandinput thisnumber intoyourblockinsteadofprogramming indegreesorrotations

WillchangingtheinputsinonecopyofMove_CM impactanothercopyofit?◦ No.ThatisexactlywhyaMyBlockisuseful.Youcanusethesameblockmultiple times,eachtimeusingadifferentnumber forpowerandcentimeters(oranyotherparameteryousetup).

CanyoualteraMyBlockafteritismade?◦ Youcanchangeanyofthecontents,butnotthegreyblocks(input andoutputparameters).Ifyouneedtomakechangestotheparameters,youmustremakeyourMyBlock.

COPYTIGHT©2015EV3LESSONS.COM,LASTEDIT7/06/2016 12

CREDITSThistutorialwascreatedbySanjaySeshanandArvindSeshan

Morelessonsareavailableatwww.ev3lessons.com

COPYTIGHT©2015EV3LESSONS.COM,LASTEDIT7/06/201613

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Recommended