You are on page 1of 7

Kingdom of Saudi Arabia

‫اﻟﻤــﻤـــــــــﻠﻜــــﺔ اﻟﻌـﺮﺑﯿﺔ اﻟﺴــــــﻌﻮدﯾﺔ‬


Royal Commission at Yanbu
Colleges & Institutes Division ‫اﻟـــــــﮭـــــــــــﯿـــــﺌﺔ اﻟﻤﻠــــــﻜـــــــﯿﺔ ﺑــﯿﻨﺒﻊ‬
‫ﻗــــﻄـــﺎع اﻟـﻜــــــــــــﻠــﯿﺎت واﻟـﻤــﻌــﺎھـﺪ‬
Yanbu University College ‫ﻛـــــﻠﯿﺔ ﯾﻨﺒﻊ اﻟﺠــــــــــــــــﺎﻣـــــــــــﻌﯿﺔ‬
Computer Science & Engineering Dept. ‫ﻗﺴﻢ ﻋﻠﻮم وھﻨﺪﺳﺔ اﻟﺤﺎﺳﺐ اﻷﻟﻲ‬
Information & Computer Technology Dept. ‫ﻗﺴﻢ ﺗﻘﻨﯿﺔ اﻟﻤﻌﻠﻮﻣﺎت واﻟﺤﺎﺳﺐ اﻵﻟﻲ‬
LAB 5

ACADEMIC YEAR 1439/1440 H (2018/2019 G), SEMESTER II (182)

MICROCOMPUTER INTERFACING &


DATA ACQUISITION
CSE471
START TIME: 8:15 AM
DATE: Tuesday, 12 February, 2019
FINISH TIME: 10:05 AM

STUDENT NAME: _________________________________________________________

STUDENT ID: SECTION: 1

FOR INSTRUCTOR USE ONLY GENERAL INSTRUCTIONS

MAX MARKS
Q. No. CLOs
MARK OBTAINED

1
2
3
4
5
6
7

TOTAL MARKS

MARKED BY: Signature:

CHECKED BY: Signature:


LAB MANUAL
LAB EXPERIMENT - 05: STRINGS AND PROPERTY NODES IN LABVIEW

STRINGS AND PROPERTY NODES IN LABVIEW

PERFORMANCE OBJECTIVES:
Upon completion of this laboratory exercise, the student technicians/engineers will be able to:
1. Perform operations related to ASCII data using strings
2. Change front panel objects programmatically using property nodes.

EQUIPMENT:

1 LABVIEW equipped PC
DISCUSSION:
STRING

Figure 5.1 LABVIEW representation of a string.

A string is a sequence of displayable or non-displayable ASCII characters. Strings provide a


platform-independent format for information and data. Some of the more common applications
of strings include the following:
• Creating simple text messages.
• Passing numeric data as character strings to instruments and then converting the strings
back to numeric.
• Storing numeric data to disk. To store numeric data in an ASCII file, numeric are
converted to strings before writing the numeric data to a disk file.
• Instructing or prompting the user with dialog boxes.
On the front panel, strings appear as tables, text entry boxes, and labels. Edit and manipulate
strings uses the String functions on the block diagram. Strings are formatted for use in other
applications, such as word processing applications and spreadsheets, or for use within other VIs
and functions.

Figure 5.2 String Sub palette

CSE 471 – MICROCOMPUTER INTERFACING & DATA ACQUISITION


1
LAB MANUAL
LAB EXPERIMENT - 05: STRINGS AND PROPERTY NODES IN LABVIEW

Located on the Functions » String palette strings can be used in the following ways:
a. Search for, retrieve, and replace characters or substrings within a string.
b. Change all text in a string to upper case or lower case.
c. Find and retrieve matching patterns within a string.
d. Retrieve a line from a string.
e. Rotate and reverse text within a string.
f. Concatenate two or more strings.
g. Delete characters from a string.
To use data in another VI, function, or application, the data must be converted to a string and
then formatted the string in a way that the VI, function, or application can read. For example,
Microsoft Excel expects strings that include delimiters, which Excel uses to segregate numbers
or words into cells. For example, to write a 1D array of numeric to a spreadsheet using the
Write File function, the array must be formatted into a string and each numeric must be
separated with a delimiter, such as a tab. To write an array of numeric to a spreadsheet
using the Write to Spreadsheet File VI, one must format the array with the Array to
Spreadsheet String function and specify a format and a delimiter. Using the string functions
located on the Functions » String palette the following tasks can be performed:
a. Concatenate two or more strings.
b. Extract a subset of strings from a string.
c. Convert data into strings.
d. Format a string for use in a word processing or spreadsheet application.
PROPERTY NODE

Figure 5.3 Representation of a Property Node


