Sunteți pe pagina 1din 34

LabVIEW for Dummiees©

First Edition
Table of Contents Click on the Click on icon for
description of each tool
section you are
Do you want music? interested in
Introduction
Arithmetic
---Replace/Insert Node
---Create Controls
---Formula Node
---Replace Indicator/Control
---Highlight Execution
---Errors
---Rest of Numeric
---Tutorial
Boolean Operators
---Case Structure
Comparison
For, While, and Sequence
Loops
Arrays (Vectors and Matrices)
Strings
File Creation
A QUIZ!!
Time and Dialog
Graphing
Attribute Nodes
---Drawing
Creating sub-VIs
---Libraries
---User Libraries
Data Acquisition
Analysis
Other Stuff
---Clusters
---List & Ring
---Advanced
---Application
---Communication
---Instrument I/O
-----Instrument Drivers
Acknowledgments
Back to my LabVIEW Page

Introduction

This site is mainly finished, and works best in IE 5. There may be some problems
in Netscape. I welcome feedback, please fill out the form below. All the links
should be working. Even though the site is mainly finished, I still will be editing. I
am writing this tutorial for LabVIEW due to popular demand because many of my
friends and colleagues are having problems using LabVIEW, which is an acronym for
Laboratory Virtual Instrument Engineering Workbench and is distributed by National
Instruments. I become acquainted with LabVIEW in the fall of 1998 while working on
an electronic nose project. For those who don't know anything about LabVIEW it is a
graphical programming language unlike the text programming languages of C++,
Fortran, Basic, etc. Instead, LabVIEW is written in G or graphical programming
language, which is composed of many "nodes" wired together. Also, unlike the other
programming languages, LabVIEW has continuous Auto-compiling, i.e. it tells you
when an error has been committed immediately! It is important to realize that the
LabVIEW diagrams are not the same as a circuit diagram composed of resistors,
transistors, and ICs. So don't plug an antenna into the data acquisition board and
expect a radio to work! You could conceivably do this, but I can't. LabVIEW is used
as a replacement for the text based languages, so you can literally see what you are
doing, quickly insert a missing piece of code, and study how the data is traveling. If
you're like me, you would miss a quote or mistype a command in the computing class,
which would cause several hundred errors and take about a half an hour to find the
mistake. This is where LabVIEW is superior, NO REQUIRED TYPING OR
SPELLING SKILLS!!! As I write this tutorial, I am expecting that you have had a
basic computer programming course and/or understand the basic logical processes of
program writing, such as loops, if, then, else, arrays, and strings.

Before going any further, I suggest that you have LabVIEW installed and working
when you use this tutorial. I don't intend this to be a replacement for the LabVIEW
users' manuals which are like 10 volumes. I just want to help point you in the right
direction. I encourage experimenting with LabVIEW's included Examples. This is how
I learned most of my LabVIEW. Perhaps one day I will have Java applets with this
webpage. When you make your VIs, be sure to make multiple copies of them (floppy,
hard drive, and a printed copy). You don't want to loose your work! Also when you do
save, you must add the extention (.vi). You should know that I have been using
LabVIEW 5.0 on a Windows 95 based Pentium Celeron machine and the examples
worked here. I don't know about your machine. Three little disclaimers: By using this
webpage, you are in no way admitting that you are a dummie, and this is not
affiliated with the dummie book series! Before anyone becomes angry, I spelled
dummies, dummiees to avoid any possible copyright infringement.

In writing this webpage I am trying to use a color coding to help you find the concepts
easier to find and remember, and here are some terms with which you should be
familiar.

1. Red italicized type will represent the particular node or sub-VI (a VI being a
Virtual Instrument) that can be found on the functions pallet.
2. Blue type will represent what can be obtained by right clicking.
3. Bold type is used for expression such as warnings, possible errors, and
advisories.
4. If you ever have a question on what a particular node does, right click on it and
choose Online Help. Believe me, it is a great help.
5. Data Operations >> Make Current Value Default, & Reinitialize to Default -
Takes the current value and makes it the default, i.e. after you save the
program, when you open it the next time the old (default) values will be
present. Likewise, after changing the values, you can reinitialize the default
values.
6. LabVIEW is written (programmed) left (input) to right (output).
7. LabVIEW starts counting from zero.

Also, you should be familiar with the wire color code conventions used in
LabVIEW and How they change in Arrays. Be sure to notice the change in wire
size and color for the different data types. Make them in LabVIEW and note how the
indicators appear.

Starting

If you haven't installed LabVIEW yet, I suggest a full install. Even though you may
not use all the features, they are there if you need them. Double click on the LabVIEW
icon. You should see this appear
If the image is smaller with just three choices, click on the bar by large dialog. Click
on New VI. Two panels will appear. The one with the gray background is the front
panel, or the "control panel". The white panel is the block diagram where the code is
written. When you pass your mouse over the panels it will become a small hand,
which is used to control the switches. Right click on the diagram and the functions
pallet will appear. I will go into more detail later what each section means.

Arithmetic
Before we start the hard stuff, here are some simple examples. Everyone knows
arithmetic, I hope, so in this section you will gain a familiarity with the block
diagrams. If you make an error, use the regular mouse arrow to choose and delete a
node. To delete a section of wire, one click will highlight the section, if you want the
whole wire, double click to highlight all of it. An indicator/control can only be deleted
from the front panel. Since you will know what the results should be, you will know if
you are doing things correctly, or if your computer is broken.
When the functions pallet has appeared, click on the Numeric box, and choose the Add
sign in a triangle.

Just click, move, and click again. Go to Windows >> Show Tools Pallet and click the
small wire spool, or just hit the tab key several times until you see the mouse become
the wire spool. Place the spool over the icon. Wires will appear with a short
description of what connects. Go back to numeric and choose (click, move, and click
again) the Numeric Constant. Enter an integer. To enter text, such as a number, you
need the cursor mouse. Tab or choose the regular mouse arrow. Click on the number
box. Ctrl+C. Click in a different location, then Ctrl+V. Enter a floating point number
(a number with a decimal part). See the difference in color? You may remember, at
least in C++, that you had to define an integer and a double or long number otherwise
you may not get the correct precision. This is not a problem in LabVIEW, it
automatically assumes greatest precision, and you can make it smaller or larger as
needed by using Representation, and Format & Precision.... Tab back to the wire
spool. When the object starts to blink, Click, release, move to the new location, and
click to end. Repeat this for the other number. You need to have a steady hand and a
good eye to make sure the wires are connected properly. NOTE: If you get a gray
broken wire, an error has occurred. Do not connect two wires from different
sources! To remove the broken wire you can use Ctrl+B (remove Bad wires), but I
prefer to remove the wire by choosing then deleting them because you will see where
the wire cam from when it was good. Sometimes especially in complicated programs,
you will need to "move around multiple corners." Just click once in the blank space to
"pin down" the wire. Now move to the "x+y" end of the addition. Right click and
choose Create Indicator. It should already be wired. Double click and you will be
taken to the front panel. To find the indicator in the diagram, right click and choose
Find Terminal. To rename the indicator, if the name is already visible, use the cursor
to enter Result. To hide or show choose Show >> Label. Just typing a name above
does not make it a label, it would be just a note. A true label will move with the node,
i.e. it is attached, a note will stay put. However, a label can be moved independently of
the node. Click on the run arrow. If everything is correct, Congratulations, you have
made your first working VI! If not, you erred and try again. If you are totally lost, see
this on adding two numbers. Updated and Animated

You have just learned fifteen LabVIEW facts.

1. To bring up a node, just click, move, and click again


