Tutorial 2 Complete Tank Measurement Learning Objectives: Modul Praktikum 2 Sistem Kendali Proses
Tutorial 2 Complete Tank Measurement Learning Objectives: Modul Praktikum 2 Sistem Kendali Proses
Learning Objectives
• Description and Tip strip of an element
• While loop iteration number (to be displayed in a numeric indicator on the Front
panel)
• Clock (for showing elapsed time)
• Cluster (for collecting the K and u0 elements into one cluster element)
• Local variable
• Boolean indicator
• Comparison functions
• String indicators
• Chart (which is a continuously updated plot)
• Property node (for configuration the chart)
1
Modul Praktikum 2
Sistem Kendali Proses
2. VI Development
We will add a Description and a Tip strip for the uin element (the simulated measurement
signal):
Open the Property window of the vertical pointer slide of u (right-click on the element, and
select Properties). Open the Documentation tab, and enter the Description and Tip strip text
shown in the figure below.
Resulting program:
2
Modul Praktikum 2
Sistem Kendali Proses
2.2 While loop iteration number (to be displayed in a numeric indicator on the Front Panel)
Figure 4 Iteration
3
Modul Praktikum 2
Sistem Kendali Proses
4
Modul Praktikum 2
Sistem Kendali Proses
5
Modul Praktikum 2
Sistem Kendali Proses
Resulting program:
2.4 Cluster (for collecting the K and u0 elements into one cluster element)
Clusters are elements that contain one or more elements of possibly different data types. We
will create a cluster containing the Gain K element and the Zero u0 element. What are the
benefits of using clusters? On the Front panel clusters visualise groups of elements that are
somehow related, e.g. controller parameters. On the Block diagram clusters may simplify the
code since one cluster wire represents several single wires.
Add an empty cluster from the Array, Matrix & Cluster palette to the Front Panel. The empty
cluster may intermediately be placed anywhere on the Block diagram since we will move it
soon. The figure below shows the Front Panel with an empty cluster.
6
Modul Praktikum 2
Sistem Kendali Proses
7
Modul Praktikum 2
Sistem Kendali Proses
Figure 13 The Front panel with the cluster containing the Gain K and the Zero u0 elements
Now, open the Block diagram, see the figure below. The Cluster_para terminal has been
placed at an more or less arbitrary position.
8
Modul Praktikum 2
Sistem Kendali Proses
Figure 14 The Block diagram with the Cluster_para terminal situated (arbitrarily) below the
Metronome
• Move the Cluster_para terminal to a position upper left in the While loop. It is
essential that the terminal is inside the While loop.
• Add an Unbundle By Name function to the right of the cluster terminal. This function
is on the Cluster & Variant subpalette of the Functions palette.
• Connect the Cluster_para terminal to the Unbundle By Name function.
• Expand the Unbundle By Name function one step down by dragging the bottom
boarder of the function downwards, thereby showing terminals of both K and u0.
• Finally, wire the K element to the Multiply function and the u0 terminal to the
Subtract function.
9
Modul Praktikum 2
Sistem Kendali Proses
We will now add a Boolean indicator in the form of a LED (Light Emitting Diode) which will
be lightening while the VI runs (turn off when the VI stops). Local variables will be used in
the implementation.
Open the block diagram of your VI. Add a True constant and a False constant from the
Boolean subpalette on the Functions palette (see Fig. 19). By clicking a Boolean constant the
value changes from True to False or from False to True.)
Open the front panel of your VI. Add a LED from the Boolean subpalette on the Controls
palette at the position (see Fig. 20a) (the LED labeled Running?). Set the properties of the
LED as follows (in its Property window):
10
Modul Praktikum 2
Sistem Kendali Proses
Note: It may happen that the Caption has a black background color. By double-clicking the
Caption field the background color becomes white.
Open the block diagram of the VI. Locate the Boolean Running? terminal and move it to the
position shown in the figure below. Then wire the True constant to the Running? terminal.
Create a Local variable belonging to the Running? variable (terminal): Right-click on the
Running? terminal / Create Local Variable. Then, place the Local variable just outside the
While loop, and connect it to the False constant, see the figure below.
Note: By default a local variable is readable. You can set it to be writable by right-clicking on
it and then selecting Change to Write in the menu that is opened.
Figure 16 Inserting a Round LED onto Front Panel (Right click > Express > Round LED)
11
Modul Praktikum 2
Sistem Kendali Proses
12
Modul Praktikum 2
Sistem Kendali Proses
Figure 19 Block diagram with a True constant connected to the Running? terminal and a
False constant connected to the Local variable belonging to the Running? terminal (or
variable)
Open the Front panel, and run the VI. Observe that the LED is turned on. Stop the VI, and the
LED should turn off. Resulting program (Front Panel) as in Fig. 20a and Fig. 20b:
13
Modul Praktikum 2
Sistem Kendali Proses
We will implement the alarms. A High Alarm text will be shown on the Font Panel if the
level is greater than 380 mm, and a low Alarm text will be shown if the level is less than 20
mm.
Let’s start by adding String indicators which will be used to display the alarms.
14
Modul Praktikum 2
Sistem Kendali Proses
Hide the indicator: Right click on the element -> Advanced -> Hide Indicator
Repeat the above steps but for the lower String indicator, but enter the string: Alarm: Low
level (<20 mm), and set the label to “Low Alarm”.
15
Modul Praktikum 2
Sistem Kendali Proses
• Create a Property node for the High Alarm element: Right-click on the High Alarm
indicator / Create Property Node / Visible. This opens a list of properties, see the
figure below, in which you select Visible, thereby dropping Property node on the
block diagram.
16
Modul Praktikum 2
Sistem Kendali Proses
A property is either readable or writable. In our case it must be writeable, so that the indicator
will be visible or not visible on the front panel depending on the output of the Greater?
function. Thus, Right-click on the Property node / Select Change to Write.
• Repeat the step above (creating a property node) for the Low Limit indicator.
• Finally, wire the Greater? Function output to the input of the High Alarm Property
Node, and the Less? Function output to the input of the Low Alarm Property Node.
• The resulting program looks like the following figure.
Resulting program:
17
Modul Praktikum 2
Sistem Kendali Proses
Adjust ui such the tank level is less than 20 mm, the Low Alarm String should appear.
LabVIEW has many Virtual Instruments including Charts and Graphs for displaying logged
data. Let’s add a chart to the VI. A chart is a continuously diagram for plotting variables
which time along the a-xis. In our VI the chart will plot three signals:
The level
The high alarm limit, which is 380 mm.
The low alarm limit, which is 20 mm.
Adding a chart:
Right click some where in the Front Panel.
18
Modul Praktikum 2
Sistem Kendali Proses
The chart is found at Controls palette > Modern subpallete > Graph > Waveform Chart
The three signals to be plotted in the chart are collected using a Bundle function in the Block
Diagram . The Bundle function produces a cluster of signals, and this cluster is then wired to
the chart. The relevant resulting part of the Block diagram is shown in the figure below.
You have the following VI (you may rearrange elements in Front Panel):
19
Modul Praktikum 2
Sistem Kendali Proses
Open the Front Panel. The chart has got 3 digital displays. Right click the Chart (named Level
chart), Properties
• In the Appearance tab:
o Label “y_chart”. Invisible. Caption “Level Chart”
o Show digital display(s).
• Scales tab:
o Select Time (x-axis) in the axis list at the top of the page of this lab.
20
Modul Praktikum 2
Sistem Kendali Proses
Grid Style and Colours: Click the Button, and select the option to the
right. (If you want to change the colours of the grid, you can click the
colour buttons.)
21
Modul Praktikum 2
Sistem Kendali Proses
To set the Plot legend (above the diagram, to the right) properly:
• Drag the bottom edge of the Plot legend downwards to expand the legend to show
information for three plots. Move the Plot legend to a proper (nice) position just above
the chart.
• The Plot legend text: Double-click each of the three Plot legend texts areas, and type
the following texts, respectively: "Level y [mm]"; "High Alarm Limit [mm]"; "Low
Alarm Limit [mm]".
• The line colour: Right-click on the display to the right of the text field / Select
Colour. Set a proper colour to each of the three lines.
Open the Front Panel. Run the VI, and play with the uin value. The y-axis has automatic
scaling, which is the default setting. Change to manual scaling while the VI runs by right-
clicking on the chart, and selecting AutoScale Y.
22
Modul Praktikum 2
Sistem Kendali Proses
The chart has an inbuilt data buffer which stores previous (historical) data so that the previous
signal values are shown in the chart. The default length of this buffer is 1024. Thus, at each
instant of time the most 1024 recent samples of the signal are stored in this buffer. In our VI,
with a sampling time of 0.1s and a range of 50s along the x-axis, the buffer must have a
length of 50s/0.1s = 500 samples. Therefore the default buffer length is ok in our case. But in
other cases it may be necessary to increase the buffer length.
To see/set the buffer length: Right-click on the chart / Select Chart History Length, see the
figure below. However, as argued above, it is not necessary for us to change the buffer length,
so you can just close the dialog window.
The Chart History Length can be seen/set via Right-click on the Chart History Length
As an example of programmatic configuration of the chart, we will set the History property of
the Property node of the chart in the Block Diagram so that the chart is emptied as the VI
starts.
Next, we have to ensure that the added code is executed before the While loop starts. This can
be done using a Sequence structure which is in the form of a film strip with frames. Code can
be put into the different frames. The code in the first frame will be executed first, then the
code in the second frame, and so on.
Add a Flat Sequence from the Structures palette (on the Functions palette), and ensure it
embraces the While loop, see the figure below.
Do as follows:
• Add a Flat Sequence Structure from the Structures palette (on the Functions palette or
on Express Vis), label the Flat Sequence Structure. Make the label of the Sequence
Structure visible: Right-click on the border / Visible Items / Label.
• Add one frame before the present single frame: Right-click on the top border of the
frame / Add Frame Before. The Block Diagram looks like the following figure.
23
Modul Praktikum 2
Sistem Kendali Proses
• Open the History property of the Property node as follows: Right-click the y_chart
terminal / Create Property Node / History Data (at the bottom). See the following
figure.
Figure 33 The Property Node with the History Data of the y_chart element
24
Modul Praktikum 2
Sistem Kendali Proses
• Change the History property from readable to writeable: Right-click on the Property
Node / Change to Write. (The arrow then points into the Property node at its left
side.)
• To add a proper constant to the History property node: Right-click on the node /
Create Constant. (The constant automatically becomes a cluster of three empty
arrays (one array for each plot line), causing the History buffer to be emptied.)
• Make the Label of the array entering the Property node visible.
• To save some space, move the array above the Property node, as shown in the figure.
Figure 34 Block diagram with a Flat Sequence Structure and History Data
Open the Front panel, and Run the VI. Adjust the input signal u. Stop the VI, and run it again.
Is the chart emptied at the moment the VI is started, as expected?
25
Modul Praktikum 2
Sistem Kendali Proses
26
Modul Praktikum 2
Sistem Kendali Proses
Conclusions
Exercise
27