<?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>Square Root VI</name>
  <metadata>
  <md:version>1.1</md:version>
  <md:created>2004/06/23 14:56:36 GMT-5</md:created>
  <md:revised>2004/07/16 15:19:49.791 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 use the Case structure in a VI. Complete the following steps to build a VI that checks whether a number is positive. If the number is positive, the VI calculates the square root of the number. Otherwise, the VI returns an error message.
</md:abstract>
</metadata>
  <!--When CNXML 0.6 comes out, this module will need to be revised to
  include para in the items indicated.-->
  <content>
    <exercise id="e1">
      <problem>
	<section id="s1">
	  <name>Front Panel</name>
	  <list id="s1l1" type="enumerated">
	    <item>
	      Open a blank VI and build the front panel shown in <cnxn target="s1l1f1"/>.
	      <figure id="s1l1f1">
		<media type="image/png" src="squareroot.png"/>
	      </figure>
	    </item>
	  </list>
	</section>
	<section id="s2">
	  <name>Block Diagram</name>
	  <list id="s2l1" type="enumerated">
	    <item>
	      Build the block diagram shown in <cnxn target="s2l1f1"/>.
	      <figure id="s2l1f1">
		<media type="image/png" src="squarerootbd.png"/>
	      </figure>
	      <list id="s2l1l1" type="enumerated">
		<item>
		    <media type="image/png" src="case.png"/>
		  Place the <code>Case</code>
		  structure, located on the <code>Functions&gt;&gt;Execution
		  Control</code> palette, on the block diagram. Click
		  the <code>decrement</code> or <code>increment</code>
		  button to select the <code>False</code> case.
		</item>
		<item>
		    <media type="image/png" src="greateq0icon.png"/>
		  Place the <code>Greater or Equal
		  to 0?</code> function, located on the
		  <code>Functions&gt;&gt;Arithmetic &amp;
		  Comparison&gt;&gt;Express Comparison</code> palette, on
		  the block diagram. This function returns
		  <code>True</code> if <code>Number</code> is greater
		  than or equal to <code>0</code>.
		</item>
		<item>
		    <media type="image/png" src="numconstSR.png"/>
		  Right-click the <code>numeric
		  constant</code> and select <code>Properties</code>
		  from the shortcut menu. Select the <code>Format and
		  Precision</code> tab. Set <code>Digits of
		  precision</code> to <code>1</code>, select
		  <code>Floating point notation</code>, and click the
		  <code>OK</code> button to ensure there is no data
		  conversion between the constant and the numeric
		  indicator outside the <code>Case</code> structure.
		</item>
		<item>
		    <media type="image/png" src="onebutdialogicon.png"/>
		  Place the <code>One Button
		  Dialog</code> function, located on the
		  <code>Functions&gt;&gt; All Functions&gt;&gt;Time &amp;
		  Dialog</code> palette, on the block diagram. This
		  function displays a dialog box that contains the
		  message <code>Error...Negative Number</code>.
		</item>
		<item>
		    <media type="image/png" src="strconst.png"/>
		  Right-click the <code>message</code> terminal of the
		  <code>One Button Dialog</code> function, select
		  <code>Create&gt;&gt;Constant</code> from the shortcut
		  menu, type <code>Error...Negative Number</code> in
		  the constant, and click the <code>Enter</code>
		  button on the toolbar or click outside the
		  control. Refer to the lesson on <cnxn document="m12252">Strings and File I/O</cnxn> for more
		  information about strings.
		</item>
		<item>
		  Complete the diagram as shown in <cnxn target="s2l1f1"/>.
		</item>
	      </list>
	    </item>
	    <item><!--needs para--> 
	      <!--para--> 
	      Select the <code>True</code> case of the
	      <code>Case</code> structure.
	      <!--para-->
		<media type="image/png" src="sqrticon.png"/>
	      Place the <code>Square Root</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 square root of
	      <code>Number</code>. Wire the function as shown in <cnxn target="s2l1f3"/>.
	      <figure id="s2l1f3">
		<media type="image/png" src="squareroot2bd.png"/>
	      </figure>
	    </item>
	    <item>
	      Save the VI as <code>Square Root.vi</code> in the
	      <code>C:\Exercises\LabVIEW Basics I</code> directory.
	    </item>
	  </list>
	</section>
	<section id="s3">
	  <name>Run the VI</name>
	  <list id="s3l1" type="enumerated">
	    <item>
	      Display the front panel and run the VI.
	      <note type="caution">
		Do not run this VI continuously. Under certain
		circumstances, continuously running this VI could
		result in an endless loop.
	      </note>
	      If <code>Number</code> is positive, the VI executes the
	      <code>True</code> case and returns the square root of
	      <code>Number</code>. If <code>Number</code> is negative,
	      the VI executes the <code>False</code> case, returns
	      <code>-99999</code>, and displays a dialog box with the
	      message <code>Error...Negative Number</code>.
	    </item>
	    <item>
	      Close the VI.
	    </item>
	  </list>
	</section>
      </problem>
    </exercise>
		

  </content>
  
</document>