2. Use the Tab key to change the use of the mouse
3. Once on the diagram, you can copy (Ctrl+C) and Paste (Ctrl+V) nodes
4. How to wire: Click, release, move to the new location, and click to end
5. To move around multiple corners, click once to pin down the wire
6. A BLUE wire represents an integer
7. An ORANGE wire represents a floating point number
8. A GRAY BROKEN wire is an error. That is: BAD
9. You can just click and drag to move objects
10. To create an indicator right click on the output area, and choose Create
Indicator
11. Finding the indicator on the front panel by double clicking on the terminal in
the diagram
12. Locate the terminal in the diagram by right clicking on the indicator and
choosing Find Terminal.
13. An indicator/control can only be deleted from the front panel.
14. To rename use the cursor mouse, and type in a label.
15. By choosing Show >> Label, you can decide to show or not to show the label.

Replacing and inserting a node

Once you have the example working, right click on the addition node and choose
Replace. Another functions pallet will appear and you can choose another operation.
Pick the multiply node from the Numeric section and it will replace the addition node.
This can save much time by avoiding rewiring and possible mistakes. NOTE: When
replacing if similar nodes (like Numeric, Boolean or Comparison section) are
used there should be no problem, but if you try to replace a dissimilar object with
a different number of terminals, the wiring may be wrong, or a BAD WIRE
error.
To insert a new piece of code, right click on the wire and choose Insert. Using the
previous example, insert an Increment on one of the wires and see if it works. There
may be some problems when replacing Sub-VIs. See what I mean below.

Creating Controls

An instrument is not much use if you can only have set constants. Flexibility is needed
to control, not only for analyzing data, but instrument control. By choosing Create
Control, a terminal will appear allowing you to control the calculations from the front
panel. In the diagram from the previous example, right click on each of the numbers,
and choose Create Constant. They will not be connected. If the numbers hadn't been
present, the controls would have been wired but may not have been the type you
desired. Delete the old numbers and wires, and connect the control terminals. Double
click to find the control. Put the VI in continuous run (the circling arrow, See the
toolbar). By clicking on the little scroll bars on the left you can increment or
decrement the number, or you can simply enter a new number. If everything is
working, the indicator will change accordingly.
Now is a good time to discuss Key Navigation. This is mainly used with Boolean
ON/OFF switches, but can be used for any control. Many times when you are
operating a VI, it may be difficult to access a contol with the mouse. On the control
choose Key Navigation... You can define a key to access a control (for numeric), or
operate a control (for Boolean). I generally use the F# keys. This will only work whe
the VI is running. If you have only a few controls that all need to be accessed, you
can "Tab" between them. If the control is Boolean, you must push "Enter" for the
button to activate.

Formula Node

When you have a complicated calculation to perform and it would be impractical to


perform the individual operations by wiring them, you can use the Formula Node to
write your equations. Go to Structures and Choose Formula Node. You can form the
size you desire. Enter your equation, this is case sensitive. Enter y=m*x+b; Y is the
output and m,x, and b are the inputs. Be sure to include a semi-colon(;) at the end of
the equation. On the edge of the diagram right click and choose Add Output and enter
"y"(without the quotes of course!) and Create Indicator. Right click again and choose
Add Input three times and enter "m", "x", and "b" in the boxes and Create Controls for
each of them. Enter numbers, and run. Possible errors:

● Didn't wire all inputs


● Mistyping (case sensitive)
● Input and/or Output mislabeled
● Missing the semi-colon (;)

Look at the Online Help for more information. This is how the formula node example
should look.
NOTE: You CANNOT use an array in a formula node! You will need to utilize a
For Loop.

Replacing an Indicator or Control

Indicators can be replaced as well. If you want a clearer visualization (look at a


colorful slide rather than a number), on the front panel Right Click on the indicator or
control choose Replace. Keep the same type. So choose numeric. You can have slides,
dials, and other visually stimulating icons. The Boolean one you will be using later
and consists mainly of ON/OFF switches. You can also insert decorations to make the
front panel look pretty, such as a raised box. The rest of the controls I will get to later.

Highlighting Execution

Highlighting Execution is one of the most powerful debugging features of LabVIEW.


It shows exactly where the data is flowing and what that data is. In the wire diagram,
click on the little light bulb to make it light up, and run. You will see the data flow in
the block diagram.

Errors

Just for fun, create an error. Connect different wires together, or delete something. The
run arrow will be gray and broken. CLICK ON IT. An error dialog box will appear
listing the errors and why they occurred, sometimes it is not very helpful. Clicking on
the error will tell you why, double clicking will highlight the error. The VI won't work
until the error is fixed, so FIX IT!! I suggest correcting the error as soon as it is
committed so you will remember why you are doing what you are doing. Sometimes
especially when you first start using LabVIEW, you will connect a wire in a way that
makes sense but doesn't work. What can I say but find a loophole. It may take a few
more steps or need to develop a new sub-VI, but where there is a will there is a way!
You can also show the WARNINGS, which tell you when something could be
diagramed better, such as overlapping nodes or a suggested wiring. The VI will still
work, but it would be a good idea to look at it.

Some values you may come across that don't make sense are NaN, Inf, and -Inf. These
represent respectively an undefined operation (not a number) such as 0/0; Positive
Infinity; and Negative Infinity.

Some more information on the Numeric Pallet

Besides the simple arithmatical operators, there are also the rest of the operations you
used in your algebra classes; Trigonometric, Logrithmic, Complex, some Physical
Constants, and Conversions.

1. Trigonometric contains the cos, sin, tan, as well as the inverse and hyperbolic
types. Uses Radians.
2. Logrithmic contains the log functions base 10 and e, exponential, power of 2
and power of x. Little suggestion, when squaring a number, I found it easier to
use the multiply terminal instead of the power of x.
3. Complex contains the nodes necessary to extract the real and imaginary
components from complex numbers, and convert to polar notation. Complex
numbers occur when taking Eigenvalues, Eigenvectors, Fourier Transforms,
and other places.
4. Physical Constants contains the constants you may need in physics and
chemistry, as well as some others. Take a look.
5. Conversion contains what you need to change a numbers type. If when adding
you don't want to include the fractional part, or whatever the reason, you can
change the type, such as from a double precision floating point to an interger.
By the way, an unsigned long (32 bit) interger goes from 0 to +232-1, while a
signed long (32 bit) interger goes from -231+1 to +231-1. You can do the same
for the other size intergers.

The rest of the operations are fairly straight forward. Just be aware that the square root
of a negative number is given as a NaN, you must define "x" as a complex number to
get an imaginary answer.

Tutorial

The tutorial contains some very elementary VIs. Open them and see how they work.
They will give a good idea of the basic and very simple operations needed in
LabVIEW.

Boolean Operators

Truth
Table
X AND X OR X XOR X NOR
X Y X NAND Y X XNOR Y
Y Y Y Y
1 1 0 1
1 1 0 0
1 0 1 0
0 1 1 0
0 1 1 0
0 1 1 0
0 0 1 1
0 0 0 1
Not
Not 1=0
0=1

These are the commands you will need when you want a specific command to execute,
only when certain conditions are met. In case you don't understand the table, here is a
simplified version.

AND Both have to be true


OR At least one has to be true
XOR Only one must be true (Exclusive OR)
NOT Makes a true a false and vise versa
NAND At least one has to be false (NOT AND)
NOR Both have to be false (NOT OR)
XNOR Both have to be false or true (NOT EXCLUSIVE OR)

It is important to note that in LabVIEW a Boolean True/False is not the same as a


