You are on page 1of 9

Lab Handout #1: Designing a basic Mobile Robot using Arduino

Instructor: Dr. Afaque Manzoor Soomro

Name: UNSA JAN


CMS ID: 033-19-0048

Department of Electrical Engineering


FEE|TEL-413: Introduction to Robotics for the semester Fall 2022
Rubrics for Lab Task Assessment
Rubrics for Marks Breakdown
Demonstration
Design Manual Total (Out of 100)
Manual

Criteria 100% 70% 30% 0%


Design (40%) Designed as per Partially designed Not designed as Code not
instructions. as per instructions. per instructions. submitted.
Demonstration Successfully Successfully Demonstrated Failed to
(40%) demonstrated the demonstrated with with Major demonstrate the
task as intended. minor mistakes. mistakes. project.
Manual (20%) The manual The manual The manual not The manual not
submitted on time submitted on time submitted on time submitted.
with proper without proper but with proper
solution code. solution code. solution.
Lab task: Design a autonomous mobile robot that can move around through the
specified paths

Required components:
1. Robot chassis with motors
2. Motor Driver circuit board
3. Arduino/Pi with data cable
4. Connecting wires
5. PC (Arduino IDE installed)

A Mobile Robot is capable of locomotion and not fixed to a single physical location. Mobile
robotics is a subfield of robotics. A mobile robot uses sensors to identify its environment and move
around it. It does have sensors, controller and actuators as physical components, like in any other
robot. It does also have software component that makes it roam around autonomously through the
decision making process based on the sensors’ input.

Parts
1. Sensors: Sensors help the robot to identify its surrounding environment and detect path &
obstacles. There are different sensors that can be used with the mobile robots for different
applications, including IR, Ultrasonic, Colour detector, Laser scanner etc.

2. Controllers: Different types of controller are used in robots along with the memory and
additional circuitry. A robot controller makes decision for the robot based on the sensor values and
the algorithm stored in the memory. In this lab we will use Arduino controller.

3. Actuators: They enable the robot to perform action in/on the environment and objects within it.
Typically motors are the actuators for mobile robot. However, a mobile robot may be equipped with
addition manipulator which may contain addition actuators such as pneumatic, suction etc. The
mobile robot chassis used in this lab have 2 motor fixed with it.

Mobile Robot Chassis


We will use a three-wheeled mobile robot chassis for these labs. Although, the chassis consist of
three wheels, only two wheels are connected with dc motors. The dc motors are then connected with
a controller (e.g., Arduino) through a bridge circuit.
Bridge circuit
An additional circuitry used with mobile robot that offers protections to the controller and proper
operating voltage for the drives. A single bridge circuit can run control two motors, each enabled
through enable pin (ENA, ENB) as shown in figure. Direction of the motor is controlled through
adjusting the control inputs of the motors (IN1-IN4). The pin IN1 and IN2 are control pins for A,
whereas IN3 and IN4 are for the motor B. The inputs are set to +5V and GND respectively for
control pins of the each motor. To change the direction of the rotation, the motor control inputs are
switched. Output (+5V) can be used to power the Arduino board.

Running the Robot


To run the robot we need to send voltage signal to the robot through Arduino pins. For this purpose
we can use digitalWrite() command in Arduino controller for the specific pin of the motor through
bridge circuit.
________________________________________________________________________________
int left_wheelA = 10; int left_wheelB = 11;
int right_wheelA = 12; int right_wheelB = 13;
void setup() {
pinMode(left_wheelA, OUTPUT); pinMode(left_wheelB, OUTPUT);
pinMode(right_wheelA, OUTPUT); pinMode(right_wheelB, OUTPUT);
}
void loop() {
digitalWrite(left_wheelA, HIGH); digitalWrite(left_wheelB, LOW);
digitalWrite(right_wheelA, HIGH); digitalWrite(right_wheelB, LOW);
delay(2000)
digitalWrite(left_wheelA, LOW); digitalWrite(left_wheelB, LOW);
digitalWrite(right_wheelA, LOW); digitalWrite(right_wheelB, LOW);
}
________________________________________________________________________________

Programming Arduino
Once the circuit is complete, connect Arduino with your PC using the data cable. Run the Arduino
IDE and perform following steps to upload the code;
a. Select appropriate board from Tools → Boards
b. Select appropriate port from Tools → Port
c. Upload the code (Sketch → Upload)

Changing the Speed


