Module 2 - MVJ22EC643 - Virtual Instrumentation
Module 2 - MVJ22EC643 - Virtual Instrumentation
1
1
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B) s
Syllabus
Module 2:
• It makes the “main’’part of the code easier to read since long code sections are replaced
with simple functions. The individual components can be reused in other programs.
• For example, suppose you write a program that accepts data from the keyboard and
calculates the average, standard deviation and so on. If the part of the program that
calculates the standard deviation is contained inside a separate function, you could reuse
that function in another program that needed to calculate the standard deviation.
3
3 3 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
Modular Programming in LabVIEW
• The power of LabVIEW lies in the hierarchical nature of the VI. After you create
a VI, you can use it on the block diagram of another VI. There is no limit on the
number of layers in the hierarchy.
• Modular programming helps manage changes and debug the block diagram
quickly.
• The icon and connector pane correspond to the function prototype in text-based
programming languages. The icon and connector pane is shown in figure 2.
• Every VI displays an icon in the upper-right corner of the front panel and block
diagram windows. An icon is a graphical representation of a VI.
• If you use a VI as a subVI, then the icon identifies the subVI on the block
diagram of the VI.
Figure 2:Icon and connector pane created for the slope VI.
6
6 6 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
CREATING AN ICON
• The default icon of a VI contains a number that indicates how many new VIs
you have opened since launching LabVIEW. You can create custom icons to
replace the default icon by completing the following steps:
1. Right-clicking the icon in the upper-right corner of the front panel or block
diagram and select Edit Icon from the shortcut menu to display the Icon
Editor dialog box as shown in Figure .
2. Double-click the hatched box which will select the entire icon. Delete the
selected portion.
3. Double-click the rectangular box which will create a border for the icon.
6. Choose the Text Tool Font to edit font, font size, color and alignment of the
text.
7. Use the Select Color tool to choose the background color of the icon.
8. Use the Fill With Color tool to change the background color of the icon.
8
8 8 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
BUILDING A CONNECTOR PANE
• The connector pane is a set of terminals that correspond to the controls and
indicators of that VI, similar to the parameter list of a function call in text-
based programming languages. The connector pane defines the inputs and
outputs you can wire to the VI so that you can use it as a subVI
• A connector pane receives data at its input terminals and passes the data
to the block diagram code through the front panel controls or receives the
results at its output terminals from the front panel indicators.
• If you placed the VI as a subVI on another block diagram, you must relink
the subVI to the VI whose connector pane you changed by right-clicking the
subVI and selecting Relink To SubVI from the shortcut menu. The figure 4
shows various patterns. 10
1010 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
BUILDING A CONNECTOR PANE
11
1111 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
Assigning Terminals to Controls and Indicators
After you select a pattern to use for the connector pane, you must assign a front
panel control or indicator to each of the connector pane terminals. To link controls
and indicators to the connector pane, place inputs on the left and outputs on the
right to prevent complicated or confusing wiring patterns.
Step 1: Ensure that you have selected a pattern sufficient for the number of controls
and indicators you want to assign to the connector pane.
Step 2: Right-click the icon in the upper-right corner of the front panel and select
Show Connector from the shortcut menu to display the connector pane. The
connector pane appears in place of the icon.
12
. 1212 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
Assigning Terminals to Controls and
Indicators
Step 3: Click a terminal of the connector pane. The tool automatically changes to
the wiring tool and the terminal turns black.
Step 4: Click the front panel control or indicator you want to assign to the
terminal. A marquee highlights the object as shown in Figure 3.9.
Step 5: Click an open space of the front panel. The marquee disappears, and the
terminal changes to the data type color of the control to indicate that you
connected the terminal. If the connector pane terminal turns white, a connection
was not made. Repeat steps 1 through 3 until the connector pane terminal
changes to the proper data type color.
Step 6: Repeat steps 3 through 5 for each control and indicator you want to
assign to a terminal. 13
1313 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
Assigning Terminals to Controls and
Indicators
Step 7: If necessary, confirm each terminal connection. You can specify which
terminals are
required, recommended and optional. You can connect only one control or
indicator to a terminal.
14
1414 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
Setting Required, Recommended, and Optional
Inputs and Outputs
You can designate which inputs and outputs are required, recommended, and
optional to prevent users from forgetting to wire subVI terminals.
Right-click a terminal in the connector pane and select This Connection Is from the
shortcut menu.
For terminal inputs and outputs, Recommended or Optional means that the block
diagram on which you placed the subVI can execute if you do not wire the
recommended or optional terminals. 15
1515 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
Setting Required, Recommended, and Optional
Inputs and Outputs
If you do not wire the terminals, the VI does not
Step 1: Right-click a terminal in the connector pane and select This Connection
Is from the shortcut menu.
• Then select Edit»Create SubVI from the menu to convert the selected portion
into a subVI. SubVI created with default icon is shown in Figure 7.
• An icon for the new subVI replaces the selected section of the block diagram.
LabVIEW creates controls and indicators for the new subVI, automatically
configures the connector pane based on the number of control and indicator
terminals you selected, and wires the subVI to the existing wires.
17
1717 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
CREATING SUBVIs FROM SECTIONS OF A
VI
18
1818 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
OPENING AND EDITING SUBVIs
When you double-click a subVI, a front panel and a block diagram appear, rather
than a dialog box in which you can configure options.
The subVI controls and indicators receive data from and return data to the block
diagram of the calling VI. Click the Select a VI icon or text on the Functions palette,
navigate to and double-click a VI, and place the VI on a block diagram to call a
created subVI.
Step 1: Use the operating or positioning tool to double-click the subVI on the block
diagram. LabVIEW displays the front panel of the subVI. You also can press the
<Ctrl> key and use the operating or positioning tool to double-click the subVI on the
block diagram to display the block diagram and front panel of the subVI.
19
1919 s
Step 2: Edit the subVI.
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
PLACING SUBVIs ON BLOCK
DIAGRAMS
Complete the following steps to place a subVI on the block diagram.
Step 4: Navigate to and double-click the VI you want to use as a subVI, and place
it on the block
diagram.
Step 5: Wire the subVI terminals to other nodes on the block diagram.
20
2020 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
FOR LOOPS
• A For Loop executes a sub diagram, a set number of times. Figure 8 shows a
For Loop in LabVIEW and the flow chart equivalent of the For Loop
functionality. The For Loop is located on the
Functions>>Programming>>Structures Palette.
• Select the For Loop from the palette and use the cursor to drag a selection
rectangle to create a new For Loop or around the section of the block
Figure 8: For Loop .
diagram you want to repeat
21
2121 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
FOR LOOPS
• The value in the count terminal ‘N’ (an input terminal) indicates how many times
to repeat the subdiagram. Set the count explicitly by wiring a value from outside
the loop to the left or top side of the count terminal, or set the count implicitly
with auto-indexing. A VI will not run if it contains a For Loop that does not have a
numeric value wired to the count terminal.
• The iteration terminal ‘i’ (an output terminal) contains the number of completed
iterations. The iteration count always starts at zero. During the first iteration, the
iteration terminal returns 0. Figure 4.2 shows a simple For Loop which generates
10 random numbers and displays in the Random Number Indicator.
Figure 9: Example of a For Loop .
22
2222 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
WHILE LOOPS
A While Loop executes a subdiagram until a condition is met.
The While Loop is similar to a Do Loop or a Repeat-Until Loop in text-based
programming languages.
A While Loop in LabVIEW and the flow chart equivalent of the While Loop is
shown in figure 10. The While Loop always executes at least once.
In LabVIEW, the WHILE Loop is located on the
Functions>>Programming>>Structures palette.
The While Loop contains two terminals, namely Conditional Terminal and
Iteration Terminal.
23
2323 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
WHILE LOOPS
.
The While Loop executes the subdiagram until the conditional terminal,
and receives a specific Boolean value. The default behavior and
appearance of the conditional terminal is Stop if True as shown in Figure
10. Figure 10: While Loop .
24
2424 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
WHILE LOOPS
When a conditional terminal is Stop if True, the While Loop executes its
subdiagram until the conditional terminal receives a TRUE value. You
can change the behavior and appearance of the conditional terminal by
right-clicking the terminal or the border of the While Loop and selecting
Continue if True from the shortcut menu as shown in Figure 11. When a
conditional terminal is Continue if True, the While Loop executes its
subdiagram until the conditional terminal receives a FALSE value.
25
2525 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
STRUCTURE TUNNELS
• Data can be passed out of or into a loop through a tunnel. Tunnels feed data
into and out of structures. The tunnel appears as a solid block on the border of
the loop. The block is the color of the data type wired to the tunnel. Data
passes out of a loop after the loop terminates. When a tunnel passes data into a
loop, the loop executes only after data arrives at the tunnel. The value in the
tunnel does not pass to the Iteration Number indicator until the While Loop has
finished execution.
26
2626 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
TERMINALS INSIDE OR OUTSIDE LOOPS
• Inputs pass data into a loop at the start of loop execution.
• Outputs pass data out of a loop only after the loop completes all iterations.
• If you want the loop to check the value of a terminal for each iteration,
place the terminal inside the loop.
• When you place the terminal of a front panel Boolean control inside a While
Loop and wire the terminal to the conditional terminal of the loop, the loop
checks the value of the terminal for every iteration to determine if it must
iterate.
• You can stop the While Loop as shown in Figure 4.10(a) by changing the
value of the front panel control to FALSE. 27
2727 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
TERMINALS INSIDE OR OUTSIDE LOOPS
• If you place the terminal of the Boolean control outside the While Loop as
shown in Figure 13 and the control is set to FALSE if the conditional terminal
is Stop if True when the loop starts, you cause an infinite loop.
• You also cause an infinite loop if the control outside the loop is set to TRUE
and the conditional terminal is Continue if True.
28
2828 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
SHIFT REGISTERS
• When programming with loops, you often need to access data from previous
iterations of the loop. For example, you may have a VI that reads the
temperature and displays it on a graph. If you want to display a running average
of the temperature as well, you need to use data generated in previous
iterations. Two ways of accessing this data include the shift register and the
feedback node.
• While Loops produce default data when the shift register is not initialized. For
Loops produce default data if you wire 0 to the count terminal of the For Loop or
if you wire an empty array to the For Loop as an input with auto-indexing
enabled. The loop does not execute, and any output tunnel with auto-indexing
disabled contains the default value for the tunnel data type. Use shift registers
to transfer values through
An Autonomous aAffiliated
Institution, loop to regardless of whether
VTU, Belagavi, Approved the
By AICTE, New loop
Delhi, executes.
Recognized
29
2929 s
by UGC with 2(f) & 12(B)
SHIFT REGISTERS
• Shift registers are used with For Loops and While Loops to transfer values from
one loop iteration to the next.
• LabVIEW transfers the data connected to the right side of the register to the
next iteration. After the loop executes, the terminal on the right side of the loop
returns the last value stored in the shift register. Create a shift register by right-
clicking the left or right border of a loop and selecting the Add shift register
from the shortcut menu.
30
3030 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
FEEDBACK NODES
When the output of a node is connected directly to the input, the feedback
node is generated automatically. The feedback node shown in Figure 4.17
appears automatically in a For Loop or While Loop if we wire the output of a
node or group of nodes to the input of that node or group of nodes. Like a
shift register, the feedback node stores data when the loop completes an
iteration, sends that value to the next iteration of the loop, and transfers any
data type. Use the feedback node to avoid unnecessarily long wires in loops.
The feedback node arrow indicates the direction in which the data flows
along the wire. The arrow automatically changes direction if the direction of
data flow changes.
31
3131 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
FEEDBACK NODES
You also can select the Feedback Node on the Structures palette and
place it inside a For Loop or While Loop. If you place the feedback node
on the wire before you branch the wire that connects the data to the
tunnel as in Figure 4.18, the feedback node passes each value to
32
the tunnel. 3232 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
CONTROL TIMING
• When a loop finishes executing an iteration, it immediately begins executing
the next iteration unless it reaches a stop condition.
• You might want to control the speed at which a process executes, such as the
speed at which data values are plotted to a chart.
• You can use a wait function in the loop to wait an amount of time in
milliseconds before the loop re-executes. LabVIEW consists of two wait
functions.
• A wait function is placed inside a loop to allow a VI to sleep for a set amount of
time. This allows your
An Autonomous processor
Institution, toVTU,
Affiliated to address otherBytasks
Belagavi, Approved during
AICTE, New the wait
Delhi, Recognized by UGCtime.
33
3333 s
with 2(f) & 12(B)
CONTROL TIMING
Wait functions use the operating system millisecond clock.
• The Wait Until Next ms Multiple function monitors a millisecond counter and
waits until the millisecond counter reaches a multiple of the time you specify.
• The Wait (ms) function adds the wait time to the code execution time. This
can cause a problem if code execution time is variable. The Wait (ms) function
waits until the millisecond counter counts to an amount equal to the input you
specify.
Figure 16: (a) Wait Until Next ms Multiple function
and (b) Wait (ms) function
34
3434 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
COMMUNICATING AMONG MULTIPLE
LOOPS
In LabVIEW, the flow of data determines the execution order of block diagram
elements.
Variables are block diagram elements that allow you to access or store data in
another location.
The actual location of the data varies depending upon the type of the variable.
35
3535 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
LOCAL VARIABLES
• Local variables transfer data within a single VI and allow data to be passed
between parallel loops as shown in Figure 4.22.
• They also break the dataflow programming paradigm. Two ways to create a
local variable are right-click on an object’s terminal and select Create»Local
Variable.
36
3636 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
LOCAL VARIABLES
• Another way is to select the Local Variable from the Structures palette. Create
the front panel and select a local variable from the Functions palette and place
it on the block diagram.
• After you create a local or global variable, you can read data from a variable
or write data to it. By default, a new variable receives data.
• This kind of variable works as an indicator and is a write local or global. When
you write new data to the local or global variable, the associated front panel
control or indicator updates to the new data.
37
3737 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
GLOBAL VARIABLES
• Global variables are built-in LabVIEW objects. You can use variables to access
and pass data among several VIs that run simultaneously.
• A local variable shares data within a VI; a global variable also shares data,
but it shares data with multiple VIs. For example, suppose you have two VIs
running simultaneously.
• Each VI contains a While Loop and writes data points to a waveform chart.
The first VI contains a Boolean control to terminate both VIs.
• You can use a global variable to terminate both loops with a single Boolean
control. If both loops were on a single block diagram within the same VI, you
could use a local variable to terminate the loops.
38
3838 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
GLOBAL VARIABLES
Arrays hold a sequence of data elements, usually of the same size and same
data type placed in contiguous memory locations that can be individually
referenced.
Hence arrays are essentially a way to store many values under the same
name. Individual elements are accessed by their position in the array.
• The array shell automatically resizes to accommodate the new object. The
array shell can be selected from Controls>>Modern>>Arrays, Matrix &
Clusters palette. The array elements must be controls or indicators.
• After placing an element in the array shell, you can expand the array either
horizontally or vertically to see more number of elements. Once a data type
is assigned to the array shell, the block diagram takes the color and
lettering (in [ ] brackets) of the data type 41
4141 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
CREATING TWO-DIMENSIONAL ARRAY
• A two-dimensional array is analogous to a spreadsheet or table. A two-
dimensional array stores elements in a grid. It requires a column index and
a row index to locate an element, both of which are zero-based. Two-
dimensional arrays are very commonly used in data acquisition
applications.
• For example, when waveforms from several channels are read from a data
acquisition (DAQ) board, the data is stored in a two-dimensional array
where each column in the array corresponds to data from one channel. To
create a two-dimensional array on the front panel, right-click the index
display of the array and select Add Dimension from the shortcut menu. You
also can use the Positioning tool to resize the index display to have one
42
4242 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
CREATING MULTIDIMENSIONAL ARRAY
• To create a multidimensional array on the front panel, right-click the index
display of the array and select Add Dimension from the shortcut menu.
• You also can use the Positioning tool to resize the index display until you
have as many dimensions as you want.
• To delete dimensions one at a time, right-click the index display and select
Remove Dimension from the shortcut menu. You can also resize the index
display to delete dimensions.
• Use the Positioning tool to resize the array to show more than one row or
column at a time.
43
4343 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
CREATING 1D, 2D and MULTIDIMENSONAO
ARRAY
2. Wire an array of any dimension to the n-dim array input of the Insert into Array
function. The function automatically resizes based on the dimensions of the array.
3. Determine which operation you want to perform from Table 5.2 and complete the
associated steps.
4. The index input specifies the element, row, column or page where you want to
insert the element or array, with 0 being the first. Elements and arrays are added
before the value you wire to index.
5. Run the VI. An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
46
4646 s
DELETING ELEMENTS, ROWS, COLUMNS AND
PAGES WITHIN ARRAYS
• You can delete an element within a one-dimensional array and a row or column
within a two-dimensional array.
• You can also programmatically delete elements, rows, columns and pages within
arrays using the Delete From Array function.
• You can delete an element, row, column or page within an array programmatically.
What you can delete depends on how many dimensions the array has. 47
4747 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
DELETING ELEMENTS, ROWS, COLUMNS AND
PAGES WITHIN ARRAYS
• Complete the following steps to delete elements, rows, columns or pages in an
array.
• Step 1: Place the Delete From Array function on the block diagram.
• Step 2: Wire an array of any dimension to the n-dim array input of the Delete
From Array
• Step 3: Determine which operation you want to perform from Table 5.1 and
complete the
• associated steps.
48
4848 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
REPLACING ELEMENTS, ROWS, COLUMNS, AND
PAGES WITHIN ARRAYS
• You can replace an element, row, column or page in an array.
• What you can replace depends on how many dimensions the array has. For
example, in an array of two or more dimensions, you can replace a row or a
column with a one-dimensional array.
• In an array of three or more dimensions, you can replace a page with a two-
dimensional array. Replacing is done using the Replace Array Subset function.
• Step 1: Place the Replace Array Subset function on the block diagram.
49
4949 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
REPLACING ELEMENTS, ROWS, COLUMNS, AND
PAGES WITHIN ARRAYS
• Step 2: Wire an array of any dimension to the n-dimension array input
of the Replace Array Subset function. The function automatically resizes
based on the dimensions of the array.
• Step 3: Determine which operation you want to perform from Table 5.3
and complete the associated steps. The index input specifies which element,
row, column or page to replace, with 0 being the first. The new
element/subarray input specifies the value you want to replace an element, or
the array you want to replace a row, column or page.
• Array functions including Index Array, Replace Array Subset, Insert Into Array,
Delete From Array, and Array Subset automatically resize to match the
dimensions of the input array you wire.
• For example, if you wire a one-dimensional array to one of these functions, the
function shows a single index input. If you wire a two-dimensional array to the
same function, it shows two index inputs—one for the row index and one for the
column index. 51
5151 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
ARRAY FUNCTIONS (EXAMPLES)
Step 5: Run the VI. The matrix indicator displays the contents of the original
array
Figure 25: Front panel and block diagram of the VI to convert an array to a
matrix.
54
54 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
MATRIX OPERATIONS WITH ARRAYS
Converting a Matrix to an Array:
Step 1: Place a Real Matrix or Complex Matrix control on the front panel.
Step 4: Right-click the Matrix To Array function and select Create» Indicator
from the shortcut menu to create a two-dimensional array indicator.
Step 5: Run the VI from the front panel. The array indicator displays the
contents of the array.
55
55 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
MATRIX OPERATIONS WITH ARRAYS
Figure 26: Front panel and block diagram of the VI to convert a matrix into
an array.
56
56 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
POLYMORPHISM
• All LabVIEW arithmetic functions are polymorphic. This means that the
inputs to these functions can be different data structures such as scalar
values and arrays.
For example, the Add function can be used in the following ways.
58
5858 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
POLYMORPHISM
•Polymorphism does not perform matrix arithmetic when inputs are two-
dimensional arrays (for example, two two-dimensional array inputs to a
multiply function do element by element multiplication, not matrix
multiplication).
59
5959 s
An Autonomous Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
Assignment Questions
1. Bulid a VI to create seven segment display.
2. Build a VI to create seven segment display for two digit numbers. (EX:10 TO
99)
4. Build a VI to display only the odd numbers using conditional tunnel modes.
6. Create a VI to find the sum of first n natural numbers using A WHILE LOOP
with a feedback node.Institution, Affiliated to VTU, Belagavi, Approved By AICTE, New Delhi, Recognized by UGC with 2(f) & 12(B)
An Autonomous
60
60 s
MVJ College of Engineering
Near ITPB, Whitefield
Thank You
Bangalore