numeric 1/0. You need to insert a Boolean to (0/1). You need this in cases when to
multiply a number by 0 or 1 dependent on the result of an operation. It probably would
have been more correct to write the table using Trues and Falses, but it would have
been too cluttered. You can also change numbers to Boolean operators. Be careful
when using this option because it takes the binary equivalent of the number, such as a
decimal 6 is equal to 01100000000000000000000000000000 in binary. Before you get
angry, this is because it is represented as a 32 bit number, and written backwards
because that is the way LabVIEW does it. You could change the Representation of 6
to a byte (again by right clicking) if you need to save memory. This can be helpful
when controlling multiple switches and are in need of a control.

You can connect two numbers to a Boolean logic operator, but the result may be
confusing to you. LabVIEW converts the decimal number to binary and then performs
a bit by bit comparison between the two numbers. For Example: ignoring the end
zeros and reading backwards
6 AND 10 is equivalent to 0110 AND 0101 which is 0100 the same as 2. Try it.

Case Structure

Boolean operations can help in If, Then, Else sequences in text programming. You can
use the Case Structure (found under Structures) as an If, Then, Else sequence.
If the conditions are met,
Then, do something
Else, do something else.

Use of the Case Structures are fairly straight forward. The little green question mark
on the left is where to connect the Boolean operator output, or Boolean True/False
control. By clicking on the arrow bars on the top you can scroll between True and
False. This is what is used for the if/then/else loop. Here is an example of how the case
structure should look. Notice that a black "tunnel" is good, and a white tunnel is bad.
All possible cases must have an output. Even if you don't want anything to happen,
just connect the wire to the other side. If you need more than an if/then/else, you have
two choices, either connect a numeric integer control (0,1,2,...) or use an Enumerated
Constant which allow you to define as a word, such as Sine Wave, and Cosine Wave,
to be defined in the diagram, or controlled from the front panel by creating a control.
Just be sure to define a Default Case, i.e. what to do if nothing matches, and make sure
outputs are defined for everything. For both of these just connect them to the little
green question mark, it will turn blue. When you use these you will probably need
more than two cases. Simply choose Add Case, or Duplicate Case. If you are using a
number, the cases will increment. For the Enumerated Constant, I would type in the
name first, then add a case. A Ring Constant is just a Enumerated Constant with one
value.

