From: <par...@us...> - 2011-08-02 15:28:26
|
Revision: 8429 http://octave.svn.sourceforge.net/octave/?rev=8429&view=rev Author: paramaniac Date: 2011-08-02 15:28:20 +0000 (Tue, 02 Aug 2011) Log Message: ----------- control: touch up ncfsyn and example Modified Paths: -------------- trunk/octave-forge/main/control/devel/MDSSystem.m trunk/octave-forge/main/control/devel/ncfsyn/ncfsyn.m Modified: trunk/octave-forge/main/control/devel/MDSSystem.m =================================================================== --- trunk/octave-forge/main/control/devel/MDSSystem.m 2011-08-01 21:45:22 UTC (rev 8428) +++ trunk/octave-forge/main/control/devel/MDSSystem.m 2011-08-02 15:28:20 UTC (rev 8429) @@ -1,16 +1,16 @@ +% =============================================================================== +% Robust Control of a Mass-Damper-Spring System +% =============================================================================== +% Reference: Gu, D.W., Petkov, P.Hr. and Konstantinov, M.M. +% Robust Control Design with Matlab, Springer 2005 +% =============================================================================== + % Tabula Rasa clear all, close all, clc -% Nominal Values -m_nom = 3; % Mass -c_nom = 1; % Damping Coefficient -k_nom = 2; % Spring Stiffness - -% Perturbations -p_m = 0.4; % 40% uncertainty in the mass -p_c = 0.2; % 20% uncertainty in the damping coefficient -p_k = 0.3; % 30% uncertainty in the spring stiffness - +% =============================================================================== +% System Model +% =============================================================================== % +---------------+ % | d_m 0 0 | % +-----| 0 d_c 0 |<----+ @@ -23,6 +23,16 @@ % u ----->| |-----> y % +---------------+ +% Nominal Values +m_nom = 3; % Mass +c_nom = 1; % Damping Coefficient +k_nom = 2; % Spring Stiffness + +% Perturbations +p_m = 0.4; % 40% uncertainty in the mass +p_c = 0.2; % 20% uncertainty in the damping coefficient +p_k = 0.3; % 30% uncertainty in the spring stiffness + % State-Space Representation A = [ 0, 1 -k_nom/m_nom, -c_nom/m_nom ]; @@ -51,12 +61,36 @@ D22 = [ 0 ]; -inname = {"u_m", "u_c", "u_k", "u"}; % Input Names -outname = {"y_m", "y_c", "y_k", "y"}; % Output Names +inname = {'u_m', 'u_c', 'u_k', 'u'}; % Input Names +outname = {'y_m', 'y_c', 'y_k', 'y'}; % Output Names G_nom = ss (A, [B1, B2], [C1; C2], [D11, D12; D21, D22], \ - "inname", inname, "outname", outname); + 'inputname', inname, 'outputname', outname); + +% =============================================================================== +% Frequency Analysis of Uncertain System +% =============================================================================== + +% Uncertainties: -1 <= delta_m, delta_c, delta_k <= 1 +[delta_m, delta_c, delta_k] = ndgrid ([-1, 0, 1], [-1, 0, 1], [-1, 0, 1]); +w = logspace (-1, 1, 100); % Frequency Vector +figure (1) + +for k = 1 : numel (delta_m) + Delta = diag ([delta_m(k), delta_c(k), delta_k(k)]); + G_per = lft (Delta, G_nom); + bode (G_per, w) + subplot (2, 1, 1) + hold on + subplot (2, 1, 2) + hold on +endfor + + +% =============================================================================== +% Mixed Sensitivity H-infinity Controller Design +% =============================================================================== % +-------+ % +--------------------->| W_p |----------> e_p % | +-------+ @@ -72,11 +106,11 @@ % +-----------------------------------------+ % Weighting Functions -s = tf ("s"); +s = tf ('s'); W_p = 0.95 * (s^2 + 1.8*s + 10) / (s^2 + 8.0*s + 0.01); W_u = 10^-2; -% Suboptimal H-infinity Controller Design +% Mixed Sensitivity H-infinity Controller Design G = G_nom(4, 4); % Extract output y and input u %K = mixsyn (G, W_p, W_u); %[K, ~, gamma] = mixsyn (G, W_p, W_u) @@ -91,33 +125,38 @@ % Closed Loop T = feedback (L); -figure (1) +figure (2) sigma (T) -figure (2) +figure (3) sigma (N) norm (N, inf) -figure (3) +figure (4) step (T) -figure (4) +% =============================================================================== +% H-infinity Loop-Shaping Design +% =============================================================================== -w = logspace (-1, 1, 100); +W1 = 8 * (2*s + 1) / (0.9*s); % Precompensator +W2 = 1; % Postcompensator +factor = 1.1 % Suboptimal Controller -% Uncertainties -% -1 <= delta_m, delta_c, delta_k <= 1 -[delta_m, delta_c, delta_k] = ndgrid ([-1, 0, 1], [-1, 0, 1], [-1, 0, 1]); +% Compute the suboptimal positive feedback controller +K = ncfsyn (G, W1, W2, factor) -for k = 1 : numel (delta_1) - Delta = diag ([delta_m(k), delta_c(k), delta_k(k)]); - G_per = lft (Delta, G_nom); - %figure (4) - bode (G_per, w) - subplot (2, 1, 1) - hold on - subplot (2, 1, 2) - hold on -endfor \ No newline at end of file +K = -K; % negative feedback controller + +% Open Loop +L = G * K; + +% Closed Loop +T = feedback (L); + +figure (5) +step (T) + +% =============================================================================== Modified: trunk/octave-forge/main/control/devel/ncfsyn/ncfsyn.m =================================================================== --- trunk/octave-forge/main/control/devel/ncfsyn/ncfsyn.m 2011-08-01 21:45:22 UTC (rev 8428) +++ trunk/octave-forge/main/control/devel/ncfsyn/ncfsyn.m 2011-08-02 15:28:20 UTC (rev 8429) @@ -21,13 +21,42 @@ ## Compute positive feedback controller using the McFarlane/Glover Loop Shaping Design Procedure. ## Uses SLICOT SB10ID, SB10KD and SB10ZD by courtesy of ## @uref{http://www.slicot.org, NICONET e.V.} +## +## @strong{Inputs} +## @table @var +## @item G +## LTI model of plant. +## @item W1 +## LTI model of precompensator. Model must be SISO or of appropriate size. +## An identity matrix is taken if @var{W1} is not specified or if an empty model +## @code{[]} is passed. +## @item W2 +## LTI model of postcompensator. Model must be SISO or of appropriate size. +## An identity matrix is taken if @var{W2} is not specified or if an empty model +## @code{[]} is passed. +## @item factor +## @code{factor = 1} implies that an optimal controller is required. +## @code{factor > 1} implies that a suboptimal controller is required, +## achieving a performance taht is @var{factor} times less than optimal. +## Default value is 1. +## @end table +## +## @strong{Outputs} +## @table @var +## @item K +## State-space model of the H-infinity loop-shaping controller. +## @item N +## State-space model of the lower LFT of @var{P} and @var{K}. +## @item gamma +## L-infinity norm of @var{N}. +## @end table ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> ## Created: July 2011 ## Version: 0.1 -% function [K, N, gamma] = ncfsyn (G, W1 = [], W2 = [], factor = 1.0) +% function [K, N, gamma, info] = ncfsyn (G, W1 = [], W2 = [], factor = 1.0) function K = ncfsyn (G, W1 = [], W2 = [], factor = 1.0) if (nargin == 0 || nargin > 4) @@ -65,7 +94,7 @@ K = W1 * Ks * W2; - %struct ("Gs", Gs, "Ks", Ks); + %struct ("Gs", Gs, "Ks", Ks, "rcond", rcond); endfunction @@ -76,12 +105,12 @@ W = ss (eye (s)); else W = ss (W); - if (! isstable (W)) - error ("ncfsyn: %s must be stable", inputname (1)); - endif - if (! isminimumphase (W)) - error ("ncfsyn: %s must be minimum-phase", inputname (1)); - endif + %if (! isstable (W)) + % error ("ncfsyn: %s must be stable", inputname (1)); + %endif + %if (! isminimumphase (W)) + % error ("ncfsyn: %s must be minimum-phase", inputname (1)); + %endif [p, m] = size (W); if (m == s && p == s) # model is of correct size return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |