You are on page 1of 15

Robotics and Automation Lab

(CEN4032)
Lab Report: 05
Department of Computer Engineering

National University of Technology Islamabad

Department Name/Registration Number Semester/Section

Computer Engineering Waqas Salman/F18604022 7th Semester

Date Instructor Name Instructor Signature

19/December/2021
Dr. Awais Yasin
Lab Engr. Rida Batool
Experiment 05
Moving, Mathematics and Sensors
Objective:
Activity Time Boxing:
Task Activity Name Activity Time
No.
1 Lecture 10 ~ 15mins
2 Performing Experiment 120 ~ 125 mins
3 Results and Evaluation 30 ~ 40 mins
Time: 180

Background:
Movement:
EV3 programs consist of a series of programming blocks, each of which makes the robot do one particular
thing, such as move forward for one second. Programs run the blocks one by one, beginning with the first
block on the left. Once the first block finishes running, the program continues with the second block, and
so on. Once the last block finishes running, the program ends.

The Move Steering Block:


The Move Steering block controls the movement of a robot’s motors. By using it in your program, you can
make the EXPLOR3R move forward or backward, and steer left or right.

The Move Steering Block in Action:

Before we get into how the Move Steering block works, let’s make a small program to see it in action. This
program will make the EXPLOR3R drive backward until the wheels make two full rotations and then spin
quickly to the right for three Block type icon Settings. For example, the first block makes the robot drive
backward, while the second makes it steer right.
• Create a new project named EXPLOR3R-4. Change the name of the first program to Move.
• Pick two Move Steering blocks from the Programming Palette and place them on the
Programming Canvas, as shown in figure.

• By default, the blocks you’ve just placed are configured to make the robot go forward for a little
while, but we want to change the first Move Steering block so that it makes the robot drive
backward for two-wheel rotations. To accomplish this, change the settings on the first block, as
shown in figure.

• Now you want to modify the settings on the second block. This block will make the EXPLOR3R spin
quickly to the right for three seconds. First, change its mode to On for Seconds, as shown in figure.
• To make the robot spin quickly to the right for three seconds, change the settings on the second
block, as shown in figure.

• Once you’ve configured both Move Steering blocks, you can download the program to your robot
and run it. You’ll know it’s working if the EXPLOR3R goes backward until both wheels make two
rotations and then turns around quickly for three seconds.
Sensors:

The LEGO MINDSTORMS EV3 set includes three types of sensors: Touch, Color, and Infrared. You can use
these sensors to make your robot respond to its environment. For example, you can program your robot
to make a sound when it sees you, avoid obstacles while driving, or follow colored lines. This part of the
book will teach you how to create working robots that use these sensors.

what are sensors?

LEGO MINDSTORMS robots can’t actually see or feel the way humans do, but you can add sensors to them
so they can collect and report information about their environment. By designing programs that can
interpret this sensor information, you can make your robots seem intelligent by having them respond to
their environment. For instance, you could create a program that makes the robot say “blue” when one
of its sensors sees a piece of blue paper.

Understanding Modes and Settings:

The Move Steering block has several modes, each of which can be selected by clicking the Mode Selector
and each of which makes the block do something slightly different. For example, the first block in our
program was in On for Rotations mode, which allows you to choose the number of motor rotations the
robot will move for, while the second was in On for Seconds mode, which allows you to specify how long
the motors will move in seconds.

The modes in the Move Steering block are as follows:

On: Switch on motors.

Off: Stop the motors.

On for Rotations: Turn on motors for a specified number of complete rotations; then stop.

On for Seconds: Turn on motors for a specified number of seconds; then stop.

On for Degrees: Turn on motors for a specified number of degrees of rotation; then stop.

Ports:

In the Ports setting at the top right of the block, you can choose which output ports of the EV3 brick you’ve
connected the driving motors to so that the program knows which motors it should switch on. The
EXPLOR3R’s motors are connected to ports B and C, so in our sample program, we left the block at its
default setting of B+C.

Steering:

This block can control the robot’s steering by controlling the two wheels independently. For the robot to
move straight, both wheels will turn in the same direction at the same speed. To make a turn, one wheel
will spin faster than the other, or the wheels can turn in opposite directions to make the robot turn in
place.

Power:

The Power setting controls the speed of the motors. Zero power means that the wheels don’t move at all,
while 100 sets the motors to maximum speed. Negative values, such as –100 or –30, make the robot move
backward.

Rotations, Seconds, or Degrees:

