Saturday, September 25, 2010

Temperature Running Average VI

Summary: Use shift registers to perform a running average.





EXERCISE 1

Complete the following steps to modify the Temperature Monitor VI to average the last three temperature measurements and display the average on a waveform chart.

1.A) Front Panel

  1. Open the Temperature Monitor VI.
  2. Select File>>Save As and rename the VI Temperature Running Average.vi in the C:\Exercises\LabVIEW Basics I directory.

1.B) Block Diagram

  1. Display the block diagram.
  2. Right-click the right or left border of the While Loop and select Add Shift Register from the shortcut menu to create a shift register.
  3. Right-click the left terminal of the shift register and select Add Element from the shortcut menu to add an element to the shift register.
  4. Modify the block diagram as in Figure 1.
    Figure 1
    Figure 1 (temprunavgbd.png)
    1. tempicon.png Press the <Ctrl> key while you click the Thermometer VI and drag it outside the While Loop to create a copy of the subVI. The Thermometer VI returns one temperature measurement from the temperature sensor and initializes the left shift registers before the loop starts.
    2. compariticon.png Place the Compound Arithmetic function, located on the Functions>>Arithmetic & Comparison>>Express Numeric palette, on the block diagram. This function returns the sum of the current temperature and the two previous temperature readings. Use the Positioning tool to resize the function to have three left terminals.
    3. divicon.png Place the Divide function, located on the Functions>>Arithmetic & Comparison>>Express Numeric palette, on the block diagram. This function returns the average of the last three temperature readings.
    4. divconst.png Right-click the y terminal of the Divide function, select Create>>Constant, type 3, and press the <Enter> key.

1.C) Run the VI

  1. Run the VI. During each iteration of the While Loop, the Thermometer VI takes one temperature measurement. The VI adds this value to the last two measurements stored in the left terminals of the shift register. The VI divides the result by three to find the average of the three measurements, the current measurement plus the previous two. The VI displays the average on the waveform chart. Notice that the VI initializes the shift register with a temperature measurement.

1.D) Block Diagram

  1. Modify the block diagram as shown in Figure 2.
    Figure 2
    Figure 2 (temprunavgmultbd.png)
    1. bundleicon.png Place the Bundle function, located on the Functions>>All Functions>>Cluster palette, on the block diagram. This function bundles the average and current temperature for plotting on the waveform chart.
  2. Save the VI. You will use this VI later in the course.

1.E) Run the VI

  1. Run the VI. The VI displays two plots on the waveform chart. The plots are overlaid. That is, they share the same vertical scale.
  2. If time permits, complete the optional steps. Otherwise, close the VI.

1.F) Optional

Customize the waveform chart as shown in Figure 3. You can display a plot legend, a scale legend, a graph palette, a digital display, and a scrollbar. By default, a waveform chartdisplays the plot legend.
Figure 3
Figure 3 (temprunavgfp.png)
  1. Customize the y-axis.
    1. labeling.png Use the Labeling tool to double-click 70.0 in the y-axis, type 75.0, and press the <Enter> key.
    2. b: Use the Labeling tool to double-click the second number from the bottom on the y-axis, type 80.0, and press the <Enter> key. This number determines the numerical spacing of the y-axis divisions. For example, if the number above 75.0 is 77.5, it indicates a y-axis division of 2.5, changing the 77.5 to 80.0 reformats the y-axis to multiples of 5.0 (75.080.085.0, and so on).

    NOTE: 

    The waveform chart size has a direct effect on the display of axis scales. Increase the waveform chart size if you encounter problems while customizing the axis.
  2. Right-click the waveform chart and select Visible Items>>Scale Legend from the shortcut menu to display the scale legend, as shown in Figure 4. You can place the scale legend anywhere on the front panel.
    Figure 4: 1. X-axis, 2. Y-axis, 3. Scale Labels, 4. Scale Lock Button, 5. Autoscale Button, 6. Scale Format Button
    Figure 4 (scale.png)
  3. Use the scale legend to customize each axis.
    1. Make sure the Lock Autoscale button appears locked and the Autoscale LED is green so the y-axis adjusts the minimum and maximum values to fit the data in the chart.
    2. Click the Scale Format button to change the format, precision, mapping mode, scale visibility, and grid options for each axis.
  4. Use the plot legend to customize the plots.
    1. Use the Positioning tool to resize the plot legend to include two plots.
    2. Use the Labeling tool to change Temp to Running Avg and to change Plot 1 to Current Temp. If the text does not fit, use the Positioning tool to resize the plot legend.
    3. Right-click the plot in the plot legend to set the line and point styles and the color of the plot background or traces.
  5. Right-click the waveform chart and select Visible Items>>Graph Palette from the shortcut menu to display the graph palette, as shown in Figure 5. You can place the graph palette anywhere on the front panel.
    Figure 5: 1. Cursor Movement Tool, 2. Zoom Button, 3. Panning Tool, 4. Zoom Pull-down Menu
    Figure 5 (graphpal.png)
    Use the Zoom button on the graph palette to zoom in or out of sections of the chart or the whole chart. Use the Panning tool to pick up the plot and move it around on the display. Use the Cursor Movement tool to move the cursor on the graph.
  6. Run the VI. While the VI runs, use the buttons in the scale legend and graph palette to modify the waveform chart.

    NOTE: 

    If you modify the axis labels, the display might become larger than the maximum size that the VI can correctly present.
  7. Use the Operating tool to click the Power switch and stop the VI.
  8. Save and close the VI.

Content actions

GIVE FEEDBACK:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Popular Projects

My Blog List

Give support

Give support
Encourage Me through Comments & Followers

Followers