Practical-1: 1. Arduino Software
Practical-1: 1. Arduino Software
Practical-1
2. Proteus Professional
1. Arduino software
Step-1: Open the Arduino software and select the new project.
Step-3: After verifying the program, copy the “hex” file location of the
program.
2. Proteus Professional
Step-1: Open the proteus professional software and select the new
project.
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No: 180210111030
Step-2: Then select the p (p is component) and search the Arduino uno
select and enter.
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No: 180210111030
Step-3: Then after search the LEDs then select and enter.
Step-5: Select the Arduino Uno and program file is the location of
Arduino programming ‘hex’ file copy and paste.
Practical-2
Figure-1: Clockwise
Figure-2: Anti-clockwise
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
Code:
#define Forw1 12
#define Forw2 10
#define Back1 11
#define Back2 9
void setup()
{
pinMode(Forw1,OUTPUT);
pinMode(Back1,OUTPUT);
pinMode(Forw2,OUTPUT);
pinMode(Back2,OUTPUT);
}
void loop()
{
digitalWrite(Forw1,HIGH);
digitalWrite(Back1,LOW);
digitalWrite(Forw2,HIGH);
digitalWrite(Back2,LOW);
delay(5000);
digitalWrite(Forw1,LOW);
digitalWrite(Back1,HIGH);
digitalWrite(Forw2,LOW);
digitalWrite(Back2,HIGH);
delay(5000);
}
Practical-3
Aim: Interface motor driver IC and Stepper motor and write a program to
rotate Motor Clockwise and Anticlockwise also show simulation
Components: Arduino Uno, L293d Motor Driver IC and Stepper Motor
Figure-1: Clockwise
Figure-2: Anti-clockwise
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
Working: When we first start the stimulation, the stepper motor initially
rotates clockwise at 150 rpm. When the push button is pressed the motor
start to rotates anti-clockwise at the same speed.
Code:
int i=0;
void setup()
{
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,INPUT);
}
void loop()
{
if(digitalRead(8)==HIGH)
{
i++;
delay(100);
}
if(i%2==0)
{
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(10,HIGH);
digitalWrite(9,HIGH);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(10,LOW);
digitalWrite(9,HIGH);
delay(50);
digitalWrite(11,HIGH);
Practical-4
Aim: Interface Servo motor and write a program to rotate Motor Clockwise
and Anticlockwise also show simulation.
Components: Arduino Uno and Servo motor
Circuit diagram is shown in the figure.
Figure-1: Anti-clockwise
Figure-2: Clockwise
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
Code:
#include<Servo.h>
Servo servo;
void setup()
{
servo.attach(11);
}
void loop()
{
servo.write(0);
delay(1000);
servo.write(180);
delay(1000);
}
Conclusion: In the above experiment, we learnt how servo motor works with
PWM principle and programmed to rotate clockwise and anti-clockwise.
Practical-5
Aim: Interface Ultrasonic Sensor and DC motor and write a program to move
robot forward and reverse direction based on sensor feedback.
Components: Arduino Uno, L293d Motor driver IC, DC motor and Ultrasonic
sensor.
Figure-1: Forward
Figure-2: Reverse
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
Working: Ultrasonic sensors work by emitting sound waves at a frequency
too high for humans to hear. They then wait for the sound to be reflected
back, calculating distance based on the time required. This is similar to how
radar measures the time it takes a radio wave to return after hitting an object.
Initially motors rotate forward. If ultrasonic sensor senses an object less than
100cm close, then the motors rotate reverse for 1 sec.
Code:
int US;
long readUltrasonicDistance(int triggerPin, int echoPin)
{
pinMode(triggerPin, OUTPUT); // Clear the trigger
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
// Sets the trigger pin to HIGH state for 10 microseconds
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
pinMode(echoPin, INPUT);
// Reads the echo pin, and returns the sound wave travel time in microseconds
return pulseIn(echoPin, HIGH);
}
void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
}
void loop()
{
if((US=0.01723*readUltrasonicDistance(8,7)) >= 100)
{
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
digitalWrite(11,HIGH);
digitalWrite(10,LOW);
}
else
{
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(1000);
}
}
Practical-6
Aim: Interface infrared Sensor and DC motor and write a program to stop
robot if obstacle detected also move robot forward and reverse direction
based on sensor feedback.
Components: Arduino Uno, Infrared sensor, dc motor.
Figure-1: Forward
Code:
void setup()
{
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,INPUT);
}
void loop()
{
if(digitalRead(9)==HIGH)
{
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
delay(1000);
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(1000);
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(1000);
}
else
{
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
digitalWrite(11,HIGH);
digitalWrite(10,LOW);
delay(100);
}
}
Practical-7
Working: Servo Motor has inbuilt library. We only have to give value of
angle. The inputs of potentiometers are divided by 5.6889 which gives the
angle for servo motors in range from 0 to 180 degree.
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
Code:
#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
void setup()
{
servo1.attach(11);
servo2.attach(10);
servo3.attach(9);
}
void loop()
{
servo1.write((analogRead(A0)/5.68889));
delay(100);
servo2.write((analogRead(A1)/5.68889));
delay(100);
servo3.write((analogRead(A2)/5.68889));
delay(100);
}
Practical-8
Working: As shown in the figure, the robotic arm is in the default position.
When the IR sensor detects an object then the arm performs the predefined
action and take the object from the conveyor belt and put it on another place.
Then arm came to default position.
Code:
#include <Servo.h>
Servo base; //Base:
Servo elbow; //Elbow:
Servo actuator; //Actuator:
void setup()
{
base.attach(11);
elbow.attach(10);
actuator.attach(9);
pinMode(8,INPUT); //Infrared Sensor:
//Initially Base is at 90 degree i.e. right side or between object is to be lifted(0 degree)
and placed(180 degree):
//Elbow is vertical i.e. upward at 90 degree:
//Actuator is wide open at 0 degree and closes at 180 degree:
base.write(90);
elbow.write(90);
actuator.write(0);
delay(500);
}
void loop()
{
if(digitalRead(8)==HIGH) //When object is detected at infrared sensor:
{
base.write(0); //Base turns left-side:
delay(1000);
elbow.write(180); //Elbow bends down at 90 degree:
delay(1000);
actuator.write(180); //Actuator holds the object:
delay(1000);
elbow.write(90); //Elbow goes up at 90 degree:
GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
delay(1000);
base.write(180); //Base turns right-side at 180 degree:
delay(1000);
elbow.write(180); //Elbow bends down at 90 degree:
delay(1000);
actuator.write(0); //Actuator opens and release the object:
delay(1000);
elbow.write(90); //Elbow goes up at 90 degree:
delay(1000);
base.write(90); //Base turns left about 90 degree at initial position:
delay(1000);
}
}
Practical-9
Aim: Study and Simulate Forward and inverse kinematics on IITK virtual Lab
Software: IITK Virtual Lab
Introduction: The PUMA 560 is an industrial robot arm with six degrees of freedom
and all rotational joints. In this experiment at first a brief theory about PUMA 560 robot is
presented in the theory section. The theory for mathematical computations was obtained
from a wide variety of sources encompassing books, papers and internet. In simulation
section a virtual model is developed in JavaScript program which is used to investigate
the forward kinematics problem. For more information on other aspects of PUMA 560 and
robotics visitors are advised to follow the references.
1. Forward Kinematics:
Figure 2: Kinematic parameters and frame assignments for the PUMA 560 manipulator.
Figure 3: Kinematic parameters and frame assignments for the forearm of the PUMA 560 manipulator.
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
Figure 4: Schematic of a 3R wrist in which all three axes intersect at a point and are mutually orthogonal.
Simulator:
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
2. Inverse Kinematics:
Given the end-effector position and orientation from Forward kinematics problem, the
inverse kinematics approach is used to obtain the joint angles. But as stated in the
introduction inverse kinematics is more difficult problem than forward kinematics as it
includes much complexity. The relationship between forward and inverse kinematics is
shown in Figure 1. In general, there are two main solution techniques for inverse
kinematics problem one is analytic approach and other is numerical method. Analytic
approach comprises of geometric and algebraic solutions in which joint variables are
solved analytically according to given configuration data.
Simulator:
Figure-2: Solution 1
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
Figure-3: Solution 2
Figure-4: Solution 3
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
Figure-5: Solution 4
Practical-10
Aim: Simulate Autonomous robot movements using ultrasonic sensor and Infrared
Sensor.
Components: Arduino Uno, L293d motor driver, dc motor, Infrared sensor and
Ultrasonic sensor.
Code:
#include <Servo.h>
Servo servo_6;
#define IR 9
int US,left,right;
void setup()
{
servo_6.attach(6);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(IR,INPUT);
}
void loop()
{
servo_6.write(90);
delay(500);
while((US=0.01723*readUltrasonicDistance(8,7)) >= 100)
{
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
digitalWrite(11,HIGH);
digitalWrite(10,LOW);
}
if(digitalRead(IR)!=HIGH)
{
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(1000);
}
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
delay(500);
servo_6.write(180);
delay(500);
left=0.01723*readUltrasonicDistance(8,7);
GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
delay(1000);
servo_6.write(0);
delay(500);
right=0.01723*readUltrasonicDistance(8,7);
delay(1000);
servo_6.write(90);
delay(1000);
if(left>right)
{
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
digitalWrite(10,LOW);
delay(1000);
}
else if(left<right)
{
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(1000);
}
else if(digitalRead(IR)!=HIGH)
{
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(500);
}
left=right=0;
}