Ahmad Shtaiyat
Download
Report
Transcript Ahmad Shtaiyat
Robot Project
by
Ahmad Shtaiyat
Supervised by Dr. Salem Al-Agtash
Robot: An electromechanical device which is capable of
reacting in some way to its environment, and take
autonomous decisions or actions in order to achieve a
specific task
My robot operation :
It will use Ultrasonic sensors to detect the distances ,
and enable it to move in many degrees then go to the
distance if there is no wall or barrier ,and the distance
larger than 20 cm , if it become less than 20 after
movement then stop , detect the distance in the other
directions then choose the best direction and move .
Is this Robot Mobile Robot ?
It has Mechnical parts ( DC motors , wheels , chasse , H-bridge ,
sensor, servo motor …) , and has Microcontroller (Arduino ) .
Microcontroller receive the information from the sensor , then
according to this information it will determine the distance , then
change the servo angle , then force the sensor to recompute the
distance , then determine the direction of movement .
Force the DC-motor to move
So this Robot function autonomously , it has its own decision
according to the environment sensing , this decision change with
these information directly , it doesn’t keep doing the same task
every time .
According to these four points its mobile Robot not just industrial
one .
Is this Robot Real time system ?
1. Perception :
We sensing the information from the environment using
ultrasonic sensor , which send ultrasound waves with specific
predetermined angle , these wave will be reflected from the
surface when collide with it , then the sensor give us the trigger
time (sending time ) , and the echo time ( receiving time ) .
2. Localization :
The ultrasonic.h library give us a function Ranging(CM) ;
which determine the distance according to the equation :
distance = speed *time .
time = echo time - trigger time .
speed of ultrasonic wave constant in space = 345 m/sec.
this distance represent our location
barrier .
with reference to the
3. Cognition :
According to this distance the microcontroller will
determine the path .
a. while ( distance >= 20 ) : move forward ,
So our path will be forward .
b. while ( distance < 20 ) :
change the angle to left , Then recalculate the distance .
change the angle to right , Then recalculate the distance .
move in the direction of the larger distance .
still doing this until the distance become larger than 20 cm
then go to a and move forward .
4. Motion control :
After the Robot move forward , during walking there is a closed loop , which will
keep taking the measuring distance , still compared it with 20 cm , if it become
less than it , stop then repeat the step 3-b.
Controlled
system
Sensing value , or process value
Microcontroller
Set point (20 CM)
Applications :
Work as cleaning machine .
By adding small camera and register device , we can
use it to collect information ( pictures and sounds)
for locations which we can't reach .
By replace the DC-motors by stepper motors , we
can use it for planting seeds .
Disturbances :
The major problem is when we used it outside the
house , is that the wind , because its weight is too
small .
The code :
As the following code there are four tasks :
Sensing the distance .
Changing the angle .
Determine the direction .
Control the motion
And they operate concurrently
#include <Ultrasonic.h>
#include <NewPing.h>
#include <Servo.h>
unsigned int Time;
unsigned int distance;
unsigned int left1 ;
unsigned int left2 ;
unsigned int right1 ;
unsigned int right2 ;
int IN1 = 3;
int IN2 = 5;
int IN3 = 6;
int IN4 = 9;
int sensor_reading = 0;
Servo myservo;
int A = 0;
Ultrasonic ultrasonic (12, 13);
void setup () {
myservo.attach(10);
pinMode(IN1, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(IN2 , OUTPUT);
pinMode(IN3 , OUTPUT);
pinMode(A0, INPUT);
Serial.println("Robot initialize");
}
void forword() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
delay(50);
}
void background() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
delay(50);
}
void right() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
delay(50);}
void left(){
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
delay(50);}
void STOP()
{
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
delay(50);}
void loop () {
myservo.write(90);
delay(15) ;
sensor_reading = ultrasonic.Ranging(CM);
Serial.print("Distance= ");
Serial.println(sensor_reading);
while (sensor_reading > 20) {
forword();
Serial.print("Distance= ");
Serial.println(sensor_reading);
Serial.println("Forward,distance>20"); }
while (sensor_reading < 20) {
STOP();
myservo.write(165);
left1 = ultrasonic.Ranging(CM);
delay(1000);
myservo.write(135);
left2 = ultrasonic.Ranging(CM);
delay(1000);
if ( (left1 - left2) >= 0);
else left1 = left2 ;
delay(50);
delay(1000);
myservo.write(0);
right1 = ultrasonic.Ranging(CM);
delay(1000);
myservo.write(45);
right2 = ultrasonic.Ranging(CM);
if ( (right1 - right2) >= 0);
else right1 = right2 ;
if ( (left1 - right1) >= 0)
left();
else
right();
sensor_reading = ultrasonic.Ranging(CM);
}
}
Robot parts:
Frame / Platform : I will use Aluminum or Plastics
because these materials are light weight
,moderately and easy to work can also be found at
Home Hardware or I can use Re-purposed
Materials: There are a lot of items around the house
which can be turned into a robot frame.
Motors : Continuous Rotation Servos ( Servos already
have all of the control circuitry built in and are easy to
control; they have 3 wires which represent signal,
Voltage, and ground. By pulsing the signal line you can
go forward, stop, or backward. ) , or Gear motors
( Gear motors will require additional control circuitry
(normally an H-bridge) to allow forward and reverse
motion and in some cases braking. Gear motors can
provide great flexibility but usually cost more
compared to servos)
Wheels : we can use wheels from old toys or buy
wheels from a shop or air-filled wheels for model
aircraft are very easy to use. Note that often wheels
from toys don’t have the right hole size, so we might
have to do some customizing to get them to fit the
motor
Power : Batteries ( we need to decide what type of
batteries to use. It can quickly become very expensive
replacing non-rechargeable batteries. Rechargeable
batteries are really the best and we need
corresponding charger to charge them with , though
there are a number of different types to choose from.)
, and Power supply ( We need a voltage regulator to
drop the voltage from the battery to the 5 volts needed
by the Microcontroller and other parts of the Brain for
the robot )
Microcontroller or brain :
There are three different types of them , Atom
,PIC16F876, Arduino , I will use Arduino :
Arduino: The “newest” contender on the market is
Arduino; it’s open source and there are a LOT of
different versions. It has become wildly popular with
the robotics community and seems to be incredibly
versatile.
Motor driver L298
It's used to control the movement of two motors with
maximum current of two ampere for each of them
Sensors : there is a lot of different sensors according
to their types , manufacture and functionality , but for
my robot I need sensors to sense distance there a lot
of types of them like laser , infrared and ultrasonic , I
will chose the ultrasonic sensor :
Ultrasonic Range Finders: Ultrasonic range finders
use acoustics to measure the time between when a
signal is sent versus when its echo is received
back.
Ultrasonic range finders can measure a range of
distances .
The circuit :
.
Servo :
DC motors :
Ultrasonic sensor :
Thanks