gyro turns - ev3 lessons · 3. direction (the first input) defines: • 0 –check if the value has...
TRANSCRIPT
![Page 1: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/1.jpg)
ADVANCEDEV3PROGRAMMINGLESSON
GyroTurnsBySanjayandArvindSeshan
©2016EV3Lessons.com,Lastedit7/19/2016 1
![Page 2: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/2.jpg)
1. LearnwhatGyroLagis
2. Learnonewaytocorrectforthislag
3. Understandwhyitisimportanttoexplorealternativesolutionstoaproblem
ì Pre-requisites:MyBlockswithInputsandOutputs,Datawires,MathBlocks,Loops
©2016EV3Lessons.com,Lastedit7/19/2016 2
LessonObjectives
![Page 3: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/3.jpg)
ì Whatislag?ì Thegyrosensorreadingslagbehindthetruevaluesometimes
ì Whentheturnstarts,ittakestimeforthegyrotobeginchanging
ì Thislessonpresentsonewaytodealwithlaginaturn: reducetheamountofanglethatyouturntocompensateforlag
©2016EV3Lessons.com,Lastedit7/19/2016 3
GyroProblem2:Lag
![Page 4: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/4.jpg)
©2016EV3Lessons.com,Lastedit7/19/2016 4
ChangeModeinWaitBlock
1. InthislessonweusetheWaitBlock(gyrosensor)inChangeMode
2. AdvantagesoverCompareMode:• Youdonotneedtoresetthegyrobeforehand• Youcanmeasureifthevaluehaschangedthe
targetdegreesbybothdecreasingorincreasing(noneedtochangethewaitblockforaleftturn)
3. Direction(thefirstinput)defines:• 0– checkifthevaluehasincreasedthedesired
degrees• 1– checkifthevaluehasdecreasedthedesired
degrees• 2– checkifthevaluehaseitherincreasedor
decreasedthedesireddegrees
![Page 5: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/5.jpg)
STEP1:CreateasimpleGyroTurnprogramthatturns90degreesusingtheWaitforGyroblockinChangeMode
Remember toCalibrate theGyrobeforetheWaitForBlock(seeGyroLessonforhelp)
STEP2:CompensateforLag
A. Compensateforthelagbyreducingtheamountofangletoturnbasedonyourrobot(e.g 86degreesinsteadof90degrees)
B. UseaMathBlocktocreateanautomaticcalculatortocompensateforlag
STEP3:CreateandWiretheMyBlock
STEP4:RepeatthestepstomakeoneforLeftTurnsvs.oneforRightTurns.
©2016EV3Lessons.com,Lastedit7/19/2016 5
GyroTurninFourEasySteps
![Page 6: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/6.jpg)
©2016EV3Lessons.com,Lastedit7/19/2016 6
Step1:SimpleGyroTurn
![Page 7: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/7.jpg)
©2016EV3Lessons.com,Lastedit7/19/2016 7
Step2A:DealingwithLag
![Page 8: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/8.jpg)
©2016EV3Lessons.com,Lastedit7/19/2016 8
Step2B:AutomaticallyCorrectforLag
![Page 9: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/9.jpg)
©2016EV3Lessons.com,Lastedit7/19/2016 9
Step3A:CreateaMyBlock
A. HighlightalltheblocksthengotoMyBlockBuilder
B. Add2inputs:oneforpowerandoneforanddegrees
RefertotheMyBlockswithInputs&OutputslessonifyouneedhelpsettinguptheMyBlock
B
A
![Page 10: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/10.jpg)
©2016EV3Lessons.com,Lastedit7/19/2016 10
Stage3B:WiretheMyBlock
degrees
power
Connectthedegreesvalueintothemathblockandthepowerintothemovesteeringblock
![Page 11: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/11.jpg)
©2016EV3Lessons.com,Lastedit7/19/2016 11
Stage4:UsingtheMyBlock
![Page 12: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/12.jpg)
©2016EV3Lessons.com,Lastedit7/19/2016 12
Step4:TurnDegreesRight
![Page 13: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/13.jpg)
©2016EV3Lessons.com,Lastedit7/19/2016 13
Step4:TurnDegreesLeft
![Page 14: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/14.jpg)
ì Whatisgyrolag?Ans.Thegyrosensor’sreadinglagsbehindthetruereading
ì Whatisonewaytocompensateforlag?Ans:Reducethenumberofdegreesthatyouturn
©2016EV3Lessons.com,Lastedit7/19/2016 14
Discussion
![Page 15: Gyro Turns - EV3 Lessons · 3. Direction (the first input) defines: • 0 –check if the value has increased the desired degrees • 1 –check if the value has decreased the desired](https://reader033.vdocuments.site/reader033/viewer/2022052000/601305e822a1a05bb13a9680/html5/thumbnails/15.jpg)
ì ThistutorialwaswrittenbySanjaySeshan andArvindSeshan
ì Morelessonsatwww.ev3lessons.com
©2016EV3Lessons.com,Lastedit7/19/2016 15
Credits
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.