Control Tutorials For MATLAB and Simulink - Motor Position - Simulink Modeling
Control Tutorials For MATLAB and Simulink - Motor Position - Simulink Modeling
SYSTEM
CONTROL
PID Related
Tutorial
ROOT LOCUS Links
FREQUENCY
Simulink
Basics
STATE-SPACE
Modeling
DIGITAL w/
Simulink
DC Motor
SIMULINK
Activity
MODELING
Related
CONTROL
External
SIMSCAPE Links
Simulink
Modeling
Video
Simscape
Video
Contents
Physical setup
Physical setup
A common actuator in control systems is the DC motor. It directly provides
rotary motion and, coupled with wheels or drums and cables, can provide
translational motion. The electric circuit of the armature and the free-body
The input to the system is the voltage applied to the motor's armature ( ),
while the output is the angular position of the shaft ( ).
(1)
(2)
In SI units, the motor torque and back emf constants are equal, that is,
.
Building the model with Simulink
This system will be modeled by summing the torques acting on the rotor
inertia and integrating the rotor's angular acceleration to give the velocity,
and integrating the velocity to get position. Also, Kirchoff's laws will be
applied to the armature circuit. First, we will model the integrals of the rotor
(3)
(4)
To build the simulation model, open Simulink and open a new model
Label the input line "d2/dt2(theta)" and the output line "d/dt(theta)" as
shown below. To add such a label, double-click in the empty space just
above the line.
Insert a third Integrator block above the first one and draw lines to and
from its input and output terminals.
Label the input line "d/dt(i)" and the output line "i".
Next, we will apply Newton's law and Kirchoff's law to the motor system to
generate the following equations.
(5)
(6)
below.
Insert two Gain blocks from the Simulink/Math Operations library, one
attached to each of the leftmost integrators.
Change the label of this Gain block to "Inertia" by clicking on the word
Similarly, edit the other Gain's value to "1/L" and it's label to
"Inductance".
Insert two Add blocks from the Simulink/Math Operations library, one
Edit the signs of the Add block corresponding to rotation to "+-" since
Edit the signs of the other Add block to "-+-" to represent the signs of
the terms in Kirchoff's equation.
Now, we will add in the torques which are represented in Newton's equation.
First, we will add in the damping torque.
Insert a Gain block below the "Inertia" block, then select it by single-
clicking on it. Next select Flip Block from the Rotate & Flip menu
(reached by right-clicking) to flip the block from left to right. You can
Set the Gain value to "b" and rename the block "damping".
Tap a line (hold Ctrl while drawing or right-click) off the first rotational
Integrator's output (d/dt(theta)) and connect it to the input of the
Draw a line from the damping Gain output to the negative input of the
Insert a Gain block attached to the positive input of the rotational Add
Edit it's value to "K" to represent the motor constant and label it "Kt".
Continue drawing the line leading from the current Integrator and
Now, we will add in the voltage terms which are represented in Kirchoff's
equation. First, we will add in the voltage drop across the armature
resistance.
Insert a Gain block above the Inductance block and flip it left to right.
Set the Gain value to "R" and rename this block "Resistance".
Tap a line off the current Integrator's output and connect it to the input
Draw a line from the Resistance Gain output to the upper negative input
Insert a Gain block and attach it to the other negative input of the
current Add block with a line.
Edit it's value to "K" to represent the motor back emf constant and label
it "Ke".
Tap a line off the first rotational Integrator's output (d/dt(theta)) and
download the file for this system by right-clicking here and selecting save
link as. We use this model in the DC Motor Position: Simulink Controller
Design page
Building the model with Simscape
In this section, we alternatively show how to build the DC Motor model using
the physical modeling blocks of the Simscape extension to Simulink. The
Open a new Simulink model and insert the following list of blocks.
Three Out1 blocks and one In1 block from the Simulink/Ports &
Subsystems library
parameters the following variables and units. We will eventually define these
variables at the command line of the MATLAB workspace. Note that since
the motor torque constant and the back emf constant are equal if the units
are consistent, we only need to define one of the two.
two nodes. In this case, we employ the block to measure the position and
velocity of the motor shaft as compared to a fixed reference represented by
the Mechanical Rotational Reference block.
can perform a units conversion between the physical signals and the
Simulink signals. In our case, we can leave the units undefined since the
input and output of each of the conversion blocks have the same units. In
general, the Simscape blockset is employed to model the physical plant,
The Solver Configuration block is employed for defining the details of the
numerical solver employed in running the Simscape simulation. We will use
the default settings for this block.
Next, connect and label the components so that they appear as in the figure
below. Double-click on the lines which are connected to the Out1 blocks and
label them "Current", "Position", and "Speed". Also click on the In1 block
and label it "Voltage".
We now need to define the parameters used in our simulation. Type the
following commands at the prompt of the MATLAB command window.
R = 4;
L = 2.75E-6;
K = 0.0274;
J = 3.2284E-6;
b = 3.5077E-6;
You can save these components in a single subsystem with one input and
three outputs. Select all of the blocks and then select Create Subsystem
from Selection after right-clicking on the selected portion. Also label the
subsystem and signals as shown in the following figure.
You can download the complete model file by right-clicking here and then
selecting Save link as but note that you will need the Simscape addition to
You can also build the DC motor model in Simulink by importing one of the
models we created in MATLAB in the DC Motor Position: System Modeling
page. In this page we specifically created a transfer function model and a
state-space model, both of which may be imported. A zero-pole-gain format
model can also be imported. Recall the following commands used to build a
state-space model of the DC motor in MATLAB.
A = [0 1 0
0 -b/J K/J
0 -K/L -R/L];
B = [0 ; 0 ; 1/L];
C = [1 0 0];
D = 0;
This model can then be imported using the LTI System block from the
Control System Toolbox library as shown below. This figure demonstrates
how the model is defined by entering "ss(A,B,C,D)" into the LTI system
variable cell, though the tf and zpk commands could also be employed.
Adding In1 and Out1 ports from the Ports & Subsystems library then creates
International License.