Sunteți pe pagina 1din 38

Week 3 Labview exercises

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.

12
10
Vout vs Vin
8

Vout (V)
6
4
2
0
0 1 2 3 4
Vin (V)
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”.

Vout vs Vin
12

10

8
Vout (V)

0
0 0.5 1 1.5 2 2.5 3 3.5
-2
Vin (V)
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.
Dynamic Data
• Watch video to help with graphing
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.
Back to Labview
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
• Watch the video
• Do the diode of the previous slide but instead
of using tabs use enums
Documenting Block Diagram Code
Owned labels:
Free labels: – Explain data contents
– Describe algorithms. of wires and objects.
– Move with object.
– Have pale yellow – Have transparent
backgrounds. backgrounds.
– Double-click in any – Select Visible
Items»Label from the
open space to shortcut menu to
create. create.

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

10
Arrays – 1D and 2D Examples
ID array
One row of 10-elements
0 1 2 3 4 5 6 7 8 9
1.2 3.2 8.2 8.0 4.8 5.1 6.0 1.0 2.5 1.7

Index
2D array numbers
Five-row by seven-column table of 35
elements
0 1 2 3 4 5 6
0
1
2
3
4

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

12
Creating an Array Control
For a new array:
1. Select an Array control from the
Controls palette on the front panel.
2. Place a data object, such as a
numeric control, into the array
shell.
3. Add a second dimension, if necessary, by
resizing the index.
From a block diagram terminal or wire:
1. Right-click the object and select
Create»Control or Create»Indicator.

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

14
Auto-Indexing
Auto-Indexing Enabled

Wire becomes thicker


– Allows For Loops and
While Loops to accumulate
arrays at their boundaries.
1D Array
– Is the default behavior for
For Loops. 0 1 2 3 4 5
– Is disabled by default for
While Loops. Auto-Indexing Disabled

– Is enabled/disabled by Wire remains the same


right-clicking on a tunnel. size

– Produces arrays that are


always equal in size to the
number of iterations of the Only one value (last
iteration) is passed out of
loop. the loop

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

16
Charts vs. Graphs – Single-Plot

17
Auto-Indexing with a Conditional
Tunnel

Right-click on a tunnel and


select Tunnel
Mode»Conditional.

18
Creating 2D Arrays

1D Array 2D Array

0 1 2 3 4 5

• Inner loop creates column elements.


• Outer loop stacks column elements into rows.

19
Arrays
Simulate circuit 1 and store Vout in an array. Graph Vout using
Waveform graph (not waveform chart) and using x-y graph
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.

21
Understanding Modularity – SubVIs

Repeated code can become subVIs.

22
Understanding Modularity – SubVIs

23
Understanding Modularity – SubVIs
Function Code Calling Program Code
function average (in1, in2, main
out) {
{ average (point1, point2,
out = (in1 + in2)/2.0; pointavg)
} }

SubVI Block Diagram Calling VI Block Diagram

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

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

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

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

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

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

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

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

32
C. Connector Pane
Patterns
Standards

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

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

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

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

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

S-ar putea să vă placă și