Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore Lego Ev3 Programming

Lego Ev3 Programming

Published by bassem.abdullah, 2016-02-22 10:17:23

Description: www.softcomputer.com > UTrain

Keywords: none

Search

Read the Text Version

th d. 4 step: If the Color Sensor identifies White color, Ev3 use the Medium Motor to Clear nd Field of the 2 tire. Fig. 9 Programming – Step 7 We used Sound with Sound Detected and Medium Motor with On For Rotation Mode and power of rotation is equal to 74 for 2 rotation and brake at end function is TRUE ( Medium Motor connected to Port A) th e. 5 Step: If the Color Sensor identify Red Color, Ev3 will Move Backward to the starting Area Fig. 10 Programming – Step 8 We used Sound with sound Backing alert and Move Steering with Steering value of 0 to let the Ev3 Moving straight and power value equal -75 to Move backward for 4 Rotations and function of Brake at End is true Finally, we interrupt the loop of the program with Brick Buttons Function to stop the loop and Ev3. Fig. 11 Programming – Step 9 We Use Brick Buttons to interrupt the loop with specific setting Sample July 2014 Icon based Programming Page 44 Your First Step For Coding

6.3.1 Overall Program Ev3 will wait color sensor to identify colors and according to color sensor identification the robot will do specific actions using big motors and medium motor for clearing tires from the pad. Fig. 12 Full Program of Action Color using Icon Based 6.4 Adjust Field Setting Adjust field of the Ev3 Moving and Make it convenient for the movement of the robot. Fig. 13 Ev3 in the field Icon based Programming Sample July 2014 Your First Step For Coding Page 45

6.5 Download and Test After finishing all above Steps , it’s the time to download program on the brick and start Program Testing by start the brick with the start button and see what happened . 6.6 Technical Notes 1. Power value of motor to moving forward is from 1 to 100 2. Power value of motor to moving backward is from -1 to -100 3. Final block in the switch structure is very important for the real test of the program because of the speed of the sensor identification and we should use it as a default case of the switch 4. All programming blocks input values maybe need to be calibrated due to leak of the battery or changing in the field and obstacles. 6.7 Mission Tips 6.7.1 My Track3r doesn’t move  If your robot doesn’t move the problem can be that the batteries are empty and or that you didn’t connected the cables from motors to brick in the correct way. 6.7.2 My Track3r Color sensor identify colors wrong  Colors should be Obvious and clear opposite the color sensor. 6.7.3 My Tracker replay the same color when start before identifying any color  You should use the final block of the switch with no color identify and no action inside it as default case Sample July 2014 Icon based Programming Page 46 Your First Step For Coding

7 Escape The goal on this mission is to detect Enemies behind the robot and take the several actions to save himself from the enemy attacking and after that continue moving till the robot detect new enemy. Fig.1 Mission Icon based Programming Sample July 2014 Your First Step For Coding Page 47

7.1 Tracker Build Lego Ev3 track3r is one of the basic building of ev3 robot and composed of most of Lego parts that provided with the robot to the robot owner And there is specified steps to build this track3r With two Sensors IR and Color sensor in the back of Ev3 (for More Information about building look at our manual ) Fig. 2 Track3r with IR Sensor 7.2 Connecting Inputs/Outputs In this ev3 module we need some of inputs and outputs to get the features of moving, so the component we need is a. 2 Large Motors b. 1 IR Sensor • Large motors should connect to two output ports ( in our example we connect the motors to the ports B+C ) • IR Sensor should connect to one of the Inputs port ( in our Example we connect the input port 4) Sample July 2014 Icon based Programming Page 48 Your First Step For Coding

Fig. 3 Tracker with IR Sensor 7.3 Programming Robot Using Icons We used Programming icons to program robot to use Large motors for moving and there is specific block for every robot action and every block have some models of work so we use some of them with custom models to program Ev3 track3r robot to Move and detect enemies that move in the area back of ev3 robot and then escape. 1. First we use Loop block to surround all Mission blocks or actions to replay actions inside it to detect enemies. Fig. 4 Programming – Step 1 Fig 4 Loop block to let the actions inside the switch function to be replayed for specific times or finite times Icon based Programming Sample July 2014 Your First Step For Coding Page 49

2. We use the Move Steering to keep the ev3 moving in the field. Fig. 5 Programming – Step 2 Fig 5 Move steering in On Mode with steering 0 to move straight and power value of 30 to move forward and connected to output port B+C 3. After using Move steering we use the switch block that is the main idea of this mission programming with the ability to replay blocks within its True or False loop as a result of compare result of the first switch structure block to save time and blocks number used in mission programming . Fig. 6 Switch Block without any setting • Now, we are into the switch and we should program it using blocks to do our mission of detect enemies and Escape. • First we use Infrared Sensor to detect any enemy moving in the area behind the Ev3 Sample July 2014 Icon based Programming Page 50 Your First Step For Coding

