0% found this document useful (0 votes)
12 views21 pages

EDXC3103 Control System1

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

EDXC3103 Control System1

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

FACULTY OF SCIENCE AND TECHNOLOGY

Diploma in Electrical Engineering


Subject Control System
Code EDXC3103
Semester

A. Information on Students
Name of Student
Matric No
I/C No
Learning Centre (PPW/PPT)

General Guidelines:
1. Students must abide by the lab regulation accordingly.
2. Students should attend their laboratory sessions promptly and punctually.
3. Students will not be allowed to be in the lab alone and unsupervised.
4. Students must be properly attired at all times during the lab session.
5. Students are expected to keep the lab clean and tidy at all times.
6. Students must sign in and out when they come for the lab session.
7. Students must complete their labs work 10 minutes before the end of the session and
return all the material taken to the lab assistance.

Guidelines of Laboratory Report:


1. After completing each experiment, results must be verified by the lab demonstrator.
(In the result sheet).
2. Report submission.

1
B. Laboratory Session
Date
Venue
Time
Name of Demonstrator

C. Detail of Experiments
EXPERIMENT 1 Matlab Fundamentals
EXPERIMENT 2 Basic Graphics of Matlab
EXPERIMENT 3 Setting Up Control Problem
EXPERIMENT 4 Poles, Zeros and Time Response

2
Experiment 1 Matlab Fundamentals

1.1 Introduction

Matlab, an abbreviation of Matrix laboratory, was founded in 1984, Boston, USA. Major industries
involve in designing using Matlab including automotive, digital signal processing, aerospace, finance
and economic, automotive control and education.
Matlab is the engineering based computer software used to solve engineering problem in the matrix-
based system. Matlab are frequently used in analyzing and design control system. Matlab have many
predefined function and command that can be call by user to solve many types of control problem.
The Matlab family product consist of toolboxes, compiler, simulink, blocksets, stateflow and coder.
Toolboxes such as control system toolbox is used extensively for control system design, and being
compliment by the simulink.

1.2 Getting started

Matlab can be started by double clicking on the Matlab icon. To change the default view, go to
VIEW, DESKTOP LAYOUT and choose any view the user preferred or depend on the application
need. User can quit the Matlab by typing exit or quit. To clear the command window, type clc. To
clear the function or command used, type clear. If user need help to search for more pre-defined
command, then type help. If the command name is known, then type help “command name”.

1.3 Fundamental Expression

To learn the simple Matlab command, let us hand on, try the following simple examples:

Example 1

Learning the format long and format short commands.

>> a = 4/3 % 4 divide by 3


>> a =1.3333 % 4 decimal point by default

>> format long % format long the decimal point

>> a = 4/3
>> a = 1.33333333333333

>> format short % back to default


>> a = 4/3
>> a = 1.3333

3
Example 2

>> pi % pi mean for 


>> ans =
3.1416
>> inf % inf mean for infinity
>> ans =
Inf
>> nan % NaN mean for Not a number
>> ans =
NaN
>> x =1:6 % ‘:’means the increment of 1 by default
>> x=
1 2 3 4 5 6

>> x=1:2:6 % the increments is set to 2


>> x=1 3 5

Example 3

Trying simple mathematic symbol.

>> a = 2+4; % 2 plus 4


>> a=6
>> b = 3;
>> a+b
>> ans = 9
>> a-b
>> ans = 3
>> a*b % a multiply b
>> ans = 18

Example 4

Let us try some example on the matrices

>> a = [1 2;3 4] % matrix of order 2X2


>> a=
1 2
3 4

>> b = [2 3;4 5];


>> a+b
>> ans =
3 5
7 9
>> a*b
>> ans =
10 13
22 29

>> size(a) % checking the order of the matrix


>> ans = 2 2 % 2 rows and 2 columns

4
>> c = [1 2 3;4 5 6;7 8 9]

>> c=
1 2 3
4 5 6
7 8 9

>> size(c)
>> ans = 3 3
>> a' % ' means transpose
>> ans =
1 3
2 4

>> c'
>> ans =
1 4 7
2 5 8
3 6 9

>> k=diag([1 2]) % creating diagonal matrix

>> k=
1 0
0 2

Example 5

Let say the polynomial equation p = s2 + 5 s + 6. To factorise the equation, roots command is used.

>> p = [1 5 6];
>> roots(p) % factorise the equation
>> ans =
-3.0000
-2.0000

>> p = poly([-2 -3]) % to obtain polynomial equation from roots

>> p=
1 5 6

Solving the product of 2 or more factors

