Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 3 Labview exercises

Similar presentations


Presentation on theme: "Week 3 Labview exercises"— Presentation transcript:

1 Week 3 Labview exercises

2 ECE 206 Lab 5 Build the following circuit using your DAQ. Since the DAQ probe cannot read voltages greater than 10 V, use a potentiometer to get a 10V power source. Build a Labview program that sweeps the input in .1 V increments from 0V to 3 V. You might find the “Merge” VI helpful. Store your voltages in excel, and plot Vout vs Vin in excel. Your plot should look like the one below. Upload your Labview code and excel file onto the google drive.

3 Simulation Design a labview program that will simulate the inverter transistor. Store your voltages in excel, and plot Vout vs Vin in excel. Upload your Labview code and excel file onto the google drive. Your plot should look like the one below. In the program I wrote, some of the VI’s I Used were: “Select”, “In Range and Coerce”, and “Formula”.

4 ECE 206 Lab 4 Build the following circuits using your DAQ. Use a signal generator to generate the sine wave inputs and the MyDAQ to read both the input and outputs. Store your voltages in excel, and plot Vout and Vin on the same axes in excel. (Also have plots in your front panel). Upload your Labview code and excel file onto the google drive.

5 Dynamic Data Watch video to help with graphing

6 Simulation Simulate the following circuits in one labview VI (use tabs and case structures for the different circuits. Make plots Vo on the front panel and Vo and Vi in excel.

7 Back to Labview Enums give users a list of items from which to select.
Enums (can be used with case structures instead of tab control) Enums give users a list of items from which to select. Each item represents a pair of values. String 16-bit Integer 7

8 Watch the video Do the diode of the previous slide but instead of using tabs use enums

9 Documenting Block Diagram Code
Owned labels: Explain data contents of wires and objects. Move with object. Have transparent backgrounds. Select Visible Items»Label from the shortcut menu to create. Free labels: Describe algorithms. Have pale yellow backgrounds. Double-click in any open space to create.

10 Arrays An array: Is a collection of data elements that are of same type. Has one or more dimensions. Contains up to (231)–1 elements per dimension, memory permitting. Accesses elements by its index. Note: The first element is index 0. Arrays are lists of elements of the same data type. They are analogous to arrays in traditional languages. Arrays can have one or more dimensions. Arrays can have up to 2^31 elements per dimension. Actual array sizes that students can create is limited by memory. Elements are accessed by an index. The index ranges from 0 to N-1 (N = number of elements in the array). Arrays are zero-indexed (first element is zero) in each dimension. A 2D array is analogous to a spreadsheet or table. Example: If your data contains temperature readings and time stamps, one column is time values and the other column is readings. Be careful to specify the element you really want. Example: The first element in an array is array (0), not array(1).

11 Arrays – 1D and 2D Examples
ID array One row of 10-elements 1.2 3.2 8.2 8.0 4.8 5.1 6.0 1.0 2.5 1.7 Index numbers 2D array Five-row by seven-column table of 35 elements 1 2 3 4

12 Viewing Arrays on the Front Panel
The elements at index 0 are not shown because element 1 is selected in the index display. First element at index 1 Second element at index 2 The element selected in the index display always refers to the element shown in the upper-left corner of the element display. 12

13 Creating an Array Control
For a new array: Select an Array control from the Controls palette on the front panel. Place a data object, such as a numeric control, into the array shell. Add a second dimension, if necessary, by resizing the index. From a block diagram terminal or wire: Right-click the object and select Create»Control or Create»Indicator. Creating array controls in LabVIEW: You can place any data type in an array shell except an array. You cannot have an array of arrays; use a 2D array instead. Emphasize that this is a two-step process. Students often place only empty array shells on the front panel. Remind them they must place a data type inside the array shell. Demonstrate the following on your computer: Create a numeric array. Point out index and data object components. Show how to create a 2D array. Show how to display multiple array elements. Show that index elements always reference the upper-leftmost object in the array display. Show how elements in an array are initially grayed out, indicating that a portion of the array has not been defined.

14 2D Arrays 2D arrays: Store elements in a grid. Require a column index and a row index to locate an element, both of which are zero-based. Create a multidimensional array on the front panel by right-clicking the index display and selecting Add Dimension from the shortcut menu. Resize the index display until you have as many dimensions as you want.

15 Auto-Indexing Auto-Indexing Enabled Wire becomes thicker Allows For Loops and While Loops to accumulate arrays at their boundaries. Is the default behavior for For Loops. Is disabled by default for While Loops. Is enabled/disabled by right-clicking on a tunnel. Produces arrays that are always equal in size to the number of iterations of the loop. 1D Array Auto-Indexing Disabled Wire remains the same size For Loops and While Loops can index and accumulate arrays at their boundaries. This is known as auto-indexing. The indexing point on the boundary is called a tunnel. The For Loop default is auto-indexing enabled. The While Loop default is auto-indexing disabled. Only one value (the last iteration) is passed out of the While Loop by default. Examples: Enable auto-indexing to collect values within the loop and build the array. All values are placed in the array upon exiting the loop. Disable auto-indexing if you are interested only in the final value. Only one value (last iteration) is passed out of the loop

16 Waveform Graph Is a graphical display of data.
Displays one or more plots of evenly sampled measurements. Is used to plot pre-generated arrays of data. Can display plots with any number of data points.

17 Charts vs. Graphs – Single-Plot

18 Auto-Indexing with a Conditional Tunnel
Right-click on a tunnel and select Tunnel Mode»Conditional. You can determine what values LabVIEW writes to the loop output tunnel based on a condition you specify by right-clicking the loop output tunnel and selecting Tunnel Mode»Conditional from the shortcut menu. Because of the conditional tunnel, the Values less than 5 array contains only the elements 2, 0, 3, and 1 after this loop completes all iterations.

19 Creating 2D Arrays Inner loop creates column elements.
You can use two nested For Loops to create a 2D array. Auto-indexing must be enabled for both loops. Explain the different line thicknesses in the wire connecting the Random Number function to the 2D Array Indicator. Demonstrate on your computer: How to change indexing and line thickness. When you see Enable indexing in the shortcut menu it means that indexing is currently disabled. The menu choice is the opposite of the current indexing mode. Students get confused about this feature. Inner loop creates column elements. Outer loop stacks column elements into rows.

20 Arrays Simulate circuit 1 and store Vout in an array. Graph Vout using Waveform graph (not waveform chart) and using x-y graph

21 Understanding Modularity – SubVIs
SubVI — A VI within another VI SubVIs correspond to subroutines in text-based programming languages. The upper-right corner of the front panel and block diagram displays the icon for the VI. This icon identifies the VI when you place the VI on a block diagram.

22 Understanding Modularity – SubVIs
Repeated code can become subVIs.

23 Understanding Modularity – SubVIs

24 Understanding Modularity – SubVIs
Function Code Calling Program Code function average (in1, in2, out) { out = (in1 + in2)/2.0; } main average (point1, point2, pointavg) SubVI Block Diagram Calling VI Block Diagram Every VI displays an icon in the upper-right corner of the front panel and block diagram windows. The icon is a graphical representation of a VI and identifies the subVI on the block diagram of the calling VI. The icon and connector pane correspond to the function prototype in text-based programming languages.

25 B. Icon Characteristics of a Good Icon Using the Icon Editor

26 Icon An icon is a graphical representation of a VI.
If you use a VI as a subVI, the icon identifies the subVI on the block diagram of the VI.

27 Characteristics of a Good Icon
Good icons convey the functionality of the VI using: Relevant graphics Descriptive text, if necessary

28 Creating Icons - Icon Editor
Open the Icon Editor using one of these methods: Right-click the icon in the upper-right corner of the front panel or block diagram and select Edit Icon. Double-click the icon. After you build a VI, customize the icon so you can identify the VI when you use it as a subVI on a block diagram. Create icons using the Icon Editor dialog box. Alternatively, you can drag a graphic file, such as a .bmp or .jpg, from your file system to the icon in the upper-right corner of the VI.

29 Icon Editor Use the editing tools to modify an icon manually.

30 Icon Editor Use the Glyphs tab to display glyphs you can include in the icon.

31 Icon Editor Use the Icon Text tab to specify the text to display in the icon.

32 Icon Editor Use the Templates tab to display icon templates you can use as a background for the icon.

33 C. Connector Pane Patterns Standards

34 Connector Pane The connector pane is displayed next to the icon in the upper right corner of the front panel. Each rectangle on the connector pane represents a terminal. Use the terminals to assign inputs and outputs. Select a different pattern by right-clicking the connector pane and selecting Patterns from the shortcut menu.

35 Connector Pane – Standards
Use this connector pane layout as a standard. Top terminals are usually reserved for references, such as a file reference. Bottom terminals are usually reserved for error clusters.

36 D. Using SubVIs Using on Block Diagram Terminal Settings
Handling Errors Creating from a Section of Block Diagram

37 Using SubVIs Options to place a subVI on the block diagram:
Drag the VI from the Project Explorer to the block diagram. Click Select a VI on the Functions palette and then navigate to the VI. Drag the icon from an open VI to the block diagram of another VI.

38 SubVI Define a subVI called diode which outputs .7V for Vi1>Vi2 and outputs Vi1-Vi2 for Vi1<Vi2. Simulate the circuits below and graph Vout using Waveform graph (not waveform chart) and using x-y graph. Your program may or may not correspond to the circuit.


Download ppt "Week 3 Labview exercises"

Similar presentations


Ads by Google