2 %% Robust control of a mass-damper-spring system.
3 %% Type @code{which MDSSystem} to locate,
4 %% @code{edit MDSSystem} to open and simply
5 %% @code{MDSSystem} to run the example file.
7 % ===============================================================================
8 % Robust Control of a Mass-Damper-Spring System Lukas Reichlin August 2011
9 % ===============================================================================
10 % Reference: Gu, D.W., Petkov, P.Hr. and Konstantinov, M.M.
11 % Robust Control Design with Matlab, Springer 2005
12 % ===============================================================================
15 clear all, close all, clc
17 % ===============================================================================
19 % ===============================================================================
22 % +-----| 0 d_c 0 |<----+
23 % u_m | | 0 0 d_k | | y_m
24 % u_c | +---------------+ | y_c
26 % | +---------------+ |
34 c_nom = 1; % damping coefficient
35 k_nom = 2; % spring stiffness
38 p_m = 0.4; % 40% uncertainty in the mass
39 p_c = 0.2; % 20% uncertainty in the damping coefficient
40 p_k = 0.3; % 30% uncertainty in the spring stiffness
42 % State-Space Representation
44 -k_nom/m_nom, -c_nom/m_nom ];
47 -p_m, -p_c/m_nom, -p_k/m_nom ];
52 C1 = [ -k_nom/m_nom, -c_nom/m_nom
58 D11 = [ -p_m, -p_c/m_nom, -p_k/m_nom
70 inname = {'u_m', 'u_c', 'u_k', 'u'}; % input names
71 outname = {'y_m', 'y_c', 'y_k', 'y'}; % output names
73 G_nom = ss (A, [B1, B2], [C1; C2], [D11, D12; D21, D22], ...
74 'inputname', inname, 'outputname', outname);
76 G = G_nom(4, 4); % extract output y and input u
79 % ===============================================================================
80 % Frequency Analysis of Uncertain System
81 % ===============================================================================
83 % Uncertainties: -1 <= delta_m, delta_c, delta_k <= 1
84 [delta_m, delta_c, delta_k] = ndgrid ([-1, 0, 1], [-1, 0, 1], [-1, 0, 1]);
86 % Bode Plots of Perturbed Plants
87 w = logspace (-1, 1, 100); % frequency vector
90 for k = 1 : numel (delta_m)
91 Delta = diag ([delta_m(k), delta_c(k), delta_k(k)]);
92 G_per = lft (Delta, G_nom);
101 % ===============================================================================
102 % Mixed Sensitivity H-infinity Controller Design (S over KS Method)
103 % ===============================================================================
105 % +--------------------->| W_p |----------> e_p
108 % | +---->| W_u |----------> e_u
112 % r + e | +-------+ u | | G_nom |
113 % ----->(+)---+-->| K |----+--->| |----+----> y
114 % ^ - +-------+ +---------+ |
116 % +-----------------------------------------+
118 % Weighting Functions
119 s = tf ('s'); % transfer function variable
120 W_p = 0.95 * (s^2 + 1.8*s + 10) / (s^2 + 8.0*s + 0.01); % performance weighting
121 W_u = 10^-2; % control weighting
124 K_mix = mixsyn (G, W_p, W_u); % mixed-sensitivity H-infinity synthesis
127 L_mix = G * K_mix; % open loop
128 T_mix = feedback (L_mix); % closed loop
132 bode (K_mix) % bode plot
135 step (T_mix, 10) % step response for 10 seconds
138 % ===============================================================================
139 % H-infinity Loop-Shaping Design (Normalized Coprime Factor Perturbations)
140 % ===============================================================================
143 W1 = 8 * (2*s + 1) / (0.9*s); % precompensator
144 W2 = 1; % postcompensator
145 factor = 1.1; % suboptimal controller
148 K_ncf = ncfsyn (G, W1, W2, factor); % positive feedback controller
151 K_ncf = -K_ncf; % negative feedback controller
152 L_ncf = G * K_ncf; % open loop
153 T_ncf = feedback (L_ncf); % closed loop
157 bode (K_ncf) % bode plot
160 step (T_ncf, 10) % step response for 10 seconds
162 % ===============================================================================