<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="None">
  <name>Temperature Running Average VI</name>
  <metadata>
  <md:version>1.1</md:version>
  <md:created>2004/06/28 13:06:44 GMT-5</md:created>
  <md:revised>2004/07/16 15:14:52.383 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="NationalInstruments">
      <md:firstname>National</md:firstname>
      
      <md:surname>Instruments</md:surname>
      <md:email>certification@ni.com</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="lizzardg">
      <md:firstname>Elizabeth</md:firstname>
      
      <md:surname>Gregory</md:surname>
      <md:email>lizzardg@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="mshiralkar05">
      <md:firstname>Malan</md:firstname>
      
      <md:surname>Shiralkar</md:surname>
      <md:email>mshiralkar05@hotmail.com</md:email>
    </md:maintainer>
    <md:maintainer id="harika">
      <md:firstname>Harika</md:firstname>
      
      <md:surname>Basana</md:surname>
      <md:email>ilsai@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="NationalInstruments">
      <md:firstname>National</md:firstname>
      
      <md:surname>Instruments</md:surname>
      <md:email>certification@ni.com</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>National Instruments</md:keyword>
    <md:keyword>LabVIEW</md:keyword>
    <md:keyword>exercise</md:keyword>
    <md:keyword>Temperature Running Average VI</md:keyword>
  </md:keywordlist>

  <md:abstract>Use shift registers to perform a running average.</md:abstract>
