0% found this document useful (1 vote)
259 views54 pages

Giáo Trình Labview

This document provides an introduction and instructions for setting up LabVIEW on a PC. It describes LabVIEW as a visual programming platform for data acquisition, instrument control, and industrial automation. It lists modules required for a course and provides step-by-step screenshots to guide the download, installation, and activation of LabVIEW 2016 and required modules. The setup process involves downloading installation files, running the installer, selecting module contents, and activating the software in administration mode before resetting the computer.

Uploaded by

Xuan Chiem
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 (1 vote)
259 views54 pages

Giáo Trình Labview

This document provides an introduction and instructions for setting up LabVIEW on a PC. It describes LabVIEW as a visual programming platform for data acquisition, instrument control, and industrial automation. It lists modules required for a course and provides step-by-step screenshots to guide the download, installation, and activation of LabVIEW 2016 and required modules. The setup process involves downloading installation files, running the installer, selecting module contents, and activating the software in administration mode before resetting the computer.

Uploaded by

Xuan Chiem
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/ 54

INTRODUCTION TO

LABVIEW AND SIMPLE APPLICATIONS

Person in charge: Đỗ Thành Trung


Major: Mechatronics Engineering
Phone number: +84 908 403 339
Email: [email protected]

Ho Chi Minh City, June 18th, 2018


CONTENTS

CONTENTS ...............................................................................................................2
FOREWORDS ...........................................................................................................3
CHAPTER 1: INTRODUCTION TO LABVIEW .................................................4
1.1 LabVIEW: ....................................................................................................4
1.2 Setup LabVIEW on your PC: ....................................................................5
1.3 Getting started with LabVIEW: ..............................................................14
1.4 How to use? ................................................................................................15
1.5 Front Panel and Block Diagram Panel:...................................................20
1.5.1 Front Panel: .....................................................................................20
1.5.2 Block Diagram Panel: .....................................................................21
Chapter 2: Programming .......................................................................................22
2.1 Elements in LabVIEW: .............................................................................22
2.1.1 Structures: ........................................................................................22
2.1.2 Data Types: ......................................................................................27
2.1.3 Numeric Palette: ..............................................................................29
2.1.4 Comparison Palette: ........................................................................32
2.1.5 Boolean Palette: ...............................................................................37
2.1.6 Timing Palette: ................................................................................40
2.1.7 Array and Clusters:.........................................................................42
2.1.8 String: ...............................................................................................46
2.2 Algorithm: ..................................................................................................48
** Small exercises: ..........................................................................................50
CHAPTER 3: LABVIEW+ARDUINO .................................................................51
3.1 Introductions:.............................................................................................51
3.2 Hardwares: .................................................................................................51
3.3 Softwares: ...................................................................................................51
**Small exercises: ...........................................................................................54
CHAPTER 4: REFERENCE .................................................................................54

2
FOREWORDS

I have been using LabVIEW for nearly a year when working with a
project name “Water level tank control”. Before knowing LabVIEW, I just
knew a little bit of Matlab and wanted to find a simulation software which can
indicate results combined with Transfer Function to look more reality and
animated. That’s how I know LabVIEW.
But in the first time approaching this software, I had a concern of how
can I work with it, just like I had the same thought with Matlab eventhough I
had spent 3 months working with Matlab and still it was so complicated. On
the contrary, LabVIEW proves to be friendlier than Matlab but if you want to
ask me of which software will be better in solving Automatic Control System
or strong in combination of mathematics, analyze characteristics and
supportive in researches ? I’d rather choose Matlab than LabVIEW. Anyway,
with the same amount of time to get acquainted to LabVIEW, I could
understand some basic elements in this software and finalized my project
quite well (not totally well in mathematics but in simulation was fine).
What I mentioned there was just that each software has its own strong points
depend on what kind of applications we are working with. LabVIEW has its
strong points at indicating results animatedly, faster loading time, there are
lots of open-sourced modules with high accuracy which help you connect to
various types of peripheral devices. There was a time I almost needed to
reinstall my Window Operations because I couldn’t connect Arduino UNO to
Matlab for reasons until now I haven’t had an answer but just for a few clicks,
I made it easily with LabVIEW and module NIVISA.
This book only provides introduction to LabVIEW with nothing huge
in knowledge, you can easily find some similar documents like the one you
are reading now but in Việt Nam there are less of documents about
LabVIEW, I only want to contribute my little knowledge of this software to
the community along students, students who are studying Engineering majors,
researchers or even engineers. There will be mistakes in this book and
misunderstanding terms, please be generous and send me your thoughts. I do
appreciate that.
Thank you,
Trung.

