Sie sind auf Seite 1von 12

Nanoengineering group LabVIEW Lecture -2(Little bit more advanced LabVIEW): In class examples with solutions The purpose

of this lecture is to get familiar with i) some of the frequently used functions (2D arrays, while loop, formula node, shift register, strings and save functions) and ii) some of the advanced programing logics in LabVIEW which can be helpful for guided user interface GUI (Tab Control, self-running start and stops button for executable VIs, autosave to a directory, property nodes and creating sub VI).

In example 1, a tab control together with a case structure is used as the selector for the user between different examples. Be aware of the fact that the same logic can be used with String Control, Ring and Enum structures. 2nd and 3rd examples are given to get more familiar (additional to the 1st weeks examples) with array structures. 4th example is to introduce the feedback structure and its comparison with the shift register structure. A widely used algorithm to generate equally spaced numbers between a start an d stop point are demonstrated in example 5. Note that these numbers created one-by-one which can be, for example, wavelength scan of a monochromator. For each specific wavelength you can make a measurement of light intensity. Example 6 shows how to create a s elfrunning start button which can be quite helpful if you would like to create an exe file. 7th example displays a way to eliminate unnecessary calculations. This code will run only if user changes a specific number in the control panel. User prompt and saving options are demonstrated in example 8. Example 9 shows how to manage strings and create an autosave function. Example 10 is most suitable for people who get used to write lines instead of adding icons while they can still control lab equipment via LabVIEW. 11th example is a GUI application. Run it in continuous mode and change the temperature. Its pretty cool, huh? Finally, 12th example shows how to create a sub VI.

1. Create a selector using tab control and case structure 2. Build and array from 4 user-defined numbers using build array. a. Set user-defined numbers as default. (Write click on the control (Data operations >> make current value default)) b. Align controls in same y-axis with equal spacing c. Group controls

3. (Add new tab and case in tab control and Case structure, respectively). Create a 2D array of 4x4 random numbers. Then, output the number in the 3rd row and 3rd column.

4. (Add new tab and case in tab control and Case structure, respectively). Write a program which multiplies subsequent numbers starting from 1 with the result of the previous multiplication for 10 times (i.e. 1x1=1, 1x2=2, 2x3=6, 6x4=24, 24x5=120, 120x6=5040, etc). a. using feed back b. using shift register

5. (Add new tab and case in tab control and case structure, respectively). Write a program (using while loop) which outputs userdefined numbers between start and stop with a size of step. (start, stop and step are the labels of the controls).

6. (Add new tab and case in tab control and case structure, respectively). (Copy and paste the program in page 4). Create a start button using while loop and stack sequence structure. Insert a while loop around the stack sequence structure. Add a stop button as the while condition and hide the stop button in the front panel.

7. (Add new tab and case in Tab control and case structure, respectively). (Copy and paste the program in page 4). Modify the program so that it runs a null case if user does not change the step size in the front panel and it runs the while loop if user changes the step size in the front panel. (Hint: Use shift register and case structure with true and false cases).

8. (Add new tab and case in tab control and case structure, respectively). (Copy and paste the program in page 4). Ask user if he/she wants to save the array (using two button dialog) and save the array into a *.txt file.

9. (Add new tab and case in Tab control and case structure, respectively). (Copy and paste the program in page 7). (Remove the prompt user and case structures). Insert Get Date/Time String and write click to date format input and create constant to get familiar with preset options in LabVIEW. Insert Get Date/Time in Seconds and connect it to Format Date/Time String. Crop the minutes and seconds using String subset. Create a constant path (for the folder that you want to save the data). Merge the path, /, minute, second and .txt using concatenate string. Finally, convert it to a path and feed this path into Write Spreadsheet file.

10. (Add new tab and case in tab control and case structure, respectively). Write a program (using formula node) which displays the spectral irradiance of a blackbody curve for a given temperature (in oC) with a step size of 0.1 m. Fix the y-axis between 0.01 and 4000. Use logarithmic scale in x-axis.

, where, c1 is 374050000 and c2 is 14387.9.

11. (Add new tab and case in tab control and case structure, respectively). (Copy and paste the program in page 9). a. Write a program to implement .

b. Find the maximum of the irradiance and find the wavelength corresponding to this data point using array tools. c. Create a cursor in the x-y graph. Hint: right click on graph >> properties >> Cursors >> Add. d. Create a property node for Cursor position in x-axis (right click on graph icon >> Property node >> Cursor >> Cursor Position >> Cursor X) e. Enter the wavelength for maximum irradiance to the property node.

12. (Add new tab and case in tab control and case structure, respectively). (Copy and paste the program in page 4). Select the while loop and array using your mouse. Click on Edit >> Create SubVI. Double click on the sub VI. Right click on the Icon and Connector window >> VI Properties (investigate different options in the pop-down menu). Click on Edit Icon. Click on Show connector. Close the sub VI and save it.

Das könnte Ihnen auch gefallen