</metadata>
  
  <content>
    <exercise id="e1">
      <problem>
	<para id="para1">
	  Complete the following steps to modify the <code>Temperature
	    Monitor</code> VI to average the last three temperature
	  measurements and display the average on a <code>waveform
	    chart</code>.
	</para>
	<section id="section1">
	  <name>Front Panel</name>
	  <list id="list1" type="enumerated">
	    <item>
	      Open the <cnxn document="m12234">Temperature Monitor</cnxn> VI.
	    </item>
	    <item>
	      Select <code>File&gt;&gt;Save As</code> and rename the VI
	      <code>Temperature Running Average.vi</code> in the
	      <code>C:\Exercises\LabVIEW Basics I</code> directory.
	    </item>
	  </list>
	</section>
	<section id="section2">
	  <name>Block Diagram</name>
	  <list id="list2" type="enumerated">
	    <item>
	      Display the block diagram.
	    </item>
	    <item>
	      Right-click the right or left border of the <code>While
		Loop</code> and select <code>Add Shift Register</code> from
	      the shortcut menu to create a <code>shift register</code>.
	    </item>
	    <item>
	      Right-click the left terminal of the <code>shift
		register</code> and select <code>Add Element</code> from the
	      shortcut menu to add an element to the <code>shift
		register</code>.
	    </item>
	    <item>
	      Modify the block diagram as in <cnxn target="f1"/>.
	      <figure id="f1">
		<media type="image/png" src="temprunavgbd.png"/>
	      </figure>
	      <list id="list3" type="enumerated">
		<item>   
		  <!--needs to be corrected, should be a seperate
		  paragraph-->
		  <media type="image/png" src="tempicon.png"/>
		  Press the <code>&lt;Ctrl&gt;</code> key while you click the
		  <code>Thermometer</code> VI and drag it outside the
		  <code>While Loop</code> to create a copy of the subVI.
		  <!--different para-->
		  The <code>Thermometer</code> VI returns one temperature
		  measurement from the temperature sensor and initializes
		  the left <code>shift registers</code> before the
		    loop starts.
		</item>
		<item>	      
		  <media type="image/png" src="compariticon.png"/>
		  Place the <code>Compound Arithmetic</code> function,
		  located on the <code>Functions&gt;&gt;Arithmetic &amp;
		    Comparison&gt;&gt;Express Numeric</code> palette, on the block
		  diagram. This function returns the sum of the current
		  temperature and the two previous temperature
		  readings. Use the <code>Positioning</code> tool to
		  resize the function to have three left terminals.
		</item>
		<item>            
		  <media type="image/png" src="divicon.png"/>
		  Place the <code>Divide</code> function, located on the
		  <code>Functions&gt;&gt;Arithmetic &amp; Comparison&gt;&gt;Express
		    Numeric</code> palette, on the block diagram. This
		  function returns the average of the last three
		  temperature readings.
		</item>
		<item>             
		  <media type="image/png" src="divconst.png"/>
		  Right-click the <code>y</code> terminal of the
		  <code>Divide</code> function, select
		  <code>Create&gt;&gt;Constant</code>, type <m:math>
		    <m:cn>3</m:cn> </m:math>, and press the
		  <code>&lt;Enter&gt;</code> key.
		</item>
	      </list>
	    </item>
	  </list>
	</section>
	<section id="section3">
	  <name>Run the VI</name>
	  <list id="list4" type="enumerated">
	    <item>
	      <!--needs to be corrected, should be a seperate paragraph-->
	      Run the VI.
	      <!--different para-->
	      During each iteration of the <code>While Loop</code>, the
	      <code>Thermometer</code> VI takes one temperature
	      measurement. The VI adds this value to the last two
	      measurements stored in the left terminals of the <code>shift
		register</code>. 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 <code>waveform chart</code>. Notice that the
	      VI initializes the <code>shift register</code> with a
	      temperature measurement.
	    </item>
	  </list>
	</section>
	<section id="section4">
	  <name>Block Diagram</name>
	  <list id="list5" type="enumerated">
	    <item>
	      Modify the block diagram as shown in <cnxn target="f2"/>.
	      <figure id="f2">
		<media type="image/png" src="temprunavgmultbd.png"/>
	      </figure>
	      <list id="list6" type="enumerated">
		<item>
		  <media type="image/png" src="bundleicon.png"/>      
		  Place the <code>Bundle</code> function, located on the
		  <code>Functions&gt;&gt;All Functions&gt;&gt;Cluster</code> palette,
		  on the block diagram. This function bundles the average
		  and current temperature for plotting on the
		  <code>waveform chart</code>.
		</item>
	      </list>
	    </item>
	    <item>
	      Save the VI. You will use this VI later in the course.
	    </item>
	  </list>
	</section>
	<section id="section5">
	  <name>Run the VI</name>
	  <list id="list7" type="enumerated">
	    <item>
	      Run the VI. The VI displays two plots on the <code>waveform
		chart</code>. The plots are overlaid. That is, they share
	      the same vertical scale.
	    </item>
	    <item>
	      If time permits, complete the optional steps. Otherwise,
	      close the VI.
	    </item>
	  </list>
	</section>
	<section id="section6">
	  <name>Optional</name>
	  <para id="para2">
	    Customize the waveform chart as shown in <cnxn target="f3"/>. You can display a plot legend, a scale legend,
	    a graph palette, a digital display, and a scrollbar. By
	    default, a <code>waveform chart</code> displays the plot
	    legend.
	  </para>
	  <figure id="f3">
	    <media type="image/png" src="temprunavgfp.png"/>
	  </figure>
	  <list id="list8" type="enumerated">
	    <item>
	      Customize the y-axis.
	      <list id="list9" type="enumerated">
		<item>
		  <media type="image/png" src="labeling.png"/>
		  Use the <code>Labeling</code> tool to double-click
		  <m:math> <m:cn>70.0</m:cn> </m:math> in the y-axis, type
		  <m:math> <m:cn>75.0</m:cn> </m:math>, and press the
		  <code>&lt;Enter&gt;</code> key.
		</item>
		<item>
		  <name>b</name>
		  <!--needs to be corrected, should be a seperate paragraph-->
		  Use the <code>Labeling</code> tool to double-click the
		  second number from the bottom on the y-axis, type
		  <m:math><m:cn>80.0</m:cn> </m:math>, and press the
		  <code>&lt;Enter&gt;</code> key. This number determines the
		  numerical spacing of the y-axis divisions.
		  <!--different para-->
		  For example, if the number above <m:math>
		    <m:cn>75.0</m:cn> </m:math> is <m:math>
		    <m:cn>77.5</m:cn> </m:math>, it indicates a y-axis
		  division of <m:math> <m:cn>2.5</m:cn> </m:math>,
		  changing the <m:math> <m:cn>77.5</m:cn> </m:math> to
		  <m:math> <m:cn>80.0</m:cn> </m:math> reformats the
		  y-axis to multiples of <m:math> <m:cn>5.0</m:cn>
		  </m:math> (<m:math> <m:cn>75.0</m:cn> </m:math>,
		  <m:math> <m:cn>80.0</m:cn> </m:math>, <m:math>
		    <m:cn>85.0</m:cn> </m:math>, and so on).
		</item>
	      </list>
	      <note type="note">
		The <code>waveform chart</code> size has a direct effect
		on the display of axis scales. Increase the <code>waveform
		  chart</code> size if you encounter problems while
		customizing the axis.
	      </note>
	    </item>
	    <item>
	      Right-click the waveform chart and select <code>Visible
		Items&gt;&gt;Scale Legend</code> from the shortcut menu to display
	      the scale legend, as shown in <cnxn target="f4"/>. You can
	      place the scale legend anywhere on the front panel.
	      <figure id="f4">
		<media type="image/png" src="scale.png"/>
		<caption>
		  1. X-axis,
		  2. Y-axis,
		  3. Scale Labels,
		  4. Scale Lock Button,
		  5. Autoscale Button,
		  6. Scale Format Button
		</caption>
	      </figure>
	    </item>
	    <item>
	      Use the scale legend to customize each axis.
	      <list id="list10" type="enumerated">
		<item>      
		  Make sure the <code>Lock Autoscale</code> button appears
		  locked and the <code>Autoscale</code> LED is green so
		  the y-axis adjusts the minimum and maximum values to fit
		  the data in the chart.
		</item>
		<item>
		  Click the <code>Scale Format</code> button to change the
		  format, precision, mapping mode, scale visibility, and
		  grid options for each axis.
		</item>
	      </list>
	    </item>
	    <item>
	      Use the plot legend to customize the plots.
	      <list id="list11" type="enumerated">
		<item>
		  Use the <code>Positioning</code> tool to
		  resize the plot legend to include two plots.
		</item>
		<item> 
		  Use the <code>Labeling</code> tool to change
		  <code>Temp</code> to <code>Running Avg</code> and to
		  change <code>Plot 1</code> to <code>Current
		    Temp</code>. If the text does not fit, use the
		  Positioning tool to resize the plot legend.
		</item>
		<item> 
		  Right-click the plot in the plot legend to set the line
		  and point styles and the color of the plot background or
		  traces.
		</item>
	      </list>
	    </item>
	    <item>
	      <!--needs to be corrected, should be a seperate paragraph-->
	      Right-click the <code>waveform chart</code> and select
	      <code>Visible Items&gt;&gt;Graph Palette</code> from the shortcut
	      menu to display the graph palette, as shown in <cnxn target="f5"/>. You can place the graph palette anywhere on
	      the front panel.
	      <figure id="f5">
		<media type="image/png" src="graphpal.png"/>
		<caption>
		  1. Cursor Movement Tool,
		  2. Zoom Button,
		  3. Panning Tool,
		  4. Zoom Pull-down Menu
		</caption>
	      </figure>
	      <!--different para-->
	      Use the <code>Zoom</code> button on the graph palette to
	      zoom in or out of sections of the chart or the whole
	      chart. Use the <code>Panning</code> tool to pick up the plot
	      and move it around on the display. Use the <code>Cursor
		Movement</code> tool to move the cursor on the graph.
	    </item>
	    <item>
	      Run the VI. While the VI runs, use the buttons in the scale
	      legend and graph palette to modify the <code>waveform
		chart</code>.
	      <note type="note">
		If you modify the axis labels, the display might become
		larger than the maximum size that the VI can correctly
		present.
	      </note>
	    </item>
	    <item>
	      Use the <code>Operating</code> tool to click the
	      <code>Power</code> switch and stop the VI.
	    </item>
	    <item>
	      Save and close the VI.
	    </item>
	  </list>
	</section>
      </problem>
    </exercise>
  </content>
</document>
