Control System I

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Scientific Programming in Matlab

Version 1.0 Control System Toolbox I Page 1

The Control System Toolbox provides algorithms and tools for the systematic analysis,
design and tuning of linear control systems. It accepts models in time and frequency
domain for linear time invariant systems in terms of

• transfer functions
• state-space models
• pole-zero-gain models,
• frequency-response models

There are interactive tools and command-line functions for the visualization in both ti-
me and frequency domains. You can tune compensator parameters using automatic PID
controller tuning, Bode loop shaping, root locus method, LQR/LQG design, and other
interactive and automated techniques. You can validate your design by verifying rise time,
overshoot, settling time, gain and phase margins, and other requirements.
It is assumed that you have a profound background in system theory, in particular know-
ledge about representations of linear time invariant systems, feedback control design and
analysis in the time and frequency domain. This background knowledge is provided in the
course control theory of the degree program.
Representations of LTI systems
Theory of linear systems is a branch of applied mathematics and provides the mathema-
tical foundation for engineering applications such as signal processing and control system
design. It investigates the response of a linear and time-invariant system to an arbitrary
input signal. Examples of LTI systems are electrical circuits composed of resistors, capa-
citors, and inductors or mechanical systems composed of inertia/mass, damping (friction)
and springs.
The superposition principle (linearity property) postulates that the relationship between
the input and the output of the system is a linear map. If input x1 (t), generates the
response y1 (t), and input x2 (t) generates y2 (t) then the scaled and summed input a1 x1 (t)+
a2 x2 (t), exhibits the scaled and summed response a1 y1 (t) + a2 y2 (t).
Time invariance refers to the fact that an input applied to the system at T = 0 or at a
later instance T = ∆T produces the identical response merely delayed by ∆T . That is, if
the response due to input x(t) is y(t), then the response due to input x(t − T ) is y(t − T ).
In other words the output does not depend on the particular time the input is applied.
Any LTI system is characterized completely by the systems impulse response h(t). The
output of the system y(t) for an arbitrary input x(t) is obtained by the convolution of the
input signal with the systems impulse response.
Z ∞
y(t) = x(t) ∗ h(t) = x(t − τ )h(τ )dτ (1)
−∞
Scientific Programming in Matlab
Version 1.0 Control System Toolbox I Page 2

where h(t) is the system’s response to an impulse signal x(t) = δ(t). The response y(t)
is obtained as a weighted average of the input function x(t) with the weighting function
h(−τ ) shifted by the time t. As t changes, the weighting function responds to different
parts of the input function.

This type of analysis is denoted as the time domain point-of-view. An LTI system can be
analyzed in the frequency domain in terms of its transfer function, which is the Laplace
transform of the systems impulse response. The output of the system in the frequency
domain is given by the product of the transfer function and the transform of the input.
In other words, convolution in the time domain is equivalent to multiplication in the
frequency domain.

State-space models

A state-space representation models a dynamic system as a set of input, output and state
variables related by first-order differential equations. The term state space refers to the
space spanned by the state variables xi , merged into a state vector x = [x1 , . . . , xn ]. If
the continuous dynamical system is linear, time-invariant, and finite-dimensional, then
the differential and algebraic equations that form the state-space model may be written
in matrix form:

ẋ = Ax + Bu (2)
y = Cx + Du (3)

where the state matrix A, the input matrix B, the output matrix C, and the feed-
through D are matrices of appropriate dimensions, x is the state vector, and u and y are
the input and output vectors. The Figure 1 shows the block diagram representation of
the underlying linear state space differential and algebraic equations.

Figure 1: State-space model : http://commons.wikimedia.org/wiki/File:Typical_


State_Space_model.png
Scientific Programming in Matlab
Version 1.0 Control System Toolbox I Page 3

In case of SISO (single input, single output) systems the state-space model becomes

ẋ = Ax + bu (4)
y = c′ x + du (5)

where A is the n × n-system matrix, b and c are n × 1 input and output vectors and d
is a scalar. The remainder of this tutorial only considers SISO systems.

These Matlab commands support the design and analysis of LTI systems:

• ss: creates a state-space model, or converts other dynamic system models to state-
space models:
sys = ss(a,b,c,d)

where a,b,c,d are the system, input, output and the feed-through scalars respec-
tively. sys is an object of class @ss.

• step: generates the step response of a dynamic system. For the state space case,
zero initial state is assumed. When step is invoked with no output arguments, step
plots the step response.

• lsim: simulates the (time) response of continuous or discrete linear systems to arbi-
trary inputs. When invoked without left-hand arguments, lsim plots the response.
lsim(sys,u,t)

produces a plot of the time response of the dynamic system model sys to the input
time history u. The vector t specifies the N time samples for the simulation. The
vector u is N xM , where M is the number of system inputs.
lsim(sys,u,t,x0)