Comparison
Now that you have been introduced to the Boolean logic system, the comparison
operators are what you will need to yield Boolean results. Next to arithmetic, everyone
is familiar with the concept of comparison: equality, greater than, and less than.
Comparing 5 > 6 would return False, and the wire color is green. There are some
problems comparing the values NaN, Inf, and -Inf because they are all undefined. You
can convert them to a String and compare them that way. Strings can also be compared
because if you remember the letters are really just seen as hexidecimal (0-F0 numbers
by the computer.

A simple version of the Case Structure is available if you only need to pass two
different values based on True/False. Select - If you wanted to pass 9 if true and 5 if
false, you would simply connect the Boolean Control to the "s", 9 to the "t", and 5 to
the "f", and the output would depend if the result was true or false. Try it.

Continue to Section 2
LabVIEW for Dummiees
Section 2
Back to the Beginning

For, While, and Sequence Loops

These are very similar to the for and while loops encountered in your first computing class.
A For Loop performs an operation for a certain number of times, say ten. The big N in the upper left hand corner
is the set number of times for the loop to execute.
A While Loop performs an operation while a certain condition is true, say the end of the file has not been reached.
The little round arrow in the lower right hand corner is the condition, that is, to keep the loop executing or not.
This has to be wired with a Boolean operator or the loop will execute only once, negating the purpose of making
a loop. Usually uses a comparison, Boolean logic operator, or simple control.
The little blue boxed i in the lower left hand corner is the iteration number. It represents the number of times the
loop has been executed. Needed if you want an operation to occur at a certain step.

A Sequence Loop, which looks like a piece of film, performs an operation after one has been completed, say after
acquiring the data, analyze the data. To add a Sequence frame, right click on the frame and choose Add Frame
After or Add Frame Before or Duplicate Frame. They will be used in sequential order according to the
numbering scheme on the top center. Many times you will want the data from a previous frame to be used in a
later sequence, Add Sequence Local, where you can attach any wire to be brought out in a later frame. An arrow
will show the direction of data flow. If you move a sequence local, it will move the same way in the other frames.
Little programming tip: If you are acquiring data aver a several minutes and need to enter some physical
constants needed after acquisition is complete, place the control for the physical constants inside the later
sequence, not outside the loop. This way while the data is acquiring, your data can be entered SAVING TIME!
This works because LabVIEW hasn't started on your data yet.

You may notice some problems when an Array enters a For Loop. What happens is the array is auto-indexed, i.e.
the array's value at the index of the iteration is used. If you don't like, click on the little black "tunnel", and
choose Disable Indexing. The Loop can also be used to build an array, by indexing the values to the iteration
number. Look at this for a comparison. As you can see, the while and for loops both have this feature. Once
again:
Enable Indexing allows you to build arrays for output, or auto-index input arrays
Disable Indexing allows you to just take the values as they come in or out.
By placing a Formula Node in the For Loop, and array can be evaluated, the number of times to evaluate is the
size of the array, and the array will be automatically rebuilt upon exiting.

In For and While Loops a Shift Register can be added to the loop by right clicking on the loop and selecting Add
Shift Register. This is invaluable when you need to use data from a previous loop in order to calculate the next
loop. By choosing Add Element, you can use the element from two iterations ago. For example, by adding two
elements, you can use the data from the previous three iterations.

Arrays

Arrays are invaluable. Nearly every application will need them. You can define vectors (a 1-D array) or matrices
(a 2-D array) or a general N dimensional array, like tensors. Although Arrays may resemble vectors and
matricies, they are not the same thing. This is how the basics work. Same principals for subtraction and division.
Scalar + Scalar = Scalar; 1+1=2

Scalar + Array = Array; 1+[1,2,3]=[2,3,4]

Array + Array = Array; [1,2,3]+[4,5,6]=[5,7,9], but [1,2]+[3,4,5]=[4,6]

Scalar * Scalar = Scalar; 4*5=20

Scalar * Array = Array; 4*[4,5,6]=[16,20,24]

Array * Array = Array; [1,3,3]*[4,6,2]=[4,18,6], but [1,3]*[4,6,2]=[4,18]

As you can see, only the values for the smallest array are used.
Even if you are not using vectors and matrices, they can be used to store a lot of data as one unit. Would you
rather try to keep track of a bunch of wires or one wire? Arrays are numbered or indexed 0,1,2,...,N-1, where N is
the size of the array. Arrays can be used for anything, Numeric, Boolean, String, etc. Just remember to keep the
same type in the array, that is, don't mix String and Numeric or Boolean. I have used most of the array operations
and they are all important.

1. Build array. First choose the build array element. Go to the bottom corner of the node and click and drag
till it's doubled. The regualr mouse arrow will change to a little corner. Create two numbers, and wire
them to each of the inputs, and create and indicator. Run and on the front panel you will see the numbers
combined into a 1-D array. Try with Boolean values and strings.
2. Initialize Array is invaluable in loops especially with a Shift Register. First connect an initializing value to
the element data, usually zero. If you need an N-D array, enlarge it like the build array. Enter the
dimension size(s) which is the length (and width) of the array. Create an indicator and see if it worked. A
little note, you can't initialize a random array by connecting the random operator to the element data. It
will be random, but the array will have the same value.
3. Index Array allows you to find the value at an index. Simply connect the array and list what index you
want. If you need a column in a matrix you can choose the Disable Indexing on the boxes in the lower left
corner to make a 2-D matrix into a 1-D vector. Be careful when using, it can be a bit tricky, check with
known values before you have rely on the program. See this on extracting a row/column from a matrix.
4. Transpose 2D Array simply flips the 2-D array over. That is, the rows and columns are interchanged.
5. Array Size simply tells the size of the array. If it is a 1-D array with 15 elements, it returns 15. A 2-D array
with 10 by 5 elements returns [10,5]
6. Interleave 1D Arrays - Takes two arrays of the same size and type and interleaves them. For example,
interleaving the two arrays [1,2,3] and [0,6,9] would result [1,0,2,6,3,9]. Order is important. If the sizes
are unequal, the size will be only twice the smallest array. Try it and see.
7. Decimate Arrays - Undoes the Interleave Arrays operation.
8. Array Max & Min - Finds the Max and Min values and the indexes.
9. Sort 1D Array - Sorts the Array in Accending Order. Either String or Numeric.
10. Add Array Elements & Multiply Array Elements - found under the Numeric pallet allow you to either find
the sum or product of all the elements in an array.

NOTE: Don't use the array constant without defining the type first, it won't work. You must insert a type.
That is, if you want a numeric, drag and release a numeric control inside. Same for a string, Boolean, etc.
Also, if you are moving the array on the front panel and accidentally drag one of the cells out, you'll get an
empty undefined array. Ctrl+Z to undo, or replace the array.
The Sort, Interleave, and Max/Min functions are avaliable. However, sometimes you may need to sort two 1-D
arrays with respect to each other, add an array onto the end of the other, or find the two highest and two lowest
numbers. Try making these VIs. This is how I did them.

Strings

Strings are needed whenever you are working with an alphanumeric sequence of characters. Most of the times
you will be using strings is in file creation and reading. You may have discovered that you can write notes on the
diagram by using the mouse cursor. This is not a string! It's only a note or label. A string must appear in Pink.
If you're not sure, try connmecting a wire to it. Choose String Constant. Type something in. Create Indicator.
RUN. What you typed will appear on the front panel. Not very impressive. Copy this sequence into the box after
changing it to '\' Code Display:
"This\sis\sa\stest\sto\ssee\sthe\s\t\stab\sand\s\r\nend\s\sof\sline\sbackslash\scodes."
Run it and you should see this on the front panel:

"This is a test to see the tab and

end of line backslash codes."

If you can't figure this out, here are what the \ codes mean. A complete list can be found under Backslash (‘\’)
Codes Display. Also there are the tab and end of line operators in the string box:
1. \s - space
2. \t - Tab
3. \r\n - EOL (end of line)

● Concatenate Strings is used to combine multiple strings and can be expanded in the same way as an array.
If you need a delimiter between strings, be sure to include it in the Concatenate Strings. Very useful when
need to combine a descriptive string with an array.
● Match Pattern - is very useful when extracting an alphanumeric character string from a file, such as
contains: name \s 10 20 30 .
1. name \s 10 20 30 is the String
2. \s is the Regular Expression
3. name is the Before Substring
4. \s is the Match Substring
5. 10 20 30 is After Substring
6. The Offset is where to start.
● Format Into String - takes a number and converts it into a string. You can't just wire a number with a
string. Also, you need to set the format string.
❍ Format - determines to what precision you want the number represented. Even if it is only an

integer, there are the invisible zeros. These are some you may need:
%.3f which is a 3 decimal floating point number. This is the default when saving files.
%.0f - an integer
%.5e - a floating point number to 5 decimal places in scientific notation
If you need others look in the String Syntax Elements Table >> Conversion Codes
● Array to Spreadsheet String - Works like the Format Into String except you need to insert a delimiter, but
the default is Tab. A problem you may encounter is the need to include the data from several arrays on one
line in a file. However, the array is converted with an end of line break. The way to remove this is by
using the Match Pattern, using the EOL character as the Regular Expression, and the data is contained in
the Before Substring. Then simply use Concatenate Strings to combine the strings. Be sure to include
Tabs between the strings and an EOL at the end.
● Spreadsheet String to Array - Transforms a numeric delimited string into an array. I use the way it appears
in my altered Read from Text File.vi.

The others I really never used or are self explanatory.

File Creation

Whenever you perform an experiment you need to save the results for later study. LabVIEW allows you to save
the data as simple text files (*.txt) which can be studied in Microsoft Excel, or another spreadsheet program. If
you need to create a file for the VI to read such as a control file or data file, you can form the file in Excel and
Just remember to save it as a Text (Tab Delimited) File. Before you start your data collection two things:

● Have all the necessary data included in your file(s)


● Know where all the data is being placed

These seem very simple and common sense, but many people forget.
There are Four File sub-VIs that you will use most of the time.

1. Write to Spreadsheet File.vi


2. Read from Spreadsheet File.vi
3. Write Characters to File.vi
4. Read Characters from File.vi

The other sub-VIs you may need for advanced work, but I never needed them.
Here are terms with which you need to be familiar with wire colors

● FILE PATH - The location of the file you want to read or write, such as C:\Windows\Desktop\myfile.txt
If you are working with a large number of files that need to combine strings to make a file name, you need
to use the String to File Path
● DELIMITER - The special pattern between the data entries, defaulted to Tab, no real reason the change
unless you are using another program to read the file that needs another delimiter. For example,
Mathematica needs comma delimited files.
● APPEND TO FILE - Put new data in the file, defaulted to False. Change to True especially if you are
acquiring data over a period of time
● CHARACTER STRING - The data has been converted to an alphanumeric sequence, needed if data
contains words and numbers.
● EOF (End of File) If you are reading the lines from a file, in a loop you will need to know when the end
has been reached. NOTE: If this is in a loop you will need the Boolean NOT to keep the loop
operating.
● Format - See under strings
● 1D Data and 2D Data - are used when you are using Array data in vector or matrix form. NOTE: If you
are extracting the data with a mixture of types, numeric and symbolic, only the numeric will be
extracted correctly.
● TRANSPOSE - flip the array over. Use when 1-D array very large (>256) or you just want a column
vector. Useful when you are going to analyze the data later in a spreadsheet.

Here is a little trick I learned. Whenever I needed to extract data line by line from a file, I modified the Read
From Text File.vi, by removing the pausing operation, the Match Pattern, and adding a control for file path. If
you are unclear here is how is should look

Well by now I have hopefully explained the concept of wiring, numeric, loops, Boolean
operators, Strings, File creation and reading. UPDATED! REAL LIFE EXAMPLE!!!
So here is your first QUIZ!!

Time and Dialog

When you have written your programs you sometimes need to inform others about errors when entering data.
This is done by using a Dialog Box

Click ME!!
Other times you may need to slow down the program. You may be thinking why? The reason is that sometimes,
especially when acquiring data or tracing a pattern, the program works too fast and you don't need data acquired
every millisecond. Once a second is enough. I use the Wait (ms) most of the time. Be sure to remember it is in
milliseconds or 0.001 seconds. That would make half a second 500 milliseconds. Another useful node is the Get
Date/Time String which gives the date and time as determined by the computer to the minute. Useful when
storing and dating your data. If accuracy is to the second is needed, Get Date/Time In Seconds gives the number
of seconds since 12:00 AM January 1, 1904, UT. Why 1904? Don't ask me. For most people that is useless. That
is why the calendar with days, months, and years was invented. By connecting the Format Date/Time String to
the previous node, the time is given as a string in a familiar notation. When I was writing this the result was:
08/12/99 03:17:35 PM . That is for the default case (%c). You may want to change it if you're European. Is it
Y2K or 2004+ compliant? I don't know. We'll find out very soon.

Graphing

Once you have taken all of your data, you need an easy way to visualize it. Unless you are very unusual, you can't
just look at an array of numbers and determine the result. The ability to Graph and gather data from those graphs
are two of LabVIEW's most important attributes. To obtain the graphs, you need to go the front panels and right
click to bring up the controls. You can choose from graphs or charts. Charts have a buffer, that is, they only hold
so many points. Charts are useful when acquiring data. When studying graphs I usually choose graphs. There are
three major types of graphs you will use.

1. Waveform which only needs the Y component, i.e. uses a 1-D array. It graphs the array's data over time.
2. X,Y Plot - Plots X vs. Y The X-Y plot is a Cluster consisting of Bundled Elements. This is a bit difficult
to explain. So I suggest you look at this picture. Try reproducing it.
3. Intensity - Plots the values of a matrix, i.e. uses a 2-D array. Kind of like making a picture.

Also by using a Waveform Graph and a Bundle with three elements, you can create a graph with an offset and a
set distance between points. All you will need is an array representing the Y values. On the bundle the first value
is the offset, i.e. where to start; the second value is the "dx", i.e. the horizontal space bewteen the points; and third
your array. Try it.

To make the graphs more user friendly, there are ways to interact with the graphs to extract data, label, zoom,
interpolate, and color. By right clicking and choosing Show >>

1. Label & Caption are basically the same thing allowing you to name your graph
2. Legend is all important for your display of data. You can choose
❍ Common Plots - Waveform, points, points and line, bar graph, base fill. I used the default usually

❍ Point Style, Line Style, Line Width, & Bar Plots, I think are self explanatory

❍ Fill Base Line - If you want to fill the region under the graph. I never used it.

❍ Interpolation - Only points, or connect the dots either as a square wave or as a even wave

❍ Color - Change the plots color. Very useful when examining more than one data set at a time

❍ X-Scale & Y-Scale I never did anything with it

3. Pallet - Allows you to zoom, set the precision and expression of the axes, or to auto-scale
4. Cursor Display - Move a cursor around the graph to study the plot. Lock to the plot, to point or allow to
drag (the padlock). The little rhombus on the right allows you to make minor adjustments either up, down,
right, or left by clicking. Only on appears on graphs. By using attribute nodes you record certain points.
Coming later
5. X-Scale & Y-Scale - Show the X or Y scale
6. Scrollbar - Allows you to scroll around the graph in the x direction. Only appears on Charts.
7. Chart History Length - Charts have a buffer size (default 1024 data points) so you can input numbers and
they will be displayed as a graph. You can change it, but don't be ridiculous, the buffer is usually
sufficient.

You can also change the graph ranges by clicking on the upper and lower bounds and replacing the numbers. If
you want a logarithmic plot, you can either insert a Logarithm Base 10, or choose X Scale, Y Scale >>
Formatting... to change the number to log, also once there you can change the digits of precision, the notation,
and if you want graph lines.
Continue to Section 3
Test 1
Question 1

By now you should know enough LabVIEW to perform a fairly rudimentary operation. I am writing this in
pseudocode so you should be able to follow. This may seem hard or dumb to you, but it contains the basics I
have covered in these previous sections, and give you an idea of how to convert thought to what to do. Also you
will probably use these techniques in many data analysis applications.
First INITALIZE a 1-D array with 5 elements of zero
WHILE the END OF FILE has NOT been reached

● IF the data is greater than one(1) and less than two(2) INCREMENT index 0 by 1
● IF the data is less than one(1) OR greater than or equal to two(2) DECREMENT index 1 by 1
● IF the data is equal to one(1) ADD index 0 and index 1 to index 3

Enter a STRING with the following message: "The result of this silly program is"
Convert final 1-D array to a string tab delimited to one decimal place
Combine the strings with a tab separating them, and save as myfile.txt on the desktop.

The data file you will need is here. Simply copy it into a notepad and save it as a text file.

The way I did it is only one way, there are much harder ways and probably some simplier ways. If you have no
idea what is going on, I would really appreciate you E-mailing me, so I can help resolve the problem.

Your results should look like this:

The result of this silly program is 20.0 -27.0 0.0 -1.0 0.0

Question 2

Here is a good thought and real life problem


You are building a refrigerator and need to keep the temperature between 35oF and 40oF. Now to economize,
you want the compressor to start if the temp is above 35oF, then stop and only start again when the temperature
has reached 40oF and continue until ir reaches 35o, and so on until you tell it to stop. Here is a graph to illustrate
the idea.
Perhaps in real life the graph wouldn't be so sinusodial, but I just wanted to illustrate what I was saying.
Your job is to build a VI that will read the temperature and tell the compressor when to go on or off. Now since
you haven't done the data acquisition and control section yet, and probably don't have a thermistor or
compressor avaliable, you just have to use a manual control and display. That is enter the temperatures
manually and create a boolean indicator to represent on/off compressor.

Programming tips:

● If this were a real life problem you have to solve, the compressor wouldn't need to be updated every
second, so you would insert a time delay to slow the program down
● You will need a shift register, case structure, loop, and Boolean operators.
● Before you try to tackle the problem, think it through. Break down your thought process to the simplest
leval so the computer will understand.

***CHALLENGE***
If you are taking or have taken a class in thermodynamics, make a model based on the properties of the
refrigerator, outdoor temperature, and other variables to simulate a real refrigeration system.

If you are totally lost here are the answers in the all zipped away in this file.
Back
This should cheer you up
1.203716701

1.041637056

2.5

1.128849454

0.641810569

1.432928346

1.000608333

1.185768472

0.643491517

0.941513667

0.817046883

1.428767604

1.137961096

1.127246486

0.899062058

0.899800904

1.156008301

1.368847096

0.658654918

0.861275888

0.801827854

0.962677376

0.665836896

1.395482069

1.240727617

1.397249918

0.602766938

0.985429163

1.111140011

0.717373513
0.536600313

1.162997848

1.013193783

0.787467404

0.928703247

1.005917026

1.322440912

0.903524533

0.725761893

0.918878184

0.513967686

0.887973864

1.002646613
LabVIEW for Dummiees
Section 3
Back to the Section 2

Attribute Nodes

Attribute Nodes are very important and can be a bit tricky to learn. There are over 100
different attribute nodes. I have only used a small number. For the most part they are
ways of computer controlling the display characteristics of the front panel. You can do
all of these things by right clicking and making the current values default. However in
certain circumstances, such as when you need to record the attributes for computation,
or you are concerned that someone will change the default values, they are extremely
useful. They can be created by Create >> Attribute Node. If you want it to be a
control, leave it be. Just remember to Create Control, or Create Constant. If you need
to collect data, Change to Read.

Making Works of Art

Here is a method where I used the attribute nodes to create a background curve by
literally drawing it. There are two ways of performing this operation, the simple and
the complicated, and I will tell you both. You will need these functions:
1) A Waveform or XY Graph (must have at least one XY Graph)
2) An Attribute Node with two elements with the selection Select Item >> Cursor Info
>> Cursor Position >> Cursor X then Cursor Y
3) A While Loop, Shift Registers, Case Structures, Initalize and Replace Array, and a
Time delay.

