AE4610
  • Welcome
  • Experiments
  • Lab 0: MATLAB & SIMULINK
  • Lab 1: Rotary Servo Base
    • A. Integration (Week 1)
    • B. Modeling (Week 1)
    • C. Control Design (Week 2)
    • D. Controller Implementation & Evaluation (Week 3)
  • Lab 2: 3 DOF Gyroscope
    • A & B. Modeling and Control Design (Week 1)
    • C. Controller Implementation (Week 2)
  • Lab 3: Rotary Flexible Link
    • A. System Identification (Week 1)
    • B & C. Control Design and Controller Implementation (Week 2)
  • Lab 4: Rotary Inverted Pendulum
    • A & B. Modeling and Balance Control
    • C. Swing-up Control (Demo)
  • Final Project
  • Archive
    • Old Lab 1 Model Validation
    • Problem Set
    • DC Motor
    • Lab 1: Rotary Servo Base (Older Version)
      • A. Integration (Week 1)
      • B. Modelling (Week 1)
      • C. Position Control (Week 2)
    • Quadcopter
    • Gyroscope
    • Inverted Pendulum
    • 3DOF Helicopter
    • Torsional Pendulum
    • Aero LQR
      • A. System Identification
      • A. System Identification (Week 1) last check
      • B. Control Design & Implementation (Week 2)
    • Rotary Gyro
      • Rotary Gyro
    • 2 DOF AERO
      • A. System Identification
      • B. Control Design
      • C. Controller Implementation
    • Copy of Lab 4: Rotary Inverted Pendulum
      • Week 1
      • Week 2
Powered by GitBook
On this page
  • Objective
  • B. Control Design
  • State Space Model
  • Linear Quadratic Regulator (LQR) Design
  • Controller Specifications:
  • Controller Design Procedure:
  • C. Controller Implementation and Evaluation
  • Experiment
  • Results & Questions for Report
  • Control Design
  • Controller Implementation

Was this helpful?

Export as PDF
  1. Lab 3: Rotary Flexible Link

B & C. Control Design and Controller Implementation (Week 2)

Objective

The objective is to design a controller that allows rapid reorientation of the link with very little vibrations from the link flexibility. This analysis is a preliminary approach to containing structural vibrations in real-world applications like aircraft and spacecraft structures as well as robotic links/manipulators

B. Control Design

The methodology used is to design the control law assuming full state feedback to meet a given set of specifications. This will be followed by studying the loss of controller performance with servo feedback alone. The method we will use for full state feedback is based on the linear quadratic regulator (LQR) theory, which requires the given system to be controllable.

State Space Model

The equations that describe the motions of the servo and the link with respect to the servo motor voltage are obtained using the lumped mass method and can be written as

(Jeq+Jl)θ¨+Jlα¨+Beqθ˙=τ(1)(J_{eq} + J_l)\ddot{\theta} + J_l\ddot{\alpha} + B_{eq}\dot{\theta} = \tau \quad \quad \tag{1}(Jeq​+Jl​)θ¨+Jl​α¨+Beq​θ˙=τ(1)
Jlθ¨+Jlα¨+Blθ˙+Ksα=0(2)J_{l}\ddot{\theta} + J_l\ddot{\alpha} + B_{l}\dot{\theta} + K_s\alpha= 0 \quad \quad \tag{2} Jl​θ¨+Jl​α¨+Bl​θ˙+Ks​α=0(2)

Assuming the viscous damping of the link is negligible, i.e. BlB_lBl​ = 0 and substituting the torque τ\tauτ using the expression,

τ=ηgKgηmkt(Vm−Kgkmθ˙)Rm=C1Vm−C2θ˙\tau = \displaystyle\frac{\eta_gK_g\eta_mk_t(V_m - K_gk_m\dot\theta)}{R_m} = C_1V_m - C_2\dot\theta τ=Rm​ηg​Kg​ηm​kt​(Vm​−Kg​km​θ˙)​=C1​Vm​−C2​θ˙

the EOM can be rearranged as

θ¨=−(Beq+C2Jeq)θ˙+KsJeqα+C1JeqVm(3)\ddot{\theta} = -(\frac{B_{eq} + C_2}{J_eq})\dot{\theta} + \frac{K_s}{J_{eq}}\alpha + \frac{C_1}{J_{eq}}V_m \quad \quad \tag{3}θ¨=−(Je​qBeq​+C2​​)θ˙+Jeq​Ks​​α+Jeq​C1​​Vm​(3)
α¨=(Beq+C2Jeq)θ˙−Ks(Jeq+JlJeqJl)α−C1JeqVm(4){\ddot{\alpha}} = (\frac{B_{eq}+C_2}{J_{eq}}){\dot{\theta}} - K_s(\frac{J_{eq}+J_l}{J_{eq}J_l}){\alpha }- \frac{C_1}{J_{eq}}V_m \quad \quad \tag{4}α¨=(Jeq​Beq​+C2​​)θ˙−Ks​(Jeq​Jl​Jeq​+Jl​​)α−Jeq​C1​​Vm​(4)