Fig. 7 Programming – Step 4 In Fig 7 we used IR Sensor as a switch compare block and the IR Mode is Infrared – Compare – Proximity with compare type 4 that mean that the compare type will be less that the threshold input that it is 25 cm in this block and this Sensor connected to input Port 4 • Now the compare result of the IR sensor will specify the set of the blocks that will be used in this condition. • If it was True, That mean that there is an enemy within the area of 25 cm in the back of the Ev3 and robot will take a set of actions to escape from this enemy. a. 1-Ev3 will Say Ouch and Immediately moving away fast Fig. 8 Programming – Step 5 In Fig 8 we used Sound and The Move Steering icon in On For Seconds Mode with steering 0 to move straight with power value of 100 to move forward fast for 2 seconds and function of Brake At End Is True and connected to output port B+C b. After moving fast the Ev3 will rotate again in order to move and detect enemies Fig. 9 Programming – Step 6 Move steering in On for seconds mode with steering -100 to rotate left and power value 50 to move forward for 2 sec and function of brake at end is True and connected to output port B+C Icon based Programming Sample July 2014 Your First Step For Coding Page 51

If the comparison was False that mean that there is no thing detected by the IR sensor within the 25 cm of the Ev3 tracker behind area and this false comparison activate the set of actions or blocks that used in the false side of Switch Structure and neglect True blocks • All we need from Ev3 in this mission is to detect enemies and take a set of steps to save himself and escape • So , if there is no enemy detected Ev3 should continue moving and detection and compare it to save itself and while it is moving he must be ready to escape in every second and the False set of Actions is : a. we use Move Steering to let the Ev3 continue moving forward while collecting new readings from IR Fig. 10 Programming – Step 7 We Used Move Steering in On Mode with steering 0 to move straight and power value of 40 and connected to output port B+C b. Using Wait block to let the Ev3 moving slowly and detect enemies Fig. 11 Programming – Step 8 Wait Icon Setting to Wait For 1 Second c. Moving Ev3 in Rotational style is important to detect enemies and iR scan big area behind the Ev3. Fig. 12 Programming – Step 9 Moving Steering in On Mode with and steering 50 to turn right and power value of 40 and connected to output ports B+C Sample July 2014 Icon based Programming Page 52 Your First Step For Coding

4. Now we almost finish the program by completing the True and False Action that will used by the robot depending on the comparison data coming from IR sensor block and we should specify the number of loop replays and in our mission here we used infinity number of replays in the loop. Fig. 13 Programming – Step 10 Number of Replays in Switch Structured Loop block 7.3.1 Overall Program We used tracker with IR sensor and Hammer Accessory to Detect Enemies and then Escape from it using icon programming with switch structure to decide if there is an enemy to Escape. Fig. 14 Full program of Detect and attacking enemies 7.4 Adjust Field Setting Adjust field of the Ev3 Moving and try to make it suitable and safe. 7.5 Download and Test After finishing all above Steps , it’s the time to download program on the brick and start Program Testing by start the brick with the start button and see what happened . Icon based Programming Sample July 2014 Your First Step For Coding Page 53

7.6 Technical Notes 1. Power value of motor to moving forward is from 1 to 100 2. Power value of motor to moving backward is from -1 to -100 3. All programming blocks input values maybe need to be calibrated due to leak of the battery or changing in the field and obstacles. 7.7 Mission Tips 7.7.1 My Track3r doesn’t move  If your robot doesn’t move the problem can be that the batteries are empty and or that you didn’t connected the cables from motors to brick in the correct way. 7.7.2 My Track3r turns to the wrong side  You either crossed the motor’s cables or you just coded the Tracked Vehicle block to turn to the wrong side. It is easy to fix. We suggest you check the cables first. 7.7.3 My Track3r moving the hammer Wrong  If the M-motor correctly plugged, Make sure that you are not rotating the motor in the wrong direction and check program ports and inputs 7.7.4 My Track3r doesn’t detect enemies  Check IR sensor Connectivity and port number in the robot and the Program and check the space of the threshold input that you specify in the program. Sample July 2014 Icon based Programming Page 54 Your First Step For Coding

8 Enemies Detect and Attack The goal on this mission is to detect Enemies behind the robot and take the several actions to save him from and attack the enemy and after that continue moving till the robot detect new enemy. Fig. 1 Mission Icon based Programming Sample July 2014 Your First Step For Coding Page 55

8.1 Tracker Build Lego Ev3 track3r is one of the basic building of ev3 robot and composed of most of Lego parts that provided with the robot to the robot owner And there is specified steps to build this track3r With two Sensors IR and Color sensor in the back of Ev3 (for More Information about building look at our manual ) Fig. 2 Track3r with Hammer Accessory 8.2 Connecting Inputs/Outputs In this ev3 module we need some of inputs and outputs to get the features of moving, so the component we need is a. 1 Medium Motor b. 2 Large Motors c. 1 IR Sensor • -We should connect Medium Motor to one of the output port( in our example we connect the Medium Motor to Output Port A ) • Large motors should connect to two output ports ( in our example we connect the motors to the ports B+C ) • IR Sensor should connect to one of the Inputs port ( in our Example we connect the input port 4) Sample July 2014 Icon based Programming Page 56 Your First Step For Coding

