Basic LabVIEW Programming
Basic LabVIEW Programming
Faculty of Technology, Postboks 203, Kjlnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01
Preface
In this document you will learn basic LabVIEW programming by creating some
simple LabVIEW applications.
http://home.hit.no/~finnh/videos/topics/labview/labview/labview.html
3/19
Simple Calculator.vi
Front Panel:
Add 2 Numeric
Controls and name them
Number1 and Number2
Add a Numeric Indicator
and name it Answer
Block Diagram:
http://home.hit.no/~hansha
4/19
Extend your calculator (make sure to rename your file) so it can handle the 4
basic calculations (Add, Subtract, Multiply, Divide).
Front Panel:
Calculator.vi
http://home.hit.no/~hansha
5/19
Block Diagram:
The Block Diagram should look like this when you are finished:
http://home.hit.no/~hansha
6/19
[End of Task]
http://home.hit.no/~hansha
7/19
While Loop.vi
The program will update the date and time each second using a While loop
until you stop the program using the Stop button.
Front Panel:
Block Diagram:
The Block Diagram should look like this when you are finished:
http://home.hit.no/~hansha
8/19
While Loop:
Use the Get Date/Time String function in order to get the current Date and
Time from the computer:
Wait (ms):
The Date and Time strings should be updated every second. You can use the
Wait (ms) for that:
[End of Task]
http://home.hit.no/~hansha
9/19
Advanced Calculator.vi
Front Panel:
The calculations will be performed when you click the Calculate button.
Block Diagram:
While Loop:
Event Structure:
http://home.hit.no/~hansha
10/19
The Block Diagram should look like this when you are finished:
[End of Task]
http://home.hit.no/~hansha
11/19
Task 4: Arrays
Create the following program:
Arrays.vi
Front Panel:
Creating an Array:
Start by dragging an empty array into your Front Panel and drag a
Numeric Control inside it:
Block Diagram:
Index Array:
Next we will use the Index Array function in order to find a spesific
element in the array:
http://home.hit.no/~hansha
12/19
The Block Diagram should look like this when you are finished:
[End of Task]
http://home.hit.no/~hansha
13/19
Task 5: SubVIs
Create a SubVI from the Calculator created in a previous task.
Calculator.vi
Icon Editor:
Right-click in the upper right window and select Edit Icon in order to open
the Icon Editor.
http://home.hit.no/~hansha
14/19
Block Diagram:
http://home.hit.no/~hansha
15/19
The Block Diagram should look like this when you are finished:
Front Panel:
http://home.hit.no/~hansha
16/19
[End of Task]
http://home.hit.no/~hansha
17/19
Task 6: Plotting
Create the following program:
Plotting.vi
Front Panel:
http://home.hit.no/~hansha
18/19
Block Diagram:
Use the Random Number (0-1) function in order to create some random
data in your plot:
Waveform Chart:
Wait (ms):
The Block Diagram should look like this when you are finished:
[End of Task]
http://home.hit.no/~hansha
Telemark University College
Faculty of Technology
Kjlnes Ring 56
www.hit.no
E-mail: [email protected]
Blog: http://home.hit.no/~hansha/
Room: B-237a