You are on page 1of 10

DC Motor Position: System Modeling

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 equivalent circuit of the armature and the free-body diagram of the rotor are
shown in the following figure.

For this example, we will assume the following values for the physical parameters. These values were derived by experiment from
an actual motor in Carnegie Mellon's undergraduate controls lab.
(J)
moment of inertia of the rotor
3.2284E-6 kg.m^2
(b)
motor viscous friction constant
3.5077E-6 N.m.s
(Kb)
electromotive force constant
0.0274 V/rad/sec
(Kt)
motor torque constant
0.0274 N.m/Amp
(R)
electric resistance
4 Ohm
(L)
electric inductance
2.75E-6H
In this example, we assume that the input of the system is the voltage source (V) applied to the motor's armature, while the output
is the position of the shaft (theta). The rotor and shaft are assumed to be rigid. We further assume a viscous friction model, that is,
the friction torque is proportional to shaft angular velocity.

System equations
In general, the torque generated by a DC motor is proportional to the armature current and the strength of the magnetic field. In this
example we will assume that the magnetic field is constant and, therefore, that the motor torque is proportional to only the armature
current i by a constant factor Kt as shown in the equation below. This is referred to as an armature-controlled motor.
(1)
The back emf, e, is proportional to the angular velocity of the shaft by a constant factor Kb.
(2)
In SI units, the motor torque and back emf constants are equal, that is, Kt = Ke; therefore, we will use K to represent both the motor
torque constant and the back emf constant.
From the figure above, we can derive the following governing equations based on Newton's 2nd law and Kirchhoff's voltage law.
(3)

(4)
1. Transfer Function
Applying the Laplace transform, the above modeling equations can be expressed in terms of the Laplace variable s.
(5)
(6)
We arrive at the following open-loop transfer function by eliminating I(s) between the two above equations, where the rotational
speed is considered the output and the armature voltage is considered the input.

(7)

However, during this example we will be looking at the position as the output. We can obtain the position by integrating the speed,
therefore, we just need to divide the above transfer function by s.

(8)

Design requirements
We will want to be able to position the motor very precisely, thus the steady-state error of the motor position should be zero when
given a commanded position. We will also want the steady-state error due to a constant disturbance to be zero as well. The other
performance requirement is that the motor reaches its final position very quickly without excessive overshoot. In this case, we want
the system to have a settling time of 40 ms and an overshoot smaller than 16%.
If we simulate the reference input by a unit step input, then the motor position output should have:
Settling time less than 40 milliseconds
Overshoot less than 16%
No steady-state error, even in the presence of a step disturbance input

MATLAB representation
1. Transfer Function
We can represent the above open-loop transfer function of the motor in MATLAB by defining the parameters and transfer function
as follows. Running this code in the command window produces the output shown below.
J = 3.2284E-6;
b = 3.5077E-6;
K = 0.0274;
R = 4;
L = 2.75E-6;
s = tf('s');
P_motor = K/(s*((J*s+b)*(L*s+R)+K^2))
P_motor =
0.0274
------------------------------------------8.878e-12 s^3 + 1.291e-05 s^2 + 0.0007648 s
Continuous-time transfer function.

DC Motor Position: System Analysis

Open-loop response
Closed-loop response

From the main problem, the dynamic equations in the Laplace domain and the open-loop transfer function of the DC Motor are the
following.
(1)
(2)

(3)
For the original problem setup and the derivation of the above equations, please refer to the DC Motor Position: System Modeling
page.
For a 1-radian step reference, the design criteria are given are the following.
Settling time less than 0.040 seconds
Overshoot less than 16%
No steady-state error, even in the presence of a step disturbance input

Open-loop response
First create a new m-file and type in the following commands (refer to the main problem for the details of getting these commands).
J = 3.2284E-6;
b = 3.5077E-6;
K = 0.0274;
R = 4;
L = 2.75E-6;
s = tf('s');
P_motor = K/(s*((J*s+b)*(L*s+R)+K^2));
Now let's see how the uncompensated open-loop system performs. Specifically, we will use the MATLAB command step to
analyze the open-loop step response. Add the following commands onto the end of the m-file and run it in the MATLAB command
window and you will get the associated plot shown below.
t = 0:0.001:0.2;
step(P_motor,t)

