labview presentations

27
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. Danny Vu NOTE: The Professional Labview Development License Program is required to build an Application and an Installer. How to build an Application: 1.Create a new Project File (File >> New Project>> save a project as Main_Test_Program.lvpj) 2.In Project Explorer, right click My Computer >> select Add>>File and select the main.vi 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 3.Right click Build Specifications>>New>>Application(exe) and under category information put the application in the current folder tree. 4.Unser category Source Files, select main.vi file and add in the startup VIs. Add in necessary files in Always included if the main.vi needs to load some .txt file when it open. 1 2 3 5 06/06/22 1

Upload: tvu0244689

Post on 27-Nov-2014

154 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: LabVIEW Presentations

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.

Danny Vu

NOTE: The Professional Labview Development License Program is required to build an Application and an Installer.

How to build an Application:1.Create a new Project File (File >> New Project>> save a project as Main_Test_Program.lvpj)2.In Project Explorer, right click My Computer >> select Add>>File and select the main.vi 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 well3.Right click Build Specifications>>New>>Application(exe) and under category information put the application in the current folder tree.4.Unser category Source Files, select main.vi file and add in the startup VIs. Add in necessary files in Always included if the main.vi needs to load some .txt file when it open.5.Under category Destinations>> select support files and create a Build Application folder inside the main.vi so that all application fileswill store in this directory. Press [OK].

1

2

3

5

04/08/23 1

Page 2: LabVIEW Presentations

BUILDING AN APPLICATION and AN INSTALLER in LabVIEW

Danny Vu

66. Right click My Application and select Build and hit Done when complete.

7. Your directory should show as shown8. Next, we need to build an installer so

that the main_test_program project can transfer to client PC that has no Labviewprogram installed.

9. Right click Build Specifications>>New>>Installer10. Under Category product information, create My

Installer folder in same level with My Application folder

11. Add My Application to Main_test_program underSource 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 thatall hardware initialization build with your Installer. Hit OK

13. Right click My Installer and Build and Done

7

10

11

04/08/23 2

Page 3: LabVIEW Presentations

BUILDING AN APPLICATION and AN INSTALLER in LabVIEW

Danny Vu

14. Your final directory should be as shown so far15. 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 setup.exe to install your Main_Test_Program to the client PC.17.Test 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.

14

main.lvprojBuild Folder

Installer Folder

Company Name Folder

04/08/23 3

Page 4: LabVIEW Presentations

Example of Test Application

Danny Vu

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 application built successfully in project library. Consider to have different Buildscript folder for each version.

11

2

2

Delete the data folder in Destination path in project library and replace with Build folder to prevent problems

3

3

04/08/23 4

Page 5: LabVIEW Presentations

Calling Codes From Other Languages

Labview gives 3 options to call external, compiled code:

• Using the command line with System Exec.vi

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

Danny Vu

1 System Exec.vi

Command line string contains the path to the .exe file.

<<Example>>

04/08/23 5

Page 6: LabVIEW Presentations

Using Call Library Function Node-DLL

Danny Vu

• 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

04/08/23 6

Page 7: LabVIEW Presentations

Building .dll file in LabWindows-CVI

Danny Vu

Objective: Write a C code program in WindowCVI and build a *.dll file. Using LabVIEW to call this .dll

Implementation:

1.Open NI LabWindow CVI program and create a folder on desktop name test2.Create a New >> Project. Go to File>>Save Untitled project as Temperature.prj3.Select File >> New >> Source(*.C) to create an untitled1.C program and save the untitled1 as Temperature.c4.Enter the C code program as shown below

2

3

4

04/08/23 7

Page 8: LabVIEW Presentations

Using Call Library Function Node-DLL

Danny Vu

5. Now we need to add the Temperature.c file into the Tempearture.prj file so that we can compile the code to ensure the program works. Right click Temperature.prj 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.8. Build >> Create Debuggable Executable.

6

9. Put a break in your code to watch the I/O display and exit CVIWindows (Run>>toggle breakpoint)

8

9

Building a Temperature.DLL10. 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

10

12

7

04/08/23 8

Page 9: LabVIEW Presentations

Using Call Library Function Node-DLL

Replace with main program in TempDLL.c*

13. Replace int Your_Functions_Here(intx) in TempDLL.h* with void TempDLL () since this function do not return a value.14.Build/Create Debuggable Dynamic Link Library 15.You have build TempDLL successful if no error return.16.File >> Save AllNotes: ignore if you see warnings…. For this example

13

04/08/23 9Danny Vu

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

Page 10: LabVIEW Presentations

Calling TempDLL into LabVIEW

Objectives: Calling TempDLL into LabView using Library Function Node

Implementation:

1.Open labVIEW2.Function>>Connectivity>>Call Library Function Node3.Right Click >>Configure4.Set Function as shown below and hit OK

3

5. Run to test program

5

4

04/08/23 10Danny Vu

