Professional Documents
Culture Documents
2013 Ev 3 Programming
2013 Ev 3 Programming
2013 Ev 3 Programming
People Introductions
Deborah Kerr & Faridodin Lajvardi - FIRST Senior Mentor
Jason Yount - Technical Training Manager - LEGO Education North America
Glenn Swinson , FIRST FLL Logistics Manager
Main Topic:
Jason will walk through a slide set for programming the EV3 robot
This call is meant to present Basic programming, not advanced methods, and
thus geared toward newcomers to the Mindstorm and FLL experience
Technical Support where to get help
Q&A
Outline
Purpose:
This workshop is intended for FLL coaches who are interested in learning about
Mindstorms EV3 programming language.
Programming
EV3 Controller (aka: the brick)
User Interface
Building Blocks
Controlling the robot with MOVE Blocks
What is New: EV3 vs. NXT
Turns - there is more than one way to turn
Geometry and Math for the Robot
Gyro Sensor
Advanced Programming
Light Sensor
Program Control (WAIT, LOOP, SWITCH Blocks)
Math (VARIABLES, MATH and COMPARE Blocks)
My Block
Resources
EV3 Brick
2 = Center, press the
center button to select
and accept options, or
run a program.
1 = Back, this button
is used to reverse
actions, to stop a
running program,
and to shut down the
EV3.
3
3
2
3
Programmable EV3
Brick
Four outputs (motors)
Four inputs (sensors)
USB, Bluetooth, or Wi-Fi
connection
Improved LCD screen
16 MB flash memory
64 MB RAM
SD Card Port: 32 GB
Multiple onboard utilities
1,000 samples per second
EV3 Brick Button lights
Sound
A, B, C, D = Output ports
used for motors.
Large Motor
Medium Motor
EV3 Motors
Detects distance
Auto ID
Auto ID
Touch Sensor
Detects pressed
Detects released
Detects bumped
Auto ID
Gyro Sensor
Angle mode
Auto ID
EV3 Navigation
Open a previously saved project
Lobby
Button
Open New
Project
Open New
Project or
previously
saved ones
12
Robot Educator
Opened Project
Project Properties
Currently Opened Programs
belonging to opened project
Click to create a
new program
within the current
project
14
Programming canvas
where you can lay out
the programs blocks /
instructions
Programming palettes
where you can find the
various building blocks
Content Editor
Animations
Build guides
Interactive guides
Sample programs
Challenges
Save as a project
Teacher and student
modes
Edit facility
Palettes
Action Blocks
Medium Motor, Large Motor, Move Steering, Move Tank, Display, Sound,
Brick Status Light.
Flow Blocks
Brick Buttons, Color, Gyro, Infrared, Motor Rotation, Temperature, Timer, Touch, Ultrasonic,
Energy Meter, Sound
18
Palettes
Action Blocks
Variable, Constant, Array, Logic, Math, Round, Compare, Range, Text, Random
Advanced Blocks
File Access, Data Logging, Messaging, BlueTooth, Keep Awake, Raw Sensor
Value, Unregulated Motor, Invert Motor, Stop Program
My Blocks
19
B - Motor
C - Motor
20
Brake or
Coast
Number of motor
degrees, rotations or
seconds
21
Move Tank
Control two motors and allows each motor to
move with different power level including in
different direction for turning or spinning.
For turning: one motor has zero power; the other
has positive (forward) or negative(backward)
power.
When zero power is specified, the motor is locked
and will not move to ensure accurate turns
For spinning, use positive power for one and
negative for the other
Brake or
Coast
Number of motor
degrees, rotations or
seconds
22
Large Motor
Control a single large motor
When zero power is specified, the motor is
locked and will not move to ensure accurate
turns
Brake or
Coast
Number of motor
degrees, rotations or
seconds
23
Medium Motor
The Medium Motor block controls the
Medium Motor. You can turn the motor on or
off, control its power level, or turn the motor
on for a specified amount of time or
rotations
When zero power is specified, the motor is
locked and will not move
Use positive or negative power to control
direction
Brake or
Coast
Number of motor
degrees, rotations or
seconds
24
25
Whats new
All files are stored within the Project file, i.e., programs, my blocks. You can move /
copy the project file to other computers and it will work. Now you can backup the
entire project or even use a memory stick to store your project!
Turning on/off the EV3 now takes about 30 seconds
The MOVE block is replaced by the MOVE STEERING and MOVE TANK blocks
MOVE STEERING has single power control; motors are regulated, i.e., if one motor
moves faster than the other, the faster motor will be slowed down to compensate.
MOVE TANK: has independent power controls for each motor where one can move
faster than the other or even in opposite direction. This too is regulated.
NOTE: with limited testing, it appears that issues using steering in NXT are solved in
EV3!
27
Walk and
Chew gum
At the same
Time!
Use the Invert Motor block to have a normal forward and backward
directions swapped. Any programming blocks after the Invert Motor block
that would normally make the motor turn clockwise will instead make the
motor turn counter-clockwise, and vice-versa.
Programming Bug NOTE: IT DOESNT WORK with Move Steering or
Move Tank.
Built-in light sensor calibration is gone! You have to build your own (see example on
the following pages)
28
X
2000
Black
2300
Step 2:
Black - X 2300 - 2000
Intensity =
= .3 or 30%
=
1000
Range
29
To Type
Result
Logic
Numeric
False = 0, True = 1
Logic
Text
False = 0, True = 1
Numeric
Text
30
B
One Motor move:
Right Turn Use MOVE TANK block and select a power
level for the B motor and zero for the "C" motor
In this case the robots right wheel will be stationary and
the left wheel will move.
Right
brake
Forward
B
Turning with two motors in opposite direction
To turn right, use the MOVE TANK block where the B
motor will turn clockwise (positive power) and the C
motor will turn counter clockwise (negative power).
Backward
Turns Continued
To make 180 degree right turn using a tank move or large motor
End Position
Start Position
B
B
To make 180 degree right turn using tank move (spin in place)
Start Position
End Position
Note the distance travelled is shorter (exactly half) when using both two motors.
32
C = x Diameter
33
1.6 inches
5.5 in
5.5 in
2.2 inches
If the robot is using the wheel whose diameter is 2.2 inches
and therefore its circumference is 7 inches, how many wheel rotations
will it take to make a complete robot turn rotation (34.5 inches)?
Circumference of Robot Turn Circle
Circumference of Robots Wheel
Diameter X
Diameter X
11 X 3.14
2.2 X 3.14
4.9
35
Negative
Positive
NOTE: you must reset the gyro sensor as the first step and
immediately before turning so that your turn is measured
from the robots current position!
36
Programming Process
Analysis and Planning Steps
Define the problem
Brainstorm solution and select one
KEEP IT SIMPLE!
Plan and create a flowchart and take measurements
Programming suggestions
Divide the program into small pieces
Program one pieces at a time
Example: Move the robot to black line
37
Tips
For moving straight, the MOVE STEERING / MOVE TANK blocks have a
built-in PID to regulate the movement of B & C motors. If one motor falls
behind, the MOVE STEERING block compensate by applying less power to
the faster motor.
For driving the robot, use the B & C motor ports; the A and D ports should
be used for the robots arm.
Using full motor power (100%) may cause erratic robot movement, use 75%
or less.
Conversely, too little power (below 25%) may cause the robot to stall.
Brake at the end of each MOVE block to take advantage of the PID which self
corrects to achieve more precise moves.
Using Degrees is a more accurate way to move motors; using time, will be
inconsistent when the batteries become weak
The MOVE STEERING / MOVE TRACK block also keeps track of errors
that accumulate in multiple blocks and adjusts itself.
Use the brake option and also use the RESET block.
REMEMBER: the tradeoff between speed and accuracy!
38
39
70%
50%
20%
50%
Black
Violet
Dark Blue
Dark Red / Brown
70%
To obtain more accurate reading, make sure the light sensor is close to the mat (less
than inch)
Calibrate the sensor whenever light conditions change (see calibrate slide)
40
41
42
Example 2:
Move to detect a black line, using
a LOOP block instead of WAIT.
Simultaneously use the WAIT for
time block and if two seconds
elapsed, end the loop using
LOOP INTERRUPT and stop the
motors.
43
44
Warning: Deleting the LOOP block will also delete all the blocks within the
loop. You can move the blocks out of the loop, then delete it.
45
SWITCH block
The SWITCH block will check for a condition and will take one action if
the condition is true and another action if the condition is false
46
Advanced Blocks
VARIABLE block
The variable block is a bucket where you can store
information and retrieve it at a later time.
There are three types: Number, Text, and Logic
MATH block
The math block allows the addition, subtraction,
division or multiplication of two numbers.
Input
Input
Result
COMPARE block
The compare allows you to determine if
one number is greater than, less than
or equal to another number.
Result (True or False)
47
9/26/2013
48
My Block
My Block is a combination of one or more blocks that are grouped into a single "Block".
Once created, it can be used in many programs. My Block can be used in the following
ways:
1. Minimize the coding, if certain actions are repeated in multiple programs.
Often, you need to repeat certain steps, for example, different programs require
that the robot would back into the wall to re-orient itself. This process can be
placed into a My Block.
2. Divide a program into smaller manageable pieces
3. Reduces the amount of memory used.
4. Clarify the action taken in programs by creating self explanatory My Blocks
Example 1: your program already includes 22 blocks and youre not finished. It is time
to consider breaking up the program into chunks, i.e., My Blocks.
Example 2: For turning left or right you use the LARGE MOTOR block. When someone
is reviewing the program, they cant tell which way the robot is turning if you are only
using MOTOR block. Solution: create a Turn Left My Block to make it easy to
understand the program.
Example 3: One youve fine tuned a perfect 90 degree turn, you can create your own
My Block for the perfect 90 degree left and right turn.
49
50
Using My Block
Once youve created My Block, it will
become available on the My Block palette
1. Select the My Block palette
51
My Block Tips
Use My Block to break down a large program into two or more My Blocks
If you create a My Block with one input and decided later to add another input, youll
have to start over
If you create a My Block with two inputs and decided later to remove one, you cannot
delete the input; either start over, or ignore it.
52
53