further specifies an initial condition x0 for the system states.

• gensig: generates customized input signals for the system. It supports the signal
forms sine wave (’sin’), square wave (’square’) and periodic pulse (’pulse’).
[u,t]=gensig(type,tau,Tf,Ts)

generates a scalar signal u of class type and with period tau (in seconds). Tf denotes
the time duration of the signal and Ts is the spacing between consecutive time
samples t.

• linearSystemAnalyzer: The interactive user interface for analyzing the time and
frequency responses of linear systems and comparing such systems is called with the
command:
linearSystemAnalyzer(sys)
Scientific Programming in Matlab
Version 1.0 Control System Toolbox I Page 4

The app linearSystemAnalyzer replaces the GUI ltiview in older versions of


Matlab. The linearSystemAnalyzer facilitates the analysis of time and frequency
responses of LTI systems and supports the following functionalities.

– View and compare the response plots of SISO and MIMO systems, or of several
linear models at the same time.
– Generate time response plots such as step, impulse, and time response to ar-
bitrary inputs (see Figure 2). The step response of a system in a given initial
state consists of the time evolution of its outputs when its control inputs are
Heaviside (unit) step functions. In control theory, step response is the time
behavior of the outputs of a general system when its inputs change from zero
to one in a very short time.
– Generate frequency response plots such as Bode, Nyquist, Nichols, singular-
value, and pole-zero plots (see Figure 2).
– Inspect key response characteristics, such as rise time, maximum overshoot,
and stability margins.

1) mandatory: Generate a state-space model for a first order linear system. A P T1


element is a proportional transfer element with a first order delay described by the
differential equation.

T ẋ + x = Ku (6)

characterized by the static gain K and the delay time constant T . Transform the
above equation into state space form

ẋ = ax + bu (7)
y = cx + d (8)

in that you compute the state-space model with scalars a, b, c and d in 8 in terms
of the original parameters K and T from:

ẋ = −1/T x + K/T u (9)


y = x (10)

a b c d

Generate the corresponding LTI system syspt1 with ss for the specific parameters
K = 1 and T = 2.

2) mandatory: Invoke the linearSystemAnalyzer to analyze the LTI system syspt1


and plot its step response, impulse response and bode diagram.
Scientific Programming in Matlab
Version 1.0 Control System Toolbox I Page 5

Figure 2: Linear system analyzer: step response and Bode diagram of two LTI systems

3) mandatory:
Plot the step response of syspt1 from the command line with step.

4) mandatory: Generate an LTI system syspt2 for the second order state-space model
defined by
!
−1 −2
A = (11)
1 −1
!
1
b = (12)
0
c = (0 1) (13)
d = 0 (14)

5) mandatory: Stability and natural response characteristics of a continuous-time LTI


system can be analyzed from the eigenvalues of the matrix A. The characteristic
Scientific Programming in Matlab
Version 1.0 Control System Toolbox I Page 6

polynomial is obtained from the determinant of the matrix sI −A. The poles coincide
with the eigenvalues of the matrix A and their location in the left or right half
complex plane determines whether the system is either unstable, asymptotically
stable or marginally stable.
Compute the eigenvalues si of the system matrix A with the command eig.
s1 s2

What can you infer about the stability of the system?

6) mandatory: Plot the step response of the second order LTI system syspt2.

7) mandatory: Generate the following input signals u(t) over the interval t ∈ [0, 10]
with a sample rate ∆t = 0.1 as vectors

• u1 (t) = 0 (eigen motion)


• u2 (t) = sin(t)

8) mandatory: Plot the system response for the LTI system syspt2 over the interval
t ∈ [0, 10] for the following initial states and previously generated input signals.
!
1
• x01 = , u1 (t) = 0 (eigen motion)
0
!
0
• x02 = , u2 (t) = sin(t)
0
Scientific Programming in Matlab
Version 1.0 Control System Toolbox I Page 7

Transfer Functions and Zero-Pole-Gain Models

A transfer function represents the relation between the input and output of a linear time-
invariant system with zero initial conditions and zero-point equilibrium. For continuous-
time input signals x(t) and output y(t), the transfer function H(s) is the linear mapping
of the Laplace transform of the input, X(s) = L{x(t)}, to the Laplace transform of the
output Y (s) = L{y(t)}:

Y (s) = H(s)X(s) (15)

or
Y (s) L{y(t)}
H(s) = = (16)
X(s) L{x(t)}

where the Laplace transform of x(t) is


Z +∞
X(s) = L{x(t)} = x(t)e−st dt (17)
−∞

A transfer function is defined by the numerator and denominator polynomial, where the
roots of the numerator correspond to the zeros of the LTI system and the roots of the
denominator to its poles.