Fig. 3 Ev3 Tracker Medium motor connected to hammer accessory 8.3 Programming Robot Using Icons We used Programming icons to program robot to use Large motors for moving and use Medium motor to control the Hammer Weapon and there is specific block for every robot action and every block have some models of work so we use some of them with custom models to program Ev3 track3r robot to Move and detect enemies that move in the area back of ev3 robot and the main idea of this mission program is the concept of loop and a special type of loop called switch loop that apply custom steps after making compare of early data from sensors or other inputs and how to use this loop to replay actions without using more blocks every time. 1. First we use the Medium Motor to adjust the Hammer in the Ready State. Fig. 4 Programming – Step 1 Fig 4 Medium Motor in On for Seconds Mode and power is -20 for 1 second and Brake at End function is True 2. After using the medium motor to move the Hammer in ready state we use the Structured switch loop block that is the main idea of this mission programming with the ability to replay blocks within its True or False loop as a result of compare result of the first switch structure block to save time and blocks number used in mission programming. Icon based Programming Sample July 2014 Your First Step For Coding Page 57

Fig. 5 Switch Block without any setting • Now, we are into the switch and we should program it using blocks to do our mission of detect enemies and attack them. • First we use Infrared Sensor to detect any enemy moving in the area behind the Ev3 Fig. 6 Programming – Step 3 In Fig 6 we used IR Sensor as a switch compare block and the IR Mode is Infrared – Compare – Proximity with compare type 4 that mean that the compare type will be less that the threshold input that it is 25 cm in this block and this Sensor connected to input Port 4 • Now the compare result of the IR sensor will specify the set of the blocks that will be used in this condition. • If it was True , That mean that there is an enemy within the area of 25 cm in the back of the Ev3 and robot will take a set of actions to attack this enemy Sample July 2014 Icon based Programming Page 58 Your First Step For Coding

a. Ev3 will rotate 360 degree using move steering icon to attack detected enemy Fig. 7 Programming – Step 4 In Fig 7 we used The Move Steering icon in On For Degrees Mode with steering -100 to move to left with power value of 75 and degree of 1000 to do complete rotation and function of Brake At End Is True and connected to output port B+C b. After completing a complete rotation we should use the medium motor connected to the hammer to attack the enemy Fig. 8 Programming – Step 5 In Fig 8 we used Medium Motor block in On for Seconds Mode with power value of 100 for 0.3 second and function of Brake at End is True and connected to the output port A 3. Finally, we use the medium motor block again to adjust the hammer again in the ready state. Fig. 9 Programming – Step 6 In Fig 9 we used Medium Motor block in On for Seconds Mode with power value of -20 for 1 second and function of Brake at End is True and connected to the output port A If the comparison was False that mean that there is no thing detected by the IR sensor within the 25 cm of the Ev3 tracker behind area and this false comparison activate the set of actions or blocks that used in the False side of Switch Structure and neglect True blocks • All we need from Ev3 in this mission is to detect enemies and take a set of steps to save himself and attack this enemies Icon based Programming Sample July 2014 Your First Step For Coding Page 59

• So , if there is no enemy detected Ev3 should continue moving and detection and compare it to save itself and while it is moving he must be ready to attack in every second and the False set of Actions is : a. we use Move Steering to let the Ev3 continue moving forward while collecting new readings from IR Fig. 10 Programming – Step 7 We Used Move Steering in On Mode with steering 0 to move forward and power value of 75 and connected to output port B+C b. We put the Hammer in ready mode using the medium motor brick by continue moving hammer during moving and detection. Fig. 11 Programming – Step 8 We used Medium Motor icon in On for Seconds Mode with power value of 75 for 0.1 second and Brake at End function is True and connected to input port A c. Using Wait block to let the Ev3 wait and compare is very important and help to let Ev3 moving slowly and detect enemies Fig. 12 Programming – Step 9 Wait Icon Setting to Wait For 1 Second d. Moving Ev3 in Rotational style is important to detect enemies and IR scans big area behind the Ev3. Fig. 13 Programming – Step 10 Sample July 2014 Icon based Programming Page 60 Your First Step For Coding

Moving Steering in On Mode with and steering 50 to turn right and power value of 75 and connected to output ports B+C e. Hammer Moving up and down is a ready mode that we put the hammer in and here we use the medium motor again to moving the hammer. Fig. 14 Programming – Step 11 Medium Motor icon in On for Seconds Mode with power value -10 for 0.2 seconds and function of Brake at End is False and connected to input port A 4. Now we almost finish the program by completing the True and False Action that will used by the robot depending on the comparison data coming from IR sensor block and we should specify the number of loop replays and in our mission here we used infinity number of replays in the loop. Fig. 15 Programming – Step 12 Number of Replays in Switch Structured Loop block 8.3.1 Overall Program We used tracker with IR sensor and Hammer Accessory to Detect Enemies and then attack it using icon programming with switch structure to decide if there is an enemy to attack. Fig. 16 Full program of Detect and attacking enemies Icon based Programming Sample July 2014 Your First Step For Coding Page 61