Property node is used to get and set various properties on an application or VI. The properties
can be selected either by using the operating tool or just by right-clicking the white area of the
node and selecting Properties from the shortcut menu. Multiple properties can be read or write
using a single node. Using Positioning tool a property node can be resized hence it provides
space to add new terminals. A small direction arrow to the right of the property indicates a
property being read. A small direction arrow to the left of the property indicates a property that
is written. The operation of the property can be changed by right-clicking the property and
selecting Change to Read or Change to Write from the shortcut menu. The node executes
from top to bottom. The property node does not execute if an error occurs before it is executed,
therefore the possibility of errors must be checked before. If an error occurs in a property,
LABVIEW ignores the remaining properties and returns an error. The error out cluster contains
information about which property caused the error.
IMPLICITLY LINKED PROPERTY NODES
To create a Property Node from a front panel, the object must be right-clicked and Create »
Property Node from the shortcut menu must be selected. LABVIEW then creates a property
node on the block diagram that is implicitly linked to the front panel object. Because these
property nodes are implicitly linked to the object from which they were created, therefore they
have no refnum input, and require no wire from the property node to the terminal of the front
panel object or to the control refnum.

YANBU UNIVERSITY COLLEGE


2
LAB MANUAL
LAB EXPERIMENT - 05: STRINGS AND PROPERTY NODES IN LABVIEW

TASK-1
STRING VI
Perform the following steps to build a VI that converts a numeric to a string, concatenates the
string to other strings to form a single output string, and determines the output string length. The
VI also matches a pattern in a string and converts the remaining string to a numeric.
PROCEDURE:
1. Open a new VI and build the following front panel.
a. Right-click String 2 and select ‘\’ Codes Display from the shortcut menu.
b. Change String Length and Offset Past Match to I32 representation.

Figure 5.4 Front Panel for Task 1.

2. Build the following block diagram.


a. Place the Format Into String function located on the Functions » String palette. This
function converts Numeric to a string.
b. Right-click the Format Into String function and select Edit Format String from the
shortcut menu to display the Edit Format String dialog box.
c. Place a checkmark in the Use specified precision checkbox and type 4 in the
corresponding text box to create a format string that converts Numeric to a string with
four digits after the decimal point.
d. Click the OK button. LABVIEW creates a format string of %.4f using the options you
selected.
e. Use the Labeling tool to type a space on either side of the %.4f constant and press the
<Shift-Enter> keys so Numeric will appear with spaces on either side in Combined
String.
f. Right-click the constant and select ‘\’ Codes Display from the shortcut menu. The spaces
you typed change to \s.
g. Place the Concatenate Strings function located on the Functions » String palette. This
function concatenates input strings into a single output string.
h. Place the String Length function located on the Functions » String palette. This function
returns the number of characters in Combined String.
i. Place the Match Pattern function located on the Functions » String palette. This function
searches String 2 for a colon.

CSE 471 – MICROCOMPUTER INTERFACING & DATA ACQUISITION


3
LAB MANUAL
LAB EXPERIMENT - 05: STRINGS AND PROPERTY NODES IN LABVIEW

j. Right-click the regular expression input terminal, select Create » Constant from the
shortcut menu, type a colon (:), and press the <Shift-Enter> keys.
k. Place the Scan from String function located on the Functions » String palette. This
function converts the string after the colon to a numeric.

Figure 5.6 Block Diagram of Task 1


3. Save the VI as Build String.vi.
4. Change the values of the front panel controls and run the VI. The VI concatenates Header,
Numeric, and Trailer into Combined String and displays the string length. The VI also
searches String 2 for a colon, converts the string following the colon to Numeric Out, and
displays the index of the first character after the colon in Offset Past Match.
5. Save and close the VI.

YANBU UNIVERSITY COLLEGE


4
LAB MANUAL
LAB EXPERIMENT - 05: STRINGS AND PROPERTY NODES IN LABVIEW

TASK-2
PROPERTY NODE EXERCISE VI
In this students will build a VI that programmatically changes the position, disable color
properties of front panel objects.

Figure 5.7 Front Panel of Task 2


PROCEDURE:
1. Open a new VI and build the following front panel and block diagram.
2. Save this VI as Property Node Exercise.vi.
3. Return to the front panel and run the VI.
4. Several things should be happening. First, as new random numbers are generated and written
to the tank, the fill color is red if the random value is greater than the Limit value and the
color is blue if the random value is less than the Limit.
5. The two sliders change the position of the tank on the panel. Move these values and see how
the tank moves.
6. The Disable switch controls whether you can change the values. Flip the Disable switch to
True and all the panel objects except the Disable switch and the Stop button are grayed out
and you cannot change their values.
7. Stop and close this VI when you are finished.

Figure 5.8 Block Diagram of solution Task 2

CSE 471 – MICROCOMPUTER INTERFACING & DATA ACQUISITION


5
LAB MANUAL
LAB EXPERIMENT - 05: STRINGS AND PROPERTY NODES IN LABVIEW

REVIEW QUESTIONS
1. For each string given below, indicate the display type.

2. How do you access a file through a dialog box?

3. In the following property node, in what order will the node be executed?

FINAL CHECKLIST
All the students must make sure, before they leave the Lab:
1. Clean your equipment, materials, and work benches before you leave.
2. Return all equipment and materials to their proper storage area.
3. Submit your lab report and answers to the questions, together with your data,
calculations (if any) and results before the next laboratory sessions.

YANBU UNIVERSITY COLLEGE


6

You might also like