ES158_Lab3_final

ES158
Feedback Control System
Lab 3
Fall 2015
Name:_____________________________________ Date:_________________
ES 158 Lab 3: Inverted Pendulum on a Cart
Objectives:
 Model an inverted pendulum cart system
 Use Simulink to implement open loop system
 Analyze stability of system using root locus, Bode, and Nyquist techniques
 Analyze controllability and observability of system
********************************************************************************************
MATLAB Values for Model Setup
g = 9.81;
mp = 0.230;
l = 0.6413;
r = l/2;
J = (1/3)*mp*l^2;
γ = 0.0024;
mc = 0.38;
c = 0.90;
%
%
%
%
%
%
%
%
g accel [m/s^2]
mass of pendulum [kg]
length of pendulum [m]
radius to COM of pendulum [m]
inertia of pendulum rotating about 1 end [kg-m^2]
pendulum damping [N-m*s]
mass of cart [kg]
cart damping [N-s/m]
*******************************************************************************************
1.a Modeling The System
Using Newtonian or Lagrangian mechanics, we can find the equations of motion
for our inverted pendulum system. We can construct two equations that consist
of terms involving the desired states
for our system, where is the
horizontal displacement of the cart and is the angular displacement of the
pendulum.
Figure 1: Inverted pendulum and cart system.
Page 1 of 5
ES158
Feedback Control System
Lab 3
Fall 2015
The nonlinear equations of motion for the cart-pendulum are:
where mc and mp are the mass of the cart and the pendulum respectively, r is the
length of the pendulum, is the moment of inertia about the center of mass of the
pendulum, the acceleration due to gravity, and are damping coefficients. θ
is defined as the deviation of the pendulum from the vertical (θ = 0 is in the
inverted standing position).
To model this system in state-space form, we linearize the system about the
equilibrium point (θ = 0). Thus, the equations of motion become:
If we choose our state vector to be:
What are the open-loop A, B, C, and D matrices? The hardware on the
inverted cart pendulum limits us to observing the position of the cart and the
angle of the pendulum.
Page 2 of 5
ES158
Feedback Control System
Lab 3
Fall 2015
1.b Stability Analysis
Open up a script in MATLAB and create a state-space model using the A, B, C,
and D matrices you calculated above. Use the numerical values for the relevant
parameters found at the end of this handout.
You can create a state-space model using the following command:
sys = ss(A, B, C, D);
Then, plot the poles and zeros of the dynamical system by using the “pzmap()”
function in MATLAB. This function takes our variable “sys” as its argument. The
following three lines of code should give the correct plot, with poles represented
as “x”s and zeros as “o”s.
Based on the plot, what do the pole locations tell us about the stability of
the open loop system? Be sure to attach the plot to this handout to show your
work.
In order to build upon our initial assessment on the stability, use the “bode()” and
“nyquist()” functions in MATLAB to generate the respective plots of the system.
The code for both is simply the function with our “sys” variable as the argument
for each.
Comment on the stability of the open-loop system based on the Nyquist
plot. How does the information from the Nyquist plot support your
assessment? Be sure to attach your Nyquist plots to this handout.
Page 3 of 5
ES158
Feedback Control System
Lab 3
Fall 2015
Implement this state-space model in Simulink. Use the state-space block to
implement your model. All relevant blocks can be found in the Simulink Library
browser:
In your state-space block, set your A, B, C, and D matrices to the variables “A”,
“B”, “C”, and “D.” Write a MATLAB script to generate these matrices. When you
run your Simulink model, the state-space block will automatically retrieve these
matrices from your MATLAB workspace. Don’t forget to set the initial conditions
of your states.
Provide a step force input with reasonable values and observe the step response
using a scope. Save plots of (1) the step input, (2) the position of the cart, and (3)
the angle of the pendulum.
How do the resulting step response plots correspond to your stability
analysis above? Show your plots.
Page 4 of 5
ES158
Feedback Control System
Lab 3
Fall 2015
1.c Controllability and Observability
In the next lab, you will be designing controllers to stabilize the inverted
pendulum cart. As such, we want to know whether the system is controllable and
observable.
Determine the controllability and observability of this system by
constructing controllability and observability matrices. Show your work.
Page 5 of 5