3. Control Requirements
-SISO System
• The pendulum should return to its upright
position within 5 seconds (Settling time)
• The position of pendulum should never move
more than 0.05 radians away from the
vertical.
Transfer function model with impulse
input
Dr.R.Subasri,KEC,INDIA
4. Parameters
• mass of the cart (M) :0.5 kg
• mass of the pendulum (m) :0.5 kg
• friction of the cart (b) :0.1 N/m/sec
• length to pendulum center
of mass(l) : 0.3 m
• Inertia of the pendulum (I) : 0.006 kg*m^2
• Force applied to the cart :F
• Cart position coordinate : x
• pendulum angle from vertical :
Dr.R.Subasri,KEC,INDIA
5. Mathematical modeling
• Summing the forces in the Free Body Diagram
of the cart in the horizontal direction
• Summing the forces in the Free Body Diagram
of the pendulum in the horizontal direction
Mx bx N F+ + =
2
N mx mlθcosθ mlθ sinθ= + −
2
(M m)x bx mlθcosθ mlθ sinθ F+ + + − =
First equation of motion:
Dr.R.Subasri,KEC,INDIA
6. • sum the forces perpendicular to the pendulum
• Second equation of motion:
2
(I ml )θ mglsinθ mlxcosθ+ + = −
Linearise the equations about vertical equilibrium angle
( = )
Let represent the deviation of the pendulum's
position from equilibrium, that is = +
Approximations of small angle
sin ( + ) =-
cos ( + ) = -1
Dr.R.Subasri,KEC,INDIA
7. Mathematical modeling
• The two linear equations of motions are:
( )2
I ml φ mglφ mlx
(M m) x bx mlφ u
+ − =
+ + − = Control Force F
replaced by u
Dr.R.Subasri,KEC,INDIA
8. Transfer function model
• Use Laplace transform to derive the transfer
function model
• Where,
2
2
4 3 2
ml
s
φ(s) q
U(s) b(I ml ) (M m)mgl bmgl
s s s s
q q q
=
+ +
+ − −
( )( )2 2
q M m I ml (ml) = + + −
Dr.R.Subasri,KEC,INDIA
9. open-loop response
-transfer function model
• M = .5; m = 0.2; b = 0.1;
• i = 0.006; g = 9.8;
• l = 0.3;
• q = (M+m)*(i+m*l^2)-(m*l)^2; %simplifies input
• num = [m*l/q 0]
• den = [1 b*(i+m*l^2)/q -(M+m)*m*g*l/q -b*m*g*l/q]
output should be:
• num = 4.5455 0
• den = 1.0000 0.1818 -31.1818 -4.4545
Dr.R.Subasri,KEC,INDIA
10. open-loop response
-transfer function model
• To observe the system's velocity response to an
impulse force applied to the cart add the following
lines at the end m-file:
• t=0:0.01:5;
• impulse(num,den,t)
• axis([0 1 0 60])
The response is entirely
unsatisfactory.
It is not stable in open loop.
Dr.R.Subasri,KEC,INDIA
11. Closed loop response-transfer function model
• As the pendulum's position should return to
the vertical after the initial disturbance, the
reference signal should be zero.
• The force applied to the cart can be added as
an impulse disturbance.
Dr.R.Subasri,KEC,INDIA
13. Closed loop Impulse response with PID
• t=0:0.01:5;
• impulse(numc,denc,t)
• axis([0 1.5 0 40])
This response is still
not stable.
Dr.R.Subasri,KEC,INDIA
14. Closed loop Impulse response with PID
• increasing the proportional control (k) ,
k=100;
axis([0, 2.5, -0.2, 0.2])
The settling time is
acceptable at about
2 sec.
The overshoot is high
Dr.R.Subasri,KEC,INDIA
15. Closed loop Impulse response with PID
• increase kd as 20
The overshoot has been
reduced so that the
pendulum does not
move more than 0.05
radians away from the
vertical.
Dr.R.Subasri,KEC,INDIA
16. Control Requirements
-MIMO System
• To control both the pendulum's angle and the
cart's position.
• The cart should achieve it's desired position
within 5 seconds (settling time)
• Rise time under 0.5 seconds.
• Pendulum's overshoot to 20 degrees (0.35
radians), and it should also settle in under 5
seconds.
-State space model with step inputDr.R.Subasri,KEC,INDIA
17. State space model
• After a little algebra, the linearized system
equations can also be represented in state-
space form:
Dr.R.Subasri,KEC,INDIA
18. • R - commanded step input to the cart (step
input of 0.2 m)
• 4 states X– the position and velocity of the
cart and the angle and angular velocity of the
pendulum.
• output y - both the position of the cart and
the angle of the pendulum.
Dr.R.Subasri,KEC,INDIA
19. Open loop response
• M = 0.5; m = 0.2; b = 0.1; i = 0.006; g
= 9.8; l = 0.3;
• p = i*(M+m)+M*m*l^2; %denominator
• A = [0 1 0 0;
0 -(i+m*l^2)*b/p (m^2*g*l^2)/p 0;
0 0 0 1;
0 -(m*l*b)/p m*g*l*(M+m)/p 0];
B = [0; (i+m*l^2)/p; 0; m*l/p];
C = [1 0 0 0; 0 0 1 0];
D = [0;0];
p = eig(A)
Dr.R.Subasri,KEC,INDIA
20. • Eigen Values are
p = 0 -0.1428 5.5651 -5.6041
one right-half-plane pole at 5.5651,the system
is unstable in open loop.
• blue line - the cart's position
• green line - the pendulum's angle.Dr.R.Subasri,KEC,INDIA
25. Linear Quadratic Regulator (LQR) Controller
• The lqr function allows to choose two
parameters, R and Q, which will balance the
relative importance of the input and state in
the cost function to be optimized.
• The simplest case is to assume R=1, and
Q=C'*C.
• Essentially, the lqr method allows for the
control of both outputs. The controller can be
tuned by changing the nonzero elements in
the Q matrix to get a desirable response.
Dr.R.Subasri,KEC,INDIA
26. • The structure of Q, is C'*C
• 1 0 0 0
• 0 0 0 0
• 0 0 1 0
• 0 0 0 0
• The element in the (1,1) position will be used
to weight the cart's position and the element
in the (3,3) position will be used to weight the
pendulum's angle.
Find the K matrix that will give a good controller.
Dr.R.Subasri,KEC,INDIA
27. • x=1;y=1;
• Q=[x 0 0 0; 0 0 0 0; 0 0 y 0; 0 0 0 0];
• R = 1;
• K = lqr(A,B,Q,R)
• Ac = [(A-B*K)];
• Bc = [B];
• Cc = [C];
• Dc = [D]; T=0:0.01:5;
• U=0.2*ones(size(T));
• [Y,X]=lsim(Ac,Bc,Cc,Dc,U,T);plot(T,Y)
Dr.R.Subasri,KEC,INDIA
29. • Using x=5000 and y=100, the following value
of K and step response were found:
• K = -70.7107 -37.8345 105.5298 20.9238
All of the design requirements have been met
with the minimum amount of control effortDr.R.Subasri,KEC,INDIA