Summary: Use shift registers to perform a running average.
Note: Your browser may not currently support MathML. See our browser support page for additional details. You can always view the correct math in the PDF version.
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.
File>>Save As and rename the VI
Temperature Running Average.vi in the
C:\Exercises\LabVIEW Basics I directory.
While
Loop and select Add Shift Register from
the shortcut menu to create a shift register.
shift
register and select Add Element from the
shortcut menu to add an element to the shift
register.
![]() |
<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.
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.
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.
Right-click the y terminal of the
Divide function, select
Create>>Constant, type <Enter> key.
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.
![]() |
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.
waveform
chart. The plots are overlaid. That is, they share
the same vertical scale.
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 chart displays the plot
legend.
![]() |
Use the Labeling tool to double-click
<Enter> key.
Labeling tool to double-click the
second number from the bottom on the y-axis, type
<Enter> key. This number determines the
numerical spacing of the y-axis divisions.
For example, if the number above 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.
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.
![]() |
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.
Scale Format button to change the
format, precision, mapping mode, scale visibility, and
grid options for each axis.
Positioning tool to
resize the plot legend to include two plots.
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.
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.
![]() |
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.
waveform
chart.
Operating tool to click the
Power switch and stop the VI.
"A full introductory course on programming with LabVIEW."