0% found this document useful (0 votes)
21 views8 pages

Lab#1,2 LCS

The document outlines a MATLAB/SIMULINK lab for analyzing linear control systems, detailing tasks and examples for modeling and simulating various systems. It includes instructions for defining transfer functions, interconnecting models, and performing stability analysis. Key concepts such as impulse and step responses, as well as commands for system analysis, are also discussed.

Uploaded by

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

Lab#1,2 LCS

The document outlines a MATLAB/SIMULINK lab for analyzing linear control systems, detailing tasks and examples for modeling and simulating various systems. It includes instructions for defining transfer functions, interconnecting models, and performing stability analysis. Key concepts such as impulse and step responses, as well as commands for system analysis, are also discussed.

Uploaded by

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

DEE, CEME, NUST EE-371 Linear Control Systems

Lab 1,2: Modeling in MATLAB/SIMULINK

Conducted on: Submitted on:

Instructor:

Lab Engineer:

Group Members

1)
2)
3)

Aim
Analysis of linear systems in Matlab

Theory
Chapter 1 and chapter 2 of Feedback Control Systems by Stefani

Equipment
PC with MATLAB installed

1
DEE, CEME, NUST EE-371 Linear Control Systems

Explanation

System Definition In Matlab


1) sys = tf(num, den) creates a continuous-time transfer function with numerator(s) and
denominator(s) specified by num and den. The output sys is A tf model object, when num and
den are numeric arrays
>> r=tf([1 0 1],[1 2 1])
r=
s^2 + 1
-------------
s^2 + 2 s + 1
Continuous-time transfer function.
2) To use a rational expression to create a SISO TF model, type
s = tf('s');

H = s/(s^2 + 2*s +10);

This produces the same transfer function as

h = tf([1 0],[1 2 10]);

3) sys = zpk(z,p,k) creates a continuous-time zero-pole-gain model with zeros z, poles p, and
gain(s) k. The output sys is a zpk model object storing the model data. In the SISO case, z and p
are the vectors of real- or complex-valued zeros and poles, and k is the real- or complex-valued
scalar gain:
tr=zpk([1 3],[1 2 4],1)
tr =
(s-1) (s-3)
-----------------
(s-1) (s-2) (s-4)
Continuous-time zero/pole/gain model.
4) Tf commands also converts zpk form of system to tf form same holds for zpk command
5) In Simulink a block labelled “LTI System” is available in control system toolbox. Write above
commands (tf, zpk) in input space of block to define a linear system.

Task 1
Use all of above mentioned commands to define a fifth order system.

Model Interconnections
Interconnecting models of components allows you to construct models of control
systems. You can conceptualize your control system as a block diagram containing multiple
interconnected components, such as a plant or a controller. Using model arithmetic or
interconnection commands, you combine models of each of these components into a single model
representing the entire block diagram.

2
DEE, CEME, NUST EE-371 Linear Control Systems

For example, you can interconnect dynamic system models of a plant G(s), a controller C(s), sensor
dynamics S(s), and a pre filter F(s) to construct a single model that represents the entire closed-loop
control system in the following illustration:

Catalogue of Model Interconnections


Each type of block diagram connection corresponds to a model interconnection command or
arithmetic expression. The following table summarizes the block diagram connections with the
corresponding interconnection command and arithmetic expression

The connect command lets you connect systems in any configuration given in above figure. To use
connect, specify the input and output channel names of the components of the block diagram.
Connect automatically joins ports that have the same name, as shown in the following figure

3
DEE, CEME, NUST EE-371 Linear Control Systems

Example 1
We will define above system in Matlab

1) We assume following values for these models

G = zpk( [ ] , [ - 1 , - 1 ] , 1 ) ;
C = pid( 2 , 1 . 3 , 0 . 3 , 0 . 5 ) ;
S = tf( 5 , [ 1 4 ] ) ;
F = tf( 1 , [ 1 1 ] ) ;

The plant G is a zero-pole-gain (zpk) model with a double pole at s =–1. Model object C is a PID
controller. The models F and S are transfer functions

2) Connect the controller and plant models.


H = G*C;
To combine models using the multiplication operator *, enter the models in reverse order
compared to the block diagram. Alternatively, construct H(s) using the series command.
H = series(C,G);
3) Construct the unfiltered closed-loop response T s   H/(1  HS) .
Do not use model arithmetic to construct T algebraically:
T = H/(1+H*S)

4
DEE, CEME, NUST EE-371 Linear Control Systems

This computation duplicates the poles of H, which inflates the model order and might lead to
computational inaccuracy
4) Construct the entire closed-loop system response from r to y.
T_ry = T*F;
T_ry is a Numeric LTI Model representing the aggregate closed-loop system. T_ry does not keep
track of the coefficients of the components G, C, F, and S. You can operate on T_ry with any
Control System Toolbox control design or analysis commands

Example 2

Input = ysp , Output = y

1) Create the components of the block diagram: the process model P, the predictor model Gp, the
delay model Dp, the filter F, and the PI controller C. Specify names for the input and output
channels of each model so that connect can automatically join them to build the block diagram.

