EE128 Fa17 Lab6a
EE128 Fa17 Lab6a
1 Objectives
The objective of this lab is to achieve simultaneous control of both the angular position of the pendulum
and horizontal position of the cart on the track using full-state feedback. We will be considering small
angle perturbations and sine wave reference tracking of the cart position. Note that the system is a SIMO
– a Single Input Multiple Output – system, since we are trying to control both the position of the cart
and the angle of the pendulum by using only the motor voltage.
2 Theory
The setup consists of a pendulum attached to the movable cart from Labs 3 and 4. The free body
diagram of this setup is shown in Figure 1. We ignore friction and assume that the mass of the rod is
uniformly distributed, e.g. its center of mass is located at the center of the rod, Lp = L/2. N and P
are the horizontal and vertical components, respectively, of the reaction force between the cart and the
pendulum. The parameter values of the physical system are given in Table 1 in the Appendix.
Figure 1: Free body diagram of the inverted pendulum setup (ignoring friction)
3 Pre-Lab
3.1 Equations of Motion of the Mechanical System
Under the small-angle approximation sin θ ≈ θ and cos θ ≈ 1, derive the equations of motion (1) and (2)
of the inverted pendulum-cart system. In (1), Fa is the force exerted on the cart by the motor.
(M + m) ẍ + mLp θ̈ = Fa (1)
4mL2p
mLp ẍ + θ̈ − mgLp θ = 0 (2)
3
One way of doing this is by considering the free-body diagrams of the cart and the pendulum separately
and writing their respective equations of motion.
Hint: Consider the following force/torque balance equations: horizontal acceleration on the cart, accel-
eration of the center of mass of the pendulum, and torsion of the pendulum. An easy way to analyze
the torque equation for the pendulum is to consider its motion as observed from the frame of the cart.
However, this will introduce a ‘fictitious’ force, known as D’Alembert’s effect. The associated free body
diagram of the cart and the pendulum are given in Figure 2 and Figure 3, respectively. Apply Newton’s
laws to obtain the required equations.
y
Fa
N
x
x P Mg
body diagram of the cart (ignoring friction; normal force not depicted)
Figure 2: Free
mx
θ mg
Figure 3: Free body diagram of the pendulum (ignoring friction; the mẍ vector will appear in the torsion
equation due to D’Alembert’s effect)
Once you have the expressions for your state space representation, use a MATLAB script file to plug
in your values. This will make things much easier if parameters need to be adjusted.
(a) The feedback gain matrix K is of the form K = [k1 k2 k3 k4 ]. The closed-loop system matrix
is given by AK = A − BK. Using your A and B matrices (with the values plugged in) from (3),
compute the matrix AK as a function of the ki .
(b) Compute the characteristic polynomial P (K; s) = det(sI − AK ) of the closed-loop system as a
function of k1 through k4 .
(c) Compute the desired characteristic polynomial Pdes (s) = 4i=1 (s−si ) determined by the desired
Q
4 Lab
During this lab, you will implement your state-feedback controller from the PreLab and run it on the
actual hardware. Make sure to save all the models and script files used and attach them to your lab
report submission.
Gear Protection In order to prevent the gear from slipping, you must put a saturation block before
the Analog Output block. You have two choices:
You must connect this block to the ẋ signal as well as the control signal for saturation. It applies
different bounds depending on ẋ: once the cart is moving, it allows higher “forward” voltages, while
prohibiting big “reverse” voltages. The u sat output is the saturated signal, while max lim and
min lim allow you to plot/analyze the limits.
Sign of θ The direction we have defined θ to increase and the direction the hardware encoder increases
are reversed. Make sure to use a negative factor for angular unit conversion!
Units Watch your units. Everything in this system should match the units you used for your state-space
derivation. When in doubt, always work with SI units.
3. Introduce a sine wave reference signal and and analyze the results. Your reference input will be
T
r = M sin ωt 0 0 0 . Start with a reasonable amplitude (M ≈ 0.1 m), and use frequencies
ω = 1, 2, 5 rad/s. Again make sure to start at the center of the track and to hold the pendulum
vertical when you start the program. Check your response and include plots of cart position, cart
velocity and pendulum angle in your report.
(a) Calculate the gain and phase for each of the frequencies in your frequency response (ignoring the
offset from the hardware response). Locate these frequencies on the Bode plot from Part 3.3.4
of your Pre-Lab and compare the results. Do your values match for each frequency? If not,
explain possible causes for the difference.
(b) Slightly change the position of the desired closed-loop poles. Try a couple of different values
and run the resulting controllers on the hardware. Again include plots of cart position, cart
velocity and pendulum angle in your report. Discuss how the changes in the position of the
poles affect the behavior of the system. You do not need to repeat part 3a.
4. Plot the cart velocity ẋ and the pendulum’s angular velocity θ̇, which are obtained by numerically
differentiating the signals x and θ, respectively. Comment on the quality of the obtained signals.
A System Parameters
Parameter Value Description
439.6 counts/cm Resolution of the cart position encoder
651.9 counts/rad Resolution of the angle encoder
M 0.94 kg Mass of cart and motor
m 0.230 kg Mass of pendulum
Lp 0.3302 m Pendulum distance from pivot to center of mass
Ic m L2p /3 Moment of inertia of pendulum about its center
Ie 4m L2p /3 Moment of inertia of pendulum about its end
Kt 7.67 · 10−3 Nm/A Motor torque constant
Km 7.67 · 10−3 Vs/rad Motor back EMF constant
Kg 3.71 Motor gearbox ratio
Rm 2.6 Ω Motor winding resistance
r 6.36 · 10−3 m Radius of motor gear
Jm 3.9 · 10−7 kg m2 Motor moment of inertia