First the simple way


Bring out your two Graphs on the Front Panel. For your Artistic Pallet Graph, Show
>> Cursor Display then Create >> Attribute Node, and locate it on the diagram.
Double its size, Change All to Read, and choose the two elements listed above (#2).
Create a while loop with a Boolean Control on the conditional operator. Place the
attribute nodes inside the while loop, the Graphs shouldn't be in the Loop. Place a
Bundle outside the loop. Connect the Node to the Bundle which is connected to the
XY Graph control. Be sure to Enable Indexing at the tunnel on the While Loop. To
make the cursor work, just enter something. You will see a yellow cursor on the graph.
If all is well, RUN, and click and drag the cursor around. When you are finished, click
the Control OFF, and you should see your Work of Art!
This was the simple way and does have its limitations because, what if you want to
pause? Make a mistake? Or just want certain points? This next way is more general
and flexable.

Now the Hard One


First the logic behind it: (This isn't a computer code)

Initalize Array A[1000]=0; Array B[1000]=0; number=0;

While (ON)

GET point(x,y);

if(Start)

A[number]=x; B[number]=y;

number=number+1;

//Insert the cursor values into the arrays

else

{if((NOT Start) AND (NOT Pause))

A[1000]=0; B[1000]=0;

number=0;

//reinitalize to default for mistakes

if((NOT Start) AND Pause)

//just pass data through}

WAIT 100 ms;

}
I used this program to draw background curves. Above I mentioned a time delay
because with an array size of only 1000, LabVIEW would go though it in less than a
second, and if I had made the array size much bigger, there would be many more
points than are needed for curve fitting. You can reduce the wait, but I wouldn't
eliminate it. Make sure the Time delay is in the While Loop! I don't have more to
say. Try you hand at it. The most common error would be the confusing of the
Boolean operators. If you are lost here are the two drawing VIs zipped.

Well I could go through each of the Attribute Nodes, but I would be typing until the
next millennium. But just use these facts that any control or indicator can have them,
just choose Create >> Attribute Node and they can control or read the properties, or
attributes of the Front Panel Icon. The names are fairly descriptive and can alter the
graphing properties, foreground and background color, sizes of icons and text, to make
an icon visible or blink. Play around with them. If anyone completely confuses you, I
will be happy to add it.

Creating Sub-VIs

Imagine that you have just written a very complicated program. You feel really proud
and run it, but it doesn't work quite right. When you look over the wire diagram you
realize you missed an important complicated calculation. &#@*!! There is no way to
fit it in the diagram, and if you tried, probably more mistakes would be created. Or you
need a piece of code for several programs you are developing, and you don't feel like
rewriting it every time. In text based programs, you could just type or copy the code in
anywhere. LabVIEW uses sub-VIs which are sub-routines for functions you may use
many times. In fact most of the functions from file on down are sub-VIs. All sub-VIs
are squares, but not all squares are sub-VIs. An easy way of determining this is by
double clicking on the node. If a new VI opens, it is a sub-VI. Sub-VIs are completely
self sufficient programs, i.e. they can run on their own. The controls are the inputs and
the indicators are the outputs.
How to make a sub-VI:

1. Write your subroutine with the controls as the inputs and the indicators as the
outputs
2. Be sure to label the controls and indicators with descriptive and appropriate
labels

3. The little icon in the upper right hand corner , is where to make the node.
4. By right clicking on the icon and choosing Edit Icon..., you can put a short
description of what the sub-VI does. This is what you will see on the diagram
when you use it. If you are an artist, color it. When you are finished, click on
OK.
5. Make sure that you are on the front panel. Right Click again and choose Show
Terminals.
6. The square is automatically divided for the number of indicators and controls.
If you don't like it, you can choose a new pattern, add or delete terminals, or
rotate the terminals. Usually LabVIEW has a good idea of what to give. Just be
warned that the maximum number of terminals is 28. I never needed that many,
but if you do, there are two ways around it. Use more than one sub-VI by
breaking the subroutine in half, or by bundling the elements (See Clusters).
7. Get the wire spool. Try to keep the inputs on the left and the outputs on the
right. Click on the terminal, then click on the indicator or control, or vise versa.
The terminal will appear in the color of the wire. Keep repeating for the rest of
the terminals, but not everyone has to be used. Also, a sub-VI need not have
any outputs, or any inputs.
8. If a connection is a vital necessity, choose This connection is.... Useful if others
will be using the sub-VI.
9. SAVE IT
10. Go to your main program, and by using the functions pallet's very bottom icon
(Select a VI...), choose your sub-VI. By passing the wire spool over the sub-VI
you will see the connectors appear. Now you can connect. You can also insert
or replace a sub-VI.

NOTE: If you open a sub-VI from the program, and save it under a different
name and alter it, the other sub-VIs in the program may be altered that you don't
want. For example, in a program I was writing, I always wanted a temp file to be
rewritten, but the dialog box would appear, so I altered the file to remove the dialog
box appearance as I described and it altered the other file sub-VIs I wanted left alone.
You can search the VI for Problems, or Replace the sub-VIs you want changed. Be
sure to check!

Libraries

If you are making a program, it is just good programming practice to write sub-VIs
because they will make your diagram less cluttered, easier to test and study. However,
those little icons will take up much space. LabVIEW has a special folder structure for
its own files called a library (*.llb). When you File >> Save As... Choose New VI
Library, enter the name, VI Library, then save (*.vi). To put more VIs there, just
click on the library icon when you save.
If you have many VIs in the library and just want the main program to open when you
start. File >> Edit VI Library, highlight the main program, and choose Top Level,
while you are there you can also delete any obsolete VIs. Repeat as necessary. NOTE:
Only LabVIEW objects can be stored in the library, not just anything (such as
text files).
Close LabVIEW, when you click on the library icon, the main program will open
automatically.
User Libraries

If you create a new VI that you believe is important enough to be placed perminantly
on the functions pallet, if you save it in the User Libraries folder, it can be accessed
very easily.

Data Acquisition

Before I tell you about how to program for Data Acquisition, you need to know how to
connect the hardware. The data acquisition (DAQ) device we have here is a PCI-MIO-
16E-1. The configuration we used is (Under the NI-DAQ Configuration Utilities
<-10.0V - +10.0V><Referenced Single Ended><Bipolar><None><Disabled>
If you have no idea how to use it, here is how the first electronic nose team did it.
When the DAQ board came we unwrapped it carefully. There is a board you have to
insert into the computer. We put it into a slot where it fit (I'm not a computer
engineer). Turned the computer on and it worked! Afterwards we waited for a month
for the cable and the DAQ connection board. The company said we didn't specify it
when we ordered. Make sure all the software is installed. Find a friend and a
multimeter. Just in case you can't find a multimeter, you can use a LED (light emitting
diode). Be sure to attach a resistor or it will burn out! Go to the NI-DAQ for
Windows, and view the NI-DAQ Test Panels.

Symbol meanings on the DAQ board

ACH# Analog input channel #


AIGND Analog input ground
DAC#OUT Analog output
DIO# Digital Input/Output (5 V)
DGND Digital Ground

Find the DIO0 and DGND pins (on my board 52 and 53), place your two multimeter
probes on the "screws". You should register +5 V. If it is negative, you have the
probes backwards. Once you have reached the test panels, go to the Digital I/O where
there is a long row of circles. Move your mouse to the second row left hand side where
there should be a clear circle above the 0. CLICK! If you did this right, the voltage
should reduce to ZERO. Find the other Digital I/O pins on the DAQ board and click
on the corresponding circles. This can get exciting when it works for the first time. By
connecting a MOSFET to the board (not the DAQ board, your own circuit of course),
you can operate a solenoid switch.

Find the DAC0OUT and the AOGND pins (on my board 22 and 55), and place the
multimeter on the "screws". You should register 0 V. Go to Analog Output on the Test
Panels. Output a DC Voltage anywhere between -10 V and 10 V. The multimeter
should register the voltage being put out. If you are using a LED, the intensity will
change.

Find the ACH0 and AIGND pins (on my board 68 and 67), get a 1.5 V battery (if you
can, a calculator battery is fine), and two wires. Make sure the battery has some life
yet! Go to the Analog Input Panel. The chart should be nearly constant, there is always
some noise. If there is some drift, don't worry, you just need to connect it to a ground.
Connect your battery terminals to the two pins and voltage should jump to +1.5 Volts,
or whatever the battery voltage is. If it's negative, your backwards. Use the Multimeter
to compair the two voltages. The agreement is usually very good.

If you need more specific info on the technical specifications see the user's manual that
comes with the DAQ board. Now that you are familiar with the location of the pins
and what they do, I will explain what the electronic nose group used the DAQ board
for.

● Analog Input was used to detect voltage changes in the electrochemical sensors
due to the reaction caused by the gas. Due to the relativly slow response of the
sensors, 100 points were averaged over one second intervals. Also op-amps and
potientiostats were used to amplify and filter the signals. If you want to know
more about Electrochemical Sensors, See this site
● The Digital Trigger was used for precision control of solenoid switches. The
use of a MOSFET (Metal Oxide Silicon Field Effect Transistor) used the
voltage difference to turn a switch on and off.
● Analog Output was used to output a constant voltage between 0 and +2 Volts to
change the temperature of a filament

Be mindful that our needed data acquisition rate was slow. If you need faster rates or
more control over your hardware, you can design your DAQ VI from the elementary
parts used in the common DAQ VIs. Here are the sub-VIs we used.

1. AI Sample Channels.vi - You will need the device number which can be
determined when you open the NI-DAQ Test Panels. The channel numbers
which are written in a string comma delimited. The high and low limit don't
have to be wired, they use the values set down in the NI-DAQ Configuration
Utility (-10 V to +10 V). The output (Samples) is a 1-D array. Connect it to a
Build Array to make a 2-D array which defines the values as different plots.
Finally connect this to a Waveform Chart. Make sure to have all this in a While
Loop.
2. AO Update Channel.vi - Three simple things
a) Device - same as above
b) Channel Number - a string 0 or 1
c) Value - How many volts between -10 V and 10 V.
That's all there is too it.
3. Run_me.llb/Getting Started Digital I/O.vi - This is what I used for the control
of the switches. But I had to alter it. Remember to save it under a different
name!! The program uses a cluster to control the ON/OFF. Just run it to see if
it works. Look at the diagram to see what is happening.
A cluster of 8 Boolean Switches moves to the Cluster to Array which moves to
Boolean Array to Number and so on.
You could just use the cluster as a manual control, but it becomes more
difficult if you want to control from a file. I deleted the Custer and Cluster to
Array, and made a control going to the Boolean Array to Number. Now enlarge
the array to 8 elements and try it. It is as good as the original. Try it to make
sure. Now reconnect the terminals, so you can have your sub-VI. I didn't bother
altering the rest. In your control file you need to have interger numbers. If you
are just going to be using one switch, use 0 and 1 for on and off. If you need to
control more switches, refer to Boolean Section to see how LabVIEW converts
from number to boolean array. Connect the control to a Number to Boolean
Array. You may be thinking, why didn't I just use the number as the control
since it will be converted back anyway? Well, this way you can see the boolean
control, and will know which switch is on.
When you connect the program in your main diagram, you may have a
problem. The first time we tried it, it kept switching on and off between each
iteration. I made the "Port Configure" a control in the main program and made
"configure the port for reading or writing" the default. I just had to hide it
behind a graph, and it worked fine. Sometimes if it isn't working right try
anything.

