www.gusucode.com > control_featured 案例源码程序 matlab代码 > control_featured/FRDPlantdemo1.m

    %% Design Compensator for Systems Represented by Frequency Response Data 
% This example shows how to design a compensator for a plant model defined
% by frequency response data (FRD) using Control System Designer.
%

% Copyright 2009-2012 The MathWorks, Inc.

%% Acquire Frequency Response Data (FRD) Plant Model
% Non-parametric representations of plant models, such as frequency
% response data, are often used for analysis and control design. These FRD
% models are typically obtained from:
%
% 1) Signal analyzer hardware that performs frequency domain measurements on
% systems.
%
% 2) Non-parametric estimation techniques using the systems time response
% data. You can use the following products to estimate FRD models:
%
%
% Simulink(R) Control Design(TM):
%
% * Function: <matlab:doc('frestimate') frestimate>
% * Example: <docid:slcontrol_examples.example-scdenginepad>.
%
% Signal Processing Toolbox(TM):
%
% * Function: <matlab:doc('tfestimate') tfestimate>.
%
% System Identification Toolbox(TM):
%
% * Functions: <matlab:doc('etfe') etfe>, <matlab:doc('spa') spa>,
% <matlab:doc('spafdr') spafdr>
%

%% FRD Model and Design Requirements
% In this example, design an engine speed controller that actuates the
% engine throttle angle:
%
% <<../FRDPlantDemo_Fig01.png>>

%%
% The frequency response of the engine is already estimated. Load and view
% the data.
load FRDPlantDemoData.mat
AnalyzerData

%%
% Create an FRD model object: 
FRDPlant = frd(AnalyzerData.Response,AnalyzerData.Frequency,...
    'Unit',AnalyzerData.FrequencyUnits);

%%
% The design requirements are:
%
% * Zero steady-state error for step reference speed changes
% * Phase margin greater than 60 degrees
% * Gain margin greater than 20 dB.

%% Design Compensator
% Open Control System Designer.
%
%  controlSystemDesigner({'bode','nichols'},FRDPlant)|
%
% The Control System Designer opens with both Bode and Nichols open-loop
% editors.
%
% <<../FRDPlantDemo_Fig02.png>>

%%
% You can design the compensator by shaping the open-loop frequency
% response in either the Bode editor or Nichols editor. In these editors,
% interactively modify the gain, poles, and zeros of the compensator.
%
% To satisfy the tracking requirement of zero steady-state error, add an
% integrator to the compensator. Right-click the Bode editor plot area, and
% select *Add Pole/Zero > Integrator*.
%%
% To meet the gain and phase margin requirements, add a zero to the
% compensator. Right-click the Bode editor plot area, and select *Add
% Pole/Zero > Real Zero*. Modify the location of the zero and the gain of
% the compensator until you satisfy the margin requirements.
%
%%
% One possible design that satisfies the design requirements is:
%
% $$ C(s) = \frac{0.001(s+4)}{s}. $$
%
%%
% This compensator design, which is a PI controller, achieves a 20.7 dB
% gain margin and a 70.8 degree phase margin.
%
% <<../FRDPlantDemo_Fig03.png>>

%%
% Export the designed compensator to the workspace. Click *Export*.

%% Validate the Design
% Validate the controller performance by simulating the engine response
% using a nonlinear model in Simulink(R). For this example, the validation
% simulation results are in |EngineStepResponse|.
%
% Plot the response of the engine to a reference speed change from 2000 to
% 2500 RPM:

plot(EngineStepResponse.Time,EngineStepResponse.Speed)
title('Engine Step Response')
xlabel('Time (s)')
ylabel('Engine Speed (RPM)')

%%
% The response shows zero steady-state error and well-behaved transients
% with the following metrics.
stepinfo(EngineStepResponse.Speed,EngineStepResponse.Time)