Page 11: LabVIEW Presentations

Calling lvanlys.dll into LabVIEW

Objectives: Calling lvanlys.dll into LabView using Library Function Node. The Lvanlys.dll 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);

Implementation:

1.Define the return type parameter2.Define the arguments or input parameters to the DLL function “Mean_head”3.Four outputs, the return type plus the 3 pointers data from each of the 3 inputs.

5. Run to test program04/08/23 11Danny Vu

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

1

2

Page 12: LabVIEW Presentations

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: #include <stdio.h> /*include information about standard ANSI library 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.

ANSI First C 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.

04/08/23 12Danny Vu

Page 13: LabVIEW Presentations

ANSI C –While Loop Structure

1

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.

2

2 While ( condition) { …… } 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.

Other basic data types in C: Char character-a single byte Short short integer long long integer double double-precision floating point

%d print as decimal integer%6d print as decimal integer, at least 6 characters wide.%f print as floating point.

%6f print as floating point, at least 6 characters wide

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

3

3

13Danny Vu04/08/23

Page 14: LabVIEW Presentations

ANSI C – The For Statement

04/08/23 14Danny Vu

Condition Increment Step

Specify the argument fahr will be printed as an integer with at least 3 chars. Wide.

initialization

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

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

Page 15: LabVIEW Presentations

HOW TO READ CONTENTS FROM A TEXT FILE Objectives: to read contents from text file, FastLoad-5.txt without popping up the control path.

Solution: If the FastLoad-5.txt file is located in E:\DAQ-Presentation\Files, build path and read from text file functions can be implemented as follow.

<< Read contents from text files.vi>>04/08/23 15Danny Vu

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 ifthe file is already exist.•Replace or create overwrite the current file name. •Replace or create with confirmation

1

2

Page 16: LabVIEW Presentations

SHORT CUT KEY

16Danny Vu

Objective: Connect all wires to the create virtual channels.vi using short cut.

Implementation:

1. Drop the create virtual channel.vi in the block diagram window.2. Select the create virtual channel.vi 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.

Page 17: LabVIEW Presentations

Type Def Control

Type Def.ctl is used to update all the VIs that are used this type def.

Strict Type Def.ctl update all the VIs and its physical appearances.

1 In a new blank VI, create a Enum Control and Add elements into the 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 menu.ctl. Say Yes on the pop up dialog to replace the original control.

3 Open a new blank VI, right mouse click on the front panel and select a control… Select the test menu.ctl type def. and place on the front panel. Save this VI as main program.vi

4 Now, open the test menu.ctl control and add in another 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.

04/08/23 17Danny Vu

Page 18: LabVIEW Presentations

Advanced Type Def Control

In Customize mode, you can use to resize, color, and replace the various picture components of the control.

1

2 Right-Clicking mouse and choose Advanced>>Customize Change to Customize Mode

3

4

Change to Edit Mode and select Type Def. on drop down menu. Then go to File>>Save as >> Valve.ctl

Create a blank VI, Place a Flat Square Button, name Valve control (available on the Classic>>Classic Boolean Palette)

3 Pop up Boolean Valve Control and select import from file…choose close.png picture to create True Case of the Boolean. 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 open.png picture to create False Case of the Boolean.

True False

Create a blank VI, right mouse click on front panel and select a control…and place Valve.ctl on the front panel.

5 Save the file as Mixer Process.vi

To Test: create a constant true / false to the input of the constant boolean control. You will see the image alternate the close/open valve states.04/08/23 18Danny Vu

Page 19: LabVIEW Presentations

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.

04/08/23 19Danny Vu

Page 20: LabVIEW Presentations

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 insidethe field.

1 2 3

04/08/23 20Danny Vu

Page 21: LabVIEW Presentations

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 . Right Click Event Case and rearrange cases.This event structure capture front panel events when Do Some Work Boolean Control button

is pressed, one time for every push button! This is much better than the polling technique.

We must place the stop button inside theEvent Structure to stop the while loop that contains an event structure.04/08/23 21Danny Vu

Page 22: LabVIEW Presentations

Using The Event Structures – Cont.

04/08/23 22Danny Vu

This nested WHILE loop is needed to execute event structure once.

This program is written to wait for an event occur. For example, if [Start] button was 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.

Page 23: LabVIEW Presentations

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.

04/08/23 23Danny Vu

Page 24: LabVIEW Presentations

Using Tab Control User Interface

• Find the Tab Control from control >>classic>>classic containers.

04/08/23 24Danny Vu

Page 25: LabVIEW Presentations

Using Tab Control User Interface-Multiplot

04/08/23 25Danny Vu

Use build array to create multiplot

Use bundle

Page 26: LabVIEW Presentations

Using QUEUE

04/08/23 26Danny Vu

Page 27: LabVIEW Presentations

Appended Path and Open Front Panel Window

04/08/23 27Danny Vu