3
CHAPTER 1: INTRODUCTION TO LABVIEW
1.1 LabVIEW:

Laboratory Virtual Instrument Engineering Workbench (LabVIEW) is a


system-design platform and development environment for a visual programming
language from National Instruments.

The graphical language is named "G"; not to be confused with G-code. Originally
released for the Apple Macintosh in 1986, LabVIEW is commonly used for data
acquisition, instrument control, and industrial automation on a variety of operating
systems (OSs), including Microsoft Windows, various versions of Unix, Linux,
and macOS.

Interfacing to devices

LabVIEW includes extensive support for interfacing to devices, instruments,


camera, and other devices. Users interface to hardware by either writing direct bus
commands (USB, GPIB, Serial) or using high-level, device-specific, drivers that
provide native LabVIEW function nodes for controlling the device.

LabVIEW includes built-in support for NI hardware platforms such as


CompactDAQ and CompactRIO, with a large number of device-specific blocks for
such hardware, the Measurement and Automation eXplorer (MAX) and Virtual
Instrument Software Architecture (VISA) toolsets.

National Instruments makes thousands of device drivers available for download on


the NI Instrument Driver Network (IDNet).

4
Figure 1 Example of LabVIEW.

Figure 1 is taken from: http://techteach.no/simview_2010/feedforward/index.php

1.2 Setup LabVIEW on your PC:


We are using LabVIEW 2016 32-bit version. You can go to www.ni.com and
download this software and its modules.
Modules required for this course (remember to download the modules with
the same year of LabVIEW version):
 Control Design and Simulation Module 2016
 Datalogging and Supervisory Control Module 2016
 NIVISA 2016

5
Figure 2 LabVIEW components

Now let’s start setting up, follow these figures below:


Run file “2016LV-WinEng.exe”

Figure 3 Press OK

6
Figure 4 Unzip and wait till it's done

If it’s asking, just “Yes”.

Figure 5 Setup Window

7
Figure 6 Press "Next" and fill out your information

Figure 7 Leave this page empty and press "Next"

8
Figure 8 Should leave the directory in C drive

Figure 9 Follow the figure and choose all contents

9
Figure 10 Leave that little square empty

Figure 11 Press "Next" and remember to choose "Decline Support"

10
After installations, no need to reset your computer. Keep installing the
modules. I will show you how to install one module and the following
modules that suit your purpose, you can install them alike.

Figure 12 Leave this empty and press "Next"

Figure 13 Choose all contents and press "Next"

11
Figure 14 No ticking and "Next"

Figure 15 Follow figure and start installation

12
After our installations are succeeded, let’s “crack” them up.

Figure 16 Open this file in Administration Mode

Figure 17 Right-Click on every content and select Activate

 Finally, reset your PC and begin to work with LabVIEW.

13
1.3 Getting started with LabVIEW:

Figure 18 Homepage

Figure 19 Open new VI file

14
Figure 20 Front Panel and Block Diagram Panel

- In Front Panel, we design objects to indicate results or to enter


variables and see how the results are changed. It’s like working with C#
Window Form, where Window Form is Front Panel.
- In Block Diagram Panel, we start coding our projects using block-code
symbols and arrows.