To change the speed of the motor, we can supply PWM signal to the enable of the motors. For this
purpose we can use analogue pins of the Arduino.

Analogue value of the pin can be set between 0~255. Through changing this value speed of the
motors can be varied. The speed can also be varied by providing analogue value to the motor enable
pin.
________________________________________________________________________________
.
.
.
void loop() {
analogWrite(left_wheelA, 100); digitalWrite(left_wheelB, LOW);
analogWrite(right_wheelA, 100); digitalWrite(right_wheelB, LOW);
}

Turning the robot


There are two types of turns that our robot can make.
I. Radial Turn
In radial turn wheels of one side are halt while other side wheels are rotated to make the
turn. For example, to make a turn on right side, the wheels on the right side are halt, while
left side wheels move forward. The turn is called radial as the robot takes a curved path to
make the turn.
________________________________________________________________________________
.
.
.
void loop() {
turn_left();
}
void turn_left(void){
digitalWrite(left_wheelA, LOW); digitalWrite(left_wheelB, LOW);
digitalWrite(right_wheelA, HIGH); digitalWrite(right_wheelB, LOW);
}
________________________________________________________________________________

II. Axial Turn


In axial turn, wheels on the both sides of the robot are moved. Wheels on the turning
direction are moved backward, while the wheels on opposite are moved forward. The turn
is called axial turn as the robot makes the turn around its vertical axis.

Practice Tasks:
1. Program the robot to drive straight forward for five seconds and repeat in reverse direction.

2. Program the robot to move straight for 5 seconds in full speed then slowdowns, makes U-turn

and then moves straight for 5 seconds in full speed.

3. Make the robot move forward for 2 seconds and then make a random radial turn.

4. Make the robot move forward for 2 seconds and then make a random axial turn.

5. Program the robot to follow a path that is in Z shape. For shorter lengths run the robot in half

speed for 5 seconds. The longer length takes 10 seconds to cover in full speed. The angle between

shorter and longer lengths is 45 degree.

Exercise Task: Write a program for the robot to run on a path shaped like infinity. The robot
should complete the path between 10~20 seconds.

Exercise Question: What kind of issue(s) you had while solving the practice and exercise tasks?
How you may solve those issue(s)?
Answer:
1. The motors were unable to run while putting them on the floor when the lower
PWM value is passed. The issue was resolved by providing the higher PWM
values.
2. While using ESP32, it was challenging to provide it approximately 3.3V. The
different terminals of the provided battery were checked, and ESP32 could also be
powered up along with the H-Bridge with the same battery.
3. Understanding the working principle of H-Bridge has still to be learnt. With
practice and extra time, it could be understood.
Note: Demonstrate the practice and exercise tasks within the lab. Submit the handout along with the
exercise code and a picture of the final circuit on LMS.

Exercise Code

int left_wheelA = 22;


int left_wheelB = 23;
int right_wheelA = 18;
int right_wheelB = 19;

void setup() {
pinMode(left_wheelA, OUTPUT); pinMode(left_wheelB, OUTPUT);
pinMode(right_wheelA, OUTPUT); pinMode(right_wheelB, OUTPUT);
}

void loop() {

// First Part of Loop


analogWrite(left_wheelA, 70);
analogWrite(left_wheelB, LOW);
analogWrite(right_wheelA, LOW);
analogWrite(right_wheelB, LOW);

delay(2000);

// Stops
analogWrite(left_wheelA, LOW);
analogWrite(left_wheelB, LOW);

analogWrite(right_wheelA, LOW);
analogWrite(right_wheelB, LOW);

delay(500);

// Slightly Straight
analogWrite(left_wheelA, 70);
analogWrite(left_wheelB, LOW);
analogWrite(right_wheelA, 70);
analogWrite(right_wheelB, LOW);

delay(300);
// Second Part of Loop
analogWrite(left_wheelA, LOW);
analogWrite(left_wheelB, LOW);
analogWrite(right_wheelA, 70);
analogWrite(right_wheelB, LOW);

delay(2000);

// Stops
analogWrite(left_wheelA, LOW);
analogWrite(left_wheelB, LOW);

analogWrite(right_wheelA, LOW);
analogWrite(right_wheelB, LOW);

delay(500);

}
Conclusion:
Thus a mobile robot is studied through which numerous concepts of H-Bridge and ESP32/Arduino
UNO are cleared and PWM speed is also taken into consideration.

You might also like