194 lines
11 KiB
HTML
194 lines
11 KiB
HTML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
|
<head><title>NAP</title>
|
|
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
|
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
|
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h1 class="code">NAP</h1>
|
|
<div class="ImagePlusCaption">
|
|
<div class="Col2">
|
|
<p>
|
|
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
|
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
|
|
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
|
|
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
|
|
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
|
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
|
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
|
</p>
|
|
</div>
|
|
<p style="text-align: right;"><a href="../ExampleTopics/NapEx.htm" target="" title="" alt="" class="MCXref_0">NAP Example</a>
|
|
</p>
|
|
<p> </p>
|
|
</div>
|
|
<p class="clear"> </p>
|
|
<p> </p>
|
|
<p class="PlainText">Syntax: <span class="keyword_in_text">NAP</span> <![CDATA[ ]]><i>Duration</i></p>
|
|
<h2>Function</h2>
|
|
<p class="PlainText">Enter sleep mode for a short time. Power consumption is reduced as indicated in
|
|
the table below assuming no loads are being driven.
|
|
|
|
</p>
|
|
<ul>
|
|
<li value="1"><b><i>Duration</i></b> is a variable/constant/expression* (0 - 7) that
|
|
specifies the duration of the reduced-power "nap." The low-power duration is
|
|
2<sup style="font-style: italic;">Duration</sup> x 18 milliseconds.</li>
|
|
</ul>
|
|
<p class="PlainText">*<img src="../../graphics/bs1note.gif" style="vertical-align: super;" /> Note: expressions are not allowed as arguments on the BS1.</p>
|
|
<h2>Quick Facts</h2>
|
|
<table width="100%" cellpadding="4" cellspacing="0" border="1">
|
|
<tr align="center" bgcolor="#CFCFCF">
|
|
<td width="23%"> </td>
|
|
<td width="11%">BS1</td>
|
|
<td width="11%">BS2</td>
|
|
<td width="11%">BS2e</td>
|
|
<td width="11%">BS2sx</td>
|
|
<td width="11%">BS2p</td>
|
|
<td width="11%">BS2pe</td>
|
|
<td width="11%">BS2px</td>
|
|
</tr>
|
|
<tr align="center">
|
|
<td bgcolor="#CFCFCF">Current Draw during Run</td>
|
|
<td>1 mA</td>
|
|
<td>3 mA</td>
|
|
<td>25 mA</td>
|
|
<td>60 mA</td>
|
|
<td>40 mA</td>
|
|
<td>15 mA</td>
|
|
<td>55 mA</td>
|
|
</tr>
|
|
<tr align="center">
|
|
<td bgcolor="#CFCFCF">Current Draw during <span class="keyword_in_text">NAP</span></td>
|
|
<td>25 µA</td>
|
|
<td>50 µA</td>
|
|
<td>200 µA</td>
|
|
<td>500 µA</td>
|
|
<td>350 µA</td>
|
|
<td>36 µA</td>
|
|
<td>450 µA</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
|
|
<td align="center" colspan="4">
|
|
<p colspan="4" align="center"><a href="END.htm" target="" title="" alt="" class="MCXref_0">END</a>, <a href="SLEEP.htm" target="" title="" alt="" class="MCXref_0">SLEEP</a></p>
|
|
</td>
|
|
<td align="center" colspan="3">
|
|
<p colspan="3" align="center"><a href="END.htm" target="" title="" alt="" class="MCXref_0">END</a>, <a href="SLEEP.htm" target="" title="" alt="" class="MCXref_0">SLEEP</a>, <a href="POLLWAIT.htm" target="" title="" alt="" class="MCXref_0">POLLWAIT</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr align="center">
|
|
<td bgcolor="#CFCFCF">Accuracy of <span class="keyword_in_text">NAP</span></td>
|
|
<td colspan="7">-50 to 100% (±10% @ 75°F with stable power supply)</td>
|
|
</tr>
|
|
</table>
|
|
<h2>Explanation</h2>
|
|
<p class="PlainText"><span class="keyword_in_text">NAP</span> uses the same shutdown/startup mechanism as <span class="keyword_in_text">SLEEP</span>, with one big
|
|
difference. During <span class="keyword_in_text">SLEEP</span>, the BASIC Stamp automatically compensates for
|
|
variations in the speed of the watchdog timer oscillator that serves as its alarm
|
|
clock. As a result, longer <span class="keyword_in_text">SLEEP</span> intervals are accurate to approximately
|
|
±1 percent.</p>
|
|
<center>
|
|
<table cellpadding="4" cellspacing="0" border="1">
|
|
<col style="width: 63px;" />
|
|
<col />
|
|
<tr align="center" bgcolor="#CFCFCF">
|
|
<td><i>Duration</i>
|
|
</td>
|
|
<td width="165">Length of <span class="keyword_in_text">NAP</span></td>
|
|
</tr>
|
|
<tr align="center">
|
|
<td>0</td>
|
|
<td>18 ms</td>
|
|
</tr>
|
|
<tr align="center">
|
|
<td>1</td>
|
|
<td>36 ms</td>
|
|
</tr>
|
|
<tr align="center">
|
|
<td>2</td>
|
|
<td>72 ms</td>
|
|
</tr>
|
|
<tr align="center">
|
|
<td>3</td>
|
|
<td>144 ms</td>
|
|
</tr>
|
|
<tr align="center">
|
|
<td>4</td>
|
|
<td>288 ms</td>
|
|
</tr>
|
|
<tr align="center">
|
|
<td>5</td>
|
|
<td>576 ms</td>
|
|
</tr>
|
|
<tr align="center">
|
|
<td>6</td>
|
|
<td>1152 ms (1.152 seconds)</td>
|
|
</tr>
|
|
<tr align="center">
|
|
<td>7</td>
|
|
<td>2304 ms (2.304 seconds)</td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
<p> </p>
|
|
<p class="PlainText"><span class="keyword_in_text">NAP</span> intervals are directly controlled by the watchdog timer without
|
|
compensation. Variations in temperature, supply voltage, and manufacturing
|
|
tolerance of the BASIC Stamp's interpreter chip can cause the actual timing to
|
|
vary by as much as -50, +100 percent (i.e., a <i>Duration</i> of 0, <span class="keyword_in_text">NAP</span> can range
|
|
from 9 to 36 ms). At room temperature with a fresh battery or other stable power
|
|
supply, variations in the length of a <span class="keyword_in_text">NAP</span> will be less than ±10 percent. </p>
|
|
<p class="PlainText">One great use for <span class="keyword_in_text">NAP</span> is in a battery-powered application where at least
|
|
some small amount of time is spent doing nothing. For example, you may have a
|
|
program that loops endlessly, performing some task, and pausing for approximately
|
|
100 ms each time through the loop. You could replace your <span class="code_in_text">PAUSE 100</span> with
|
|
<span class="code_in_text">NAP 3</span>, as long as the timing of the 100 ms pause was not critical. The
|
|
<span class="code_in_text">NAP 3</span> would effectively pause your program for about 144 milliseconds and,
|
|
at the same time, would place the BASIC Stamp in low-power mode, which would extend
|
|
your battery life.</p>
|
|
<p class="PlainText">During execution of power conserving commands (<span class="keyword_in_text">END</span>, <span class="keyword_in_text">NAP</span>, <span class="keyword_in_text">POLLWAIT</span>, and <span class="keyword_in_text">SLEEP</span>), current will occasionally be interrupted
|
|
on I/O pins for about 18 ms durations (60 µs on the BS2pe). The reason is that the
|
|
watchdog-timer reset that awakens the BASIC Stamp during these commands also causes all of the pins to
|
|
switch to input mode for approximately 18 ms (60 µs on the BS2pe). When the interpreter
|
|
firmware regains control of the processor, it restores the I/O direction dictated
|
|
by your program.</p>
|
|
<p class="PlainText">If you plan to use <span class="keyword_in_text">END</span>, <span class="keyword_in_text">NAP</span>, <span class="keyword_in_text">POLLWAIT</span>, or <span class="keyword_in_text">SLEEP</span> in your programs,
|
|
make sure that your loads can tolerate these power outages. The simplest solution
|
|
is often to connect resistors high or low (to +5V or ground) as appropriate to
|
|
ensure a continuing supply of current during the reset. </p>
|
|
<p class="PlainText">The example program can be used to demonstrate the effects
|
|
of the <span class="keyword_in_text">NAP</span> reset with an LED and resistor.</p>
|
|
<div class="Col2">
|
|
<div class="MasterFoot">
|
|
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="Col2">
|
|
<div class="MasterFoot">
|
|
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
|
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
|
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">/* <![CDATA[ */
|
|
|
|
var _gaq = _gaq || [];
|
|
_gaq.push(['_setAccount', 'UA-285614-1']);
|
|
_gaq.push(['_trackPageview']);
|
|
|
|
(function() {
|
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
})();
|
|
|
|
/* ]]> */</script>
|
|
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
|
</script>
|
|
</body>
|
|
</html> |