Professional Documents
Culture Documents
Submitted by:
Faiz Muhammad
I am grateful, first and foremost, to Allah Almighty by whose grace this project has been
completed. Next I wish to acknowledge with gratefulness the expert guidance and help of Dr.
Riaz Akbar Shah. I personally feel that his able and continuous support during the project work
resulted in the completion of this project.
ABSTRACT
This report focuses on the motion control of the three-degree-of-freedom (3-DOF) planar
manipulator of a Robot. To improve the response performance, the proportional-derivative
controller is introduced to the closed-loop system of a Robot. The simulations show that the end
effecter moves along a circular trajectory. The simulation shows that the response speed is
increased and the maximum overshoot, rise time and settling time are also reduced.
List of Abbreviations
ACKNOWLEDGMENT.................................................................................................................ii
ABSTRACT...................................................................................................................................iii
List of Abbreviations......................................................................................................................iv
INTRODUCTION.........................................................................................................................vii
1.1 Robot Manipulator...........................................................................................................vii
1.2 Robot..............................................................................................................................viii
1.3 Laws of Robot................................................................................................................viii
1.4 Industrial Robot..............................................................................................................viii
1.5 Robot types.....................................................................................................................viii
CHAPTER 2...................................................................................................................................ix
CONTROLLER..............................................................................................................................ix
2.1 Introduction.....................................................................................................................ix
2.2 Open-loop step response....................................................................................................x
2.3 Proportional control..........................................................................................................xi
2.4 PD control.......................................................................................................................xiii
2.5 PI control............................................................................................................................xiv
2.6 PID control.....................................................................................................................xvi
CHAPTER 3.................................................................................................................................xix
Description of Manipulator..........................................................................................................xix
3.1 Introduction....................................................................................................................xix
3.2 Forward Kinematics of the Manipulator..........................................................................xx
3.3 Inverse Kinematics of the Manipulator.........................................................................xxii
3.4 CLOSED FORM DYNAMIC EQUATIONS...............................................................xxiii
3.5 The outward iterations..................................................................................................xxiv
3.6 Inward iterations..........................................................................................................xxvii
CHAPTER 4............................................................................................................................xxxvii
Dynamic Simulation and Control............................................................................................xxxvii
4.1 Introduction...............................................................................................................xxxvii
4.2 Feedback and closed loop control............................................................................xxxviii
4.3 Simulation runs.........................................................................................................xxxviii
4.4 Matlab Code.....................................................................................................................xl
4.5 PD Control of End Effector...........................................................................................xliv
5
CHAPTER 5................................................................................................................................xlvi
Discussions and conclusions.......................................................................................................xlvi
REFERENCES...........................................................................................................................xlvii
CHAPTER 1
INTRODUCTION
1.1 Robot Manipulator
An industrial robot is comprised of a robot manipulator, power supply, and controllers. The robot
manipulator can be divided into two sections, each with a different function:
Arm and Body - The arm and body of a robot are used to move and position parts or tools
within a work envelope. They are formed from three joints connected by large links.
Wrist The wrist is used to orient the parts or tools at the work location. It consists of two or
three compact joints.
The robot manipulator is created from a sequence of link and joint combinations. The links are the rigid
members connecting the joints, or axes. The axes are the movable components of the robot that cause
relative motion between adjoining links. The mechanical joints used to construct the manipulator consist
of five principal types. Two of the joints are linear, in which the relative motion between adjacent links is
non-rotational, and three are rotary types, in which the relative motion involves rotation between links.
The arm-and-body section of the manipulator is based on one of four configurations. Each of these
anatomies provides a different work envelope and is suited for different applications.
Gantry - These robots have linear joints and are mounted overhead. They are also called
Cartesian and rectilinear robots.
Cylindrical - Named for the shape of its work envelope, cylindrical anatomy robots are fashioned
from linear joints that connect to a rotary base joint.
Polar - The base joint of a polar robot allows for twisting and the joints are a combination of
rotary and linear types. The work space created by this configuration is spherical.
Jointed-Arm - This is the most popular industrial robotic configuration. The arm connects with a
twisting joint, and the links within it are connected with rotary joints. It is also called an
articulated robot.
1.2 Robot
A robot is an automatically guided machine, able to do tasks on its own. Another common characteristic
is that by its appearance or movements, a robot often conveys a sense that it has intent or agency of its
own.
applications
of
robots
include welding,
painting,
place, packaging and palletizing, product inspection, and testing, all accomplished with high endurance,
speed, and precision.
programmed routines that specify the direction, acceleration, velocity, deceleration, and distance of a
series of coordinated motions.
CHAPTER 2
CONTROLLER
2.1 Introduction
The three-term controller
The transfer function of the PID controller looks like the following:
(2)
Where Kp is the proportional gain, Ki is the integral gain, and Kd is the derivative gain. First, let's take a
look at the effect of a PID controller on the closed-loop system using the schematic above. To begin, the
variable e is the tracking error or the difference between the desired reference value (r) and the actual
output (y). The controller takes this error signal and computes both its derivative and its integral. The
signal which is sent to the actuator (u) is now equal to the proportional gain (Kp) times the magnitude of
the error plus the integral gain (Ki) times the integral of the error plus the derivative gain (Kd) times the
derivative of the error.
Generally speaking, for an open-loop transfer function which has the canonical second-order form of?
1
y +2 W R +W 2R
2
10
a large Kp will have the effect of reducing the rise time and will reduce (but never eliminate) the steadystate error. Integral control (Ki) will have the effect of eliminating the steady-state error, but it will make
the transient response worse. If integral control is to be used, a small Ki should always be tried first.
Derivative control will have the effect of increasing the stability of the system, reducing the overshoot,
and improving the transient response. The effects on the closed-loop response of adding to the controller
terms Kp, Ki and Kd are listed in table form below.
CL RESPONSE
RISE TIME
OVERSHOOT
SETTLING TIME
S-S ERROR
Kp
Decreases
Increases
No Change
Decreases
Ki
Decreases
Increases
Increases
Eliminates
Kd
No Change
Decreases
Decreases
No Change
Note that these correlations are not exactly accurate, because Kp, Ki, Kd are related to each other.
Changing one of these variables can change the effect of the other two. For this reason, the table should
only be used as a reference when you are determining the values for Ki, Kp and Kd by trial & error.
Let's first view the open-loop step response. To model this system into Matlab, create a new m-file and
add in the following code:
num=1;
den=[1 10 20];
step(num,den)
11
Figure:
The DC gain of the plant transfer function is 1/20, so 0.05 is the final value of the output for a unit step
input. This corresponds to a steady-state error of 0.95, quite large indeed. Furthermore, the rise time is
about one second, and the settling time is about 1.5 seconds. Most likely, this response will not be
adequate. Therefore, we need to add some control.
12
Now, the rise time has been reduced and the steady-state error is smaller, if greater Kp is used a, the rise
time and steady-state error will become even smaller. Change the Kp value in the m-file:
Kp=500;
Rerun the m-file and we should get the following plot:
It is clear that the rise time is now about 0.1 second and the steady-state error is much smaller. But the
overshoot has gotten very large. From this example shows that a large proportional gain will reduce the
steady-state error but at the same time, worsen the transient response. For a small overshoot and a small
steady-state error, a proportional gain alone is not enough.
13
2.4 PD control
The rise time is now probably satisfactory (rise time is about 0.1 second). Now let's add a derivative
controller to the system to see if the overshoot can be reduced. Add another variable, Kd, to the m-file, set
it equal to 10 and rerun the m-file:
Kp=500;
Kd=10;
numc=[Kd Kp];
[numCL, denCL]=cloop(conv(num,numc),den);
step(numCL, denCL,t)
The overshoot is much less than before. It is now only twenty percent instead of almost forty-five percent.
It can be improved further more. By increasing Kd to 100, the overshoot will be eliminated completely.
14
The above system is with a fast rise time and no overshoot. Unfortunately, there is still about a 5 percent
steady-state error. It would seem that a PD controller is not satisfactory for this system. Let's try a PI
controller instead.
2.5 PI control
As proportional control will reduce the steady-state error, but at the cost of a larger overshoot.
Furthermore, proportional gain will never completely eliminate the steady-state error. For that integral
control is required. Let's implement a PI controller and start with a small Ki. Lets go back to the m-file
and change it so it looks like the following (note that t input is removed from the step command so more
of the response can be seen):
Kp=500;
Ki=1;
Kd=0;
numc=[Kd Kp Ki];
denc=[1 0];
[numCL, denCL]=cloop(conv(num,numc),conv(den,denc));
step(numCL, denCL)
The Ki controller really slows down the response. The settling time becomes more than 500 seconds. To
reduce the settling time, we can increase Ki, but by doing this, the transient response will get worse (e.g.
large overshoot). Try Ki=10, by changing the Ki variable. The plot can be seeing better if
an axis command is added after the step response. The m-file should now look like the following:
15
Kp=500;
Ki=10;
Kd=0;
numc=[Kd Kp Ki];
denc=[1 0];
[numCL, denCL]=cloop(conv(num,numc),conv(den,denc));
step(numCL, denCL)
axis([0 100 0 1.5])
Now it has a large overshoot again, while the settling time is still long. To reduce settling time and
overshoot, a PI controller by itself is not enough.
16
numc=[KD KP KI];
denc=[1 0];
[numCL, denCL]=cloop(conv(num,numc),conv(den,denc));
Step (numCL, denCL)
The settling time is much shorter, but still not small enough. Increase Ki to 500 and change
the step command to step(numCL, denCL,t):
17
Now the settling time reduces to only 1.5 seconds. This is probably an acceptable response for this
system. To design a PID controller, the general rule is to add proportional control to get the desired rise
time, add derivative control to get the desired overshoot, and then add integral control (if needed) to
eliminate the steady-state error.
PID Examples
Cruise control, DC Motor, Bus Suspension, Inverted pendulum
18
CHAPTER 3
Description of Manipulator
3.1 Introduction
This is a two link planar manipulator as shown in the figure. All mass exists as a point mass at the distal
end of each link. A separate motor through a gearbox powers each link. The base is fixed to the ground.
Various symbols used are defined as follows.
M 1 MASS OF LINK 1
M 2 MASS OF LINK 2
M 3 MASS OF LINK 3
LI LENGTH OF LINK 1
L 2 LENGTH OF LINK 2
L3 LENGTH OF LINK 3
DH TABLE
I
1
2
3
4
i-1
0
0
0
0
i
1
2
3
0
di
0
0
0
0
ai-1
0
L1
L2
L3
19
C1 S1
S1 C1
0
0
0
0
0
0
1
0
C2 S2
S 2 C2
0
0
0
0
0 L1
0 0
1 0
0 1
0
0
0
1
T1 =
T2 =
T3 =
c3 -s3 0 l2
S3 c3 0 0
0 0
1 0
0 0 0
T3 = 1T2. 2T3 =
T3 = 0T1. 1T3 =
T4 =
1 0 0 l3
0 1 0 0
0 0 1 0
0 0 0 1
20
T4 = 1T3. 3T4 =
T4 = 0T1. 1T4 =
c123 -s123 0 Px
S123 c123 0 Py
0
Where
r11=c1c2-s1s23=+c123
r12=-c1s23-s1c23=-s123
r13=0
PX=r14=c1 (c23L3+c2L2+L1)-s1 (L3s23+s2L2)
r21=s1c23+c1s23=s123
r22=-s1s23+c1c23=c123
r23=0
Py=r24=s1 (c23L3+c2L2+L1) +c1 (L3s23+s2L2)
r31=0, r32, r33=1, r34=0
r41=0, r42=0, r43=0, r44=1
Let
PX=X
Py=Y
and from 0T3
X=l2c12+l1c1
Y=l2s12+l1s1
21
( X 2 Y 2 L12 L 2 2 )
2.L1.L 2
S2 1 C22
2 ATAN 2( S 2, C 2)
1 ATAN 2(Y , X ) ATAN 2( K 2, K1)
Where
K1 L1 L 2.C 2
K 2 L 2.S 2
C=C123
S=S123
=1 + 2+ 3
=atan2(S, C)
22
PC1 L1 X 1
PC2 L 2. X 2
I1 0
C2
I2 0
0 0
including gravity
0 .
v 0 g .Y 0
3Pc3=L3X
f i force exerted on link i by link i 1
n i torque exerted on link i by link i 1
23
0
w1 0
.
1
0
w1 0
..
1
1 .
gS1
v1 gC1
0
1 .
0
w1 0
.
1
1 .
v C1
F1
L1. 12 g .S1
..
L1. 1 gC1
.
m2.L1. 1 m2.gC1
0
N1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3^2+
m2*l1*l2*c2 ,m3*l3^2+m3*l2*l3*c3-m3*l1*l3*s2*s3+m3*l1*l3*c2*c3(m3*l2*l3*s3- m3*l1*l3*c2*s3)
(thetadot1+thetadot2+thetadot3)^2+(m3*l2*l3*s2-m3*l2^2*c3*s3+m3*l2^2*c3*s2m3*l1*l2*s2*c3^2
-m2*l1*l2*s2-m3*l1*l2*s2^2*s3+m3*l1*l2*c2*c3*s3+m3*l1*l2*c2*c3*s2)
(thetadot1+thetadot2)^2
+(m3*l2*l3*s3+m3*l1*l3*c3*s2+m2*l1*l2*s2m3*l1*l2*c2*s3+m3*l1*l2*s2*s3^2+m3*l1*l2*c3^2*s2+
m3*l1*l2*s3*c3-m3*l1^2*s2*c3^2+m3*l1^2*s2^2*c3*s3-m3*l1^2*c2*s3^2m3*l1^2*s2^2*c3*s3m3*l1^2*c2*c3*s3+m3*l1^2*c2*s2*s3^2+m3*l1^2*c2*c3*s3+m3*l1^2*c2*c3^2
*s2+m2*l1^2*c2*s2)
(thetadot1^2)+ (-m3*l3*s3+m3*l1*s2*c3^2+m2*l1*s2+m3*l1*s2*s3^2)*(g*s12)+
(m3*l3*c3+m2*l2
+m3*l2*s3^2+m3*l2*c3^2+m3*l1*c2*s3^2+m3*l1*c2*c3^2+m2*l1*c2)*(g*c(thet
a1+theta2)+
m1*l1*g*c1
Extracting the Z component we find the joint torques :
The Dynamic equations can be written in the form
..
M ( ) V ( , ) G ( ) F ( , )
34
where
M ( ) n n mass matrix
.
F ( , ) friction terms
The friction term consists of both the viscous friction and coulomb friction.
We have
M( )=[m3*l3^2+2(m3*l2*l3*c3)+m2*l2^2+m3*l2^2*s3^2+m3*l2^2*c3^22(m3*s2*s3*l1*l3)+m3*l1*l3*c2*c3+m2*l1*l2*c2+
m3*l1*l2*c2*s3^2+m3*c3*c2*c3*l1*l2+m1*l1^2+m3*l1^2*c3^2*s2*s2+m2*l1^2*s2^2+m3*l
1^2*s2^2*s3^2+
m3*l1^2*s3*s3*c2*c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2*c3^2*s2+m2*l1^2*c2*s2)
(thetadot1^2); (-m3*l2*l3*s3)
(thetadot1+thetadot2+thetadot3)^2+ (m3*l2*l3*s2m3*l2^2*c3*s3+m3*l2^2*c3*s2)(thetadot1+thetadot2)^2
+(m3*l3*L2*s3+m3*l3*L1*c3*s2+m2*l1*L2*s2+m3*l1*L2*s2*s3^2+
m3*l1*L2*c3^2*s2)(thetadot1^2);
(m3*l2*l3*s2)(thetadot1+thetadot2)^2+(m3*l1*l3*c3*s2+m3*l2*l3*s3)
(thetadot1^2)];
G()=[(-m3*l3*s3+m3*l1*s2*c3^2+m2*l1*s2+m3*l1*s2*s3^2)*(g*s12)+
(m3*l3*c3+m2*l2+m3*l2*s3^2+m3*l2*c3^2+m3*l1*c2*s3^2+
m3*l1*c2*c3^2+m2*l1*c2)*(g*c(theta1+theta2)+ m1*l1*g*c1; -m3*l3*s3*g*s12+
(m3*l3*c3+m2*l2+m3*l2*s3^2+m3*l2*c3^2)
(g*c(theta1+theta2); m3*l3*c3*g*cos(theta1+theta2)-m3*l3*s3*g*s(theta1+theta2)];
Motor torque or theoretical Torque for a link pivoted at the end is given by:
t (J m
.
..
M . g .L
ML2 ..
Sin
m Cm m
m
2
2
N
N
N
N t N 2 J m N 2 C m
Where
36
Jo int torque
..
Jo int acceleration
.
Jo int velocity
Jo int angle
J m Inertia cons tan t for motor
C m Friction cons tan t for motor
N Gear ratio
g gravitational cons tan t
37
CHAPTER 4
Dynamic Simulation and Control
4.1 Introduction
To simulate the motion of the manipulator we make use of the dynamics model just developed.
Simulation requires solving the dynamic equation for acceleration. We then use Euler
Integration to integrate the acceleration to compute future positions and velocities. Putting all
things together from previous equations, The final system Dynamics model is as follows.
N12 J m1
..1 M ( )
0
2
..
2
N 2 J m2
.
N 12
2
V
(
1
,
1 G ( 1) N1 C m1
1
N 2 2 2 V ( 2, .2 G ( 2)
0
2
N 2 Cm2
-1
1
2
3
(( N 1)2 Jm 1 )
0
0
= M() +
V ( 3 , 3)
G( 3)
0
0
(N 2) 2 Jm2
0
0
(N 3)2 Jm 3
(N 1) 2 1
(N 2) 2 2
(N 3) 2 3
(N 1) 2 cm1
0
0
0
(N 2) 2 cm2
0
0
0
( N 3)2 cm3
1
2
3
(0) 0
.
(0) 0
38
.1
2
..
(t t ) (t ) (t )t
.
1 ..
(t t ) (t ) (t )t (t )t 2
2
d
.
The control system computes how much current to send to the motor as a function of the servo error
.
i k p k d
t i.k t
where k t is the motor cons tan t and depends on the size and watage of motor
39
Cm1 = 0.1
Cm2 = 0.1
Cm3 = 0.1
Jm1 = 0.01
Jm2 = 0.01
Jm3 = 0.01
M1 = 1 kg
M2 = 0.5 kg
M3=0.5kg
g = 9.8 m/s2
Kt = 10
L1 = 1 m
L2 = 2 m
L3=1m
KP = 100
L3
Kd =0.5
L2
L1
Initial position of the manipulator
40
thetadot1=0;
thetadot2=0;
figure
for index=2:22
x=[2.121 2.002 1.723 1.414 1.105 .826 .605 .463 .414 .463 .605 .826 1.105 1.414 1.723
2.002 2.223 2.365 2.441 2.365 2.223 2.121 2.002 ];
y=[2.121 2.223 2.365 2.414 2.365 2.223 2.002 1.723 1.414 1.105 0.826 0.605 0.463 0.414
0.463 0.605 0.826 1.105 1.414 1.723 2.002 2.121 2.233 ];
c2=(x(index)^2+y(index)^2-l1^2-l2^2)/(2*l1*l2);
s2=sqrt(1-c2^2);
theta2=atan2(s2,c2);
theta1=atan2(y(index),x(index))- atan2(l2*s2,l1+l2*c2);
locationx(index-1)=l1*cos(theta1)+l2*cos(theta1+theta2);
locationy(index-1)=l1*sin(theta1)+l2*sin(theta1+theta2);
%savingx(index-1)=theta1*57.3
%savingy(index-1)=theta2*57.3
M=[l2^2*m2+2*l1*l2*m2*c2+l1^2*(m1+m2) , l2^2*m2+l1*l2*m2*c2 ;
l2^2*m2+l1*l2*m2*c2 ,l2^2*m2];
42
V=[ -m2*l1*l2*s2*theta2^2-2*m2*l1*l2*s2*thetadot1*thetadot2;
m2*l1*l2*s2*thetadot1 ];
G=[m2*l2*g*cos(theta1+theta2)+(m1+m2)*l1*g*cos(theta1);
m2*l2*3*cos(theta1+theta2)];
thetae1=theta1-thetac1;
thetae2=theta2-thetac2;
thetae1r(index-1)=thetae1;
thetae2r(index-1)=thetae2;
thetadote1=(thetaep1-thetae1)/t;
thetadote2=(thetaep2-thetae2)/t;
current1=kp*thetae1+kd*thetadote1;
current2=kp*thetae2+kd*thetadote2;
torque1=current1*kt;
torque2=current2*kt;
43
thetadotdot1=thetadotdot(1);
thetadotdot2=thetadotdot(2);
thetadot1=thetadot1+thetadotdot1*t;
thetadot2=thetadot2+thetadotdot2*t;
theta1=theta1+thetadot1*t+0.5*thetadotdot1*t^2;
theta2=theta2+thetadot2*t+0.5*thetadotdot2*t^2;
savingx(index-1)=l1*cos(theta1)+l2*cos(theta1+theta2);
savingy(index-1)=l1*sin(theta1)+l2*sin(theta1+theta2);
thetac1=theta1;
thetac2=theta2;
thetaep1=thetae1;
thetaep2=thetae2;
end
%plot(thetae1r);
%hold on
%plot(thetae2r,'r');
plot(savingx,savingy);
hold on
plot(x,y,'r');
%hold on
%plot(differencex,differencey,'r');
44
%location=[(locationx)',(locationy)']
4.5 PD Control of End Effector
The rise time is about 0.001 second. Now let's add a derivative controller to the system ,the overshoot
can be reduced. Add variable, Kd, kp to the m-file, set it equal to 0.5 and 100 respectively and rerun the
m-file:
45
46
CHAPTER 5
Discussions and conclusions
In developing the model i made many assumptions, which in real life will require more
considerations. Some of these assumptions are
a) Stiffness is not considered.
b) It is assumed that friction and inertia terms will remain constant.
c) Noise in the control system is not considered
d) Environmental and surrounding external effects are not considered
In order to eliminate the steady-state error a modification should be made to the controller. This
involves the addition of an integral term to the controller so that the system will have no steady state
error.
The value of Kd is selected so that the error is minimal. Plot of Error Vs Kd is shows that for a value
of Kd=1.05 the error is minimum, corresponding to Kp = 100.
47
REFERENCES
1. R K Mittal and I J Nagrath, Robotics and Control.
2. Benjamin KUO , Automatic Control
3. John J. Craig, Introduction to Robotics mechanics and control
4. Prof. Hamid D. Taghirad, Robotics: Evolution, technology and applications
48