Introduction To LabVIEW - Overview
Introduction To LabVIEW - Overview
blog
Introduction to LabVIEW
Basic LabVIEW Programming
Wi-Fi DAQ
Water Tank
USB-6008
Pt-100
TC-01
ZigBee Arduino
Vision System
cRIO
NOx Sensor
LabVIEW
This is the core LabVIEW installation that installs
the LabVIEW Programming Environment.
Block Diagram
Create your Code here
Switch between them: Ctrl + E
these Functions
contents in the different
subpalettes
LabVIEW Programming
Hans-Petter Halvorsen
Run the Program Front Panel
Simple Example
Controls
vs.
Find these Controls and Indicators in the Controls Indicators
Palette and place them on the Front Panel (Right-
click on the Front Panel in order to make the What is the difference?
Controls Palette visible)
Block Diagram
Controls Indicator
Block Diagram
Students: Create this Example using the different Data Types in LabVIEW
Ctrl + H I need Help!!
Where can I find it?
When you use Ctrl + H, you may click on all kind of objects (both on
In the Help
Front Panel and Block Diagram) on the screen to get help, e.g., how
menu you will
built-in functions are working, etc.
find Examples,
etc.
Ctrl + H
Students:
• Create this Example
• Try out different options on the Chart,
e.g. Autoscale, different Modes, Grid,
Layout, Colors, etc. (Right-click on the
Chart) While Loop
Note! To do something with an object – Right-click on it
Charts vs. Graphs
- Example
Students: Create this VI in order to see the
difference between a Chart and a Graph
SubVIs
Hans-Petter Halvorsen
Select Inputs and Outputs
SubVIs
Input Output
Icon that makes it easier
to understand what the
SubVI is doing
(Control) (Indicator)
Create a nice icon as well
(Icon Editor)
A SubVI is the same as a
function or a method used
in other languages
Students: Create
this SubVI
Icon Editor Use the Icon Editor in order to create
a descriptive icon for your SubVI.
Using SubVIs
Block Diagram
SubVI
Do you see how simple and intuitive the
code becomes when using SubVIs? SubVI
Writing Formulas
Hans-Petter Halvorsen
LabVIEW Formula Node
Formula Node: Create and use C code
within LabVIEW
Example:
Note!
Alternative Solution:
MathScript Node: You can create and use MathScript/MATLAB code within LabVIEW
LabVIEW MathScript Node
Celcius to Fahrenheit:
Hans-Petter Halvorsen
Loops & Structures
Sequence Structure
Case Structure
(if...else...)
Specify Number of Iterations
For Loop
Shift Register
Right-click on the
border and select “Add
Shift Register”
Right-click on
Current Iteration the border
...
Hans-Petter Halvorsen
Project Explorer Similar to “Solutions Explorer” in Visual Studio. It
Keeps all your Files for a spesific project in one place.
Students: Change the different options according to how you want to use LabVIEW
Spaghetti Code
Since LabVIEW is a graphical programming language with lots of wires, etc., it is
extremely important to have a good and clear structure in your program!
Spaghetti Code – Bad Example 1
Same code – why
not use SubVI?
Structure your code! Use SubVIs, Avoid Spaghetti Code, Document your Code, etc.
Spaghetti Code – Bad Example 2
Make sure your code fits into your screen size – scrolling to see code is not good!
Structure your code! Use SubVIs, Avoid Spaghetti Code, Document your Code, etc.
Spaghetti Code – Very Bad Example
Structure your code! Use SubVIs, Avoid Spaghetti Code, Document your Code, etc.
Bad vs. Good Code
The Flow should go from left to right
This is a comment
Use SubVIs!!!
Use Labels and Comment your Code
http://www.ni.com/pdf/manuals/376039a.pdf
Short-Cuts that you must know!
Ctrl + drag objects with your mouse: Copy objects (easier than Ctrl + C and Ctrl + V)
https://www.halvorsen.blog
Hans-Petter Halvorsen
Note! This is just an example to illustrate the assignment. You can create
your own User Interface with your own features.
The code should include a While Loop, Case structures, SubVIs, etc. You can
use the built-in Random Generator when playing Lottery.
Level formula:
Previous Level
Implement the Equations using standard LabVIEW operators like:
E-mail: [email protected]
Web: https://www.halvorsen.blog