8.4 Adjust Field Setting Adjust field of the Ev3 Moving and try to make it suitable and safe. 8.5 Download and Test After finishing all above Steps , it’s the time to download program on the brick and start Program Testing by start the brick with the start button and see what happened . 8.6 Technical Notes 1. Power value of motor to moving forward is from 1 to 100 2. Power value of motor to moving backward is from -1 to -100 3. All programming blocks input values maybe need to be calibrated due to leak of the battery or changing in the field and obstacles. 8.7 Mission Tips 8.7.1 My Track3r doesn’t move  If your robot doesn’t move the problem can be that the batteries are empty and or that you didn’t connected the cables from motors to brick in the correct way. 8.7.2 My Track3r turns to the wrong side  You either crossed the motor’s cables or you just coded the Tracked Vehicle block to turn to the wrong side. It is easy to fix. We suggest you check the cables first. 8.7.3 My Track3r moving the hammer Wrong  If the M-motor correctly plugged, Make sure that you are not rotating the motor in the wrong direction and check program ports and inputs 8.7.4 My Track3r doesn’t detect enemies  Check IR sensor Connectivity and port number in the robot and the Program and check the space of the threshold input that you specify in the program. Sample July 2014 Icon based Programming Page 62 Your First Step For Coding

9 Bouncing Ball The goal on this mission is use 178×128 pixels screen of the brick to make bouncing ball with using of variables and mathematics abilities of the brick. 9.1 Tracker Build In our mission we need only ev3 brick without any special build or any connecting inputs or outputs devices and all we need is programming brick Fig. 1 Ev3 Brick 9.2 Programming Robot Using Icons We used Programming icons to program Ev3 brick and by blocks and every block have some models of work so we use some of them with custom models to program Ev3 brick to bouncing ball on the brick screen. • Concept of this mission is to design a shape of a ball and move it on the screen using x,y axis 1. First we used variable with name of x Fig. 2 Programming – Step 1 In Fig 2 we used Variable with (x) name in Write – Numeric Mode and with value equal 80 2. First we used variable with name of y Icon based Programming Sample July 2014 Your First Step For Coding Page 63

Fig. 3 Programming – Step 2 In Fig 3 We used Variable with (y) name in Write – Numeric Mode and with value equal 60 rd 3. Now we used 3 variable with name of dx as speed of moving speed on x axis Fig. 4 Programming – Step 3 In Fig 4 We used Variable with (dx) name in Write – Numeric Mode and with value equal 3 4. 4th variable with name of (dy) as speed of moving speed on y axis Fig. 5 Programming – Step 4 In Fig 5 We used Variable with (dy) name in Write – Numeric Mode and with value equal 3 5. We used loop for the coming blocks to continue moving ball by adding and compare result axis with the screen boundaries to keep the ball in this screen. Fig. 6 Programming – Step 5 Loop block with infinite time of replays Sample July 2014 Icon based Programming Page 64 Your First Step For Coding

6. Now we give the speed to x variable by adding value of x variable to value of the dx value using math Fig. 7 Programming – Step 6 Dx and x variable added by math block in Add mode 7. we got the sum of the dx and x and add it to the x variable to specify the new location on x- axis Fig. 8 Programming – Step 7 Adding sum of the x and dx to x variable in Mode Write Numeric 8. Adding dx to x is the way we use to move the ball in x axis and we want keep the ball in the boundaries of the screen by using Range block to compare every new location of x on the x- axis with the boundaries of the screen. Fig. 9 Programming – Step 8 Adding sum of x to range with boundaries 10 and 168 to always keep the ball in this boundaries 9. Result of the Range block will provide the logic comparison of the switch with data to decide if the ball still in or not Fig. 10 Programming – Step 9 Range block connected to logic compare block in switch block Icon based Programming Sample July 2014 Your First Step For Coding Page 65

10. If the result was true this is what we want but if it was false we should reverse the speed of moving in x direction to get the ball back into the boundaries. Fig. 11 Programming – Step 10 Value of dx is multiplied with -1 to reverse the direction of ball moving and then added to dx variable again 11. after finishing controlling of x and moving of ball in x-axis we work to control y and moving of y in y-axis 12. Now we give the speed to y variable by adding value of y variable to value of the dy value using math Fig. 12 Programming – Step 11 Dy and y variable added by math block in Add mode 13. We got the sum of the dy and y and add it to the y variable to specify the new location on y- axis Fig. 13 Programming – Step 12 Adding sum of the y and dy to y variable in Mode Write Numeric 14. Adding dy to y is the way we use to move the ball in y-axis and we want keep the ball in the boundaries of the screen by using Range block to compare every new location of y on the y- axis with the boundaries of the screen. Fig. 14 Programming – Step 13 Adding sum of y to range with boundaries 10 and 118 to always keep the ball in this boundaries Sample July 2014 Icon based Programming Page 66 Your First Step For Coding

15. Result of the Range block will provide the logic comparison of the switch with data to decide if the ball still in or not Fig. 15 Programming – Step 14 Range block connected to logic compare block in switch block 16. If the result was true this is what we want but if it was false we should reverse the speed of moving in y direction to get the ball back into the boundaries. Fig. 16 Programming – Step 15 Value of dy is multiplied with -1 to reverse the direction of ball moving and then added to dy variable again 17. Now we finish the information of x and y coordinates and the method of moving the ball with moving x and y on x-axis and y-axis and finally we should design the shape that will move on the screen as a circle using x and y. Fig. 17 Programming – Step 16 X variable and y variable added to Display Block in Shapes – Circle Mode with function of clear screen is True with radius of circle is 10 and fill function is true with color function False 18. We use Wait block to delay the replays of the loop and brick buttons to interrupt it. Fig. 18 Programming – Step 17 Wait block with 0.05 seconds and brick buttons with Brick Buttons – Compare mode and set of Brick Buttons is [2] and state is 2 to just bump the button Icon based Programming Sample July 2014 Your First Step For Coding Page 67

