辅导案例-EGH445

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
Discrete-time Controller Design:
Cart-Pendulum System
Lab 09 - EGH445 Modern Control - 2020
Electrical Engineering & Robotics (EER)
Queensland University of Technology
September 24, 2020
Important: Demonstration 2
Demonstration 2 requires you to build and demonstrate a complete and working control system
for a discrete time cart-pendulum model in MATLAB/Simulink. Your demonstrations will be
assessed individually and conducted during your usual computer lab session.
Preparation: You are required to create the system outlined in Section 1 and Section 2 of this
computer lab. Read the lab carefully and follow the instructions to complete the control system design.
Demonstration: You will be required to run two scripts and execute two functions created from
this lab. These scripts and functions are listed below and should be used to automatically produce
Figures 4 and 5 from this lab.
ˆ CP_DTSFC_Lin_a_MainFile_yourstudentnumber.m
ˆ CP_DTSFC_Lin_b_MainFile_yourstudentnumber.m
ˆ matexp(A,T,n)
ˆ intmatexpB(A,B,T,n)
You will then be asked a few questions (orally) of increasing complexity to assess your understanding
of the scripts, Simulink models and the concepts used in control system design.
Marking: The marks for the demonstration are allocated as follows: 50% for the scripts, models
and functions (correct expressions in fcn blocks and connections in Simulink model), and 50% for the
questions.
Hint: For more guidance, see Computer Labs 4 - 8. Consider attempting Lab 9 (this lab) before your
in class session so you can use your lab session to refine your scripts and simulation models with help
from the teaching team.
1
Objectives
The objective of this Lab is to design and simulate a state-feedback controller for the cart-pendulum system in
the discrete-time domain using Matlab and Simulink.
1 Inverted pendulum on a cart
The cart-pendulum system is a benchmark that has been widely used to study control system designs. Figure 1
shows the idealised model of the system that consists of a pendulum of mass m and length ` attached to a cart
of mass Mc. The cart moves on the horizontal direction and is actuated by the input force F . The equations
of motion of the system are as follows
(Mc +m) q¨1 +m` cos(q2) q¨2 −m` sin(q2) q˙22 = F, (1)
m` cos(q2) q¨1 +m`
2 q¨2 −mg ` sin(q2) = 0, (2)
where q1 and q2 are the position of the cart and the angle of the pendulum respectively, and g is the gravitational
constant. The state-space model can be written as follows
x˙1
x˙2
x˙3
x˙4
 =

x3
x4
x24`m sin(x2)−gm sin(x2) cos(x2)+F
Mc+m−m cos2(x2)
−`m sin(x2) cos(x2)x24+g(Mc+m) sin(x2)−cos(x2)F
`[Mc+m−m cos2(x2)]
 , (3)
where x1 = q1, x2 = q2, x3 = q˙1 and x4 = q˙2 are the states. We consider the values of the model parameters
given in Table 1.
Table 1: Model parameters.
Parameter value
m 0.15kg
Mc 0.4kg
` 0.2m
g 9.81m/s2
Figure 1: Cart-pendulum system.
2
1.1 Linearised models.
We consider the following equilibrium points of the system (1)-(2):
x¯a =

x¯1a
x¯2a
x¯3a
x¯4a
 =

0
0
0
0
 , x¯b =

x¯1b
x¯2b
x¯3b
x¯4b
 =

0
pi
0
0
 , (4)
where x¯a and x¯b correspond to the pendulum in the upright and down positions respectively, with the cart at
the origin of the coordinate frame.
The linearised model of the cart-pendulum about x¯a is
˙˜xa = Aax˜a +BaF, (5)
y = Cax˜a +DaF, (6)
where
Aa =

0 0 1 0
0 0 0 1
0 −mgMc 0 0
0 g(Mc+m)`Mc 0 0
 ; Ba =

0
0
1
Mc
− 1`Mc
 ; Ca = I4; Da = 04×1.
The linearised model of the cart-pendulum about x¯b is
˙˜xb = Abx˜b +BbF, (7)
y = Cbx˜b +DbF, (8)
where
Ab =

0 0 1 0
0 0 0 1
0 −mgMc 0 0
0 − g(Mc+m)`Mc 0 0
 ; Bb =

0
0
1
Mc
1
`Mc
 ; Cb = I4; Db = 04×1.