1.4 How to use?


- Whenever you start working, just need Right-Click and Left-Click.
That’s it.
- Each type of commands is arranged into each palette so it’s quite easy
for you to code.
- On behalf, Help menus in LabVIEW shows clearly about how
command works, what this theory means or when will it take place,…

15
Figure 21 In Front Panel

Figure 22 Block Diagram Panel

16
Figure 23 Open Help menu

Figure 24 Help Menu

- To switch between to Panels, you can go to Window -> Front Panel/


Block Diagram or use keystrokes Ctrl + E.
- If you don’t know how a block command works, Right-Click on the
block and choose Example or Help. LabVIEW will take you to the
Help section of that block including with its examples.

17
Figure 25 Open Help and Examples

Figure 26 Roll the Help menu to lowest and you will see "Open Example", click on it

- After clicking, you will receive a VI file they created. Following this
file, you can get to know more clearly of how the command works,
when you should apply this one or what elements it requires.

18
Figure 27 Front Panel of the Example

Figure 28 Block Diagram of the Example

19
1.5 Front Panel and Block Diagram Panel:
1.5.1 Front Panel:

Figure 29 Elements on Toolbar [1]

Figure 30 Commands in Front Panel

20
As you have seen, Control Palette of Front Panel has 2 objects:
 Controls: Used for changing the values of the variables while
simulating.
 Indicators: Used to show the results of the code while simulating.

1.5.2 Block Diagram Panel:

Figure 31 Elements in Block Diagram [1]

21
CHAPTER 2: PROGRAMMING
2.1 Elements in LabVIEW:
2.1.1 Structures:
Structures are located in Structure Palette in Block Diagram Panel.

Figure 32 Structures Palette

Like you can see, we will mostly work with For Loop, While Loop,
Formula Node. If you have had some experiences in programming
languages, then these loops construction wouldn’t have been hard to deal
with.

22
While Loop:
Repeats what located inside it until the conditional terminal receives a
particular Boolean value. By default, if the conditional terminal receives a
True (Boolean Value) the iteration stops. However, this condition can be
changed by right-clicking on it and changing the continuation behavior from
Stop if True to Continue if True.

Figure 33 While Loop [1]

For Loop:
For Loop and While Loop are two necessary commands in any programming
language. The main difference between these two is that by the latter the
number of the iterations is limited to the predefined number (N). The iteration
(i) terminal provides the current loop iteration count, which ranges from 0 to
n-1.

Figure 34 For Loop [1]

23
Formula Node
This node calculates the mathematical formulas. Many mathematical formulas
such as sin, asin, cos, acos, absolute value and so on can be used with this
node.

Figure 35 Formula Node [1]

Table 1 Mathematical Formulas used in Formula Node [1]

Corresponding
Function Description
LabVIEW Function
abs(x) Absolute Value Returns the absolute value of x.
Rounds x to the next higher integer
Round Toward
ceil(x) (smallest
+Infinity
integer x).
Computes the cosine of x, where x is in
cos(x) Cosine
radians.
Computes the cotangent of x (1/tan(x)),
cot(x) Cotangent
where x is in radians.
Computes the value of e raised to the x
exp(x) Exponential
power.
Truncates x to the next lower integer
floor(x) Round To –Infinity (largest
integer x).
int(x) Round To Nearest Rounds x to the nearest integer.
Rounds x to the nearest integer between x
intrz(x) — and
zero.
Computes the natural logarithm of x (to
ln(x) Natural Logarithm the
base of e).

