Basic LabVIEW Programming

Hans-Petter Halvorsen

Delivery  

Introduction

Video: LabVIEW in Automation - Basic LabVIEW Programming

Prerequisites: No skills needed

 

LabVIEW

LabVIEW is a graphical programming language, and it has powerful features for simulation, control and DAQ applications.

LabVIEW is developed by NI/Emerson.

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

 

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).

 

 

Getting Started with LabVIEW

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.

 

Video: Getting Started with LabVIEW

Tutorial

 

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 by yourself in LabVIEW. Then do the Exercises for each topic.

 

 

While 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.

 

Video: While Loops in LabVIEW

Tutorial

Exercises

 

 

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.

 

Video: Plotting in LabVIEW

Tutorial

Exercises

 

 

SubVIs

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

 

Video: SubVIs in LabVIEW

Tutorial

Exercises

 

 

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.

 

Video: Case Structures in LabVIEW

Tutorial

Exercises

 

 

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.

 

Video: LabVIEW Arrays

Tutorial

Exercises

 

 

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.

 

Video: LabVIEW Clusters

Tutorial

Exercises

 

 

Property Nodes

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

 

Video: LabVIEW Property Nodes

Tutorial

 

 

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.

 

Video - LabVIEW Project Explorer

Tutorial

Exercises

 

 

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.

 

Video - Desbugging in LabVIEW

Tutorial

 

 

LabVIEW Programming

Now you have learned the basics regarding LabVIEW Programming, such as Front Panels, Block Diagrams, While Loops, Plotting, SubVIS, etc. The video below summarize all these things.

Video (LabVIEW Programming)

LabVIEW Tutorial with Examples and Exercises

LabVIEW Code to most of the Examples and Exercises

 

LabVIEW Programming using State Machine

Typically engineers often create simple LabVIEW VIs that eventually grow out of control, because they don't have the proper structure and best practices. The solution to this problem is organizing your code and data in a way that enables modularity, readability, and reuse. Using a state machine approach is a good way to make it right from the early beginning.

The state machine is one of the fundamental architectures LabVIEW developers frequently use to build applications. It is reccomeded that you learn and use the LabVIEW State Machine principles when creating your applications.

In LabVIEW software, you can create a basic state machine with a While loop, a Shift Register, a Case Structure, and some form of case selector.

Video: LabVIEW State Machine - Basic Application

Video: LabVIEW State Machine - Advanced Application

Tutorial

Download Code

 

You should now be ready to make your own LabVIEW Applications.

 

 

LabVIEW Applications and Examples

To get an idea of what you can create with LabVIEW, see the following videos below. Note! These videos are presented only to get you inspired, and to see what LabVIEW is capable of. Perhaps you can get some ideas for your Delivery (see below)?

Example 1

Data Logging and Monitoring in LabVIEW Example (Video)

Read more (including downloading the LabVIEW Code)

 

Example 2

LabVIEW Application Examples (Video)

Read more (including downloading the LabVIEW Code)

 

Simple LabVIEW VIs vs. LabVIEW Applications: Typically engineers often create simple LabVIEW VIs that eventually grow out of control, because they don't have the proper structure and best practices. The solution to this problem is organizing your code and data in a way that enables modularity, readability, and reuse. Using a state machine approach is a good way to make it right from the early beginning. In the LabVIEW Application Examples above, this approach has been used when developing the LabVIEW applications.

 

 

LabVIEW Programming Guidelines

Typically engineers often create simple LabVIEW VIs that eventually grow out of control, because they don't have the proper structure and best practices. The solution to this problem is organizing your code and data in a way that enables modularity, readability, and reuse.

Some examples are:

For more details, see the video below.

Video: LabVIEW Programming Guidelines

PowerPoint used in the Video

 

 

Delivery

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!



Submission: Document your LabVIEW Application (both GUI and code) and deliver a PDF (e.g, 5-8 pages). Here you find a Word Report Template you can use for your report. You can use another template if you prefer. Make sure you fulfill all items in this Checklist (pdf) before you deliver your Report.

Where should you deliver? Canvas

What should you deliver? Only PDF File - No LabVIEW Code

The text should primarily be reflective and not descriptive. The text should not merely describe what has been done, but also why and how and what the results are. The outcome needs to be put into relevant context.

The document (pdf) can be built up as follows (the so-called IMRaD model):

  1. Introduction: This documentation can start with a brief introduction, i.e. describe what you have made, what is the purpose with the program, etc. Typically, you should also include a System Sketch (video). A System sketch is an illustration/figure of your system, the different parts the system consists of, and how they relate to each other.
  2. Methods and Results (Overview of the Work that has been done and the Results): Include one or more images of the User Interface (Front Panel) and Code (Block Diagram). These should also be briefly described in the text.
  3. Discussions and Conclusion/Summary: Discuss your Results. Finally, a brief summary/conclusion of your work. Does you program work as expected? Why/Why Not, any improvements that needs to be made with your program, etc.

Write Technical Reports in Microsoft Word - Here you learn the basic structure of a Technical Report, how to insert Figure Captions and refer to those in the text, how to insert Equations and refer to those in the text, how to add References, etc.

More information about IMRaD.

Make sure to insert Figures, Tables and Equations correctly, please see the video Equations in Word and PowerPoint.

Referencing: If you have used external sources, you need to use referencing. In scientific documents we typically use the IEEE standard, see Kildekompasset for details. Citation and Referencing with Microsoft Word (YouTube)

Remember to have focus on the technical work that has been done (as you have learned that technical/ professional documentation should be written), i.e., you should NOT tell how much you have learned, that the assignment was interesting and such things. Pretend that you write this documentation for a Customer that have asked you to make this program and document the Methods used and the Results achieved.