LabVIEW Presentations

of 27 /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

Embed Size (px)

Transcript of 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.

1

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. 5.Under category Destinations>> select support files and create a Build Application folder inside the main.vi so that all application files will store in this directory. Press [OK].6/2/2011 Danny Vu

2

3

5

1

BUILDING AN APPLICATION and AN INSTALLER in LabVIEW6. 7. 8. Right click My Application and select Build and hit Done when complete. 7 Your directory should show as shown 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. Right click Build Specifications>>New>>Installer Under Category product information, create My Installer folder in same level with My Application folder Add My Application to Main_test_program under Source Files Category 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 Right click My Installer and Build and Done

6

9. 10. 11. 12.

10

13.

11

6/2/2011

Danny Vu

2

BUILDING AN APPLICATION and AN INSTALLER in LabVIEW 1414. 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 setup.exe to install your Main_Test_Program to the client PC. 17. Test Your Main_test_Program. Notes: its 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

main.lvproj Build Folder Installer Folder

6/2/2011

Danny Vu

3

1

Example of Test Application 1Note: 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.

2

Buildscript folder have the following files after application built successfully in project library. Consider to have different Buildscript folder for each version.

3 2

3

Delete the data folder in Destination path in project library and replace with Build folder to prevent problemsDanny Vu 4

6/2/2011

Calling Codes From Other LanguagesLabview 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.

1

System Exec.vi

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

6/2/2011

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 double6/2/2011 6

Danny Vu

Building .dll file in LabWindows-CVIObjective: Write a C code program in WindowCVI and build a *.dll file. Using LabVIEW to call this .dll Implementation: 1. 2. 3. 4. Open NI LabWindow CVI program and create a folder on desktop name test Create a New >> Project. Go to File>>Save Untitled project as Temperature.prj Select File >> New >> Source(*.C) to create an untitled1.C program and save the untitled1 as Temperature.c 3 Enter the C code program as shown below2

4

6/2/2011

Danny Vu

7

Using Call Library Function Node-DLL5. 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 Add File Project window display, select Temperature.c and press ADD button and then hit OK. 6 Build >> Compile File to compile your code. Build >> Create Debuggable Executable. 78

6. 7. 8.

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

Building a Temperature.DLL

10. File >> New >> Project From Templateselect 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

6/2/2011

Danny Vu

8

Using Call Library Function Node-DLLReplace 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. 14. Build/Create Debuggable Dynamic Link Library 15. You have build TempDLL successful if no error return. 16. File >> Save All Notes: ignore if you see warnings. For this example

Creating multiple .c files in CVI project: Remove the .c file that youre currently working on Create a new one(File>New> select source(*.c) )6/2/2011 Danny Vu 9

Calling TempDLL into LabVIEWObjectives: Calling TempDLL into LabView using Library Function Node Implementation: 1. 2. 3. 4. Open labVIEW Function>>Connectivity>>Call Library Function Node Right Click >>Configure Set Function as shown below and hit OK4 3

5

6/2/2011 Run to test program 5.

Danny Vu

10

Calling lvanlys.dll into LabVIEWObjectives: 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 2

1. Define the return type parameter 2. 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.

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.

6/2/2011 Run to test program 5.

Danny Vu

11

ANSI C ARCHITECTUREA 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 #include /*include information about standard ANSI library main( ) { printf(Hello World \n); } /* The statements of a function are enclosed in braces { }. /* define a function name main that receives no argument values First C Program

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. 6/2/2011 Danny Vu 12

ANSI C While Loop Structure 3

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

1 3 2

%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

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

2

6/2/2011

Danny Vu

13

ANSI C The For Statement

Condition initialization

Increment Step

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

1LOWER, 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.

1

6/2/2011

Danny Vu

14

HOW TO READ CONTENTS FROM A TEXT FILEObjectives: 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.

1

2

If Build Path function is not in used. The Open File Window Pop up and prompt the user to choose the file.

>

Danny Vu

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 15

SHORT CUT KEYObjective: Connect all wires to the create virtual channels.vi using short cut. Implementation: 1. 2. 3. 4. 5. Drop the create virtual channel.vi in the block diagram window. Select the create virtual channel.vi Press [CTRL+Space] to bring up Quick Drop window. Press [CTRL + D] to connect all wires to the input and output terminals. Press [CTRL+U] or go to Edit>Clean Up Diagram to align objects.

Danny Vu

16

Type Def ControlType 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

3

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. 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 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 programs cluster as well. conclusion: Type Def is useful to eliminate the errors when you need to update the enum properties constant.

4

6/2/2011

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.

1 2 3

Create a blank VI, Place a Flat Square Button, name Valve control (available on the Classic>>Classic Boolean Palette) Right-Clicking mouse and choose Advanced>>Customize Change to Customize Mode Pop up Boolean Valve Control and select import from filechoose 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 filechoose open.png picture to create False Case of the Boolean. Change to Edit Mode and select Type Def. on drop down menu. Then go to File>>Save as >> Valve.ctl Create a blank VI, right mouse click on front panel and select a controland place Valve.ctl on the front panel. Save the file as Mixer Process.viTrue False

3 4 5

To Test: create a constant true / false to the input of the constant boolean control. You will see the image alternate the close/open 6/2/2011 Danny Vu valve states.

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.

6/2/2011

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

6/2/2011

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 . 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 the Event Structure to stop the while loop 6/2/2011 that contains an event structure.

Danny Vu

21

Using The Event Structures Cont.

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.

6/2/2011

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.

6/2/2011

Danny Vu

23

Using Tab Control User Interface Find the Tab Control from control >>classic>>classic containers.

6/2/2011

Danny Vu

24

Using Tab Control User Interface-Multiplot

Use build array to create multiplot Use bundle

6/2/2011

Danny Vu

25

Using QUEUE

6/2/2011

Danny Vu

26

Appended Path and Open Front Panel Window

6/2/2011

Danny Vu

27