Depending on which mode you select, the third setting on the Move Steering block lets you specify how
long the motors should move. For instance, entering 3 in the Seconds setting in On for Seconds mode
makes the EXPLOR3R move for three seconds. On for Degrees mode allows you to specify the number of
degrees the motors—and as a result, the wheels—should turn. Turning 360 degrees is the same as one
full rotation of the wheels, while 180 degrees would be half a rotation. You can set the wheels to turn a
number of full rotations when the block is in On for Rotations mode as you saw in the first block of the
sample program.

Brake at End:

The Brake at End option controls how the motors stop after they rotate the required number of degrees,
rotations, or seconds. Selecting true makes the motors stop immediately, while false ( ) makes them stop
gently.

Making Accurate Turns:

When you use a Move Steering block to make the robot turn 90 degrees, you might think you need to set
the Degrees setting to 90, but this is not true. In fact, the Degrees setting specifies only how many degrees
the motors—and, as a result, the wheels—turn. The actual number of degrees the motors should turn so
the robot makes a 90-degree turn is different for every robot.

Understanding the Sensors in the EV3 Set:

Your EV3 set contains three sensors that you can attach to your robot as well as some built-in sensors.
The Touch Sensor detects whether the red button on the sensor is pressed or released. The Color Sensor
detects the color of a surface and the intensity of a light source. The Infrared Sensor measures the
approximate distance to a nearby object, and it receives signals from the infrared remote. In addition,
each motor in the EV3 set has a built-in Rotation Sensor to measure the motor’s position and speed, and
the EV3 brick can detect which of its Brick Buttons are pressed.

Understanding the Touch Sensor:

The Touch Sensor allows your robot to “feel” by detecting whether the red button on the sensor is
currently pressed or released. The EV3 retrieves this information from the sensor and can use it in
programs. For example, you could make your robot say “hello” whenever you press the Touch Sensor.
Creating The Bumper with The Touch Sensor:

If you build a bumper and attach it to the Touch Sensor, then anytime the EXPLOR3R runs into an object
with its bumper, the sensor will become pressed. The program on your EV3 can use this information to
decide to move the robot in a different direction. Build the bumper and attach it to the robot. Be sure to
connect the Touch Sensor to input port 1 using a short cable.

Take the following pieces from the box:

• Step 1:

• Step 2:

• Step 3:
• Step 4:

Now collect following pieces to make a bumper:

• Step 5:

• Step 6:
• Step 7:

• Step 8:

• Step 9:

• Step 10:
• Step 11:

• Step 12:

Take a short cable of 25 cm and connect the touch sensor to the EV3 brick.
Programming with Sensors:

Several programming blocks let you use sensors in your program, including the Wait, Loop, and Switch
blocks.

Sensors and The Wait Block:

Earlier, you used a Wait block to pause the program for a set amount of time (say, five seconds). But you
can also use a Wait block to pause a program until a sensor is triggered. For example, you can configure a
Wait block to pause until the Touch Sensor is pressed by selecting the Touch Sensor mode.

• After selecting this mode, you must also choose between Compare and Change mode. In Compare
mode, you specify with the State setting whether the program should wait until the sensor is
released (0), pressed (1), or bumped (2). If you choose bumped, the program waits for a press
followed by a release.
• In Change mode, the program waits until the state of the sensor changes: If the sensor is pressed
when the block begins running, the program waits until it’s released. If it’s released at first, the
program pauses until the sensor is pressed.
• The Port setting lets you specify which input port your sensor is connected to (in this case, port
1). Finally, the Measured Value plug allows you to use the last sensor measurement later on in
your program.
Using the Color Sensor:

The Color Sensor can detect the color of a surface (in Color mode), the amount of light reflected by a
surface (in Reflected Light Intensity mode), or the brightness of ambient light (in Ambient Light Intensity
mode).

Attaching the Color Sensor:

Before you begin programming, remove the Touch Sensor attachment from the robot. Then, connect the
Color Sensor to the robot. For attaching a color sensor collect the following pieces:
• Step 1:

• Step 2:

• Step 3:
• Step 4:

• Step 5
Creating the Program

Figure shows the program flow we’ll need to make the robot drive around without leaving the black
shape.

For this program, you’ll use a Wait block in Color Sensor – Compare – Color mode. In this configuration,
you can choose a combination of colors that the sensor should look for using the Set of Colors setting.
When it sees any of them, the block stops waiting, and the program moves on to the next block.
Lab Task:

• Make the EXPLOR3R robot drive around a room and turn around when it feels something such as

a wall or chair, with its bumper.

Output:

Discussion:

This lab includes many steps to follow a step-by-step guide to make a perfect module or
robot in which different sensors are used like ultrasonic sensor and touch sensor to work
with and to burn the program file in the robot we use Lego Mindstorms.

Conclusion:
In this lab we worked with the real time robot and studied them to relate with our
Robotics and automation course.

You might also like