Control Files for the Outputs are very easy to create. In Excel or another spreadsheet,
enter the numbers in a column and save as a Text File (Tab Delimited). If you want a
time value to see how far along you are, just insert it in another column. By using the
Read Lines from File.vi as an example you can extract the values, convert to a number
and input to the Output sub-VI.

As a good exercise, I suggest you look at a recent issue of Scientific American in The
Amateur Scientist section. There are some inexpensive and interesting projects where a
DAQ system could be useful.

Analysis

The Analysis sub-VIs in LabVIEW covers just about every possible need for
analyzing and creating data series. You can create a many types of wave patterns.
Look under Signal Generation. Try connecting the different sub-VIs to Waveform
Graphs and view the results. Alter the inputs and observe the changes. Also try adding
waves.
For some of the analysis VIs, if you need to know the mathematics behind their
operation, use the Online Help, and you will see the Name Details. Not every VI will
have them. The analysis VIs are very easy to use, usually only needing the input data.
Under Digital Signal Processing you can perform FFT (Fast Fourier Transform), but
only if there are 2x points. However, LabVIEW automatically looks for the number of
points, and if it's not 2x points, the DFT (Descrete Fourier Transform) is implemented.
Also avaliable is the Hilbert Transforms, and Derivatives and Integrals (Numeric
only!).
The Most important sub-pallet is the curve fitting VIs. You can perform any order
polynomial or exponential fit on data series and the points need not be identically
spaced, any X and any Y. For a N order polynomial fit you need at least N+1 points. If
you need a smoother curve, a possibility is using an even coefficient fit, i.e.
a0+a1x2+a2x4+... This can easily be accomplished by squaring the x points before they
enter the poly fit, and use the original x's when the fit points are generated. NOTE:
The Y points generated are for the original X points entered. If you entered the
points [(1,23)(4,2)(5,7)], the result would be [(1,Y0)(4,Y1)(5,Y2)]. Also the default
for the polynomial fit is SVD. I noticed some problems when I used it. I like to use the
Housholder instead.