The various system parameters can be found in Table 2 of Part A: System Identification.

Equations 3 and 4 can be represented in state-space form

x˙=Ax+Buy=Cx+Du\dot{x} = Ax + Bu \\ y = Cx + Dux˙=Ax+Buy=Cx+Du

withx=[θ    α    θ˙    α˙]Tx=[\theta \;\; \alpha \;\; \dot{\theta} \;\; \dot{\alpha}]^Tx=[θαθ˙α˙]T andu=Vmu = V_mu=Vm​, where

A=[001000010KsJeq−(Beq+C2Jeq)00−Ks(Jeq+JlJeqJl)(Beq+C2Jeq)0](5)A = \begin{bmatrix} 0 &0 & 1 &0 \\ 0 &0 & 0 &1 \\ 0 &\frac{K_s}{J_{eq}} & -(\frac{B_{eq}+C_2}{J_{eq}}) &0 \\ 0 &-K_s(\frac{J_{eq}+J_l}{J_{eq}J_l}) & (\frac{B_{eq}+C_2}{J_{eq}}) & 0 \end{bmatrix} \quad \quad \tag{5}A=​0000​00Jeq​Ks​​−Ks​(Jeq​Jl​Jeq​+Jl​​)​10−(Jeq​Beq​+C2​​)(Jeq​Beq​+C2​​)​0100​​(5)
B=[00C1Jeq−C1Jeq](6)B = \begin{bmatrix} 0 \\ 0\\ \frac{C_1}{J_{eq}} \\ -\frac{C_1}{J_{eq}} \end{bmatrix} \quad \quad \tag{6}B=​00Jeq​C1​​−Jeq​C1​​​​(6)

In the output equation, only the position of the servo and link angles are being measured.

As such, the velocities of the servo and link angles can be computed in the digital controller if required, e.g., by taking the derivative and filtering the result though a high-pass filter. Hence, with all the states of the system as outputs, the C and D matrices are

C=[1000010000100001 ](7)C = \begin{bmatrix} 1 & 0& 0& 0\\ 0 & 1& 0& 0\\ 0 & 0& 1& 0\\ 0 & 0& 0& 1\ \end{bmatrix} \qquad \qquad \tag{7}C=​1000​0100​0010​0001 ​​(7)
D=[0000](8)D = \begin{bmatrix} 0\\ 0 \\0 \\ 0 \end{bmatrix} \qquad \qquad \tag{8}D=​0000​​(8)

Linear Quadratic Regulator (LQR) Design

Controllability

If the control input ′u′'u'′u′ of a system can take each state variable, xix_ixi​ where i=1...ni = 1 . . . ni=1...n, from an initial state to a final state in finite time, then the system is controllable, otherwise it is uncontrollable. The controllability of a system can be determined using the ‘Rank Test’. According to the Rank Test, the system is controllable if the rank of its controllability matrix

T=[B    AB    A2B…An−1B]T=[B \;\; AB \;\;A^2B… A^{n−1}B]T=[BABA2B…An−1B]

equals the number of states of the system,

rank(T)=nrank(T)=nrank(T)=n

LQR controller

If (A,B) are controllable, then the Linear Quadratic Regular optimization method can be used to find full state feedback controller gains. Given the plant model in state-space form where xxx represents the state vector, this technique finds a control input ‘uuu’ that minimizes the cost function

J=∫0∞(xTQx+uTRu)dt(9)J= \int_0^\infty(x^TQx+ u^TRu)dt \qquad \qquad \tag{9} J=∫0∞​(xTQx+uTRu)dt(9)

where Q and R are the user-defined weighting matrices Q=QTQ = Q^TQ=QT and R=RTR = R^TR=RT. It is assumed that Q is positive semi-definite (all the eigenvalues ofQQQ are non-negative) and RRR is positive definite (all the eigenvalues ofRRR are positive). The weighting matrices affect how LQR minimizes the function and are, essentially, tuning variables. Here,xxx is the state vector[θ    α    θ˙    α˙]T[\theta \;\; \alpha \;\; \dot{\theta} \;\; \dot{\alpha}]^T[θαθ˙α˙]T anduuu is the servo motor voltage input VmV_mVm​.

