Control and Automation - Lecture 2
Control and Automation - Lecture 2
Lecture 2
v(t ) Ri(t )
v(t)
dv(t ) C i(t)
i (t ) C
dt
v(t)
Example. Electrical circuit
Making a model for the electrical i1(t) R2 i2(t)
R1
circuit
The input, or impulse, is v0 (t) and
vR1(t) vR2(t)
the output quantities, i.e., the
v0(t) v1(t) C1 v2(t) C2
voltages V1 (t) and V2 (t).
i3(t)
Electric currents and resistors can
be modelled as
dv1 (t ) 1 1 1 1
v1 (t ) v2 (t ) v0 (t )
dt R1C1 R2C1 R2C1 R1C1
dv2 (t ) 1 v (t ) 1 v (t )
dt 1 2
R C
2 2 R
2 2C
Basic components of mechanical systems
Linear Motion: m
Mass (inertia)
d 2 x(t )
Fm (t ) m x(t)
dt 2
k
Spring
Fk (t ) k x (t ) k ( x1 (t ) x2 (t ))
x1(t) x2(t)
Damper B
d x(t ) dx1 (t ) dx2 (t )
Fb (t ) B B
dt dt dt
x1(t) x2(t)
Example. Mechanical system
Make a model for a mechanical k
system in which two mass pieces F(t)
are connected together with a m2 m1
spring and a damper
The input is an external force F B
(T) and the position of the second
mass x2(t) is the output x2(t) x1(t)
First mass force equation:
d 2 x1 (t ) dx1 (t ) dx2 (t )
m1 (t ) 2
B k x1 (t ) x2 (t ) F (t )
dt dt dt
Second mass force equation:
d 2 x2 (t ) dx1 (t ) dx2 (t )
m2 (t ) 2
B k x1 (t ) x2 (t )
dt dt dt
Basic components of mechanical systems
Rotational motion:
Moment of inertia
d 2 (t ) (t) J
TJ (t ) J
dt 2
Torque Spring
k
Tk (t ) k1 (t )
1(t) 2(t)
Torque Damper B
d1 (t ) 1(t) 2(t)
Tb (t ) B
dt
Example. Mechanical system
Make a model for the rotating
B
system shown in the figure. The 1(t) k 2 (t)
excitation is torque T (t) and the T(t) J
response is angles 1(t) and2(t)
d 21 (t )
J dt 2 k 1 (t ) 2 (t ) T (t )
B d 2 (t ) k (t ) (t )
dt
1 2
Basic components of flow systems
F1(t)
Flow tank
dV (t )
F1 (t ) F2 (t )
dt V(t) F2(t)
Ideal Mixer F1(t)
dV (t )C2 (t ) C1(t)
F1 (t )C1 (t ) F2 (t )C2 (t )
dt
V(t)
Pipe flow delay C2(t) F2(t)
V C2(t)
C2 (t ) C1 (t Td (t )) C1 t
F (t )
F(t)
Flow through an orifice C1(t) V C2(t)
F(t)
F (t ) A(t ) R p(t ) A(t ) R p1 (t ) p2 (t ) p1(t) p2(t)
R
A(t)
Example. Flow System
The flow system is shown in the diagram. F2 F1
There is the input flow concentration C1 (t) C2(t) C1(t)
and the concentration of the output flow is
C3(t). Flow and volumes are constants
V F3 C3(t)
The flow branching point can be F1
F3 F1 F2 F2 C3(t)
Considering ideal sensor and pipe flow Vp C3(t)
dVC3 (t ) Vp
F1C1 (t ) F2C2 (t ) F3C3 (t ), C2 (t ) C3 t
dt F2
Eliminating the variable C2(t) and F3 :
dC3 (t ) 1 Vp
F1C1 (t ) F2C3 t F1 F2 C3 (t )
dt V F2
Example. Flow System Simulation
Configuring simulation model for flow system with Simullink
V= 0.2 Impulse
Vp= 2 response
Step response F1= 1
F2= 2
State Space Representation
The state space representation is a compact way of representing high-
order differential equations/systems.
The instantaneous state of the system is a complete description of the
system. If the initial state (state quantities at the beginning) and all the
input quantities are known from the beginning, then the system state and
the output quantities can be determined at an arbitrary time. It follows
that the state space representation is very suitable for simulation.
The control of state variables allows for better system control compared
with the control of the system's output quantities.
The state space representation is a standard-format representation, so
the management mechanisms can be standardized independently of the
system (equations are independent of the individual system number and
parameters)
The state space representation is suitable for modeling and managing
multivariate systems
State Space Representation
In a state space representation, an arbitrary order differential equation/system is
represented as a group of first-order differential equations.
The selection of spaces can be made in infinitely different ways = > The state
space representation is not unique but many different state variables can
describe the same input/output model.
The general state space representation is of the format x RS
(t ) f (x(t ), u (t ))
Ty(t ) g(x(t ), u(t ))
x(t) is the state, u(t) the control input y(t) output - All these quantities can be
vectors or scalars.
f(x(t),u(t)) is the system equation (describing system dynamics) and g(x(t),u(t)) is
the starting description (explains how the output quantities depend on the input
and the state)
If u(t) is a scalar u(t) and y(t) is a scalar y(t), then this is a SISO system-
regardless of the vector x(t)’s dimension.
Example. Flow System in State Space representation
dt |T C1 F1 ( t ) C2 F2 (t ) C (t ) F ( t )
dC (t )V (t ) dC (t )
dt
dt
V (t ) C (t )
dV (t ) dC (t )
dt
dt
b
V (t ) C (t ) F1 (t ) F2 (t ) F (t ) g
R| A dh(t ) F (t ) F (t ) k h(t )
1 2
S| dC(t )
dt
R| dh(t ) 1 d F (t ) F (t ) k h(t ) i
1 2
S| dC(t ) 1
dt A
|T dt Ah(t ) cb C C ( t ) g F ( t ) bC C ( t ) g F ( t ) h
1 1 2 2
Choose H and C for state , F1 and F2 for input and output quantities as F
and C
L
x( t ) M
x (t ) O L h( t ) O
1
P M P ,
L
u( t ) M
u (t ) O L F (t ) O
1
P M
1
P ,
L
y( t ) M
y (t ) O L F (t ) O
1
P M P
N x ( t ) Q NC ( t ) Q
2 Nu ( t ) Q N F ( t ) Q
2 2 N Q N Q
y (
2 t ) C ( t )
These variable selections can be used to write directly in the standard
format: RS
x (t ) f (x(t ), u (t ))
Ty(t ) g(x(t ), u(t ))
Example. Flow System in State Space representation
N Q
x ( t ) N f ( x ( t ), u ( t )) Q MM Ax (t ) cbC x (t )gu (t ) bC x (t )gu (t )hPP
N Q
2 2
1 2 1 2 2 2
1
For the initial description, the dependency of the output variables on state
variables
L y ( t ) O L F ( t ) O L k h( t ) O L k x ( t ) O
y(t ) M P M P M P M P
1 1
N Q N Q N Q N
y ( t
2 ) C ( t ) C ( t ) x ( t ) Q 2
Initial description:
L y (t ) O L g ( x(t ), u( t )) O L k x (t ) O
y( t ) M P g( x(t ), u( t )) M P M P
1 1 1
N Q
y2( t ) N g
2 ( x ( t ), u ( t )) Q N x ( t )
2 Q
Example. Flow System in State Space representation
R| L 1
d i O
M
||x (t ) M 1 A
1 u ( t )2 u ( t ) k x
1 ( t ) P
P
M
S| MN Ax (t ) cb1 C x (t ) gu (t ) bC x (t ) gu (t )hP
2 1 2 2 2
PQ
1
||y(t ) LMk x (t ) OP
1
T N x (t ) Q
2
dv1 (t ) 1 1 1 1
v1 (t ) v2 (t ) v0 (t )
dt R1C1 R2C1 R2C1 R1C1
dv2 (t ) 1 v (t ) 1 v (t )
dt 1 2
R C
2 2 R
2 2C
1 1 1 1
x1 (t ) x2 (t ) u (t )
x (t ) R1C1 R2C1 R2C1 R1C1 f ( x(t ), u (t ))
1 1
x1 (t ) x2 (t )
R2C2 R2C2
y (t ) x2 (t ) g (x(t ), u (t ))
And thus:
1 1 1
1
x (t ) R1C1 R2C1 R2C1 x(t ) R C u (t ) Ax(t ) Bu (t )
1 1
1 1
0
R2C2 R2C2
y (t ) 0 1 x(t ) 0 u (t ) Cx(t ) Du (t )
Forming a State Space representation
How to generate a state space representation systematically?
Choosing physical and rational state variables from model equations (as in
previous examples)
Using a derivative operator p
Using canonical forms
y (t ) x ( t ) x1 (t ), u(t ) F (t ) Tx (t ) x(t )
2 k B
T y ( t ) 1 0 x( t )
Forming a State Space representation
Second method: Use the p operator p d / dt
You write the original equation using the p operator whenever there is a
differentiation: x
2 (t )
B
k 1
x1 ( t )
8
B k 1
x (t ) x (t ) x (t ) F (t ) p{ p{x (t )} x (t )} x (t ) F (t )
m m m m m m
R|x (t ) x(t ) R|x (t ) B x (t ) x (t )
|| 1
B B ||
1
m
1 2
S| x ( t ) p{ x ( t )} x ( t )
x ( t ) x (t ) k 1
2
m
1 1
m
|| p{x (t )} x (t ) k x(t ) 1 F (t ) k x (t ) 1 u(t ) S|
2
x ( t )
m
1x ( t )
m
u(t )
T 2 2
m m
1
m m || y(t ) x(t ) x (t )
1
T
R|x (t ) L 1O x(t ) L 0O u(t )
B
S| MN 0PQ MN PQ
m
k 1
m m
T y ( t ) 1 0 x( t )
Differential equation to transfer function
1
s n
a s n 1
an 1 s an Y ( s ) 1 bn1s bn U ( s)
b s n 1
y (t ) 2 y (t ) 5 y (t ) u (t ) s 2Y ( s) 2 sY ( s) 5Y ( s ) U ( s)
c h
s 2 s 5 Y ( s) U ( s) G ( s)
2 Y ( s)
2
1
U ( s) s 2 s 5
g (t ) L1
lG(s)q L 1 RS 1 UV 1 1
L
RS 2 UV
1 t
e sin( 2t )
Ts 2
W
2s 5 2 T
( s 1) 2
2 2
2 W
The weighting function is now the same as the unit impulse
response
Determination of response
Determine the unit step and ramp responses for the mass
position. A transfer function was previously assigned to the
system as: 1
G ( s)
s2 2 s 5
1
Unit step: U ( s)
s
Response: 1 1 1
Y ( s) G ( s ) U ( s)
s 2 2 s 5 s s( s 2 2 s 5)
Taking partial fractions:
1 A Bs C A( s 2 2 s 5) s( Bs C ) ( A B ) s 2 (2 A C) s 5 A
2
s( s 2 s 5) s s 2 s 5
2
s( s 2 s 5)
2
s( s2 2 s 5)
R| A B 0 R| A 1
5
( A B ) s 2 (2 A C ) s 5 A 1 S|2 A C 0 S|B 1
5
T5 A 1 TC 2
5
Example: Mass block
1 1
5s 5
1 2
11 s 1 1 2
Y ( s) 2
5
s ( s 2s 5) s s 2 s 5 5 s ( s 1) 2 2 ( s 1) 2 22
2 2 2
l q ct
y (t ) L1 Y ( s) 1
5
2
5 25 e t cos(2t ) 103 e t sin(2t ) h
Steady State Response
Steady state response tells you how much the signal is
strengthened or dampened after passing through the system
With the unit step response, steady state amplification indicates to which level
the response will remain (asymptotically stable system)
With the ramp response, the amplification indicates the continuity of the slope
of the response (Asymptotically stable system)
Steady state response can be calculated from the transfer
function using the limit value theorem. Steady state
response can also be set for unstable system transfer
functions, but it does not have a physical interpretation that is
linked to the end value of the response.
R
k limlG ( s)q limS
1
1UV
s 0
Tss 0 2
2s 5 5 W
Also seen in time domain as t tends to ꚙ
Unit Step Response y (t ) 1
5 e1 ce cos(2t ) e sin(2t )hj
t 1
2
t
Ramp response y (t ) 1
5 ct e cos(2t ) e sin(2t )h
2
5
2
5
t 3
10
t
MATLAB: Models, Inputs and Responses
For confirmation:
k=dcgain(sys)
k =0.2000
Responses can also be examined in
ltiview-LTI window
ltiview
file -> import -> sys
plot(t2,ram)
Sine response
osc=lsim(sys,sin(10*t2),t2);
plot(t2,osc)
t3=linspace(0,10,101)';
MATLAB: Models, Inputs and Responses
In earlier lectures, it was told that the basic responses
were derived from each other by either derivation or
integration. Now, we see how well this works
numerically
Take the base response as step function and
find out impluse response by derivation and
slope (ramp) response by integration:
The numerical derivative of a step response:
imp2=diff(ste2)./diff(t2);
plot(t2,[0;imp2],t1,imp1)
plot(t2,[ram2 ram])
G ( s ) C( sI A) 1 B D
Often the feedforward term D is zero, in which case the formula is even
simpler to form:
G ( s) C( sI A) 1 B
Example: Mass block
Solving a mass block Unit step response (forced response) using the
transfer function
1
s 1 0
G ( s ) C( sI A) B 1 0
1
1
5 s 2
s 2 1 0
1 0 1
5 s 1
2
s 2s 5
2
s 2s 5
1
U (s)
The response s
1
y (t ) L Y ( s ) L G ( s )U ( s ) L 2
1 1 1
s ( s 2 s 5)
15 1 e t cos(2t ) 12 e t sin(2t )
Models and conversions between them:
Tilojen
DE to SSvalinta
Epälineaarinen
Non Linear Epälineaarinen
Non Linear
Differential Equations State Space
differentiaaliyhtälö tilaesitys
Tilojen
SS to DEeliminointi
Linearisointi
Linearize Linearisointi
Tilojen
DE to SS valinta
Lineaarinen
Linear Differential Lineaarinen
Linear State =eA t Transfer Function
Equations Space
Tilansiirtomatriisi
matrix
differentiaaliyhtälö tilaesitys
Tilojen eliminointi
SS to DE
L{ } L-1 { }
Canonical forms
Kanoniset muodot
Transfer Functions
Siirtofunktio
(Laplace domain
G=C(sI-A)-1 B+D
Todellinen
Real L-1 { } L{ }
systeemi
System
Painofunktio
Time domain eli Tilaesityksen
General State
impulssivaste
impulse response yleinen ratkaisu
Space solution
d/dt
Step
Askelvaste
response
d/dt
Pengervaste
Ramp
response