The basics of Probability and Statistics, filters for cleaning waves, the tools necessary
to perform Matrix operations, polynomial evaluations are all available. It would take
too long to explain all of them. If you need it, you will know how to use it. If anything
completely confuses you, I will be happy to add it.

Other Stuff

Clusters

Clusters can best be describes as all purpose arrays. While arrays can only hold data
from one wire type, Clusters can be used to hold data from all wire types, including
cluster. Clusters are used mostly for X,Y Plots and errors, but can be useful to limit the
amount a wires in the diagram. Here are important terms:

1. Bundle - Used to combine any combination of your needed wire types. Just
enlarge and attach as needed. It is a good idea to have a different descriptive
label name for each of the items. If you don't have them coming from a direct
control or constant, Create Indicator and name it. As a starting point the Source
Element doesn't need to be wired. To replace an element in the cluster, wire
your original cluster to the Source Element, make sure the Bundle size is the
same as the original, and only add an input to the element you want changed.
2. Unbundle - Quite simply, it undoes the bundle operation. All you have to do is
make sure that the size is the same, and then just wire them to indicators or the
rest of the diagram.
3. Bundle By Name - If you have a large bundle and just want to replace one or
two of the elements in a cluster, you can tell the VI to replace only the element
with a particular name. This is why I told you to label the inputs before! Wire
the cluster, then Select Item >> "Whatever", and wire your new value. This is
analogous to the Replace Array.
4. Unbundle By Name - Can you guess? Same thing as above, just the item will be
an output.
5. Cluster to Array & Array to Cluster - They do what they sound like. However,
it only works for elements individually clustered, that is only individual
numeric and Boolean.
6. Here is an example of the bundling operations for clusters. Reproduce them and
try your own.

List & Ring

An interesting feature of LabVIEW is the ability to choose from a List, if you want the
VI to do a particular thing. Think of the List as an "Ordered List <OL>" in HTML, i.e.
each description is preceded by a number. To see what I mean, on the Front Panel call
up the Control >> List & Ring >> Single Selection Listbox. Now you will see a box
where you can enter your different names, a different item is made by hitting the Enter
Key. Look at the terminal on the diagram. This is one thing I don't like. It is looks
exactly the same as a Long Interger. Make an indicator to the control. You will see a
regular digital display. Put the VI on Continuous Run, and click on the different
words. You will see the number change. This could be connected to a Case Structure
and work like a bigger Enumerated Control. The Multiple Selection Listbox allows
you to select more than one item, and appears as a 1-D array. However, to select
multiple items you must hold down the Shift Key when you click on the item. You can
also add symbols in front of the name by choosing Show >> Symbols, then Item
Symbol, where you can choose what you want. From the diagram you can get a
symbol from the Functions Pallet >> Numeric >> Additional Numeric Constants >>
Listbox Symbol Ring, and by using the hand, choose your symbol. Be sure to take a
look at the Attribute Nodes, where you can control the size, need click or double click,
and symbols.

