61
UNIVERSITY of VAASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo Mantere http://www.uwasa.fi/~timan/TLTE3120/

U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

Embed Size (px)

Citation preview

Page 1: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS)

Lecture 8

28.10.2015

Timo Mantere

http://www.uwasa.fi/~timan/TLTE3120/

Page 2: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Matlab features

We cannot go through all the possibilities of Matlab and Simulink in this course, so most important is to know where to get help when you start doing real things with Matlab

Basically most of the things you need to know is available in Mathworks homepage http://se.mathworks.com/

Use find there with proper keywords and you probably find what you are looking for, lot of examples and example codes

Page 3: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Matlab features

Matlab tutorial videos available Data analysis and visualization

http://se.mathworks.com/products/matlab/description3.html

Programming and algorithm development http://se.mathworks.com/products/matlab/description4.html

Application development http://se.mathworks.com/products/matlab/description5.html

Page 4: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Matlab features

Simulink tutorial videos available Simulink key features

Building the model Simulating the model Analyzing simulation results Managing projects Connecting to hardware http://se.mathworks.com/products/simulink/features.html#key_features

Videos http://se.mathworks.com/products/simulink/videos.html

Examples http://

se.mathworks.com/examples/product-group/matlab-signal-processing-and-communications

Page 5: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Matlab features

Features important to our students Digital signal processing toolbox

http://se.mathworks.com/products/dsp-system/

Control system toolbox http://se.mathworks.com/products/control/

Communications system toolbox http://se.mathworks.com/products/communications/

Also: Design and simulate radio systems

http://se.mathworks.com/products/simrf/ Radio frequency toolbox

http://se.mathworks.com/products/rftoolbox/ LTE toolbox

http://se.mathworks.com/products/lte-system/

Page 6: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Matlab features

Features important to our students Digital filter design

http://se.mathworks.com/discovery/filter-design.html

Filterbuilder http://se.mathworks.com/help/dsp/gs/design-a-filter-using-filterbuilder.html Type filterbuilder Select filter type Select features View filter response

Page 7: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Matlab features

Filter design with Matlab, example, copy paste parts

s1=[20, 30, -10, 40, 40, 30, 20] %first signal

s2=[20, 30, 40, 0, -1, 0, 40, 30, 20] %second signal

b1=fir1(3,0.5) %create FIR filter with fir1

[b2, a]=butter(3,0.5) %create IIR filter

freqz(b2,a,100,1000) %frequency response of IIR filter

%hold

%freqz(b1,1,100,1000) %frequency response of FIR filter

%filter 1. signal with FIR and IIR filters

F1=filter(b1,1,s1) %FIR filter a=1

I1=filter(b2,a,s1)

%filter 2. signal with FIR and IIR filters

F2=filter(b1,1,s2)

I2=filter(b2,a,s2)

Page 8: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Matlab features

Filter design with Matlab, example 2N=50; %fir degree

%create rectangular window

window=ones(N+1,1);

%frequncies and responses for drawing

f=[0 1];

m=[0 1];

%fir filter creation with fir1 or fir2 function

b=fir2(N, f, m, window)

%b=fir2(N, f, m, window);

%calclate fir attenuation

[h,w]=freqz(b,1,1000);

%draw frequncy response, wanted and obtained

plot(f,m,w/pi,abs(h))

legend('Ideal','fir2 Designed');

title('Comparison of Frequency Response Magnitudes');

%freqz(b,1,512) %attenuation

Page 9: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Matlab features

Filter design with Matlab, example 3% Define bandbass

wn=[0.2 0.6];

N=50; %FIR degree

window=ones(N+1,1);

b=fir1(N, wn, window) %Fir

%attenuation

[h,w]=freqz(b,1,512)

%frequncies for calulating responses

f=[0 0.2 0.2 0.6 0.6 1];

m=[0 0 1 1 0 0];

%draw wanted and obtained response

plot(f,m,w/pi,abs(h))

legend('Ideal','fir1 Designed');

title('Comparison of Frequency Response Magnitudes');

%freqz(b,1,512)

Page 10: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Matlab features

Also available other filter models e.g. Butterfield

% Generate low pass filter eg. len=10, Fn=0.5 [b,a]=butter(len,Fn);

Chebyshev Cheby1 [b,a] = cheby1(N,R,Wp) Chepy2 [b,a] = cheby2(N,R,Wst)

Elliptic [b,a] = ellip(N,Rp,Rs,Wp)

Page 11: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Matlab features

