Control Tutorials For MATLAB and Simulink - Inverted Pendulum - System Modeling
Control Tutorials For MATLAB and Simulink - Inverted Pendulum - System Modeling
http://ctms.engin.umich.edu/CTMS/index.php?example=InvertedPendulum§ion=SystemModeling 1/11
12/22/2015 Control Tutorials for MATLAB and Simulink - Inverted Pendulum: System Modeling
SYSTEM
Key MATLAB commands used in this tutorial are: tf, ss, set
CONTROL
PID
Contents
ROOT LOCUS
Problem setup and design requirements
FREQUENCY
Force analysis and system equations
DIGITAL
unstable without control, that is, the pendulum will simply fall over if
the cart isn't moved to balance it. Additionally, the dynamics of the
system are nonlinear. The objective of the control system is to
figure below. For this system, the control input is the force that
moves the cart horizontally and the outputs are the angular position
http://ctms.engin.umich.edu/CTMS/index.php?example=InvertedPendulum§ion=SystemModeling 2/11
12/22/2015 Control Tutorials for MATLAB and Simulink - Inverted Pendulum: System Modeling
For the PID, root locus, and frequency response sections of this
move more than 0.05 radians away from vertical after being
disturbed by an impulse of magnitude 1 Nsec. The pendulum will
initially begin in the vertically upward equilibrium, = .
http://ctms.engin.umich.edu/CTMS/index.php?example=InvertedPendulum§ion=SystemModeling 3/11
12/22/2015 Control Tutorials for MATLAB and Simulink - Inverted Pendulum: System Modeling
position within 5 seconds and have a rise time under 0.5 seconds.
It is also desired that the pendulum settle to its vertical position in
under 5 seconds, and further, that the pendulum angle not travel
more than 20 degrees (0.35 radians) way from the vertically upward
position.
(1)
Note that you can also sum the forces in the vertical direction for
(2)
If you substitute this equation into the first equation, you get one of
the two governing equations for this system.
(3)
To get the second equation of motion for this system, sum the
forces perpendicular to the pendulum. Solving the system along
this axis greatly simplifies the mathematics. You should get the
following equation.
(4)
To get rid of the and terms in the equation above, sum the
(5)
(6)
since under control we desire that the pendulum not deviate more
than 20 degrees from the vertically upward position. Let
represent the deviation of the pedulum's position from equilibrium,
(7)
(8)
(9)
(10)
(11)
1. Transfer Function
(12)
(13)
(14)
(15)
(16)
where,
http://ctms.engin.umich.edu/CTMS/index.php?example=InvertedPendulum§ion=SystemModeling 6/11
12/22/2015 Control Tutorials for MATLAB and Simulink - Inverted Pendulum: System Modeling
(17)
From the transfer function above it can be seen that there is both a
pole and a zero at the origin. These can be canceled and the
transfer function becomes the following.
(18)
(19)
2. StateSpace
(20)
(21)
The matrix has 2 rows because both the cart's position and the
MATLAB representation
1. Transfer Function
M = 0.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;
s = tf('s');
inputs = {'u'};
outputs = {'x'; 'phi'};
set(sys_tf,'InputName',inputs)
set(sys_tf,'OutputName',outputs)
sys_tf
sys_tf =
1.045e-05 s
phi: -----------------------------------------------------
http://ctms.engin.umich.edu/CTMS/index.php?example=InvertedPendulum§ion=SystemModeling 8/11
12/22/2015 Control Tutorials for MATLAB and Simulink - Inverted Pendulum: System Modeling
2. StateSpace
M = .5;
m = 0.2;
b = 0.1;
I = 0.006;
g = 9.8;
l = 0.3;
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];
sys_ss = ss(A,B,C,D,'statename',states,'inputname',inputs,
sys_ss =
a=
b=
u
x 0
x_dot 1.818
phi 0
phi_dot 4.545
c=
x x_dot phi phi_dot
x 1 0 0 0
phi 0 0 1 0
d=
u
x 0
phi 0
sys_tf = tf(sys_ss)
sys_tf =
x: --------------------------------------
s^4 + 0.1818 s^3 - 31.18 s^2 - 4.455 s
4.545 s - 1.277e-16
http://ctms.engin.umich.edu/CTMS/index.php?example=InvertedPendulum§ion=SystemModeling 10/11
12/22/2015 Control Tutorials for MATLAB and Simulink - Inverted Pendulum: System Modeling
4.545 s - 1.277e-16
phi: ----------------------------------
s^3 + 0.1818 s^2 - 31.18 s - 4.455
Examining the above, note the existance of some terms with very
small coefficients. These terms should actually be zero and show
up due to numerical roundoff errors that accumulate in the
http://ctms.engin.umich.edu/CTMS/index.php?example=InvertedPendulum§ion=SystemModeling 11/11