Given the control law u=−Kxu = −Kxu=−Kx, the state-space model of the closed loop system becomes

x˙=Ax+B(−Kx)=(A−BK)x(10)\dot{x} = Ax+B(−Kx)=(A−BK)x \quad \quad \tag{10}x˙=Ax+B(−Kx)=(A−BK)x(10)

where KKK is given by

K=[kθ    kα    kθ˙    kα˙](11)K=[k_{\theta} \;\;k_{\alpha}\;\;k_{\dot{\theta}}\;\;k_{\dot{\alpha}}] \qquad \qquad \tag{11}K=[kθ​kα​kθ˙​kα˙​](11)

is the controller gain vector. Note that the input voltage VmVmVm is scalar, and therefore, RRR is also scalar. In practice, the weighting matrices QQQ and RRR are chosen to be diagonal. A simple way for choosing QQQ and RRR is using the Bryson's rule. This method works best when control design specifications regarding the system response and control input are given in terms of limits on excursions from equilibrium.

Assuming the time-domain design specifications are

∣xi∣≤ximax⁡  i=1,2,...,n      ∣uj∣≤ujmax⁡  j=1,2,...,m|x_i| \leq x_{i_{\max}} \; i = 1, 2, ..., n \; \; \; \\ |u_j| \leq u_{j_{\max}} \; j = 1, 2, ..., m∣xi​∣≤ximax​​i=1,2,...,n∣uj​∣≤ujmax​​j=1,2,...,m

Then one can use the Bryson’s rule to choose the weighting matrices as

Q=diag(1ximax⁡2)    i=1,2,...,n(12)R=diag(1ujmax⁡2)    j=1,2,...,m(13)Q=\displaystyle {diag\left (\frac{1}{x_{i_{\max}}^2}\right) \; \; i = 1, 2, ..., n} \quad \quad (12) \\ R = diag\left (\frac{1}{u_{j_{\max}}^2}\right) \; \; j = 1, 2, ..., m \quad \quad (13)Q=diag(ximax​2​1​)i=1,2,...,n(12)R=diag(ujmax​2​1​)j=1,2,...,m(13)

Further tuning of QQQ and RRR may be required for improving the controller performance. Note that increasing RRR means increasing the penalty on the control input (using less control effort). Similarly, increasing QQQ means increasing the penalty on the states (states reaching equilibrium position quickly and with less overshoot). Matrix QQQ sets the weight on the states and determines how uuu will minimize JJJ (and hence how it generates gain KKK).

In our case,

Q=[1θmax200001αmax200001θ˙max200001α˙max2 ](14)Q = \begin{bmatrix} \frac{1}{\theta_{max}^2} & 0& 0& 0\\ 0 & \frac{1}{\alpha_{max}^2}& 0& 0\\ 0 & 0& \frac{1}{\dot{\theta}_{max}^2}& 0\\ 0 & 0& 0& \frac{1}{\dot{\alpha}_{max}^2}\ \end{bmatrix} \qquad \qquad \tag{14}Q=​θmax2​1​000​0αmax2​1​00​00θ˙max2​1​0​000α˙max2​1​ ​​(14)
R=1Vm,max2(15)R = \frac{1}{V^2_{m, max}} \quad \quad (15)R=Vm,max2​1​(15)

Substituting QQQ and RRR in Eqn. 9 gives

J=∫0∞(qθθ2+qαα2+qθ˙θ˙2+qα˙α˙2+RVm2)dt(16)J= ∫_0^\infty (q_{θ}\theta^2+q_{α}\alpha^2+ q_{\dot{θ}}{\dot{\theta}}^2+q_{\dot{α}}{\dot{\alpha}}^2+RV_m^2)dt \quad \quad \tag{16}J=∫0∞​(qθ​θ2+qα​α2+qθ˙​θ˙2+qα˙​α˙2+RVm2​)dt(16)

where qθ=1θmax2q_\theta= \displaystyle\frac{1}{\theta_{max}^2}qθ​=θmax2​1​, qα=1αmax2q_\alpha= \displaystyle\frac{1}{\alpha_{max}^2}qα​=αmax2​1​, qθ˙=1θ˙max2q_{\dot{\theta}}= \displaystyle\frac{1}{\dot{\theta}_{max}^2}qθ˙​=θ˙max2​1​, qα˙=1α˙2q_{\dot{\alpha}}= \displaystyle\frac{1}{\dot{\alpha}^2}qα˙​=α˙21​, R=1Vm,max2R=\displaystyle\frac{1}{V_{m,max}^2}R=Vm,max2​1​

