Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views16 pages

Obstacle Avoiding Robot

Uploaded by

imranzbrbd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views16 pages

Obstacle Avoiding Robot

Uploaded by

imranzbrbd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Obstacle A voiding Robot

Computer Science & Engineering

Rajshahi University of Engineering & Technology

Submitted by:

Rajit[2303109], Fuad[2303110], A
sad[2303111], Imran [2303112], Samia

[2303113], Sayem [2303114]


Project Objectives

Obstacle Detection

Design a robot that detects and avoids obstacles

autonomously

2 Real-Time Navigation:

Allow the robot to navigate autonomously in an

environment without human intervention.

Hardware-Software Integration:

Demonstrate the integration of A


rduino, sensors,

motor driver, and motors for smooth operation.

Educational and Practical A pplication:

Provide a simple model for learning Electronics,

robotics concepts, microcontroller programming.


System Overview

Sensor A rduino

Reads data from the real-time environment and Processes the data and makes decisions based on

passes it to the Arduino. 1 2 its algorithm.

Motor Driver 4 3 Motors

Receives commands from A rduino and controls Execute the movement commands, enabling the

the motors9 speed and direction. robot to navigate and avoid obstacles.

The robot operates on a closed-loop control system, continuously sensing its environment and adjusting its movement accordingly.

The workflow begins with the sensor acquiring environmental data, which is then processed by the A
rduino. Based on this data, the A
rduino

sends commands to the motor driver, initiating precise motor movements for obstacle avoidance.
Hardware Components

A rduino Nano: Ultrasonic Sensor L298N Motor DC Motors &

Acts as the brain of the


(HC-SR04) Driver Wheels

robot, processing sensor Reads distance from Receives commands Execute movement

data and controlling obstacles in real-time from A


rduino to control commands, enabling the

outputs. and sends data to motor speed and robot to navigate and

Arduino. direction. avoid obstacles.

Power Supply Chassis / Frame Jumper Wires Breadboard

(Rechargeable
Holds and supports all Connect the sensors,
Used to make temporary
Battery)
the components of the motor driver, and
circuit connections

Provides necessary robot. Arduino for signal and


without soldering.

voltage and current to all power transmission.

components.
Working Principle

The robot employs a continuous sensing and reaction loop to navigate its environment.

Obstacle Detection Data Processing

The ultrasonic sensor emits sound waves


1 2
Arduino receives distance data from the

and calculates distance based on the sensor. If the distance is below a

echo's return time. threshold, an obstacle is detected.

Motor Response Decision Making

A rduino sends signals to the motor Based on obstacle detection, Arduino

driver, controlling motor speed and 4 3 executes an avoidance algorithm (e.g.,

direction for the avoidance maneuver. stop, turn left/right).


Software & Programming Logic

The robot's behavior is defined by its Arduino sketch, written in C++ within the A
rduino IDE.

Reading Sensor Data: Continuously read distance values from the ultrasonic sensor using dedicated libraries.

Decision-Making:

If distance < critical threshold: Trigger avoidance routine.

Else: Continue moving forward.

Motor Control Commands: Utilize specific functions to control motor direction (forward, backward, left, right) and speed via the L298N driver.

Avoidance Algorithm Example (Pseudocode):

Initialize motor pins, servo, and speed


Loop forever:
distance = readUltrasonic()
If distance <= 65:
stopMotors()
moveBackward(minSpeed)
distanceRight = lookRight()
distanceLeft = lookLeft()
If distanceRight >= distanceLeft:
turnRight(minSpeed)
Else:
turnLeft(minSpeed)
Else:
moveForwardGradually()
End Loop
A
rduino Code:

#include <Wire.h> void setup() { int distanceR = lookRight();


