Week 1
Objective
The objectives of this laboratory experiment are as follows:
Obtain the linear state-space representation of the rotary pendulum plant.
Design a state-feedback control system that balances the pendulum in its upright position using Pole Placement.
Simulate the closed-loop system to ensure the given specifications are met.
Equipment
Week 1
A. Modeling
This experiment involves modeling of the rotary inverted pendulum.
Rotary Inverted Pendulum Model
Table 1 Rotary Pendulum components (Figure 1)
1
Rotary Servo
2
Thumbscrews
3
Rotary Arm
4
Shaft Housing
5
Shaft
6
Pendulum T-Fitting
7
Pendulum Link
8
Pendulum Encoder Connector
9
Pendulum Encoder
Table 2 Main Parameters associated with the Rotary Pendulum module
Mass of pendulum
0.127
Total length of pendulum
0.337
Distance from pivot to center of mass
0.156
Pendulum moment of intertia about center of mass
0.0012
Pendulum viscous damping coeffiÂcient as seen at the pivot axis
0.0024
Mass of rotary arm with two thumb screws
0.257
Rotary arm length from pivot to tip
0.216
Rotary arm length from pivot to center of mass
0.0619
Rotary arm moment of inertia about its center of mass
9.98 x 10^-4
Rotary arm viscous damping coeffiÂcient as seen at the pivot axis
0.0024
Rotary arm moment of inertia about pivot
0.0020
Pendulum encoder resolution
4096
Model Convention
The rotary inverted pendulum model is shown in Figure 2. The rotary arm pivot is attached to the Rotary Servo system and is actuated. The arm has a length of L_\rm{r}, a moment of inertia of J_\rm{r}, and its angle, , increases positively when it rotates counterclockwise (CCW). The servo (and thus the arm) should turn in the CCW direction when the control voltage is positive, i.e. V_\rm{m} > 0.
The pendulum link is connected to the end of the rotary arm. It has a total length of and it center of mass is {L_\rm{p}}/{2} . The moment of inertia about its center of mass is J_\rm{p}. The inverted pendulum angle, , is zero when it is perfectly upright in the vertical position and increases positively when rotated CCW.
Nonlinear Equations of Motion
Instead of using classical (Newtonian) mechanics, the Lagrange method is used to find the equations of motion of the system. This systematic method is often used for more complicated systems such as robot manipulators with multiple joints.
Specifically, the equations that describe the motions of the rotary arm and the pendulum with respect to the servo motor voltage, i.e., the dynamics, will be obtained using the Euler-Lagrange equation:
\frac{d}{dt}\frac{\partial L}{\partial \dot{q_i}} - \frac{\partial L}{\partial q_i} = Q_i \qquad \qquad \tag{1}
The variables are called generalized coordinates. For this system let
q(t) =\begin{bmatrix} \theta(t) & \alpha(t) \end{bmatrix}^T \tag{2}
where, as shown in Figure 2, is the rotary arm angle and is the inverted pendulum angle. The corresponding velocities are
\dot{q}(t)=\begin{bmatrix} \displaystyle \frac{d\theta(t)}{dt} & \displaystyle\frac{d\alpha(t)}{dt} \end{bmatrix} ^T\tag{3}
With the generalized coordinates defined, the Euler-Lagrange equations for the rotary pendulum system are\frac{d}{dt} \frac{\partial L}{\partial \dot{\theta}} - \frac{\partial L}{\partial \theta} = Q_1 \tag{4a}
\frac{d}{dt}\frac{\partial L}{\partial \dot{\alpha}} - \frac{\partial L}{\partial \alpha} = Q_2 \tag{4b}
The Lagrangian of the system is described byL = T - V \tag{5}
where is the total kinetic energy of the system and is the total potential energy of the system. Thus the Lagrangian is the difference between a system’s kinetic and potential energies.
The generalized forces are used to describe the nonconservative forces (e.g. friction) applied to a system with respect to the generalized coordinates. In this case, the generalized force acting on the rotary arm isQ_1 = \tau - B_\rm{r}\dot{\theta} \tag{6a}
and acting on the pendulum isQ_2 = -B_\rm{p}\dot{\alpha} \tag{6b}
Once the kinetic and potential energy are obtained and the Lagrangian is found, then the task is to compute various derivatives to get the EOMs. After going through this process, the nonlinear equations of motion for the Rotary Pendulum are:
​\displaystyle\left (m_pL_r^2 + \frac{1}{4}m_pL_p^2 - \frac{1}{4}m_pL_p^2 \cos^2(\alpha)+J_r \right )\ddot{\theta} - \left (\frac{1}{2}m_pL_pL_r\cos(\alpha) \right)\ddot{\alpha} \\+ \displaystyle\left(\frac{1}{2}m_pL_p^2\sin(\alpha)\cos(\alpha)\right)\dot{\theta}\dot{\alpha} + \left( \frac{1}{2}m_pL_pL_r\sin(\alpha)\right)\dot{\alpha}^2 = \tau - B_r\dot{\theta} \tag{7}​
\displaystyle{\left(-\frac{1}{2}m_pL_pL_r\cos(\alpha) \right)\ddot{\theta} + \left(J_p + \frac{1}{4}m_pL_p^2 \right) \ddot{\alpha} - \left(\frac{1}{4} m_pL_p^2\cos(\alpha)\sin(\alpha)\right)\dot{\theta}^2 \\-\frac{1}{2} m_pL_pg\sin(\alpha) = -B_p\dot{\alpha}} \tag{8}
\tau = \displaystyle\frac{\eta_gK_g\eta_mk_t(V_m - K_gk_m\dot{\theta})}{R_m} \tag{9}
Linearization
Linearization of a nonlinear function about a selected point is obtained by retaining upto first order term in the Taylor Series expansion of the function about the selected point. For example, linearization of a two variable nonlinear function f(z) where
about the point
can be written as
​
Linearization of Inverted Pendulum Equations
The nonlinear equations of the inverted pendulum system obtained as Equations (7) and (8) are linearized about the equilibrium point with the pendulum in the upright position, i.e.,
, , , , ,
Linearization of Equation (7) about the above equilibrium state gives
where, from Equation(9) the servo motor torque coefficient is
and the back emf coefficient is
Likewise, linearization of Equation (8) about the equilibrium point with the pendulum in the upright position gives
where is the acceleration due to gravity. Note that the negative sign of the gravity torque ( term) in Equation 11 indicates negative stiffness with the pendulum in the vertically upright position.
Equation (10) and (11) can be arranged in the matrix form as
Where mass matrix , damping matrix , and the stiffness matrix become
Defining the state vector , output vector and the control input as
Equation (12) can be rewritten in state space form as
where the system state matrix , control matrix , output matrix and the feedthrough of input to the output matrix become
Analysis: Modeling
Download the above zip file and extract it.
Note down your state-space matrices for your report. Note: You may want to cross-check the state-space matrix with TAs before proceeding to balance control.
Find the open-loop poles of the system. Hint: Use
eig(A).
B. Balance Control
Specification
The control design and time-response requirements are: Specification 1: Damping ratio: 0.6 < < 0.8 Specification 2: Natural frequency: 3.5 rad/s < \omega_\rm{n} < 4.5 rad/s Specification 3: Maximum pendulum angle deflection: < 15 deg. Specification 4: Maximum control effort / voltage: |V_\rm{m}| < 10 V. The necessary closed-loop poles are found from specifications 1 and 2. The pendulum deflection and control effort requirements (i.e. specifications 3 and 4) are to be satisfied when the rotary arm is tracking a degree angle square wave.
Stability
The stability of a system can be determined from its poles ([2]):
Stable systems have poles only in the left-hand plane.
Unstable systems have at least one pole in the righthand plane and/or poles of multiplicity greater than 1 on the imaginary axis.
Marginally stable systems have one pole on the imaginary axis and the other poles in the left-hand plane.
The poles are the roots of the system’s characteristic equation. From the state-space, the characteristic equation of the system can be found using \mathrm{det}(sI - A) = 0 \tag{15} where is the determinant function, is the Laplace operator, and the identity matrix. These are the eigenvalues of the state-space matrix .
Controllability
If the control input of a system can take each state variable, where , from an initial state to a final state in finite time then the system is controllable, otherwise it is uncontrollable ([2]).
Rank Test The system is controllable if the rank of its controllability matrix
T = [B \ AB \ A^2B \ ... \ A^{n-1}B] \tag{16} equals the number of states in the system, \mathrm{rank}(T) = n \tag{17}
Companion Matrix
If (A,B) are controllable and B is n×1, then A is similar to a companion matrix ([1]). Let the characteristic equation of A be s^n + a_ns^{n-1}+\dots +a_1 \tag{18} Then the companion matrices of A and B are \tilde{A} = \begin{bmatrix} 0 & 1 & \dots & 0& 0 \\ 0 & 0 & \dots & 0& 0 \\ \vdots & \vdots & \ddots & \vdots& \vdots \\ 0 & 0 & \dots & 0& 1 \\ -a_1 & -a_2 & \dots & -a_{n-1}& -a_n \end{bmatrix} \tag{19}
and\tilde{B} = \begin{bmatrix} 0\\\vdots\\ \\1 \end{bmatrix} \tag{20}
Define W = T\tilde{T}^{-1} \tag{21} where is the controllability matrix defined in Equation 16 and\tilde{T} = \begin{bmatrix}\tilde{B} & \tilde{A}\tilde{B} & \cdots & \tilde{A}^{n-1}\tilde{B}\end{bmatrix} \tag{22} Then W^{-1}AW = \tilde{A} \tag{23} and W^{-1}B = \tilde{B} \tag{24}
Pole Placement Theory
If are controllable, then pole placement can be used to design the controller. Given the control law , the state-space model of Equation (13) becomes \dot{x} = Ax + B(-Kx) \\=(A - BK)x \tag{25}
We can generalize the procedure to design a gain for a controllable system as follows:
Step 1 Find the companion matrices and . Compute . Step 2 Compute to assign the poles of to the desired locations.
\tilde{A} - \tilde{B}\tilde{K}= \begin{bmatrix} 0 & 1 & \dots & 0& 0 \\ 0 & 0 & \dots & 0& 0 \\ \vdots & \vdots & \ddots & \vdots& \vdots \\ 0 & 0 & \dots & 0& 1 \\ -a_1-k_1 & -a_2-k_2 & \dots & -a_{n-1}-k_{n-1}& -a_n -k_n \end{bmatrix} \tag{26} Step 3 Find to get the feedback gain for the original system . Remark-1: It is important to do the conversion. Remember that represents the actual system while the companion matrices and do not.
Remark-2: The entire control design procedure using the pole placement method can be simply done in MATLAB using the function called 'place' or 'acker'. For a selected desired set of closed loop poles DP, the full state feedback gain matrix is obtained from
Desired Poles
Simulation Model with Feedback
The feedback control loop that balances the rotary pendulum is illustrated in Figure 4. The reference state is defined as x_d = [\theta_d \ 0\ 0\ 0]^ \intercal \tag{28}where is the desired rotary arm angle. The controller is u = K(x_d - x) \tag{29}Note that if then , which is the control used in the pole-placement algorithm.
B.1 Experiment: Designing the Balance Control
Select and such that they satisfy the given design specifications.
In the same rotpen_week1_student.mlx live script, go to the Balance Control section. Enter the chosen
zeta
andomega_n
values.Determine the locations of the two dominant poles and based on the specifications and enter their values in the MATLAB live script. Ensure that the other poles are placed at
p3 = -30
andp4 = -40
. Hint: Use Equation 27.Find gain
K
using a predefined Compensator Design MATLAB commandK = acker(A,B,DP)
, which is based on pole-placement design. Note:DP
is a row vector of the desired poles found in Step 3.
For sanity check, if you use damping ratio of 0.7 and natural frequency of 4 rad/s, you should get around K = [-12 63 -5.5 7].
B.2 Experiment: Simulating the Balance Control
Run rotpen_week1_student.mlx live script. Ensure the gain K you found is loaded in the workspace (type K matrix in the command window).
Open and run the s_rotpen_bal.mdl for 10 seconds. The responses in the scopes shown in Figure 6 were generated using an arbitrary feedback control gain. Note: When the simulation stops, the last 10 seconds of data is automatically saved in the MATLAB workspace to the variables
data_theta
,data_alpha
, anddata_Vm
.Save the data corresponding to the simulated response of the rotary arm, pendulum, and motor input voltage obtained using your obtained gain K. Note: The time is stored in the
data_theta(:,1)
vector, the desired and measured rotary arm angles are saved in thedata_theta(:,2)
anddata_theta(:,3)
arrays. Similarly, the pendulum angle is stored in thedata_alpha(:,2)
vector, and the control input is in thedata_Vm(:,2)
structure.
Results for Report
A) Modeling
The linear state-space representation of the rotary inverted pendulum system, i.e., , , and matrices (numerical values).
Open-loop poles of the system.
B.1) Balance Control Design
Chosen and based on design specifications.
Corresponding locations of the two dominant poles and .
Gain vector .
B.2) Balance Control Simulation
Plots of the commanded position of the rotary arm (), simulated responses of the rotary arm (), pendulum (), and motor input voltage () obtained using your obtained gain K.
Questions for Report
B.1) Balance Control Design
Determine the controllability matrix of the system. Is the inverted pendulum system controllable? Hint: Use Equation 17.
Using the open-loop poles, find the characteristic equation of . Hint: The roots of the characteristic equation are the open-Âloop poles.
Determine the controllability matrix of the companion system.
Determine the transformation matrix .
Check if and with the obtained matrices.
Appendix
Table A Main Rotary Servo Base Unit Specifications
Motor nominal input voltage
6.0 V
Motor armature resistance
2.6 Ω ± 12%
Motor armature inductance
0.18 mH
Motor current-torque constant
7.68 × 10−3 N-m/A ± 12%
Motor back-emf constant
7.68 × 10−3 V/(rad/s) ± 12%
High-gear total gear ratio
70
Motor efficiency
0.69 ± 5%
Gearbox efficiency
0.90 ± 10%
rotor Rotor moment of inertia
3.90 × 10−7 kg-m2 ± 10%
High-gear equivalent moment of inertia without external load
1.823 × 10−3 kg-m2
High-gear Equivalent viscous damping coefficient
0.015 N-m/(rad/s)
Mass of bar load
0.038 kg
Length of bar load
0.1525 m
Mass of disc load
0.04 kg
Radius of disc load
0.05 m
Maximum load mass
5 kg
Maximum input voltage frequency
50 Hz
Maximum input current
1 A
Maximum motor speed
628.3 rad/s
Reference
[1] Bruce Francis. Ece1619 linear systems, 2001. [2] Norman S. Nise. Control Systems Engineering. John Wiley & Sons, Inc., 2008.
Last updated
Was this helpful?