From the above plot, we can see that when 1 volt is applied to the system the motor position grows unbounded. This is obviously at
odds with the given requirements, in particular, that there be no steady-state error. The open-loop response of the system is not
even stable. Stability of a system can be verified with the MATLAB command isstable where a returned value of TRUE (1)
indicates that the system is stable and a returned value of FALSE (0) indicates that the system is not stable.
isstable(P_motor)
ans =
0

Stability of the system can also be determined from the poles of the transfer function where the poles can be identified using the
MATLAB command pole as shown below.
pole(P_motor)
ans =
1.0e+06 *
0
-1.4545
-0.0001
As indicated by this function, one of the poles of the open-loop transfer function is on the imaginary axis while the other two poles
are in the left half of the complex s-plane. A pole on the imaginary axis indicates that the free response of the system will not grow
unbounded, but also will not decay to zero. Even though the free response will not grow unbounded, a system with a pole on the
imaginary axis can grow unbounded when given an input, even when the input is bounded. This fact is in agreement with what we
have already seen. In this particular case, the pole at the origin behaves like an integrator. Therefore, when the system is given a
step input its output continues to grow to infinity in the same manner that an integral of a constant would grow to infinity as the
upper limit of the integral is made larger.

Closed-loop response
Let's now consider the closed-loop response of the system where the system schematic has the following structure.

The closed-loop transfer function for the above with the controller C(s) simply set equal to 1 can be generated using the MATLAB
command feedback as shown below.
sys_cl = feedback(P_motor,1)
sys_cl =
0.0274
---------------------------------------------------8.878e-12 s^3 + 1.291e-05 s^2 + 0.0007648 s + 0.0274
Continuous-time transfer function.
The corresponding unit step response can be generated by adding the above and following command to your m-file. The
annotations for the peak response, settling time, and final value can be added to the plot from the right-click menu under
Characteristics.
step(sys_cl,t)

Examining the above closed-loop step response, the addition of feedback has stabilized the system. In fact, the steady-state error
appears to be driven to zero and the overshoot is less than 16%, though the settle time requirement is not met. The character of the
resulting step response is again indicated by the location of the poles of the system's transfer function just like the system's stability
properties were. The MATLAB command pzmap will plot the poles (and zeros) of a given transfer function as shown below.
pzmap(sys_cl)

The above plot shows that the closed-loop system has one real pole at -1.45e6 and a pair of complex poles at -29.6+35.3j and 29.6-35.3j as indicated by the locations of the blue x's. The damping and natural frequencies associated with these poles can be
determined by right-clicking on the associated poles in the resulting plot. This information can also be determined using the
MATLAB command damp as shown below.
damp(sys_cl)
Eigenvalue
-2.96e+01 + 3.53e+01i
-2.96e+01 - 3.53e+01i
-1.45e+06

Damping
6.43e-01
6.43e-01
1.00e+00

Frequency
4.61e+01
4.61e+01
1.45e+06

(Frequencies expressed in rad/seconds)


Since the one real pole is so much faster than the complex conjugate poles (its real part is much more negative) its effect on the
dynamic response of the system will be mimimal. Therefore, the damping (zeta = 0.643) and the natural frequency (Wn = 46.1) of
the complex conjugate poles will primarily indicate the response of the closed-loop system.
Adding the following commands to your m-file will calculate the overshoot and 2% settle time predicted by these poles assuming
that they dominate, in other words, that we have a canonical underdamped second-order system.
[Wn,zeta,poles] = damp(sys_cl);
OS = exp((-zeta(1)*pi)/sqrt(1-zeta(1)^2))
Ts = 4/(zeta(1)*Wn(1))
OS =
0.0716
Ts =
0.1351
The above results closely match the overshoot and settle time from the step response plot above which explicitly captured the effect
of the third, non-dominant pole.
Throughout the rest of the pages of this example, different controllers will be designed to reduce the settle time of the closed-loop
step response to meet the given 40 millisecond requirement while still meeting the other system requirements, including the zero
steady-state error in the presence of a step disturbance.

