This repository has been archived on 2024-09-22. You can view files and clone it, but cannot push or open issues or pull requests.
pbi-ide/help/BasicStampHelp/Content/LanguageTopics/Commands/PULSIN.htm

136 lines
7.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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>PULSIN</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">PULSIN</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/PulsinEx.htm" target="" title="" alt="" class="MCXref_0">PULSIN Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">PULSIN</span> <![CDATA[ ]]><i>Pin</i>,<i> State</i>,<i> Variable</i></p>
<h2>Function</h2>
<p class="PlainText">Measure the width of a pulse on <i>Pin</i> described by <i>State</i> and store the
result in <i>Variable</i>.
</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression* (0 - 15) that specifies
the I/O pin to use. This pin will be set to input mode.</li>
<li value="2"><b><i>State</i></b> is a variable/constant/expression* (0 - 1) that specifies
whether the pulse to be measured is low (0) or high (1). A low pulse begins
with a 1-to-0 transition and a high pulse begins with a 0-to-1 transition.</li>
<li value="3"><b><i>Variable</i></b> is a variable (usually a word) in which the measured
pulse duration will be stored. The unit of time for <i>Variable</i> is
described below.</li>
</ul>
<p class="PlainText">*<img src="../../graphics/bs1note.gif" style="vertical-align: super;" /> Note: expressions are not allowed as arguments on the BS1. The range
of the <i>Pin</i> argument on the BS1 is 07.</p>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr align="center" bgcolor="#CFCFCF">
<td width="16%">&#160;</td>
<td width="12%">BS1</td>
<td width="12%">BS2</td>
<td width="12%">BS2e</td>
<td width="12%">BS2sx</td>
<td width="12%">BS2p</td>
<td width="12%">BS2pe</td>
<td width="12%">BS2px</td>
</tr>
<tr align="center">
<td bgcolor="#CFCFCF">Units in <i>Variable</i></td>
<td>10 µs</td>
<td>2 µs</td>
<td>2 µs</td>
<td>0.8 µs</td>
<td>0.75 µs</td>
<td>2 µs</td>
<td>0.81 µs</td>
</tr>
<tr align="center">
<td align="center" bgcolor="#CFCFCF">Maximum pulse width</td>
<td>655.35 ms</td>
<td>131.07 ms</td>
<td>131.07 ms</td>
<td>52.428 ms</td>
<td>49.151 ms</td>
<td>123.6 ms</td>
<td>53.08 ms</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="7">
<p colspan="7" align="center"><a href="PULSOUT.htm" target="" title="" alt="" class="MCXref_0">PULSOUT</a>, <a href="COUNT.htm" target="" title="" alt="" class="MCXref_0">COUNT</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">PULSIN</span> is like a fast stopwatch that is triggered by a change in state
(0 or 1) on the specified pin. The entire width of the specified pulse (high or
low) is measured, in units shown above and stored in <i>Variable</i>. </p>
<p class="PlainText">Many analog properties (voltage, resistance, capacitance, frequency, duty cycle)
can be measured in terms of pulse duration. This makes <span class="keyword_in_text">PULSIN</span> a valuable
form of analog-to-digital conversion. </p>
<p class="PlainText"><span class="keyword_in_text">PULSIN</span> will wait for the desired pulse, for up to the maximum pulse
width it can measure, shown in the table above. If it sees the desired pulse it
measures the time until the end of the pulse and stores the result in <i>Variable</i>.
If it never sees the start of the pulse, or the pulse is too long (greater than
the Maximum Pulse Width shown above), <span class="keyword_in_text">PULSIN</span> "times out" and store 0 in
<i>Variable</i>. This operation keeps your program from locking-up should the
desired pulse never occur.</p>
<p class="PlainText">Regardless of the size of <i>Variable</i>, <span class="keyword_in_text">PULSIN</span> internally uses a
16-bit timer. Unless the pulse widths are known to be short enough to fit in an
8-bit result, it is recommended using a word-sized variable. Not doing so may
result in strange and misleading results as the BASIC Stamp will only store the
lower 8-bits into a byte variable. </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 ©&#160;<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>