Matlab C code generation C conversion can be done with codegen command Help codegen Examples:

http://se.mathworks.com/examples/matlab-coder/1866-c-code-generation-for-a-matlab-kalman-filtering-algorithm#1

http://se.mathworks.com/examples/search?utf8=%E2%9C%93&q=C+Code+Generation+for+a+MATLAB

Page 12: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Simulation of communication systems

Communication systems have become more and more complex over the years

Systems requires more analyses during the design phase Analyses must be done fast and cost-effectively These things have lead to the computer based simulations

Page 13: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Simulation of communication systems

Communication systems can be analyzed and evaluated e.g. by Based on formulas and their calculations (usually simplified models) Waveform-level simulations Hardware prototyping and measurements (quite costly) Combinations of previous

Usually simulation based evaluation is most flexible, one can combine mathematics with models or measured data

Communication system could be whatever, satellite-based, terrestrial wireless, optic cables, Ethernet, etc.

Page 14: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Simulation of communication systems

Different simulation techniques are used to evaluate performance, e.g. At network level flow of packets and messages over the

network is simulated, calculating throughput, packet loss, response time, resource utilization etc

Communication links are measured in terms of error characteristics, bit error rate etc.

Link could contain different parts that are simulated separately; modulators, encoders, filters, amplifiers, decoders, demodulators, etc.

Also the hardware parts can be simulated by using hardware description language like VHDL

Page 15: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Simulation of communication systems

Quite often the simulation results are presented as Scope Y-T plot X-Y plot Frequency curve Frequency response curve (filter, channel) Eye diagram Error rate plot (SNR) I-Q plot (real-imaginary axis)

Page 16: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

A Refreshment of System Analysis

Page 17: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Introduction: What is a Signal?

Signals describe quantities that change. This change can be with time, frequency, location, ..etc.

Figure (1) in the next slide shows signal x(t) changes with time, this signal represent voice signal for word “Finland”.

Figure (2) shows signal y(f) which represents certain signal in frequency domain

Figure (3) shows signal z(n) which represents the grades of one of one of telecommunication courses in the University of Vaasa

Page 18: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Introduction: What is a Signal?

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-0.6

-0.5

-0.4

-0.3

-0.2

-0.1

0

0.1

0.2

0.3

0.4

time [2]

x(t

)

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2

x 104

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

frequency [Hz]

y(f

)

0 1 2 3 4 5 0

1

2

3

4

Grade

Num

ber of students

Figure (1) Figure (2)

Figure (3)

Page 19: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Introduction: What is a Signal?

A signal is a function or sequence of values that represent information.

The signals can be classified according to various criteria as shown in the table:

Continuous (in time) discrete (in time)

Amplitude-continuous Amplitude-discrete

analogue digital

Real-valued Complex-valued

Uni-dimensional Multi-dimensional

Deterministic stochastic

Page 20: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Introduction: What is a Signal?

E.g. signal processing

s = importdata('test.wav') % load sound sample

soundsc(s.data,s.fs) % play sample

plot(s.data) % plot sound sample

plot(s.data(:,1)) % plot first channel

0 2 4 6 8 10 12

x 104

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0 2 4 6 8 10 12

x 104

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

Page 21: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Introduction: What is a Signal?

E.g. spectral density

DF=fft(s.data(:,1)); % Fourier transform of 1. channel

N=length(s.data); % Length

FF= DF.*conj(DF)/N; % spectral density

f = s.fs/N*(0:(N-1)/2); % s.fs sample rate

plot(f,FF(1:length(f)));

See signal processing exampleshttp://se.mathworks.com/products/signal/index.html

0 0.5 1 1.5 2 2.5

x 104

0

0.5

1

1.5

2

2.5

3

3.5

Page 22: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Introduction: What is a System?

A system is the abstraction of a process or object that puts a number of signals into some relationship.

Usually, we can classify system’s signals as input and output signals.

Input signals exist independently of the system and are not affected by the system; instead the system reacts to these signals.

Output signals carry information generated by the system, often as a response to input signals.

SystemSystem

Single Input, Single Output (SISO)

Multiple Input - Multiple Output (MIMO)

x y 1x2xMx

1y2y

Ny

Page 23: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Derivative Notation

Following notations of derivative are equivalent:

Usually the last form (x with dots) is favored in system analysis

2

2

3

3

( )'( ) ( )

( )''( ) ( )