On observing Eq. 12, it can be seen that increasing qiq_iqi​ causes control input VmV_mVm​ to work harder to minimize state xix_ixi​, which will predominately increasekik_iki​. If qθq_{\theta}qθ​ is increased, then kθk_{\theta}kθ​ will increase to compensate for the larger weight placed on state θ\thetaθ. Depending on the model, changing a singleqiq_iqi​ can affect multiplekik_i ki​ gains because each state is not independent. IfRRR is increased, then control input VVV has to work less to minimizeJJJ. In that case, LQR would generate a lower overall value ofKKK. A block diagram of the system with fill state feedback controller is shown in Figure 1.

The feedback control loop in Figure 1 is designed to stabilize the servo to a desired position,θdθ_dθd​, while minimizing the deflection of the flexible link, wherexxx is the state column vector andKKK is the gain row vector as shown earlier. Note thatCCC is4×44×44×4identity matrix andDDD is 4×14×14×1 column of zeros in Figure 1.

The reference state is defined as

xd=[θd    0    0    0]Tx_d=[θ_d \;\; 0\;\; 0\;\;0]^Txd​=[θd​000]T

and the controller is

u=K(xd−x)u=K(x_d−x)u=K(xd​−x)

Controller Specifications:

The following specifications in the time domain are to be met when the rotary arm is tracking a 30°30°30°step change in its angular position.

Specification 1: Servo angle 2% settling time: ts≤0.5s t_s≤0.5sts​≤0.5s

Specification 2: Servo angle percentage overshoot: PO≤5%PO≤5 \% PO≤5%

Specification 3: Maximum link angle deflection:∣α∣max≤10°|α|_{max}≤10°∣α∣max​≤10°

Specification 4: Maximum control effort (voltage): ∣Vm∣max≤10V |V_{m}|_{max}≤10 V∣Vm​∣max​≤10V

Controller Design Procedure:

Note: The results from the following steps have to be included in the Analysis section of the report.

  1. Obtain the AAA and BBB matrices of the system using the parameters from Part A: System identification. Check your A and B matrices with the TA.

  2. Using Bryson’s rule (Eq. 12-15) calculate QQQ and RRR matrices, based on the following suggested maximum values of state and control excursions:

    0.05rad≤∣θmax∣≤0.1rad            ∣αmax∣≃0.1rad0.05 rad ≤|θ_{max}|≤0.1 rad \;\;\;\;\;\; |α_{max}|\simeq0.1 rad 0.05rad≤∣θmax​∣≤0.1rad∣αmax​∣≃0.1rad ∣θ˙max∣≃1rad/s            0.4rad/s≤∣α˙max∣≤0.6rad/s ∣\dot{θ}_{max}∣\simeq1rad/s \;\;\;\; \; \; 0.4rad/s≤|\dot{α}_{max}|≤0.6rad/s ∣θ˙max​∣≃1rad/s0.4rad/s≤∣α˙max​∣≤0.6rad/s 0.8V≤∣Vm,max∣≤1.2V0.8 V ≤ |V_{m,max}|≤1.2 V0.8V≤∣Vm,max​∣≤1.2V Check if Q≥0Q \ge 0Q≥0 and R>0R > 0R>0 (by finding eigenvalues of the matrix).

  3. Using the lqr command in MATLAB, calculate the optimal feedback gain vector KKK. The lqr command solves the Algebraic Riccati equation which is required to determine the gain vector KKK is

    >> [K,S,E] = lqr(A,B,Q,R);

    where KKK is the gain matrix, SSS is the solution to the Riccati equation and E are closed loop system poles. Check your gain matrix K with the TA.

  4. Using Figure 1 as a guide, develop a Simulink model of the system.

    Note: SIMULINK references the current MATLAB workspace when setting variables. Use the variable names for the system matrices AAA and BBB and the control gain matrix KKK from your MATLAB script file for the LQR design.

    Make sure to include servo position command input, saturation blocks, and appropriate outputs. Use scopes and To Workspace blocks so that reference, output, and response signals can be tracked. (Make sure to maintain consistency between deg and rad in SIMULINK)

  5. Using the controller gains found in step 3, simulate the closed loop system for a step servo position command of 30°30\degree30°over a 10s duration.

    • Record (and plot for lab report) the servo angle (θ\thetaθ) link angle (α\alphaα) and voltage input VmV_mVm​.

    • Check if all the given specifications are met.

    • If not, keep adjusting the QQQ and RRR weighting matrices parameters, till all specifications are met. Record the final Q and R matrices, the servo angle (θ\thetaθ), link angle (α\alphaα) and voltage input VmV_mVm​plots.

  6. Study in simulation the degradation, if any, in closed loop system performance (in meeting the given specifications) using partial feedback. For partial feedback consider feedback of servo angle (θ\thetaθ) and servo angle rate (θ˙\dot{\theta}θ˙).

    • This is easily done by retaining the gain value of the chosen feedback loops and zeroing out the remaining gains in the gain matrix KKK used in your Simulink model.

    • Check your plots with the TA.

    • Check if the specifications are met (no need to tune Q and R matrices.)

    • Record (and plot for lab report) the servo angle (θ\thetaθ) link angle (α\alphaα) and voltage input VmV_mVm​

