Differences

This shows you the differences between two versions of the page.

Link to this comparison view

products:ardx:circ-10 [2012/03/14 04:58] (current)
Line 1: Line 1:
  
 +<html>
 +<div id="CIRC-head">
 +<div id="CIRC-100"><table height="100px" width="100px" valign="center"><tr><td><span class="headText"><center>CIRC<br>10</center></span></td></tr></table></div>
 +<div id="CIRC-465"><table height="100px" width="465px" valign="center"><tr><td><span class="subText"><center>.:Temperature:.<br>.:TMP36 Precision Temperature Sensor:. </center></span></td></tr></table></div>
 +<div id="CIRC-100"><img src="http://www.ardx.org/src/circ/CIRC-10-square-100.jpg" width="100" height="100"></div>
 +</div>
 +<span class="familyName"><center>(ARDX)   .:Arduino Expermentation Kit:.   (ARDX)</center></span>
 +<div id="CIRC-whitespace"></div>
 +<div id="CIRC-body">
 +<div id="CIRC-whitespace"></div><br>
 +<div id="CIRC-whatweredoing">
 +<span class="titleText">What We're Doing</span><br>
 +<span class="regularText">What's the next phenomena we will measure with our Arduino? Temperature. To do this we'll use a rather complicated IC (integrated circuit) hidden in a package identical to our P2N2222AG transistors. It has three pin's, ground, signal and +5 volts, and is easy to use. It outputs 10 millivolts per degree centigrade on the signal pin (to allow measuring temperatures below freezing there is a 500 mV offset eg. 25 degrees C = 750 mV, 0 degrees C = 500mV). To convert this from the digital value to degrees, we will use some of the Arduino's math abilities. Then to display it we'll use one of the IDE's rather powerful features, the debug window. We'll output the value over a serial connection to display on the screen. Let's get to it.<br><br>One extra note, this circuit uses the Arduino IDE's serial monitor. To open this, first upload the program then click the button which looks like a square with an antennae.<br><br>The TMP36 Datasheet:<br><a href="http://ardx.org/TMP36 ">http://ardx.org/TMP36 </a></span>
 +</div><br>
 +<div id="CIRC-whitespace"></div><br>
 +<div id="CIRC-thecircuit">
 +<span class="titleText">The Circuit</span><br>
 +<div id="CIRC-thepartsSideSpacer">
 +</div>
 +        <div id="CIRC-theparts">
 +          <span class="smallTitleText">The Parts</span><br>
 +          <span class="regularText">
 +<table>
 +<tr>
 +<td>
 +<img src="http://www.oomlout.com/parts/CIRC-01-3dsheet-60.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +CIRC-10<br>Breadboard Sheet <br>x1
 +</span>
 +</td>
 +<td>
 +<img src="http://www.oomlout.com/parts/HEAD-02-60.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +2 Pin Header<br>x4
 +</span>
 +</td>
 +<td>
 +<img src="http://www.oomlout.com/parts/IC-TMP36-60.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +TMP36<br>Temperature Sensor <br>x1
 +</span>
 +</td>
 +<td>
 +
 +<img src="http://www.oomlout.com/parts/WIRE-01-60.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +Wire
 +</span>
 +</td>
 +</tr>
 +
 +<tr>
 +<td>
 +<img src="http://www.oomlout.com/parts/BLANK.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +
 +</span>
 +</td>
 +<td>
 +<img src="http://www.oomlout.com/parts/BLANK.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +
 +</span>
 +</td>
 +<td>
 +<img src="http://www.oomlout.com/parts/BLANK.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +
 +</span>
 +</td>
 +<td>
 +
 +<img src="http://www.oomlout.com/parts/BLANK.png" width="60px" height="36px">
 +</td>
 +<td>
 +<span class="partsText">
 +
 +</span>
 +</td>
 +</tr>
 +</table>
 +</span>
 +        </div><br>
 +        <div id="CIRC-whitespace"></div><br>
 +        <div id="CIRC-thepartsSideSpacer"></div>
 +          <div id="CIRC-circuitBox">
 +            <div id="CIRC-schematic"><center><span class="smallTitleText">Schematic</span><span class="smallTitleText"><img src="http://www.ardx.org/src/circ/ARDX-SC-10-150.png"></span></center></div>
 + <br>
 + <div id="CIRC-smallwhitespace">&nbsp;</div><br>
 +            <div id="CIRC-resources">
 + <center><span class="smallTitleText">Resources</span><br><span class="smallMediumDarkText"><b>.:download:.</b><br>breadboard layout sheet<br><b><a href="http://ardx.org/BBLS10">http://ardx.org/BBLS10</a></b><br><br><b>.:view:.</b><br>assembly video <b><br><a href="http://ardx.org/VIDE10">http://ardx.org/VIDE10</a></b></span></center>
 +            </div>
 +          </div>
 +        <div id="CIRC-circuitPicture">
 +          <center>
 +            <img src="http://www.ardx.org/src/circ/CIRC10-3dexploded-445.png" width="445">
 +          </center>
 +        </div>
 +      </div><br>
 +      <div id="CIRC-whitespace">&nbsp;</div><br>
 +<div id="CIRC-thecode">
 +        <span class="titleText">Code</span> <span class="smallDarkText">(no need to type everything in just)</span><br>
 +        <span class="mediumDarkText">Download the Code from ( <a href="http://ardx.org/CODE10 ">http://ardx.org/CODE10 </a>)<br>(copy the text and paste it into an empty Arduino Sketch) </span><br>
 +        <span class="code">        <prew>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;<br>
 +&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;Arduino&nbsp;Experimentation&nbsp;Kit&nbsp;Example&nbsp;Code&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<br>
 +&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;CIRC&#45;10&nbsp;.:&nbsp;Temperature&nbsp;:.&nbsp;(TMP36&nbsp;Temperature&nbsp;Sensor)&nbsp;|<br>
 +&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;<br>
 +&nbsp;*&nbsp;&nbsp;&nbsp;<br>
 +&nbsp;*&nbsp;&nbsp;A&nbsp;simple&nbsp;program&nbsp;to&nbsp;output&nbsp;the&nbsp;current&nbsp;temperature&nbsp;to&nbsp;the&nbsp;IDE's&nbsp;debug&nbsp;window&nbsp;<br>
 +&nbsp;*&nbsp;<br>
 +&nbsp;*&nbsp;&nbsp;For&nbsp;more&nbsp;details&nbsp;on&nbsp;this&nbsp;circuit:&nbsp;http://tinyurl.com/c89tvd&nbsp;<br>
 +&nbsp;*/<br>
 +<br>
 +//TMP36&nbsp;Pin&nbsp;Variables<br>
 +int&nbsp;temperaturePin&nbsp;=&nbsp;0;&nbsp;//the&nbsp;analog&nbsp;pin&nbsp;the&nbsp;TMP36's&nbsp;Vout&nbsp;(sense)&nbsp;pin&nbsp;is&nbsp;connected&nbsp;to<br>
 +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//the&nbsp;resolution&nbsp;is&nbsp;10&nbsp;mV&nbsp;/&nbsp;degree&nbsp;centigrade&nbsp;<br>
 +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//(500&nbsp;mV&nbsp;offset)&nbsp;to&nbsp;make&nbsp;negative&nbsp;temperatures&nbsp;an&nbsp;option<br>
 +<br>
 +/*<br>
 +&nbsp;*&nbsp;setup()&nbsp;&#45;&nbsp;this&nbsp;function&nbsp;runs&nbsp;once&nbsp;when&nbsp;you&nbsp;turn&nbsp;your&nbsp;Arduino&nbsp;on<br>
 +&nbsp;*&nbsp;We&nbsp;initialize&nbsp;the&nbsp;serial&nbsp;connection&nbsp;with&nbsp;the&nbsp;computer<br>
 +&nbsp;*/<br>
 +void&nbsp;setup()<br>
 +{<br>
 +&nbsp;&nbsp;Serial.begin(9600);&nbsp;&nbsp;//Start&nbsp;the&nbsp;serial&nbsp;connection&nbsp;with&nbsp;the&nbsp;copmuter<br>
 +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//to&nbsp;view&nbsp;the&nbsp;result&nbsp;open&nbsp;the&nbsp;serial&nbsp;monitor&nbsp;<br>
 +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//last&nbsp;button&nbsp;beneath&nbsp;the&nbsp;file&nbsp;bar&nbsp;(looks&nbsp;like&nbsp;a&nbsp;box&nbsp;with&nbsp;an&nbsp;antenae)<br>
 +}<br>
 +&nbsp;<br>
 +void&nbsp;loop()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;run&nbsp;over&nbsp;and&nbsp;over&nbsp;again<br>
 +{<br>
 +&nbsp;float&nbsp;temperature&nbsp;=&nbsp;getVoltage(temperaturePin);&nbsp;&nbsp;//getting&nbsp;the&nbsp;voltage&nbsp;reading&nbsp;from&nbsp;the&nbsp;tem<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//perature&nbsp;sensor<br>
 +&nbsp;temperature&nbsp;=&nbsp;(temperature&nbsp;&#45;&nbsp;.5)&nbsp;*&nbsp;100;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//converting&nbsp;from&nbsp;10&nbsp;mv&nbsp;per&nbsp;degree&nbsp;wit&nbsp;500<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;mV&nbsp;offset<br>
 +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//to&nbsp;degrees&nbsp;((volatge&nbsp;&#45;&nbsp;500mV)&nbsp;times&nbsp;100)<br>
 +&nbsp;Serial.println(temperature);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//printing&nbsp;the&nbsp;result<br>
 +&nbsp;delay(1000);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//waiting&nbsp;a&nbsp;second<br>
 +}<br>
 +<br>
 +/*<br>
 +&nbsp;*&nbsp;getVoltage()&nbsp;&#45;&nbsp;returns&nbsp;the&nbsp;voltage&nbsp;on&nbsp;the&nbsp;analog&nbsp;input&nbsp;defined&nbsp;by<br>
 +&nbsp;*&nbsp;pin<br>
 +&nbsp;*/<br>
 +float&nbsp;getVoltage(int&nbsp;pin){<br>
 +&nbsp;return&nbsp;(analogRead(pin)&nbsp;*&nbsp;.004882814);&nbsp;//converting&nbsp;from&nbsp;a&nbsp;0&nbsp;to&nbsp;1023&nbsp;digital&nbsp;range<br>
 +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;to&nbsp;0&nbsp;to&nbsp;5&nbsp;volts&nbsp;(each&nbsp;1&nbsp;reading&nbsp;equals&nbsp;~&nbsp;5&nbsp;milliv<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//olts<br>
 +}<br>
 +<br>
 +        </prew></span>
 +      </div>
 +      <div id="CIRC-whitespace">&nbsp;</div><br>
 +<div id="CIRC-notWorking">
 +        <span class="titleText">Not Working?</span> <span class="smallDarkText">(3 things to try)</span>
 + <br><div id="CIRC-smallwhitespace">&nbsp;</div><br>
 + <div>
 +        <div id="CIRC-thepartsSideSpacer">&nbsp;</div>
 +        <div id="CIRC-nw1"><center><span class="regularText"><b>Nothing Seems to Happen</b></span><br><span class="regularText">This program has no outward indication it is working. To see the results you must open the Arduino IDE's serial monitor.<br>(instructions on previous page) </span></center></div>
 +        <div id="CIRC-thepartsSideSpacer">&nbsp;</div>
 +        <div id="CIRC-nw2"><center><span class="regularText"><b>Gibberish is Displayed</b></span><br><span class="regularText">This happens because the serial monitor is receiving data at a different speed than expected. To fix this, click the pull-down box that reads "*** baud" and change it to "9600 baud".</span></center></div>
 +        <div id="CIRC-thepartsSideSpacer">&nbsp;</div>
 +        <div id="CIRC-nw3"><center><span class="regularText"><b>Temperature Value is Unchanging </b></span><br><span class="regularText">Try pinching the sensor with your fingers to heat it up or pressing a bag of ice against it to cool it down.</span></center></div>
 +        <div id="CIRC-thepartsSideSpacer">&nbsp;</div>
 +</div></div>
 +<div id="CIRC-whitespace">&nbsp;</div><br>
 +<div id="CIRC-makingBetter">
 +<span class="titleText">Making it Better?</span><br>&nbsp;<br>
 +<span class="regularText"><b>Outputting voltage:</b> <BR>This is a simple matter of changing one line. Our sensor outputs 10mv per degree centigrade so to get voltage we simply display the result of <span class="bigCode">getVoltage()</span>. <BR>&nbsp; <BR>delete the line   <span class="bigCode">temperature = (temperature - .5) * 100; </span> <BR>&nbsp; <BR><b>Outputting degrees Fahrenheit:</b> <BR>Again this is a simple change requiring only math. to go degrees C ----> degrees F we use the formula.  <BR>&nbsp;&nbsp;&nbsp;&nbsp;<span class="bigCode">( F = C * 1.8) +  32 )  </span> <BR>add the line   <BR>&nbsp;&nbsp;&nbsp;&nbsp;<span class="bigCode">temperature = (((temperature - .5) * 100)*1.8) + 32; </span> <BR>&nbsp;&nbsp;&nbsp;&nbsp;before <span class="bigCode">Serial.println(temperature);</span> <BR>&nbsp; <BR><b>More informative output:</b> <BR>Lets add a message to the serial output to make what is appearing in the Serial Monitor more informative. To do this first revert to the original code then change: <BR>&nbsp;&nbsp;<span class="bigCode">Serial.println(temperature); ----> Serial.print(temperature); </span> <BR>&nbsp;&nbsp;Serial.println(" degrees centigrade"); <BR>The change to the first line means when we next output it will appear on the same line, then we add the informative text and a new line. <BR>&nbsp; <BR><b>Changing the serial speed:</b> <BR>If you ever wish to output a lot of data over the serial line time is of the essence. We are currently transmitting at 9600 baud but much faster speeds are possible. To change this change the line: <BR>&nbsp;&nbsp;<span class="bigCode">Serial.begin(9600); ----> Serial.begin(115200);</span> <BR>Upload the sketch turn on the serial monitor, then change the speed from 9600 baud to 115200 baud in the pull down menu. You are now transmitting data 12 times faster. <BR>
 +</span></html>