Example of a second order transfer function:


s+2
G(s) = (18)
s2 + s + 10

An alternative representation is the specification in terms of zeros s0,i , poles sinf,i and
static gain k.
(s − s0,1 ) . . . (s − s0,m )
G(s) = k (19)
(s − s∞,1 ) . . . (s − s∞,n )

The above transfer function has a unit gain k = 1, a zero at s0,1 = −2 and two conjugate
complex poles at sinf,{1,2} = −0.5 ± 3.12i with a zero pole gain representation

(s − 2)
G(s) = (20)
(s + 0.5 − 3.12i)(s + 0.5 + 3.12i)

The following Matlab commands support the definition of LTI systems in terms of transfer
functions and zero pole gain models:

• tf : A continuous-time transfer function with numerator(s) num and denominator(s)


den can be created with the command
Scientific Programming in Matlab
Version 1.0 Control System Toolbox I Page 8

sys = tf(num,den)

The coefficients of the numerator and denominator polynomial are provided as a


vector, e.g. the polynomial s3 + 3s + 2 is defined by the vector [1 3 2]. sys is an
object of class @tf.

• zpk: The command


sys = zpk(Z,P,K)

creates a continuous-time zero-pole-gain (zpk) model sys with zeros Z, poles P, and
gains K. sys is an object of class @zpk.

9) mandatory: Generate an LTI system with the Matlab function tf for the second
order SISO transfer function
K
G(s) = s2 2ξ
(21)
ω02
+ ω0
s +1

with parameters K = 1, ξ = 0.25 and ω0 = 1.

10) mandatory: Plot the system response for the LTI system over the interval t ∈ [0, 40]
with a sample rate ∆t = 0.1 for the input signal u(t) = cos(t).
note: in case of transfer function models you can not provide an initial state x0 for
the simulation with lsim.

11) mandatory: Convert the second order system described by the transfer function
in Eq. (21) to a state-space representation with ss and denote the system matrix
A, input vector b and output vector c in numerical form.

A = (22)
b = (23)
c = (24)

Note: The state-space representation is better suited for numerical computations,


such as simulation of the system, in particular it allows the specification of an initial
state x0 .

12) mandatory: Convert the state-space model in Eq. (24) into a zero-pole-gain repre-
sentation with zpk. Denote the poles s∞,1 , s∞,2 in numerical form.

s∞,1 = (25)
s∞,2 = (26)
Scientific Programming in Matlab
Version 1.0 Control System Toolbox I Page 9

Frequency response models


Frequency response models (frd) store, manipulate, and analyze frequency response da-
ta. An frd model stores a vector of frequency points with the corresponding complex
frequency response data you obtain either through simulations or experimentally.

• frd: A frd model sys with response data R specified at the frequency points in Freqs
can be created with the command
sys = frd(R,Freqs)

The output sys is an object of class @frd.

• bode: The command


bode(sys)

creates a Bode plot of the frequency response of a dynamic system model sys.

13) optional: AnalyzerData.mat provided from Matlab includes frequency response


data. The variables freq and resp contain 256 test frequencies and the correspon-
ding complex-valued frequency response points, respectively.
Generate a frequency response model from the data with frd and generate its Bode
plot.

System Identification

System identification uses statistical methods to estimate mathematical models of dyna-


mical systems from experimental data. The purpose of system identification is to generate
models of dynamic systems which structure and/or parameters are difficult to derive from
first principles. Parameter identification employs time-domain and/or frequency-domain
input-output data to identify transfer functions and state-space models.

The system identification toolbox enables you to identify the parameters and structure
of linear and nonlinear models from experimental data in the time or frequency domain.
A complete coverage of the system identification toolbox is beyond the scope of this
assignment.

The following commands will be utilized:

• ssest: A state-space model using time or frequency domain data is estimated with
the command
sys = ssest(data,nx)
Scientific Programming in Matlab
Version 1.0 Control System Toolbox I Page 10

data is either an iddata object containing input and output signals in the time
domain or a frequency response model (frd) containing recorded frequency data.
The optional parameter nx denotes the order of the state-space model.

14) optional: Identify a third order state-space model from the frequency response
model in the previous task with ssest.

15) optional: Generate the step response for the identified model.

16) optional: Superimpose the Bode plot of the identified model with the original
frequency response of the frd model.

Model Characteristics

The Control System Toolbox provides commands to query model characteristics such as
the I/O dimensions, poles, zeros, and DC gain. A pole zero map is a graphical represen-
tation of a rational transfer function in the complex plane which conveys fundamental
properties of an LTI system such as stability, causal system / anticausal system, region
of convergence (ROC), minimum phase / non minimum phase.

