arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

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

hashtag
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

hashtag
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.

hashtag
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

Assuming the viscous damping of the link is negligible, i.e. = 0 and substituting the torque using the expression,

the EOM can be rearranged as

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

with and, where

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

hashtag
Linear Quadratic Regulator (LQR) Design

hashtag
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. 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

equals the number of states of the system,

hashtag
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 represents the state vector, this technique finds a control input ‘’ that minimizes the cost function

where Q and R are the user-defined weighting matrices and . It is assumed that Q is positive semi-definite (all the eigenvalues of are non-negative) and is positive definite (all the eigenvalues of are positive). The weighting matrices affect how LQR minimizes the function and are, essentially, tuning variables. Here, is the state vector and is the servo motor voltage input .

Given the control law , the state-space model of the closed loop system becomes

where is given by

is the controller gain vector. Note that the input voltage is scalar, and therefore, is also scalar. In practice, the weighting matrices and are chosen to be diagonal. A simple way for choosing and 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

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

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

In our case,

Substituting and in Eqn. 9 gives

where , , , ,

On observing Eq. 12, it can be seen that increasing causes control input to work harder to minimize state , which will predominately increase. If is increased, then will increase to compensate for the larger weight placed on state . Depending on the model, changing a single can affect multiple gains because each state is not independent. If is increased, then control input has to work less to minimize. In that case, LQR would generate a lower overall value of. 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,, while minimizing the deflection of the flexible link, where is the state column vector and is the gain row vector as shown earlier. Note that isidentity matrix and is column of zeros in Figure 1.

The reference state is defined as

and the controller is

hashtag
Controller Specifications:

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

Specification 1: Servo angle 2% settling time:

Specification 2: Servo angle percentage overshoot:

Specification 3: Maximum link angle deflection:

Specification 4: Maximum control effort (voltage):

hashtag
Controller Design Procedure:

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

  1. Obtain the and 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 and matrices, based on the following suggested maximum values of state and control excursions:

    Check if and (by finding eigenvalues of the matrix).

hashtag
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.

triangle-exclamation

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

hashtag
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.

hashtag
Results & Questions for Report

hashtag
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 () 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.

hashtag
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.

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.

  • 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)

  • 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 and weighting matrices parameters, till all specifications are met. Record the final Q and R matrices, the servo angle (), link angle () and voltage input plots.

  • 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 () link angle () and voltage input

  • To build the model, click down arrow on Monitor & Tune under Hardware tab and then Build for monitoring . This generates the controller code.
  • Align the flexible link along the 0 mark on the servo stand.

  • Double click on the scopes and open them.

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

  • Click Connect button under Monitor & Tune and then click Start

  • 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.

  • 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.

  • 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.

  • Turn the power off.

  • (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)
    BlB_lBl​
    τ\tauτ
    τ=η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​θ˙
    θ¨=−(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)
    x˙=Ax+Buy=Cx+Du\dot{x} = Ax + Bu \\ y = Cx + Dux˙=Ax+Buy=Cx+Du
    x=[θ    α    θ˙    α˙]Tx=[\theta \;\; \alpha \;\; \dot{\theta} \;\; \dot{\alpha}]^Tx=[θαθ˙α˙]T
    u=Vmu = V_mu=Vm​
    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)
    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)
    ′u′'u'′u′
    xix_ixi​
    i=1...ni = 1 . . . ni=1...n
    T=[B    AB    A2B…An−1B]T=[B \;\; AB \;\;A^2B… A^{n−1}B]T=[BABA2B…An−1B]
    rank(T)=nrank(T)=nrank(T)=n
    xxx
    uuu
    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)
    Q=QTQ = Q^TQ=QT
    R=RTR = R^TR=RT
    QQQ
    RRR
    RRR
    xxx
    [θ    α    θ˙    α˙]T[\theta \;\; \alpha \;\; \dot{\theta} \;\; \dot{\alpha}]^T[θαθ˙α˙]T
    uuu
    VmV_mVm​
    u=−Kxu = −Kxu=−Kx
    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)
    KKK
    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)
    VmVmVm
    RRR
    QQQ
    RRR
    QQQ
    RRR
    ∣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
    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)
    QQQ
    RRR
    RRR
    QQQ
    QQQ
    uuu
    JJJ
    KKK
    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)
    QQQ
    RRR
    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)
    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​
    qiq_iqi​
    VmV_mVm​
    xix_ixi​
    kik_iki​
    qθq_{\theta}qθ​
    kθk_{\theta}kθ​
    θ\thetaθ
    qiq_iqi​
    kik_i ki​
    RRR
    VVV
    JJJ
    KKK
    θdθ_dθd​
    xxx
    KKK
    CCC
    4×44×44×4
    DDD
    4×14×14×1
    xd=[θd    0    0    0]Tx_d=[θ_d \;\; 0\;\; 0\;\;0]^Txd​=[θd​000]T
    u=K(xd−x)u=K(x_d−x)u=K(xd​−x)
    30°30°30°
    ts≤0.5s t_s≤0.5sts​≤0.5s
    PO≤5%PO≤5 \% PO≤5%
    ∣α∣max≤10°|α|_{max}≤10°∣α∣max​≤10°
    ∣Vm∣max≤10V |V_{m}|_{max}≤10 V∣Vm​∣max​≤10V
    AAA
    BBB
    QQQ
    RRR
    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
    Q≥0Q \ge 0Q≥0
    R>0R > 0R>0
    θ\thetaθ
    file-archive
    32KB
    q_flex.zip
    archive
    arrow-up-right-from-squareOpen
    Figure 1. State-feedback Control Loop (Note:CCC is4×44×44×4 identity matrix andDDD is4×14×14×1 column of zeros.)
    QQQ
    RRR
    θ\thetaθ
    α\alphaα
    VmV_mVm​
    θ\thetaθ
    α\alphaα
    VmV_mVm​