9.3 Download and Test After finishing all above Steps , it’s the time to download program on the brick and start Program Testing by start the brick with the start button and see what happened . 9.4 Mission Tips 9.4.1 Ball moving slowly  Screen resolution is bad but it will be helpful to test this abilities of Ev3 Sample July 2014 Icon based Programming Page 68 Your First Step For Coding

10 Move It Away The goal on this mission is to collect a tire from specific place on the mission pad and move with it to different place and drop it. This mission show you how to control both Large-motors and Medium-motor, so basically the task is about completing the robot and coding a program that makes the robot move forward and then collect Tires or Target object in order to move it to new place and do this mission twice with 2 object . Fig. 1 Mission Icon based Programming Sample July 2014 Your First Step For Coding Page 69

10.1 Tracker Build Lego Ev3 track3r is one of the basic building of ev3 robot and composed of most of Lego parts that provided with the robot to the robot owner And there is specified steps to build this track3r With two Sensors IR and Color sensor in the back of Ev3 (for More Information about building look at our manual ) Fig 2 Track3r with Claw Accessory 10.2 Connecting Inputs/Outputs In obstacle avoidance ev3 module we need some of inputs and outputs to get the features of moving, so the component we need is a. 1 Medium Motor b. 2 Large Motors • We should connect Medium Motor to one of the output port( in our example we connect the Medium Motor to Output Port A ) • Large motors should connect to two output ports ( in our example we connect the motors to the ports B+C ) Sample July 2014 Icon based Programming Page 70 Your First Step For Coding

Fig. 3 Claw Connected to Medium Motor 10.3 Programming Robot Using Icons We used Programming icons to program robot to use Large motors for moving and use Medium motor to control the claw to grab and place tires and there is specific block for every robot action and every block have some models of work so we use some of them with custom models to program Ev3 track3r robot to Move tires from specified place to new one and the main idea of this mission program is the concept of loop and how to use loop to reduce instruction with the same quality. 1. First we use the Medium Motor to adjust the claw in the grab function Fig. 4 Programming – Step 1 In Fig 4 We used Medium Motor that connected with the claw in the On Mode with power value of - 75 and connected to output port A to adjust the claw in grab Mode 2. After using the medium motor to move the claw in grab mode we use the loop block that is the main idea of this mission programming with the ability to replay blocks within it to save time and blocks number used in mission programming. Icon based Programming Sample July 2014 Your First Step For Coding Page 71

Fig. 5 Loop block 3. Now , we are into the loop and we should programming certain blocks to do our mission by grabbing tires and place them in the new place for one time and the loop will replay it to nd finish the 2 half of the mission because its identical to the first one . • First we use Move Steering to move forward. Fig. 6 Programming – Step 3 In Fig 6 we used Moving Steering with Steering value of 0 to let the Ev3 Moving straight and power value equal 75 to Move forward for 2 Rotations and function of Brake at End is True and connected to output ports B+C . • Now we are in the grab area and so that we use the medium motor block to grab the tire from the field. Fig. 7 Programming – Step 4 In fig 7 we used Medium Motor with power value of 75 and connected to output port A • We used Move Steering Block to let the Ev3 move to the tire delivery point Fig. 8 Programming – Step 5 In Fig 8 we used Moving Steering with Steering value of 35 to let the Ev3 Turn Right and power value equal 75 to Move forward for 3 Rotations and function of Brake at End is True and connected to output ports B+C . • Ev3 now in the tire delivery point and we should use the medium motor again to release the tire from the claw Sample July 2014 Icon based Programming Page 72 Your First Step For Coding

Fig. 9 Programming – Step 6 In fig 9 we used Medium Motor with power value of -75 and connected to output Port A (Claw Release Block) • Mission First half now is finished but we need the Ev3 to go back to the latest point to start the second half of the mission without any more blocks because we are using loop , So , we use Move steering to go back to the latest point. Fig. 10 Programming – Step 7 In Fig 10 we use Move Steering Block by steering value of 35 to move to right and power value of - 75 to move backward for 3 Rotations and Brake at End Function Is True and the block output ports is B+C • Loop Inside blocks now is finished and we need to specify the number of Replays of this set of blocks together depending on the number of replays we want in the mission. Fig. 11 Programming – Step 8 Loop ending is the latest half of the loop block that we use it to specify the number of replays and the number of replays in our program is 2 4. Finally, we use Move Steering Block to let Ev3 go back to the Mission starting point. Fig. 12 Programming – Step 9 In Fig 12 we use Move Steering Block by steering value of 0 to move to Straight and power value of - 75 to move backward for 4 Rotations and Brake at End Function Is True and the block output ports is B+C Icon based Programming Sample July 2014 Your First Step For Coding Page 73

