BUILDING AN APPLICATION and AN INSTALLER in LabVIEW
• The advantages of building an Application and an Installer in LabVIEW is that the
application file can be moved to the client’s computer, wherever the client PC does not
need to have LabVIEW program license.
• an Application builds a test execution file where it encapsulates all SubVIs into one.
• The Installer build the application file, including its drivers, and supporting files into a
labVIEW runtime engine so that it can be installed in a client PC without a need of a
Labview Development Program.
1
NOTE: The Professional Labview Development License Program is
required to build an Application and an Installer. 2
How to build an Application:
[Link] a new Project File (File >> New Project>> save a project as
Main_Test_Program.lvpj)
[Link] Project Explorer, right click My Computer >> select Add>>File and 3
select the [Link] that you want to build an application.
Notes: If the main vi have supporting files, such as .txt load file, add them
within this step as well
[Link] click Build Specifications>>New>>Application(exe) and under
category information put the application in the current folder tree.
[Link] category Source Files, select [Link] file and add in the startup
VIs. Add in necessary files in Always included if the [Link] needs to 5
load some .txt file when it open.
[Link] category Destinations>> select support files and create a Build
Application folder inside the [Link] so that all application files
will store in this directory. Press [OK].
12/09/21 Danny Vu 1
BUILDING AN APPLICATION and AN INSTALLER in LabVIEW
6. Right click My Application and select Build and hit 6
Done when complete.
7. Your directory should show as shown 7
8. Next, we need to build an installer so
that the main_test_program project can
transfer to client PC that has no Labview
program installed.
9. Right click Build Specifications>>New>>Installer
10. Under Category product information, create My
Installer folder in same level with My Application
folder
11. Add My Application to Main_test_program under 10
Source Files Category
12. This is an important step, select Additional Installers,
check on NI LabVIEW run time engine version of
your development program, and check all
where applies VISA, NI Switch, etc so that
all hardware initialization build with your
Installer. Hit OK
13. Right click My Installer and Build and Done
11
12/09/21 Danny Vu 2
BUILDING AN APPLICATION and AN INSTALLER in LabVIEW
14
14. Your final directory should be as shown so far
15. Move the whole high level directory that contains
all files in step 14 and transfer to the client PC that do not
have LabVIEW Development Program Installed.
16. Open the Installer folder and double click on [Link] to install
your Main_Test_Program to the client PC.
[Link] Your Main_test_Program.
Notes: it’s recommended not to save the Main_Test_Program.lvproj outside of
the build application and my installer directory because the client pc can not use
the *.lvproj file without LabVIEW development license program.
Company Name Folder
[Link]
Build Folder
Installer Folder
12/09/21 Danny Vu 3
1 Example of Test Application
1
Note: If SAI User Interface V1.0 needs to be
upgraded. Consider to do as follows:
1. copy the same file and change the original file
name as SAI User Interface V1.0_XX
2. Open the copied version and go to file>>save
so that the new version also link to subvis of the
original file.
Buildscript folder have the following files after
2 application built successfully in project library.
Consider to have different Buildscript folder for
each version.
3
2
Delete the data folder in Destination
3 path in project library and replace with
Build folder to prevent problems
12/09/21 Danny Vu 4
Calling Codes From Other Languages
Labview gives 3 options to call external, compiled code:
• Using the command line with System [Link]
• Calling dynamic linked libraries, or DLLs (apply only to Windows; for Mac OS and Linux,
you can call Frameworks.
• Interface to compiled code using a code interface Node.
1 System [Link]
Command line string contains the path to the .exe file.
<<Example>>
12/09/21 Danny Vu 5
Using Call Library Function Node-DLL
• DLLs are small, compiled libraries in a .dll file that encapsulate some functionality and
export a set of functions that other applications like LabVIEW can call.
• What you need is a set of document describe what the functions are and how the data
should be passed to and from them.
• The table below are usually helpful to understand the data types return of a function from
one platform to the other.
Standard ANSI C keywords:
Void: means that function does not return a value
Integer 16: can be signed (by default) or unsigned -32768 to
+32768 or 0 to 65535, respectively. 2^16=65536-1 (short int)
Int8 : signed char = -128 to 127 (signed char); unsigned char = 0
to 255 (unsigned char)
Long is same as double
12/09/21 Danny Vu 6
Building .dll file in LabWindows-CVI
Objective: Write a C code program in WindowCVI and build a *.dll file. Using LabVIEW to
call this .dll
Implementation:
2
[Link] NI LabWindow CVI program and create a folder on desktop name test
[Link] a New >> Project. Go to File>>Save Untitled project as [Link]
[Link] File >> New >> Source(*.C) to create an untitled1.C program and save the untitled1 as
Temperature.c 3
[Link] the C code program as shown below
12/09/21 Danny Vu 7
Using Call Library Function Node-DLL
5. Now we need to add the Temperature.c file into the [Link] file so that we can
compile the code to ensure the program works. Right click [Link] and select Add
Exsiting File…
6. Add File Project window display, select Temperature.c
and press ADD button and then hit OK.
7. Build >> Compile File to compile your code. 6
8. Build >> Create Debuggable Executable.
7
8
9. Put a break in your code to watch the I/O display and exit CVIWindows (Run>>toggle breakpoint)
9
10
Building a [Link]
10. File >> New >> Project From Template…select Dynamic Link and
enter TempDLL in project name box. Press OK.
11. This will create 4 files TempDLL in your root directory.
12. Open TempDLL.c and replace the code
12
12/09/21 Danny Vu 8
Using Call Library Function Node-DLL
Replace with main program
in TempDLL.c*
13
13. Replace int Your_Functions_Here(intx) in TempDLL.h*
with void TempDLL () since this function do not return a value.
[Link]/Create Debuggable Dynamic Link Library
[Link] have build TempDLL successful if no error return.
[Link] >> Save All
Notes: ignore if you see warnings…. For this example
Creating multiple .c files in CVI project:
Remove the .c file that you’re currently working on
Create a new one(File>New> select source(*.c) )
12/09/21 Danny Vu 9
Calling TempDLL into LabVIEW
Objectives: Calling TempDLL into LabView using Library Function Node 3
Implementation:
[Link] labVIEW
[Link]>>Connectivity>>Call Library Function Node
[Link] Click >>Configure
[Link] Function as shown below and hit OK
5. Run to test program
12/09/21 Danny Vu 10
Calling [Link] into LabVIEW
Objectives: Calling [Link] into LabView using Library Function Node. The
[Link] takes an array of numerics referenced by point xH and calculates the mean,
placing its value in the memory location referenced by the pointer mean. If there is an
error, its numeric code is referenced by the pointer dsperr.
long Mean_head(void *xH, void *mean, void *dsperr);
1
Implementation:
2
[Link] the return type parameter
[Link] the arguments or input parameters to the DLL function “Mean_head”
[Link] outputs, the return type plus the 3 pointers data from each of the 3 inputs.
Note: you have to provide dummy inputs to the arguments, even if they represent outputs, so
that LabVIEW knows what kind of data type you are using (due to the fact that these
parameter types were configured as “Adapt to Type”.
5. Run to test program
12/09/21 Danny Vu 11
ANSI C ARCHITECTURE
A C program, whatever it size, consists of functions and variables.
A Function contains statements that specify the computing operations.
Variables store values used during the computation.
Ex: ANSI
First C
#include <stdio.h> /*include information about standard ANSI library Program
main( ) /* define a function name main that receives no argument values
{
printf(“Hello World \n”); /* The statements of a function are enclosed in braces { }.
}
C Compilation system architecture:
Preprocessor: this component reads lines in your source codes. #include is use to read whole source file,
#define is used to read external source file.
Compiler: translate C language code into your source files, which now contains the contents of
any included header files into assembly codes.
• Assembler: translate the assembly language code into the machine instructions of the computer your
program is to run on.
• Link Editor: link these object files each other and with any library function calls in your program.
Notes: stdio.h is a standard library of functions that are normally accessible to C programs, so its properties
should be the same with any compiler and library that conforms to the standard.
12/09/21 Danny Vu 12
Other basic data types in C:
Char character-a single byte
Short short integer
ANSI C –While Loop Structure long long integer
double double-precision floating
3 point
%d print as decimal integer
%6d print as decimal integer, at
least 6 characters wide.
%f print as floating point.
1
%6f print as floating point, at
3 least 6 characters wide
2 %.2f print as floating point, 2
characters after decimal pt.
%6.1f print as floating point,
at least 6 wide and 1 after
decimal point.
%O for octal
%x for hexadicimal
%c for character
%% for % itself
1 In C, all variables must be declared before they are used. It consists of a type name and a list of variables.
int is a type integer by contrast with float. The range of int and float depends on the machine you are
using; 16 bit ints = 2^16 = 64K, which lie between -32768 and +32768
fahr and celsius are variables.
While ( condition)
{
2 ……
}
condition inside the loop is tested, if true, the body is executed. The condition retested again, if true it executed again. When the test
become false, it executes once and exit the loop.
printf is a general-purpose output formatting function. %d specifies an integer argument, \t is a tab, and \n is a new line.
12/09/21 Danny Vu 13
ANSI C – The For Statement
Condition Increment Step
initialization
Specify the argument fahr will be printed as
an integer with at least 3 chars. Wide.
Declaration
ANSI C – Symbolic Constant #define
#define line defines a symbolic name or symbolic constant to be used in a systematic way when you
need to change a constant throughout in your program.
#define name replacement text
1 1
LOWER, UPPER, and STEP are symbolic constants,
Not variables, so they do not appear in declarations.
Symbolic constant names written in upper case so
they can be readily distinguished from lower case
variable names.
12/09/21 Danny Vu 14
HOW TO READ CONTENTS FROM A TEXT FILE 1
Objectives: to read contents from text file, [Link] without popping up the
control path.
Solution: If the [Link] file is located in E:\DAQ-Presentation\Files, build path
and read from text file functions can be implemented as follow.
2
If Build Path function is not in used. The
Open File Window Pop up and prompt
the user to choose the file.
•Create a new file. Error 10 occur if
the file is already exist.
•Replace or create overwrite the
current file name.
•Replace or create with confirmation
<< Read contents from text [Link]>> Danny Vu
12/09/21 15
SHORT CUT KEY
Objective: Connect all wires to the create virtual [Link] using short cut.
Implementation:
1. Drop the create virtual [Link] in the block diagram window.
2. Select the create virtual [Link]
3. Press [CTRL+Space] to bring up Quick Drop window.
4. Press [CTRL + D] to connect all wires to the input and output terminals.
5. Press [CTRL+U] or go to Edit>Clean Up Diagram to align objects.
Danny Vu 16
Type Def Control
Type [Link] is used to update all the VIs that are used this type def.
Strict Type [Link] update all the VIs and its physical appearances.
In a new blank VI, create a Enum Control and Add elements into the
1
Enum
Right-clicking on the cluster frame, add select
Advanced>>Customize…
2 Select Type Def status in a drop-down menu. Save the
control as test [Link]. Say Yes on the pop up dialog to
replace the original control.
Open a new blank VI, right mouse click on the front panel
3 and select a control…
Select the test [Link] type def. and place on the front
panel. Save this VI as main [Link]
Now, open the test [Link] control and add in another
4
boolean indicator into the cluster and save it. You would
see it would automatically update the main program’s
cluster as well.
conclusion: Type Def is useful to eliminate the errors
when you need to update the enum properties constant.
12/09/21 Danny Vu 17
Advanced Type Def Control
In Customize mode, you can use to resize, color, and replace the
various picture components of the control.
Create a blank VI, Place a Flat Square Button, name Valve
1 control (available on the Classic>>Classic Boolean Palette)
Right-Clicking mouse and choose Advanced>>Customize
2 Change to Customize Mode
3 Pop up Boolean Valve Control and select import from file…choose
[Link] picture to create True Case of the Boolean. True False
Right mouse click Boolean Valve Control, select Picture Item,
and choose another Boolean Valve Control to create False of
Boolean.
Right mouse click and select import from file…choose [Link]
picture to create False Case of the Boolean.
Change to Edit Mode and select Type Def. on drop down
3
menu. Then go to File>>Save as >> [Link]
Create a blank VI, right mouse click on front panel and select a
4
control…and place [Link] on the front panel.
5 Save the file as Mixer [Link]
To Test: create a constant true / false to the input of the constant
boolean control. You will see the image alternate the close/open
12/09/21 valve states. Danny Vu 18
Controlling Parallel Loops
Create a local variable stop button so that the variable is always
contains the up-to-date value of its associated front panel project.
12/09/21 Danny Vu 19
Using Property Node
Property Node allows you to programmatically control the properties
of a front panel object: things such as color, visibility, position,
numeric display format, and so on.
Create a reference allows you to
This example changes the value of the numeric control. Key Focus use to set the active cursor inside
the field.
1 2 3
12/09/21 Danny Vu 20
Using The Event Structures
The event structures allows you to write highly efficient code
that
waits for events to happen, rather than inefficient code that
periodically checks whether events have happened.
Placing a single event structure inside a while loop is the most
common way to use the Event Structure.
Right-mouse clicking on event and select Add Event Case to
configure an event .
This
event structure capture front panel events when Do Some Work Boolean Control button
Right Click Event Case and rearrange cases.
is pressed, one time for every push button! This is much better than the polling technique.
We must place the stop button inside the
Event Structure to stop the while loop
that contains an event structure.
12/09/21 Danny Vu 21
Using The Event Structures – Cont.
This nested WHILE
loop is needed to
execute event
This program is written to wait for an event occur. For example, if [Start] button was
structure once.
pressed, the message ‘Ready For Test’ display on Test Status String Indicator, if
[RS232 Transmit] button was pressed, it would send the command from RS232 Write
to RS232-Read.
12/09/21 Danny Vu 22
Using Sending and Waiting on Notification
Just like queue, a notifier has an element data type that you can
define, but it can have only one element.
Unlike queue which has an array of elements.
Notifiers are very useful in situations where you only need to have
the latest message, and not all the messages.
12/09/21 Danny Vu 23
Using Tab Control User Interface
• Find the Tab Control from control >>classic>>classic containers.
12/09/21 Danny Vu 24
Using Tab Control User Interface-Multiplot
Use build array to create multiplot
Use bundle
12/09/21 Danny Vu 25
Using QUEUE
12/09/21 Danny Vu 26
Appended Path and Open Front Panel Window
12/09/21 Danny Vu 27