Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
344 views

Lab Manual - Control Systems

The document discusses modeling control systems and electrical systems mathematically. It provides guidelines for modeling, including focusing on important variables, using reasonable approximations, writing equations from physical laws, and eliminating intermediate variables. Common physical laws for electrical systems modeling are also presented, such as Kirchhoff's current and voltage laws and relationships for resistors, inductors, and capacitors. An example RLC circuit is modeled by applying Kirchhoff's voltage law and obtaining a second-order differential equation relating the circuit variables.

Uploaded by

Muhammad Hamza
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
344 views

Lab Manual - Control Systems

The document discusses modeling control systems and electrical systems mathematically. It provides guidelines for modeling, including focusing on important variables, using reasonable approximations, writing equations from physical laws, and eliminating intermediate variables. Common physical laws for electrical systems modeling are also presented, such as Kirchhoff's current and voltage laws and relationships for resistors, inductors, and capacitors. An example RLC circuit is modeled by applying Kirchhoff's voltage law and obtaining a second-order differential equation relating the circuit variables.

Uploaded by

Muhammad Hamza
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 106

LAB1 SYSTEM REPRESENTATION AND

CONTROL SYSTEMS TRANSOFRMATIONS


1.0 Obtaining Cascaded, Parallel, and Feedback (Closed-Loop) Transfer
Functions

In control-systems analysis, we frequently need to calculate the cascaded transfer


functions, parallel-connected transfer functions, and feedback-connected (closed-loop)
transfer functions. MATLAB has convenient commands to obtain the cascaded, parallel,
and feedback (closed-loop) transfer functions.

Suppose that there are two components G1(s) and G2(s) connected differently as
shown in Figure (a), (b), and (c), where

= , =

To obtain the transfer functions of the cascaded system, parallel system, or feedback
(closed-loop) system, the following commands may be used:
[num, den] = series(num1,den1,num2,den2)
[num, den] = parallel(num1,den1,num2,den2)
[num, den] = feedback(num1,den1,num2,den2)

As an example, consider the case where


10 1 5 2
= = , = =
+ 2 + 10 1 +5 2

1
LAB1 SYSTEM REPRESENTATION AND
CONTROL SYSTEMS TRANSOFRMATIONS

Following MATLAB program gives C(s)/R(s)=num/den for each arrangement of G1(s)


and G2(s).

num1 = [10];
den1 = [1 2 10];
num2 = [5];
den2 = [1 5];
[num, den] = series(num1,den1,num2,den2);
printsys(num,den)
num/den =
50
s^3 + 7s^2 + 20s + 50

[num, den] = parallel(num1,den1,num2,den2);


printsys(num,den)
num/den =

5 ^2 + 20 + 100
s^3 + 7s^2 + 20s + 50

[num, den] = feedback(num1,den1,num2,den2);


printsys(num,den)
num/den =

10 + 50
s^3 + 7s^2 + 20s + 50

Note that the command


printsys(num,den)

displays the num/den [that is, the transfer function C(s)/R(s)] of the system considered.

2.0 Transformation of Mathematical Models

MATLAB is quite useful to transform the system model from transfer function to state
space, and vice versa. We shall begin our discussion with transformation from transfer
function to state space.

2
LAB1 SYSTEM REPRESENTATION AND
CONTROL SYSTEMS TRANSOFRMATIONS

Let us write the closed-loop transfer function as

! numerator polynomial in s num


= =
" denominator polynomial in s den

Once we have this transfer-function expression, the MATLAB command

[A,B,C,D] = tf2ss(num,den)

will give a state-space representation. It is important to note that the state-space


representation for any system is not unique. There are many (infinitely many) state-
space representations for the same system. The MATLAB command gives one possible
such state-space representation.

2.1 Transformation from Transfer Function to State Space Representation

Consider the transfer-function system

0 1
=
2 1 + 3 +4 + 5

= 6 + 14 + 56 + 160

There are many (infinitely many) possible state-space representations for this system.
One possible state-space representation is

:; 0 1 0 : 0
: ;
9 <=9 0 0 :
1 <9 <+ 9 1 <
:6; −160 −56 −14 :6 −14
:
> = ?1 0 0@ 9: < + ?0@
:6
Another possible state-space representation (among infinitely many alternatives) is

:; −14 −56 −160 : 1


9: ; < = 9 1 0 0 < 9: < + 90<
:6; 0 1 0 :6 0

3
LAB1 SYSTEM REPRESENTATION AND
CONTROL SYSTEMS TRANSOFRMATIONS
:
> = ?0 1 0@ 9: < + ?0@
:6

MATLAB transforms the transfer function into the state-space representation. For the
example system considered here, following MATLAB program will produce matrices A, B,
C, and D.

num = [1 0];
den = [1 14 56 160];
[A,B,C,D] = tf2ss(num,den)

A=
-14 -56 -160
1 0 0
0 1 0

B=
1
0
0

C=
0 1 0

D=
0

2.2 Transformation from State Space Representation to Transfer Function

To obtain the transfer function from state-space equations, use the following command:

[num,den] = ss2tf(A,B,C,D,iu)

iu must be specified for systems with more than one input. For example, if the system
has three inputs (u1, u2, u3), then iu must be either 1, 2, or 3, where 1 implies u1, 2
implies u2, and 3 implies u3. If the system has only one input, then either

[num,den] = ss2tf(A,B,C,D)
or
[num,den] = ss2tf(A,B,C,D,1)

4
LAB1 SYSTEM REPRESENTATION AND
CONTROL SYSTEMS TRANSOFRMATIONS
may be used. For the case where the system has multiple inputs and multiple outputs.
Obtain the transfer function of the system defined by the following state-space
equations:

:; 0 1 0 : 0
9: ; < = 9 0 0 1 < 9: < + 9 25 <
:6; −5 −25 −5 :6 −120
:
> = ?1 0 :
0@ 9 < + ?0@
:6

The transfer function obtained is given by

! 25 + 5
=
" 6 + 5 + 25 + 5

Following MATLAB program will produce the transfer function for the given system.

A = [0 1 0; 0 0 1; -5 -25 -5];
B = [0; 25; -120];
C = [1 0 0];
D = [0];
[num,den] = ss2tf(A,B,C,D)
num =
0 0.0000 25.0000 5.0000
den
1.0000 5.0000 25.0000 5.0000
% ***** The same result can be obtained by entering the following command: *****
[num,den] = ss2tf(A,B,C,D,1)
num =
0 0.0000 25.0000 5.0000
den =
1.0000 5.0000 25.0000 5.0000

5
LAB1 SYSTEM REPRESENTATION AND
CONTROL SYSTEMS TRANSOFRMATIONS
3.0 Lab Report
Prepare a lab report based on literature review from this document, Chapter 1 and 2 of
the textbook, exercise problems of this lab and also include the solutions to the following
problems using MATLAB. Attach MATLAB codes with your lab report.

1. Evaluate the transfer function of following block diagram. First, convert the
system to pure series/parallel/feedback combination, then write the MATLAB
code:

2. Convert the following transfer function to state space:

0 1 1 + +
=
2 1 + A + B1 + + 5

3. Evaluate the transfer function of the following state space model:

:; −1 1 0 : 0
: ; :
9 < = 9 0 −1 1 < 9 < + 90<
:6; 0 0 −2 :6 1
:
> = ?1 0 0@ 9: < + ?0@
:6

6
LAB2 MATHEMATICAL MODELING OF
CONTROL SYSTEMS ELECTRICAL SYSTEMS
1.0 Modeling

We make use of mathematics to describe the operation of the plant, including sensors
and actuators. An engineer must capture how variables relate to each other and must pay
close attention to how input affects output. An appropriate level of abstraction vs detail
must be used. Many types of physical systems share the same mathematical model
therefore it is important to focus on models.

2.0 Modeling Guidelines

Firstly, one must focus on important variables and use reasonable approximations.
Write mathematical equations from physical laws, don’t invent your own. Eliminate
intermediate variables, and then obtain ordinary differential equation involving
input/output variables. Afterwards, you may obtain and input/output model (transfer
function) or a state space model.

Common physical laws that make up the ordinary differential equations of electrical
systems are provided as follows:

KCL:
into node = 0
KVL:
along loop = 0
RLC:
=
=

Additional relationships are given as follows:

1
LAB2 MATHEMATICAL MODELING OF
CONTROL SYSTEMS ELECTRICAL SYSTEMS
2.1 RLC Circuits

An example is given below:

First of all, we shall apply KVL on the given system:

di (t ) 1
L + Ri (t ) + ∫ i (t )dt = v(t )
dt C
as q(t) = ∫ i(t)dt
d 2 q (t ) dq (t ) 1
L + R + q (t ) = v(t )
dt 2 dt C
output vC , q(t) = Cv C (t )
d 2 v C (t ) dv C (t )
LC + RC + v C (t ) = v(t )
dt 2 dt
LCs 2 VC ( s ) + RCsVC ( s ) + VC ( s ) = V ( s )
1
V (s) 1 LC
G( s) = C = 2
=
V ( s ) LCs + RCs + 1 s 2 + R s + 1
L LC
2
LAB2 MATHEMATICAL MODELING OF
CONTROL SYSTEMS ELECTRICAL SYSTEMS

To construct symbolic numbers, variables and objects; use following command:


var1=sym(‘var1’)

Following MATLAB program gives G(s) in generalized form

R = sym('R');
L = sym('L');
C = sym('C');
s = sym('s');
G = (1/(L*C))/(s^2 + s*R/L + 1/(L*C))

Suppose, R = 1 kΩ, L = 25 mH, and C = 1µF. The following MATLAB program produces G(s)
in numeric form for further analysis:

R = 1000;
L = 25e-3;
C = 1e-6;
num = [0 0 1/(L*C)];
den = [1 R/L 1/(L*C)];
G = tf(num,den)
G=

4e07
--------------------
s^2 + 40000 s + 4e07

2.2 Circuits with Operational Amplifiers

Operational amplifiers are widely used to design controllers, that would be discussed in
later part of the course. Operational amplifiers are optimized for use with negative
feedback.

3
LAB2 MATHEMATICAL MODELING OF
CONTROL SYSTEMS ELECTRICAL SYSTEMS
An inverting amplifier is a special case of the differential amplifier in which that circuit's
non-inverting input V2 is grounded, and inverting input V1 is identified with Vin above.
The closed-loop gain is Rf / Rin, hence

= !"

The simplified circuit above is like the differential amplifier in the limit of R2 and Rg very
small. In this case, though, the circuit will be susceptible to input bias current drift
because of the mismatch between Rf and Rin.
To intuitively see the gain equation above, calculate the current in Rin:

#
!" =

then recall that this same current must be passing through Rf, therefore
(because V− = V+ = 0):

A non-inverting amplifier is a special case of the differential amplifier in which that


circuit's inverting input V1 is grounded, and non-inverting input V2 is identified
with Vin above, with R1 ≫ R2. Referring to the circuit immediately above,

= %1 ' (
* !"
)

To intuitively see this gain equation, use the virtual ground technique to calculate the
current in resistor R1:

!"
+ =
+

4
LAB2 MATHEMATICAL MODELING OF
CONTROL SYSTEMS ELECTRICAL SYSTEMS
then recall that this same current must be passing through R2, therefore:

,
= !" ' + , = !" -1 + .
+
Unlike the inverting amplifier, a non-inverting amplifier cannot have a gain of less than
1.

3.0 Lab Report


Prepare a lab report based on literature review from this document, Chapter 3 of the
textbook, exercise problems of this lab and also include the solutions to the following
problems using MATLAB. Attach MATLAB codes with your lab report.