ie (s+2)(s+3)

>> conv([1 2],[1 3])


>> ans =

1 5 6

5
Example 6

Introducing the i and j operator.

>> i
>> ans = 0 + 1.0000i

>> j
>> ans = 0 + 1.0000i % Both i and j can be used

Example 7

Trigonometry calculation is being considered in this example.

Find sin, cos and tan for 30 degree

>> x = 30*pi/180; % change to radian


>> sin(x)
>> ans =
0.5000
>> cos(x)
>> ans =
0.8660
>> tan(x)
>> ans =
0.5774

Example 8

Solving the equation with unknown variable.

-x1 +x2 +2x3 = 2


3x1 – x2 + x3 = 6
-x1 + 3x2 + 4x3= 4

>> a = [-1 1 2;3 -1 1;-1 3 4];


>> b = [2;6;4];
>> x = inv(a)*b % inverse matrix a

>> x=
1.0000
-1.0000
2.0000

6
Exercise 1

Question 1

Find y using Matlab command.

3 (4) + 42 - 6
a) y = 
6½+

(4 X 7 + 8)2
b) y = 
 7 + 3 1/4

Question 2

-5 1 0 0
Consider A = 0 -2 1 , b= 0 , c= -1 1 0
0 0 1 1

a) If Ax=B, find x.

b) yA= C, find y.

c) The characteristic equation is given as G(s)=c(sI-A)-1.

Question 3

Given the open-loop transfer function is given as below:

1
a) G1(s) = 
s2 + 4s + 1

20(s+1)
b) G2(s) = 
s2+8s+3

Find the magnitude and phase angle.

Experiment 2 Basic Graphics of Matlab

7
2.1 Introduction
Human are very good at extracting information from the pictures. Matlab provides the plotting
command to help you take advantages of this ability to process data.

2.2 2-D plotting

To plot a single line, use the following command:

plot(x1, y1, ‘clm’)

For plotting of multiple lines:

plot(x1, y1,’clm1’, x2, y2,’clm2’,…..)

The plot function is used to produce 2- dimensional curves using x and y data. Besides, the plot
command allows character-string argument that designate various colour and lines styles for the
resulting lines.

Example 1

Try this simple example:

>> x = -5:5; % set range for x axis, from –5 to 5.


>> y = x.^2; % the curve is x power 2
>> plot(x,y,’r:s’) % plotting the curve and red colour

Figure Example 1
Example 2

Plotting the sine wave:

>> x=0:0.1:2*pi; % setting range for 2 with increment of 0.1


>> y = sin(x); % writing the formula
>> plot(x,y) % plot the sine wave

8
>> grid on % creates grid on the graph
>> grid off % turn off the grid from the current figures.

To add additional figures, use hold on, then the current plot will be hold. Try the following:

>> x = 0:0.1:2*pi;
>> y = sin(x);
>> plot(x,y)
>> grid on
>> hold on
>> plot (x, exp(-x),’r:*’)

Figure Example 2 with single plot

Figure Example 2 with exponential waveform.

To add title or label the graph, use the following command:

title - to add title to the graph


xlabel - to label the x-axis
ylabel - to label the y-axis

However, all this can be done without writing these commands. It can be done using the features
provided by the Matlab figure, go to Insert and many features are available. Try them out.

2.3 Subplots

9
You can display multiples plots in the same window with the subplot command. The advantage of
subplot is to plot a few graphs on the same page for the ease of comparison. Command subplot(m,n,p)
is used where m and n determine how many figure can accommodate into the same page. The m by n
determine the number of figure for row and column.

Example 3

This example demonstrates how to use subplot.

>> subplot(2,2,1);
>> plot(1:10);
>> subplot(2,2,2);
>> x=0:0.1:2*pi;
>> plot(x,sin(x))
>> subplot(2,2,3)
>> plot(x,exp(-x),’r’)
>> subplot(2,2,4)
>> plot(peaks)

Figure Example 3

Exercise 2

1 Plot the following:

a) y = cos2(x) where 0 < x < 2. Label both x and y axis as well as title to the graph.

b) Plot y = (x+1)2 + 3 on the same window.

2 Plot the following functions in the same graph using different style option, where t =
linspace(0,2*pi,100).

a) x=tcos(t), plot(t,x)
b) x=cos(t), plot(t,x)
c) x=sin(t), plot)t,x)

10
Label both axes and give a title to the graph. Also indicate each graph by using the command
gtext

Experiment 3 Setting Up Control Problem

3.1 Introduction