s=tf('s');
P = e x p ( - 93.9*s )*5.6 / ( 40.2*s + 1 ) ;
P.InputName = 'u' ; P.OutputName = ' y ' ;
Gp = 5.6/ ( 40.2*s + 1 ) ;
Gp.InputName = ' u ' ; Gp.OutputName = ' yp ' ;
Dp = exp ( - 9 3.9*s ) ;
Dp.InputName = ' yp ' ; Dp.OutputName = ' y1 ' ;
F = 1 / ( 2 0 *s + 1 ) ;
F.InputName = ' dy' ; F.OutputName = ' dp ' ;
C = pidstd ( 0.574 , 40.1 ) ;
C.InputName = ' e ' ; C.InputName = ' u ' ;
2) Create the summing junctions needed to complete the block diagram
sum1 = sumblk( ' e = ysp - ym ' ) ;
sum2 = sumblk( ' ym = yp + dp ' ) ;
sum3 = sumblk( ' dy = y - y1 ' ) ;

The argument to sumblk is a formula specified as a string. This string relates the input and
output signals of the summing junction. Sumblk creates a summing junction with the input and
output signal names specified in the formula. For example, in sum1, the string 'e = ysp - ym'

5
DEE, CEME, NUST EE-371 Linear Control Systems

specifies an output signal named e, which is the difference between input signals named ysp
and ym

3) Assemble the complete model from ysp to y.

T = connect(P,Gp,Dp,C,F,sum1,sum2,sum3,'ysp','y');

You can list the models and summing junctions in any order because connect automatically
interconnects them using their input and output channel names.

Task 2
Define following system given in MATLAB

1) example 1
2) example 2
3) DC Motor Position
4) Ball and Beam

DC Motor Model
J = 3.2284E-6;

b = 3.5077E-6;

K = 0.0274;

R = 4;

L = 2.75E-6;

s = tf('s');

P_motor = K/(s*((J*s+b)*(L*s+R)+K^2))

Impulse Response
Impulse (sys) plots the impulse response of the dynamic system model sys. This model can
be continuous or discrete, and SISO or MIMO. The impulse response of multi-input systems is the
collection of impulse responses for each input channel. Impulse (sys, Tfinal) simulates the impulse
response from t = 0 to the final time t = Tfinal.

Step Response
Step (sys) plots the step response of an arbitrary dynamic system model sys. This model can
be continuous or discrete, and SISO or MIMO. The step response of multi-input systems is the
collection of step responses for each input channel. In Simulink step block is available

S = stepinfo (y,t,yfinal) takes step response data (t,y) and a steady-state value yfinal and
returns a structure S containing the following performance indicators:

RiseTime — Rise time

SettlingTime — settling time

Overshoot — Percentage overshoot (relative to yfinal)

6
DEE, CEME, NUST EE-371 Linear Control Systems

Undershoot — Percentage undershoot

Peak — Peak absolute value of y

PeakTime — Time at which this peak is reached

System Response for Arbitrary Inbut


lsim simulates the (time) response of continuous or discrete linear systems to arbitrary inputs.
When invoked without left-hand arguments, lsim plots the response on the screen.

lsim(sys,u,t) produces a plot of the time response of the dynamic system model sys to the input
time history t,u. The vector t specifies the time samples for the simulation (in system time units,
specified in the TimeUnit property of sys), and consists of regularly spaced time samples.

The matrix u must have as many rows as time samples (length(t)) and as many columns as system
inputs. Each row u(i,:) specifies the input value(s) at the time sample t(i).

S = lsiminfo( y,t,yfinal) takes the response data (t,y) and a steady-state value yfinal and returns a
structure S containing the following performance indicators:

SettlingTime — settling time

Min — Minimum value of Y

MinTime — Time at which the min value is reached

Max — Maximum value of Y

MaxTime — Time at which the max value is reached

All of the above responses can be viewed in LTI VIEW TOOL

Task 3
View step response impulse response, step response characteristics m impulse response, impulse
response characteristics of systems given in task2

Repeat task 3 using LTIVIEW TOOL

Stability Analysis
1) Pole (sys) computes the poles p of the SISO or MIMO dynamic system model sys.
2) z = zero(sys) returns the zeros of the single-input, single-output (SISO) dynamic system model sys
3) [Wn, zeta] = damp(sys) returns the natural frequencies, Wn , and damping ratios, zeta, of the poles
of sys.(check this command for higher order systems)
4) h = pzplot(sys) computes the poles and (transmission) zeros of the dynamic system model sys and
plots them in the complex plane. The poles are plotted as x's and the zeros are plotted as o's. It also
returns the plot handle h. You can use this handle to customize the plot with the “getoptions” and
“setoptions” commands. Type “help pzoptions “for a list of available plot options.
5) p = poly(A) where A is an n-by-n matrix returns an n+1 element row vector whose elements are the
coefficients of the characteristic polynomial, det(λI – A). The coefficients are ordered in descending
powers: if a vector c has n+1 components, the polynomial it represents is c1λn + c2λn-1 + … + cn λ + cn+1

7
DEE, CEME, NUST EE-371 Linear Control Systems

p = poly(r) where r is a vector returns a row vector whose elements are the coefficients of the
polynomial whose roots are the elements of r.
6) r = roots(c) returns a column vector whose elements are the roots of the polynomial c. Row vector
c contains the coefficients of a polynomial, ordered in descending powers. If c has n+1 components,
the polynomial it represents is c1sn + … + cns + cn + 1.
7) pzmap(sys) creates a pole-zero plot of the continuous- or discrete-time dynamic system model sys.
For SISO systems, pzmap plots the transfer function poles and zeros. For MIMO systems, it plots the
system poles and transmission zeros. The poles are plotted as x's and the zeros are plotted as o's.

Task 4
Do stability analysis of systems given in task2.

You might also like