( )'''( ) ( )

dx tx t x t

dt

dx tx t x t

dt

dx tx t x t

dt

Page 24: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Example: Static and Dynamic Models

A system is called dynamic, if its state is a function of its previous states. For example: The effect of external force F to

object location x can be derived from the force balance equation (m is a mass, k is a spring constant and B is a damping coefficient)

A system is called static, if its current state does not depend on previous state For example: the effect of temperature T to

pressure p in closed and isolated tank can be derived from the ideal gases law (n is the molar amount, V volume and R gas constant)

m

k B

x(t)

F(t)

p(t) T(t)

nV

mx t Bx t kx t F t( ) ( ) ( ) ( )

p t V nRT t( ) ( )

Page 25: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Example: Static and Dynamic Models

In the simulations plotted on the right side, the external force in the mechanic system and the temperature in the gas tank model are changed step-vise In a dynamic system, the response will

change long after the input has already stabilized. One can not define the respose just by knowing the input at the same time moment.

In a static system the input and the response are changing only on same time monents, and the system response can be defined just by knowing the input at the same time moment

Mass location

External force

Pressure

Temperature

Page 26: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Linear and Nonlinear Systems

A system is linear, if it satisfies the following two conditions:

1) If input u1 generates response y1, then input Ku1 generates response Ky1 (K is a constant).

2) If input u1 generates response y1 and input u2 generates response y2, then input (u1+u2) generates response (y1+y2).

Page 27: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Linear and Nonlinear Systems

In general, a differential equation is linear, if each term in it has a form constant(variable or variable’s derivative) For example:

The real systems are usually nonlinear, but one can often approximate them by using linearization

( ) ( ) ( ) ( ) ( ) ( ) ( )y t y t y t u t u t u t u t 3 5 2 3 21 1 2 2

Page 28: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Continuous Time and Discrete Time Models

Dynamic, continuous time models are described by using differential equations and differential equation groups For example, the damped oscillator differential equation

Dynamic, discrete time models are described by using difference equations and difference equation groups For example, a rate formula:

mx t Bx t kx t F t( ) ( ) ( ) ( )

y t y t u tk k k( ) . ( ) ( ) 1 107 1

Page 29: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Time Variant and Time Invariant Systems

In time variant systems the model parameters are changing as a function of time Further analysis of time variant systems is out of the scope of this course

In time invariant systems the model parameters are assumed to be constants over time

Most of the real-world systems are time variant (worning, dirt and dust, changing environmental conditions etc.), but in many cases the effect of time invariance is so small that it can be ignored in the model

m t x t Bx t kx t F t( ) ( ) ( ) ( ) ( )

Page 30: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

State-Space Representation

There always exist a first order differential equation group which is equivalent to higher order differential equation The solution is not unique; usually there are several first order groups equivalent to

higher order differential equation

State-space representation is a compact way to present higher order differential equations

System state in a certain time moment is a complete system description. If we know the initial state as well as all input values after the initial state, we can define system state and output values in every time moment. That makes state space representation well suitable for modeling.

State space representation is also applied in the context of multivariable systems

Page 31: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

State-Space Representation

In state-space representation, a higher order differential equation (or a group of higher order differential equations) is represented as a group of first order differential equations The number of first order equations will be equal to the order of the higher

order differential equation

There are several ways to select the state variables state-space representation is not unique

Page 32: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

State-Space Representation

The general form of the state-space representation is

x(t)=f(x(t),u(t)

y(t)=g(x(t),u(t))

x(t) contains the state variables, u(t) control (input) variables and y(t) output variables These variables can be either matrices or scalars

f(x(t),u(t)) is the system equation which describes the system dynamics g(x(t),u(t)) is the output equation which describes how system output

depends on states and on control input If u(t) has a scaler value u(t) and y(t) has a scalar value y(t), the system

is SISO. The dimension of state matrix x(t) can still be higher.

Page 33: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Example: A Fluid Flow System (1/5)

In a flow process a liquid one which have a chemical consentration C1 is mixed with liquid two which have a chemical concentration C2.

We are targeting to have a production (flow F) of such a product, which concentration is C by controlling the flows F1 and F2.

There is a free flow from the mixing tank to the air pressure the outflow is propotional to the square root of the tank surface level: C(t) F(t)

F1(t)C1 F2(t)C2

C(t)h(t)

A

F t k h t( ) ( )

Page 34: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Example: A Fluid Flow System (2/5)

Form a differential equations for mass balance (will be simplified to volume balance) and for concentration balance:

1 2

1 1 2 2

( ) ( )( ) ( ) ( )

( ) ( )( ) ( ) ( ) ( )

dV t dh tA F t F t F t

dt dtdC t V t

C F t C F t C t F tdt

Page 35: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Linear State-Space Representation

If the system is linear, variables and parameters can be separated. In that case the standard form of the state-space representation is

A is system matrix, B control matrix, C output matrix and D direct effect matrix. It is often so that there is no direct effect. In that case D = 0 (so-called

strictly proper system).

( ) ( ( ), ( )) ( ) ( )

( ) ( ( ), ( )) ( ) ( )

x f x u Ax Bu

y g x u Cx Du

t t t t t

t t t t t

RSTX(t)

Y(t)

Page 36: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Linear State-Space Representation

A differential equation group

Can be represented as a matrix equation

1 11 1 1 11 1 1

2 21 1 2 21 1 2

1 1 1 1

n n m m

n n m m

n n nn n n nm m

x a x a x b u b u

x a x a x b u b u

x a x a x b u b u

1 11 1 1 11 1 1

1 1

n m

n n nn n n nm m

x a a x b b u

x a a x b b u

x Ax Bu

Page 37: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Example: a Circuit Board (1/4)

A model for the circuit board illustrated on the left Input is v0(t), outputs are

voltages v1(t) ja v2(t).

Equations for the capacitors and currents are

Kirchoff I Kirchoff II

1 21 3 2 2

( ) ( )( ), ( )

dv t dv tC i t C i t

dt dt

1 2 3( ) ( ) ( )i t i t i t

v1(t) v2(t)

i1(t) i2(t)R1 R2

C1 C2v0(t)

i3(t)

vR1(t) vR2(t)

1 1 1 2 2 2( ) ( ), ( ) ( )R Rv t R i t v t R i t

0 11

0 1 1 0 1 1 1 1

1 21 2 2 1 2 2 22

2

( ) ( )( )

( ) ( ) ( ) ( ) ( ) ( )

( ) ( )( ) ( ) ( ) ( ) ( ) ( )( )

R

R

v t v ti t

v t v t v t v t R i t v t R

v t v tv t v t v t v t R i t v ti t

R

Page 38: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Example: a Circuit Board (2/4)

Since the system input and system responses are all voltages, it is reasonable to eliminate the currents from the equations.

0 11 1 23 1 2

1 1 1 1 2 1

2 1 22

2 2 2

( ) ( )( ) 1 1 ( ) ( )( ) ( ) ( )

( ) 1 ( ) ( )( )

v t v tdv t v t v ti t i t i t

dt C C RC R C

dv t v t v ti t

dt C R C

11 2 0

1 1 2 1 2 1 1 1

21 2

2 2 2 2

( ) 1 1 1 1( ) ( ) ( )

( ) 1 1( ) ( )

dv tv t v t v t

dt RC R C R C RC

dv tv t v t

dt R C R C

Page 39: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Example: a Circuit Board (3/4)

We got first order differential equation group

Capasitor voltages are natural choise to be the state variables. Select the output to be only the voltage of the latter capasitor v2:

11 2 0

1 1 2 1 2 1 1 1

21 2

2 2 2 2

( ) 1 1 1 1( ) ( ) ( )

( ) 1 1( ) ( )

dv tv t v t v t

dt RC R C R C RC

dv tv t v t

dt R C R C

x( )( )

( ), ( ) ( ), ( ) ( )t

v t

v tu t v t y t v t

LNMOQP 1

20 2

v1(t) ,v2(t)

Page 40: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Example: a Circuit Board (4/4)

By applying these selections we will get

and finally

1 21 1 2 1 2 1 1 1

1 22 2 2 2

2

1 1 1 1( ) ( ) ( )

( ) ( ( ), ( ))1 1

( ) ( )

( ) ( ) ( ( ), ( ))

x t x t u tRC R C R C RC

t t u t

x t x tR C R C

y t x t g t u t

x f x

x

1 1 2 1 2 11 1

2 2 2 2

1 1 11

( ) ( ) ( ) ( ) ( )1 1

0

( ) 0 1 ( ) 0 ( ) ( ) ( )

RC R C R CRCt t u t t u t

R C R C

y t t u t t Du t

x x Ax B

x Cx

Page 41: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Finding the State Variables

How to select the state variables? Make such a selection, which is physically reasonable (like in the previous

examples) Use derivative operator p (so-called p-technique) Use chanonical forms

Physically reasonable state variable selection is usually the easiest way

Applying chanonical forms is just applying of a straightforward formula, but it might be difficult to see the physical meaning of the state variables

Page 42: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Method 3: Use Chanonical Forms (2/2)

Apply chanonical forms

A result by using controllable chanonical form is similar with the one achieved by using derivative operator

1( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )kBm m mmx t Bx t kx t F t x t x t x t F t

11 2 1 2( ) ( ) ( ) 0 ( ) ( ) ( ) ( ) ( ) ( ) ( )kB

m m my t y t y t u t u t y t a y t a y t b u t b u t

1 1

12 2

01 1( ) ( ) ( ) ( ) ( ) ( )

0 0

( ) 1 0 ( )( ) 1 0 ( )

Bm

kmm

a bt t u t t t u t

a b

y t ty t t

x x x x

xx

Page 43: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

The Dimensions of the Linear State-Space Representation

The system order is the same as the sum of the order of the differential equations which describe the system. It is also the dimension of the system matrix A.

The number of inputs (control signals) is nu The number of outputs is ny System order is nS The dimensions of the linear state-space representation are as follows:

1 1 1

1 1 1

( ) ( ) ( )

( ) ( ) ( )

S S S uS S u

y uy Sy S u

n n n nn n n

n nn nn n n

t t t

t t t

x A x B u

y C x D u

Page 44: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Solutions in Time and Laplace Domains

( ) 2 ( )

(0) 1

ty t y t e

y

Laplace-domainsolution

Laplace-domainproblem

Time domain problem

Time domainsolution

1( ) (0) 2 ( )

1

(0) 1

sY s y Y ss

y

1( )

1Y s

s

( ) ty t e

Page 45: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Laplace-transform

F(s) is a Laplace transform of time domain function f(t). The Laplace-transform and its inverse transform are defined as follows:

The following two theorems can be applied, if the respective limits exist:

Final value theorem

Initial value theorem

The most usual Laplace-transforms and inverse transforms are tabulated

0

( ) ( ) ( ) stF s L f t f t e dt

1 1

( ) ( ) ( )2

b jst

b j

f t L F s F s e dsj

0lim ( ) lim ( )t s

f t sF s

0

lim ( ) lim ( )t s

f t sF s

Page 46: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Laplace-transforms (1/5)

1 1 2 2 1 1 2 2

Laplace-transform Inverse Laplace transform

( ) ( ) T1

( ) ( ) ( ) ( ) T2

( ) ( ) T3

0,( ) T4

( ),

1( ) T5

( ) ( ) T6

at

as

F s f t

C F s C F s C f t C f t

F s a e f t

t ae F s

f t a t a

sF f at

a a

dF s f t t

ds

Page 47: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Laplace-transforms (2/5)

1 2 1 2

0

2

1 2 ( 1) ( )

0

Laplace-transform Time-domain function

1( ) ( ) T7

( ) ( ) ( ) ( ) T8

( ) (0) ( ) T9

( ) (0) (0) ( ) T10

( ) (0) (0) (0) ( ) T11

1 1( ) ( )

s

t

n n n n n

t

t

F d f tt

F s F s f f t d

sF s f f t

s F s sf f f t

s F s s f s f f f t

F s f ds s

00

( ) T12t

f d

Page 48: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Laplace-transforms (3/5)

2

1

2

1

Laplace-transform Time domain

1 ( ) M1

11 M2

1M3

1M4

!1

M5

1M6

( )

1M7

( ) !

1 11 M8

( )

n

n

at

at

n at

n

at

t

s

ts

t

s n

es a

tes a

t e

s a n

es s a a

2 2

2 2

2 2

2 2

Laplace-transform Time domain

1 1M9

( )( )

1 1 1M10

( )( ) ( )

sin( ) M11

cos( ) M12

sin( ) M13( )

cos( ) M14( )

( ) ( ) M15

bt at

bt at

bt

bt

bt

e es a s b a b

ae bes s a s b ab ab b a

aat

s as

ats aa

e ats b a

s be at

s b a

s at a b e

s b

Page 49: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Diracin deltaImpulssi

Askel

Penger

Page 50: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Page 51: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Deterministic Test Functions

Following signals u(t) are often used as system inputs Unit impulse function (Dirac delta function)

Unit step function

U(t) = 0; t <0

= 1; t >0

Unit ramp function

U(t) = 0; t <0

= t; t >0

0 t

u(t)

0

1

t

u(t)

0 t

u(t)

; 0( ) ( )

0; 0

tu t t

t

U s s ( ) ( ) 1

U sss ( ) 1

U ssr ( ) 12

Page 52: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Example: Damped Oscillator

The differential equation of the damped oscillator:

Solve the system response (output), when K=5 B=2 M=1

In time domain the model is

m

k B

x(t)

F(t)

mx t Bx t kx t F t( ) ( ) ( ) ( )

(0) 1

(0) 1

( ) 2 ( ) (impulse)

x

x

F t t

( ) ( ) ( ) ( )x t x t x t t 2 5 2

Page 53: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Example: Damped Oscillator

Solve location X(s) from the Laplace-transformed expression:

Then solve x(t) by computing the inverse Laplace transform back to the time domain:

X ss

s s

s

s

s

s s( )

( ) ( ) ( )

3

2 5

1 2

1 2

1

1 2

2

1 22 2 2 2 2 2 2

1( ) ( ) cos(2 ) sin(2 ) sin(2 ) cos(2 )t t tx t L X s e t e t e t t

Page 54: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Zero-State and Zero-Control Responses

System response can be divided to the part y0(t) (zero-control response) caused by system initial values and to the part yu(t) caused by the external input (zero-state response). Linear system response is a sum of these two parts:

System response is equal to zero-control response y0(t) if the external inputs ui(t) = 0.

System response is equal to zero-state response yu(t), if all system initial values y(n)(0) and ui(n)(0) are zeros.

Term ”response” refers often to zero-state response, in other words system response to some external input

y t y t y tu( ) ( ) ( ) 0

Page 55: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Example: Damped Oscillator

Zero-control response starts from the system initial state (location 1, velocity -1)

Zero-state response starts from zero once the external force starts to effect

System response is a sum of these two components

Page 56: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Transfer Function

One of the crucial topics in system analysis is to analyze that how external signals and disturbances affect the system response

System transfer function is system response divided by system external input in Laplace-domain:

It follows from the definition that if system initial values are zero, system output in Laplace-domain is given by

Y s G s U s( ) ( ) ( )

( )( )

( )

Y sG s

U s

U(s) Y(s)G(s)

heräte vastesiirtofunktioInput ResponseTransfer fcn

Page 57: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Transfer Function

A differential equation (or equation group) characterizing the system is first Laplace-transformed and then Y(s) / U(s) is solved.

If we have several input and output variables (MIMO-model), we will get a transfer function matrix

Page 58: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Transfer Function

General form of the linear differential equation is

Laplace-transform gives (initial values are assumed to be zero)

Then it is easy to solve the transfer function

y t a y t a y t a y t b u t b u t b u tn nn n

nn n

( ) ( ) ( ) ( ) ( )( ) ( ) ( ) ( ) ( ) ( ) ( )

1

11

11

11

1

1 11 1 1 1( ) ( )n n n

n n n ns a s a s a Y s b s b s b U s

11 1

11 1

( )( )

( )

nn n

n nn n

b s b s bY sG s

U s s a s a s a

Page 59: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Static Gain

System static gain quantifies how much signal is strengthtened of faded once it goes through the system For unit step respons, the static gain describes in which level the

system response will set (asymptotic stable system) For unit ramp response, the static gain gives the response angular

coefficient in continuous state (asymptotic stable system)

Static gain can be solved as a limit of system transfer function. It can be solved also for nonstabile systems, but in that case there is no physical connection to system response end value.

System static gain is given by

For stabile system

k G ss

lim ( )0l q

0

lim ( ) lim ( )s t

k G s y t

Page 60: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

From State-Space Representation to Transfer Function

A transfer function can be counted directly from the state-space representation such that

If the direct effect term D = 0, the formula is simplified to

1( ) ( )s s G C I A B D

1( ) ( )s s G C I A B

Page 61: U NIVERSITY of V AASA Telecommunication Engineering Group TLTE.3120 Computer Simulation in Communication and Systems (5 ECTS) Lecture 8 28.10.2015 Timo

UNIVERSITY of VAASA Telecommunication Engineering Group

Example: Damped Oscillator

Solve unit step response by using a transfer function

The response is

1

1

2 2

1 0( ) ( ) 1 0

5 2 1

2 1 01 0

5 1 1

2 5 2 5

sG s s

s

s

s

s s s s

C I A B

1 1 12

1 15 2

1( ) ( ) ( ) ( )

( 2 5)

1 cos(2 ) sin(2 )t t

y t L Y s L G s U s Ls s s

e t e t

1( )U s

s