Advanced

If you are an old softy who craves the good old days of text programming and are
being forced to learn LabVIEW, you can still use your beloved FORTRAN, BASIC,
C++, etc. You can't just use the text programming. You need to compile them and they
need to have *.lsb extension. Get the Code Interface Node (CIN). Connect the Input
terminals you will need and label them. Create .c File, write your code in the file
LabVIEW gave you, compile, and Load Code Resource.... This should work. I have
never used them.
Another feature in LabVIEW is the ability to call Dynamic Link Libraries (*.dll),
which are the big computer programs that your computer needs to operate. Call
Library Function uses the *.dll files. By using these you can call programs not
normally used for LabVIEW. My opinion on this is that instead of trying to link
another program to LabVIEW, just use the program that was given to you.
Also here is the Beep function. In Windows it doesn't do much, just a "phllp". Place it
in a while loop and you get a longer phllp. Apparently on a Macintosh, you can control
the amplitude, frequency, and duration. If you want music or nice sounds, use the Play
Sound.vi, and just name a *.wav file you acquired from somewhere else. You can
insert it in a program as a sub-VI. I'm not sure, but you may have to create the
terminals to make it a sub-VI. I don't remember if they were included originally.

Application Control

This pallet contains the necessary controls for controlling the operation of the VI. The
only one I have ever used is the Stop which stops the VI in its tracks, the same as
pushing the stop botton on the tool bar. Also you can call up menues and help tools.
Not used very much.

Communication

I have never used this but it can be used to access the internet for remote access
devices.

Instrument I/O

Since we disn't use any other instruments, I have no experience with them. They use a
GPIB (General Purpose Interface Bus), this his used for control of outside instruments
by sending ASCII text to acquire data turn on/off, etc. Each instrument has its own
ASCII codes but they try to be written to be easily convertable using the IEEE 488.2
standard.
Instrument Drivers contains the VIs necessary to control the HP33401A Multimeter.

Acknowledgments

Finally thanks to all the people who helped me learn LabVIEW, offered guidance on
the tutorial, and gave me inspiration.
The Entire Electronic Nose Team
Dr. P. Lykos
Dr. J.R. Stetter
Dr. W. Penrose
Schattke Chemical Consulting
Asha Joesph
Harald Edvard Ziel Opsvik - Inspiration behind the Compressor example in the Quiz
If I missed you, tell me and I will include you.

I would appreciate it if you would send some feedback so I can


better design this tutorial to fit everyone's needs
Name:

E-mail:

Homepage or other LabVIEW site:

Comments/info or Problems?

SEND CLEAR

Copyright © 1999 Christopher Morong All Rights Reserved


Last Updated 8/26/99
THE ELECTRONIC NOSE
The electronic nose is an emerging technology dedicated to the detection and
classification of odors. I have been working on an Interprofessional Project (IPRO) at
the Illinois Institute of Technology over the past two semsters with Dr. Peter Lykos,
Dr. Joseph Stetter, and Dr. William Penrose. We have been able to design an
electronic nose from scratch that is composed of an array of chemical sensors and a
data acquition unit. My main project was to develop the software neede to catalog the
sensor responses and use a neural network technique or a statistical means to identify
the signal. In the end I opted for a method called Principal Component Analysis. You
can visit the E-Nose home page which includes many other interests including the
sampling, circuitry, experiences, etc.

I have also been doing coffee research. Some excellent websites can be found here.

Here is a new addition made the the electronic nose. Do to Dr. Stetter's and Dr.
Penrose's research we installed a filament which acts like a pseudo-mass spectrometer.
Saturated hydrocarbons (Like methane), and aromatics (Like toluene) are relatively
inert to electrochemical sensors. We try to break them down by "burning" them in air.
The animation represents methane, CH4, not being effected by the OFF filament, but
burning in air to product CO, H2O, CO2, and nitrogen oxides (NOx) when the filament
is ON.

We have results, and as soon as a can place them here I will.


Principal Component Analysis and the
Chemical Composition of Coffee Odors

One of the most essential features of an electronic nose is to find a way of correlating human responses with the
responses of the sensors. This can be accomplished by using a neural network to analyze the pattern of the data, and
compare the pattern to an unknown. Each of the sensor's responses could be plotted on an axis. However, when
there are more than three sensors, visualization becomes impossible. Principal Component Analysis (PCA) takes
the points plotted in higher dimensional space and reduces them to be displayed on a 2-D plane while keeping the
relationships between the points constant. A graphical representation allows the user to find patterns, and perhaps
correlate the responses to the characteristics of the smell, that is, sweet, offensive, green, nutty, etc.

The odour causes a response in the sensors which is amplified by the circutry, and is sent to the computer via a data
acquisition board which is then analyzed by LabVIEW, which uses a graphical programming language to produce a
virtual instrument (VI) which can be interacted with like a real instrument. The HAL2001.vi will be able to acquire,
display, and analyze the data and find the patterns by using the Eigenanalysis.vi as described below.

The Eigenanalysis.vi performs a principal component analysis by performing the


following steps.

1. The data is taken and scaled by subtracting the mean and then dividing by the standard deviation (x-
(Σx/N))/(σ) for each sensor to produce data with a mean of zero and a standard deviation of one. This is
done to prevent any one-sensor reading from dominating over the other sensors.
2. All of the scaled data is put into an m x n matrix, A.
3. ATA produces an n x n matrix.
4. The eigenvalues (λ) and eigenvectors (V) are calculated.
5. The variance is (λk)/Σ(λk) The more variance, the more data a sensor contains, that is, more information is
included in the axis.
6. The eigenvectors corresponding to the two largest eigenvalues are taken.
7. The dot product of each data run is taken with the two eigenvectors to produce a scalar product (X, Y).
8. The two numbers are plotted on a graph and trends and relationships can be seen.

Here is a plot of different coffee odours using sensor data taken from the MOSES II
The C's represent the coffees and the U's represent the unknown coffees which were taken from the knowns at a
later time.The distances are proportional to the likelihood of relationship. As you may see, the sensors don't
produce responses at the same point for the same coffee. The most likely reasons for this fact are that the sensors
don't recover enough to give the same reading. A longer clean air flush time may help. The sensors also aren't
perfect. Over time and exposure to chemicals, the surfaces degrade and can't be expected to produce the same
response.

Chemistry
Also I have been doing research on the chemical composition of coffee. Here are some informative websites.

Jamaican Coffeeis an excellent site listing coffee facts and GC/MS data for the major constitutents in coffee and 3-
D representations of the molecules. Be sure to get the Plugin!

Coffee Brewing is an OK site. The main thing it lists is the chemicals in coffee.

The following are from SIS Application Notes which contain research papers that address headspace and other
techniques of organic volatile preparation for GC and GC/MS experiments.

Comparison of Sensitivity of Headspace GC, Purge and Trap Thermal Desorption and Direct Thermal Extraction
Techniques for Volatile Organics

Direct Analysis Using the Short Path Thermal Desorption System

Flavor/Fragrance Profiles of Instant and Ground Coffees by Short Path Thermal Desorption

Direct Analysis of Spices and Coffee

Click me for Home

cmorong1@hotmail.com

S-ar putea să vă placă și