CÓDIGO CLASSROOM:
ANTES DE COMENZAR:
Objective: To create an array using the auto-indexing feature of a For Loop and plot the array in a waveform graph.
Build a VI that generates and plots an array in a waveform graph and modify the VI to graph multiple plots.
Front Panel
1. Open a new VI and build the front panel shown below. Be sure to modify the controls and indicators as shown.
a. Place an array shell, available on the Controls»Array & Cluster palette, on the front panel. Label the array shellWaveform Array.
Place a digital indicator, available on the Controls»Numeric palette, inside the array shell using the shortcut menu. This indicator displays the array contents.
b. Place a waveform graph, available on the Controls»Graph palette, on the front panel.
Choose a digital indicator from the Numeric subpalette and place it into the array shell.
Block Diagram
2. Build the block diagram shown above.
Process Monitor VI, available on the Functions»User
Libraries»Basics I Course palette—Outputs simulated experimental data. In this exercise, the VI returns one point of simulated temperature data during each For Loop iteration.
Numeric Constant, available on the Functions»Numeric palette—Sets the number of For Loop iterations in this exercise. The VI generates 100 temperature values at the border of the For Loop. The tunnel output is a 100-element array. Right-click the count terminal and select
Create»Constant. Type100in the highlighted terminal.
3. Wire the waveform array directly to the waveform graph terminal. Each iteration of the For Loop will generate a temperature value and store it in an array at the loop border (tunnel).
4. Save the VI. Name itGraph Waveform Array.vi.
5. Return to the front panel and run the VI. The VI plots the auto-indexed waveform array on the waveform graph.
6. You can view any element in the Waveform Array on the front panel by entering the index of that element in the index display. If you enter a number greater than the array size, the display dims.
To view more than one element at a time, resize the array indicator. Place the Positioning tool on the lower-right corner of the array until the tool appears as shown at left and drag. The indicator now displays several elements in an ascending index order, beginning with the element corresponding to the specified index, as shown below.
Count terminal
Positioning tool
Positioning tool over the corner of an array
In the previous block diagram, you used the default value of the initial X and delta X value for the waveform. There are often cases where the initial X and delta X value will be a specific value. In these instances, you can use the Bundle function to specify an initial and delta X value for a waveform array.
7. Return to the block diagram. Delete the wire between the waveform array and waveform graph. Finish wiring the block diagram as shown above.
Bundle function, available on the Functions»Cluster
palette—Assembles the plot components into a single cluster in this exercise. The components include the initial X value (10), the delta X value (1.5), and the Y array (waveform data). Use the Positioning tool to resize the function by dragging one of the corners.
You can draw the delta by first typing “DX” for the label of the constant. Select the D using the Labeling tool and then select the Symbol font from the Font Ring. The letter D then converts to the delta symbol.
After the loop finishes execution, the Bundle function bundles the initial value of X (Xo), the delta value of X, and the array for plotting on the graph.
8. Return to the front panel. Save and run the VI. The VI plots the auto-indexed waveform array on the waveform graph. The initial X value is 10 and the delta X value is 1.5.
9. Change the delta X value to 0.5 and the initial X value to 20.
Notice that the graph now displays the same 100 points of data with a starting value of 20 and a delta X of 0.5 for each point (see the X axis). In a timed test, this graph would correspond to 50 seconds worth of data starting at 20 seconds. Experiment with several combinations for the initial and delta X values.
10. Graphs contain scale legends and graph palettes just as charts do. View the graph palette by right-clicking the waveform graph and selecting Visible Items»Graph Palette from the shortcut menu. You can use the ∆X
Labeling tool
zooming features on the palette to see the data on the graph in more detail. View the scale legend by right-clicking the graph and selecting Visible Items»Scale Legend from the shortcut menu.
11. With LabVIEW, you can specify a time and date format for numerics and Graphs. Right-click the waveform graph and select X Scale» Formatting from the shortcut menu. Change the formatting options as shown below.
a. Modify the Scale Style to match the style shown above.
b. Change Format to the Time & Date format by clicking the menu ring.
c. Modify the Time to show the time as HH:MM:SS.
d. Modify the Scaling Factors to have Xo begin at 7:30:00 a.m. 01/15/2000 and∆X to increment every 10 minutes (0:10:00.00). e. Click the OK button to apply your changes.
Note The Xo and∆X parameters in the X Scale Formatting screen interact with the Xo and∆X from the Bundle function. Change the bundle’s Xo and ∆X to 0 and 1,
respectively, to match the example. For example:
Bundle Values Formatting Setup Resultant Graph Settings
Change the starting and delta scale times in just one location—either the Bundle function or X Scale»Formatting.
Note If the x-axis text is not clearly visible, shrink the inner display (black area) of the graph with the Positioning tool to increase the border area around the graph.