Tuesday 7 November 2017

Obstacle Avoiding Robot using Arduino

Robotics is an interesting and fast growing field. Being a branch of engineering, the applications of robotics are increasing with the advancement of technology.
The concept of Mobile Robot is fast evolving and the number of mobile robots and their complexities are increasing with different applications.
There are many types of mobile robot navigation techniques like path planning, self – localization and map interpreting. An Obstacle Avoiding Robot is a type of autonomous mobile robot that avoids collision with unexpected obstacles.
In this project, an Obstacle Avoiding Robot is designed. It is an Arduino based robot that uses Ultrasonic range finder sensors to avoid collisions.

Circuit Diagram




Hardware Required

  • Arduino Uno
  • Ultrasonic Range Finder Sensor – HC – SR04
  • Motor Driver IC – L293D
  • Motors x 2
  • Robot Chassis

Component Description

Arduino Uno

Arduino Uno is an ATmega 328p Microcontroller based prototyping board. It is an open source electronic prototyping platform that can be used with various sensors and actuators.
Arduino Uno has 14 digital I/O pins out of which 6 pins are used in this project.

HC – SR04

It is an Ultrasonic Range Finder Sensor. It is a non-contact based distance measurement system and can measure distance of 2cm to 4m.

L293D

It is a motor driver which can provide bi-directional drive current for two motors.

Design of Obstacle Avoiding Robot using Arduino

Arduino is the main processing unit of the robot. Out of the 14 available digital I/O pins, 6 pins are used in this project design.
The ultrasonic sensor has 4 pins: Vcc, Trig, Echo and Gnd. Vcc and Gnd are connected to the supply pins of the Arduino. Trig is connected to the 11th pin and Echo is connected to 10th pin of the Arduino.
L293D is a 16 pin IC. Pins 1 and 9 are enable pins. They are connected to Vcc. Pins 2 and 7 are control inputs from microcontroller for first motor. They are connected to pins 9 and 8 of Arduino respectively.
Similarly, pins 10 and 15 are control inputs from microcontroller for second motor. They are connected to pins 4 and 3 of Arduino. Pins 4, 5, 12 and 13 of L293D are ground pins and are connected to Gnd.
First motor (consider this as the motor for left wheel) is connected across the pins 3 and 6 of L293D. The second motor, which acts as the right wheel motor, is connected to 11 and 14 pins of L293D.
The 16th pin of L293D is Vcc1. This is connected to 5V Vcc. The 8th pins is Vcc2. This is the motor supply voltage. This can be connected anywhere between 4.7V and 36V. In this project, pin 8 if L293D is connected to 9V supply.
Motor Driver boards are available with on – board 5V voltage regulator. A similar one is used in the project.

Working

Before going to working of the project, it is important to understand how the ultrasonic sensor works. The basic principle behind the working of ultrasonic sensor is as follows:
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.
The aim of this project is to implement an obstacle avoiding robot using ultrasonic sensor and Arduino. All the connections are made as per the circuit diagram. The working of the project is explained below.
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.
This information is processed by the Arduino. If the distance between the robot and the obstacle is less than 15cm, the left wheel motor is reversed in direction and the right wheel motor is operated normally.
This will rotate the robot towards right. This rotation continues until the distance between the robot and any obstacle is greater than 15cm. The process continues forever and the robot keeps on moving without hitting any obstacle.

Project Code:

const int trigPin = 11;
const int echoPin = 10;
const int in1 = 9;
const int in2 = 8;
const int in3 = 4;
const int in4 = 3;


void setup() 
{
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode (in1, OUTPUT);
  pinMode (in2, OUTPUT);
  pinMode (in3, OUTPUT);
  pinMode (in4, OUTPUT);
}
long duration, distance;

void loop()
{     
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);  
  duration = pulseIn(echoPin, HIGH);
  distance = duration/58.2;
  if(distance<15)
    {
      digitalWrite(in1, LOW); 
      digitalWrite(in2, HIGH); 
      digitalWrite(in3, HIGH); 
      digitalWrite(in4, LOW);
    }
  else
    {
      digitalWrite(in1, HIGH); 
      digitalWrite(in2, LOW); 
      digitalWrite(in3, HIGH); 
      digitalWrite(in4, LOW);
    }  
  delay(50);
}


NOTE
  • As the project is based on Arduino, the programming is very easy and can be easily modified.
  • Doesn’t require the Arduino Motor Shield.
  • When using a 9V battery, at least 2 such batteries are needed to power the robot. It is better to use 3 9V batteries (one for Arduino and ultrasonic sensor, one for L293D and other for motors).
  • The ultrasonic sensor should not be connected directly to power supply as it might affect the normal performance.
  • Additionally, a servo motor can be fixed to the ultrasonic sensor and only ultrasonic sensor rotates according to the servo. Based on the distance, the entire robot rotates.
  • Instead of ultrasonic sensor, an IR transmitter – receiver pair can also be used.

Applications

  • Obstacle avoiding robots can be used in almost all mobile robot navigation systems.
  • They can be used for household work like automatic vacuum cleaning.
  • They can also be used in dangerous environments, where human penetration could be fatal.

0 comments:

Post a Comment