/0 !) !(
1. Obtain the transfer functions , , and of the following system:
/ / /

2. Obtain the transfer function of (1) if R1 = 5kΩ, R2 = 10 kΩ, L = 50mH, C = 1nF


[CLO 2]

/1
3. Obtain the transfer function of the following system:
/

4. Obtain the transfer function of (2) if R1 = 10kΩ, R2 = 20 kΩ, C1 = 1µF, C2 = 10nF

5
TRANSIENT RESPONSE
LAB3 ANALYSIS &PROTOTYOPE
CONTROL SYSTEMS
FIRST ORDER SYSTEMS
1.0 Introduction

The practical procedure for plotting time response curves of systems higher than second
order is through computer simulation. In this section we present the computational
approach to the transient-response analysis with MATLAB. In particular, we discuss step
response, impulse response, ramp response, and responses to other simple inputs.

2.0 MATLAB Representation of Linear Systems

The transfer function of a system is represented by two arrays of numbers. Consider the

( ) 2 + 25
system
=
( ) + 4 + 25

This system can be represented as two arrays, each containing the coefficients of the
polynomials in decreasing powers of s as follows:

num = [2 25]

den = [1 4 25]
An alternative representation is

num = [0 2 25]

den = [1 4 25]

In this expression a zero is padded. Note that if zeros are padded, the dimensions of
“num” vector and “den” vector become the same.An advantage of padding zeros is that
the “num” vector and “den” vector can be directly added. For example,

num + den = [0 2 25] + [1 4 25]


= [1 6 50]
If num and den (the numerator and denominator of the closed-loop transfer function)
are known, commands such as

step(num,den), step(num,den,t)

will generate plots of unit-step responses (t in the step command is the user-specified
time.)

1
TRANSIENT RESPONSE
LAB3 ANALYSIS &PROTOTYOPE
CONTROL SYSTEMS
FIRST ORDER SYSTEMS
For a control system defined in a state-space form, where state matrix A, control matrix
B, output matrix C, and direct transmission matrix D of state-space equations are
known, the command

step(A,B,C,D), step(A,B,C,D,t)

will generate plots of unit-step responses.When t is not explicitly included in the step
commands, the time vector is automatically determined.
Note that the command step(sys) may be used to obtain the unit-step response of a
system. First, define the system by
sys = tf(num,den)
or
sys = ss(A,B,C,D)

Then, to obtain, for example, the unit-step response, enter

step(sys)

into the computer.

When step commands have left-hand arguments such as


[y,x,t] = step(num,den,t)

[y,x,t] = step(A,B,C,D,iu)

[y,x,t] = step(A,B,C,D,iu,t)

no plot is shown on the screen. Hence it is necessary to use a plot command to see the
response curves. The matrices y and x contain the output and state response of the
system, respectively, evaluated at the computation time points t. (y has as many
columns as outputs and one row for each element in t. x has as many columns as states
and one row for each element in t.)

Note in above equation that the scalar iu is an index into the inputs of the system and
specifies which input is to be used for the response, and t is the user-specified time. If
the system involves multiple inputs and multiple outputs, the step command, such as
given by above equation, produces a series of step-response plots, one for each input
and output combination of

= +

2
TRANSIENT RESPONSE
LAB3 ANALYSIS &PROTOTYOPE
CONTROL SYSTEMS
FIRST ORDER SYSTEMS
= +

3.0 Example

Consider the following system:

−1 −1 1 1
= +
6.5 0 1 0

1 0 0 0
= +
0 1 0 0

Obtain the unit-step response curves.

Although it is not necessary to obtain the transfer-matrix expression for the system to
obtain the unit-step response curves with MATLAB, we shall evaluate it for reference.

The transfer function of the system is given by:

( )= ( − ) +
Which gives us:

1 0 +1 1 1 1
0 1 −6.5 1 0

1 −1 1 1
=
+ + 6.5 −6.5 1 0

1 −1
=
+ + 6.5 + 7.5 6.5
Hence

−1
"( ) + + 6.5 + + 6.5$ % ( )
=#
"( ) + 7.5 6.5 %( )
+ + 6.5 + + 6.5

Since this system involves two inputs and two outputs, four transfer functions may be
defined, depending on which signals are considered as input and output. Note that,
when considering the signal u1 as the input, we assume that signal u2 is zero, and vice
versa. The four transfer functions are
3
TRANSIENT RESPONSE
LAB3 ANALYSIS &PROTOTYOPE
CONTROL SYSTEMS
FIRST ORDER SYSTEMS

"( ) −1 "( )
= , =
%( ) + + 6.5 % ( ) + + 6.5

"( ) + 7.5 "( ) 6.5


= , =
%( ) + + 6.5 % ( ) + + 6.5

Assume that u1 and u2 are unit-step functions. The four individual step-response curves
can then be plotted by use of the command

step(A,B,C,D)

Following MATLAB program produces four such step-response curves. The curves are
shown in the figure followed by the program. (Note that the time vector t is
automatically determined, since the command does not include t.)

A = [–1 –1;6.5 0];


B = [1 1;1 0];
C = [1 0;0 1];
D = [0 0;0 0];
step(A,B,C,D)

4
TRANSIENT RESPONSE
LAB3 ANALYSIS &PROTOTYOPE
CONTROL SYSTEMS
FIRST ORDER SYSTEMS
To plot two step-response curves for the input u1 in one diagram and two step-response
curves for the input u2 in another diagram, we may use the commands

step(A,B,C,D,1)
and
step(A,B,C,D,2)

respectively.

To write text on the graphics screen, enter, for example, the following statements:
text(3.4, -0.06,'Y1')
and
text(3.4,1.4,'Y2')

The first statement tells the computer to write ‘Y1’ beginning at the coordinates x=3.4,
y=–0.06. Similarly, the second statement tells the computer to write ‘Y2’ beginning at
the coordinates x=3.4, y=1.4.

Another way to write a text or texts in the plot is to use the gtext command. The syntax
is
gtext('text')

When gtext is executed, the computer waits until the cursor is positioned (using a
mouse) at the desired position in the screen. When the left mouse button is pressed,
the text enclosed in simple quotes is written on the plot at the cursor’s position. Any
number of gtext commands can be used in a plot.

Following MATLAB program plots two step-response curves for the input u1 in one
diagram and two step-response curves for the input u2 in another diagram.

Following figure shows the two diagrams, each consisting of two step-response curves.

% ***** In this program we plot step-response curves of a system


% having two inputs (u1 and u2) and two outputs (y1 and y2) *****
% ***** We shall first plot step-response curves when the input is
% u1. Then we shall plot step-response curves when the input is
% u2 *****
% ***** Enter matrices A, B, C, and D *****
A = [-1 -1;6.5 0];

5
TRANSIENT RESPONSE
LAB3 ANALYSIS &PROTOTYOPE
CONTROL SYSTEMS
FIRST ORDER SYSTEMS
B = [1 1;1 0];
C = [1 0;0 1];
D = [0 0;0 0];
% ***** To plot step-response curves when the input is u1, enter
% the command 'step(A,B,C,D,1)' *****
step(A,B,C,D,1)
grid
title ('Step-Response Plots: Input = u1 (u2 = 0)')
text(3.4, -0.06,'Y1')
text(3.4, 1.4,'Y2')
% ***** Next, we shall plot step-response curves when the input
% is u2. Enter the command 'step(A,B,C,D,2)' *****
step(A,B,C,D,2)
grid
title ('Step-Response Plots: Input = u2 (u1 = 0)')
text(3,0.14,'Y1')
text(2.8,1.1,'Y2')

6
TRANSIENT RESPONSE
LAB3 ANALYSIS &PROTOTYOPE
CONTROL SYSTEMS
FIRST ORDER SYSTEMS

4.0 Lab Report

Prepare a lab report based on literature review from this document, Chapter 5 of the
textbook, exercise problems of this lab and also include the solutions to the following
problems using MATLAB. Attach MATLAB codes with your lab report.

1. Evaluate the step response of the following first order system using MATLAB:

'
( )=
+'
Where, p=2, 50, and 100

2. List the following from the results of 1 for all given values of p
a. Overshoot?
b. Steady state error and output value
c. Settling time
d. Delay time
e. Rise Time

3. Discuss the results obtained from 2 with reference to the different values of p
provided in 1.

4. Derive the state space model of the system given in 1 and evaluate its impulse
response through MATLAB for given values of p.

7
LAB4 PROTOTYOPE SECOND ORDER
CONTROL SYSTEMS SYSTEMS
1.0 MATLAB Description of Standard Second-Order System

The second-order system is given by:

=
+2 +

is called the standard second-order system. Given vn and z, the command

printsys(num,den) or printsys(num,den,s)

prints num/den as a ratio of polynomials in s.

Consider, for example, the case where = 5rad/sec and = 0.4 following MATLAB
program generates the standard second-order system, where = 5rad/sec and =
0.4. Note that in this MATLAB Program 5–3,“num0” is 1.

wn = 5;
damping_ratio = 0.4;
[num0,den] = ord2(wn,damping_ratio);
num = 5^2*num0;
printsys(num,den,'s')
num/den =
25
^2 + 4 + 25

2.0 Obtaining the Unit-Step Response of the Transfer-Function System

Let us consider the unit-step response of the system given by

25
=
+ 4 + 25
Following MATLAB program will yield a plot of the unit-step response of this system.

% ------------- Unit-step response -------------


% ***** Enter the numerator and denominator of the transfer
% function *****
num = [25];
den = [1 4 25];
% ***** Enter the following step-response command *****

1
LAB4 PROTOTYOPE SECOND ORDER
CONTROL SYSTEMS SYSTEMS
step(num,den)
% ***** Enter grid and title of the plot *****
grid
title (' Unit-Step Response of G(s) = 25/(s^2+4s+25)')

A plot of the unit-step response curve is shown in the following figure.

Notice in the figure above, that the x-axis and y-axis labels are automatically determined.
If it is desired to label the x axis and y axis differently, we need to modify the step
command. For example, if it is desired to label the x axis as 't Sec' and the y axis as
‘Output,’ then use step-response commands with left-hand arguments, such as

c = step(num,den,t)
or, more generally,

[y,x,t] = step(num,den,t)

and use plot(t,y) command. See, for example, the following MATLAB program and its
figure:

% ------------- Unit-step response -------------


num = [25];
den = [1 4 25];

2
LAB4 PROTOTYOPE SECOND ORDER
CONTROL SYSTEMS SYSTEMS
t = 0:0.01:3;
[y,x,t] = step(num,den,t);
plot(t,y)
grid
title('Unit-Step Response of G(s)=25/(sˆ2+4s+25)')
xlabel('t Sec')
ylabel('Output')

3.0 Obtaining Three-Dimensional Plot of Unit-Step Response Curves with


MATLAB

MATLAB enables us to plot three-dimensional plots easily. The commands to obtain


three-dimensional plots are “mesh” and “surf.” The difference between the “mesh” plot
and “surf” plot is that in the former only the lines are drawn and in the latter the spaces
between the lines are filled in by colors. In this book we use only the “mesh” command.

Consider the closed-loop system defined by

1
=
+2 1
(The undamped natural frequency is normalized to 1.) Plot unit-step response curves
c(t) when assumes the following values:

= 0, 0.2, 0.4, 0.6. 0.8, 1.0

3
LAB4 PROTOTYOPE SECOND ORDER
CONTROL SYSTEMS SYSTEMS

Also plot a three-dimensional plot.

An illustrative MATLAB program for plotting a two-dimensional diagram and a three


dimensional diagram of unit-step response curves of this second-order system is given in
the following MATLAB program. The resulting plots are shown in following figures. Notice
that we used the command mesh(t,zeta,y') to plot the three-dimensional plot. We may
use a command mesh(y') to get the same result. [Note that command mesh(t,zeta,y) or
mesh(y) will produce a three-dimensional plot the same as following figures, except that
x axis and y axis are interchanged.]

When we want to solve a problem using MATLAB and if the solution process involves
many repetitive computations, various approaches may be conceived to simplify the
MATLAB program. A frequently used approach to simplify the computation is to use “for
loops.” Following MATLAB program uses such a “for loop.” In this book many MATLAB
programs using “for loops” are presented for solving a variety of problems. You are
advised to study all those problems carefully to familiarize themselves with the approach.

% ------- Two-dimensional plot and three-dimensional plot of unit-step


% response curves for the standard second-order system with wn = 1
% and zeta = 0, 0.2, 0.4, 0.6, 0.8, and 1. -------
t = 0:0.2:10;
zeta = [0 0.2 0.4 0.6 0.8 1];
for n = 1:6;
num = [1];
den = [1 2*zeta(n) 1];
[y(1:51,n),x,t] = step(num,den,t);
end
% To plot a two-dimensional diagram, enter the command plot(t,y).
plot(t,y)
grid
title('Plot of Unit-Step Response Curves with \omega_n = 1 and \zeta = 0, 0.2, 0.4, 0.6,
0.8, 1')
xlabel('t (sec)')
ylabel('Response')
text(4.1,1.86,'\zeta = 0')
text(3.5,1.5,'0.2')
text(3 .5,1.24,'0.4')
text(3.5,1.08,'0.6')
text(3.5,0.95,'0.8')
text(3.5,0.86,'1.0')
% To plot a three-dimensional diagram, enter the command mesh(t,zeta,y').

4
LAB4 PROTOTYOPE SECOND ORDER
CONTROL SYSTEMS SYSTEMS
mesh(t,zeta,y')
title('Three-Dimensional Plot of Unit-Step Response Curves')
xlabel('t Sec')
ylabel('\zeta')
zlabel('Response')

5
LAB4 PROTOTYOPE SECOND ORDER
CONTROL SYSTEMS SYSTEMS
4.0 Lab Report

Prepare a lab report based on literature review from this document, Chapter 5 of the
textbook, exercise problems of this lab and also include the solutions to the following
problems using MATLAB. Attach MATLAB codes with your lab report.

1. Evaluate the two-dimensional step response of the following second order


system using MATLAB:
=
+ 1.4 +
Where, =2, 50, and 100

2. Evaluate the three-dimensional step response of the second order system given
in 1 using MATLAB:

3. Discuss the results obtained in 1 and 2.

6
LAB5 DYNAMIC RESPONSE
CONTROL SYSTEMS SPECIFICATIONS
1.0 Obtaining Rise Time, Peak Time, Maximum Overshoot, and Settling
Time with MATLAB.

MATLAB can conveniently be used to obtain the rise time, peak time, maximum
overshoot, and settling time. Consider the system defined by

( ) 25
=
( ) + 6 + 25

Following MATLAB program yields the rise time, peak time, maximum overshoot, and
settling time. A unit-step response curve for this system is given in following figure to
verify the results obtained with given MATLAB program. (Note that this program can also
be applied to higher-order systems.)

% ------- This is a MATLAB program to find the rise time, peak time,
% maximum overshoot, and settling time of the second-order system
% and higher-order system -------
% ------- In this example, we assume zeta = 0.6 and wn = 5 -------
num = [25];
den = [1 6 25];
t = 0:0.005:5;
[y,x,t] = step(num,den,t);
r = 1; while y(r) < 1.0001; r = r + 1; end;
rise_time = (r - 1)*0.005
rise_time =
0.5550
[ymax,tp] = max(y);
peak_time = (tp - 1)*0.005
peak_time =
0.7850
max_overshoot = ymax-1
max_overshoot =
0.0948
s = 1001; while y(s) > 0.98 & y(s) < 1.02; s = s - 1; end;
settling_time = (s - 1)*0.005
settling_time =
1.1850

1
LAB5 DYNAMIC RESPONSE
CONTROL SYSTEMS SPECIFICATIONS

2.0 Impulse Response

The unit-impulse response of a control system may be obtained by using any of the
impulse commands such as

impulse(num,den)
impulse(A,B,C,D)
[y,x,t] = impulse(num,den)
[y,x,t] = impulse(num,den,t)
[y,x,t] = impulse(A,B,C,D)
[y,x,t] = impulse(A,B,C,D,iu)
[y,x,t] = impulse(A,B,C,D,iu,t)

The command impulse(num,den) plots the unit-impulse response on the screen. The
command impulse(A,B,C,D) produces a series of unit-impulse-response plots, one for
each input and output combination of the state space system.

Note that in above equations the scalar iu is an index into the inputs of the system and
specifies which input to be used for the impulse response.

Note also that if the command used does not include “t” explicitly, the time vector is
automatically determined. If the command includes the user-supplied time vector “t”,
this vector specifies the times at which the impulse response is to be computed.

2
LAB5 DYNAMIC RESPONSE
CONTROL SYSTEMS SPECIFICATIONS
If MATLAB is invoked with the left-hand argument [y,x,t], such as in the case of [y,x,t] =
impulse(A,B,C,D), the command returns the output and state responses of the system and
the time vector t. No plot is drawn on the screen. The matrices y and x contain the output
and state responses of the system evaluated at the time points t. (y has as many columns
as outputs and one row for each element in t. x has as many columns as state variables
and one row for each element in t.) To plot the response curve, we must include a plot
command, such as plot(t,y).

2.1 EXAMPLE

Obtain the unit-impulse response of the following system:

( ) 1
= ( )=
( ) + 0.2 1

Following MATLAB will produce the unit-impulse response. The resulting plot is shown
in the following figure

num = [1];
den = [1 0.2 1];
impulse(num,den);
grid
title(‘Unit-Impulse Response of G(s) = 1/(s^2 + 0.2s + 1)‘)

3
LAB5 DYNAMIC RESPONSE
CONTROL SYSTEMS SPECIFICATIONS
Alternative Approach:

Note that when the initial conditions are zero, the unit-impulse response of G(s) is the
same as the unit-step response of sG(s). Consider the unit-impulse response of the system
considered in previous example. Since R(s)=1 for the unit-impulse input, we have

1 1
0.2 1 0.2 1

We can thus convert the unit-impulse response of G(s) to the unit-step response of
sG(s). If we enter the following num and den into MATLAB,

num = [0 1 0]
den = [1 0.2 1]

and use the step-response command; as given in following MATLAB program, we obtain
a plot of the unit-impulse response of the system as shown in the following figure.

num = [1 0];
den = [1 0.2 1];
step(num,den);
grid
title(‘Unit-Step Response of sG(s) = s/(s^2 + 0.2s + 1)‘)

4
LAB5 DYNAMIC RESPONSE
CONTROL SYSTEMS SPECIFICATIONS
3.0 Ramp Response

There is no ramp command in MATLAB. Therefore, we need to use the step command to
obtain the ramp response. Specifically, to obtain the ramp response of the transfer-
function system G(s), divide G(s) by s and use the step-response command. For example,
consider the closed loop system

2 +1
+ +1

For a unit ramp input, 1⁄ . Hence

2 +1 1 2 +1 1
=
+ +1 + +1

To obtain the unit-ramp response of this system, enter the following numerator and
denominator into the MATLAB program:

num = [2 1];
den = [1 1 1 0];

and use the step-response command. See following MATLAB program. The plot
obtained by using this program is shown in the following figure.

% --------------- Unit-ramp response ---------------


% ***** The unit-ramp response is obtained as the unit-step
% response of G(s)/s *****
% ***** Enter the numerator and denominator of G(s)/s *****
num = [2 1];
den = [1 1 1 0];
% ***** Specify the computing time points (such as t = 0:0.1:10)
% and then enter step-response command: c = step(num,den,t) *****
t = 0:0.1:10;
c = step(num,den,t);
% ***** In plotting the ramp-response curve, add the reference
% input to the plot. The reference input is t. Add to the
% argument of the plot command with the following: t,t,'-'. Thus
% the plot command becomes as follows: plot(t,c,'o',t,t,'-') *****
plot(t,c,'o',t,t,'-')
% ***** Add grid, title, xlabel, and ylabel *****
grid

5
LAB5 DYNAMIC RESPONSE
CONTROL SYSTEMS SPECIFICATIONS
title('Unit-Ramp Response Curve for System G(s) = (2s + 1)/(s^2 + s + 1)')
xlabel('t Sec')
ylabel('Input and Output')

6
LAB5 DYNAMIC RESPONSE
CONTROL SYSTEMS SPECIFICATIONS
4.0 Lab Report

Prepare a lab report based on literature review from this document, Chapter 5 of the
textbook, exercise problems of this lab and also include the solutions to the following
problems using MATLAB. Attach MATLAB codes with your lab report.

1. Evaluate the unit impulse response for the given samples of the system
parameters and plot results in two plots(one for , another for :

2 +

0, 0.35, 0.707, 0.9, 1, 1.5


0, 1, 50, 500, 5000 /

2. Evaluate the unit step response for the given samples of the system parameters
given in (1) and plot results in two plots(one for , another for .

3. Evaluate the Rise Time, Peak Time, Maximum Overshoot, and Settling Time for
the unit step response for the given samples of the system given in (1) and plot
results in two plots(one for , another for Discuss the results obtained in 1, 2
and 3.

4. Based on the results you have obtained, discuss in detail the effects of the
damping ratio and undamped natural frequency on the overall unit step
response of the system.

7
LAB6 CONTROL SYSTEM ANALYSIS BY
CONTROL SYSTEMS ROOT LOCUS METHOD

1.0 Introduction

The basic characteristic of the transient response of a closed-loop system is closely related
to the location of the closed-loop poles. If the system has a variable loop gain, then the
location of the closed-loop poles depends on the value of the loop gain chosen. It is
important, therefore, that the designer know how the closed-loop poles move in
the s plane as the loop gain is varied.

From the design viewpoint, in some systems simple gain adjustment may move the
closed-loop poles to desired locations. Then the design problem may become the
selection of an appropriate gain value. If the gain adjustment alone does not yield a
desired result, addition of a compensator to the system will become necessary.

The closed-loop poles are the roots of the characteristic equation. Finding the roots of
the characteristic equation of degree higher than 3 is laborious and will need computer
solution. (MATLAB provides a simple solution to this problem.) However, just finding the
roots of the characteristic equation may be of limited value, because as the gain of the
open-loop transfer function varies, the characteristic equation changes and the
computations must be repeated.

A simple method for finding the roots of the characteristic equation has been
developed by W. R. Evans and used extensively in control engineering. This method,
called the root-locus method, is one in which the roots of the characteristic equation are
plotted for all values of a system parameter. The roots corresponding to a particular value
of this parameter can then be located on the resulting graph. Note that the parameter is
usually the gain, but any other variable of the open-loop transfer function may be used.
Unless otherwise stated, we shall assume that the gain of the open-loop transfer function
is the parameter to be varied through all values, from zero to infinity.

By using the root-locus method the designer can predict the effects on the location
of the closed-loop poles of varying the gain value or adding open-loop poles and/or
open-loop zeros. Therefore, it is desired that the designer have a good understanding of
the method for generating the root loci of the closed-loop system, both by hand and by
use of a computer software program like MATLAB.

1
LAB6 CONTROL SYSTEM ANALYSIS BY
CONTROL SYSTEMS ROOT LOCUS METHOD
2.0 Typical Pole–Zero Configurations and Corresponding Root Loci

In summarizing, we show several open-loop pole–zero configurations and their


corresponding root loci in the following table. The pattern of the root loci depends only
on the relative separation of the open-loop poles and zeros. If the number of open-loop
poles exceeds the number of finite zeros by three or more, there is a value of the gain K
beyond which root loci enter the right-half s plane, and thus the system can become
unstable. A stable system must have all its closed-loop poles in the left-half s plane.

2
LAB6 CONTROL SYSTEM ANALYSIS BY
CONTROL SYSTEMS ROOT LOCUS METHOD
2.0 Root locus of systems represented as transfer functions

Consider the system shown in the following figure. Plot root loci with a square aspect
ratio so that a line with slope 1 is a true 45° line. Choose the region of root-locus plot to
be

−6 ≤ ≤ 6, −6≤ ≤6
where x and y are the real-axis coordinate and imaginary-axis coordinate, respectively.

To set the given plot region on the screen to be square, enter the command
v = [-6 6 -6 6]; axis (v); axis('square')

With this command, the region of the plot is as specified and a line with slope 1 is at a
true 45°, not skewed by the irregular shape of the screen. For this problem, the
denominator is given as a product of first- and second-order terms. So we must multiply
these terms to get a polynomial in s. The multiplication of these terms can be done easily
by use of the convolution command, as shown next.

Define
= +1 = [1 1 0]
= + 4 + 16 = [1 4 16]

Then we use the following command:

c = conv(a, b)

Note that conv(a, b) gives the product of two polynomials a and b. See the following
computer output:

a = [1 1 0];
b = [1 4 16];
c = conv (a,b)
c=
1 5 20 16 0

3
LAB6 CONTROL SYSTEM ANALYSIS BY
CONTROL SYSTEMS ROOT LOCUS METHOD
The denominator polynomial is thus found to be
den = [1 5 20 16 0]

To find the complex-conjugate open-loop poles (the roots of + 4 + 16 = 0), we


may enter the roots command as follows:

r = roots(b)
r=
–2.0000 + 3.464li
–2.0000 - 3.464li

Thus, the system has the following open-loop zero and open-loop poles:
Open-loop zero: s=–3
Open-loop poles: s=0, s=–1, s=–2±j3.4641

Following MATLAB Program will plot the root-locus diagram for this system. The plot is
shown in following figure.

% --------- Root-locus plot ---------


num = [1 3];
den = [1 5 20 16 0];
rlocus(num,den)
v = [-6 6 -6 6];
axis(v); axis('square')
grid;
title ('Root-Locus Plot of G(s) = K(s + 3)/[s(s + 1)(s^2 + 4s + 16)]')

4
LAB6 CONTROL SYSTEM ANALYSIS BY
CONTROL SYSTEMS ROOT LOCUS METHOD

Note that in previous MATLAB program, instead of


den = [1 5 20 16 0]
we may enter
den = conv ([1 1 0], [1 4 16])
The results are the same.

3.0 Root locus of systems represented as state space

Consider the system represented as a state space model in the following figure. The
system equations are
= +
= +
= −

In this example problem we shall obtain the root-locus diagram of the system defined in
state space. As an example let us consider the case where matrices A, B, C, and D are

0 1 0 0
= 0 0 1 , = 1
−160 −56 −14 −14

= [1 0 0], = [0]

The root-locus plot for this system can be obtained with MATLAB by use of the following
command:
rlocus(A,B,C,D)

This command will produce the same root-locus plot as can be obtained by use of the
rlocus (num,den) command, where num and den are obtained from

5
LAB6 CONTROL SYSTEM ANALYSIS BY
CONTROL SYSTEMS ROOT LOCUS METHOD

[num,den] = ss2tf(A,B,C,D)
as follows:
num = [0 0 1 0]
den = [1 14 56 160]
Following MATLAB program will generate the root-locus plot as shown in following
figure.

% --------- Root-locus plot ---------


A = [0 1 0;0 0 1;-160 -56 -14];
B = [0;1;-14];
C = [1 0 0];
D = [0];
K = 0:0.1:400;
rlocus(A,B,C,D,K);
v = [-20 20 -20 20]; axis(v)
grid
title('Root-Locus Plot of System Defined in State Space')

6
LAB6 CONTROL SYSTEM ANALYSIS BY
CONTROL SYSTEMS ROOT LOCUS METHOD
4.0 Lab Report

Prepare a lab report based on literature review from this document, Chapter 6 of the
textbook, exercise problems of this lab and include the solutions to the following
problems using MATLAB. Attach MATLAB codes with your lab report.

1. Evaluate the root locus for the following open loop systems

1
=
+3
1
=
+3 +1
+5
=
"
+3 +1
1
=
#
+1 +3 +5

2. From root locus, observe the range for K for which the closed loop system is
stable. (State the limits)

3. Discuss the step time response of the closed loop system with respect to K for
each system keeping in view the effects of s-plane variables to that of time
domain. (e.g. $ %& '( ). Only use your root locus results for discussion.

4. Choose the most ideal closed loop root location on the root locus for each
example (minimum rise time, overshoot and settling time)

7
LAB7 PROPORTIONAL CONTROLLER
CONTROL SYSTEMS DESIGN USING ROOT LOCUS

1.0 Closed-Loop Poles

The root locus of an (open-loop) transfer function ( ) is a plot of the locations (locus)
of all possible closed-loop poles with proportional gain K and unity feedback.

The closed-loop transfer function is:

( ) ( )
=
( ) 1+ ( )

and thus the poles of the closed-loop poles of the closed-loop system are values of s
such that

1+ ( ) = 0.

If we write ( ) = ( )/ ( ) , then this equation has the form:

( )+ ( )=0

( )
+ ( )=0

Let = order of ( ) and = order of ( ) (the order of a polynomial is the highest


power of s that appears in it). We will consider all positive values of K. In the limit as →
0, the poles of the closed-loop system are ( ) = 0 or the poles of ( ). In the limit
as → ∞, the poles of the closed-loop system are ( ) = 0 or the zeros of ( ).
No matter what we pick K to be, the closed-loop system must always have poles,
where is the number of poles of ( ). The root locus must have branches, each
branch starts at a pole of ( ). and goes to a zero of ( ). If ( ). has more poles than
zeros (as is often the case), < and we say that ( ) has zeros at infinity. In this case,
the limit of ( ) as → ∞ is zero. The number of zeros at infinity is − , the number
of poles minus the number of zeros, and is the number of branches of the root locus that
go to infinity (asymptotes).

1
LAB7 PROPORTIONAL CONTROLLER
CONTROL SYSTEMS DESIGN USING ROOT LOCUS
Since the root locus is actually the locations of all possible closed-loop poles, from the
root locus we can select a gain such that our closed-loop system will perform the way we
want. If any of the selected poles are on the right half plane, the closed-loop system will
be unstable. The poles that are closest to the imaginary axis have the greatest influence
on the closed-loop response, so even though the system has three or four poles, it may
still act like a second or even first order system depending on the location(s) of the
dominant pole(s).

2.0 Choosing a Value of K from the Root Locus

The plot above shows all possible closed-loop pole locations for a pure proportional
controller. Obviously not all of those closed-loop poles will satisfy our design criteria, To
determine what part of the locus is acceptable, we can use the
command sgrid(Zeta,Wn) to plot lines of constant damping ratio and natural frequency.
Its two arguments are the damping ratio ( ) and natural frequency ( ) [these may be
vectors if you want to look at a range of acceptable values]. In our problem, we need an
overshoot less than 5% (which means a damping ratio of greater than 0.7) and a rise
time of 1 second (which means a natural frequency greater than 1.8). Enter the
following in the MATLAB command window:
Zeta = 0.7;
Wn = 1.8;
sgrid(Zeta,Wn)

On the plot above, the two dotted lines at about a 45 degree angle indicate pole locations
with = 0.7; in between these lines, the poles will have > 0.7 and outside of the

2
LAB7 PROPORTIONAL CONTROLLER
CONTROL SYSTEMS DESIGN USING ROOT LOCUS
lines < 0.7. The semicircle indicates pole locations with a natural frequency = 1.8;
inside the circle, < 1.8 and outside the circle > 1.8.

Going back to our problem, to make the overshoot less than 5%, the poles must lie in
between the two white dotted lines, and to make the rise time shorter than 1 second, the
poles have to be outside of the white dotted semicircle. So now we know only the part of
the locus outside of the semicircle and in between the two lines are acceptable. All the
poles in this location are in the left-half plane, so the closed-loop system will be stable.

From the plot above we see that there is part of the root locus inside the desired region.
So in this case, we need only a proportional controller to move the poles to the desired
region. You can use the rlocfind command in MATLAB to choose the desired poles on the
locus:
[k,poles] = rlocfind(sys)
Click on the plot the point where you want the closed-loop pole to be. You may want to
select the points indicated in the plot below to satisfy the design criteria.

3
LAB7 PROPORTIONAL CONTROLLER
CONTROL SYSTEMS DESIGN USING ROOT LOCUS
Note that since the root locus may have more than one branch, when you select a pole,
you may want to find out where the other pole (poles) are. Remember they will affect the
response too. From the plot above, we see that all the poles selected (all the "+" signs)
are at reasonable positions. We can go ahead and use the chosen K as our proportional
controller.

3.0 Closed-Loop Response


In order to find the step response, you need to know the closed-loop transfer function.
You could compute this using the rules of block diagrams, or let MATLAB do it for you
(there is no need to enter a value for K if the rlocfind command was used):
K = 350;
sys_cl = feedback(K*sys,1)
sys_cl =

350 s + 2450
--------------------------------------
s^4 + 40 s^3 + 475 s^2 + 1850 s + 2450

Continuous-time transfer function.

The two arguments to the function feedback are the numerator and denominator of the
open-loop system. You need to include the proportional gain that you have chosen.
Unity feedback is assumed.
If you have a non-unity feedback situation, look at the help file for the MATLAB
function feedback, which can find the closed-loop transfer function with a gain in the
feedback loop.
Check out the step response of your closed-loop system:
step(sys_cl)

4
LAB7 PROPORTIONAL CONTROLLER
CONTROL SYSTEMS DESIGN USING ROOT LOCUS
As we expected, this response has an overshoot less than 5% and a rise time less than 1
second.

4.0 Using SISOTOOL for Root Locus Design


Another way to complete what was done above is to use the interactive MATLAB GUI
called sisotool. Using the same model as above, first define the plant, ( ).
s = tf('s');
plant = (s + 7)/(s*(s + 5)*(s + 15)*(s + 20));
The sisotool function can be used for analysis and design. In this case, we will focus on
using the Root Locus as the design method to improve the step response of the plant.
To begin, type the following into the MATLAB command window:
sisotool(plant)
The following window should appear. To start, select the tab labeled Graphical Tuning.
Within this window, turn off Plot 2 and make sure Plot 1 is the Root Locus and verify
that Open Loop 1 is selected. Finally, click the button labeled Show Design Plot to bring
up the tunable Root Locus plot.

5
LAB7 PROPORTIONAL CONTROLLER
CONTROL SYSTEMS DESIGN USING ROOT LOCUS

6
LAB7 PROPORTIONAL CONTROLLER
CONTROL SYSTEMS DESIGN USING ROOT LOCUS
In the same fashion, select the tab labeled Analysis Plots. Within this window, for Plot 1,
select Step. In the Contents of Plots subwindow, select Closed Loop r to y for Plot 1. If
the window does not automatically pop up, click the button labeled Show Analysis Plot.

The next thing to do is to add the design requirements to the Root Locus plot. This is done
directly on the plot by right-clicking and selecting Design Requirements, New. Design
requirements can be set for the Settling Time, the Percent Overshoot, the Damping Ratio,
the Natural Frequency, or a Region Constraint. There is no direct requirement for Rise
Time, but the natural frequency can be used for this.
Here, we will set the design requirements for the damping ratio and the natural frequency
just like was done with sgrid. Recall that the requirements call for = 0.7 and = 1.8. Set
these within the design requirements. On the plot, any area which is still white, is an
acceptable region for the poles.
Zoom into the Root Locus by right-clicking on the axis and select Properties, then click the
label Limits. Change the real axis to -25 to 5 and the imaginary to -2.5 to 2.5.
Also, we can see the current values of some key parameters in the response. In the Step
response, right-click on the plot and go to Characteristics and select Peak Response. Do
the same for the Rise Time. There should now be two large dots on the screen indicating

7
LAB7 PROPORTIONAL CONTROLLER
CONTROL SYSTEMS DESIGN USING ROOT LOCUS
the location of these parameters. Click each of these dots to bring up a screen with
information.
Both plots should appear as shown here:

As the characteristics show on the Step response, the overshoot is acceptable, but the
rise time is incredibly off. To fix this, we need to choose a new value for the gain K.
Similarly to the rlocfind command, the gain of the controller can be changed directly on
the root locus plot. Click and drag the pink box on the origin to the acceptable area where
the poles have an imaginary component as shown below.

8
LAB7 PROPORTIONAL CONTROLLER
CONTROL SYSTEMS DESIGN USING ROOT LOCUS
At the bottom of the plot, it can be seen that the loop gain has been changed to 361.
Looking at the Step response, both of the values are acceptable for our requirements.

5.0 Lab Report

Prepare a lab report based on literature review from this document, Chapter 6 of the
textbook, exercise problems of this lab and include the solutions to the following
problems using MATLAB. Attach MATLAB codes with your lab report.

1. Write a MATLAB code to implement the design steps for proportional controller
design. The program must take as an input the time-domain requirements and
open loop transfer function. Next, it should plot the root locus and the desired
region of closed loop pole location. The user must be able to choose the desired
pole location from root locus. The program should provide the design value for K
and its closed loop step response.

1
( )=
+3
1
( )=
( + 3)( + 1)
( + 5)
!( ) =
( + 3)( + 1)
1
#( ) =
( + 1)( + 3)( + 5)

9
LAB7 PROPORTIONAL CONTROLLER
CONTROL SYSTEMS DESIGN USING ROOT LOCUS

2. Use the program in 1 to design proportional controller for following open loop
systems, keeping the overshoot under 5% and minimum rise time.

1
( )=
+3
1
( )=
( + 3)( + 1)
( + 5)
!( ) =
( + 3)( + 1)
1
#( ) =
( + 1)( + 4)( + 8)

3. Explain which pole location have you chosen in 2 and why?

4. If the design requirements aren’t being met in 2, tune the controller to do so.
Explain how are you tuning the controller.

5. Verify the results using sisotool.

6. Comment on what you have learned after performing this lab.

10
LAB8 LEAD COMPENSATION USING
CONTROL SYSTEMS ROOT LOCUS

1.0 Introduction

In lecture notes, we presented an introduction to compensation of control systems and


discussed preliminary materials for the root-locus approach to control-systems design
and compensation. In this lab we shall present control-systems design by use of the lead
compensation technique. In carrying out a control-system design, we place a
compensator in series with the unalterable transfer function G(s) to obtain desirable
behavior. The main problem then involves the judicious choice of the pole(s) and zero(s)
of the compensator Gc(s) to have the dominant closed-loop poles at the desired location
in the s plane so that the performance specifications will be met.

2.0 Physical Realization:

There are many ways to realize lead compensators and lag compensators, such as
electronic networks using operational amplifiers, electrical RC networks, and mechanical
spring-dashpot systems. Following figure shows an electronic circuit using operational
amplifiers. The transfer function for this circuit is obtained in Chapter 3 of the textbook
as follows:

1
( ) +1 + +1
= = =
( ) +1 1 +1
+
Notice that for lead network, > , and this network has a D.C. gain of .

1
LAB8 LEAD COMPENSATION USING
CONTROL SYSTEMS ROOT LOCUS
3.0 Lead Compensation Techniques Based on the Root-Locus Approach

The root-locus approach to design is very powerful when the specifications are given in
terms of time-domain quantities, such as the damping ratio and undamped natural
frequency of the desired dominant closed-loop poles, maximum overshoot, rise time, and
settling time.
Consider a design problem in which the original system either is unstable for all values of
gain or is stable but has undesirable transient-response characteristics. In such a case, the
reshaping of the root locus is necessary in the broad neighborhood of the jv axis and the
origin in order that the dominant closed-loop poles be at desired locations in the complex
plane. This problem may be solved by inserting an appropriate lead compensator in
cascade with the feedforward transfer function. The procedures for designing a lead
compensator for the system by the root-locus method may be stated as follows:

1. From the performance specifications, determine the desired location for the
dominant closed-loop poles.

2. By drawing the root-locus plot of the uncompensated system (original system),


ascertain whether or not the gain adjustment alone can yield the desired closed
loop poles. If not, calculate the angle deficiency f. This angle must be contributed
by the lead compensator if the new root locus is to pass through the desired
locations for the dominant closed-loop poles.

3. Assume the lead compensator Gc(s) to be (you may use the conventions use in
lecture notes as well):

+1
( )= , (0 < < 1)
+1
where and T are determined from the angle deficiency. Kc is determined from
the requirement of the open-loop gain.

4. Determine the value of Kc of the lead compensator from the magnitude condition.

Once a compensator has been designed, check to see whether all performance
specifications have been met. If the compensated system does not meet the performance

2
LAB8 LEAD COMPENSATION USING
CONTROL SYSTEMS ROOT LOCUS
specifications, then repeat the design procedure by adjusting the compensator pole and
zero until all such specifications are met.

Note that if the selected dominant closed-loop poles are not really dominant, or if the
selected dominant closed-loop poles do not yield the desired result, it will be necessary
to modify the location of the pair of such selected dominant closed-loop poles. (The
closed-loop poles other than dominant ones modify the response obtained from the
dominant closed-loop poles alone. The amount of modification depends on the location
of these remaining closed-loop poles.) Also, the closed-loop zeros affect the response if
they are located near the origin.

4.0 Writing MATLAB code for Lead Controller

Where the lead controller C(s) is given by the following expression:

+
( )=
+
Where > >0

1. Draw root locus for the plant in MATLAB using the rlocus command.

rlocus(num, den);
grid; hold on;
yl=ylim;

2. Draw the rise time desired region in s-plane represented by undamped natural
frequency. The following command for example draws circle with r=5

trd=0.4; omega_n=2/trd; %from tr requirement to omega_n


rectangle('Position',[-omega_n,-omega_n,2*omega_n,2*omega_n],'Curvature',[1,1]);

3. Plot settling time requirements(if any) on s plane, represented by the real part.
The following command, for example draws a line at -4

tsd=1; sigma = 4/tsd; %from ts requirement to sigma


line([-sigma -sigma],yl);

4. Overshoot requirements on s plane are represented by the damping ratio. The


following command plots the limits in s-plane for 0.7 damping ratio(5%
overshoot)

3
LAB8 LEAD COMPENSATION USING
CONTROL SYSTEMS ROOT LOCUS

Mp=5; zeta=0.7; %from Mp requiremet to zeta


line([0 yl(1)*zeta/sqrt(1-zeta^2)],[0 yl(1)]);
line([0 -yl(2)*zeta/sqrt(1-zeta^2)],[0 yl(2)]);

Use following command after the command mention in 4:


hold off;
xl=xlim;
xl(2)=0; xlim(xl);

‘xl’ and ‘yl’ must be chosen suitably, such that movement of dominant poles is
suitably visible in the root locus.

5. To choose desired closed loop pole location, use the following command:

[x,y]=ginput(1); pd=x+j*y

6. To compute the ∠ ( ) , use the following command. Note that MATLAB


evaluates angles in radians.

Gpd=evalfr(sys_p,pd)
phi=pi - angle(Gpd)
7. Pick z such that:
Z=abs(x)
8. Calculate and from .

phi1=angle(pd+z); phi2=phi1-phi;

9. Calculate the p of controller such that:


p=abs(real(pd))+abs(imag(pd)/tan(phi2));

10. Compute K

K=abs((pd+p)/(pd+z)/Gpd);

11. Evaluate the step response of the overall closed loop system and see if the
requirements are met:

sysc=tf(K*[1 z],[1 p]);


hold on;

4
LAB8 LEAD COMPENSATION USING
CONTROL SYSTEMS ROOT LOCUS
rlocus(sysc*sysp);

12. Choose the value of desired pole moving further inside the desired region and
repeat the steps if the specifications haven’t been completely met.

5.0 Lab Report

Prepare a lab report based on literature review from this document, Chapter 6 of the
textbook, exercise problems of this lab and include the solutions to the following
problems using MATLAB. Attach MATLAB codes with your lab report.

1. Write a MATLAB code to implement the design steps for lead controller design.
The program must take as an input the time-domain requirements and open loop
transfer function. Next, it should plot the root locus and the desired region of
closed loop pole location. The user must be able to choose the desired pole
location from root locus. The program should provide the design value for K, z and
p, and its closed loop step response.

2. Use the program in 1 to design lead controller for following open loop systems,
keeping the overshoot under 5%, rise time less than or equal to 0.2s, and settling
time less than or equal to 1s.

1 1
( )= , ( )=
+3 ( + 3)( + 1)
( + 5) 1
( )= , ( )=
( + 3)( + 1) ( + 1)( + 4)( + 8)

3. Explain which pole location have you chosen in 2 and why?

4. If the design requirements aren’t being met in 2, tune the controller to do so.
Explain how are you tuning the controller.

5. Verify the results using sisotool.

6. Comment on what you have learned after performing this lab.

5
LAB9 LAG COMPENSATION USING
CONTROL SYSTEMS ROOT LOCUS

1.0 Introduction

Consider the problem of finding a suitable compensation network for the case where the
system exhibits satisfactory transient-response characteristics but unsatisfactory steady-
state characteristics. Compensation in this case essentially consists of increasing the open
loop gain without appreciably changing the transient-response characteristics. This
means that the root locus in the neighborhood of the dominant closed-loop poles should
not be changed appreciably, but the open-loop gain should be increased as much as
needed.
This can be accomplished if a lag compensator is put in cascade with the given
feedforward transfer function. To avoid an appreciable change in the root loci, the angle
contribution of the lag network should be limited to a small amount, say less than 5°. To
assure this, we place the pole and zero of the lag network relatively close together and
near the origin of the s plane. Then the closed-loop poles of the compensated system will
be shifted only slightly from their original locations. Hence, the transient-response
characteristics will be changed only slightly.

2.0 Physical Realization:

There are many ways to realize lead compensators and lag compensators, such as
electronic networks using operational amplifiers, electrical RC networks, and mechanical
spring-dashpot systems. Following figure shows an electronic circuit using operational
amplifiers. The transfer function for this circuit is obtained in Chapter 3 of the textbook
as follows:

1
( ) +1 + +1
= = =
( ) +1 1 +1
+

1
LAB9 LAG COMPENSATION USING
CONTROL SYSTEMS ROOT LOCUS
Notice that for lead network, < , and this network has a D.C. gain of .

3.0 Lag Compensation Techniques Based on the Root-Locus Approach

The procedure for designing lag compensators for the system shown in following figure
by the root-locus method may be stated as follows (we assume that the uncompensated
system meets the transient-response specifications by simple gain adjustment):

1. Draw the root-locus plot for the uncompensated system whose open-loop
transfer function is G(s). Based on the transient-response specifications, locate the
dominant closed-loop poles on the root locus.

2. Assume the transfer function of the lag compensator to be given by equation:

+1
( )=
+1
Then the open-loop transfer function of the compensated system becomes
( ) ( )

3. Evaluate the particular static error constant specified in the problem.

4. Determine the amount of increase in the static error constant necessary to satisfy
the specifications.

5. Determine the pole and zero of the lag compensator that produce the necessary
increase in the particular static error constant without appreciably altering the
original root loci. (Note that the ratio of the value of gain required in the
specifications and the gain found in the uncompensated system is the required
ratio between the distance of the zero from the origin and that of the pole from
the origin.)

6. Draw a new root-locus plot for the compensated system. Locate the desired
dominant closed-loop poles on the root locus. (If the angle contribution of the lag
network is very small—that is, a few degrees—then the original and new root loci

2
LAB9 LAG COMPENSATION USING
CONTROL SYSTEMS ROOT LOCUS
are almost identical. Otherwise, there will be a slight discrepancy between them.
Then locate, on the new root locus, the desired dominant closed-loop poles based
on the transient-response specifications.)

7. Adjust gain of the compensator from the magnitude condition so that the
dominant closed-loop poles lie at the desired location. ( will be approximately
1)

4.0 Writing MATLAB code for Lag Controller

Where the lead controller C(s) is given by the following expression:

+
( )=
+
Where > >0

1. Draw root locus for the plant in MATLAB using the rlocus command.

rlocus(num, den);
grid; hold on;
yl=ylim;

2. Draw the rise time desired region in s-plane represented by undamped natural
frequency. The following command for example draws circle with r=5

trd=0.4; omega_n=2/trd; %from tr requirement to omega_n


rectangle('Position',[-omega_n,-omega_n,2*omega_n,2*omega_n],'Curvature',[1,1]);

3. Plot settling time requirements(if any) on s plane, represented by the real part.
The following command, for example draws a line at -4

tsd=1; sigma = 4/tsd; %from ts requirement to sigma


line([-sigma -sigma],yl);

4. Overshoot requirements on s plane are represented by the damping ratio. The


following command plots the limits in s-plane for 0.7 damping ratio(5%
overshoot)

Mp=5; zeta=0.7; %from Mp requiremet to zeta


line([0 yl(1)*zeta/sqrt(1-zeta^2)],[0 yl(1)]);
line([0 -yl(2)*zeta/sqrt(1-zeta^2)],[0 yl(2)]);

3
LAB9 LAG COMPENSATION USING
CONTROL SYSTEMS ROOT LOCUS

Use following command after the command mention in 4:


hold off;
xl=xlim;
xl(2)=0; xlim(xl);
‘xl’ and ‘yl’ must be chosen suitably, such that movement of dominant poles is
suitably visible in the root locus.

5. To choose desired closed loop pole location, use the following command:

[x,y]=ginput(1); pd=x+j*y

6. Compute K

K=abs(1/Gpd);

7. With that K, compute error constant (Kpa, Kva, Kaa) from KG(s)

sysol = sysc*sysp;
[nol, dol]=tfdata(sysol,'v');
dn0=dol(dol~=0);
Kact=nol(end)/dn0(end);

8. From specs, compute Kpd, Kvd, Kad

Kdes=(1-ess)/ess %for kp
Kdes = 1/ess; % for Kv and Ka

9. If Kact > Kdes , requirements already met and hence no further need to evaluate
the controller

( ) $%&'
else: pick − ≈ , and =
!~ # $ ()

z=-real(pd)/…; %where … is in the range 5~20


p=z*Kact/Kdes/(1+…); % where … is 0.05 or 0.1

10. Re-compute K

K=abs((pd+p)/(pd+z)/Gpd);

4
LAB9 LAG COMPENSATION USING
CONTROL SYSTEMS ROOT LOCUS

11. Evaluate the step response of the overall closed loop system and see if the
requirements are met:

sysc=tf(K*[1 z],[1 p]);


hold on;
rlocus(sysc*sysp);

12. Change the value of the range mentioned in step 9, and repeat the steps if the
specifications haven’t been completely met.

5.0 Lab Report

Prepare a lab report based on literature review from this document, Chapter 6 of the
textbook, exercise problems of this lab and include the solutions to the following
problems using MATLAB. Attach MATLAB codes with your lab report.

1. Write a MATLAB code to implement the design steps for lag controller design. The
program must take as an input the time-domain requirements and open loop
transfer function. Next, it should plot the root locus and the desired region of
closed loop pole location. The user must be able to choose the desired pole
location from root locus. The program should provide the design value for K, z and
p and its closed loop step response.

2. Use the program in 1 to design lag controller for following open loop systems,
keeping the ess to unit step in first part less than 1%, ess to unit ramp in the second
system less than 1% and ess to unit acceleration in third example to be less than
1%

1 1
( )= , ( )=
+3 ( + 3)( + 1)
( + 5)
( )=
( + 3)( + 1)

3. Explain which pole location have you chosen in 2 and why?

5
LAB9 LAG COMPENSATION USING
CONTROL SYSTEMS ROOT LOCUS
4. If the design requirements aren’t being met in 2, tune the controller to do so.
Explain how are you tuning the controller.

5. Verify the results using sisotool.

6. Comment on what you have learned after performing this lab.

6
LAB10 LAG-LEAD COMPENSATION
CONTROL SYSTEMS USING ROOT LOCUS

1.0 Introduction

Lead compensation basically speeds up the response and increases the stability of the
system. Lag compensation improves the steady-state accuracy of the system, but reduces
the speed of the response. If improvements in both transient response and steady-state
response are desired, then both a lead compensator and a lag compensator may be used
simultaneously. Rather than introducing both a lead compensator and a lag compensator
as separate units, however, it is economical to use a single lag–lead compensator.

Lag–lead compensation combines the advantages of lag and lead compensations. Since
the lag–lead compensator possesses two poles and two zeros, such a compensation
increases the order of the system by 2, unless cancellation of pole(s) and zero(s) occurs in
the compensated system.

2.0 Physical Realization:

Following figure shows an electronic lag–lead compensator using operational amplifiers.

1 1
+ +
The transfer function of the compensator shown in the above figure is

( )
=
( ) 1
+ +
Where

1
LAB10 LAG-LEAD COMPENSATION
CONTROL SYSTEMS USING ROOT LOCUS
+ + +
= > 1, = > 1, =
+

Note that is often chosen to be equal to .

3.0 Lag-Lead Compensation Techniques Based on the Root-Locus


Approach

figure by the root-locus method may be stated as follows (assuming : = )


The procedure for designing lag-lead compensators for the system shown in following

1. From the given performance specifications, determine the desired location for the
dominant closed-loop poles.

1 1
+ +
2. The lag–lead compensator given by Equation (6–23) is modified to

( )=
1
+ +

where : > 1. The open-loop transfer function of the compensated system is


( ) ( ). If the static velocity error constant is specified, determine the value

= lim ( )
of constant from the following equation:
"→$

angle contribution % needed from the phase-lead portion of the lag–lead


3. To have the dominant closed-loop poles at the desired location, calculate the

compensator.

1
+
4. For the lag–lead compensator, we later choose sufficiently large so that

& &
1
+

2
LAB10 LAG-LEAD COMPENSATION
CONTROL SYSTEMS USING ROOT LOCUS

is approximately unity, where is one of the dominant closed-loop poles.


Determine the values of and b from the magnitude and angle conditions:

1
+
& ' ( ( )& = 1
+
1
+
)*+,- ' (=%
+

5. Using the value of just determined, choose so that

1
+
& &≈1
+

1
+
−5° < ' ( = 0°
+

The value of the largest time constant of the lag–lead compensator, should not be
too large to be physically realized.

4.0 Writing MATLAB code for Lag Controller

Where the lead controller C(s) is given by the following expression:

+ 56789 + 568;
4( ) =
+ :6789 + :68;
Where :6789 > 56789 > 0 and 568; > :68; > 0

1. Draw root locus for the plant in MATLAB using the rlocus command.

3
LAB10 LAG-LEAD COMPENSATION
CONTROL SYSTEMS USING ROOT LOCUS
sys_p=tf(num,den);
rlocus(sys_p);
grid; hold on;
yl=ylim;

2. Draw the rise time desired region in s-plane represented by undamped natural
frequency. The following command for example draws circle with r=5

trd=0.4; omega_n=2/trd; %from tr requirement to omega_n


rectangle('Position',[-omega_n,-omega_n,2*omega_n,2*omega_n],'Curvature',[1,1]);

3. Plot settling time requirements(if any) on s plane, represented by the real part.
The following command, for example draws a line at -4

tsd=1; sigma = 4/tsd; %from ts requirement to sigma


line([-sigma -sigma],yl);

4. Overshoot requirements on s plane are represented by the damping ratio. The


following command plots the limits in s-plane for 0.7 damping ratio(5%
overshoot)

Mp=5; zeta=0.7; %from Mp requiremet to zeta


line([0 yl(1)*zeta/sqrt(1-zeta^2)],[0 yl(1)]);
line([0 -yl(2)*zeta/sqrt(1-zeta^2)],[0 yl(2)]);

Use following command after the command mentioned in 4:


hold off;
xl=xlim;
xl(2)=0; xlim(xl);
‘xl’ and ‘yl’ must be chosen suitably, such that movement of dominant poles is
suitably visible in the root locus.

5. To choose desired closed loop pole location, use the following command:

[x,y]=ginput(1); pd=x+j*y

6. To compute the ∠ (:9 )=> %, use the following command. Note that MATLAB
evaluates angles in radians.

4
LAB10 LAG-LEAD COMPENSATION
CONTROL SYSTEMS USING ROOT LOCUS
Gpd=evalfr(sys_p,pd)
phi=pi - angle(Gpd)
7. Pick z of lead controller such that:

8. Calculate % and % from %.


z_lead=abs(real(pd))+4

phi1=angle(pd+z); phi2=phi1-phi;

9. Calculate the p of lead controller such that:


p_lead=abs(real(pd))+abs(imag(pd)/tan(phi2));

10. Compute K

K=abs((pd+p)/(pd+z)/Gpd);
sysc_lead=tf([1 z_lead],[1 p_lead]);

11. With that K, compute error constant (Kpa, Kva, Kaa) from KG(s)

sysol = sysc_lead*sys_p;
[nol, dol]=tfdata(sysol,'v');
dn0=dol(dol~=0);
Kact=nol(end)/dn0(end);

12. From specs, compute Kpd, Kvd, Kad

Kdes=(1-ess)/ess %for kp
Kdes = 1/ess; % for Kv and Ka

13. If Kact > Kdes , requirements already met and hence no further need to evaluate
the controller

else: pick −5 ≈ , and : = 5 CDEF


?7(@A ) C
~ $ AGH

z_lag=-real(pd)/…; %where … is in the range 5~20


p_lag=z_lag*Kact/Kdes/(1+…); % where … is 0.05 or 0.1

14. Re-compute K

K=abs((pd+p_lag)*(pd+p_lead)/((pd+z_lag)*(pd+z_lead)*Gpd));

5
LAB10 LAG-LEAD COMPENSATION
CONTROL SYSTEMS USING ROOT LOCUS

15. Evaluate the step response of the overall closed loop system and see if the
requirements are met:

sysc_num=conv([1 z_lead],[1 z_lag]);


sysc_den=conv([1 p_lead],[1 p_lag]);
sysc_laglead=tf(K*sysc_num,sysc_den);
hold on;
rlocus(sysc_laglead*sys_p);

16. Change the desired pole location in step 5, value of the range mentioned in step
13, and repeat the steps if the specifications haven’t been completely met.

5.0 Lab Report

Prepare a lab report based on literature review from this document, Chapter 6 of the
textbook, exercise problems of this lab and include the solutions to the following
problems using MATLAB. Attach MATLAB codes with your lab report.

1. Write a MATLAB code to implement the design steps for lag-lead controller design.
The program must take as an input the time-domain requirements and open loop
transfer function. Next, it should plot the root locus and the desired region of
closed loop pole location. The user must be able to choose the desired pole
location from root locus. The program should provide the design value for K, z and
p for lead controller. Furthermore, it should also evaluate the z and p for lag
controller and recompute K and provide a final step response of overall system.

2. Use the program in 1 to design lag-lead controller for following open loop system
to meet following requirements:

J@ ≤ 16%, N" ≤ 20 , NO ≤ 5 , -"" N= N-: = 0, -"" N= >)P: ≤ 0.2

1
( )=
( + 1)( + 2)

6
LAB10 LAG-LEAD COMPENSATION
CONTROL SYSTEMS USING ROOT LOCUS
3. Explain which pole location have you chosen in 2 and why?

4. If the design requirements aren’t being met in 2, tune the controller to do so.
Explain how are you tuning the controller.

5. Verify the results using sisotool.

6. Comment on what you have learned after performing this lab.

7
LAB11 PI COMPENSATION & OVERALL
CONTROL SYSTEMS CONTROLLER DESIGN

1.0 Introduction

PI compensation is used to eliminate the steady state error for a certain type of input.
Since the steady state error depends on the system type of the open loop system, PI
changes the steady state error of the closed loop system by increasing the system type of
open loop system by one. Refer to the table in lecture notes that compares the steady
state error with the system type of open loop system for more details.

2.0 Implementation

Design a PI controller using the steps provided in the lecture notes and also write a
MATLAB code for overall controller design. The code should implement the following
sequence:

1. Check for rise time, settling time and overshoot requirements.


2. Plot the root locus with the shaded desired pole location area according to the
given time-domain specifications:
3. If the root locus passes through the desired region
a. Implement Proportional Controller and go to step 5.
b. Else go to step 4.
4. If the root locus doesn’t pass through the desired region implement Lead
compensation. Avoid using PD compensation due to its demerits such as; large
high frequency gain.
5. Check for steady state error requirements:
a. If requirements are met, go directly to step 6.
b. Else, If you need to reduce the steady state error at a said input;
implement Lag compensation.
c. Else, If you need to eliminate the steady state error at a said input;
implement PI compensation.
6. Fulfill the unity gain requirement for open loop system and calculate K.
7. Tune the controllers if requirements are not completely met.

1
LAB11 PI COMPENSATION & OVERALL
CONTROL SYSTEMS CONTROLLER DESIGN
5.0 Lab Report

Prepare a lab report based on literature review from this document, Chapter 8 of the
textbook, exercise problems of this lab and include the solutions to the following
problems using MATLAB. Attach MATLAB codes with your lab report.

1. Write a MATLAB code to implement the design steps for PI controller design.

2. Write a MATLAB code to implement the overall controller design as explained in


Section 2.0.

3. Use examples in previous labs and lecture notes for verifying your code.

4. Verify the results using sisotool.

5. Comment on what you have learned after performing this lab.

2
Name: Reg # Section/Group:

EXPERIMENT # 12
Modular Servo System
Introduction and General Description
Introduction
The Modular Servo System (MSS) consists of the Inteco digital servomechanism and open
architecture software environment for real-time control experiments. The main concept of the
MSS is to create a rapid and direct path from the control system design to hardware
implementation. The MSS supports the real-time design and implementation of advanced control
methods using MATLAB and Simulink tools and extends the MATLAB environment in the
solution of digital servomechanism control problems.

The integrated software supports all phases of a control system development:




on-line process identification,


control system modelling, design and simulation,

real-time implementation of control algorithms.

Product Overview

The MSS setup (Fig. 1.1) consists of several modules mounted at the metal rail and coupled with
small clutches. The modules are arranged in the chain. The DC motor together with
tachogenerator opens the chain. The gearbox with the output disk closes the chain. The
potentiometer module is located outside the chain. For example the DC motor can drive activates
the following modules: inertia, backlash, encoder module, magnetic brake and the gearbox with
the output disk. The rotation angle of the DC motor shaft is measured using an incremental
encoder. Anywhere the rotational angle measurement is required we can place the encoder. A
tachogenerator is connected directly to the DC motor and generates a voltage signal proportional
to the angular velocity.

The servomechanism is connected to a computer where a control algorithm is realized based on


measurements of angle and angular velocity. The system has no inner feedback for dead zone

University of Engineering and Technology 1


Taxila, Pakistan
Name: Reg # Section/Group:

compensation. The accuracy of measurement of velocity is 5% while the accuracy of angle


measurement is 0.1%. The armature voltage of the DC motor is controlled by PWM signal. For
this reason the dimensionless control signal is the scaled input voltage, u(t)=v(t)/v max.
The admissible controls satisfy |u(t)| ≤ 1 and V max = 12 [V].

The measurement system is based on RTDAC/PCI acquisition board equipped with A/D
converters. The I/O board communicates with the power interface unit. The whole logic
necessary to activate and read the encoder signals and to generate the appropriate sequence of
PWM pulsesto control the DC motor is configured in the Xilinx chip of the RT-DAC/PCI board.
All functions of the board are accessed from the Modular Servo Toolbox which operates directly
in the MATLAB/Simulink environment.

Features



The set-up is fully integrated with MATLAB/Simulink and operates in real-time in MS
 Window 2000/XP/W7.

Real-time control algorithms can be rapidly prototyped. No C code programming is
 required. The software includes complete dynamic models.

The User’s Manual contains a number  of pre-programmed experiments familiarizing the
user with the system in a fast way.

Modular Servo System Setup


Modular servo system setup consists of following parts.

 Tachogenerator

 DC motor

 Inertial load

 Backlash

 Encoder

 Gearbox with disc

Magnetic brake

University of Engineering and Technology 2


Taxila, Pakistan
Name: Reg # Section/Group:

Tachogenerator

An electromechanical generator is a device capable of producing electrical power from


mechanical energy, usually the turning of a shaft. When not connected to a load resistance,
generators will generate voltage roughly proportional to shaft speed. With precise construction
and design, generators can be built to produce very precise voltages for certain ranges of shaft
speeds, thus making them well-suited as measurement devices for shaft speed in mechanical
equipment. A generator specially designed and constructed for this use is called
a tachometer or tachogenerator. Often, the word "tach" (pronounced "tack") is used rather than
the whole word.

By measuring the voltage produced by a tachogenerator, we can easily determine the rotational
speed of whatever it’s mechanically attached to. One of the more common voltage signal ranges
used with tachogenerators is 0 to 10 volts. Obviously, since a tachogenerator cannot produce
voltage when its not turning, the zero cannot be "live" in this signal standard. Tachogenerators
can be purchased with different "full-scale" (10 volt) speeds for different applications. Although
a voltage divider could theoretically be used with a tachogenerator to extend the measurable
speed range in the 0-10 volt scale, it is not advisable to significantly overspeed a precision
instrument like this, or its life will be shortened.

Tachogenerators can also indicate the direction of rotation by the polarity of the output voltage.
When a permanent-magnet style DC generator's rotational direction is reversed, the polarity of
its output voltage will switch. In measurement and control systems where directional indication
is needed, tachogenerators provide an easy way to determine that.

Tachogenerators are frequently used to measure the speeds of electric motors, engines, and the
equipment they power: conveyor belts, machine tools, mixers, fans, etc

University of Engineering and Technology 3


Taxila, Pakistan
Name: Reg # Section/Group:

Backlash

In mechanical engineering, backlash, sometimes called lash or play, is clearance or lost motion
in a mechanism caused by gaps between the parts. It can be defined as "the maximum distance or
angle through which any part of a mechanical system may be moved in one direction without
applying appreciable force or motion to the next part in mechanical sequence"

Modular servo system setup

University of Engineering and Technology 4


Taxila, Pakistan
Name: Reg # Section/Group:

EXERCISE 1 : -
Explain following in detail and their functions in modular servo system.

 Tachogenerator

 Backlash

 Inertial load

 Magnetic brake

Gear box

Solution :-

University of Engineering and Technology 5


Taxila, Pakistan
Name: Reg # Section/Group:

University of Engineering and Technology 6


Taxila, Pakistan
Name: Reg # Section/Group:

EXERCISE 2 : -
Indicate where each of the parts are connected in modular servo system and also draw figure
of each in detail.

Solution :-

University of Engineering and Technology 7


Taxila, Pakistan
Name: Reg # Section/Group:

University of Engineering and Technology 8


Taxila, Pakistan
Name: Reg # Section/Group:

EXPERIMENT # 13
STARTING, TESTING AND STOPPING PROCEDURES
OF MODULAR SERVO SYSTEM
Starting procedure
Invoke MATLAB by double clicking on the MATLAB icon. The MATLAB command window
opens. Then simply type:

>> Servo

Servo Control Window opens (see Fig). The pushbuttons indicate actions that execute
callback routines when the user selects a menu item.

University of Engineering and Technology 1


Taxila, Pakistan
Name: Reg # Section/Group:

Testing and troubleshooting


This section explains how to perform the tests. These tests allow checking if mechanical
assembling and wiring has been done correctly. The tests have to be performed obligatorily after
assembling the system. They are also necessary if an incorrect operation of the system takes
place. The tests are helpful to look for reasons of errors when the system fails. The tests have
been designed to validate the existence and sequence of measurements and controls. They do not
relate to accuracy of the signals.

Task1: Write down the five steps involved in Basic Tests and briefly explain functionality of
each step in your own words.

Solution:-

University of Engineering and Technology 2


Taxila, Pakistan
Name: Reg # Section/Group:

First, you have to be aware that all signals are transferred in a proper way. Five testing steps are
applied.

Double click the Basic Tests button. The following window appears.

The first step in testing of the MSS is to check if the RT-DAC/PCI I/O board is installed
properly.

• Double click the Detect RTDAC/PCI board button. One of the messages shown in Fig opens. If
the board has been correctly installed, the base address, and number of logic version of the board
are displayed.

University of Engineering and Technology 3


Taxila, Pakistan
Name: Reg # Section/Group:

If the board is not detected check if the board is put into the slot properly. The boards are
tested very precisely before sending to a customer and only wrong assembly procedure invokes
errors.

In the next step one can reset encoders. One sets the initial position of the servo system.

• Double click the Reset Angle Encoders button. When the window opens click the Yes option.
The encoders are reset and zero position of the servo system are stored.

The next step of the testing procedure refers to the angle measurement.

University of Engineering and Technology 4


Taxila, Pakistan
Name: Reg # Section/Group:

Task 2: Double click the Check Angles button, next click the Yes button and rotate the inertia
load by hand. The rotational angle of the inertia is measured and displayed. Record and paste
graph displayed.

Solution :-

Task 3: To check whether the potentiometer works correctly double click the Check Reference
Pot button. Next click the Yes and turn the potentiometer right and left using hand. Record and
paste graph displayed.

Solution :-

University of Engineering and Technology 5


Taxila, Pakistan
Name: Reg # Section/Group:

In the next step of the basic tests one can check whether the control and measurements of the
angle and velocity in MSS are correct. This experiment is not performed in real-time mode.

Task 4: Double click the Control Impulse Response button and start experiment clicking the Yes
button. Draw and comment upon figure.

Solution :-

University of Engineering and Technology 6


Taxila, Pakistan
Name: Reg # Section/Group:

Manual setup
The Servo Manual Setup program gives access to the basic parameters of the laboratory modular
servo setup. The most important data transferred from the RT-DAC/PCI board and the
measurements of the servo may be visualized. Moreover, the control signals can be set.

Double click the Manual Setup button and the screen shown in Fig opens.

The application contains four frames:

• RT-DAC/PCI board,

• Encoders,

• Control and

• Analog inputs.

All data presented by the Servo Manual Setup program are updated 10 times per second.

RT-DAC/PCI board frame


The RT-DAC/PCI board frame presents the main parameters of the RT-DAC/PCI I/O board.

No of detected boards

Presents the number of detected RT-DAC/PCI boards. If the number is equal to zero it means
that the software has not detect any RT-DAC/PCI board. When more than one board is detected
the Board list must be used to select the board that communicates with the MSS control program.

Board

Contains the list applied to select the board currently used by the program. The list contains a
single entry for each RT-DAC/PCI board installed in the computer. A new selection at the list
automatically changes values of the remaining parameters.

Bus number

Displays the number of the PCI bus where the current RT-DAC/PCI board is plugged-in. The
parameter may be useful to distinguish boards, when more than one board is used.

University of Engineering and Technology 7


Taxila, Pakistan
Name: Reg # Section/Group:

Slot number

The number of the PCI slot where the current RT-DAC/PCI board is plugged-in. The parameter
may be useful to distinguish boards, when more than one board is used.

Base address

The base address of the selected RT-DAC/PCI board. The RT-DAC/PCI board occupies 256
bytes of the I/O address space of the microprocessor. The base address is equal to the beginning
of the occupied I/O range. The I/O space is assigned to the board by the computer operating
system and may differ from one computer to another.

The base address is given in the decimal and hexadecimal forms.

Logic version

The number of the configuration logic of the on-board FPGA chip. A logic version corresponds
to the configuration of the RT-DAC/PCI boards defined by this logic.

University of Engineering and Technology 8


Taxila, Pakistan
Name: Reg # Section/Group:

Application

The name of the application the board is dedicated for. The name contains four characters. In the
case of the MSS it has to be SERV string.

I/O driver status

The status of the driver that allows the access to the I/O address space of the microprocessor. The
status displayed has to be OK string. In other case the driver HAS TO BE
INSTALLED.

Encoders frame

The state of the encoder channels is given in the Encoder frame.

Channel 0, Channel 1

The values of the encoder counters, the angles expressed in radians and the encoder reset flags
are displayed in the Channel 0 and Channel 1 row. In this version MSS may use a single encoder
module. In such a case only one channel presents the current data.

Value

The values of the encoder counters are given in the respective columns. The values are 24-bit
integer numbers. When an encoder remains in the reset state the corresponding value is equal to
zero.

Angle [rad]

The angular positions of the encoders expressed in radians are given in the respective
columns. When the encoder remains in the reset state the corresponding angle is equal to zero.

Reset

When the checkbox is selected the corresponding encoder remains in the reset state. The
checkbox has to be unchecked to allow the encoder to count the position.

Control frame

The Control frame allows to change the control signal.

Edit field, slider

The control edit box and the slider are applied to set a new control value. The control value may
vary from –1.0 to 1.0.

University of Engineering and Technology 9


Taxila, Pakistan
Name: Reg # Section/Group:

STOP

The pushbutton is applied to switch off the control signal. When pressed the control value is set
to zero.

PWM prescaler

The divider of the PWM reference signal. The frequency of the PWM control is equal to:

Thermal flag / status

The thermal flag and the thermal status of the power amplifier. If the thermal status box is
checked the power interface is overheated. If the thermal flag is set and the power interface is
overheated the RT-DAC/PCI board automatically switches off the PWM control signal.

Analog inputs frame

The Analog inputs frame displays two measured analog signals.

Potentiometer

Presents the voltage at the output of the potentiometer block.

Tacho

Presents the voltage at the output of the tachogenerator.

University of Engineering and Technology 10


Taxila, Pakistan
Name: Reg # Section/Group:

Task5: Vary control input from -1 to +1, Note down all the values shown in manual test in the
form of table, write code in MATLAB and also draw/ paste its output graph (i.e. use subplot).

Solution:-

University of Engineering and Technology 11


Taxila, Pakistan
Name: Reg # Section/Group:

EXPERIMENT # 14
RTWT DRIVER, SIMULATION MODELS AND
IDENTIFICATION OF MODULAR SERVO SYSTEM AND
STATE FEED BACK CONTROLLER
RTWT Driver
The main driver is located in the RTWT Device Driver column. The driver is a software “go-
between” for the real-time MATLAB environment and the RT-DAC/PCI I/O board. This driver
serves the control and measurement signals. Click the Modular Servo Device Driver button and
the driver window opens. When one wants to build his own application he has to copy this driver
to a new Simulink diagram.The device driver has two inputs: control and u (t) ⊂ [−1 1 ] signal
Reset. If the Reset signal changes to one the encoders are reset and do not work. If the Reset
signal is equal to zero encoders work in the standard way. It means when switching occurs,
encoders reset and start measure when the switch returns to the zero (normal) position. It is
important that the Reset switch works only when the real-time code is executed.

The mask of the Servo block contains base address of the RT-DAC/PCI board (automatically
detected with the help RTDACPCIBase Address function) and the sampling period which default
value is set to 0.002 sec. If one wants to change the default sampling time he must do it in this
mask also.

Mask of the device driver

University of Engineering and Technology 1


Taxila, Pakistan
Name: Reg # Section/Group:

The details of the device driver are depicted in Fig. The driver uses a function which
communicates directly with a logic applied at the RTDAC/PCI board. Notice, that the driver is
ready to use a second (optional) encoder, as well.

Interior of the RTWT device driver


Task 1: Write down necessary steps involved in simulating Modular Servo device driver, also
draw/paste SIMULINK model, simulation results of RTWT for angle, velocity and
potentiometer and comment on it.

SIMULINK MODEL :-

University of Engineering and Technology 2


Taxila, Pakistan
Name: Reg # Section/Group:

Simulation Results, Comments :-

Simulation Models
There are two simulation models available for the servo system. The first one is a linear model
and the second one is nonlinear. The linear model is used to design controllers. The nonlinear
model is used to check the quality of the designed control system.

Linear and Nonlinear Simulation Model – the simulation models of the servo are
located under these buttons. The external view of the simulation models is identical as
the model described in the Modular Servo Device Driver except the Reset Encoder input and
reference Potentiometer output which are not used in the simulation mode.

University of Engineering and Technology 3


Taxila, Pakistan
Name: Reg # Section/Group:

Task 2: Write down necessary steps involved in linear simulation model, also draw/paste
SIMULINK model, simulation results of angle & velocity and comment on it.

SIMULINK model, Simulation Results & Comments

University of Engineering and Technology 4


Taxila, Pakistan
Name: Reg # Section/Group:

Linear & Non-Linear Simulation Model masks


The vector of the initial conditions of the state variables of the simulation model is the parameter
available in the mask.

The model has no constrained control (as in the case of the real servo system). If you use the
linear simulation model in a closed-loop remember that control should satisfy u≤ 1. You can
include the Saturation block to limit the control.

In the case of the nonlinear simulation model two additional parameters appear. The gain of the

model and the vector which contains the static characteristics of the servo system.

Nonlinear Simulation Model mask

University of Engineering and Technology 5


Taxila, Pakistan
Name: Reg # Section/Group:

Identification
The consecutive buttons in the group Identification of the Servo Control Window perform the
following tasks:

Basic Measurements – contains a real-time Simulink model where a saw shape control signal is
given as the input of the servo system and four velocities are plotted in a scope:

 measurements reconstructed from encoder,



 measurement directly from tachogenerator,

 filtered tachogenerator voltage using low pass Butterworth filter,

 filtered tachogenerator voltage using simple first order filter.

The experiment allows to decide which kind of velocity measurements can be used in following
experiments.

Plot basic measurements push button - activates the plot_basic.m file to plot
measurements visible in the scope in the previous experiment.

Static Characteristics - performs experiment aimed to measure of the static characteristics of


the loaded DC motor (angular velocity [rad/s] vs. input voltage [dimensionless] in the steady
state). The characteristics can be measured for the servo system with or without magnetic brake
module. The measurements are stored in the ChStat.mat file.

Plot & Save Characteristics - uses plot_stat.m file which plots measured characteristics,
performs some normalizations of the data, and saves characteristics in servo_chstat.mat file.

Time Domain Identification – opens the real-time Simulink model which starts identification
based on a step system response.

The button Identify Model - takes advantage of identification data and calculates coefficients of
a linear model of the servo system. The surface method is applied by the identification
procedure.

Demo Controllers

University of Engineering and Technology 6


Taxila, Pakistan
Name: Reg # Section/Group:

The respective buttons in the column Demo Controllers perform the following tasks:

Position control

PID Control Continous - contains the Simulink model for real-time experiments in closed-loop
with PID position controller, and simulation model of the PID controlled servo system.

State Feedback Control - opens the Simulink model to start real-time experiments for closed-
loop system with state feedback. This model can be used for experiments with LQ or deadbeat
controllers. Also simulation model of the closed-loop system is included under this button.

All the Simulink models mentioned above are examples of position control problems.

Calculate LQ controller – uses Servo_calc_lq.m file to obtain state feedback controller


coefficients by solving the appropriate LQ problem. In the Servo_calc_lq.m file one can set
matrices of the objective function to obtain appropriate behavior of the system.

Velocity control

PID Controller - opens the Simulink model to start-real time experiments for the closed-loop
system with velocity PID controller.

University of Engineering and Technology 7


Taxila, Pakistan
Name: Reg # Section/Group:

Task 3: Write down necessary steps involved in non- linear simulation model, also draw/paste
SIMULINK model, simulation results of angle & velocity and comment on it.

SIMULINK model, Simulation Results & Comments

University of Engineering and Technology 8


Taxila, Pakistan
Name: Reg # Section/Group:

EXPERIMENT # 15
PID CONTROLLER DESGIN FOR VELOCITY CONTROL OF
DC MOTOR (USING MSS)

1. INTRODUCTION:

In the previous week of motor modeling lab, a mathematical model of a DC motor from first
principles was derived to obtain a first order system. The open and closed loop (proportional-
derivative) control was implemented specifically for this motor model in the previous lab for
speed control. In the previous lab, a physical DC motor was used for open-loop control
implementation and the first order transient characteristics were observed i.e. system
identification. Based on the model response, DC motor parameters (time constant) were
estimated both by hand-calculations as well as using MATLAB. You should have also observed
in the open loop control of actual DC motor that the motor positions start to drift over time
indicating continuous accumulation of error within the system. Another observation that should
have been made is that there is no way to enforce the output of the motor to track the input
voltage in the absence of any feedback loop. In this lab, you will try to address some of these
issues by realizing the benefits of closed-loop control of DC motor. In particular, you will:

a) Study transient characteristics of a typical second order system and evaluate model or
system responsesusing these specifications.
b) Extend the closed loop control implemented in the first week of this lab to the actual DC
motor.
c) Analyze the effects of proportional-, derivative- and integral- control individually and in
combinationon the closed loop response of motor.
d) Solve a position control problem by calculating PD controller gains analytically and validate
the controlby monitoring the motor response for different desired trajectories.
e) Design a PID controller for the actual DC motor using Ziegler-Nichols’ method and
compare theperformance with that of the PD controller.

2. DC MOTOR MODEL:

We derived the mathematical model of DC motor earlier and obtained the following
first order transfer function that relates the motor velocity (rad/s) to input voltage (V) as:

University of Engineering and Technology 1


Taxila, Pakistan
Name: Reg # Section/Group:

The open loop control of the DC servo motor is given in Figure below. You should
remember that simulation of these two forms of mathematical motor models were performed in
the previous lab of motor as wellas the experiments with actual DC motor in the last labs to
estimate model parameters. Next, let us studyabout transient response characteristics of typical
2nd order systems.

3. TRANSIENT CHARACTERISTICS OF SECOND ORDER SYSTEMS:

Systems that store energy cannot respond instantaneously, so they exhibit a transient
response when they are subjected to inputs or disturbances. Consequently, the transient response
characteristics constitute one of the most important factors in system design. In many practical
cases, the desired performance characteristics of control systems can be given in terms of
transient response specifications and step inputs are commonly used input for this purpose, since
such an input is easy to generate and is sufficiently drastic. Mathematically, if the response of a
linear system to a step input is known, by principle of superposition and linear theory
assumptions, it is possible to compute the system’s response to any input. However, the transient
response of a system to a unit step input depends on initial conditions. For convenience in
comparing the transient responses of various systems, it is thus a common practice to use
standard initial conditions: the system is initially considered to be at rest, with its output and all
time derivatives thereof zero to facilitate comparison of different transient responses (if you had
not realized this earlier). By ensuring these protocols, it will then be possible to compare
transient responses for different controller parameters and design our controllers for given
transient response specifications.

In general, transfer function of a 2nd order system with input, u(t) and output, y(t) can be
expressed as:

University of Engineering and Technology 2


Taxila, Pakistan
Name: Reg # Section/Group:

The response for such a system is given in Fig.2 marked with the transient response
specifications that are defined below and any or all of the following parameters can be used
to specify such responses completely:

a) Rise time (tr): Time required for a signal to change from a specified low value to a specified
high value. Typically, these values are 10% and 90% of the input step size.

b) Maximum Overshoot (Mp): It is measured as a ratio of value from the maximum peak of the
response curve measured to the desired response of the system and final steady state value.
Typically, it is1.

Note: When designing or analyzing a system, often it is useful to model the system
graphically. Block Diagrams are a useful and simple method for analyzing a system
graphically. The percentage overshoot (PO) is the maximum value minus the input step size
divided by the step size % of ratio of value.

c) Settling time (ts): Time elapsed from the application of an ideal instantaneous step input to
the time at which the output has entered and remained within a specified error band (typically
within 2 % or5% within the final value).