DC Motor Position: PID Controller Design


Key MATLAB commands used in this tutorial are: tf , step , feedback

Contents

Proportional control
PI control
PID control

From the main problem, the open-loop transfer function of the DC Motor is given as follows.

(1)
The structure of the control system has the form shown in the figure below.

For the original problem setup and the derivation of the above equations, please refer to the DC Motor Position: System Modeling
page.
For a 1-radian step reference, the design criteria are the following.
Settling time less than 0.040 seconds
Overshoot less than 16%
No steady-state error, even in the presence of a step disturbance input
Now let's design a PID controller and add it into the system. First create a new m-file and type in the following commands (refer to
main problem for the details of getting these commands).
J = 3.2284E-6;
b = 3.5077E-6;
K = 0.0274;
R = 4;
L = 2.75E-6;
s = tf('s');
P_motor = K/(s*((J*s+b)*(L*s+R)+K^2));
Recall that the transfer function for a PID controller has the following form.

(2)

Proportional control
Let's first try using a proportional controller with gain ranging from 1 to 21. An array of LTI models, each with a different
proportional gain, can be built using a for loop. The closed-loop transfer functions can be generated using the feedback
command. Add the following code to the end of your m-file and run it in the MATLAB command window:
Kp = 1;
for i = 1:3
C(:,:,i) = pid(Kp);
Kp = Kp + 10;
end
sys_cl = feedback(C*P_motor,1);
Now let's see what the step responses look like. Add the following code to the end of your m-file and again run it in the command
window. You should generate the plot shown in the figure below.
t = 0:0.001:0.2;
step(sys_cl(:,:,1), sys_cl(:,:,2), sys_cl(:,:,3), t)
ylabel('Position, \theta (radians)')
title('Response to a Step Reference with Different Values of K_p')
legend('K_p = 1', 'K_p = 11', 'K_p = 21')

Let's also consider the system's response to a step disturbance. In this case, we will assume a reference of zero and look at the
how the system responds to the disturbance by itself. The feedback command can still be employed for generating the closedloop transfer function where there is still negative feedback, however, now only the plant transfer function P(s) is in the forward path
and the controller C(s) is considered to be in the feedback path. Refer back to the block diagram at the top of this page to see the
structure of the system. Add the following to the end of your m-file and run it in the command window. You should generate the plot
shown in the figure below.
dist_cl = feedback(P_motor,C);
step(dist_cl(:,:,1), dist_cl(:,:,2), dist_cl(:,:,3), t)
ylabel('Position, \theta (radians)')
title('Response to a Step Disturbance with Different Values of K_p')
legend('K_p = 1', 'K_p = 11','K_p = 21')

The above plots show that the system has no steady-state error in response to the step reference by itself, no matter the choice of
proportional gain Kp. This is due to the fact that the plant has an integrator, that is, the system is type 1. However, the system has
significant steady-state error when the disturbance is added. Specifically, the response due to the reference and disturbance
applied simultaneously is equal to the sum of the two graphs shown above. This follows from the property of superposition that
holds for linear systems. Therefore, to have zero steady-state error in the presence of a disturbance, we need the disturbance
response to decay to zero. The larger the value of Kp the smaller the steady-state error is due to the disturbance, but it never
reaches zero. Furthermore, employing increasingly larger values of Kp has the adverse effect of increasing the overshoot and settle
time as can be seen from the step reference plot. Recall from the DC Motor Position: System Modeling page that adding an integral
term will eliminate the steady-state error and a derivative term can reduce the overshoot and settling time.

PI control