24
Natural Logarithm
lnp1(x) (Arg Computes the natural logarithm of (x + 1).
+1)
Computes the logarithm of x (to the base
log(x) Logarithm Base 10 of
10).
Compares x and y and returns the larger
max(x,y) Max & Min
value.
Compares x and y and returns the smaller
min(x,y) Max & Min
value.
Computes the remainder of x/y, when the
mod(x,y) Quotient & Remainder
quotient is rounded toward –Infinity.
pow(x,y) Power of X Computes x raised to the y power.
Produces a floating-point number between
Random Number (0 –
rand( ) 0
1)
and 1 exclusively.
Computes the remainder of x/y, when the
rem(x,y) Quotient & Remainder
quotient is rounded to the nearest integer.
Returns 1 if x is greater than 0, returns 0 if
x
sign(x) Sign
is equal to 0, and returns –1 if x is less
than 0.
Computes the sine of x, where x is in
sin(x) Sine
radians.
Returns the size of the dimension di
sizeOfDim(ary,di) — specified
for the array ary.
sqrt(x) Square Root Computes the square root of x.
Computes the tangent of x, where x is in
tan(x) Tangent
radians

25
Flat Sequence
Consists of one or more subdiagrams, or frames, that execute sequentially.
Use the Flat Sequence structure to ensure that a subdiagram executes before
or after another subdiagram.
Data flow for the Flat Sequence structure differs from data flow for other
structures. Frames in a Flat Sequence structure execute from left to right and
when all data values wired to a frame are available. The data leaves each
frame as the frame finishes executing. This means the input of one frame can
depend on the output of another frame. [2]

Figure 36 Flat Sequence

Case Structure
Condition structure, where you will receive condition input is TRUE or
FALSE and inside the structure, you will implement some processing codes
or warning.

Figure 37 Case Structure

26
Feedback Nodes and Shift Registers
These two are memory elements that save data between subsequent cycles of
While Loop or For Loop. [3]
These are used in case the data of a present terminal is dependent on the
previous data.
Feedback Node and Shift Registers are almost the same.

Figure 38 Feedback Nodes and Shift Registers

2.1.2 Data Types:


LabVIEW represents numeric data types as floating-point numbers, fixed-
point numbers, integers, unsigned integers, and complex numbers. The
difference among the numeric data types is the number of bits they use to
store data and the data values they represent. [2]
(Windows) LabVIEW can process data only in the ranges shown in the
Numeric Data Types Table, but it can display in text format a range of
±9.9999999999999999E999. (Ex = 10^x) [2]

Figure 39 Complex numbers

Figure 40 Floating-points numbers

27
Table 2 Numeric Data types table

28
2.1.3 Numeric Palette:
Use the Express Numeric functions to create and perform arithmetic and
complex mathematical operations on numbers and to convert numbers from
one data type to another.

29
30
Figure 41 Details about Numeric Palette [1]

Figure 42 Numeric Palette

31
2.1.4 Comparison Palette:

Figure 43 Comparison Palette

32
33
34
35
Figure 44 Details about Comparison Palette [1]

36
2.1.5 Boolean Palette:

Figure 45 Boolean Palette

37
38
Figure 46 Details about Boolean Palette [1]

39
2.1.6 Timing Palette:

Figure 47 Timing Palette;

Table 3 Details about Timing Palette [2]

Palette Description
Object
Date/Time Converts a cluster of time values into a timestamp measured as
To Seconds the number of seconds that have elapsed since 12:00 a.m.,
Friday, January 1, 1904, Universal Time, assuming is DST is set
to 1.
Elapsed Indicates the amount of time that has elapsed since the specified
Time start time.
Format Displays a timestamp value or a numeric value as time in the
Date/Time format you specify using time format codes.
String
Get Returns a timestamp of the current time. LabVIEW calculates
Date/Time In this timestamp using the number of seconds elapsed since 12:00
Seconds a.m., Friday, January 1, 1904, Universal Time.
Get Converts a timestamp value or a numeric value to a date and time
Date/Time string in the time zone configured for the computer. The function
String interprets timestamp and numeric values as the time-zone-
independent number of seconds that have elapsed since 12:00
a.m., Friday, January 1, 1904, Universal Time.
High Returns the relative current time in seconds. Use the difference
Resolution between two successive values to measure the elapsed
Relative
Seconds time between the calls. Use this VI to measure time spans with
40
much higher resolution than you can obtain from the Tick Count
(ms) function. The time resolution of this VI may vary with
different operating systems and CPU types.
Seconds To Converts a timestamp value or a numeric value to a cluster of
Date/Time time values.

