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
- Open the Temperature Monitor VI.
- Select
File>>Save As
and rename the VITemperature Running Average.vi
in theC:\Exercises\LabVIEW Basics I
directory.
1.B) Block Diagram
- Display the block diagram.
- Right-click the right or left border of the
While Loop
and selectAdd Shift Register
from the shortcut menu to create ashift register
. - Right-click the left terminal of the
shift register
and selectAdd Element
from the shortcut menu to add an element to theshift register
. - Modify the block diagram as in Figure 1.
Figure 1 - Press the
<Ctrl>
key while you click theThermometer
VI and drag it outside theWhile Loop
to create a copy of the subVI. TheThermometer
VI returns one temperature measurement from the temperature sensor and initializes the leftshift registers
before the loop starts. - Place the
Compound Arithmetic
function, located on theFunctions>>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 thePositioning
tool to resize the function to have three left terminals. - Place the
Divide
function, located on theFunctions>>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 theDivide
function, selectCreate>>Constant
, type 3, and press the<Enter>
key.
- Press the
1.C) Run the VI
- Run the VI. During each iteration of the
While Loop
, theThermometer
VI takes one temperature measurement. The VI adds this value to the last two measurements stored in the left terminals of theshift 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 thewaveform chart
. Notice that the VI initializes theshift register
with a temperature measurement.
1.D) Block Diagram
- Modify the block diagram as shown in Figure 2.
Figure 2 - Place the
Bundle
function, located on theFunctions>>All Functions>>Cluster
palette, on the block diagram. This function bundles the average and current temperature for plotting on thewaveform chart
.
- Place the
- Save the VI. You will use this VI later in the course.
1.E) Run the VI
- Run the VI. The VI displays two plots on the
waveform chart
. The plots are overlaid. That is, they share the same vertical scale. - 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 chart
displays the plot legend.- Customize the y-axis.
- Use the
Labeling
tool to double-click 70.0 in the y-axis, type 75.0, and press the<Enter>
key. - 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.0, 80.0, 85.0, and so on).
NOTE:
Thewaveform chart
size has a direct effect on the display of axis scales. Increase thewaveform chart
size if you encounter problems while customizing the axis. - Use the
- 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 - Use the scale legend to customize each axis.
- Make sure the
Lock Autoscale
button appears locked and theAutoscale
LED is green so the y-axis adjusts the minimum and maximum values to fit the data in the chart. - Click the
Scale Format
button to change the format, precision, mapping mode, scale visibility, and grid options for each axis.
- Make sure the
- Use the plot legend to customize the plots.
- Use the
Positioning
tool to resize the plot legend to include two plots. - Use the
Labeling
tool to changeTemp
toRunning Avg
and to changePlot 1
toCurrent Temp
. If the text does not fit, use the Positioning tool to resize the plot legend. - Right-click the plot in the plot legend to set the line and point styles and the color of the plot background or traces.
- Use the
- Right-click the
waveform chart
and selectVisible 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.
Use theFigure 5: 1. Cursor Movement Tool, 2. Zoom Button, 3. Panning Tool, 4. Zoom Pull-down Menu Zoom
button on the graph palette to zoom in or out of sections of the chart or the whole chart. Use thePanning
tool to pick up the plot and move it around on the display. Use theCursor Movement
tool to move the cursor on the graph. - 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. - Use the
Operating
tool to click thePower
switch and stop the VI. - Save and close the VI.
No comments:
Post a Comment