LabVIEW Fundamentals

Hans-Petter Halvorsen

LabVIEW

LabVIEW is a graphical programming language, and it has powerful features for simulation, control and DAQ applications. LabVIEW is developed by NI/Emerson. They have Professional paid versions or a free Community version for personal, non-commercial, non-academic and non-industrial purposes.

 

Below we see a typical LabVIEW program:

Since LabVIEW is a full-blood programming language (in a graphical way), you can use LabVIEW for almost everything, personally I use LabVIEW for Datalogging and Monitoring, DAQ, Control Systems, OPC, Database Systems, SCADA Systems, Hardware in the Loop Simulations and Testing, Modbus, etc.

LabVIEW (YouTube) - This video introduces the LabVIEW Programming Environment.

LabVIEW Fundamentals (YouTube Playlist) - This video series introduces all the key concepts and fundamental parts in LabVIEW.

LabVIEW Fundamentals Tutorial (PDF)

 

Installation of LabVIEW

Open the links below in order to download LabVIEW:

LabVIEW Software

Note! LabVIEW 32bit version (even if you have 64bit operating system) is recommended because some features and toolboxes are only supported by the 32bit version of LabVIEW.

You can use LabVIEW in Evaluation mode for some weeks, after that you will need a valid Serial Number. The Serial Number is provided by the LabVIEW responsible at your University/Workplace (assuming they have a valid license).

 

 

LabVIEW Programming

LabVIEW programs are called Virtual Instruments, or VIs, because their appearance and operation imitate physical instruments, such as oscilloscopes and multimeters. 
In LabVIEW we have 2 different windows; the Front Panel and the Block Diagram. We will introduce the "G" programming Language, LabVIEW IDE, Data Flow Programming, LabVIEW Programming vs. Text-based Programming, Front Panel, Block Diagram, and Wiring in LabVIEW.

 

LabVIEW (YouTube) - This video introduces the LabVIEW Programming Environment

 

You will learn the following main featues in LabVIEW:

 

You should watch the Videos/Tutorials below for each topic. Make sure to actually do the examples in the videos by yourself in LabVIEW. At the end you will find a LabVIEW Project where you need to use all your acquired LabVIEW skills in order to make a LabVIEW Application of your own choice.

 

 

While Loops

Loops allow you to repeatedly execute a specific portion of code. The different Loops and Structures available are located in the Structures subpalette in the Functions palette on the Block Diagram. The most important loops are For Loops and While Loop.

Below you see a basic While Loop:

 

While Loops in LabVIEW (YouTube)

 

For Loops

Loops allow you to repeatedly execute a specific portion of code. The different Loops and Structures available are located in the Structures sub palette in the Functions palette on the Block Diagram. The most important loops are For Loops and While Loop.

Below you see different alternatives to use a For Loop.

 

Below we use the "auto-indexing" feature by looping throug an array of elements:

 

For Loops in LabVIEW (YouTube)

 

Plotting

LabVIEW has powerful features for plotting your data. You can graphically visualize data in LabVIEW using two basic methods: a waveform chart and waveform graph. This module introduces a waveform graph and a waveform chart and explains when you should use them.

 

Plotting in LabVIEW (YouTube)

 

SubVIs

SubVIs are VIs within your VI. They increase readability and reusability. SubVIs are like functions or methods used in other programming languages.

 

SubVIs in LabVIEW (YouTube)

 

Case Structures

Case structures are some of the features you probably use most in LabVIEW. It is similar to using "If .. Else .." in text based programming languages. In LabVIEW we dont have If.. Else, so we need to use the Case Structure.

 

Case Structures in LabVIEW (YouTube)

 

State Machine

We will create a basic Application in LabVIEW where we will use the “State Machine” principle. Using this basic principle, you can easily create larger applications in LabVIEW. It is also easy to extend the Application with new features.

 

State Machine in LabVIEW (YouTube)

 

Arrays

Typically, when dealing with data logging, etc, you need to deal with arrays. LabVIEW has lots of built in functions for manipulating data within arrays.

 

Arrays in LabVIEW (YouTube)

 

Clusters

Clusters grouped data elements of mixed types, and handy to use when you want to structure your data into a manageable package. It's similar to struct or record (or a "miniature" class) used in other programming languages.

 

Clusters in LabVIEW (YouTube)

 

Property Nodes

Property Nodes, Invoke Nodes and References are powerful features in LabVIEW. Lets start with Property Nodes.

 

Property Nodes in LabVIEW (YouTube)

 

Formula Node

We use the Formula Node to create equations, calculations, mathematical expressions, etc. Simulations, etc. The Formula Node uses C syntax.

 

Here you see the Formula Node used in a simulation application:

 

Formula Node in LabVIEW (YouTube)

 

Write and Read Data Files

Very often you may need to write and read data files, you may log data from a temperature sensor you want to save to a file, etc.

Write/Save Data to File Example:

Open/Read Data from File Example:

 

Write and Read Data Files in LabVIEW (YouTube)

 

Debugging in LabVIEW

Debugging is the process of locating and fixing or bugs (errors) in your computer program code, in this case your LabVIEW program. LabVIEW has powerful features for Debugging your Code, such as: Broken Run Arrow, Highlight Execution, Probes and Breakpoints.

 

Debugging in LabVIEW (YouTube)

 

 

Project Explorer

The Project Explorer lets you structure all your files that your LabVIEW Application consists of, similar to, e.g., Solution Explorer in Visual Studio. You also need to use the project Explorer if you need to create executable files, or create more advanced applications like Real-Time Applications, etc.

 

Project Explorer in LabVIEW (YouTube)

 

LabVIEW Project

Create a LabVIEW Application of your own choice. It should contain basic LabVIEW features like While Loop, Case Structure, SubVIs, Arrays, Property Nodes and Clusters, etc. You should use the Project Explorer.

Here you see a LabVIEW Slot Machine (YouTube) Example (Download LabVIEW Slot Machine). Here you find some LabVIEW RFID Reader Examples.

Make sure to create a proper GUI (Graphical User Interface).

Some Examples (if you lack ideas):

Use your imagination. Create something you are interested in and passionate about, in that way you learn so much more. Do it because you want to learn, not to satisfy my "requirements". Don't make the same application as everybody else in your class. Surprise me! Don't always go for the easy solution! Challenge yourself!

Please follow the LabVIEW Programming Guidelines (pdf) as shown and explained in this video: LabVIEW Programming Guidelines.

Note! By using a simple LabVIEW State Machine you can create more advanved LabVIEW Applications in a simple manner!