10.4 Summary Fig. 13 Full Program 10.5 Adjust Field Setting Adjust field of the Ev3 Moving and Tires place to be like the blocks settings Fig. 14 Field of Mission Sample July 2014 Icon based Programming Page 74 Your First Step For Coding

10.6 Download and Test After finishing all above Steps , it’s the time to download program on the brick and start Program Testing by start the brick with the start button and see what happened . 10.7 Mission Tips 10.7.1 My Track3r doesn’t move  If your robot doesn’t move the problem can be that the batteries are empty and or that you didn’t connected the cables from motors to brick in the correct way. 10.7.2 My Track3r turns to the wrong side  You either crossed the motor’s cables or you just coded the Tracked Vehicle block to turn to the wrong side. It is easy to fix. I suggest you check the cables first. 10.7.3 My Track3r doesn’t open the claw  Is the M-motor correctly plugged? Make sure that you are not rotating the motor in the wrong direction. Icon based Programming Sample July 2014 Your First Step For Coding Page 75

11 Control Using Brick The goal on this mission is to control Ev3 moving or actions using Brick Buttons. 11.1 Tracker Build Lego Ev3 track3r is one of the basic building of ev3 robot and composed of most of Lego parts that provided with the robot to the robot owner And there are specified steps to build this track3r but in this build we will use the color sensor to identify colors (Look at Ev3 Building Help) Fig. 1 Track3r with Infrared sensor 11.2 Connecting Inputs/Outputs In this ev3 module we need some of inputs and outputs to get the features of moving, so the component we need is a. 2 Large Motors • Large motors should connect to two output ports ( in our example we connect the motors to the ports B+C ) Sample July 2014 Icon based Programming Page 76 Your First Step For Coding

11.3 Programming Robot Using Icons We used Programming icons to program robot to do actions or moves using brick buttons. 1. First we use Loop block to surround all Mission blocks or actions to replay actions inside it to identify new IR instructions Fig. 1 Programming – Step 1 Fig 2 Loop block to let the actions inside the switch function to be replayed for specific times or infinite times 2. After using loop block we use switch structure with IR sensor block to detect instructions from remote and then do specific actions Fig. 3 Switch Block with Brick buttons compare block • Now, we are into the switch and we should program it using blocks to do our mission of get control instructions using brick buttons. Icon based Programming Sample July 2014 Your First Step For Coding Page 77

• First we use IR Sensor to get instructions from remote Fig. 4 Programming – Step 3 In Fig 4 we used Brick buttons as a switch compare block and the Brick button Mode is Brick Buttons – Measure Now the compare result of the Brick Buttons will specify the set of the blocks that will be used in these conditions. a. Condition One: If the Left brick button is Pressed the instructions of the first Condition will occur with the ev3 rotating Left for 3 sec and then moving forward for 1 sec and medium motor work for 3 sec Fig. 5 Programming – Step 4 In Fig 5 we used Move steering in On For seconds mode with steer of -100 to rotating left and power value is 50 for 3 seconds and brake at end is True and connected to output port B+C and then Move steering again with On for seconds mode and steering 0 to move straight with power value 20 to move forward for 1 sec and brake at end is True and finally using Medium Motor in on for Seconds mode with power value -50 for 3 seconds and brake at end is True and connected to Output port A b. Condition Two: If the Right brick button is Pressed the instructions of the 2nd Condition will occur with the ev3 rotating Right for 3 sec and then moving forward for 1 sec and medium motor work for 3 sec Sample July 2014 Icon based Programming Page 78 Your First Step For Coding

Fig. 6 Programming – Step 5 In Fig 6 we used Move steering in On For seconds mode with steer of 100 to rotating Right and power value is 50 for 3 seconds and brake at end is True and connected to output port B+C and then Move steering again with On for seconds mode and steering 0 to move straight with power value 20 to move forward for 1 sec and brake at end is True and finally using Medium Motor in on for Seconds mode with power value 50 for 3 seconds and brake at end is True and connected to Output port A c. Condition Three: If the Upper middle brick button is Pressed the instructions of the 3rd Condition will occur with the ev3 Moving forward for 2 sec and then medium motor will work for 3 sec Fig. 7 Programming – Step 6 In Fig 7 we used Move steering with On for seconds mode and steering 0 to move straight with power value 50 to move forward for 2 sec and brake at end is True and finally using Medium Motor in on for Seconds mode with power value 50 for 3 seconds and brake at end is True and connected to Output port A d. Condition Four: If the lower middle brick button is pressed the instructions of the 4th Condition will occur with the ev3 Moving backward for 2 sec and then medium motor will work for 3 sec Fig. 8 Programming – Step 7 In Fig 8 we used Move steering with On for seconds mode and steering 0 to move straight with power value -50 to move backward for 2 sec and brake at end is True and finally using Medium Motor in on for Seconds mode with power value 50 for 3 seconds and brake at end is True and connected to Output port A Icon based Programming Sample July 2014 Your First Step For Coding Page 79