C. Controller Implementation and Evaluation

In this experiment, the servo position is controlled while minimizing the link deflection using the LQR­ based control found. Measurements will then be taken to ensure that the specifications are satisfied.

Warning: In closed loop experiments, the link may swing around rather quickly. Stay clear of it during closed loop experiments.

Experiment

  1. Turn the amplifier power on.

  2. Download the q_flex.zip and open the Simulink file q_flex for controller implementation. This is the block diagram for this part of the experiment. Make sure you have K gain variable in the MATLAB workspace. Note: The Smooth Signal Generator block generates a 0.33 Hz square wave (with amplitude of 1) that is passed through a Rate Limiter block to smooth the signal (Rising slew rate of 100 and falling slew rate of -100). The Amplitude (deg) gain block is used to change the desired servo position command. The state-feedback gain K is set in the LQR Control gain block and is read from the MATLAB workspace.

  3. Align the flexible link along the 0 mark on the servo stand.

  4. Double click on the scopes and open them.

  5. Ensure that the manual switch is connected to the full state feedback.

  6. A periodic square wave is given as commanded link rotation to the servo motor, causing the link to move left and right alternately for 10 seconds.

  7. Copy the response data to your group folder. The response data is saved in variables data_theta, data_alpha, and data_vm. DO NOT DELETE or SAVE THE SIMULINK MODEL.

  8. Connect the manual switch to the partial state feedback and repeat steps 4-9 again. Make sure your files name is different from full state feedback.

  9. Turn the power off.

Results & Questions for Report

Control Design

Results

  1. Include the results from the controller design procedure Steps 1-6.

Questions

  1. Estimate the bandwidth for your full state and partial state feedback controllers. Hint: Use 'bandwidth(sysclosed)' command in MATLAB with link rotation (θ\thetaθ) as the output.

>> sysclosed = ss((A-B*K), B, [1 0 0 0], 0);

>> bw = bandwidth(sysclosed)

>> bode(sysclosed)

The bode() function produces closed loop system frequency response plot. Include Bode Plots of the closed loop system and list the bandwidth of the system with full and partial state feedback.

  1. Estimate the stability margins (gain and phase margins) of your full state and partial state feedback controllers. Hint: Use 'margin(sysopen)' command in MATLAB where 'sysopen' is the state space model of the open loop system with the controller.

>> sysopen = ss(A,B,K,0)

>> margin(sysopen)

We get bode plot of the open loop system with the controller with margins listed on the plots. Include the Bode plots for the full state and partial state feedback.

Controller Implementation

Results

  1. Plots of servo angle, link deflection angle and input voltage vs time for full state and partial state feedback. Compare the results and explain the differences.

  2. Run the Simulink that you built in control design with the same command input used in the experiment. Compare the simulated response with the experimental response for both full state and partial state feedback and explain any differences between them. Note 1: Generate two sets of figures with one set containing the plots of simulation and experiment for full state feedback and the second set containing the plots of simulation and experiment for partial state feedback. For each feedback case, the simulated response and corresponding experimental response must be on the same graph. Note 2: Average the first few seconds of the experimental data to obtain initial conditions for your state-space block in Simulink.

Questions

  1. Explain why the link deflection angle goes opposite to servo rotation initially.

  2. For a controllable system, can partial state feedback guarantee stability like full state feedback? Briefly explain.

PreviousA. System Identification (Week 1)NextLab 4: Rotary Inverted Pendulum

Last updated 2 months ago

Was this helpful?

To build the model, click down arrow on Monitor & Tune under Hardware tab and then Build for monitoring . This generates the controller code.

Click Connect button under Monitor & Tune and then click Start

32KB
q_flex.zip
archive
Figure 1. State-feedback Control Loop (Note:CCC is4×44×44×4 identity matrix andDDD is4×14×14×1 column of zeros.)