2 Discrete-time linear models and state-feedback control
The tasks in this section are:
ˆ Formulate the discrete-time state-space linear models from the continuous-time models for both equilib-
rium points x¯a and x¯b. The general form of a discrete-time state-space linear model is
x(kT + T ) = Gx(kT ) +Hu(kT ), (9)
y(kT ) = Cx(kT ) +Du(kT ). (10)
ˆ Design a controller u(kT ) = −Kdx(kT ) such that the eigenvalues of the characteristic polynomial of
closed-loop dynamics
x(kT + T ) = (G−HKd)x(kT ), (11)
y(kT ) = Cx(kT ) +Du(kT ) (12)
are placed in a desired location.
2.1 Discrete-time control system about x¯a.
Create the script CP_DTSFC_Lin_a_MainFile_yourstudentnumber.m that computes a discrete-time state-space
linear model about x¯a and the controller gain Kd =K_da as follows
a) Define all the values of the model parameters for the linearised model (5)-(6).
b) Compute the matrices Aa, Ba, Ca and Da.
c) Use the command ss to create a continuous-time state-space model. Name the model as sysc.
d) Use the command c2d to create a discrete-time model from sysc. Use sample time T_s=0.03 seconds and
zoh method. Name the model as sysdzoh.
3
e) Consider the desired eigenvalues of the continuous-time closed-loop system λ1 = −3, λ2 = −4, λ3 = −5
and λ4 = −6. Map these eigenvalues to the discrete-time domain.
f) Compute the gain of the controller Kd =K_da such that the eigenvalues of (G−HKd) are placed at the
desired location in the discrete-time domain.
g) Simulate the discrete-time closed loop and the sampled-data continuous-time closed loop:
i) Create a Simulink model of the discrete-time system in closed loop with the state-feedback controller
u(kT ) = −K_dax(kT ). An example of the Simulink model is shown in Figure 2. Hints: use the block
Discrete State-Space, set sample time to T_s for the blocks that require sample time, use the dis-
crete solver and set fixed-step size to T_s. Save your model as CP_DTSFC_Lin_a_yourstudentnumber.slx
ii) Create a Simulink model of the sampled-data continuous-time system in closed loop with the state-
feedback controller and select the control gain K_a=K_da. An example of the Simulink model is
shown in Figure 3. This Simulink model attempts to emulate the behaviour of the continuous-time
plant in closed loop with the discrete-time controller. Hints: use the blocks Rate Transition,
set the sample time to T_s if needed, set the initial conditions of the blocks that require ini-
tial conditions, use fixed-step solver ode4 and select 0.001 as step time. Save your model as
CP_SD_SFC_Lin_a_yourstudentnumber.slx.
iii) Export the states, the control input and the simulation time from Simulink to Matlab.
iv) Simulate both the discrete-time closed-loop system and the sampled-data closed-loop system. Use
the initial condition x(0) =
[
0.2 20pi/180 0 0
]>
.
h) Plot the results of the simulations in a figure that shows the time histories of the position of the cart,
the angle of the pendulum, the velocity of the cart, the angular velocity of the pendulum and the control
force for both the discrete-time control system and the sampled-data control system. Use the command
stem to plot the results of the discrete-time control system, and the command plot for the sampled-data
control system. An example of the simulation results is shown in Figure 4.
In addition, run the script CP_DTSFC_Lin_a_MainFile_yourstudentnumber.m but select T_s=0.05. Compare
the results and analyse the response.
4
Figure 2: Discrete-time control system.
Rate Transition!
Figure 3: Sampled-data continuous-time control system.
5
2.2 Discrete-time control system about x¯b.
Similar to the tasks in Section 2.1, create the script CP_DTSFC_Lin_b_MainFile_yourstudentnumber.m that
computes a discrete-time state-space linear model about x¯b and the controller gain Kd =K_db. Follow the
same steps as in section 2.1, but name the Simulink models: CP_DTSFC_Lin_b_yourstudentnumber.slx and
CP_SD_SFC_Lin_b_yourstudentnumber.slx. An example of the simulation results is shown in Figure 5.
2.3 Discrete-time models using approximation of the matrix exponential.
The task in this section is to create two functions to compute the matrices G and H of the discrete-time model
(9) given the matrices A and B of a linear model. The matrices G and H are defined as
G = eAT , (13)
H =
∫ T
0
eAλdλB. (14)
Use the approximation of the matrix exponential
eAT = I +AT +
1
2!
A2T 2 +
1
3!
A3T 3 +
1
4!
A4T 4 + · · · ,
to create the following functions:
a) matexp(A,T,n): Compute the matrix exponential eAT using an approximation of order n.
b) intmatexpB(A,B,T,n): Compute
∫ T
0
eAλdλB using an approximation of order n for the matrix exponen-
tial eAT .
Compute the matrices G and H for the linearised models of the cart-pendulum about the equilibrium x¯a and
x¯b using the functions matexp(A,T,n) and intmatexpB(A,B,T,n) with n=4. Compare the results with the
matrices obtained using the command c2d.
6
00.5
Ca
rt
po
sit
io
n
[m
] Design Using Linearisation About EPa
0 0.5 1 1.5 2 2.5 3
Time [s]
x1 Discrete-time model
x1 sampled-data model
-20
0
20
Pe
nd
ul
um
a
ng
le
[d
eg
]
0 0.5 1 1.5 2 2.5 3
Time [s]
x2 Discrete-time model
x2 sampled-data model
-0.5
0
0.5
1
1.5
Ca
rt
ve
lo
cit
y
[m
/s]
0 0.5 1 1.5 2 2.5 3
Time [s]
x3 Discrete-time model
x3 sampled-data model
-300
-200
-100
0
100
Pe
nd
ul
um
ra
te
[d
eg
/s]
0 0.5 1 1.5 2 2.5 3
Time [s]
x4 Discrete-time model
x4 sampled-data model
-5
0
5
10
Co
nt
ro
l F
or
ce
[N
]
0 0.5 1 1.5 2 2.5 3
Time [s]
F Discrete-time model
F sampled-data model
Figure 4: Time histories of the states and input.
7
00.1
0.2
Ca
rt
po
sit
io
n
[m
] Design Using Linearisation About EPb
0 0.5 1 1.5 2 2.5 3
Time [s]
x1 Discrete-time model
x1 sampled-data model
-10
0
10
20
Pe
nd
ul
um
a
ng
le
[d
eg
]
0 0.5 1 1.5 2 2.5 3
Time [s]
x2 Discrete-time model
x2 sampled-data model
-0.4
-0.2
0
0.2
Ca
rt
ve
lo
cit
y
[m
/s]
0 0.5 1 1.5 2 2.5 3
Time [s]
x3 Discrete-time model
x3 sampled-data model
-200
-100
0
100
Pe
nd
ul
um
ra
te
[d
eg
/s]
0 0.5 1 1.5 2 2.5 3
Time [s]
x4 Discrete-time model
x4 sampled-data model
-2
0
2
Co
nt
ro
l F
or
ce
[N
]
0 0.5 1 1.5 2 2.5 3
Time [s]
F Discrete-time model
F sampled-data model
Figure 5: Time histories of the states and input.
8

欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468