14.3 Programming Robot Using Icons We used Programming icons to program robot to use large motors for moving and IR sensor with remote to control ev3. 1. First we use Loop block to surround all Mission blocks or actions to replay actions inside it to identify new IR instructions Fig.2 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 IR Remote Sensor • Now, we are into the switch and we should program it using blocks to do our mission of detection instructions using IR sensor. Sample July 2014 Icon based Programming Page 94 Your First Step For Coding
• First we use IR Sensor to get instructions from remote Fig.4 Programming – Step 3 In Fig 4 we used IR sensor as a switch compare block and the IR sensor Mode is Infrared sensor – Measure - Remote 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 these conditions. 1. Condition One: If the top most Button of the IR Remote pressed the medium motor will work till the same button pressed again but this condition is the default case that mean that it will happen once the ev3 start Fig.5 Programming – Step 4 Programming blocks from left to right a. Wait block for 0.5 second to give time to ev3 to realize press b. Medium motor In on mode with power value 75 c. Wait block in Infrared sensor – compare – remote in channel 1 and set of remote IDs is [9] d. Medium motor in off mode to stop medium motor when the wait icon button is pressed e. Wait block for 1 second to give time to press new button 2. Condition Two: If the bottom 2 button of the IR Remote Pressed the ev3 will move backward using move steering till the same buttons pressed again Fig.6 Programming – Step 5 Icon based Programming Sample July 2014 Your First Step For Coding Page 95
Programming blocks from left to right a. Wait block for 0.5 second to give time to ev3 to realize press b. Move steering in on mode with steering 0 to move straight and power value of -10 to move backward and connected to B+C ports c. Wait block in Infrared sensor – compare – remote in channel 1 and set of remote IDs is [8] d. Move steering in off mode to stop moving when the wait icon button is pressed e. Wait block for 1 second to give time to press new button 3. Condition Three: If the upper 2 button of the IR Remote Pressed the ev3 will move forward using move steering till the same buttons pressed again Fig.7 Programming – Step 6 Programming blocks from left to right a. Wait block for 0.5 second to give time to ev3 to realize press b. Move steering in on mode with steering 0 to move straight and power value of 10 to move forward and connected to B+C ports c. Wait block in Infrared sensor – compare – remote in channel 1 and set of remote IDs is [5] d. Move steering in off mode to stop moving when the wait icon button is pressed e. Wait block for 1 second to give time to press new button 4. Condition Four: If the Right 2 button of the IR Remote Pressed the ev3 will move forward to the Right using move steering till the same buttons pressed again Fig.8 Programming – Step 7 Sample July 2014 Icon based Programming Page 96 Your First Step For Coding
Programming blocks from left to right a. Wait block for 0.5 second to give time to ev3 to realize press b. Move steering in on mode with steering 50 to turn right and power value of 20 to move forward and connected to B+C ports c. Wait block in Infrared sensor – compare – remote in channel 1 and set of remote IDs is [11] d. Move steering in off mode to stop moving when the wait icon button is pressed e. Wait block for 1 second to give time to press new button 5. Condition Five: If the Left 2 button of the IR Remote Pressed the ev3 will move forward to the Left using move steering till the same buttons pressed again Fig.9 Programming – Step 8 Programming blocks from left to right a. Wait block for 0.5 second to give time to ev3 to realize press b. Move steering in on mode with steering -50 to turn Left and power value of 20 to move forward and connected to B+C ports c. Wait block in Infrared sensor – compare – remote in channel 1 and set of remote IDs is [10] d. Move steering in off mode to stop moving when the wait icon button is pressed e. Wait block for 1 second to give time to press new button Now we almost finish the program by completing the switch conditions that will apply 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.10 Programming – Step 9 Number of Replays in Switch Structured Loop block 14.3.1 Overall Program We used tracker with IR sesnor and Remote to control ev3 from remote using programming with switch and loop structure blocks to give specifed action for every IR remote button in every time of using it . Icon based Programming Sample July 2014 Your First Step For Coding Page 97
Fig. 11 Full Program of Control Ev3 using IR Remote 14.4 Adjust Field Setting Adjust field of the Ev3 Moving and Colors of it 14.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 . 14.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. Sample July 2014 Icon based Programming Page 98 Your First Step For Coding
14.7 Mission Tips 14.7.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 or there is a problem with IR sensor Icon based Programming Sample July 2014 Your First Step For Coding Page 99
15 Obstacle Clearance using IR Remote The goal in this mission is to Moving Ev3 tracker using Infrared Sensor and Remote. And complete the mission of clearing the tires from the mission pad. 15.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 15.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 100 Your First Step For Coding
15.3 Programming Robot Using Icons We used Programming icons to program robot to use large motors for moving and IR sensor with remote to control ev3. 1. First we use Loop block to surround all Mission blocks or actions to replay actions inside it to identify new IR instructions Fig. 2 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 IR Remote Sensor • Now, we are into the switch and we should program it using blocks to do our mission of detection instructions using IR sensor. Icon based Programming Sample July 2014 Your First Step For Coding Page 101
• First we use IR Sensor to get instructions from remote Fig. 4 Programming – Step 3 In Fig 4 we used IR sensor as a switch compare block and the IR sensor Mode is Infrared sensor – Measure - Remote 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 these conditions. 1. Condition One: If the top most Button of the IR Remote pressed the medium motor will work till the same button pressed again but this condition is the default case that mean that it will happen once the ev3 start Fig. 5 Programming – Step 4 Programming blocks from left to right a. Wait block for 0.5 second to give time to ev3 to realize press b. Medium motor In on mode with power value 75 c. Wait block in Infrared sensor – compare – remote in channel 1 and set of remote IDs is [9] d. Medium motor in off mode to stop medium motor when the wait icon button is pressed e. Wait block for 1 second to give time to press new button 2. Condition Two: If the bottom 2 button of the IR Remote Pressed the ev3 will move backward using move steering till the same buttons pressed again Fig. 6 Programming – Step 5 Sample July 2014 Icon based Programming Page 102 Your First Step For Coding
Programming blocks from left to right a. Wait block for 0.5 second to give time to ev3 to realize press b. Move steering in on mode with steering 0 to move straight and power value of -10 to move backward and connected to B+C ports c. Wait block in Infrared sensor – compare – remote in channel 1 and set of remote IDs is [8] d. Move steering in off mode to stop moving when the wait icon button is pressed e. Wait block for 1 second to give time to press new button 3. Condition Three: If the upper 2 button of the IR Remote Pressed the ev3 will move forward using move steering till the same buttons pressed again Fig. 7 Programming – Step 6 Programming blocks from left to right a. Wait block for 0.5 second to give time to ev3 to realize press b. Move steering in on mode with steering 0 to move straight and power value of 10 to move forward and connected to B+C ports c. Wait block in Infrared sensor – compare – remote in channel 1 and set of remote IDs is [5] d. Move steering in off mode to stop moving when the wait icon button is pressed e. Wait block for 1 second to give time to press new button 4. Condition Four: If the Right 2 button of the IR Remote Pressed the ev3 will move forward to the Right using move steering till the same buttons pressed again Fig. 8 Programming – Step 7 Icon based Programming Sample July 2014 Your First Step For Coding Page 103
Programming blocks from left to right a. Wait block for 0.5 second to give time to ev3 to realize press b. Move steering in on mode with steering 50 to turn right and power value of 20 to move forward and connected to B+C ports c. Wait block in Infrared sensor – compare – remote in channel 1 and set of remote IDs is [11] d. Move steering in off mode to stop moving when the wait icon button is pressed e. Wait block for 1 second to give time to press new button 5. Condition Five: If the Left 2 button of the IR Remote Pressed the ev3 will move forward to the Left using move steering till the same buttons pressed again Fig. 9 Programming – Step 8 Programming blocks from left to right a. Wait block for 0.5 second to give time to ev3 to realize press b. Move steering in on mode with steering -50 to turn Left and power value of 20 to move forward and connected to B+C ports c. Wait block in Infrared sensor – compare – remote in channel 1 and set of remote IDs is [10] d. Move steering in off mode to stop moving when the wait icon button is pressed e. Wait block for 1 second to give time to press new button Now we almost finish the program by completing the switch conditions that will apply 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. 10 Programming – Step 9 Number of Replays in Switch Structured Loop block Sample July 2014 Icon based Programming Page 104 Your First Step For Coding
15.3.1 Overall Program We used tracker with IR sesnor and Remote to control ev3 from remote using programming clear the mission pad from tires and steps of clearing 1. Moving Forward using the upper two buttons to move forward to the place of the first tire 2. Using the upper most button of remote to use the medium motor that connected to the clear accessory nd 3. Moving forward again using the upper two buttons to move forward to the place of the 2 tire 4. Using the upper most button of remote to use the medium motor that connected to the clear accessory 5. Using the bottom 2 buttons to move backward to the start area Fig. 11 Full Program of Control Ev3 using IR Remote 15.4 Adjust Field Setting Adjust field of the Ev3 Moving and place of tires Icon based Programming Sample July 2014 Your First Step For Coding Page 105
15.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 . 15.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. 15.7 Mission Tips 15.7.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 or there is a problem with IR sensor 15.7.2 My Track3r Medium Motor doesn’t stop Try to use the button of the medium motor stop button at the correct time after finishing working time and this tip is valid for all actions in this program Sample July 2014 Icon based Programming Page 106 Your First Step For Coding
Search
Read the Text Version
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113