d) Delay time (td): Time required for the response to reach half the final value the very first
time.

e) Peak time (tp): Time required for the response to reach the first peak of the overshoot.

f) Steady-state error (ess): Difference between the desired final output and the actual
responsewhen the system reaches a steady state (yss), when its behavior may be expected to
continue if thesystem is undisturbed.

University of Engineering and Technology 3


Taxila, Pakistan
Name: Reg # Section/Group:

Given a 2nd order system response, these parameters can be manually estimated and
responses for different inputs can be compared. At the same time, by following rigorous
derivations, these parameters canbe expressed as a function of ωn and ζ and without delving into
full details, the final results are summarized in the table given belwo. We will discuss how you
can use MATLAB to trivially calculate these values later. So once we give the values of tr, ts, td,
tp and Mp, then the transient response from above can be completely specified. Nevertheless, in
most real applications, desired values of these parameters would be given and the objective will
be to design controllers that can meet the requirements. Some desirable characteristics in
addition of requiring a dynamic system to be stable, i.e., its response does not increase
unbounded with time (a condition that is satisfied for a second order system provided that ζ ≥ 0)
are the system should possess:
  Faster and “instantaneous” response
  
Minimal overshoot above the desired value (i.e., relatively stable) and

reach and remain close to the desired reference value in the minimum time
Ability to
possible.