Finally, we interrupt the loop of the program with Brick Buttons Function to stop the loop and Ev3. Fig. 9 Programming – Step 8 We Use Brick Buttons to interrupt the loop with specific setting 11.3.1 Overall Program Fig. 10 Full Program of Action Control Ev3 using Brick Buttons 11.4 Adjust Field Setting Adjust Suitable field of the Ev3 Moving 11.5 Download and Test After finishing all above Steps , it’s the time to download program on the brick and start Program Testing by start the brick with the start button and see what happened . Sample July 2014 Icon based Programming Page 80 Your First Step For Coding

11.6 Mission Tips 11.6.1 My Track3r doesn’t move  If your robot doesn’t move the problem can be that the batteries are empty or that you didn’t connected the cables from motors to brick in the correct way. Icon based Programming Sample July 2014 Your First Step For Coding Page 81

12 Count up and Control using IR Program Ev3 to count up with the IR Remote 12.1 Tracker Build Lego Ev3 track3r is one of the basic building of ev3 robot and composed of most of Lego parts that provided with the robot to the robot owner And there is specified steps to build this track3r (Look at our Ev3 building Instructions Manual) Fig. 1 Track3r with IR and Color Sensor 12.2 Connecting Inputs/Outputs In this ev3 module we need some of inputs and outputs to get the features of moving, so the component we need is a. 2 Large Motors b. 1 Infrared Sensor Sample July 2014 Icon based Programming Page 82 Your First Step For Coding

• Large motors should connect to two output ports ( in our example we connect the motors to the ports B+C ) • infrared Sensor should connect to one of the Inputs port ( in our Example we connect the input port 4) 12.3 Programming Robot Using Icons We used Programming icons to program robot to use Large motors for moving and main function of this mission programming is to use icon programming to read data from remote using IR Sensor and count up with Switch Function and then. 1. First we use Loop block to surround all Mission blocks or actions to replay actions inside it. Fig. 2 Programming – Step 1 Fig 2 Loop block to let the actions inside the switch function to be replayed for specific times or finite times 2. we use Wait block with infrared sensor to read data from Remote Fig. 3 Programming – Step 2 Wait block in Infrared sensor-Compare-Remote used in channel 1 and IDs is [1] and connected to input port 4 3. we use text block to show the numbers Fig. 4 Programming – Step 3 Text icon connected with the loop Icon based Programming Sample July 2014 Your First Step For Coding Page 83

4. connecting Result of the text to the Switch compare block Fig. 5 Programming – Step 4 Text Result Connected to Switch Compare Icon to make conditions • Now the compare result of the Text Every condition that will happen after press any button of the IR Remote a. Condition One : With first press , Ev3 will use the Medium motor and say Zero Fig. 6 Programming – Step 5 We used medium motor in on for seconds mode with power value 50 for 1 second and function of brake at end is true and connected to output port A and Ev3 will say Zero with Volume 100% nd b. Condition Two: After 2 press ,Ev3 will Go Forward and say One Fig. 7 Programming – Step 6 We used Move steering in on for seconds mode with steer 0 to move straight and power value -50 to move forward for 2 second and function of brake at end is True and connected to output port B+C and Ev3 will say One with Volume 100% Sample July 2014 Icon based Programming Page 84 Your First Step For Coding

rd c. Condition Three: After 3 press , Ev3 will move backward and say 2 Fig. 8 Programming – Step 7 We used Move steering in on for seconds mode with steer 0 to move straight and power value 50 to move Backward for 2 second and function of brake at end is True and connected to output port B+C and Ev3 will say One with Volume 100% th d. Condition Four: After 4 press , Ev3 will go backward to the left and forward to right Fig. 9 Programming – Step 8 nd We used Move Tank in on for Seconds mode with the first power is 100 and 2 power is 50 for 1 nd nd sec and 2 move tank is in on for rotations mode with first power value is -50 and 2 power is -100 for 1 rotation and connected to output port B+C and Ev3 will say Three with Volume 100% th e. Condition Five: After 5 press ,Ev3 will go right backward and left forward and say Four Fig. 10 Programming – Step 9 nd We used Move Tank in on for Rotations mode with the first power is 50 and 2 power is 100 for 1 nd nd Rotation and 2 move tank is in on for rotations mode with first power value is -100 and 2 power is -50 for 1 rotation and connected to output port B+C and Ev3 will say Four with Volume 100% Icon based Programming Sample July 2014 Your First Step For Coding Page 85

th f. Condition Six: After 6 press , Ev3 will rotate and Say Bravo and interrupt loop Fig. 11 Programming – Step 10 We used move steering with steer 100 to rotate with power value -50 to move forward for 2sec and connected to output port B+C and Ev3 will say Bravo with volume 100% and interrupt loop with loop Interrupt Finally, we specify number of loop replays a in our mission as an infinite number of replays. Fig. 12 Programming – Step 11 Fig 11 Number of Replays in Switch Structured Loop block 12.3.1 Overall Program We used the IR sensor Remote to count up and give actions to every count and finally interrupt loop th in 6 press Sample July 2014 Icon based Programming Page 86 Your First Step For Coding