This function loses fractional seconds of precision when


converting the timestamp. If you convert date time rec back into
a time stamp, the timestamp may not display the exactly correct
value.
Tick Count Returns the value of the millisecond timer.
(ms)
Time Delay Inserts a time delay into the calling VI.
Time Stamp Use the time stamp constant to pass a time and date value to the
Constant block diagram.
To Time Converts a number to a timestamp.
Stamp
Wait (ms) Waits the specified number of milliseconds and returns the value
of the millisecond timer. Wiring a value of 0 to the milliseconds
to wait input forces the current thread to yield control of the
CPU.
Wait Until Waits until the value of the millisecond timer becomes a multiple
Next ms of the specified millisecond multiple. Use this function to
Multiple synchronize activities. You can call this function in a loop to
control the loop execution rate. However, it is possible that the
first loop period might be short. Wiring a value of 0 to the
milliseconds multiple input forces the current thread to yield
control of the CPU.

41
2.1.7 Array and Clusters: [3]
An array, which consists of elements and dimensions, is either a control or an
indicator – it cannot contain a mixture of controls and indicators. Elements
are the data or values contained in the array. A dimension is the length,
height, or depth of an array. Arrays are very helpful when you are working
with a collection of similar data and when you want to store a history of
repetitive computations.
Array elements are ordered. Each element in an array has a corresponding
index value, and you can use the array index to access a specific element in
that array. In NI LabVIEW software, the array index is zero-based. This
means that if a onedimensional (1D) array contains n elements, the index
range is from 0 to n – 1, where index 0 points to the first element in the array
and index n – 1 points to the last element in the array.

Clusters group data elements of mixed types. An example of a cluster is the


LabVIEW error cluster, which combines a Boolean
value, a numeric value, and a string. A cluster is similar to a record or a struct
in text-based programming languages.
Similar to arrays, a cluster is either a control or an indicator and cannot
contain a mixture of controls and indicators. The
difference between clusters and arrays is that a particular cluster has a fixed
size, where a particular array can vary in size. Also, a cluster can contain
mixed data types, but an array can contain only one data type.

Figure 48 Array Palette

42
Figure 49 Clusters Palette

Table 4 Details about Array Palette [2]

