Simulation in LabVIEW - Overview
Simulation in LabVIEW - Overview
page=labview
Simula'on in LabVIEW
LabVIEW
Installa'on
Download
the
soIware
here:
h6p://home.hit.no/~hansha/?page=labview
These
are
the
main
modules
we
use
in
the
dierent
courses
at
Telemark
University
College:
LabVIEW
(LabVIEW
Professional
Development
System
32-Bit:
English)
LabVIEW
Control
Design
and
Simula8on
Module
LabVIEW
MathScript
RT
Module
NI-DAQmx
(Hardware
Driver
for
NI
USB-6008,
NI
TC-01,
etc.)
Note!
These
packages
are
separate
downloads!
Make
sure
to
download
and
install
all
of
them!
All
LabVIEW
SoIware
can
be
downloaded
here:
www.ni.com/download
LabVIEW
Training
Here
you
will
nd
lots
of
Videos,
Tutorials
and
Exercises
h6p://ni.com/students/learnlabview
LabVIEW
Course:
h6p://home.hit.no/~hansha/?training=labview
Learning by Doing!
It is recommended that you watch some of the videos before you read furter
Contents
Introduc'on
to
LabVIEW
Installa'on
Block
Diagram
Simula8on
based
on
dieren8al
Equa8ons
Simula8on
Loop
MathScript
Hardware
Air Heater
USB-6008
Wi-Fi
DAQ
Water
Tank
Pt-100
TC-01
Arduino
ZigBee
Vision System
cRIO
NOx
Sensor
LabVIEW
This
is
the
core
LabVIEW
installa'on
that
installs
the
LabVIEW
Programming
Environment.
NI-DAQmx
DAQmx
is
the
Hardware
Driver
needed
in
order
to
use
hardware
devices
like
NI
USB-6008,
NI
TC-01,
etc.
inside
LabVIEW.
The
module
is
available
as
a
pale6e
on
your
block
diagram.
h6p://www.ni.com/pdf/manuals/376039a.pdf
Control
Design
Pale6e
in
LabVIEW
Simula'on
Loop
Dynamic Systems
Air Heater:
Alt 3 (Nonlinear):
4 Tank:
Dynamic
Systems
Dynamic
system
represented
as
a
dieren'al
equa'on
Note
Integrator symbol
When we have the block diagram for the system, we can easily implment it in LabVIEW
Example 2:
Students: Find the block diagrams for the dieren'al equa'ons above (pen & paper)
Example 2:
or:
Students: Find the block diagram for the dieren'al equa'on above (pen & paper)
Simula'on
Tools
MATLAB
Simulink
LabVIEW
MathScript
Modelica
h6ps://www.modelica.org
HYSYS
h6p://www.aspentech.com/products/aspen-hysys.aspx
...
Simula'on in LabVIEW
Simula'on
in
LabVIEW
Simula8on
PaleLe
in
LabVIEW
Simula'on
Example
Dynamic
system
represented
as
a
dieren'al
equa'on
Integrator symbol
Step
Response
Correct
results?
Check
sta'c
response:
Control
System
DeltaV
v
e
r
-
Kp Ti Td
PID
Process
Sensor
Students:
What
is
r,
e,
u,
v,
y,
Kp,
Ti,
Td?
Control
System
e
r
-
Kp Ti Td
PID
Process
Sensor
r
Reference
Value,
SP
(Setpoint),
SV
(Set
Value)
y
Measurement
Value
(MV),
Process
Value
(PV)
e
Error
between
the
reference
value
and
the
measurement
value
(e
=
r
y)
v
Disturbance,
makes
it
more
complicated
to
control
the
process
Kp,
Ti,
Td
PID
parameters
r
-
Kp Ti Td
PID
Sensor
Process
We
will
learn
to
create
this:
Controller
r
-
Kp Ti Td
PID
Sensor
Process
We
will
learn
to
create
this:
Alterna8ve
1:
PID
Pale6e
in
LabVIEW
(PID
Toolkit)
Alterna8ve 2:
This
alterna've
uses
seconds!
Students:
Replace
u
in
the
previous
example
with
the
built-in
PID
Controller
(use
Alterna've
2)
Students:
Find
proper
Kp,
Ti,
Td
Parameters
for
this
system.
Use
Trial
and
Error
or
one
of
the
methods
explained
in
the
Text
Book
Simula'on
Subsystem
A
Way
to
structure
your
code,
similar
to
SubVIs
Students:
Change
your
code
above
where
you
create
a
Simula'on
Sub
System
for
your
Process
Students:
Change
your
code
above
where
you
create
a
Simula'on
Sub
System
for
the
PID
Controller
as
well.
Students:
Add
your
Controller
and
Process
Subsystems
inside
a
While
loop
as
shown
above.
Simulate
the
system.
Do
you
get
the
same
results?
Recommended Seungs
Datalogging Example
Students:
(1)
Log
Data
from
your
system,
i.e.,
the
Control
Signal
(u)
and
the
output
of
the
process
(y)
to
a
Measurement
File.
(2)
Then
Plot
the
Data
from
the
File
in
Excel.
Discrete Systems
Con8nuous Signal
Discret
Signal
Note!
Dierent
books
use
dierent
nota'ons
Ts
=
Sampling
Time
When
Ts
->
0,
we
have
a
con'nuous
signal,
but
in
a
computer
that
is
not
possible.
k
=
0,
1,
2,
3,
4,
....
Example
Discre'za'on
Ts Sampling Time
Then we get:
Formula Node/MathScript
Example
Ts Sampling Time
Then we get:
xk1=(1-a*Ts)*xk + Ts*b*uk;
As
expected,
we
get
the
same
results
as
in
the
previous
example
using
a
block
diagram
simula'on
SubVI
Main VI
MathScript
LabVIEW
MathScript
RT
Module
MathScript
Simula'on
Example
MathScript
Node
Students:
Try
the
same
example
inside
LabVIEW
using
the
MathScript
Node
Just
copy
and
paste
the
code
from
the
previous
example
LabVIEW
Course
Simula'on
in
LabVIEW
PDF
File
available
for
download
h6p://home.hit.no/~hansha/?training=labview
Students:
Read
the
Course
Manual
and
do
the
Exercises
(as
many
as
possible)
in
the
Course
Manual
on
your
own.
Note!
Solu'ons
with
cource
code
for
all
the
exercises
are
located
on
the
web
page
Mass-Spring-Damper System
h6p://www.techteach.no/simview/mass_spring_damper/index.php
Students:
Simulate
this
system
using
LabVIEW.
Plot
the
posi'on,
speed
and
the
accellera'on.
Test
with
dierent
values
on
m,
k
and
d.
Control
Signal
Air tube
Temperature
Measurement
Heater
TC
TT
Air In
Air Out
Where:
% Model Parameters
a = 0.25;b = 2;
% Simulation Parameters
Ts = 0.1; %s
Tstop = 20; %s
uk = 1;
x(1) = 0;
% Simulation
for k=1:(Tstop/Ts)
x(k+1) = (1-a*Ts).*x(k) + Ts*b*uk;
end
% Plot the Simulation Results
k=0:Ts:Tstop;
plot (k, x)
grid on
E-mail:
[email protected]
Blog:
hLp://home.hit.no/~hansha/
65