Fig. 12 Full Program of Count Using IR 12.4 Adjust Field Setting Adjust field of the Ev3 Moving and try to make it suitable for Ev3 Actions 12.5 Download and Test After finishing all above Steps , it’s the time to download program on the brick and start Program Testing by start the brick with the start button and see what happened . 12.6 Mission Tips 12.6.1 Power of Motor  Power value of motor to moving forward is from -1 to -100  Power value of motor to moving backward is from 1 to 100 Icon based Programming Sample July 2014 Your First Step For Coding Page 87

12.6.2 Calibration  All programming blocks input values maybe need to be calibrated due to leak of the battery or changing in the field and obstacles Sample July 2014 Icon based Programming Page 88 Your First Step For Coding

13 Shoot It The Goal of this mission is to drive Tracker around and detect edges in there way using Infrared sensor. Tracker can go straight, turn left, turn right, in order to avoid falling. Depend on early programming using programming blocks to use the information derived from the infrared sensor to change direction of tracker with custom steps. 13.1 Tracker Build Lego Ev3 track3r is one of the basic building of ev3 robot and composed of most of Lego parts that provided with the robot to the robot owner And there is specified steps to build this track3r (Look at Ev3 building Instructions for tracker and shooter building) Fig. 1 Tracker with shooter 13.2 Connecting Inputs/Outputs In Avoid Falling ev3 module we need some of inputs and outputs to get the features of moving and detection of edges, so the component we need is a. Medium Motor b. 2 Large Motors • We should connect Medium Motor to the output port ( in our example we connect the Medium motor to port A ) • Large motors should connect to two output ports ( in our example we connect the motors to the ports B+C ) Icon based Programming Sample July 2014 Your First Step For Coding Page 89

13.3 Programming Robot Using Icons We used Programming icons to program robot to use motors for moving and medium motor for shot ball and there is specific block for every robot action and every block have some models of work so we use some of them with custom models to program Ev3 track3r robot to drive ev3 and shot tires 1. We used Move Steering Icon to adjust the direction of ev3 toward the target tire Fig. 2 Programming – Step 1 In fig 2 we used Move Steering icon with On for degrees Mode and steering -100 to rotate with power 25 to move forward and degree 50 with function of Brake at End Is True and connected to output port B+C . 2. Now, Ev3 is looking to the target tire and we should use medium motor to shoot the first tire. Fig. 3 Programming – Step 2 Medium Motor in On for Rotation Mode and power is 100 for 3 Rotations and Brake at End function is True and connected to output port A nd 3. We used Move Steering Icon to adjust the direction of ev3 toward the 2 tire Fig. 4 Programming – Step 3 In fig 3 we used Move Steering icon with On for degrees Mode and steering 100 to rotate with power 25 to move forward and degree 100 with function of Brake at End Is True and connected to output port B+C . 4. Now, Ev3 is looking to the 2nd target tire and we should use medium motor to shoot it. Fig. 5 Programming – Step 4 Sample July 2014 Icon based Programming Page 90 Your First Step For Coding

Medium Motor in On for Rotation Mode and power is 100 for 6 Rotations and Brake at End function is True and connected to output port A 5. We use Move steering again to get the ev3 back to the start point. Fig. 6 Programming – Step 5 In fig 5 we used Move Steering icon with On for degrees Mode and steering -100 to rotate with power 25 to move forward and degree 50 with function of Brake at End Is True and connected to output port B+C . 13.3.1 Overall Program We used the Ev3 with shooter accessory to shoot tires using medium motor that connected to the shooter Fig. 6 Full Program with Icon Based Blocks 13.4 Adjust Field Setting Adjust field of the Ev3 Moving and Obstacles place to be like the blocks settings 13.5 Download and Test After finishing all above Steps , it’s the time to download program on the brick and start Program Testing by start the brick with the start button and see what happened . 13.6 Technical Notes 1. Power value of motor to moving forward is from 1 to 100 2. Power value of motor to moving backward is from -1 to -100 3. All programming blocks input values maybe need to be calibrated due to leak of the battery or changing in the field and obstacles. Icon based Programming Sample July 2014 Your First Step For Coding Page 91

13.7 Mission Tips 13.7.1 My Track3r doesn’t turn  Checked the batteries? Are the cables connected? Did you add the block to turn the tracked vehicle? Sounds really strange. I would double check the cables. 13.7.2 My Track3r doesn’t turn too much or too little  You can do the math here or you can just find it using try and error. The problem is that you need to turn your robot just x degrees to align the tires heap. Sample July 2014 Icon based Programming Page 92 Your First Step For Coding

14 Moving Using IR The goal on this mission is to Moving Ev3 tracker using Infrared Sensor and Remote. 14.1 Tracker Build Lego Ev3 track3r is one of the basic building of ev3 robot and composed of most of Lego parts that provided with the robot to the robot owner And there are specified steps to build this track3r but in this build we will use the color sensor to identify colors (Look at Ev3 Building Help) Fig. 1 Track3r with Infrared sensor 14.2 Connecting Inputs/Outputs In this ev3 module we need some of inputs and outputs to get the features of moving, so the component we need is a. 2 Large Motors b. 1 IR Sensor • Large motors should connect to two output ports ( in our example we connect the motors to the ports B+C ) • IR Sensor should connect to one of the Inputs port ( in our Example we connect the input port 4) Icon based Programming Sample July 2014 Your First Step For Coding Page 93


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook