Simulink Control Design

Linearization of a Conveyor Model

This example shows the use of the operating point search and snapshot features along with the linearization of a SimMechanics model. (Requires SimMechanics)

Operating Condition Search

Open the model.

open_system('scdmechconveyor');

The steady state operating point can now be found using the operating specification object initialized using the simulated operating point. For the steady state operating point search, the Analysis Type for the SimMechanics machine must be set to be in Trimming mode. See the SimMechanics documentation for details on this feature.

set_param('scdmechconveyor/Mechanical Environment','AnalysisType','Trimming')
opspec = operspec('scdmechconveyor');

For SimMechanics models, the operating condition search in some cases can converge to a steady state condition more quickly using a nonlinear least squares algorithm. This algorithm is available if the Optimization Toolbox is licensed. An iterative report of the search can also be displayed by using the LINEARIZEOPTIONS command.

opt = findopOptions('OptimizerType','lsqnonlin','DisplayReport','none');
opt.OptimizationOptions.MaxFunEvals = 2000;

To ensure that the algebraic constraints in the SimMechanics model are met, the trim output port must be specified to be zero.

opspec.Outputs.y = zeros(8,1);
opspec.Outputs.Known = ones(8,1);

The steady state operating point can now be found using the FINDOP command.

[op,opreport] = findop('scdmechconveyor',opspec,opt);

Display the final report.

opreport
 Operating Report for the Model scdmechconveyor.
 (Time-Varying Components Evaluated at time t=0)

Operating point specifications were successfully met.
States: 
----------
(1.) scdmechconveyor/Position Controller/H_inf Controller
      x:         -1.08      dx:      2.84e-14 (0)
      x:     -7.63e-12      dx:     -1.72e-12 (0)
      x:         0.199      dx:     -1.38e-13 (0)
      x:         0.199      dx:     -8.08e-15 (0)
      x:        0.0743      dx:      1.43e-13 (0)
(2.) scdmechconveyor/Position Controller/Loopshaping Weight
      x:      2.59e-07      dx:      -1.6e-14 (0)
      x:      2.59e-07      dx:     -1.31e-15 (0)
      x:      9.66e-08      dx:     -3.85e-14 (0)
(3.) scdmechconveyor/Position Controller/Prefilter
      x:        0.0103      dx:      2.44e-13 (0)
(4.) scdmechconveyor/Position Controller/inv(W)
      x:     -2.59e-07      dx:       1.6e-14 (0)
      x:     -2.59e-07      dx:      1.31e-15 (0)
      x:     -9.66e-08      dx:      1.07e-13 (0)
(5.) Prismatic.P1.Position
      x:         0.103      dx:      8.46e-22 (0)
(6.) Prismatic.P1.Velocity
      x:      8.46e-22      dx:      3.29e-13 (0)
(7.) Revolute.R1.Position
      x:        -0.881      dx:     -1.63e-21 (0)
(8.) Revolute.R1.Velocity
      x:     -1.63e-21      dx:     -2.65e-12 (0)
(9.) Revolute1.R1.Position
      x:          0.83      dx:         9e-21 (0)
(10.) Revolute1.R1.Velocity
      x:         9e-21      dx:      2.34e-12 (0)
(11.) Revolute3.R1.Position
      x:        -0.172      dx:     -3.01e-21 (0)
(12.) Revolute3.R1.Velocity
      x:     -3.01e-21      dx:     -5.26e-13 (0)
(13.) Revolute5.R1.Position
      x:       0.00175      dx:      5.55e-22 (0)
(14.) Revolute5.R1.Velocity
      x:      5.55e-22      dx:     -7.57e-14 (0)

Inputs: None 
----------

Outputs: 
----------
(1.) scdmechconveyor/MSB Trimming Out
      y:     -2.31e-13    (0)
      y:      1.41e-13    (0)
      y:     -9.12e-13    (0)
      y:      1.61e-13    (0)
      y:      8.41e-22    (0)
      y:     -3.35e-22    (0)
      y:     -7.27e-22    (0)
      y:     -2.47e-21    (0)

Before linearization of the model can be completed, the Analysis Type for the SimMechanics model needs to be restored.

set_param('scdmechconveyor/Mechanical Environment','AnalysisType','Forward dynamics')

Linearize the Model

In this model the open loop plant model between the conveyor position and the torque command can be found using the following input and outputs:

io(1) = linio('scdmechconveyor/Joint Sensor',1,'openoutput');
io(2) = linio('scdmechconveyor/Position Controller',1,'input');

Linearize the model.

sys = linearize('scdmechconveyor',op,io);

View the linearized model and corresponding Bode plot.

sysm = zpk(sys)
bodemag(sysm)
sysm =
 
  From input "Torque" to output "Joint Sensor":
        -2.0818
  -------------------
  (s-3.481) (s+3.481)
 
Continuous-time zero/pole/gain model.

Close the model.

bdclose('scdmechconveyor')