Beruflich Dokumente
Kultur Dokumente
Diskre@sering
2.orden
Dataverktøy
Analyse/Design
Stabilitets-‐
MathScript
Det
komplekse
plan
analyse
2.
Frekvensrespons
LabVIEW
1.
Systemets
poler
Bodediagram
Det
komplekse
plan
Realisering/
Implementering
Diskre@sering
Reguleringssystem
Asympto'sk
stabilt
system
E.g.
8
bit:
00000000
-‐>
0
…
…
0
1
0
1
0
…
8
bits
have
256
11111111
-‐>
255
different
combina'ons
Resolu@on:
or
levels
Resolu'on:
5V/256=0.0195V
AD
&
DA
Converters
Measurement
Signal
AD Converter
Control
Signal
DA
Converter
Previous Value:
Present Value:
Sampling
Frequency
Sampling
Time
Discrete
Approxima'on
of
the
'me
deriva've
Euler
backward
method:
More Accurate!
Other
methods
are
Zero
Order
Hold
(ZOH),
Tus'n’s
method,
etc.
Discre'za'on
Example
Given
the
following
con'nuous
system:
Students:
Pen
and
paper:
Find
the
difference
equa'on
(discrete
differeni'al
equa'on)
for
this
system.
Discre'za'on
Example
-‐
Solu'ons
Given
the
following
con'nuous
system:
% Model Parameters
a = 0.25;b = 2;
% Simulation Parameters
Ts = 0.1; %s
Tstop = 20; %s
uk = 1; % Step in u
x(1) = 0; % Initial value
% Simulation
for k=1:(Tstop/Ts)
x(k+1) = (1-a*Ts).*x(k) + Ts*b*uk;
end
Students:
% Plot the Simulation Results Implement
and
Simulate
k=0:Ts:Tstop; this
system
in
MathScript
plot (k, x)
grid on
Discre@za@on
in
MathScript
-‐
Alt.
2
% Model Parameters
a = 0.25;
b = 2;
Ts = 0.1; %s
% State-space model
A = [-a];
B = [b];
We
get
the
same
answer
as
in
C = [1];
D = [0];
previous
example!
Students:
model = ss(A,B,C,D) Implement
and
Simulate
model_discrete = c2d(model, Ts, 'forward')
this
system
in
MathScript
step(model_discrete)
Discre'za'on
in
LabVIEW
using
the
Formula
Node
Implemen'ng
dicrete
equa'ons
in
LabVIEW
using
C
syntax
SubVI
Students:
Implement
and
Simulate
this
system
in
LabVIEW
using
a
Formula
Node
and
a
For
Loop.
A
SubVI
could
be
used
to
implement
the
model.
We
will
simulate
the
number
of
bacteria
in
the
jar
aqer
1
hour
(simula'on
period),
assuming
that
ini'ally
there
are
100
bacteria
present
(x(0)).
Set
b=1,
p=0.5.
Set
Ts=0.01s.
Discre'za'on
in
LabVIEW
using
the
Formula
Node
-‐
Solu'ons
SubVI:
Simula'on
Results:
% Continuous System:
A = [0, -Ts; 0, 0];
B = [2*Ts, 0]';
C = [1 0];
D = [0];
ssmodel = ss(A, B, C, D);
figure(1)
step(ssmodel)
% Discrete System:
ssmodel_discete = c2d(ssmodel, Ts, 'forward’)
figure(2)
step(ssmodel_discete)
Students:
Implement
the
system
above
and
find
the
step
response
using
MathScript.
Project
Implement
a
Control
System
for
the
Air
Heater
with
Discrete
Lowpass
Filter
and
PI
Controller
from
Scratch
Implemen'ng
a
Control
System
While
the
real
process
is
con'nuous,
normally
the
Controller
and
the
Filter
is
implemented
in
a
computer.
Air Heater
We
are
going
to
find
discrete
algorithms
for
the
Lowpass
Filter
and
the
PI
Controller
and
implement
them
in
LabVIEW
PC-‐based
Control
System
–
LabVIEW
Example
(HMI/GUI)
Tidsdiskret
(datamaskinbasert)
PID-‐reguleringssløyfe
tk=kTs tk tk t t
Ts
uman Manuell d
ymf ym
Måle- Måleverdi-
omregning
AD Sensor
filter
Målestøy
ymf(tk) Automatiseringsutstyr ym(t)
med mikroprosessor
tk t
Lowpass
Filter
Lowpass
Filter
Transfer
func'on:
Students:
Pen
and
Paper:
Find
the
discrete
algorithm
for
this
filter,
which
can
be
implmented
in
a
programming
language
like
C
or
LabVIEW
Formula
Node
This
gives:
We
use
the
Euler
Backward
method:
Example
of
Implementa'on
Students:
Pen
and
Paper:
Find
the
discrete
algorithm
for
this
PI
controller,
which
can
be
implmented
in
a
programming
language
like
C
or
LabVIEW
Formula
Node
Example
of
Implementa'on
Students:
Implement
a
Discrete
PI
Controller
and
make
sure
to
test
it
properly
Test
of
Discrete
PI
Controller
in
LabVIEW
Note!
Make
sure
to
compare
your
PI
Controller
with
the
built-‐
in
PID
Controller!
Mathema'cal
Model
of
the
Process
Feedback
Node
PC-‐based
Control
System
–
LabVIEW
Example
(Real
process)
Scaling:
1-‐5V
-‐>
20-‐50
degrees
Celsius
SubVI:
E-‐mail:
hans.p.halvorsen@hit.no
Blog:
h[p://home.hit.no/~hansha/
36