#include <NewPing.h> Serial.begin(9600); int distanceL = lookLeft();
#include <Servo.h>
pinMode(motorAPWM, OUTPUT); if (distanceR >= distanceL) {
// Motor driver pins pinMode(motorBPWM, OUTPUT); turnRight(minSpeed);
#define motorAPWM 5 pinMode(motorAforward, OUTPUT); } else {
#define motorAforward 7 pinMode(motorAbackward, OUTPUT); turnLeft(minSpeed);
#define motorAbackward 6 pinMode(motorBforward, OUTPUT); }
#define motorBPWM 3 pinMode(motorBbackward, OUTPUT); } else {
#define motorBforward 4 accelerateForward();
#define motorBbackward 2 myservo.attach(10); }
myservo.write(115); }
// Ultrasonic sensor pins delay(1000);
#define TRIG_PIN A0 // ================= Servo look functions
#define ECHO_PIN A1 accelerateForward(); =================
#define MAX_DISTANCE 200 distance = readPing(); int lookRight() {
} myservo.write(50);
// Motor speed control delay(400);
bool usePWM = true; void loop() { int dist = readPing();
int motorSpeed = 120; // Target speed distance = readPing(); myservo.write(115);
int minSpeed = 80; // Minimum speed for backward delay(200);
& start if (distance <= 65) { return dist;
moveStop(); }
// Ultrasonic object delay(50);
NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE); int lookLeft() {
Servo myservo; accelerateBackward(minSpeed); myservo.write(170);
moveStop(); delay(400);
int distance = 40; delay(50); int dist = readPing();
A
rduino Code:

myservo.write(115); void accelerateForward() { digitalWrite(motorAbackward, LOW);


delay(200); for (int s = minSpeed; s <= motorSpeed; s += 5) { digitalWrite(motorBforward, LOW);
return dist; setMotorSpeed(s); digitalWrite(motorBbackward, HIGH);
} digitalWrite(motorAforward, HIGH); delay(300);
digitalWrite(motorAbackward, LOW); moveStop();
int readPing() { digitalWrite(motorBforward, HIGH); }
int cm = sonar.ping_cm(); digitalWrite(motorBbackward, LOW); // Turn left
if (cm == 0) cm = MAX_DISTANCE; // Adjust right motor slightly for straight void turnLeft(int speed) {
Serial.print("Distance: "); analogWrite(motorAPWM, s); // left motor setMotorSpeed(speed);
Serial.println(cm); analogWrite(motorBPWM, s - 5); // fine tuning digitalWrite(motorAforward, LOW);
return cm; delay(40); digitalWrite(motorAbackward, HIGH);
} } digitalWrite(motorBforward, HIGH);
} digitalWrite(motorBbackward, LOW);
// ================= Motor functions delay(300);
================= // Accelerate backward slowly moveStop();
void moveStop() { void accelerateBackward(int speed) { }
setMotorSpeed(0); setMotorSpeed(speed); // Speed control
digitalWrite(motorAforward, LOW); digitalWrite(motorAforward, LOW); void setMotorSpeed(int speed) {
digitalWrite(motorAbackward, LOW); digitalWrite(motorAbackward, HIGH); if (usePWM) {
digitalWrite(motorBforward, LOW); digitalWrite(motorBforward, LOW); analogWrite(motorAPWM, speed);
digitalWrite(motorBbackward, LOW); digitalWrite(motorBbackward, HIGH); analogWrite(motorBPWM, speed);
} delay(100); // backward duration increased } else {
} digitalWrite(motorAPWM, speed > 0 ? HIGH :
// Accelerate forward gradually (adjusted for straight) // Turn right LOW);
void turnRight(int speed) { digitalWrite(motorBPWM, speed > 0 ? HIGH :
setMotorSpeed(speed); LOW);
digitalWrite(motorAforward, HIGH); }
}
Circuit Diagram

This diagram illustrates the essential electrical connections, ensuring

proper data flow and power distribution across all components.


A ctuation and Movement

DC Motor Actuation

The robot9s movement is driven by DC motors.

The rotation direction of each motor (clockwise/anticlockwise) depends on polarity.

When +V and GND are applied to the motor terminals ³ it rotates in one direction.

If the polarity is reversed (swap +V and GND) ³ the motor rotates in the opposite direction.

Polarity

Reverse

Drive

Rotate
A ctuation and Movement

Forward Movement

Both left and right motors rotate in the same forward direction ³ the robot moves straight forward.

Backward Movement

Reversing polarity on both motors ³ the robot moves backward.

Turning (Left / Right)

If one motor rotates while the other stops ³ the robot turns.

If one motor rotates forward and the other backward ³ the robot spins faster in place.
Challenges & Solutions

Challenges Encountered

1. Sensor Accuracy: Erratic readings due to environmental factors (e.g., soft

surfaces absorbing sound).

2. Motor Speed Calibration: Motors often have slight variations, leading to

uneven straight-line movement.

3. Power Management: Ensuring stable voltage for all components,

especially under motor load.

4. Algorithm Optimization: Preventing the robot from getting stuck in

corners or repeating avoidance loops.


Challenges & Solutions

Implemented Solutions

1. PWM Adjustment: Fine-tuned Pulse Width Modulation (PWM) values for

each motor to achieve balanced speeds.

2. Dedicated Power Module: Utilized a separate voltage regulator for the

Arduino to ensure stable power despite motor current fluctuations.

3. Randomized Turns & Backup: Incorporated randomized left/right turns

and short backward movements to escape tricky situations.

4. Accurate Obstacle Detection: Calibrated ultrasonic sensor and averaged

multiple readings.

5. Stable Power Supply: Used a rechargeable battery with adequate voltage

to ensure consistent performance.


Conclusion
The fundamental principles of this project extend to numerous real-world and advanced

robotic systems.

Current A pplications

A utomated guided vehicles ( A GVs) in warehouses.

Home cleaning robots (e.g., robotic vacuums).

Educational platforms for robotics and STEM.

Learning Outcomes

Microcontroller Programming: Learned how to program Arduino to process sensor

data and control hardware.

Algorithm Design: Developed obstacle avoidance logic and decision-making flow.

Electronics Skills: Learned to connect, power, and interface sensors, motors, and

drivers for a complete functional system.

Hardware-Software Integration: Experienced combining electronics with code for a

functional robot.

Problem-Solving Skills: Learned to troubleshoot sensor inaccuracies, motor issues,

and power fluctuations.


Thank You.

You might also like