Palette Description
Object
Array Use this constant to supply a constant array value to the block
Constant diagram.
Array Max Returns the maximum and minimum values found in array, along
& Min with the indexes for each value.
Array Size Returns the number of elements in each dimension of array.
Array Returns a portion of array starting at index and containing length
Subset elements.
Array To Converts a 1D array to a cluster of elements of the same type as
Cluster the array elements. Right-click the function and select Cluster
Size from the shortcut menu to set the number of elements in the
cluster.
Array To Converts an array to a matrix of elements of the same type as the
Matrix array elements. Wire data to the Real 2D Array input to determine
the polymorphic instance to use or manually select the instance.
Build Array Concatenates multiple arrays or appends elements to an n-
dimensional array.
Cluster To Converts a cluster of elements of the same data type to a 1D array
Array of elements of the same data type.
Decimate 1D Divides the elements of array into the output arrays, placing
Array elements into the outputs successively. This function drops any
elements that cause the output arrays to have different lengths.
Delete From Deletes an element or subarray from n-dim array of length
Array elements starting at index. Returns the edited array in array w/
43
subset deleted and the deleted element or subarray in deleted
portion.
Index Array Returns the element or subarray of n-dimension array at index.
Initialize Creates an n-dimensional array in which every element is
Array initialized to the value of element.
Insert Into Inserts an element or subarray into n-dim array at the point you
Array specify in index.
Interleave Interleaves corresponding elements from the input arrays into a
1D Arrays single output array.
Interpolate Linearly interpolates a decimal y value from an array of numbers
1D Array or points using a fractional index or x value.
Matrix To Converts a matrix of elements to an array of elements of the same
Array data type. Wire data to the Real Matrix input to determine the
polymorphic instance to use or manually select the instance.
Replace Replaces an element or subarray in an array at the point you
Array specify in index.
Subset
Reshape Changes the dimensions of an array according to the values of
Array dimension size 0..m-1.
Reverse 1D Reverses the order of the elements in array, where array is of any
Array type.
Rotate 1D Rotates the elements of array the number of places and in the
Array direction indicated by n.
Search 1D Searches for an element in a 1D array starting at start index.
Array Because the search is linear, you need not sort the array before
calling this function. LabVIEW stops searching as soon as the
element is found.
Sort 1D Returns a sorted version of array with the elements arranged in
Array ascending order. If array is an array of clusters, the function sorts
the elements by comparing the first elements. If the first elements
match, the function compares the second and subsequent
elements. The connector pane displays the default data types for
this polymorphic function.
Split 1D Divides array at index and returns the two portions with the
Array element of index at the beginning of second subarray.
Threshold Interpolates points in a 1D array that represents a 2D non-
1D Array descending graph. This function compares threshold y to the
values in array of numbers or points starting at start index until it
finds a pair of consecutive elements such that threshold y is
greater than or equal to the value of the first element and less than
or equal to the value of the second element.
Transpose Rearranges the elements of 2D array such that 2D array[i,j]
2D Array becomes transposed array[j,i].

44
Table 5 Details about Cluster palette [2]

Palette Object Description


Array To Converts a 1D array to a cluster of elements of the same type as
Cluster the array elements. Right-click the function and select Cluster
Size from the shortcut menu to set the number of elements in
the cluster.
Build Cluster Bundles each element input into a cluster and assembles all
Array element clusters into an array of clusters.
Bundle Assembles a cluster from individual elements.
Bundle By Replaces one or more cluster elements. This function refers to
Name cluster elements by name instead of by their position in the
cluster.
Call Parent Calls the nearest ancestor implementation of a class method.
Method You can use the Call Parent Method node only on the block
diagram of a member VI that belongs to a class that inherits
member VIs from an ancestor class. The child member VI must
be a dynamic dispatching member VI and have the same name
as the ancestor member VI.
Cluster Use this constant to supply a constant cluster value to the block
Constant diagram.
Cluster To Converts a cluster of elements of the same data type to a 1D
Array array of elements of the same data type.
Get LV Class Returns the class data for the class whose path you wire to the
Default Value class path input. If the class is not in memory, LabVIEW
attempts to load it from disk. If any dependencies are missing,
LabVIEW searches for the missing dependencies. If LabVIEW
cannot find the dependency, LabVIEW assumes the dependency
is missing and does not prompt the user to browse to the needed
file.
Get LV Class Returns the class data for the class whose name you wire to the
Default Value class name input. If the class is not in memory or is broken,
By Name LabVIEW returns an error.
Get LV Class Returns the name of the class of the object.
Name
Get LV Class Returns the path to the class of the object.
Path
Index & Indexes a set of arrays and creates a cluster array in which the
Bundle ith element contains the ith element of each input array.
Cluster Array
LV Object The LabVIEW Object is the common ancestor data type for all
Constant LabVIEW classes. You can use the LabVIEW Object to create
generic methods that can handle all LabVIEW class data types.
Preserve Run- Checks at run time whether object in is of the same class as, or
Time Class is a child class of, target object.