We will use these parameters to analyze the DC motor system under different form of
controls and optimize the controller gains to achieve desired performance by end of this lab
session.

University of Engineering and Technology 4


Taxila, Pakistan
Name: Reg # Section/Group:

4. PID VELOCITY CONTROL:

The task of the velocity control is to keep the desired velocity in the presence of
disturbances. The disturbances can be introduced as a change of the velocity reference signal or
as a change of the motor load. To disturb the reference velocity the potentiometer can be used.
The load disturbances can be introduced by braking slightly the inertia load of the system. In the
example the load disturbances are introduced manually.

Click the Velocity control button in Servo Control Window and model shown in Figure
below opens.

University of Engineering and Technology 5


Taxila, Pakistan
Name: Reg # Section/Group:

Set the sine reference velocity, amplitude equal to 40 [rad/s] and frequency equal to 0.1
[Hz]. Simulation time set equal to 30 [s]. The Gain of the potentiometer set equal to zero. The
coefficients of the PID controller set to the following values: Kp = 0.15 and Ki = 0.03.Build the
model and run.

One can see that the disturbances of the motor load are introduced manually after five
seconds from the start and remain active in the period of 15 seconds. Note, that the control
increases in this time interval. The results are stored in the VelCtrl variable stored in the Matlab
workspace. The real time code.

