0% found this document useful (0 votes)
73 views15 pages

Name: Zulfiqar Ali.: Department of Electronic Engineering University of Engineering and Technology Abbottabad Campus

The document describes modeling and controlling the position of a DC motor using MATLAB. It includes: 1) Representing the open-loop motor transfer function and modeling it using state-space equations in MATLAB. 2) Analyzing the open-loop response, which is unstable, and closed-loop response with a proportional controller. 3) Tuning the proportional and integral gains in the controller to improve the closed-loop response by reducing rise time, overshoot and eliminating steady-state error to a step input.

Uploaded by

Zulfiqar Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views15 pages

Name: Zulfiqar Ali.: Department of Electronic Engineering University of Engineering and Technology Abbottabad Campus

The document describes modeling and controlling the position of a DC motor using MATLAB. It includes: 1) Representing the open-loop motor transfer function and modeling it using state-space equations in MATLAB. 2) Analyzing the open-loop response, which is unstable, and closed-loop response with a proportional controller. 3) Tuning the proportional and integral gains in the controller to improve the closed-loop response by reducing rise time, overshoot and eliminating steady-state error to a step input.

Uploaded by

Zulfiqar Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Name: Zulfiqar Ali.

DEPARTMENT OF ELECTRONIC ENGINEERING


UNIVERSITY OF ENGINEERING AND TECHNOLOGY ABBOTTABAD
CAMPUS

Registration No: 17ABELT0736.

Subject: “Control System”


Date of Conduction:
Date of Submission:
Particulars Max. Marks Marks Obtained
Pre-Lab
Lab Performance
Post-Lab
Lab Report
Total

REPORT VERIFICATION

Date:

Instructor Name:

Signature:

LAB REPORT NO.4


DC Motor Position: System Modeling

1- Aim:

Upon completion of this lab, one will be able to understand


 DC motor modeling
 Position control of DC motor
 System analysis
 Open and closed loop control of DC motor

 IN LAB TASK:

 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))
RESULT:

P_motor =

0.0274

-------------------------------------------

8.878e-12 s^3 + 1.291e-05 s^2 + 0.0007648 s

Continuous-time transfer function.

2. State Space
We can also represent the system using the state-space equations. The following additional
MATLAB commands create a state-space model of the motor and produce the output shown
below when run in the MATLAB command window.
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];
motor_ss = ss(A,B,C,D)
RESULT:

motor_ss =

a=

x1 x2 x3

x1 0 1 0

x2 0 -1.087 8487

x3 0 -9964 -1.455e+06

b=

u1

x1 0

x2 0

x3 3.636e+05

c=

x1 x2 x3

y1 1 0 0

d=
u1

y1 0

Continuous-time state-space model.

System Analysis:

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

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;
P_motor = K/(s*((J*s+b)*(L*s+R)+K^2));
t = 0:0.001:0.2;
step(P_motor,t)
RESULT:
Step Response
7

5
Amplitude

0
0 0.05 0.1 0.15 0.2
Time (seconds)

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)
RESULT:

ans =

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)
RESULT:

ans =
1.0e+06 *

-1.4545

-0.0001

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)
RESULT:

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)

Step Response
1.4

1.2

1
Amplitude

0.8

0.6

0.4

0.2

0
0 0.05 0.1 0.15 0.2
Time (seconds)

pzmap(sys_cl)
RESULT:
Pole-Zero Map
40

30

20
)
-1