45
Use this function on the block diagram of a subVI when you
want to guarantee that LabVIEW downcasts a LabVIEW class
output of the subVI node to the same class type as a LabVIEW
class input when the subVI receives a child class of the expected
input type.
To More Typecasts a reference, such as a control or a type definition, to a
Generic Class more generic class in the inheritance hierarchy.
To More Typecasts a reference, such as a control or a type definition, to a
Specific Class more specific class in the inheritance hierarchy.
Unbundle Splits a cluster into each of its individual elements.
Unbundle By Returns the cluster elements whose names you specify.
Name

2.1.8 String:

Figure 50 String Palette

46
Table 6 Details about String Palette [2]

Palette Object Description


Array To Converts an array of any dimension to a table in string form,
Spreadsheet containing tabs separating column elements, a platform-
String dependent EOL character separating rows, and, for arrays of
three or more dimensions, headers separating pages.
Build Text Creates an output string from a combination of text and
parameterized inputs. If the input is not a string, this Express
VI converts the input into a string based on the configuration of
the Express VI.
Carriage Consists of a constant string containing the ASCII CR value.
Return
Constant
Concatenate Concatenates input strings and 1D arrays of strings into a
Strings single output string. For array inputs, this function concatenates
each element of the array.
Empty String Consists of a constant string that is empty (length zero).
Constant
End of Line Consists of a constant string containing the platform-dependent
Constant end-of-line value.
Format Displays a timestamp value or a numeric value as time in the
Date/Time format you specify using time format codes.
String
Format Into Formats string, path, enumerated type, time stamp, Boolean, or
String numeric data as text.
Line Feed Consists of a constant string containing the ASCII LF value.
Constant
Match Pattern Searches for regular expression in string beginning at offset. If
the function finds a match, it splits string into three substrings.
A regular expression requires a specific combination of
characters for pattern matching. This function gives you fewer
options for matching strings but performs more quickly than
the Match Regular Expression function.
Match Regular Searches for a regular expression in the input string beginning
Expression at the offset you enter. If the function finds a match, it splits the
string into three substrings and any number of submatches.
Resize the function to view any submatches found in the string.
Normalize End Converts the line endings of the input string to the line ending
Of Line format you specify. If you do not specify a line ending format,
this VI converts the line endings of the string to the line
endings that the current platform expects. Use this VI to make
your strings readable by different platforms or by the command
line of the current platform.
Replace Inserts, deletes, or replaces a substring at the offset you specify
Substring in string.
47
Scan From Scans the input string and converts the string according to
String format string.
Search and Replaces one or all instances of a substring with another
Replace Stringsubstring. To include the multiline? input and enable advanced
regular expression searches, right-click the function and select
Regular Expression.
Space Use this constant to supply a one-character space string to the
Constant block diagram.
Spreadsheet Converts the spreadsheet string to an array of the dimension
String To and representation of array type. This function works for arrays
Array of strings and arrays of numbers.
String Use this constant to supply a constant text string to the block
Constant diagram.
String Length Returns in length the number of characters (bytes) in string.
String Subset Returns the substring of the input string beginning at offset and
containing length number of characters.
Tab Constant Consists of a constant string containing the ASCII HT
(horizontal tab) value.
To Lower Case Converts all alphabetic characters in string to lowercase
characters. Evaluates all numbers in string as ASCII codes for
characters. This function does not affect non-alphabetic
characters.
To Upper Case Converts all alphabetic characters in string to uppercase
characters. Evaluates all numbers in string as ASCII codes for
characters. This function does not affect non-alphabetic
characters.
Trim Removes all ASCII white space (spaces, tabs, carriage returns,
Whitespace and linefeeds) from the beginning, end, or both ends of string.
The Trim Whitespace VI does not remove double byte
characters.

2.2 Algorithm:
Algorithm is the most important thing to every job, without Algorithm, you
can only solve simple problems like: 1 + 1 = ? or A dog and a lion, which one
is faster ?
But when you meet a problem with higher complexity, algorithm helps you
define specifically what kind of problem you are dealing with, in step by step
you take to the final answer.
Talking about Algorithm, let’s meet Flowchart Diagram.

