DC_Motor_Speed_Simulink_Controller_Desig
DC_Motor_Speed_Simulink_Controller_Desig
SYSTEM
CONTROL
Contents
PID
Extracting a linear model into MATLAB
ROOT LOCUS
Openloop response
FREQUENCY Closedloop response with lag compensator
DIGITAL
From the DC Motor Speed: Simulink Modeling page we generated two
different DC motor models in Simulink. We will now employ these models
SIMULINK within Simulink to simulate the system response and design different
approaches to control.
MODELING
CONTROL
Extracting a linear model into MATLAB
A linear model of the system can be extracted from the Simulink model into
will specifically use the base Simulink model developed from first
principles shown below. You can download this model here, or you can
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SimulinkControl 1/11
12/17/2016 Control Tutorials for MATLAB and Simulink Motor Speed: Simulink Control
Recall that the physical parameters have to be set if they have not
J = 0.0 ;
b = 0. ;
K = 0.0 ;
R = ;
L = 0.5;
We then need to identify the inputs and outputs of the model we wish to
extract. First rightclick on the signal representing the Voltage input in the
Simulink model. Then choose Linearization > Input Point from the
The input and output signals should now be identified on your model by
arrow symbols as shown in the figure below.
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SimulinkControl 2/11
12/17/2016 Control Tutorials for MATLAB and Simulink Motor Speed: Simulink Control
In order to perform the extraction, select from the menus at the top of the
model window Tools > Control Design > Linear Analysis. This will cause
the Linear Analysis Tool to open. Within the Linear Analysis Tool
window, the Operating Point to be linearized about can remain the default,
linear components. Note that this process can be used extract linear
approximations of models with nonlinear elements too.
We will further verify the model extraction by looking at the model itself.
The linearized model can be exported by simply dragging the object into
the MATLAB Workspace. This object can then be used within MATLAB in
MATLAB command window demonstrates that the resulting model has the
following form.
(1)
This model matches the one generated in the DC Motor Speed: System
Modeling page. This can be seen by repeating the MATLAB commands
given below.
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SimulinkControl 3/11
12/17/2016 Control Tutorials for MATLAB and Simulink Motor Speed: Simulink Control
s = tf 's' ;
P_motor = K/ J*s+b * L*s+R +K^ ;
zpk P_motor
ans =
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
s+9.997 s+ .00
Openloop response
order to simulate the step response, the details of the simulation must first
be set. This can be accomplished by selecting Configuration Parameters
from the Simulation menu. Within the resulting menu, define the length for
which the simulation is to run in the Stop time field. We will enter "3" since
3 seconds will be long enough for the step response to reach steady state.
Within this window you can also specify various aspects of the numerical
solver, but we will just use the default values for this example.
Next we need to add an input signal and a means for displaying the output
of our simulation. This is done by doing the following:
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SimulinkControl 4/11
12/17/2016 Control Tutorials for MATLAB and Simulink Motor Speed: Simulink Control
Then run the simulation (press CtrlT or select Start from the Simulation
menu). When the simulation is finished, doubleclick on the scope and hit
its autoscale button. You should see the following output.
(2)
We will then put the lag compensator in series with the motor subsystem
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SimulinkControl 5/11
12/17/2016 Control Tutorials for MATLAB and Simulink Motor Speed: Simulink Control
and will feed back the motor's speed for comparison to a desired
reference.
field to "[44 44]" and the Denominator coefficients field to "[1 0.01]".
Then connect and label the components as shown in the following figure
You can download our version of the closedloop system model here,
Motor_Model_lag.mdl.
Then run the simulation (press CtrlT or select Start from the Simulation
menu). When the simulation is finished, doubleclick on the scope and hit
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SimulinkControl 6/11
12/17/2016 Control Tutorials for MATLAB and Simulink Motor Speed: Simulink Control
where the lag compensator was originally designed. Note that while we
used the physicsbased Simulink model developed in the DC Motor
We have shown in the above and in other pages of this example that the
lag compensator we have designed meets all of the given design
Speed: Frequency Domain Methods for Controller Design page for more
details on the design of the lag compensator, but the fact that the DC gains
and phase margins are similar indicate that the responses under lag and
lead control would have similar amounts of error in steady state and
similar amounts of overshoot. The difference in response would come in
that the larger gain crossover frequency provided by the lead compensator
would make the system response faster than with the lag compensator. We
(3)
To see the precise effect of the lead compensator as compared to our lag
compensator, let's modify our Simulink model from above as follows:
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SimulinkControl 7/11
12/17/2016 Control Tutorials for MATLAB and Simulink Motor Speed: Simulink Control
Disconnect the Step block and Scope block from the rest of the model.
Copy the blocks forming the closedloop of the model: the Sum block,
the Transfer Function block, and the DC Motor subsystem. Then paste
the Mux and connect the output of the Mux to the Scope.
Connect the Step block to the Sum block of the original feedback
system. Then branch off from this line and connect it to the Sum block
The Mux block serves to bundle the two signals into a single line, this way
the Scope will plot both speed signals on the same set of axes. When you
are done, your model should appear as follows.
Running the simulation and observing the output produced by the scope,
you will see that both responses have a steadystate error that approaches
zero. Zooming in on the graphs you can generate a figure like the one
shown below. Comparing the two graphs, the purple response belonging
to the lead compensated system has a much smaller settle time and
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SimulinkControl 8/11
12/17/2016 Control Tutorials for MATLAB and Simulink Motor Speed: Simulink Control
then might we prefer to use the lag compensator even though it is slower
than the lead compensator? The advantage of the lag compensator in this
case is that by responding more slowly it requires less control effort than
the lead compensator. Less control effort means that less power is
consumed and that the various components can be sized smaller since
We will now modify our simulation to explicitly observe the control effort
requirements of our two feedback systems. We will do this by sending our
various signals to the workspace for plotting and further manipulation if
desired. Specifically, delete the Scope and Mux blocks from your Simulink
model. Then insert four To Workspace blocks from the Simulink\Sinks
library. Doubleclick on each of the blocks and change their Save format
from Structure to Array. Also provide a Variable name within each block
that will make sense to you. You can then connect the blocks to the
existing model and label them as shown below. You can download our
version of this Simulink model here, Motor_Model_leadlag.mdl.
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SimulinkControl 9/11
12/17/2016 Control Tutorials for MATLAB and Simulink Motor Speed: Simulink Control
Then change the simulation stop time to 1 second and run the model. The
act of running the simulation will send to the MATLAB workspace a series
of arrays corresponding to the variables setup in your model with the To
Workspace blocks. Furthermore, the time vector used by that run of the
simulation is stored in the default variable tout. You can now plot the
results of your simulation from the workspace. Enter the following code to
subplot , ,
plot tout,ulag ;
xlabel 'time seconds '
ylabel 'control effort volts '
subplot , ,
plot tout,ulead ;
xlabel 'time seconds '
ylabel 'control effort volts '
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SimulinkControl 10/11
12/17/2016 Control Tutorials for MATLAB and Simulink Motor Speed: Simulink Control
Examination of the above shows that the control effort required by the lead
One such technique is explored in the Aircraft Pitch: State Space Methods
for Controller Design page.
http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SimulinkControl 11/11