LabVIEW for Dummiees©
First Edition

Table of Contents

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

Click on the section you are interested in

Structures Numeric Boolean String Array Cluster Comparison Time & Dialog File I/O Analysis Data Acquisition Select a VI... Application Control Advanced Communication Instrument I/O Tutorial Instrument Drivers User Libraries Functions Pallet

Click on icon for description of each tool


File Edit Operate Project Windows Help Run Continuous Run Stop Pause Watch Running Single Stepping Font control Alignment More Alignment Tool Bar


Operates the Controls Move icons, and controls around Write text Wires the nodes together Same As Right Clicking Scroll around the diagram Insert a breakpoint Probe Copies a background color Colors a background Tools Pallet

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. x y x+y x, y, x+y 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: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
1
1
0
0
Y
1
0
1
0
X AND Y
1
0
0
0
X OR Y
1
1
1
0
X XOR Y
0
1
1
0
X NAND Y
0
1
1
1
X NOR Y
0
0
0
1
X XNOR Y
1
0
0
1
Not 1=0Not 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
OR
XOR
NOT
NAND
NOR
XNOR
Both have to be true
At least one has to be true
Only one must be true (Exclusive OR)
Makes a true a false and vise versa
At least one has to be false (NOT AND)
Both have to be false (NOT OR)
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