<?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 Logger VI</name>
  <metadata>
  <md:version>1.1</md:version>
  <md:created>2004/06/22 10:42:47 GMT-5</md:created>
  <md:revised>2004/07/16 15:26:55.229 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>VI</md:keyword>
  </md:keywordlist>

  <md:abstract>In this exercise, the objective is to save data to a file in a form that a spreadsheet or a word processor can access. Complete the following steps to build a VI that saves the time and current temperature to a data file.
</md:abstract>
</metadata>
  <!--When CNXML 0.6 arrives, this module will need to be revised to
  include para in the items indicated.-->
  <content>
    <exercise id="e1">
      <problem>
	<section id="s1">
	  <name>Block Diagram</name>
	  <list id="s1l1" type="enumerated">
	    <item>
	      Open the <cnxn document="m12247">Temperature Control VI</cnxn>
	      and save it as <code>Temperature Logger.vi</code> in the
	      <code>C:\Exercises\LabVIEW Basics I</code>
	      directory. You do not need to modify the front panel.
	    </item>
	    <item>
	      Open and modify the block diagram as shown in <cnxn target="s1l1f1"/>. Resize the <code>While Loop</code> to
	      add space at the top for the file I/O operations.
	      <figure id="s1l1f1">
		<media type="image/png" src="templogbd.png"/>
	      </figure>
	      <list id="s1l1l1" type="enumerated">
		<item><!--needs para-->
		    <media type="image/png" src="OpenFileIcon.png"/>
		  <!--para-->
		  Place the <code>Open/Create/Replace File</code>
		  VI, located on the <code>Functions&gt;&gt;All
		  Functions&gt;&gt;File I/O</code> palette, on the block
		  diagram.
		  <!--para-->
		  Right-click the <code>prompt</code> input, select
		  <code>Create Constant</code> from the shortcut menu
		  and type <code>Enter File Name</code> in the
		  constant.
		  <!--para-->
		  Right-click the <code>function</code> input, select
		  <code>Create Constant</code> from the shortcut menu,
		  and click the constant with the <code>Operating</code> tool to
		  select <code>create or replace</code>.
		</item>
		<item><!--needs para-->
		    <media type="image/png" src="gettmdtstrgicon.png"/>
		  <!--para-->
		  Place the <code>Get Date/Time
		  String</code> function, located on the
		  <code>Functions&gt;&gt;All Functions&gt;&gt;Time &amp;
		  Dialog</code> palette, on the block diagram. This
		  function returns the time, in string format, when
		  the temperature measurement was taken.
		  <!--para-->
		  Right-click the <code>want seconds?</code> input,
		  select <code>Create&gt;&gt;Constant</code> from the
		  shortcut menu, and click the constant with the
		  Operating tool to change the constant from
		  <code>False</code> to <code>True</code>. The <code>True</code>
		  Boolean constant sets the function to include
		  seconds in the string.
		</item>
		<item>
		    <media type="image/png" src="BuildIcon.png"/>
		  Place the <code>Build Text</code> Express
		  VI, located on the
		  <code>Functions&gt;&gt;Output</code> palette, on the block
		  diagram. This Express VI converts the inputs to one
		  string. The <code>Configure Build Text</code> dialog
		  box appears.
		  <list id="s1l1l1l1" type="enumerated">
		    <item>
		      Type <code>%tab%%temp%%end%</code> in the
		      <code>Text with Variables in Percents</code>
		      text box to set up three variables; one for the
		      tab constant, one for the temperature and one
		      for the end of line constant. Because time uses
		      the <code>Beginning Text</code> input of the
		      <code>Build Text</code> Express VI, it does not
		      need a variable.
		    </item>
		    <item>
		      Select <code>temp</code> in the <code>Configure
		      Variables</code> section. Select the
		      <code>Number</code> option, and a format of
		      <code>Format fractional number</code>. The
		      <code>tab</code> and <code>end</code> variables
		      do not need to be formatted. You can leave them
		      in the default state.
		    </item>
		    <item>
		      Click the <code>OK</code> button to close the
		      configuration dialog box.
		    </item>
		    <item>
		      Right-click the <code>Build Text Express
		      VI</code> and select <code>View As Icon</code>
		      to conserve block diagram space.
		    </item>
		  </list>
		</item>
		<item>
		      <media type="image/png" src="tabicon.png"/>
		      <media type="image/png" src="eolicon.png"/>
		  Place a <code>Tab
		  constant</code> and an <code>End
		  of Line constant</code>, located on the
		  <code>Functions&gt;&gt;All Functions&gt;&gt;String</code>
		  palette, on the block diagram.
		</item>
		<item>
		    <media type="image/png" src="WriteFileIcon.png"/>
		  Place the <code>Write File</code>
		  function, located on the <code>Functions&gt;&gt;All
		  Functions&gt;&gt;File I/O</code> palette, on the block
		  diagram. This function writes to the file specified
		  by <code>refnum</code>.
		</item>
		<item>
		    <media type="image/png" src="CloseFileIcon.png"/>
		  Place the <code>Close File</code>
		  function, located on the <code>Functions&gt;&gt;All
		  Functions&gt;&gt;File I/O</code> palette, on the block
		  diagram. This function closes the file.
		</item>
		<item>
		    <media type="image/png" src="Error.png"/>
		  Place the <code>Simple Error
		  Handler</code> VI, located on the
		  <code>Functions&gt;&gt;All Functions&gt;&gt;Time &amp;
		  Dialog</code> palette, on the block diagram. This VI
		  checks the error cluster and displays a dialog box
		  if an error occurs.
		</item>
		<item>
		  Complete the block diagram as shown in <cnxn target="s1l1f1"/>.
		</item>
	      </list>
	    </item>
	    <item>
	      Save the VI. You will use this VI later in the course.
	    </item>
	  </list>
	</section>
	<section id="s2">
	  <name>Run the VI</name>
	  <list id="s2l1" type="enumerated">
	    <item>
	      Display the front panel and run the VI. The <code>Enter
	      File Name</code> dialog box appears.
	    </item>
	    <item><!--needs para-->
	      <!--para-->
	      Type <code>temp.txt</code> and click the
	      <code>Save</code> or <code>OK</code> button.
	      <!--para-->
	      The VI creates a file called <code>temp.txt</code>. The
	      VI takes readings every half-second and saves the time
	      and temperature data to a file until you click the
	      <code>Power</code> switch. When the VI finishes, it
	      closes the file.
	    </item>
	    <item>
	      Open a word processor or spreadsheet application, such
	      as (<emphasis>Windows</emphasis>) Notepad or WordPad,
	      (<emphasis>Mac OS</emphasis>) SimpleText, or
	      (<emphasis>UNIX</emphasis>) Text Editor.
	    </item>
	    <item>
	      Open the <code>temp.txt</code> file in the word
	      processing or spreadsheet application. The time appears
	      in the first column, and the temperature data appears in
	      the second column.
	    </item>
	    <item>
	      Exit the word processor or spreadsheet application and
	      return to LabVIEW.
	    </item>
	    <item>
	      If time permits, complete the optional steps. Otherwise,
	      close the VI.
	    </item>
	  </list>
	</section>
	<section id="s3">
	  <name>Optional</name>
	  <para id="s3p1">
	    When using error handling in a VI, the <code>While
	    Loop</code> should stop executing when an error
	    occurs. Complete the following steps to modify the VI so
	    it stops when the user clicks the <code>Power
	    </code>switch or an error occurs.
	  </para>
	  <list id="s3l1" type="enumerated">
	    <item>
	      Edit the block diagram as shown in <cnxn target="s3l1f1"/>.
	      <figure id="s3l1f1">
		<media type="image/png" src="templogoptbd.png"/>
	      </figure>
	      <list id="s3l1l1" type="enumerated">
		<item>
		    <media type="image/png" src="unbundle.png"/>
		  Place the <code>Unbundle by
		  Name</code> function, located on the
		  <code>Functions&gt;&gt;All Functions&gt;&gt;Cluster</code>
		  palette, on the block diagram. This function reads
		  the status output from the error cluster.
		</item>
		<item>
		      <media type="image/png" src="not.png"/>
		      <media type="image/png" src="andicon.png"/>
		  Place the <code>Not</code>
		  function and the <code>And</code> function, located on
		  the <code>Functions&gt;&gt;Arithmetic &amp;
		  Comparison&gt;&gt;Express Boolean</code> palette, on the
		  block diagram. These functions set the conditional
		  terminal to continue while <code>Power</code> is
		  <code>True</code> and no error occurs.
		</item>
	      </list>
	    </item>
	    <item>
	      Save and run the VI. 
	    </item>
	    <item>
	      Test the error handling by deleting the
	      <code>refnum</code> wire between the <code>Write
	      File</code> function and the left border of the
	      <code>While Loop</code>. Right-click the
	      <code>refnum</code> input of <code>Write File</code> and
	      select <code>Create&gt;&gt;Constant</code>.
	    </item>
	    <item>
	      Run the VI again. The VI should wait for a path, then
	      stop immediately with an error. If error handling was
	      not included in this VI, the VI would not report the
	      error until the user stopped the VI.
	    </item>
	    <item>
	      If time permits, complete the challenge
	      steps. Otherwise, close the VI. Do not save changes.
	    </item>
	  </list>
	</section>
	<section id="s4">
	  <name>Challenge</name>
	  <list id="s4l1" type="enumerated">
	    <item>
	      Replace the <code>Build Text Express VI</code> and the
	      <code>Write File</code> function with the <code>Format
	      Into File</code> function.
	    </item>
	    <item>
	      Run the VI.
	    </item>
	    <item>
	      Close the VI. Do not save changes.
	    </item>
	  </list>
	</section>
      </problem>
    </exercise>
	      
		  

		  

  </content>
  
</document>
