This example shows how to generate an array of LTI models that represents the plant variations of a control system from a Simulink model. This array of models is used in the Control System Designer for control design.
In armature-controlled DC motors, the applied voltage
Va controls the angular velocity of the shaft. A simplified model of the DC motor is shown below.
Open the Simulink model for the DC motor.
scdDCMotor mdl = 'scdDCMotor';
The goal of the controller is to provide tracking to step changes in reference angular velocity.
For this example, the physical constants for the motor are:
R = 2.0 +/- 10% Ohms
L = 0.5 Henrys
Km = 0.1 Torque constant
Kb = 0.1 Back emf constant
Kf = 0.2 Nms
J = 0.02 +/- .01 kg m^2/s^2
Note that the parameters R and J are specified as a range of values.
To design a controller which will work for all physical parameter values, we create a representative set of plants by sampling these values.
Values of R and J are at their nominal, minimum, and maximum values.
R = [2,1.8,2.2]; J = [.02,.03,.01];
To create an LTI array of plant models, batch linearize the DC motor plant. For each combination of the sample values of R and J, linearize the Simulink model. To do so, specify a input linearization point at the output of the controller block and a linearization output point with loop opening at the output of the load block as shown in the model.
% Get the linearization I/O specified in the model. io = getlinio(mdl); ct = 1; % Vary the plant parameters R and J. [R_grid, J_grid] = ndgrid(R,J); params(1).Name = 'R'; params(1).Value = R_grid; params(2).Name = 'J'; params(2).Value = J_grid; % Linearize the model sys = linearize(mdl,io,params);
Open the Control System Designer, importing the array of plant models.
Using the Control System Designer, you can design a controller for the nominal plant model while simultaneously visualizing the effect on the other plant models as shown below.
The root locus editor displays the root locus for the nominal model and the closed-loop pole locations associated with the other plant models.
The Bode editor displays both the nominal model response and responses of the other plant models.
The step responses show that reference tracking is not achieved for any of the plant models.
Using the tools in the Control System Designer, design the following compensator for reference tracking.
The resulting design is shown below. The closed-loop step response shows that the goal of reference tracking is achieved with zero steady-state error for all models defined in the plant set. However, if a zero percent overshoot requirement is necessary, not all responses would satisfy this requirement.
To export the designed controller to the MATLAB workspace, click Export. In the Export Model dialog box, select C, and click Export. Write the controller parameters to the Simulink model.
>> [Cnum,Cden] = tfdata(C,'v');
>> hws = get_param(mdl, 'modelworkspace');
For additional information on using the multimodel features of the Control System Designer, see example: "Compensator Design for a Set of Plant Models".