Solutions - Control and Simulation in LabVIEW
Solutions - Control and Simulation in LabVIEW
→ Solutions
Faculty of Technology, Postboks 203, Kjølnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01
Table of Contents
Table of Contents .....................................................................................................................................ii
2 Simulation in LabVIEW.................................................................................................................... 9
ii
1 Differential Equations and
Block Diagrams
1.1 1. Order systems
→ Draw a block diagram for the system using pen and paper.
Solutions:
→ Draw a block diagram for the system using pen and paper
Solutions:
3
4 Differential Equations and Block Diagrams
[End of Task]
̈ ̇
→ Draw a block diagram for the system using pen and paper.
is the position
̇ is the speed
̈ is the acceleration
[End of Task]
Solutions:
We do the following:
̈ [ ̇ ]
→ Draw a block diagram for the system using pen and paper
Solutions:
x2 x1
1 1 y
a2
u s - s
- -
a1
̇
[ ] [ ][ ] [ ]
̇
→ Draw the block diagram for this model using pen and paper.
Solutions:
u x1 x2
1 1
6 2
s s
-
Draw the block diagram for this simplified model using pen and paper
Solutions:
̇
[ ] [ ][ ] [ ]
̇
[ ][ ]
becomes:
[End of Task]
In this task we will use LabVIEW and the LabVIEW Control Design and Simulation Module to simulate
a simple model of a bacteria population in a jar.
birth rate=bx
We will simulate the number of bacteria in the jar after 1 hour, assuming that initially there are 100
bacteria present.
[End of Task]
Solutions:
9
10 Simulation in LabVIEW
See “Differential equations represented as block diagrams” for more information about creating
block Diagrams.
Below you see the “Control and Simulation Loop” and different blocks that may be used in this
simulation:
Use “LabVIEW Control Design and Simulation Module” and the “Control and Simulation
Loop” in order to create a simulation of a spring-mass damper system.
̈ ̇
Where.
m is a mass
̇ is the first derivative of the position, which equals the velocity of the mass
̈ is the second derivative of the position, which equals the acceleration of the mass
Note! Draw a block diagram of the system using pen and paper before you implement the system in
LabVIEW.
[End of Task]
Solutions:
See the video “Simulation Palette Overview” by Finn Haugen for a step-by-step instructions or read
the Tutorial “Control and Simulation in LabVIEW” for step-by-step instructions.
Block Diagram:
LabVIEW:
Block Diagram:
Front Panel:
In this task you will use the example “General PID Simulator.vi” as a base for your simulation. Use
the “NI Example Finder” (Help → Find Examples…) in order to find the VI in LabVIEW.
Make changes to the program (make sure to save it with another name) and use the “PID
Advance.vi” function instead.
Note that and is in minutes, while it’s normal to use seconds as the unit for these
parameters. So it is recommended that you do like this in your code:
15
16 PID Control in LabVIEW
Try with different values for , and and see what happens.
[End of Task]
Solutions:
Front Panel:
PID Parameters:
16
17 PID Control in LabVIEW
Block Diagram:
17
4 Additional Tasks
Task 7: Simulation Loop
̇ √
where is the input (control value), is the output (level), is the valve outflow parameter,
and is the pump inflow parameter.
→ Create an application where you use “LabVIEW Control Design and Simulation Module” and the
“Control and Simulation Loop” in order to simulate the system. Here you will use the simulation
blocks from the Simulation palette in LabVIEW to create a continuous model.
[End of Task]
Solutions:
Block Diagram:
Front Panel:
18
19 Additional Tasks
Task 8: Discretization
̇ √
→ Create a new application in LabVIEW where you Simulate the model using a Formula Node to
implement the discrete model.
Use one of Eulers Discretization methods in order to create a discrete model of the system. Which of
Eulers methods did you use? Why?
Use a While Loop or a For Loop and select a proper time-step for the simulation. Use the same
settings and values as in the previous case.
→ Compare the results from the 2 different methods used above. Do you get the same results?
Example:
19
20 Additional Tasks
[End of Task]
Solutions:
Discretization:
̇ √
This gives:
[ √ ]
20
21 Additional Tasks
Block Diagram:
Front Panel:
Control the system created above using a discrete PI controller that you create yourself.
21
22 Additional Tasks
[End of Task]
Solutions:
Discretization:
Given:
22
23 Additional Tasks
23
24 Additional Tasks
Block Diagram:
Front Panel:
24
25 Additional Tasks
Front Panel:
Block Diagram:
25
5 PID Control on real
process
Create a PID Control system for a real process.
Documents of how to use the Level Tank/Air Heater and the USB-6008 DAQ device is
available from http://home.hit.no/~hansha.
Find proper PID parameters. Use, e.g., Skogestad’s method in order to find PID parameters.
Skogestad’s method:
26
27 PID Control on real process
You need to apply a step on the input (u) and then observe the response and the output, as shown
below:
Here are the Skogestad’s formulas for finding the PID parameters:
[ ]
For more details about the Skogestads method, please read this article: “Model-based PID tuning
with Skogestad’s method”.
[End of Task]
27
28 PID Control on real process
Solutions:
[ ]
Gain:
28
29 PID Control on real process
With we get:
Time-delay:
Time constant:
[ ] [ ]
29
30 PID Control on real process
Here are some values that worked fine for me from another assignment:
Block Diagram:
30
31 PID Control on real process
Front Panel:
31
Telemark University College
Faculty of Technology
Kjølnes Ring 56
www.hit.no
E-mail: [email protected]
Blog: http://home.hit.no/~hansha/
Room: B-237a