10
Imaginary Axis (seconds

-10

-20

-30

-40
-15 -10 -5 0
-1 5
Real Axis (seconds ) x 10

damp(sys_cl)
RESULT:

Pole Damping Frequency Time Constant

(rad/seconds) (seconds)

-2.96e+01 + 3.53e+01i 6.43e-01 4.61e+01 3.38e-02

-2.96e+01 - 3.53e+01i 6.43e-01 4.61e+01 3.38e-02

-1.45e+06 1.00e+00 1.45e+06 6.88e-07


[Wn,zeta,poles] = damp(sys_cl);
Mp = exp((-zeta(1)*pi)/sqrt(1-zeta(1)^2))
Ts = 4/(zeta(1)*Wn(1))

RESULT:

Mp =
0.0716

Ts =

0.1351

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
M(:,:,i) = pid(Kp);
Kp = Kp + 10;
end
sys_cl = feedback(M*P_motor,1);
t = 0:0.001:0.2;
step(sys_cl(:,:,1),'r', sys_cl(:,:,2),'b', sys_cl(:,:,3),'m', t)
ylabel('Position, \theta (radians)')
title('Response to a Step Reference with Different Values of K_p')
legend('Kp = 1', 'Kp = 11', 'Kp = 21')
RESULT:
Response to a Step Disturbance with Different Values of K p
1.4
Kp = 1
1.2 Kp = 11
Kp = 21
1
Position,  (radians)

0.8

0.6

0.4

0.2

0
0 0.05 0.1 0.15 0.2
Time (seconds)

%Let's also consider the system's response to a step disturbance


dist_cl = feedback(P_motor,M);
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('Kp = 1', 'Kp = 11','Kp = 21')

%adding an integral term will eliminate the steady-state error


%and a derivative term can reduce the overshoot and settling time.
%We will set $K_p$ = 21 and test integral gains $K_i$ ranging from 100 to 500
PI Control:

Kp = 21;
Ki = 100;
for i = 1:5
M(:,:,i) = pid(Kp,Ki);
Ki = Ki + 200;
end

sys_cl = feedback(M*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('Ki = 100', 'Ki = 300', 'Ki = 500')
RESULT:
Response to a Step Reference with K p = 21 and Different Values of Ki
1.8
Ki = 100
1.6 Ki = 300
Ki = 500
1.4
Position,  (radians)

1.2

0.8

0.6

0.4

0.2

0
0 0.1 0.2 0.3 0.4
Time (seconds)

%distrubances
dist_cl = feedback(P_motor,M);
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('Ki = 100', 'Ki = 300', 'Ki = 500')
RESULT:
Response to a Step Disturbance with K p = 21 and Different Values of K i
0.08
Ki = 100
0.07 Ki = 300
Ki = 500
0.06
Position,  (radians)

0.05

0.04

0.03

0.02

0.01

-0.01
0 0.1 0.2 0.3 0.4
Time (seconds)

PID control
%PID
Kp = 21;
Ki = 500;
Kd = 0.05;

for i = 1:3
M(:,:,i) = pid(Kp,Ki,Kd);
Kd = Kd + 0.1;
end

sys_cl = feedback(M*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('Step Response with K_p = 21, K_i = 500 and Different Values of K_d')
legend('Kd = 0.05', 'Kd = 0.15', 'Kd = 0.25')
RESULT:
Step Response with K p = 21, K i = 500 and Different Values of K d
1.4
Kd = 0.05
1.2 Kd = 0.15
Kd = 0.25
1
Position,  (radians)

0.8

0.6

0.4

0.2

0
0 0.02 0.04 0.06 0.08 0.1
Time (seconds)

%distrubcances
dist_cl = feedback(P_motor,M);
t = 0:0.001:0.2;
step(dist_cl(:,:,1), dist_cl(:,:,2), dist_cl(:,:,3), t)
ylabel('Position, \theta (radians)')
title('Step Response with K_p = 21, K_i = 500 and Different values of K_d')
legend('Kd = 0.05', 'Kd = 0.15', 'Kd = 0.25')
RESULT:
Step Response with K p = 21, Ki = 500 and Different values of K d
0.06
Kd = 0.05
0.05 Kd = 0.15
Kd = 0.25
0.04
Position,  (radians)

0.03

0.02

0.01

-0.01
0 0.05 0.1 0.15 0.2
Time (seconds)
%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 =

struct with fields:

RiseTime: 0.0046

SettlingTime: 0.0338

SettlingMin: 0.9103

SettlingMax: 1.1212

Overshoot: 12.1175

Undershoot: 0
Peak: 1.1212

PeakTime: 0.0122

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
 = 21,   = 500, and   = 0.15,
all of our design requirements will be satisfied.

You might also like