Activity 7-3: Polymorphism


You will build a VI that demonstrates polymorphism on arrays (see Figure 7.36).

Figure 7.36. Front panel of the VI you will create during this activity


1.

Open a new VI and create the front panel shown in Figure 7.36.

First, create the arrays. Remember, to create an array, you must first select the Array shell from the Modern>>Array, Matrix & Cluster subpalette of the Controls palette. Then put a numeric indicator into the shell's data object window. To see more than one element in the array, you must grab and drag the resizing handles of the filled element display window with the Positioning tool. You can drag out multiple elements in a 1D array either horizontally or vertically.

All four arrays in this exercise contain indicator elements. Make sure to give them unique labels so that you don't get them confused. If you ever do lose track of which front panel object corresponds to which block diagram terminal, simply pop up on one of them and choose Find Terminal or Find Indicator; LabVIEW will highlight the corresponding object.

2.

After you've created the arrays, select a Waveform Graph from the Graph subpalette of the Controls palette. Although you'll learn more about graphs in the next chapter, we wanted to give you a preview and spice up this exercise.

3.

Don't forget to create the Scale control.

4.

Build the diagram shown in Figure 7.37be careful because the wiring can get a little tricky!

Figure 7.37. Block diagram of the VI you will create during this activity


Auto-indexing is enabled by default on the For Loop, so your arrays will be generated automatically.

5.

You can find Add, Multiply, and Random Number (0-1) in the Programming>>Numeric palette.

6.

Select Build Array from the Programming>>Array palette. You will have to grow it using the Positioning tool so that it has four inputs. By default, the array inputs are not concatenated; the output from Build Array is a 2D array. Each input array becomes a row, so the output 2D array is composed of four rows and ten columns.

7.

Run the VI. Your graph will plot each array element against its index for all four arrays at once: Array 1 data, Array 2 data, Array 1* Scale, and Array 1+ Array 2.

The results demonstrate several applications of polymorphism in LabVIEW. For example, Array 1 and Array 2 could be incoming waveforms that you wish to scale.

8.

Save the VI as Polymorphism Example.vi and place it in your MYWORK directory or VI library. Close the VI.




LabVIEW for Everyone. Graphical Programming Made Easy and Fun
LabVIEW for Everyone: Graphical Programming Made Easy and Fun (3rd Edition)
ISBN: 0131856723
EAN: 2147483647
Year: 2006
Pages: 294

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net