17) mandatory: Determine the poles (command pole), zeros (zero) and static gain
(dcgain) of the LTI system described by the transfer function
4s + 2
H(s) = (27)
s2 + 5.5s + 9
.

18) mandatory: Plot the pole zero map of the system with pzmap.

Interconnecting Linear Systems


LTI models allow arithmetic operations such as addition, multiplication or concatenation.
Addition performs a parallel interconnection in terms of superposition of parallel signals,
multiplication performs a serial interconnection in that the output of the first LTI beco-
mes the input to the second LTI.

The following commands define serial, parallel and feedback interconnections of LTI sys-
tems:

• series: Two model objects can be connected in series with


Scientific Programming in Matlab
Version 1.0 Control System Toolbox I Page 11

sys = series(sys1,sys2)

• parallel: Two model objects can be connected in parallel with


sys = parallel(sys1,sys2)

• feedback: The command


sys = feedback(sys1,sys2)

generates a model object sys for the negative feedback interconnection of model
objects sys1 and sys2.

For an open loop system with transfer function G(s) the closed-loop transfer function
G(s)
with unit feedback becomes C(s) = 1+G(s) .
For an open loop system with transfer function G(s) the closed-loop transfer function
G(s)
with feedback transfer function H(s) becomes C(s) = 1+G(s)H(s) .

19) mandatory: Assume an integrator with the transfer function


1
G1 (s) = (1)
s
and a first order system with
s+1
G2 (s) = (2)
s+2
Compute the transfer function of the parallel and serial connection of the two sys-
tems.

20) mandatory: Assume an integrator with the transfer function


1
G(s) = (3)
s

Compute the closed-loop transfer function for unit feedback.

21) mandatory: Assume an integrator with the transfer function


1
G(s) = (4)
s
Compute the closed-loop transfer function for a feedback transfer function
s+1
H(s) = (5)
s+2
Scientific Programming in Matlab
Version 1.0 Control System Toolbox I Page 12

Analyzing Models
The Control System Toolbox allows you to analyze the time- and frequency-domain re-
sponses of one or more linear models using the LTI Viewer GUI (linearSystemanalyzer).
The LTI Viewer is a GUI for viewing and manipulating the response plots of linear models.
It displays the following plot types for linear models:

• Step and impulse responses (step, impulse)


• Bode and Nyquist plots (bode, nyquist)
• Nichols plots (nichols)
• Singular values of the frequency response
• Pole/zero plots (pzmap)
• Response to a general input signal (lsim)
• Unforced response starting from given initial states (only for state-space models)
(lsim)

The frequency response represents the response of a system to a stimulus in the frequency
domain. It is defined in terms of the magnitude and phase of the output signal as a
function of the frequency of the input signal. In other words, if the system is stimulated
with a sinusoidal input signal the response of a linear system is a sinusoidal signal at that
very same frequency but with a modulated magnitude and phase relative to the stimulus.
The magnitude of the frequency response is measured on a logarithmic scale in decibels
(dB) and the phase measured in radians or degrees, versus the frequency in radians/sec
or Hertz (Hz) of the stimulus. The frequency response is plotted either as:

• Bode (bode): generates two separate plots of magnitude and phase versus input
frequency
• Nyquist (nyquist): magnitude and phase are visualized in a single polar plot with
frequency as a parameter
• Nichols (nichols): magnitude and phase are visualized in a single Cartesian plot
with frequency as a parameter

22) mandatory: Analyze the following closed loop model of the second order system
with the LTI viewer linearSystemAnalyzer.
1
G(s) = (1)
s2 +s+1
Determine the following characteristic in the time domain by inspecting the step
response plot.
Scientific Programming in Matlab
Version 1.0 Control System Toolbox I Page 13

• overshoot O =
• settling time ts =
• rise time tr =
• steady state yinf =

Determine the following characteristics in the frequency domain by inspecting the


bode diagram

• peak response Kpeak =


• phase margin ϕ =
• delay margin td =

What is the phase of the second order system for ω → ∞?

23) mandatory: Convert the transfer function model


1
G(s) = (2)
s2 +s+1
into state space form with ss.
The Matlab function lsim provides the same functionality regarding the simulation
of LTI systems as the linearSystemAnalyzer. lsim not only plots the signals but
also returns the output signal y and the state signal x as arguments. With gensig
you can generate customized input signals for the system. Utilize t ∈ [0 25] for the
following tasks.

• Analyze the response of the system to an initial displacement x0 = [0 2] for


u = 0 using lsim.
• Analyze the response of the system for an initial state x0 = [0 0] and a sine
wave signal of period τ = 5s (generate the signal with gensig) using lsim.
• Analyze the response of the system for an initial state x0 = [0 0] and a square
signal with period τ = 2s (generate the signal with gensig) using lsim.

You might also like