Joe Project Robot
Joe Project Robot
TECHNOLOGY WARANGAL
MADE BY:
Rishendra Tiruveedhula 21ECB0B48
Leela Krishna Prasad 21ECB0B47
Rahul Voorugonda 21ECB0B65
Rudra Kalyan 21ECB0B56
ECE(Sec B)
SUBMITTED TO:
Dr. RAVI KUMAR JATOTH
Associate Professor
Dept. of Electronics and Communication Engineering
Contents
• Introduction
• Components
• Circuit Diagram
• Theory
• Code
• Working
• Referred Websites
Introduction
An Obstacle avoiding robot is an intervention of science in
which the robot can avoid obstacles by using ultrasound
sensors and innervate its own path.We proposed a robot that
avoids the obstacle which comes in its path this robot is
introduced because in many of the industries we have seen
that many heavy components which they have to move for
one place to another place which is not possible without the
help of machines. With this we got idea and we introduce the
robot named as Obstacle avoidance robot using Arduino.
Obstacle avoidance robot is design to allow robot to navigate
in unknown environment by avoiding collisions. Obstacle
avoiding robot senses obstacles in the path, avoids it and
resumes its running. The best part of our project is that if any
obstacle is encountered by the robot the robot automatically
stops.
Components
1) Arduino Uno R3
2) Ultrasonic Sensor
3) Motor Driver IC
4) Servo Motor
5) Geared Motors
6) Robot Chassis
7) Power Supply (4 x 1.5V Li-ion Batteries)
1. Arduino Uno R3
The Arduino Uno is an open-source microcontroller board
based on the Microchip ATmega328P microcontroller. The
board is equipped with sets of digital and analog input/output
(I/O) pins that may be interfaced to various expansion boards
(shields) and other circuits. The board has 14 digital I/O pins
(six capable of PWM output), 6 analog I/O pins, and is
programmable with the Arduino IDE (Integrated
Development Environment), via a type B USB cable. It can be
powered by the USB cable or by an external 9-volt battery,
though it accepts voltages between 7 and 20 volts.
Technical Specifications:
• Microcontroller: Microchip ATmega328P
• Operating Voltage: 5 Volts
• Input Voltage: 7 to 20 Volts
• Digital I/O Pins: 14 (of which 6 can provide PWM output)
• UART: 1
• I2C: 1
• SPI: 1
• Analog Input Pins: 6
• DC Current per I/O Pin: 40 mA
• DC Current for 3.3V Pin: 50 mA
• Flash Memory: 32 KB of which 0.5 KB used by bootloader
• SRAM: 2 KB
• EEPROM: 1 KB
• Clock Speed: 16 MHz
PIN DAIGRAM:
2. Ultrasonic Sensor
The ultrasonic sensor (or
transducer) works on the same
principles as a radar system. An
ultrasonic sensor can convert
electrical energy into acoustic
waves and vice versa. The
acoustic wave signal is an
ultrasonic wave traveling at a
frequency above 18kHz. The
famous HC SR04 ultrasonic
sensor generates ultrasonic
waves at 40kHz frequency.
Typically, a microcontroller is used for communication with
an ultrasonic sensor. To begin measuring the distance, the
microcontroller sends a trigger signal to the ultrasonic sensor.
The duty cycle of this trigger signal is 10µS for the HC-SR04
ultrasonic sensor. When triggered, the ultrasonic sensor
generates eight acoustic (ultrasonic) wave bursts and initiates
a time counter. As soon as the reflected (echo) signal is
received, the timer stops. The output of the ultrasonic sensor
is a high pulse with the same duration as the time difference
between transmitted ultrasonic bursts and the received echo
signal.
The microcontroller interprets the time signal into distance
using the following functions:
Theoretically, the distance can be calculated using the TRD
(time/rate/distance) measurement formula. Since the
calculated distance is the distance traveled from the ultrasonic
transducer to the object—and back to the transducer—it is a
two-way trip. By dividing this distance by 2, you can
determine the actual distance from the transducer to the
object. Ultrasonic waves travel at the speed of sound (343 m/s
at 20°C). The distance between the object and the sensor is
half of the distance traveled by the sound wave.[iv] The
following equation calculates the distance to an object placed
in front of an ultrasonic sensor:
3.Motor Driver
A servo motor is a type of motor that
can rotate with great precision.Normally
this type of motor consists of a control
circuit that provides feedback on the
current position of the motor shaft,this
feedback allows the servo motors to
rotate with great precision.
4.Servo motor
A servo motor is a type of motor that
can rotate with great precision.
Normally this type of motor consists
of a control circuit that provides
feedback on the current position of the
motor shaft, this feedback allows the
servo motors to rotate with great
precision.
Working:
It consists of three parts:
1. Controlled device
2. Output sensor
3. Feedback system
It is a closed-loop system where it uses a positive feedback
system to control motion and the final position of the shaft.
Here the device is controlled by a feedback signal generated
by comparing output signal and reference input signal. Here
reference input signal is compared to the reference output
signal and the third signal is produced by the feedback
system. And this third signal acts as an input signal to the
control the device. This signal is present as long as the
feedback signal is generated or there is a difference between
the reference input signal and reference output signal. So, the
main task of servomechanism is to maintain the output of a
system at the desired value at presence of noises.
Controlling:
All motors have three wires
coming out of them. Out of
which two will be used for
Supply (positive and
negative) and one will be
used for the signal that is to
be sent from the MCU.
Servo motor is controlled by
PWM (Pulse with
Modulation) which is
provided by the control wires. There is a minimum pulse, a
maximum pulse and a repetition rate. Servo motor can turn 90
degree from either direction form its neutral position. The
servo motor expects to see a pulse every 20 milliseconds (ms)
and the length of the pulse will determine how far the motor
turns. For example, a 1.5ms pulse will make the motor turn to
the 90° position, such as if pulse is shorter than 1.5ms shaft
moves to 0° and if it is longer than 1.5ms than it will turn the
servo to 180°.
5.Geared Motors
A geared motor is a component whose
mechanism adjusts the speed of the motor,
leading them to operate at a certain speed.
geared motor have the ability to deliver
high torque at low speeds, as the gearhead
functions as a torque multiplier and can
allow small motors to generate higher
speeds.
6.Robot Chassis
Working Principle
When the robot is powered on, both the motors of the robot
will run normally and the robot moves forward. During this
time, the ultrasonic sensor continuously calculate the distance
between the robot and the reflective surface. If the distance
between the robot and the obstacle is less than 15cm, the
Robot stops and scans in left and right directions for new
distance using Servo Motor and Ultrasonic Sensor. If the
distance towards the left side is more than that of the right
side, the robot will prepare for a left turn. But first, it backs up
a little bit (for 300ms) and then activates the Left Wheel
Motor in reversed in direction.Similarly, if the right distance
is more than that of the left distance, the Robot prepares right
rotation. This process continues forever and the robot keeps
on moving without hitting a obstacle.
Code
#include <Servo.h>
#include <AFMotor.h>
#define Echo A1
#define Trig A0
#define motor 10
#define Speed 170
#define spoint 103
char value;
int distance;
int Left;
int Right;
int L = 0;
int R = 0;
int L1 = 0;
int R1 = 0;
Servo servo;
AF_DCMotor M1(1);
AF_DCMotor M2(2);
AF_DCMotor M3(3);
AF_DCMotor M4(4);
void setup() {
Serial.begin(9600);
pinMode(Trig, OUTPUT);
pinMode(Echo, INPUT);
servo.attach(motor);
M1.setSpeed(Speed);
M2.setSpeed(Speed);
M3.setSpeed(Speed);
M4.setSpeed(Speed);
}
void loop() {
Obstacle();
}
void Obstacle() {
distance = ultrasonic();
if (distance <= 12) {
Stop();//The car will stop
backward();//And will move backword from the
//obstractule
delay(100);//Will delay for 0.1 seconds
Stop();
L = leftsee();
servo.write(spoint);
delay(800);//Will delay for 0.8 seconds
R = rightsee();
servo.write(spoint);
if (L < R) {
right();
delay(500);//the car will stop for 0.5 seconds
Stop();
delay(200);//The car will wait for 0.2 seconds
} else if (L > R) {
left();
delay(500);
Stop();
delay(200);
}
} else {
forward();//The car will move forward if there is
//no obstacle
}
}
int ultrasonic() {
digitalWrite(Trig, LOW);
delayMicroseconds(4);
digitalWrite(Trig, HIGH);
delayMicroseconds(10);
digitalWrite(Trig, LOW);
long t = pulseIn(Echo, HIGH);
long cm = t / 29 / 2; //time convert distance
return cm;
}
void backward() {
M1.run(BACKWARD);
M2.run(BACKWARD);
M3.run(BACKWARD);
M4.run(BACKWARD);
}
void forward() {
M1.run(FORWARD);
M2.run(FORWARD);
M3.run(FORWARD);
M4.run(FORWARD);
}
void right() {
M1.run(BACKWARD);
M2.run(BACKWARD);
M3.run(FORWARD);
M4.run(FORWARD);
}
void left() {
M1.run(FORWARD);
M2.run(FORWARD);
M3.run(BACKWARD);
M4.run(BACKWARD);
}
void Stop() {
M1.run(RELEASE);
M2.run(RELEASE);
M3.run(RELEASE);
M4.run(RELEASE);
}
int rightsee() {
servo.write(20);
delay(800);
Left = ultrasonic();
return Left;
}
int leftsee() {
servo.write(180);
delay(800);
Right = ultrasonic();
return Right;
}
Working
Using an external trigger signal, the Trig pin on ultrasonic
sensor is made logic high for at least 10µs. A sonic burst from
the transmitter module is sent. This consists of 8 pulses of
40KHz.
The signals return back after hitting a surface and the receiver
detects this signal. The Echo pin is high from the time of
sending the signal and receiving it. This time can be converted
to distance using appropriate calculations.
When the robot is powered on, both the motors of the robot
will run normally and the robot moves forward. During this
time, the ultrasonic sensor continuously calculate the distance
between the robot and the reflective surface.
Referred Websites:
https://www.electronicshub.org/obstacle-avoiding-robot-
arduino/
https://www.arduino.cc/en/Tutorial/HomePage
https://www.youtube.com/watch?v=jQwYBc7YBXs