Let's first try a PI controller to get rid of the steady-state error due to the disturbance. We will set Kp = 21 and test integral gains Ki
ranging from 100 to 500. Change your m-file to the following and run in the command window. You should generate a figure like the
one shown below.
Kp = 21;
Ki = 100;
for i = 1:5
C(:,:,i) = pid(Kp,Ki);
Ki = Ki + 200;
end
sys_cl = feedback(C*P_motor,1);
t = 0:0.001:0.4;
step(sys_cl(:,:,1), sys_cl(:,:,2), sys_cl(:,:,3), t)
ylabel('Position, \theta (radians)')
title('Response to a Step Reference with K_p = 21 and Different Values of K_i')
legend('K_i = 100', 'K_i = 300', 'K_i = 500')

Now let's see what happened to the step disturbance response. Change the following commands in your m-file and re-run in the
command window. You should generate a plot like the one shown in the figure below.
dist_cl = feedback(P_motor,C);
step(dist_cl(:,:,1), dist_cl(:,:,2), dist_cl(:,:,3), t)
ylabel('Position, \theta (radians)')
title('Response to a Step Disturbance with K_p = 21 and Different Values of K_i')
legend('K_i = 100', 'K_i = 300', 'K_i = 500')

The integral control has reduced the steady-state error to zero, even when a step disturbance is present; that was the goal for
adding the integral term. For the response to the step reference, all of the reponses look similar with the amount of oscillation
increasing slightly as Ki is made larger. However, the response due to the disturbance changes significantly as the integral gain Ki
is changed. Specifically, the larger the value of Ki employed, the faster the error decays to zero. We will choose Ki = 500 because
the error due to the disturbance decays to zero quickly, even though the response to the reference has a longer settling time and
more overshoot. We will attempt to reduce the settling time and overshoot by adding a derivative term to the controller.

PID control

Adding a derivative term to the controller means that we now have all three terms of the PID controller. We will investigate
derivative gains Kd ranging from 0.05 to 0.25. Go back to the m-file and make the following changes. Running the altered m-file will
generate a graph like the one shown below.
Kp = 21;
Ki = 500;
Kd = 0.05;
for i = 1:3
C(:,:,i) = pid(Kp,Ki,Kd);
Kd = Kd + 0.1;
end
sys_cl = feedback(C*P_motor,1);
t = 0:0.001:0.1;
step(sys_cl(:,:,1), sys_cl(:,:,2), sys_cl(:,:,3), t)
ylabel('Position, \theta (radians)')
title('Response to a Step Reference with K_p = 21, K_i = 500 and Different Values of K_d')
legend('K_d = 0.05', 'K_d = 0.15', 'K_d = 0.25')

Let's see what happened to the step disturbance response, change the following commands in your m-file and re-run at the
command line.
dist_cl = feedback(P_motor,C);
t = 0:0.001:0.2;
step(dist_cl(:,:,1), dist_cl(:,:,2), dist_cl(:,:,3), t)
ylabel('Position, \theta (radians)')
title('Response to a Step Disturbance with K_p = 21, K_i = 500 and Different values of K_d')
legend('K_d = 0.05', 'K_d = 0.15', 'K_d = 0.25')

It looks like when Kd = 0.15, we can meet our design requirements. To determine the precise characteristics of the step response
you can use the right-click menu of the step response plot, or you can use the MATLAB command stepinfo as shown below.
stepinfo(sys_cl(:,:,2))
ans =
RiseTime: 0.0046
SettlingTime: 0.0338

SettlingMin: 0.9183
SettlingMax: 1.1211
Overshoot: 12.1139
Undershoot: 0
Peak: 1.1211
PeakTime: 0.0121
From the above, we see that the response to a step reference has a settling time of roughly 34ms (< 40 ms), overshoot of 12% (<
16%), and no steady-state error. Additionally, the step disturbance response also has no steady-state error. So now we know that if
we use a PID controller with
Kp = 21, Ki = 500, and Kd = 0.15,
all of our design requirements will be satisfied.

You might also like