48
Figure 51 Flowchart symbols( picture is taken from google.com)

49
Figure 52 Example of Flowchart (picture is taken from google.com)

** Small exercises:
1. Adjust a knob, indicate results on a Water tank and Number indicator
of the level water in side the Tank.
2. A traffic light has 3 colors, Red light lasts for 10 secs, Green light lasts
for 10 secs and Yellow light lasts for 5 secs. Let it run nonstop until
press Stop button.
3. Enter a number, check if it’s a prime number. If it’s true, turn on the
Light and show “Great!”. If not, don’t turn on the Light and show “Oh
no!”.
4. Enter a number n, run in a loop structure to calculate the sum of
numbers from 0 to n-1. Indicate results in Vertical bar.
5. Fill an array with 3 contexts: Name, Year of birth, Job. Length of array
is input by user. When you adjust Index number, example: at index 3,
data are {Haul, 1988, Driver}, show data on Array. If press Show, all
information is shown on cluster.
6. Input a string, rotate that string.
7. Make a switch, if it’s ON. Show information consists of 3 data types:
Double, Integer, String. If it’s OFF, show information of 3 values with
same data type.
8. Enter a number n, draw a random values from 0 to n on a chart, Stop
the loop after 10 secs.
9. Count the number of letters from a string you input.

50
CHAPTER 3: LABVIEW+ARDUINO

3.1 Introductions:
This application is applied for quite a long time since Arduino is widely
choosen for its convenience and cheap in price.
Despite of its prevalent, Arduino is not strong at dealing with signal
processing, open-sourced libraries are shown with low precisions…
The question was made up: How to combine the simplicity of Arduino and
the precision of a scientific software together to reach higher levels of
experiments and analysis. That’s how combinations of Arduino and
LabVIEW or Matlab were founded.
3.2 Hardwares:
You just need Arduino UNO/Arduino Mega2560 with cable.
3.3 Softwares:
First, install NIVISA modules.
Download LIFA library to interface Arduino with LabVIEW.
Extract files into a folder.
Open LIFA_Base.ino.

Figure 53 LIFA Base

51
Plug cable to your PC and upload code. Leave the code there, don’t do
anything.
Download VI Package Manager on www.ni.com and install.

Figure 54 VIPM

Open the file and search for “Arduino”.

Figure 55 Install LabVIEW Interface for Arduino

After it’s finished, go to Block Diagram Panel, Right-Click and you will see
Arduino Palette.

Figure 56 Arduino Palette

52
Watch some examples in the palette and you can figure how we can start
working with it.
This is my work.

Figure 57 My Example

Figure 58 Results

53
**Small exercises:
1. Show temperatures from LM35.
2. Pulse generation from LabVIEW to pin 13 on Arduino.
3. Work in groups, find a way to plot data from a Vibration sensor on
Frequency Domain.
4. Work in groups, when a car is running straight, how to change its
directions? You will receive small gifts from teacher if you can change
its directions smoothly. If you can adjust, set the output to a digital pin
on Arduino.

CHAPTER 4: REFERENCE

I want to send my special thanks to Samee Faraji. Your document helps me


most of the contents inside this lecture. Hope you achieve success in your life.

[1] S. Faraji, "Introduction to Application of LabVIEW in Automation,"


Samee Faraji, January,2013.

[2] N. Instruments, "Tutorial".

[3] N. Instruments, "Tutorial: Arrays and Clusters,"


http://www.ni.com/white-paper/7571/en/.

[4] F. A. Haugen, "LabVIEW Tutorials,"


http://home.hit.no/%7Efinnh/tutorials/labview/, 31 Jan 2017.

This document is for free but if you are mentioning some of the contents inside this lecture, please remember to leave a reference to some people in
this chapter.

54

You might also like