11
An understanding of connection among the different linear system is essential to the design of single
input and single output control system. In this chapter, participant will learn how to create the transfer
function, convert transfer function to state space and vice-versa and solving the transfer function of
the block diagram using various build in command.

Command to be learn in this experiment are:

1. tf2ss
2. ss2tf
3. series
4. parallel
5. feedback

3.2 Creating the Transfer Function

Consider

Y 15(S + 20)
 = G(s) =  (1)
U (S +15)(S+25)(S+0.4)

where it is closed loop transfer function. To display this using Matlab command, try this:

>> num=15*[1 20]; % num=numerator


>> den=conv(conv([1 15],[1 25]),[1 0.4]); % den = denominator
>> printsys(num,den) % display the result.

The Matlab display the closed loop transfer function of equation (1).

3.3 Creating the State- Space Model

Consider the following matrix:

1 2 1
a = 3 4 b= 0 c= 1 18

To display all matrixes above in the state space, try the following:

>> a = [1 2; 3 4];
>> b = [1 ; 0];
>> c = [1 18];
>> d = 0;
>> printsys(a,b,c,d)

3.4 Transfer function and State Space conversion

Both transfer function and state-space can be converted using build in command tf2ss and ss2tf. Try
the following example:

12
Example 3.1

To convert transfer function to state-space modeling.

Consider the transfer function given by

Y s+1
 = 
U s3+4s2+7s+6

>> num=[1 2];


>> den=[1 4 7 6];
>> [A,B,C,D]= tf2ss(num,den) % convert transfer function to state space
>> printsys(A,B,C,D)

Example 3.2

Consider the same matrix given in section 3.3 and D = 0, try the following to convert the
matrix to transfer function.

>> A = [1 2; 3 4];
>> B = [1;0];
>> C = [1 18];
>> D = 0;
>> (num,den)=ss2tf(A,B,C,D);
>> printsys(A,B,C,D)

3.5 Solving the transfer function of the block diagram

Previous discussion was based on the single transfer function and state space model. Practically,
engineer encounter more complicated system with many block, feedback and closed loop. Commands
used are parallel, feedback and series.

13
Example 3.3
Using parallel command to determine the transfer function of the parallel connection of systems

1

s+3
+
U(s) Y(s)
+
s+4

s+10

>> num1 = 1;
>> den1 = [1 3];
>> num2 = [1 4];
>> den2 = [1 10];
>> [num,den] = parallel(num1,den1,num2,den2);
>> printsys(num,den)

Matlab will display the transfer function as

s^2 + 8s + 22
Num/Den = 
s^2 + 13s + 30

Example 3.4

Using feedback command to solve the non-unity feedback control system

R(s) G(s) Y(s)


s+2

+ _ (s+3)(s+5)

s+6

s+12 H(s)

>> numg=[1 2];


>> deng=conv([1 3],[1 5]);
>> numg=[1 6];
>> deng=[1 12];
>> [x,y]=feedback(numg,deng,numh,denh)

Matlab display the result as

s^2 + 14s + 24

s^3 + 21s^2 + 119s + 192

14
Negative feedback is assumed and the resulting system maps R(s) to Y(s). To apply positive
feedback, use the following syntax

sys = feedback(sys1,sys2,+1)

The ‘+1’ represent positive feedback

Example 3

Using series and cloop command for block diagram with series and unity feedback system.

R(s) s+8 s+1 Y(s)


 
s +10 (s+4)(s+5)

H(s) G(s)

>> numg = [1 1];


>> deng = conv([1 4],[1 5]);
>> numh = [1 8];
>> denh = [1 10];
>> [x,y] = series(numg,deng,numh,denh)
>> [m,n] = cloop(x,y); % unity feedback
>> printsys(m,n)

Matlab will display the result as

s^2 + 9 s + 8

s^3 + 20 s^2 + 119 s + 208

15
Exercise 3

Question 1

Convert the following differentiation equation into transfer function and state space representation
using tf2ss and ss2tf. Y(s) is the output and U(s) is the input of the system

a) s2Y+4sY+5Y = 5U

b) s3Y+5s2Y+6sY+4Y = 8U

c) s3Y+4s2Y+8sY+9Y=(s+1)U

Question 2

For the following block diagram, find the transfer function of the system using Matlab command.

G2

U(s) + + + Y(s)
G1

H1

16
Experiment 4 Poles, Zeros and Time Response

4.1 Introduction
This chapter emphasizes the use of MATLAB tools for studying the relationship between the
poles and zeros of a linear time-invariant system. Since most of the control system can be
analysed using the test signal of unit step, we will focus on the step response and also impulse
response.

