Sunteți pe pagina 1din 40

EE392m - Winter 2003 Control Engineering 2-1

Lecture 2 - Modeling and Simulation


Model types: ODE, PDE, State Machines, Hybrid
Modeling approaches:
physics based (white box)
input-output models (black box)
Linear systems
Simulation
Modeling uncertainty
EE392m - Winter 2003 Control Engineering 2-2
Goals
Review dynamical modeling approaches used for control
analysis and simulation
Most of the material us assumed to be known
Target audience
people specializing in controls - practical
EE392m - Winter 2003 Control Engineering 2-3
Modeling in Control Engineering
Control in a
system
perspective
Physical system
Measurement
system
Sensors
Control
computing
Control
handles
Actuators
Physical
system
Control analysis
perspective
Control
computing
System model
Control
handle
model
Measurement
model
EE392m - Winter 2003 Control Engineering 2-4
Models
Model is a mathematical representations of a system
Models allow simulating and analyzing the system
Models are never exact
Modeling depends on your goal
A single system may have many models
Always understand what is the purpose of the model
Large libraries of standard model templates exist
A conceptually new model is a big deal
Main goals of modeling in control engineering
conceptual analysis
detailed simulation
EE392m - Winter 2003 Control Engineering 2-5
) , , (
) , , (
t u x g y
t u x f x
=
=
&
Modeling approaches
Controls analysis uses deterministic models. Randomness and
uncertainty are usually not dominant.
White box models: physics described by ODE and/or PDE
Dynamics, Newton mechanics
Space flight: add control inputs u and measured outputs y
) , ( t x f x =
&
EE392m - Winter 2003 Control Engineering 2-6
v r
t F
r
r
m v
pert
=
+ =
&
&
) (
3

Orbital mechanics example


Newtons mechanics
fundamental laws
dynamics
(
(
(
(
(
(
(

=
3
2
1
3
2
1
v
v
v
r
r
r
x ) , ( t x f x =
&
Laplace
computational dynamics
(pencil & paper computations)
deterministic model-based
prediction
1749-1827
1643-1736
r
v
EE392m - Winter 2003 Control Engineering 2-7
Orbital mechanics example
Space flight mechanics
Control problems: u - ?
(
(
(
(
(
(
(

=
3
2
1
3
2
1
v
v
v
r
r
r
x
) , , (
) , , (
t u x g y
t u x f x
=
=
&
(

=
) (
) (
r
r
y

v r
t u t F
r
r
m v
pert
=
+ + =
&
&
) ( ) (
3

Thrust
state
model
observations /
measurements
control
EE392m - Winter 2003 Control Engineering 2-8
Gene
expression
model
EE392m - Winter 2003 Control Engineering 2-9
) , , (
) , , ( ) (
t u x g y
t u x f d t x
=
= +
Sampled Time Models
Time is often sampled because of the digital computer use
computations, numerical integration of continuous-time ODE
digital (sampled time) control system
Time can be sampled because this is how a system works
Example: bank account balance
x(t) - balance in the end of day t
u(t) - total of deposits and withdrawals that day
y(t) - displayed in a daily statement
Unit delay operator z
-1
: z
-1
x(t) = x(t-1)
( ) kd t t u x f d t x d t x = + + ), , , ( ) (
x y
t u t x t x
=
+ = + ) ( ) ( ) 1 (
EE392m - Winter 2003 Control Engineering 2-10
Finite state
machines
TCP/IP State Machine
EE392m - Winter 2003 Control Engineering 2-11
Hybrid systems
Combination of continuous-time dynamics and a state machine
Thermostat example
Tools are not fully established yet
off on
72 = x
75 = x
70 = x
70
=
x
Kx x&
75
) (

=
x
x x h K x&
EE392m - Winter 2003 Control Engineering 2-12
PDE models
Include functions of spatial variables
electromagnetic fields
mass and heat transfer
fluid dynamics
structural deformations
Example: sideways heat equation
1
2
2
0 ) 1 ( ; ) 0 (
=

=
= =

x
x
T
y
T u T
x
T
k
t
T
y
heat flux
x
T
outside
=0
T
inside
=u
EE392m - Winter 2003 Control Engineering 2-13
Black-box models
Black-box models - describe P as an operator
AA, ME, Physics - state space, ODE and PDE
EE - black-box,
ChE - use anything
CS - state machines, probablistic models, neural networks
P
x
u
input data
y
output data
internal state
EE392m - Winter 2003 Control Engineering 2-14
Linear Systems
Impulse response
FIR model
IIR model
State space model
Frequency domain
Transfer functions
Sampled vs. continuous time
Linearization
EE392m - Winter 2003 Control Engineering 2-15
Linear System (black-box)
Linearity
Linear Time-Invariant systems - LTI
) ( ) (
1 1
y u
P
) ( ) ( T y T u
P

) ( ) ( ) ( ) (
2 1 2 1
+ + by ay bu au
P
) ( ) (
2 2
y u
P

P
u
t
y
t
EE392m - Winter 2003 Control Engineering 2-16
Impulse response
Response to an input impulse
Sampled time: t = 1, 2, ...
Control history = linear combination of the impulses
system response = linear combination of the impulse responses
( ) ) ( * ) ( ) ( ) (
) ( ) ( ) (
0
0
t u h k u k t h t y
k u k t t u
k
k
= =
=

) ( ) ( h
P

u
t
y
t
EE392m - Winter 2003 Control Engineering 2-17
Linear PDE System Example
Heat transfer equation,
boundary temperature input u
heat flux output y
Pulse response and step response
0
0.2
0.4
0.6
0.8
1 0
0.2
0.4
0.6
0.8
1
0
0.2
0.4
0.6
0.8
1
TIME
TEMPERATURE
COORDINATE
0 ) 1 ( ) 0 (
2
2
= =

T T u
x
T
k
t
T
1 =

=
x
x
T
y
0 20 40 60 80 100
0
2
4
6
x 10
-2
TIME
H
E
A
T

F
L
U
X
PULSE RESPONSE
0 20 40 60 80 100
0
0.2
0.4
0.6
0.8
1
TIME
H
E
A
T

F
L
U
X
STEP RESPONSE
EE392m - Winter 2003 Control Engineering 2-18
FIR model
FIR = Finite Impulse Response
Cut off the trailing part of the pulse response to obtain FIR
FIR filter state x. Shift register
) , (
) , ( ) 1 (
u x g y
u x f t x
=
= +
h
0
h
1
h
2
h
3
u(t)
x
1
=u(t-1)
y(t)
x
2
=u(t-2)
x
3
=u(t-3)
z
-1
z
-1
z
-1
( ) ) ( * ) ( ) ( ) (
0
t u h k u k t h t y
FIR
N
k
FIR
= =

=
EE392m - Winter 2003 Control Engineering 2-19
IIR model
IIR model:
Filter states: y(t-1), , y(t-n
a
), u(t-1), , u(t-n
b
)

= =
+ =
b a
n
k
k
n
k
k
k t u b k t y a t y
0 1
) ( ) ( ) (
u(t)
b
0
b
1
b
2
u(t-1)
u(t-2)
u(t-3)
z
-1
z
-1
z
-1
-a
1
-a
2
y(t-1)
y(t-2)
y(t-3)
z
-1
z
-1
z
-1
y(t)
b
3
-a
3
EE392m - Winter 2003 Control Engineering 2-20
IIR model
Matlab implementation of an IIR model: filter
Transfer function realization: unit delay operator z
-1
( ) ( ) ) ( ... ) ( ... 1
...
...
... 1
...
) (
) (
) (
) ( ) ( ) (
) (
1
1 0
) (
1
1
1
1
1
1 0
1
1
1
1 0
t u z b z b b t y z a z a
a z a z
b z b z b
z a z a
z b z b b
z A
z B
z H
t u z H t y
z B
N
N
z A
N
N
N
N N
N
N N
N
N
N
N
4 4 4 4 3 4 4 4 4 2 1 4 4 4 3 4 4 4 2 1



+ + + = + + +
+ + +
+ + +
=
+ + +
+ + +
= =
=
FIR model is a special case of an IIR with A(z) =1 (or z
N
)
EE392m - Winter 2003 Control Engineering 2-21
IIR approximation example
Low order IIR approximation of impulse response:
(prony in Matlab Signal Processing Toolbox)
Fewer parameters than a FIR model
Example: sideways heat transfer
pulse response h(t)
approximation with IIR filter a = [a
1
a
2
], b=[b
0
b
1
b
2
b
3
b
4
]
0 20 40 60 80 100
0
0.02
0.04
0.06
TIME
IMPULSE RESPONSE
2
2
1
1
4
4
3
3
2
2
1
1 0
1
) (


+ +
+ + + +
=
z a z a
z b z b z b z b b
z H
EE392m - Winter 2003 Control Engineering 2-22
Linear state space model
Generic state space model:
LTI state space model
another form of IIR model
physics-based linear system model
Transfer function of an LTI model
defines an IIR representation
Matlab commands for model conversion: help ltimodels
( ) [ ]
( ) D B A Iz z H
u D B A Iz y
+ =
+ =

1
1
) (
) ( ) ( ) (
) ( ) ( ) 1 (
t Du t Cx t y
t Bu t Ax t x
+ =
+ = +
) , , (
) , , ( ) 1 (
t u x g y
t u x f t x
=
= +
EE392m - Winter 2003 Control Engineering 2-23
Frequency domain description
Sinusoids are eigenfunctions of an LTI system:
LTI
Plant
t i i t i t i
e e e e z

= =
) 1 ( 1
Frequency domain analysis
u z H y ) ( =

= =


d e u e H y d e u u
t i
y
i t i
43 42 1
) (
~
) (
~
) ( ) (
~
) (
~

u
e
t i
u
Packet
of
sinusoids
) (
~

y
e
t i
Packet
of
sinusoids
) (
i
e H
y
EE392m - Winter 2003 Control Engineering 2-24
Frequency domain description
Bode plots:
t i i
t i
e e H y
e u

) ( =
=
Example:

) ( arg ) (
) ( ) (

i
i
e H
e H M
=
=
7 . 0
1
) (

=
z
z H
Bode Diagra m
Frequency (rad/sec)
P
h
a
s
e

(
d
e
g
)
M
a
g
n
i
t
u
d
e

(
d
B
)
-5
0
5
10
15
10
-2
10
-1
10
0
-180
-135
-90
-45
0
|H| is often measured
in dB
EE392m - Winter 2003 Control Engineering 2-25
Black-box model from data
Linear black-box model can be determined from the data,
e.g., step response data
This is called model identification
Lecture 8
EE392m - Winter 2003 Control Engineering 2-26
z-transform, Laplace transform
Formal description of the transfer function:
function of complex variable z
analytical outside the circle |z|r
for a stable system r 1
k
k
z k h z H

=
0
) ( ) (
Laplace transform:
function of complex variable s
analytical in a half plane Re s a
for a stable system a 1


= dt e t h s H
st
) ( ) (
) (

) ( ) (

s u s H s y =
EE392m - Winter 2003 Control Engineering 2-27
Stability analysis
Transfer function poles tell you everything about stability
Model-based analysis for a simple feedback example:
) (
) (
d
y y K u
u z H y
=
=
d d
y z L y
K z H
K z H
y ) (
) ( 1
) (
=
+
=
If H(z) is a rational transfer function describing an IIR
model
Then L(z) also is a rational transfer function describing an
IIR model
EE392m - Winter 2003 Control Engineering 2-28
Poles and Zeros <=> System
not quite so!
Example:
7 . 0
) (

= =
z
z
u z H y
19
17 18 19
00114 0 001628 0 ... 49 0 7 . 0
) (
z
. z . z . z z
u z H y
FIR
+ + + + +
= =
Impulse Re sponse
Time (sec)
A
m
p
l
i
t
u
d
e
0 5 10 15 20 25
0
0.2
0.4
0.6
0.8
1
Impulse Re sponse
Time (sec)
A
m
p
l
i
t
u
d
e
0 5 10 15 20 25
0
0.2
0.4
0.6
0.8
1
FIR model - truncated IIR
EE392m - Winter 2003 Control Engineering 2-29
IIR/FIR example - contd
Feedback control:
Closed loop:
) ( ) (
7 . 0
) (
d d
y y y y K u
z
z
u z H y
= =

= =
Impulse Re sponse
Time (sec)
A
m
p
l
i
t
u
d
e
0 5 10 15 20 25
0
0.2
0.4
0.6
0.8
u z L u
z H
z H
y ) (
) ( 1
) (
=
+
=
u z L u
z H
z H
y
FIR
FIR
FIR
) (
) ( 1
) (
=
+
=
EE392m - Winter 2003 Control Engineering 2-30
-0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
IIR/FIR example - contd
Poles and zeros
Blue: Loop
with IIR
model poles x
and zeros o
Red: Loop
with FIR
model poles x
and zeros o
EE392m - Winter 2003 Control Engineering 2-31
LTI models - summary
Linear system can be described by impulse response
Linear system can be described by frequency response =
Fourier transform of the impulse response
FIR, IIR, State-space models can be used to obtain close
approximations of a linear system
A pattern of poles and zeros can be very different for a
small change in approximation error.
Approximation error <=> model uncertainty
EE392m - Winter 2003 Control Engineering 2-32
Nonlinear map linearization
Nonlinear - detailed
model
Linear - conceptual
design model
Static map, gain
range, sector
linearity
Differentiation,
secant method
) ( ) (
0
u u
u
f
u f y

=
EE392m - Winter 2003 Control Engineering 2-33
Nonlinear state space model
linearization
Linearize the r.h.s. map
Secant method
Or capture a response to small step and build an
impulse response model
Bv Aq q
u u
u
f
x x
x
f
u x f x
v q
+ =

=
&
43 42 1 43 42 1
&
) ( ) ( ) , (
0 0
{
] 0 ... 1 ... 0 [
) (
# j
j
j
j
j
s
s
s x f
x
f
=
+
=
(

EE392m - Winter 2003 Control Engineering 2-34


Sampled time vs. continuous time
Continuous time analysis (Digital implementation of
continuous time controller)
Tustins method = trapezoidal rule of integration for
Matched Zero Pole: map each zero and a pole in accordance with
Sampled time analysis (Sampling of continuous signals
and system)
|
|
.
|

\
|
+

= =

1
1
1
1 2
) ( ) (
z
z
T
s H z H s H
s
s
s H
1
) ( =
sT
e s =
EE392m - Winter 2003 Control Engineering 2-35
Sampled and continuous time
Sampled and continuous time together
Continuous time physical system + digital controller
ZOH = Zero Order Hold
Sensors
Control
computing
Actuators
Physical
system
D/A, ZOH A/D, Sample
EE392m - Winter 2003 Control Engineering 2-36
Signal sampling, aliasing
Nyquist frequency:

N
=
S
;
S
= 2/T
Frequency folding: k
S
map to the same frequency
Sampling Theorem: sampling is OK if there are no frequency
components above
N
Practical approach to anti-aliasing: low pass filter (LPF)
Sampledcontinuous: impostoring
Digital
computing
D/A, ZOH A/D, Sample
Low
Pass
Filter
Low
Pass
Filter
EE392m - Winter 2003 Control Engineering 2-37
Simulation
ODE solution
dynamical model:
Euler integration method:
Runge-Kutta: ode45 in Matlab
Can do simple problems by integrating ODEs
Issues:
mixture of continuous and sampled time
hybrid logic (conditions)
state machines
stiff systems, algebraic loops
systems integrated out of many subsystems
large projects, many people contribute different subsystems
) , ( t x f x =
&
( ) t t x f d t x d t x ), ( ) ( ) ( + = +
EE392m - Winter 2003 Control Engineering 2-38
Simulation environment
Block libraries
Subsystem blocks
developed independently
Engineered for developing
large simulation models
Supports code generation
Simulink by Mathworks
Matlab functions and analysis
Stateflow state machines
Ptolemeus -
UC Berkeley
EE392m - Winter 2003 Control Engineering 2-39
Model block development
Look up around for available conceptual models
Physics - conceptual modeling
Science (analysis, simple conceptual abstraction) vs.
engineering (design, detailed models - out of simple blocks)
EE392m - Winter 2003 Control Engineering 2-40
Modeling uncertainty
Modeling uncertainty:
unknown signals
model errors
Controllers work with real systems:
Signal processing: data algorithm data
Control: algorithms in a feedback loop with a real system
BIG question: Why controller designed for a model would
ever work with a real system?
Robustness, gain and phase margins,
Control design model, vs. control analysis model
Monte-Carlo analysis - a fancy name for a desperate approach

S-ar putea să vă placă și