Type at the Matlab prompt :

plot(VelCtrl.time,VelCtrl.signals(1).values(:,2),'r',VelCtrl.time,VelCtrl
.signals(1).values(:,1),'k');grid;xlabel('time [s]');title('Reference
velocity (red) - measured velocity (black)');

University of Engineering and Technology 6


Taxila, Pakistan
Name: Reg # Section/Group:

Tasks : Design a PID controller for speed control of Motor Using Modular Servo System GUI
and also attached the plots of simulation and write the values of Kp, Ki and Kd and comment
on it (about time domain specifications Rise Time, Settling Time, Overshoot, Steady State
Error).
Tasks 1:

kp= , ki= , kd=

Tasks 2:

kp= , ki= , kd=

Tasks 3:

kp= , ki= , kd=

University of Engineering and Technology 7


Taxila, Pakistan
Name: Reg # Section/Group:

Tasks 4:

kp= , ki= , kd=

Tasks 5:

kp= , ki= , kd=

Tasks 6:

kp= , ki= , kd=

University of Engineering and Technology 8


Taxila, Pakistan
Name: Reg # Section/Group:

Tasks 7:

kp= , ki= , kd=

Tasks 8:

kp= , ki= , kd=

Tasks 9:

kp= , ki= , kd=

University of Engineering and Technology 9


Taxila, Pakistan
Name: Reg # Section/Group:

Tasks 10:

kp= , ki= , kd=

Tasks 11:

kp= , ki= , kd=

Tasks 12:

kp= , ki= , kd=

University of Engineering and Technology 10


Taxila, Pakistan
Name: Reg # Section/Group:

Tasks 13:

kp= , ki= , kd=

Tasks 14:

kp= , ki= , kd=

Tasks 15:

kp= , ki= , kd=

University of Engineering and Technology 11


Taxila, Pakistan

You might also like