4.2 Poles and Zeroes


Determine the poles and zeros of a given transfer function G (s) by hand can be troublesome and
time-consuming. Matlab can be used with the command provided, tf2zp to obtain the poles and zeros
quickly.

Example 4.1
The transfer function of the open loop control system of 5th order is given below:

3s4+2s3+8s2+4s+6
G(s) = 
s5 +3s4+4s3+2s2+7s+6

The poles and zeros of the system can be found typing the following line.

>> num = [3 2 8 4 6 ]; % create numerator polynomial


>> den = [1 3 4 2 7 6 ]; % create denominator polynomial
>> [z,p,k] = tf2zp ( num, den ) % find and display poles & zeros

where z is ZERO, p is POLE and k is GAIN.


MATLAB is also able to compute the poles and zeros from a state-space model. The
command ss2zp is used. Try the following example with matrix A, B and C given.

Example 4.2
Control system with state space model is presented with matrix A, B and C.
>> A=[1 3; 4 6];
>> B=[1;0];
>> C=[1 0];
>> [z,p,k]=ss2zp(A,B,C,0)

>> z=6
p = -0.7720
7.7720
k=1

4.3 Poles and Zeros Plotting

17
To see these zeros and poles of the control system on a plot of the complex plane, then use
the command pzmap(p,z).

Example 4.3
Repeat Example 1 and Example 2 with additional line of pzmap(p,z)

Example 4.1 Solution Example 4.2 Solution

4.4 Convert Poles and Zeros to Transfer Function


Command zp2tf is used to convert poles and zeros to transfer function. Try the following example.

Example 4.4

>> z = [ 0; 0; 0; -1 ] ;
>> p = [ -1 +i 1-i -2 -3.15 + 2.63*i -3.15 + 2.63*i ];
>> k = 2;
>> [num,den]=zp2tf (z,p,k);
>> printsys (num, den)

2s^4 + 2s^3
num / den = 
s^5 + 10.3s^4 + 48.04s^3 + 109.2s^2 + 126.2s + 67.36

It is also possible to use MATLAB to convert a list of poles, zeros and gain to a state – space
description. This is accomplished by means of the command zp2ss.

Example 4.5

18
For a system with one zero at –1 and three poles at –2, -1+ j and –1-j and a dc gain of 2, try the
following to convert the zero and poles to state space model.

>> [a, b, c, d]=zp2ss([-1], [-2 -1+i -1 –i] 2 )


>> a=
-2.0000 0 0
-1.0000 -2.0000 -1.4142
0 1.4142 0
>> b= 1
1
0
>> c= 0 0 1.4142
>> d= 0

4.5 Plotting Response Curve using Poles and Zeros


Another feature provided by the Matlab is to create graph from the poles and zeros using the
command like step, impulse and initial.

Example 4.6
Let say the open loop transfer function of the system have no zero, poles at –1 and –4 and a
gain of 5. Then try the following
>> [num,den]=zp2tf ([ ] , [ -1+4*j - 1-4*j] ,5 ); % zeros and poles convert to tf
>> step(num,den) % unit step response

Figure Example 4.6

Exercise 4

Question 1

19
Simulate and plot the impulse and step response of the state space model given below:

-7 -30 -40 1
A= 1 0 0 B= 0 C = [2 11 5] D = [0]
0 1 0 0

Question 2

Find the poles of the transfer function

1.5s +1
G(s) = 
s3+2s2+2.5s+0.5

Determine the stability of the system. Plot the poles and zeros of G(s) in the s-plane. Hence,
demonstrate system stability by simulating the impulse response.

Question 3

Consider the unity feedback system with transfer function given as


1
G(s) = 
(s+0.01)(s+1)(s+15)

Simulate the output response due to unit step input signal. Use tstats to find Mp, tp, tr and ess.
Find the damping ratio and the undamped natural frequency of the closed system poles.

References:

1. Modern Control Engineering, 3rd Edition, Prentice Hall by Ogata

2. Modern Control Systems, 9th Edition, Prentice Hall by R C Dorf and R H Bishop

20
3. Using Matlab To Analyse and Design Control Systems, 2 nd Edition, Addison
Wesley by N E Leonard and W S Levine

4. Feedback Control Problems Using Matlab and the Control System Toolbox, 1 st
Edition, Brooks/Cole, Thomson Learning by D K Frederick and J H Chow.

5. Control System Toolbox, For Use with Matlab, Getting Started Version 5,MATH
WORKS Inc

21

You might also like