0% found this document useful (0 votes)
43 views27 pages

Tutorial 2 Complete Tank Measurement Learning Objectives: Modul Praktikum 2 Sistem Kendali Proses

This document provides instructions for developing a virtual instrument (VI) to measure liquid level in a tank. It describes adding several elements to improve the VI, including: 1. Adding description and tip strips to provide more information about input elements. 2. Displaying the iteration number of the while loop and elapsed time to provide more feedback. 3. Grouping related parameters into a cluster for cleaner organization. 4. Using a boolean indicator and local variable to display running status via an LED. 5. Implementing alarms by comparing level to thresholds and displaying string messages.

Uploaded by

vinca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views27 pages

Tutorial 2 Complete Tank Measurement Learning Objectives: Modul Praktikum 2 Sistem Kendali Proses

This document provides instructions for developing a virtual instrument (VI) to measure liquid level in a tank. It describes adding several elements to improve the VI, including: 1. Adding description and tip strips to provide more information about input elements. 2. Displaying the iteration number of the while loop and elapsed time to provide more feedback. 3. Grouping related parameters into a cluster for cleaner organization. 4. Using a boolean indicator and local variable to display running status via an LED. 5. Implementing alarms by comparing level to thresholds and displaying string messages.

Uploaded by

vinca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Modul Praktikum 2

Sistem Kendali Proses

Tutorial 2 Complete Tank Measurement

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. Explain the objective program

Figure 1 Objective program

1
Modul Praktikum 2
Sistem Kendali Proses

2. VI Development

Save the VI in Tutorial 1 as Level Measurement 02.vi

2.1 Description and Tip strip of an element

Description and Tip strip

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.

Figure 2 Slide Properties

Resulting program:

2
Modul Praktikum 2
Sistem Kendali Proses

Figure 3 Tip strip for the vertical pointer slide

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

Figure 5 Resulting VI with iteration no.

2.3 Clock (for showing elapsed time)

Figure 6 Inserting a clock “Elapsed Time”

4
Modul Praktikum 2
Sistem Kendali Proses

Figure 7 Configure Elapsed Time

Figure 8 Create an Indicator for Elapsed Time

Figure 9 Block Diagram Window

5
Modul Praktikum 2
Sistem Kendali Proses

Resulting program:

Figure 10 the VI with an Indicator of Elapsed Time

Save the VI.

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

Figure 11 Inserting a Cluster

Figure 12 Cluster element in Front Panel

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

Next, do as follows. The final result is shown in Fig. 15.

• 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

Figure 15 Cluster and Unbundle with Name

Save the VI.

2.5 Boolean indicator and Local variable

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

• Label "Running?" (invisible)


• Caption "VI is Running?" (visible)
• Check for Show Boolean Text
• Uncheck for Lock text in center
• On text: "Yes"
• Off text: "No"

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

Figure 17 Setting Boolean properties

Figure 18 Block Diagram: Create > Local Variable

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:

Figure 20a The VI is running

13
Modul Praktikum 2
Sistem Kendali Proses

Figure 20b When the VI stops the LED turns off

Save the VI.

2.6 Comparison functions, String indicators and Property node

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.

Open the Front Panel of Level Measurement.vi


Add two String indicators from the String & Path subpallette. Place them as shown in the
following figure.
For the upper String indicator:

14
Modul Praktikum 2
Sistem Kendali Proses

Figure 21 Inserting two String elements

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”.

• Open the block diagram.


• Add a Greater? function and a Less? function from the Comparison subpalette to the
block diagram.
• Add two numeric constants, and give them values 7 and 1, respectively (by double-
clicking and typing the numbers).
• Wire the various signals to the Greater? function and the Less? function,
respectively.
• Locate the High Alarm indicator and the Low Alarm indicator, and move them inside
the While loop to positions shown in Fig. 23 below.

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.

Figure 22 Create > Property Node > Visible


By Right-clicking on the High Alarm indicator / Create Property Node a list of properties of
the indicator is displayed.

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.

Figure 23 Block Diagram with High Alarm and Low Alarm

Resulting program:

17
Modul Praktikum 2
Sistem Kendali Proses

Figure 24 Visualization of High Alarm

Adjust ui such the tank level is less than 20 mm, the Low Alarm String should appear.

Save the VI.

2.7 Chart (which is a continuously updated plot)

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.

Figure 25 Inserting a Waveform Chart onto Front Panel

You have the following VI (you may rearrange elements in Front Panel):

Figure 26 Front Panel with a Waveform Chart

19
Modul Praktikum 2
Sistem Kendali Proses

• Open the Block Diagram of the VI.


• Move the y_chart terminal to a position shown in Fig. 27.
• Insert a Bundle function from the Cluster & Variants palette, as shown in Fig. 27.
• Expand the Bundle function to have three inputs by dragging the bottom edge of the
function downwards.
• Add two numeric constants from the Numeric palette, and give them values 380 and
20, respectively.
• Wire the output from the Multiply function, which is the level signal, and the two
constants to the Bundle function.
• Wire the Bundle output to the y_chart terminal (which thereby changes colour and
icon, automatically).
• Open the front panel. The chart now has three digital displays. You can move them
outside to the right of the chart. The Block Diagram should look like the following:

Figure 27 Block Diagram with a Waveform Chart (y_chart)

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

Figure 28 Chart properties

ƒ Name: "Time t [s]"


ƒ Scaling factors: Multiplier: 0.1, corresponding to the 0.1 second cycle
time of our program (it is the cycle time of the While loop). (With the
default value of Multiplier of 1, the x-axis increment would be 1, so in
one second the x-axis value would increase by 10, which is not what
we want.)
ƒ Minimum: 0
ƒ Maximum: 20
ƒ Scale Style and Colours: Select as shown in the figure below:

Figure 29 Select Scale Style and Colors

ƒ 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

o Select y-axis in the Scales tab.


ƒ Name: "[mm]".
ƒ 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.)

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.

Figure 30 Front Panel with Waveform Chart (level chart)

22
Modul Praktikum 2
Sistem Kendali Proses

Stop the VI. Save the VI.

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.

Figure 31 Chart History Length

The Chart History Length can be seen/set via Right-click on the Chart History Length

2.8 Programmatic Configuration of the Chart

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.

Save your VI as Level Measurement 0201.vi (if it is still open).

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

Figure 32 Block Diagram with a Flat Sequence Structure

• 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.

The resulting block diagram is shown in the figure below.

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

Figure 35 Waveform Chart with History Data

Figure 36 Block Diagram Window

26
Modul Praktikum 2
Sistem Kendali Proses

Stop the VI. Save the VI.

The END of Tutorial 2

Conclusions

At this point, we are able to use the following:


• 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)

Exercise

Modify the Level Measurement 02.vi for temperature measurement:


The measured signal: 0-5 V
The output signal of temperature transmitter is 4-20 mA
The range of temperature is 0-100 oC.
In your VI, display:
Measured signal (V)
Measured signal in mA
Measured signal in oC
Chart displaying the following:
Temperature in oC
High alarm for 95oC, Low Alarm for 5oC

References and Further Information

Bishop, R.H. (2007). LabVIEW 8 Student Edition. Pearson Education.


Finn Haugen’s website: http://techteach.no/

27

You might also like