Initial commit after migrating repo and assuring the product launches

This commit is contained in:
Johanna Dorothea Reichmann 2019-06-23 14:56:45 +02:00
commit 507f2aedbc
Signed by: transcaffeine
GPG Key ID: 03624C433676E465
889 changed files with 60893 additions and 0 deletions

8
.classpath Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/pbi-core"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/bin/

28
.project Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>pbi-ide</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
pluginProject.extensions=false

23
LICENSE.md Normal file
View File

@ -0,0 +1,23 @@
The MIT License (MIT)
Copyright (c) 2015 Elias Groll, Johanna Reichmann
For further contributers, see CONTRIBUTORS.md
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

17
META-INF/MANIFEST.MF Normal file
View File

@ -0,0 +1,17 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: πBASIC IDE
Bundle-SymbolicName: edu.fichte.pbi.ide;singleton:=true
Bundle-Version: 1.0.0
Bundle-Vendor: FICHTE-GYMNASIUM
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.github.eliasgroll.pbi.interpreter;bundle-version="1.0.0";resolution:=optional,
org.eclipse.e4.ui.model.workbench;bundle-version="1.0.1",
org.eclipse.ui.intro;resolution:=optional,
org.eclipse.ui.editors;resolution:=optional,
org.eclipse.osgi;resolution:=optional,
org.eclipse.jface.text;resolution:=optional
Bundle-ActivationPolicy: lazy
Bundle-Activator: edu.fichte.pbi.ide.Activator

32
PBI-IDE.launch Normal file

File diff suppressed because one or more lines are too long

20
build.properties Normal file
View File

@ -0,0 +1,20 @@
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
splash.bmp,\
help/,\
plugin_customization.ini,\
contexts.xml,\
bin/,\
config/
src.includes = plugin_customization.ini,\
icons/,\
help/,\
contexts.xml,\
bin/,\
splash.bmp,\
config/
jre.compilation.profile = JavaSE-1.7

64
config/ca.cfg Normal file
View File

@ -0,0 +1,64 @@
## This is the configuration of the interpreter's content assistance.
## You can comment something by starting a line with ## .
## You can freely add/remove/modify by adding/removing/modifying a line.
## A line is build like this: keyword->replacement
## You can start the content-assistance by CTRL+SPACE.
## It is only executed if you're at the beginning of a line and if there is no other match with a keyword.
## You can use /CR to define a new line in a replacement.
SOUND -> SOUND port, (freq, time)
SD -> SOUND port, (freq, time)
HIGH -> HIGH port
LOW -> LOW pin
OUTPUT -> OUTPUT port
OP -> OUTPUT port
PAUSE -> PAUSE time
PS -> PAUSE time
GOTO -> GOTO label
JMP -> GOTO label
IF -> IF expr THEN label
END -> END
GOSUB -> GOSUB sub
SUB -> GOSUB sub
RETURN -> RETURN
FOR -> FOR counter = start TO end/CR'some content/CR NEXT
LOOP -> FOR counter = start TO end/CR'some content/CR NEXT
WHILE -> loop:/CRIF expr THEN end/CR'some content/CRGOTO loop/CRend:
DOWHILE -> loop:/CR'some content/CRIF expr THEN loop
NEXT -> NEXT
DEBUG -> DEBUG args
DB -> DEBUG args
DG -> DEBUG args
SAY -> DEBUG args
BREAKPOINT -> BREAKPOINT
BP -> BREAKPOINT
SYMBOL -> SYMBOL ref = var
LOOKUP -> LOOKUP index, (val0, val1)
LU -> LOOKUP index, (val0, val1)
LD -> LOOKDOWN target, (val0, val1)
LOOKDOWN -> LOOKDOWN target, (val0, val1)
POT -> POT pin, scale, var
PULSIN -> PULSIN pin, state, var
PINS -> PINS=%00000000 'ports 76543210
POUT -> PULSOUT pin, duration
PULSOUT -> PULSOUT pin, duration
LET -> LET var = val
= -> LET var = val
INPUT -> INPUT port
IP -> INPUT port
ASSERT -> ASSERT exp
CHECK -> ASSERT exp
ACTIVATEINFO -> ACTIVATEINFO
AI -> ACTIVATEINFO
DI -> DEACTIVATEINFO
DEACTIVATEINFO -> DEACTIVATEINFO
BRANCH -> BRANCH offset, (label0, label1)
NAP -> NAP time
SLEEP -> SLEEP time
EEPROM -> EEPROM location, (val0, val1)
RANDOM -> RANDOM seed
READ -> READ location,var
WRITE -> WRITE location, value
TOGGLE -> TOGGLE port
REVERSE -> REVERSE port
DIRS -> DIRS=%00000000 'ports 76543210

6
config/color.cfg Normal file
View File

@ -0,0 +1,6 @@
## This is the color configuration to change the look and feel of the IDE.
## You can comment by starting a line with ## .
## Do not add/delete a line.
## set the scheme of the console on startup (values: black, blue, white)
console scheme= blue

17
config/set.cfg Normal file
View File

@ -0,0 +1,17 @@
## This is the run configuration of the interpreter.
## You can comment by starting a line with ## .
## Do not delete a line.
## A line is build like this: setting= value
## You can enable/disable a setting by: true/false.
## Slow down the execution speed to the speed of Basic Stamp 1.
emulate 4Mhz= true
## Activate additional information about the commands at the beginning of the execution.
activate info= false
## Deactivate display of warnings.
ignore warnings= false
## Activate display of the parsing-result
print intern composition= false

13
contexts.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<contexts>
<context id="viewer" title="Sample View">
<description>This is the context help for the sample view with a tree viewer. It was generated by a PDE template.</description>
<topic href="/PLUGINS_ROOT/org.eclipse.platform.doc.isv/guide/ua_help_context.htm" label="Context-sensitive help">
<enablement>
<with variable="platform">
<test property="org.eclipse.core.runtime.isBundleInstalled" args="org.eclipse.platform.doc.isv"/>
</with>
</enablement>
</topic>
</context>
</contexts>

Binary file not shown.

View File

@ -0,0 +1,91 @@
<?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="Connection Troubleshooting" 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>FIFO Buffer Settings</title>
<link href="../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js">
</script>
</head>
<body>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="TFAQ.htm">Connection Troubleshooting</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">FIFO Buffer Settings</span>
</div>
<h1>FIFO Buffer Settings</h1>
<p class="PlainText">If you are using a standard serial port connection (not a USB&#160;port with a USB&#160;to serial adapter)&#160;and the <a href="RunIdTest.htm" target="" title="" alt="" class="MCXref_0">Run/Identify Test</a> <![CDATA[ ]]>shows no Device Type, but a "Yes" in the Echo column, or a "Yes" in both the Loopback and Echo columns, like this:</p>
<p>
<img src="../Resources/Images/IDnoDevice.png" />
</p>
<p>&#160;</p>
<p>...you may need to adjust the port's FIFO buffer setting.</p>
<p>&#160;</p>
<ul style="list-style-type: circle;">
<li class="Checklist" value="1">Make note of the COM port number in the row where it displays a "Yes" for Echo. (In this example it is COM5).</li>
<li class="Checklist" value="2">Find that COM&#160;port in Device Manager.</li>
</ul>
<div class="ListIndent">
<div class="MCDropDown">
<div class="MCDropDownHead_0"><a class="MCDropDownHotSpot_0" href="javascript:void(0);" id="MCDropDownHotSpot_2512036703_0" onclick="FMCDropDown( this ); return false;"><img style="border: none;margin-right: 2px;" src="../SkinSupport/DropDownClosed.gif" MadCap:altsrc="../SkinSupport/DropDownOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/DropDownOpen.gif' ); }" class="MCDropDownIcon" />Finding your Ports List in your computer's Device Manager</a>
</div>
<div class="MCDropDownBody" id="MCDropDownBody_2512036703_0" style="display: none;">
<ul style="list-style-type: circle;">
<li value="1"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows 2K<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu &gt; Settings &gt; Control Panel &gt; System &gt; click Hardware Tab &gt; Device Manager... &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
<li value="2"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows XP<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu &gt; right-click My Computer &gt; Properties &gt; click Hardware Tab &gt; Device Manager &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
<li value="3"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows Vista or Windows 7<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu (Windows icon) &gt; right-click Computer &gt; Properties &gt; Device Manager (left pane) &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
</ul>
</div>
</div>
</div>
<ul>
<li class="Checklist" value="1">Right-click on the COM port, and select Properties</li>
</ul>
<p class="PlainTextIndent">
<img src="../Resources/Images/SerComPortProps.png">
</img>
</p>
<ul>
<li class="Checklist" value="1">On the Port Settings tab, click the Advanced button. </li>
<li class="Checklist" value="2">In the Advanced Settings window, un-check the "Use FIFO buffers" box, then click OK.</li>
</ul>
<p>
<img src="../Resources/Images/FifoUncheck.png">
</img>
</p>
<ul>
<li class="Checklist" value="1">Now try the <a href="RunIdTest.htm" target="" title="" alt="" class="MCXref_0">Run/Identify Test</a> again, or try downloading a program to your BASIC&#160;Stamp.</li>
<li class="Checklist" value="2">If this didn't help, <a href="../HomeTopics/Resources.htm#Contact_Parallax" target="" title="" alt="" class="MCXref_0">Contact Parallax</a> Tech Support for assistance.</li>
</ul>
<p>&#160;</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>

View File

@ -0,0 +1,26 @@
<?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="2" MadCap:lastHeight="47" MadCap:lastWidth="579" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" class="TopicPopup" MadCap:PathToHelpSystem="../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
<head><title>Insert the BASIC Stamp module</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>Insert the BASIC Stamp module</h1>
<ul>
<li class="Checklist" value="1">Use the silkscreen pictures that show the three prominent chips on the BASIC Stamp to determine how to orient it before inserting it into its socket. There is also a small semi-circular notch at in the top-center of the BASIC Stamp module that indicates which way is “up.” Match this reference notch to the notch in the socket.</li>
<li class="Checklist" value="2">After correctly orienting the 24-pin BASIC Stamp module, gently insert it into its socket as shown at (1) in the picture below.</li>
<li class="Checklist" value="3">Make sure that each pin is seated in its corresponding socket hole, then apply firm downward pressure with your thumb. The module should sink about ¼ of an inch (~0.6 mm) into the socket, and only the flared portion of each BASIC Stamp leg should be visible above the socket.</li>
<li class="Checklist" value="4">Visually inspect the legs to make sure each pin is in its socket and that no pins are folded underneath the module.</li>
</ul>
<p>&#160;</p>
<p>
<img src="../Resources/Images/InsertBS2.png" />
</p>
<p class="Caution" MadCap:autonum="Caution! &#160;"><span class="autonumber"><span class="TipSpan">Caution! &#160;</span></span>Do not remove the BASIC Stamp module from its socket, unless it needs to be replaced with another module!&#160;&#160;&#160; Every time the BASIC Stamp is removed and re-inserted into the socket, you risk damaging it.&#160; You do not need to remove it for storage.</p>
<script type="text/javascript" src="../SkinSupport/MadCapBodyEnd.js">
</script>
</body>
</html>

View File

@ -0,0 +1,72 @@
<?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>Invalid Port</title>
<link href="../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js">
</script>
</head>
<body>
<h1>Invalid Port</h1>
<p>
<img src="../Resources/Images/IDinvalidPort.png" />
</p>
<ul>
<li class="Checklist" value="1">The port may have been disabled. Right click the port in your Ports list and click Enable.</li>
</ul>
<p class="PlainTextIndent">
<div class="MCDropDown">
<div class="MCDropDownHead_0"><a class="MCDropDownHotSpot_0" href="javascript:void(0);" id="MCDropDownHotSpot_1961910000_0" onclick="FMCDropDown( this ); return false;"><img style="border: none;margin-right: 2px;" src="../SkinSupport/DropDownClosed.gif" MadCap:altsrc="../SkinSupport/DropDownOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/DropDownOpen.gif' ); }" class="MCDropDownIcon" />Finding your Ports List in your computer's Device Manager</a>
</div>
<div class="MCDropDownBody" id="MCDropDownBody_1961910000_0" style="display: none;">
<ul style="list-style-type: circle;">
<li value="1"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows 2K<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu &gt; Settings &gt; Control Panel &gt; System &gt; click Hardware Tab &gt; Device Manager... &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
<li value="2"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows XP<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu &gt; right-click My Computer &gt; Properties &gt; click Hardware Tab &gt; Device Manager &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
<li value="3"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows Vista or Windows 7<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu (Windows icon) &gt; right-click Computer &gt; Properties &gt; Device Manager (left pane) &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
</ul>
</div>
</div>
</p>
<p>&#160;</p>
<p class="PlainTextIndent">
<img src="../Resources/Images/EnablePort.png" />
</p>
<ul>
<li class="Checklist" value="1">If this did not help, <a href="../HomeTopics/Resources.htm#Contact_Parallax" target="" title="" alt="" class="MCXref_0">Contact Parallax</a> Tech Support for assistance.</li>
</ul>
<p>&#160;</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>

View File

@ -0,0 +1,90 @@
<?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="Connection Troubleshooting" 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>Latency Timer Settings</title>
<link href="../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js">
</script>
</head>
<body>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="TFAQ.htm">Connection Troubleshooting</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Latency Timer Settings</span>
</div>
<h1>Latency Timer Settings</h1>
<p>If you are using a BASIC Stamp development board with a USB&#160;connector, or a serial board with a Parallax USB&#160;to Serial Adapter, you may need to adjust your computer's latency timer settings if any of these are true:</p>
<ul>
<li value="1">The <a href="RunIdTest.htm" target="" title="" alt="" class="MCXref_0">Run/Identify Test</a> shows no Device Type, but a "Yes" in both the Loopback and Echo columns, or a "Yes" only in the Echo column.</li>
<li value="2">You have passed the Run/Identify test but when you try to download a program with Run/Run, you get a "No BASIC Stamps Found" message. </li>
<li value="3">You are able to download short programs, but not long ones. </li>
<li value="4">You are able to program intermittently, but sometimes it fails.</li>
</ul>
<h2>How to adjust the Latency Timer settings</h2>
<ul>
<li class="Checklist" value="1">Using the Identification window from the <a href="RunIdTest.htm" target="" title="" alt="" class="MCXref_0">Run/Identify Test</a> procedure, make note of the COM port number in the row where it displays a "Yes" for Echo.</li>
<li class="Checklist" value="2">Find that COM&#160;port in Device Manager.</li>
</ul>
<div class="ListIndent">
<div class="MCDropDown">
<div class="MCDropDownHead_0"><a class="MCDropDownHotSpot_0" href="javascript:void(0);" id="MCDropDownHotSpot_4207630684_0" onclick="FMCDropDown( this ); return false;"><img style="border: none;margin-right: 2px;" src="../SkinSupport/DropDownClosed.gif" MadCap:altsrc="../SkinSupport/DropDownOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/DropDownOpen.gif' ); }" class="MCDropDownIcon" />Finding your Ports List in your computer's Device Manager</a>
</div>
<div class="MCDropDownBody" id="MCDropDownBody_4207630684_0" style="display: none;">
<ul style="list-style-type: circle;">
<li value="1"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows 2K<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu &gt; Settings &gt; Control Panel &gt; System &gt; click Hardware Tab &gt; Device Manager... &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
<li value="2"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows XP<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu &gt; right-click My Computer &gt; Properties &gt; click Hardware Tab &gt; Device Manager &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
<li value="3"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows Vista or Windows 7<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu (Windows icon) &gt; right-click Computer &gt; Properties &gt; Device Manager (left pane) &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
</ul>
</div>
</div>
</div>
<ul>
<li class="Checklist" value="1">Right-click on the COM port, and select Properties</li>
</ul>
<p class="PlainTextIndent">
<img src="../Resources/Images/PortProperties.png">
</img>
</p>
<ul>
<li class="Checklist" value="1">Under the Port Settings tab, click the Advanced button. </li>
<li class="Checklist" value="2">In the Advanced Settings window, change the Latency Timer setting to 1 and then click OK.</li>
</ul>
<p>
<img src="../Resources/Images/LatentcyTimer.png" />
</p>
<ul>
<li class="Checklist" value="1">Now try the <a href="RunIdTest.htm" target="" title="" alt="" class="MCXref_0">Run/Identify Test</a> again, or try downloading a program to your BASIC&#160;Stamp.</li>
<li class="Checklist" value="2">If this did not help, <a href="../HomeTopics/Resources.htm#Contact_Parallax" target="" title="" alt="" class="MCXref_0">Contact Parallax</a> Tech Support for assistance..</li>
</ul>
<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>

View File

@ -0,0 +1,75 @@
<?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="Connection Troubleshooting" 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>No BASIC Stamps Found...</title>
<link href="../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js">
</script>
</head>
<body>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="TFAQ.htm">Connection Troubleshooting</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">No BASIC Stamps Found...</span>
</div>
<h1>No BASIC Stamps Found...</h1>
<p>If you are on this page, you probably tried to download a program to your BASIC Stamp but got the "No BASIC Stamps found" message:</p>
<p>&#160;</p>
<p>
<img src="../Resources/Images/NoFound.png">
</img>
</p>
<p>First, try these quick fixes:</p>
<ul>
<li class="Checklist" value="1"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Loose connections<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Double-check the connections between your computer and your programming cable, the Parallax USB&#160;to Serial Adapter if you are using one, and the development board.</span></span>
</li>
<li class="Checklist" value="2"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Misconnected BASIC Stamp<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: If you are using a Board of Education, double-check how to <span class="MCPopup"><a href="javascript:void(0);" MadCap:src="InsertBS2popup.htm" onclick="FMCPopup( event, this ); return false;" class="MCXref_0" alt="Open in popup window" title="Open in popup window">Insert the BASIC Stamp module</a></span> in its socket.</span></span>
</li>
<li class="Checklist" value="3"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">No power<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: double-check the power supply that you have connected to your board. (See <a href="PowerSupplies.htm" target="" title="Open &quot;Power Supplies&quot; in popup window" alt="Open &quot;Power Supplies&quot; in popup window" class="MCXref_0">Power Supplies</a> for options). If your board has a power switch, make sure it is switched on and the power indicator is lit. If you are using a 9V battery, try a fresh one. If you are using a battery pack, make sure the batteries are all inserted into the pack correctly; try fresh batteries. If you are using a wall-mount supply, make sure the wall outlet is not turned off at a wall switch. If you have a voltmeter, use it to measure the voltage supplied by the battery pack or wall-mount to rule out defective power supply hardware.</span></span>
</li>
<li class="Checklist" value="4"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Software version<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Make sure you are using the latest version of the BASIC Stamp Editor Software. You may check for a later version at <a href="http://www.parallax.com/basicstampsoftware" target="_blank" title="Open website in new window" alt="Open website in new window">www.parallax.com/basicstampsoftware</a>.</span></span>
</li>
<li class="Checklist" value="5"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">USB drivers<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: If you are using a Parallax USB connection, you may need to update your USB drivers. See the <a href="USBdrivers.htm" target="" title="" alt="" class="MCXref_0">USB Drivers</a> page for help.</span></span>
</li>
<li class="Checklist" value="6"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">USB ports freeze after disconnecting from USB&#160;3.0 port: <img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">USB 2.0 ports are recommended for BASIC Stamp boards. On some computers, the internal USB hub will freeze when disconnecting a USB 2.0 device from a USB 3.0 port. This may cause all USB ports on the computer to become unresponsive, requiring a reboot of the computer to remedy the situation. System updates from your computer manufacturer may correct the problem.USB 3.0 ports can sometimes be identified by a blue tab inside the socket.<br /><img src="../Resources/Images/USB_3_258x115.jpg" title="USB 3.0 ports have a blue tab inside." alt="USB 3.0 ports have a blue tab inside." style="padding-top: 5px;width: 258;height: 115;" /></span></span>
</li>
<li class="Checklist" value="7">
<p><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Beware of non-Parallax USB&#160;to Serial Adapters<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Not every brand of USB&#160;to Serial Adapter supports the timing precision needed for BASIC Stamp programming. Some known-incompatible brands are Belkin and Gigaware. Keyspan #USA19-HS is known to be compatible. You can order an inexpensive Parallax USB to Serial Adapter (#28030) from <a href="http://www.parallax.com/" target="_blank" title="Open website in new window" alt="Open website in new window">www.parallax.com</a>.</span></span>
</p>
</li>
</ul>
<ul>
<li class="Checklist" value="1">If you have not done so already, try the <a href="RunIdTest.htm" target="" title="" alt="" class="MCXref_0">Run/Identify Test</a>. </li>
<li class="Checklist" value="2">If you are using other terminal software to communicate with your BASIC Stamp, such as StampPlot, Parallax Serial Terminal, or Hyperterminal, it may be holding the port open. Disconnect the port in the terminal software.</li>
<li class="Checklist" value="3">If you are using a USB connection, try adjusting your computer's <a href="LatencyTimer.htm" target="" title="" alt="" class="MCXref_0">Latency Timer Settings</a>.</li>
<li class="Checklist" value="4">If none of these things helped, <a href="../HomeTopics/Resources.htm#Contact_Parallax" target="" title="" alt="" class="MCXref_0">Contact Parallax</a> Tech Support for assistance.</li>
</ul>
<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>

View File

@ -0,0 +1,110 @@
<?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>No Device Type </title>
<link href="../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js">
</script>
</head>
<body>
<h1>No Device Type </h1>
<p class="PlainText">Before you do anything else....</p>
<div class="MCDropDown">
<div class="MCDropDownHead_0"><a class="MCDropDownHotSpot_0" href="javascript:void(0);" id="MCDropDownHotSpot_68678683_0" onclick="FMCDropDown( this ); return false;"><img style="border: none;margin-right: 2px;" src="../SkinSupport/DropDownClosed.gif" MadCap:altsrc="../SkinSupport/DropDownOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/DropDownOpen.gif' ); }" class="MCDropDownIcon" />Consider The Common Quick Fixes</a>
</div>
<div class="MCDropDownBody" id="MCDropDownBody_68678683_0" style="display: none;">
<ul>
<li class="Checklist" value="1"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Loose connections<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Double-check the connections between your computer and your programming cable, the Parallax USB&#160;to Serial Adapter if you are using one, and the development board.</span></span>
</li>
<li class="Checklist" value="2"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Misconnected BASIC Stamp<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: If you are using a Board of Education, double-check how to <span class="MCPopup"><a href="javascript:void(0);" MadCap:src="InsertBS2popup.htm" onclick="FMCPopup( event, this ); return false;" class="MCXref_0" alt="Open in popup window" title="Open in popup window">Insert the BASIC Stamp module</a></span> in its socket.</span></span>
</li>
<li class="Checklist" value="3"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">No power<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: double-check the power supply that you have connected to your board. (See <a href="PowerSupplies.htm" target="" title="Open &quot;Power Supplies&quot; in popup window" alt="Open &quot;Power Supplies&quot; in popup window" class="MCXref_0">Power Supplies</a> for options). If your board has a power switch, make sure it is switched on and the power indicator is lit. If you are using a 9V battery, try a fresh one. If you are using a battery pack, make sure the batteries are all inserted into the pack correctly; try fresh batteries. If you are using a wall-mount supply, make sure the wall outlet is not turned off at a wall switch. If you have a voltmeter, use it to measure the voltage supplied by the battery pack or wall-mount to rule out defective power supply hardware.</span></span>
</li>
<li class="Checklist" value="4"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Software version<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Make sure you are using the latest version of the BASIC Stamp Editor Software. You may check for a later version at <a href="http://www.parallax.com/basicstampsoftware" target="_blank" title="Open website in new window" alt="Open website in new window">www.parallax.com/basicstampsoftware</a>.</span></span>
</li>
<li class="Checklist" value="5"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">USB drivers<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: If you are using a Parallax USB connection, you may need to update your USB drivers. See the <a href="USBdrivers.htm" target="" title="" alt="" class="MCXref_0">USB Drivers</a> page for help.</span></span>
</li>
<li class="Checklist" value="6"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">USB ports freeze after disconnecting from USB&#160;3.0 port: <img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">USB 2.0 ports are recommended for BASIC Stamp boards. On some computers, the internal USB hub will freeze when disconnecting a USB 2.0 device from a USB 3.0 port. This may cause all USB ports on the computer to become unresponsive, requiring a reboot of the computer to remedy the situation. System updates from your computer manufacturer may correct the problem.USB 3.0 ports can sometimes be identified by a blue tab inside the socket.<br /><img src="../Resources/Images/USB_3_258x115.jpg" title="USB 3.0 ports have a blue tab inside." alt="USB 3.0 ports have a blue tab inside." style="padding-top: 5px;width: 258;height: 115;" /></span></span>
</li>
<li class="Checklist" value="7">
<p><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Beware of non-Parallax USB&#160;to Serial Adapters<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Not every brand of USB&#160;to Serial Adapter supports the timing precision needed for BASIC Stamp programming. Some known-incompatible brands are Belkin and Gigaware. Keyspan #USA19-HS is known to be compatible. You can order an inexpensive Parallax USB to Serial Adapter (#28030) from <a href="http://www.parallax.com/" target="_blank" title="Open website in new window" alt="Open website in new window">www.parallax.com</a>.</span></span>
</p>
</li>
</ul>
</div>
</div>
<p>&#160;</p>
<p>If the Run/Identify test shows no entry in the "Device Type" column, you can try these various fixes based on your Loopback and Echo results.</p>
<p>&#160;</p>
<h3>There is a "No" in Loopback, and "No" in Echo.</h3>
<p>
<img src="../Resources/Images/IDnone.png">
</img>
</p>
<ul>
<li class="Checklist" value="1">If you are using a Parallax USB&#160;connection, the USB&#160;port may be using the wrong drivers. Go to the <a href="USBdrivers.htm" target="" title="" alt="" class="MCXref_0">USB Drivers</a> page for help. </li>
<li class="Checklist" value="2">If you are using a serial connection, your serial cable may be at fault. You must use a standard straight-through serial cable, not a null modem or cross-over cable. If you have a multimeter, perform a continuity test of each pin to confirm you are using an undamaged standard straight-through serial cable.</li>
</ul>
<p>&#160;</p>
<h3>There is a "Yes" in Loopback and "Yes" in Echo:</h3>
<p>
<img src="../Resources/Images/IDnoDevice.png">
</img>
</p>
<ul>
<li class="Checklist" value="1">If you are using a USB&#160;connection, try adjusting the COM port's <a href="LatencyTimer.htm" target="" title="" alt="" class="MCXref_0">Latency Timer Settings</a>.</li>
<li class="Checklist" value="2">If you are using a serial connection, try adjusting the COM port's <a href="FIFObuffers.htm" target="" title="" alt="" class="MCXref_0">FIFO Buffer Settings</a>. </li>
<li class="Checklist" value="3">It is possible that your BASIC Stamp module has been damaged. Please <a href="../HomeTopics/Resources.htm#Contact_Parallax" target="" title="" alt="" class="MCXref_0">Contact Parallax</a> Tech Support.</li>
</ul>
<p>&#160;</p>
<h3>There is a "Yes" in Loopback and a "No"&#160;in Echo:</h3>
<p>
<img src="../Resources/Images/IDyesNo.png">
</img>
</p>
<ul>
<li class="Checklist" value="1">If you have forgotten to install the BASIC Stamp into its socket on the Board of Education, or you may have plugged it in upside-down, review the directions on how to <span class="MCPopup"><a href="javascript:void(0);" MadCap:src="InsertBS2popup.htm" onclick="FMCPopup( event, this ); return false;" class="MCXref_0" alt="Open the popup window" title="Open the popup window">Insert the BASIC Stamp module</a></span>.</li>
<li class="Checklist" value="2">If you are using a USB&#160;connection, try adjusting the COM port's <a href="LatencyTimer.htm" target="" title="" alt="" class="MCXref_0">Latency Timer Settings</a>.</li>
</ul>
<p>&#160;</p>
<h3>There is a "No" in Loopback and a "Yes" in Echo:</h3>
<p>
<img src="../Resources/Images/IDnoYes.png">
</img>
</p>
<ul>
<li class="Checklist" value="1">If you are using a USB&#160;connection, try adjusting the COM port's <a href="LatencyTimer.htm" target="" title="" alt="" class="MCXref_0">Latency Timer Settings</a>. <![CDATA[ ]]></li>
<li class="Checklist" value="2">If you are using a serial connection, your serial cable may be at fault. You must use a standard straight-through serial cable, not a null modem or cross-over cable. If you have a multimeter, perform a continuity test of each pin to confirm you are using an undamaged standard straight-through serial cable.</li>
</ul>
<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>

View File

@ -0,0 +1,90 @@
<?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>No Usable Serial Ports Found</title>
<link href="../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js">
</script>
</head>
<body>
<h1>No Usable Serial Ports Found</h1>
<p class="PlainText">If you see the error message shown below, the ports may have been excluded from the BASIC Stamp Editor's search, or the ports may have been disabled in your computer's Device Manager. You can check for both situations following the instructions below.</p>
<p>
<img src="../Resources/Images/NoSerialPorts.png" />
</p>
<h2>The ports may have been excluded from the BASIC Stamp Editor's search </h2>
<p class="PlainText">(See the <a href="SerialPortSearch.htm" target="" title="" alt="" class="MCXref_0">Serial Port Search List</a> page for complete details about this feature.) </p>
<ul style="list-style-type: circle;">
<li class="Checklist" value="1">Click the Edit Ports button </li>
</ul>
<p class="PlainTextIndent">
<img src="../Resources/Images/EditPortsButton.png" />
</p>
<ul style="list-style-type: circle;">
<li class="Checklist" value="1"> Look for "<i>Communications Port</i>" or "<i>USB&#160;Serial Port</i>" in italics, with a "Yes" in the Present column. Ports that are present but have been excluded from the BASIC Stamp Editor's Serial Port Search List will appear in italics in the list. (Note that Bluetooth communications ports are excluded by default.) </li>
<li class="Checklist" value="2">Right-click that port and select "Re-Include Port" and then click Accept.</li>
</ul>
<p class="PlainTextIndent">
<img src="../Resources/Images/ReIncludePort.png" />
</p>
<h2>The port may have been disabled in your computer's Device Manager</h2>
<ul style="list-style-type: circle;">
<li class="Checklist" value="1">Right click the port in your computer's Ports list (it will be labeled "Communications Port" with a serial connection, or "USB Serial Port"&#160;with a USB&#160;connection)</li>
<li class="Checklist" value="2">Click Enable.</li>
</ul>
<p class="PlainTextIndent">
<div class="MCDropDown">
<div class="MCDropDownHead_0"><a class="MCDropDownHotSpot_0" href="javascript:void(0);" id="MCDropDownHotSpot_2011693069_0" onclick="FMCDropDown( this ); return false;"><img style="border: none;margin-right: 2px;" src="../SkinSupport/DropDownClosed.gif" MadCap:altsrc="../SkinSupport/DropDownOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/DropDownOpen.gif' ); }" class="MCDropDownIcon" />Finding your Ports List in your computer's Device Manager</a>
</div>
<div class="MCDropDownBody" id="MCDropDownBody_2011693069_0" style="display: none;">
<ul style="list-style-type: circle;">
<li value="1"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows 2K<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu &gt; Settings &gt; Control Panel &gt; System &gt; click Hardware Tab &gt; Device Manager... &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
<li value="2"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows XP<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu &gt; right-click My Computer &gt; Properties &gt; click Hardware Tab &gt; Device Manager &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
<li value="3"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows Vista or Windows 7<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu (Windows icon) &gt; right-click Computer &gt; Properties &gt; Device Manager (left pane) &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
</ul>
</div>
</div>
</p>
<p>&#160;</p>
<p class="PlainTextIndent">
<img src="../Resources/Images/EnablePort.png" />
</p>
<h2>If the error persists...</h2>
<ul>
<li class="Checklist" value="1">If this did not help, <a href="../HomeTopics/Resources.htm#Contact_Parallax" target="" title="" alt="" class="MCXref_0">Contact Parallax</a> Tech Support for assistance.</li>
</ul>
<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>

View File

@ -0,0 +1,90 @@
<?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>Can't open port; in use</title>
<link href="../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js">
</script>
</head>
<body>
<h1>Can't open port; in use</h1>
<p class="PlainText">If you see this message, there is likely to be some other software that has used that port previously, and is now interfering.</p>
<p>
<img src="../Resources/Images/CantOpenPort.png" />
</p>
<h2>Serial Terminal Software</h2>
<ul style="list-style-type: circle;">
<li class="Checklist" value="1">If you are using other terminal software to communicate with your BASIC Stamp, such as StampPlot, Parallax Serial Terminal, or Hyperterminal, it may be holding the port open. Disconnect the port in the terminal software.</li>
</ul>
<h2>Devices with Automatic Synchronization Software</h2>
<p class="PlainText">If you have used a device such as a PDA with this computer, the device's software (such as Weatherbug or HotSync software) may be holding the port open. </p>
<ul>
<li class="Checklist" value="1">Check your computer's system tray to see if the device's software is enabled, and disable it temporarily.</li>
<li class="Checklist" value="2">If disabling the software in the above step did not release the COM&#160;port, you may need to uninstall and reinstall the COM&#160;port (sounds scary but it isn't really). </li>
</ul>
<div class="ListIndent">
<ul style="list-style-type: circle;">
<li value="1">Unplug your programming cable from your computer.</li>
<li value="2">Open your Ports list and right-click on the port you want to uninstall.</li>
</ul>
<div class="MCDropDown">
<div class="MCDropDownHead_0"><a class="MCDropDownHotSpot_0" href="javascript:void(0);" id="MCDropDownHotSpot_671848068_0" onclick="FMCDropDown( this ); return false;"><img style="border: none;margin-right: 2px;" src="../SkinSupport/DropDownClosed.gif" MadCap:altsrc="../SkinSupport/DropDownOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/DropDownOpen.gif' ); }" class="MCDropDownIcon" />Finding your Ports List in your computer's Device Manager</a>
</div>
<div class="MCDropDownBody" id="MCDropDownBody_671848068_0" style="display: none;">
<ul style="list-style-type: circle;">
<li value="1"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows 2K<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu &gt; Settings &gt; Control Panel &gt; System &gt; click Hardware Tab &gt; Device Manager... &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
<li value="2"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows XP<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu &gt; right-click My Computer &gt; Properties &gt; click Hardware Tab &gt; Device Manager &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
<li value="3"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows Vista or Windows 7<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu (Windows icon) &gt; right-click Computer &gt; Properties &gt; Device Manager (left pane) &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
</ul>
</div>
</div>
<p>&#160;</p>
<p>
<img src="../Resources/Images/ComUninstall.png">
</img>
</p>
<ul style="list-style-type: circle;">
<li value="1">Select Uninstall.</li>
<li value="2">Restart your computer.</li>
<li value="3">Reconnect your hardware and try the <a href="RunIdTest.htm" target="" title="" alt="" class="MCXref_0">Run/Identify Test</a> again.</li>
</ul>
</div>
<h2>If the error persists...</h2>
<ul style="list-style-type: circle;">
<li class="Checklist" value="1">If this did not help, <a href="../HomeTopics/Resources.htm#Contact_Parallax" target="" title="" alt="" class="MCXref_0">Contact Parallax</a> Tech Support for assistance.</li>
</ul>
<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>

View File

@ -0,0 +1,97 @@
<?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="BASIC Stamp Hardware" 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>Power Supplies</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>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="../HardwareTopics/BS_Chart.htm">BASIC Stamp Hardware</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Power Supplies</span>
</div>
<h1>Power Supplies</h1>
<p>Parallax BASIC Stamp Development Boards may have either a barrel jack connector, 9 V battery clip connector, or both (as does the Board of Education.) This page gives options for both types of power connectors.</p>
<h2>For Boards with a Barrel Jack Connector <![CDATA[ ]]></h2>
<p class="PlainText">The two most common power supply options used with this connector are wall-mount DC power supply, and battery holders.</p>
<h3>Wall-mount DC Power Supplies</h3>
<ul style="list-style-type: circle;">
<li class="Checklist" value="1">Plug: it must have a 2.1 mm center-positive barrel plug. Look for this symbol, indicating the positive connection is in the center of the plug:</li>
</ul>
<p class="PlainTextIndent">
<img src="../Resources/Images/CenterPos.png" />
</p>
<ul style="list-style-type: circle;">
<li class="Checklist" value="1">Output current: wall-mount power supplies must have a DC (direct current) output. Look for a statement that indicates VDC output or uses this symbol: <img src="../Resources/Images/OutputDCsmall.png" style="font-weight: bold;" />. For example:</li>
</ul>
<div class="ListIndent">
<ul style="list-style-type: circle;">
<li value="1"><b>OUTPUT: 7.5 VDC 1000 mA</b>
</li>
<li value="2"><b>OUTPUT: 7.5 V</b>
<img src="../Resources/Images/OutputDCsmall.png" style="font-weight: bold;" /><b>1.4 A</b>
</li>
</ul>
</div>
<ul style="list-style-type: circle;">
<li class="Checklist" value="1">Output voltage: The power supply's output voltage must be compatible with the voltage rating on your board. For example, the Board of Education requires 6 to 9 VDC. </li>
<li class="Checklist" value="2">Input voltage and current: Wall-mount power supplies must be compatible with the frequency and amplitude of the AC power at the wall outlet you are using. This may vary depending on the country you live in. In the US and Canada, the input should be compatible with 120 VAC, 60 Hz.</li>
</ul>
<p class="PlainText">Parallax carries power supplies compatible with BASIC Stamp development boards. For example, the 7.5 V, 1 amp supply (#750-00009) is compatible with the Board of Education. </p>
<p class="PlainText">
<img src="../Resources/Images/7.5Vsupply.png" />
</p>
<h3>Battery Holders</h3>
<p>Like wall-mount supplies, battery holders must have a 2.1 mm center-positive plug. However, many battery holders don't have a symbol indicating whether or not the plug is center-positive. Use a voltmeter to test any battery holder of unknown origins. A 4 AA cell battery holder with a 2.1 mm center-positive plug is available from Parallax (#700-00038); this is the one included in the <a href="http://www.parallax.com/go/boebot" target="_blank" title="Open website in new window." alt="Open website in new window.">Boe-Bot Robot Kit</a>.</p>
<p>&#160;</p>
<p>
<img src="../Resources/Images/BattHolder.png" />
</p>
<h2>For Boards with Battery Clip Connector </h2>
<h3>9-Volt Batteries</h3>
<p class="PlainText">9 V Alkaline or rechargeable batteries with a snap-connector are fine. For best results, rechargeable batteries should be rated for 100 mAh (milliamp hours) or higher.</p>
<p class="PlainText">Not all chargers work with all types of batteries. Make sure your charger is recommended for the type of battery you are using. Follow all battery and charger instructions and caution statements.</p>
<h3>9 V Battery Extension</h3>
<p class="PlainText">The figure below shows a DC supply and a 9 V battery extension that can be used with battery clip connectors, such as the one on the BASIC Stamp HomeWork Board. Read the CAUTION&#160;statement below the picture.</p>
<p class="PlainText">
<img src="../Resources/Images/BattExtend.png" />
</p>
<h3> Beware of Universal Adapters and Reversed Supply Terminals!</h3>
<p class="PlainText">The picture below shows a common mistake that should be avoided with universal adapters. Many of these allow you to reverse the terminals on the 9 V battery extension. Although it cannot hurt the BASIC Stamp, Board of Education, or HomeWork Board, it can destroy a Parallax Standard Servo connected to Vin in a matter of seconds. The only system that can protect the servo from this mistake is a Board of Education that has a jumper between the servo ports, with that jumper set to Vdd.</p>
<p class="PlainText">
<img src="../Resources/Images/TipPolarity.png" />
</p>
<h3>Beware of "Battery Replacers"</h3>
<p class="PlainText">Many battery replacers are designed to supply appliances with low current draw. With current ratings in the neighborhood of 10 mA, their output capacities are insufficient for many of the activities in the Stamps in Class texts. For example, two LEDs connected to 220-ohm resistors draw a total of 14.5 mA, and that definitely won't work with a "battery replacer."</p>
<p class="PlainText"> Note: It's pretty easy to tell when a circuit is drawing more current than the supply can deliver because the Power LED&#160;on the Board of Education flickers and/or goes dim. On the HomeWork Board, the "Running" LED may flicker if the power drops low enough to cause the BASIC Stamp to reset and restart the program.</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>

View File

@ -0,0 +1,67 @@
<?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="2" MadCap:lastHeight="47" MadCap:lastWidth="579" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" class="TopicPopup" MadCap:PathToHelpSystem="../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
<head><title>Power Supplies</title>
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js" type="text/javascript">
</script>
</head>
<body>
<h1>Power Supplies</h1>
<p>Parallax BASIC Stamp Development Boards may have either a barrel jack connector, 9 V battery clip connector, or both (as does the Board of Education.) This page gives options for both types of power connectors.</p>
<h2>For Boards with a Barrel Jack Connector <![CDATA[ ]]></h2>
<p class="PlainText">The two most common power supply options used with this connector are wall-mount DC power supply, and battery holders.</p>
<h3>Wall-mount DC Power Supplies</h3>
<ul style="list-style-type: circle;">
<li class="Checklist" value="1">Plug: it must have a 2.1 mm center-positive barrel plug. Look for this symbol, indicating the positive connection is in the center of the plug:</li>
</ul>
<p class="PlainTextIndent">
<img src="../Resources/Images/CenterPos.png" />
</p>
<ul style="list-style-type: circle;">
<li class="Checklist" value="1">Output current: wall-mount power supplies must have a DC (direct current) output. Look for a statement that indicates VDC output or uses this symbol: <img src="../Resources/Images/OutputDCsmall.png" style="font-weight: bold;" />. For example:</li>
</ul>
<div class="ListIndent">
<ul style="list-style-type: circle;">
<li value="1"><b>OUTPUT: 7.5 VDC 1000 mA</b>
</li>
<li value="2"><b>OUTPUT: 7.5 V</b>
<img src="../Resources/Images/OutputDCsmall.png" style="font-weight: bold;" /><b>1.4 A</b>
</li>
</ul>
</div>
<ul style="list-style-type: circle;">
<li class="Checklist" value="1">Output voltage: The power supply's output voltage must be compatible with the voltage rating on your board. For example, the Board of Education requires 6 to 9 VDC. </li>
<li class="Checklist" value="2">Input voltage and current: Wall-mount power supplies must be compatible with the frequency and amplitude of the AC power at the wall outlet you are using. This may vary depending on the country you live in. In the US and Canada, the input should be compatible with 120 VAC, 60 Hz.</li>
</ul>
<p class="PlainText">Parallax carries power supplies compatible with BASIC Stamp development boards. For example, the 7.5 V, 1 amp supply (#750-00009) is compatible with the Board of Education. </p>
<p class="PlainText">
<img src="../Resources/Images/7.5Vsupply.png" />
</p>
<h3>Battery Holders</h3>
<p>Like wall-mount supplies, battery holders must have a 2.1 mm center-positive plug. However, many battery holders don't have a symbol indicating whether or not the plug is center-positive. Use a voltmeter to test any battery holder of unknown origins. A 4 AA cell battery holder with a 2.1 mm center-positive plug is available from Parallax (#700-00038); this is the one included in the <a href="http://www.parallax.com/go/boebot" target="_blank" title="Open website in new window." alt="Open website in new window.">Boe-Bot Robot Kit</a>.</p>
<p>&#160;</p>
<p>
<img src="../Resources/Images/BattHolder.png" />
</p>
<h2>For Boards with Battery Clip Connector </h2>
<h3>9-Volt Batteries</h3>
<p class="PlainText">9 V Alkaline or rechargeable batteries with a snap-connector are fine. For best results, rechargeable batteries should be rated for 100 mAh (milliamp hours) or higher.</p>
<p class="PlainText">Not all chargers work with all types of batteries. Make sure your charger is recommended for the type of battery you are using. Follow all battery and charger instructions and caution statements.</p>
<h3>9 V Battery Extension</h3>
<p class="PlainText">The figure below shows a DC supply and a 9 V battery extension that can be used with battery clip connectors, such as the one on the BASIC Stamp HomeWork Board. Read the CAUTION&#160;statement below the picture.</p>
<p class="PlainText">
<img src="../Resources/Images/BattExtend.png" />
</p>
<h3> Beware of Universal Adapters and Reversed Supply Terminals!</h3>
<p class="PlainText">The picture below shows a common mistake that should be avoided with universal adapters. Many of these allow you to reverse the terminals on the 9 V battery extension. Although it cannot hurt the BASIC Stamp, Board of Education, or HomeWork Board, it can destroy a Parallax Standard Servo connected to Vin in a matter of seconds. The only system that can protect the servo from this mistake is a Board of Education that has a jumper between the servo ports, with that jumper set to Vdd.</p>
<p class="PlainText">
<img src="../Resources/Images/TipPolarity.png" />
</p>
<h3>Beware of "Battery Replacers"</h3>
<p class="PlainText">Many battery replacers are designed to supply appliances with low current draw. With current ratings in the neighborhood of 10 mA, their output capacities are insufficient for many of the activities in the Stamps in Class texts. For example, two LEDs connected to 220-ohm resistors draw a total of 14.5 mA, and that definitely won't work with a "battery replacer."</p>
<p class="PlainText"> Note: It's pretty easy to tell when a circuit is drawing more current than the supply can deliver because the Power LED&#160;on the Board of Education flickers and/or goes dim. On the HomeWork Board, the "Running" LED may flicker if the power drops low enough to cause the BASIC Stamp to reset and restart the program.</p>
<script type="text/javascript" src="../SkinSupport/MadCapBodyEnd.js">
</script>
</body>
</html>

View File

@ -0,0 +1,123 @@
<?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="Connection Troubleshooting" 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>Run/Identify Test</title>
<link href="../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js">
</script>
</head>
<body>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="TFAQ.htm">Connection Troubleshooting</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Run/Identify Test</span>
</div>
<h1>Run/Identify Test</h1>
<p class="PlainText">This page will help you troubleshoot problems found after trying the Run/Identify test to verify the programming connection between your computer and BASIC Stamp. You should have already tried the common quick fixes and the Run/Identify test.</p>
<div class="MCDropDown">
<div class="MCDropDownHead_0"><a class="MCDropDownHotSpot_0" href="javascript:void(0);" id="MCDropDownHotSpot_3311062465_0" onclick="FMCDropDown( this ); return false;"><img style="border: none;margin-right: 2px;" src="../SkinSupport/DropDownClosed.gif" MadCap:altsrc="../SkinSupport/DropDownOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/DropDownOpen.gif' ); }" class="MCDropDownIcon" />The Common Quick Fixes</a>
</div>
<div class="MCDropDownBody" id="MCDropDownBody_3311062465_0" style="display: none;">
<ul>
<li class="Checklist" value="1"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Loose connections<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Double-check the connections between your computer and your programming cable, the Parallax USB&#160;to Serial Adapter if you are using one, and the development board.</span></span>
</li>
<li class="Checklist" value="2"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Misconnected BASIC Stamp<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: If you are using a Board of Education, double-check how to <span class="MCPopup"><a href="javascript:void(0);" MadCap:src="InsertBS2popup.htm" onclick="FMCPopup( event, this ); return false;" class="MCXref_0" alt="Open in popup window" title="Open in popup window">Insert the BASIC Stamp module</a></span> in its socket.</span></span>
</li>
<li class="Checklist" value="3"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">No power<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: double-check the power supply that you have connected to your board. (See <a href="PowerSupplies.htm" target="" title="Open &quot;Power Supplies&quot; in popup window" alt="Open &quot;Power Supplies&quot; in popup window" class="MCXref_0">Power Supplies</a> for options). If your board has a power switch, make sure it is switched on and the power indicator is lit. If you are using a 9V battery, try a fresh one. If you are using a battery pack, make sure the batteries are all inserted into the pack correctly; try fresh batteries. If you are using a wall-mount supply, make sure the wall outlet is not turned off at a wall switch. If you have a voltmeter, use it to measure the voltage supplied by the battery pack or wall-mount to rule out defective power supply hardware.</span></span>
</li>
<li class="Checklist" value="4"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Software version<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Make sure you are using the latest version of the BASIC Stamp Editor Software. You may check for a later version at <a href="http://www.parallax.com/basicstampsoftware" target="_blank" title="Open website in new window" alt="Open website in new window">www.parallax.com/basicstampsoftware</a>.</span></span>
</li>
<li class="Checklist" value="5"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">USB drivers<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: If you are using a Parallax USB connection, you may need to update your USB drivers. See the <a href="USBdrivers.htm" target="" title="" alt="" class="MCXref_0">USB Drivers</a> page for help.</span></span>
</li>
<li class="Checklist" value="6"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">USB ports freeze after disconnecting from USB&#160;3.0 port: <img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">USB 2.0 ports are recommended for BASIC Stamp boards. On some computers, the internal USB hub will freeze when disconnecting a USB 2.0 device from a USB 3.0 port. This may cause all USB ports on the computer to become unresponsive, requiring a reboot of the computer to remedy the situation. System updates from your computer manufacturer may correct the problem.USB 3.0 ports can sometimes be identified by a blue tab inside the socket.<br /><img src="../Resources/Images/USB_3_258x115.jpg" title="USB 3.0 ports have a blue tab inside." alt="USB 3.0 ports have a blue tab inside." style="padding-top: 5px;width: 258;height: 115;" /></span></span>
</li>
<li class="Checklist" value="7">
<p><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Beware of non-Parallax USB&#160;to Serial Adapters<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Not every brand of USB&#160;to Serial Adapter supports the timing precision needed for BASIC Stamp programming. Some known-incompatible brands are Belkin and Gigaware. Keyspan #USA19-HS is known to be compatible. You can order an inexpensive Parallax USB to Serial Adapter (#28030) from <a href="http://www.parallax.com/" target="_blank" title="Open website in new window" alt="Open website in new window">www.parallax.com</a>.</span></span>
</p>
</li>
</ul>
</div>
</div>
<p>&#160;</p>
<div class="MCDropDown">
<div class="MCDropDownHead_0"><a class="MCDropDownHotSpot_0" href="javascript:void(0);" id="MCDropDownHotSpot_3311062465_1" onclick="FMCDropDown( this ); return false;"><img style="border: none;margin-right: 2px;" src="../SkinSupport/DropDownClosed.gif" MadCap:altsrc="../SkinSupport/DropDownOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/DropDownOpen.gif' ); }" class="MCDropDownIcon" />The Run/Identify Test Procedure</a>
</div>
<div class="MCDropDownBody" id="MCDropDownBody_3311062465_1" style="display: none;">
<ul>
<li class="Checklist" value="1">To make sure your BASIC Stamp module can communicate with your computer, click the Run menu, then select Identify.</li>
</ul>
<p>
<img src="../Resources/Images/RunID.png" />
</p>
<ul>
<li class="Checklist" value="1">Or, you can use the ID icon on the toolbar:</li>
</ul>
<p>
<img src="../Resources/Images/IDbutton.png" />
</p>
<p class="PlainText">An identification window will appear similar to the one shown here. This example shows that a BASIC Stamp 2 has been detected on COM5.</p>
<p>
<img src="../Resources/Images/BS2onCOM5.png" />
</p>
<ul>
<li class="Checklist" value="1">Check the Identification window to make sure your BASIC Stamp module has been detected on one of the COM&#160;ports. If it has been detected, then you are ready to program your BASIC Stamp. </li>
</ul>
</div>
</div>
<p>&#160;</p>
<h2>It Passed the Run/Identify Test but Still Won't Program Reliably</h2>
<ul>
<li class="Checklist" value="1">If your USB-connected BASIC Stamp is detected and you see Yes in both columns, but can program only intermittently or get a "No BASIC&#160;Stamps Found" or a hardware/communication failure message, try adjusting the <a href="LatencyTimer.htm" target="" title="" alt="" class="MCXref_0">Latency Timer Settings</a>.</li>
</ul>
<p class="PlainText">&#160;</p>
<h2>It Failed the Run/Identify Test</h2>
<p class="PlainText">If the Run/Identify test DID NOT&#160;find your BASIC Stamp on any COM&#160;port, the message that appeared can help diagnose connection problems.</p>
<ul>
<li class="Checklist" value="1">Click on a message (below) to go to its troubleshooting page.</li>
</ul>
<h3><a href="NoDeviceType.htm" target="" title="" alt="" class="MCXref_0">No Device Type </a>
</h3>
<p><a href="NoDeviceType.htm" title="Go to &quot;No Device Type&quot; page" alt="Go to &quot;No Device Type&quot; page"><img src="../Resources/Images/IDnoDevice.png" /></a>
</p>
<h3><a href="NoPortsFound.htm" target="" title="" alt="" class="MCXref_0">No Usable Serial Ports Found</a>
</h3>
<p><a href="NoPortsFound.htm" title="Go to &quot;No Usable Ports Found&quot; page" alt="Go to &quot;No Usable Ports Found&quot; page"><img src="../Resources/Images/NoSerialPorts.png" /></a>
</p>
<h3><a href="PortInUse.htm" target="" title="" alt="" class="MCXref_0">Can't open port; in use</a>
</h3>
<p><a href="PortInUse.htm" title="Go to the &quot;Can't open port; in use&quot; page" alt="Go to the &quot;Can't open port; in use&quot; page"><img src="../Resources/Images/CantOpenPort.png" /></a>
</p>
<h3><a href="InvalidPort.htm" target="" title="" alt="" class="MCXref_0">Invalid Port</a>
</h3>
<p><a href="InvalidPort.htm" title="Go to &quot;Invalid Port&quot; page" alt="Go to &quot;Invalid Port&quot; page"><img src="../Resources/Images/IDinvalidPort.png" /></a>
</p>
<p>&#160;</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>

View File

@ -0,0 +1,132 @@
<?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="Connection Troubleshooting" 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>Serial Port Search List</title>
<link href="../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js">
</script>
</head>
<body>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="TFAQ.htm">Connection Troubleshooting</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Serial Port Search List</span>
</div>
<h1>Serial Port Search List</h1>
<p class="PlainText">This dialog indicates what serial ports will be scanned, and the order they will be accessed, whenever a BASIC Stamp identification or download process is started. Use this feature to fine-tune the BASIC Stamp search to include or exclude certain serial ports.</p>
<p>
<img src="../Resources/Images/SPSLorder.png">
</img>
</p>
<p class="PlainText">To access this dialog, click the "Edit Ports..." button that appears on the Identification Window or the Preferences &gt; Editor Operation tab:</p>
<ul>
<li value="1">Identification Window: This appears when you press Ctrl+I or select the Run &gt; Identify menu.</li>
<li value="2">Preferences &gt; Editor Operation tab: This appears when you press F5, or select the Edit &gt; Preferences... menu, and select the Editor Operation tab.</li>
</ul>
<h2>Port List</h2>
<p class="PlainText"> The port list automatically updates whenever ports appear and disappear; such as USB-to-Serial ports. This is an interactive control; use your mouse to view and modify the list as indicated below.</p>
<ul>
<li value="1">Port ID column: Indicates the Port ID.</li>
<li value="2">Port Description column: Indicates the friendly name for the port, similar to that shown in the Windows Device Manager tool.</li>
<li value="3">Present column: 'Yes' if the port is currently present on the system, 'No' if not; this indicates a user rule is including a port in the search list that isn't currently present on the system.</li>
</ul>
<h3>Viewing and Modifying the List and Association Rules</h3>
<p class="PlainText">The list of ports is shown in the order in which they will be scanned during BASIC Stamp identification and/or download processes. The ports to be scanned, and the order in which they are scanned, can be set through this interface, described below.</p>
<div class="MCDropDown">
<div class="MCDropDownHead_0"><a class="MCDropDownHotSpot_0" href="javascript:void(0);" id="MCDropDownHotSpot_1967852838_0" onclick="FMCDropDown( this ); return false;"><img style="border: none;margin-right: 2px;" src="../SkinSupport/DropDownClosed.gif" MadCap:altsrc="../SkinSupport/DropDownOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/DropDownOpen.gif' ); }" class="MCDropDownIcon" />Changing the Scan Order</a>
</div>
<div class="MCDropDownBody" id="MCDropDownBody_1967852838_0" style="display: none;">
<p>&#160;</p>
<p class="PlainText">To change the order in which ports are scanned, left-click and drag port rows up and down. In this example, we selected the COM11 row, left-clicked it and dragged it up to be above the first Bluetooth Communications Port row (COM3). This results in a new scan order of COM11, COM3, COM6, and lastly COM12.</p>
<p class="PlainText">
<img src="../Resources/Images/SPSLmove.png">
</img>
</p>
</div>
</div>
<div class="MCDropDown">
<div class="MCDropDownHead_0"><a class="MCDropDownHotSpot_0" href="javascript:void(0);" id="MCDropDownHotSpot_1967852838_1" onclick="FMCDropDown( this ); return false;"><img style="border: none;margin-right: 2px;" src="../SkinSupport/DropDownClosed.gif" MadCap:altsrc="../SkinSupport/DropDownOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/DropDownOpen.gif' ); }" class="MCDropDownIcon" />Viewing the Inclusion/Exclusion status</a>
</div>
<div class="MCDropDownBody" id="MCDropDownBody_1967852838_1" style="display: none;">
<p class="PlainText">Ports may be included or excluded from the search list based on one or more user-defined rules. </p>
<p class="PlainText">To see what rule is applying to a particular port, point the mouse at the port's row and read the hint that appears. The example shown here indicates that port COM12 is being "Included by default" which means there is no rule explicitly including or excluding the port.</p>
<p class="PlainText">
<img src="../Resources/Images/SPSLinlcudeDefault.png">
</img>
</p>
<p class="PlainText">To exclude or include a port by the port's ID, right-click the port's row and select the "Exclude/Include Port (COMxx)" item. In this example, we chose to exclude COM12. </p>
<p>
<img src="../Resources/Images/SPSLexcludeCom12.png">
</img>
</p>
<p class="PlainText">After excluding it, the ports list will update as shown below. Notice that it appears ghosted and in italics to indicate it will not be scanned; it will be ignored during an identification and download process. Also, hovering the mouse over it will display a hint saying, "Excluded by Port ID rule." </p>
<p>
<img src="../Resources/Images/SPSLexcludeByID.png">
</img>
</p>
<p class="Tip" MadCap:autonum="Tip: &#160;"><span class="autonumber"><span class="TipSpan">Tip: &#160;</span></span>You can remove this Port ID rule by right-clicking on the port's row and selecting the "Re-include/exclude port (COMxx)" item.</p>
</div>
</div>
<div class="MCDropDown">
<div class="MCDropDownHead_0"><a class="MCDropDownHotSpot_0" href="javascript:void(0);" id="MCDropDownHotSpot_1967852838_2" onclick="FMCDropDown( this ); return false;"><img style="border: none;margin-right: 2px;" src="../SkinSupport/DropDownClosed.gif" MadCap:altsrc="../SkinSupport/DropDownOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/DropDownOpen.gif' ); }" class="MCDropDownIcon" />Excluding or Including a Port by Description</a>
</div>
<div class="MCDropDownBody" id="MCDropDownBody_1967852838_2" style="display: none;">
<ul style="list-style-type: circle;">
<li class="Checklist" value="1">To exclude or include a port by its description, right-click the port's row and select the "Filter Port(s) by Description…" item.</li>
</ul>
<p class="PlainText">
<img src="../Resources/Images/SPSLfilterDesc.png" />
</p>
<p class="PlainText"> This will open a new dialog that allows you to set the desired description rule. In this example, we set it to "Exclude" any ports matching "Bluetooth Communications Port" in their description.</p>
<p class="PlainText">
<img src="../Resources/Images/SPSLfilterWindow.png" />
</p>
<p class="PlainText">Click OK to update the ports list. Notice that COM3 and COM6 (the ports whose descriptions read "Bluetooth Communications Port") appear ghosted and in italics to indicate it they will not be scanned; they will be ignored during an identification and download process. Also, hovering the mouse over those ports will display a hint saying, "Excluded by Port Description rule."</p>
<p class="PlainText">
<img src="../Resources/Images/SPSLexcludeDescRule.png">
</img>
</p>
<p class="Tip" MadCap:autonum="Tip: &#160;"><span class="autonumber"><span class="TipSpan">Tip: &#160;</span></span>You can edit or remove this Port Description rule for a single port by by right-clicking on the port's row and selecting the "Include Port (COMxx)" option. You can change or remove it from all ports with the "Edit Port Description Rule..." or "Remove port description rule…" options.</p>
<p class="PlainText">
<img src="../Resources/Images/SPSLremoveRule.png">
</img>
</p>
<p class="Tip" MadCap:autonum="Tip: &#160;"><span class="autonumber"><span class="TipSpan">Tip: &#160;</span></span>On the Filter Port(s) by Description dialog, the Port Description field can be as general or as specific as necessary by using asterisk (*) characters as wild cards. For example, to exclude all ports beginning with the word "USB," enter "USB *" in the field. To exclude all ports with the word USB appearing anywhere within them, enter "*USB*" in the field. The bottom of the dialog shows the number of "Matches Found;" the number of existing ports that the rule applies to.</p>
<p class="Tip" MadCap:autonum="Tip: &#160;"><span class="autonumber"><span class="TipSpan">Tip: &#160;</span></span>To exclude all ports except specific ports, right-click on any port row and select "Exclude all ports by default," then right click on any desired ports and select either "Include Port (COMxx)" or "Filter Port(s) by Description…" and enter the desired match string of ports to include.</p>
</div>
</div>
<h2>Buttons</h2>
<ul>
<li value="1">Restore Defaults: Press this button to remove all user-defined serial port rules and return the BASIC Stamp Editor Serial Port Search List to its default scanning sequence. Note that Bluetooth ports are excluded by default.</li>
<li value="2">Accept: Press this button to apply all modifications made to the serial port search list and corresponding rules.</li>
<li value="3">Cancel: Press this button to cancel all recent modifications made to the serial port search list and corresponding rules.</li>
</ul>
<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>

View File

@ -0,0 +1,73 @@
<?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>Connection Troubleshooting</title>
<link href="../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js">
</script>
</head>
<body>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><span class="MCBreadcrumbs">Connection Troubleshooting</span>
</div>
<h1>Connection Troubleshooting</h1>
<p>This is the "triage" area for troubleshooting the programming connection between your computer and your BASIC Stamp development board.</p>
<p>&#160;</p>
<p>Let's rule out the most common causes of communications failure first:</p>
<ul>
<li class="Checklist" value="1"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Loose connections<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Double-check the connections between your computer and your programming cable, the Parallax USB&#160;to Serial Adapter if you are using one, and the development board.</span></span>
</li>
<li class="Checklist" value="2"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Misconnected BASIC Stamp<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: If you are using a Board of Education, double-check how to <span class="MCPopup"><a href="javascript:void(0);" MadCap:src="InsertBS2popup.htm" onclick="FMCPopup( event, this ); return false;" class="MCXref_0" alt="Open in popup window" title="Open in popup window">Insert the BASIC Stamp module</a></span> in its socket.</span></span>
</li>
<li class="Checklist" value="3"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">No power<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: double-check the power supply that you have connected to your board. (See <a href="PowerSupplies.htm" target="" title="Open &quot;Power Supplies&quot; in popup window" alt="Open &quot;Power Supplies&quot; in popup window" class="MCXref_0">Power Supplies</a> for options). If your board has a power switch, make sure it is switched on and the power indicator is lit. If you are using a 9V battery, try a fresh one. If you are using a battery pack, make sure the batteries are all inserted into the pack correctly; try fresh batteries. If you are using a wall-mount supply, make sure the wall outlet is not turned off at a wall switch. If you have a voltmeter, use it to measure the voltage supplied by the battery pack or wall-mount to rule out defective power supply hardware.</span></span>
</li>
<li class="Checklist" value="4"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Software version<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Make sure you are using the latest version of the BASIC Stamp Editor Software. You may check for a later version at <a href="http://www.parallax.com/basicstampsoftware" target="_blank" title="Open website in new window" alt="Open website in new window">www.parallax.com/basicstampsoftware</a>.</span></span>
</li>
<li class="Checklist" value="5"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">USB drivers<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: If you are using a Parallax USB connection, you may need to update your USB drivers. See the <a href="USBdrivers.htm" target="" title="" alt="" class="MCXref_0">USB Drivers</a> page for help.</span></span>
</li>
<li class="Checklist" value="6"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">USB ports freeze after disconnecting from USB&#160;3.0 port: <img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">USB 2.0 ports are recommended for BASIC Stamp boards. On some computers, the internal USB hub will freeze when disconnecting a USB 2.0 device from a USB 3.0 port. This may cause all USB ports on the computer to become unresponsive, requiring a reboot of the computer to remedy the situation. System updates from your computer manufacturer may correct the problem.USB 3.0 ports can sometimes be identified by a blue tab inside the socket.<br /><img src="../Resources/Images/USB_3_258x115.jpg" title="USB 3.0 ports have a blue tab inside." alt="USB 3.0 ports have a blue tab inside." style="padding-top: 5px;width: 258;height: 115;" /></span></span>
</li>
<li class="Checklist" value="7">
<p><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Beware of non-Parallax USB&#160;to Serial Adapters<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Not every brand of USB&#160;to Serial Adapter supports the timing precision needed for BASIC Stamp programming. Some known-incompatible brands are Belkin and Gigaware. Keyspan #USA19-HS is known to be compatible. You can order an inexpensive Parallax USB to Serial Adapter (#28030) from <a href="http://www.parallax.com/" target="_blank" title="Open website in new window" alt="Open website in new window">www.parallax.com</a>.</span></span>
</p>
</li>
</ul>
<p class="PlainText">Okay, if that didn't solve the problem, let's keep going:</p>
<ul>
<li class="Checklist" value="1">If you are able to program your USB-connected board sometimes, but it fails sometimes or requires several tries (and you are SURE the power supply is not the problem), you may need to change your computer's <a href="LatencyTimer.htm" target="" title="" alt="" class="MCXref_0">Latency Timer Settings</a>.</li>
<li class="Checklist" value="2">If you are using a Parallax BASIC Stamp development board (such as a Board of Education, HomeWork Board, or Professional Development Board), and your PC cannot communicate with your BASIC Stamp, go to the <a href="RunIdTest.htm" target="" title="" alt="" class="MCXref_0">Run/Identify Test</a> page.</li>
<li class="Checklist" value="3">If you are using a USB-based board or USB&#160;to Serial Adapter, and repeated BASIC Stamp resets are interfering with your program, see the <a href="UsbBoardResets.htm" target="" title="" alt="" class="MCXref_0">USB Resets BASIC Stamp</a> page.</li>
<li class="Checklist" value="4">If you are using a development board and/or BASIC Stamp OEM that you&#160;assembled yourself, there are a number of tests that can be performed best with the help of the Parallax Tech Support crew, and a voltmeter. Please <a href="../HomeTopics/Resources.htm#Contact_Parallax" target="" title="" alt="" class="MCXref_0">Contact Parallax</a> Tech Support.</li>
</ul>
<p>&#160;</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>

View File

@ -0,0 +1,89 @@
<?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="Connection Troubleshooting" 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>USB Drivers</title>
<link href="../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js">
</script>
</head>
<body>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="TFAQ.htm">Connection Troubleshooting</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">USB Drivers</span>
</div>
<h1>USB Drivers</h1>
<p class="PlainText">If you are using a Parallax board with a USB&#160;connector, or a Parallax USB&#160;to Serial Adapter: <![CDATA[ ]]></p>
<p class="PlainText">
<img src="../Resources/Images/USBconn.png" />...or...<img src="../Resources/Images/USBadapter.png" /></p>
<p>...you will need USB&#160;drivers from Parallax Inc.</p>
<ul>
<li class="Checklist" value="1"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Beware of non-Parallax USB&#160;to Serial Adapters<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Not every brand of USB&#160;to Serial Adapter supports the timing precision needed for BASIC Stamp programming. Some known-incompatible brands are Belkin and Gigaware. Keyspan #USA19-HS is known to be compatible. You can order an inexpensive Parallax USB to Serial Adapter (#28030) from <a href="http://www.parallax.com/" target="_blank" title="Open website in new window" alt="Open website in new window">www.parallax.com</a>.</span></span>
</li>
<li class="Checklist" value="2">Unplug the USB&#160;cable to your BASIC Stamp development board at the computer.</li>
<li class="Checklist" value="3">Download and install the latest version of the USB&#160;drivers from Parallax: <a href="http://www.parallax.com/usbdrivers" target="_blank" title="Open website in new window" alt="Open website in new window">www.parallax.com/usbdrivers</a>.</li>
<li class="Checklist" value="4">Reconnect the USB&#160;cable and your BASIC Stamp development board. You should see a series of messages in your system tray:</li>
</ul>
<p class="PlainTextIndent">
<img src="../Resources/Images/FoundUART.png" />... <![CDATA[ ]]><img src="../Resources/Images/FoundNewHardware.png" /> ... <img src="../Resources/Images/ReadyToUse.png" /></p>
<ul>
<li class="Checklist" value="1">If you don't see any of these messages, open your computer's Ports list to confirm that the drivers were installed properly.</li>
</ul>
<div class="ListIndent">
<div class="MCDropDown">
<div class="MCDropDownHead_0"><a class="MCDropDownHotSpot_0" href="javascript:void(0);" id="MCDropDownHotSpot_3715037958_0" onclick="FMCDropDown( this ); return false;"><img style="border: none;margin-right: 2px;" src="../SkinSupport/DropDownClosed.gif" MadCap:altsrc="../SkinSupport/DropDownOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/DropDownOpen.gif' ); }" class="MCDropDownIcon" />Finding your Ports List in your computer's Device Manager</a>
</div>
<div class="MCDropDownBody" id="MCDropDownBody_3715037958_0" style="display: none;">
<ul style="list-style-type: circle;">
<li value="1"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows 2K<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu &gt; Settings &gt; Control Panel &gt; System &gt; click Hardware Tab &gt; Device Manager... &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
<li value="2"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows XP<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu &gt; right-click My Computer &gt; Properties &gt; click Hardware Tab &gt; Device Manager &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
<li value="3"><span class="MCExpanding"><a href="javascript:void(0);" class="MCExpandingHead_0" onclick="FMCExpand( this ); return false;">Windows Vista or Windows 7<img style="border: none;margin-left: 5px;" src="../SkinSupport/ExpandingClosed.gif" MadCap:altsrc="../SkinSupport/ExpandingOpen.gif" onload="if ( typeof( FMCPreloadImage ) == 'function' ) { FMCPreloadImage( '../SkinSupport/ExpandingOpen.gif' ); }" class="MCExpandingIcon" /></a><span class="MCExpandingBody" style="display: none;">: Start Menu (Windows icon) &gt; right-click Computer &gt; Properties &gt; Device Manager (left pane) &gt; expand Ports (COM &amp;&#160;LPT)</span></span>
</li>
</ul>
</div>
</div>
</div>
<ul>
<li class="Checklist" value="1">If there is no yellow exclamation mark (like the image below), the drivers have been installed correctly and you can now go try the <a href="RunIdTest.htm" target="" title="" alt="" class="MCXref_0">Run/Identify Test</a> again.</li>
</ul>
<p class="PlainTextIndent">
<img src="../Resources/Images/USBportOK.png" />
</p>
<ul>
<li class="Checklist" value="1">There will be a yellow exclamation mark (!) by the device if the drivers either were not installed successfully or not at all. <a href="../HomeTopics/Resources.htm#Contact_Parallax" target="" title="" alt="" class="MCXref_0">Contact Parallax</a> Tech Support for assistance.</li>
</ul>
<p class="PlainTextIndent">
<img src="../Resources/Images/USBportNotOK.png" />
</p>
<p>&#160;</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>

View File

@ -0,0 +1,134 @@
<?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="Connection Troubleshooting" 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>USB Resets BASIC Stamp</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>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="TFAQ.htm">Connection Troubleshooting</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">USB Resets BASIC Stamp</span>
</div>
<h1>USB Resets BASIC Stamp</h1>
<p class="PlainText">A BASIC Stamp connected to a PC via a USB can be reset by the USB connection. This can occur with USB-based boards, and with serial boards using the USB to Serial Adapter. Resets can happen when:</p>
<ul>
<li value="1">Connecting the board to the USB&#160;port.</li>
<li value="2">Disconnecting the board from the USB port, at either end of the USB&#160;cable. </li>
<li value="3">Connecting or disconnecting another USB device on a port adjacent to your BASIC Stamp board's USB port.</li>
</ul>
<p class="PlainText">The resets are caused by the PC's operating system checking to see if a new plug-and-play device (such as a mouse) was just connected. Disconnecting your board may cause a single reset. Reconnecting typically causes several resets in a row during the first few seconds.</p>
<p class="Tip" MadCap:autonum="Tip: &#160;"><span class="autonumber"><span class="TipSpan">Tip: &#160;</span></span>If you are using the USB&#160;to Serial Adapter, resets are easy to avoid. After connecting your board to your PC&#160;the first time, always disconnect and reconnect at the serial (9-pin) end of the USB to Serial Adapter. Leaving the Adapter connected to your PC keeps the virtual communications port open, preventing an unwanted reset.</p>
<h2>What BASIC Stamp Resets Do</h2>
<p class="PlainText"> Each time a BASIC Stamp is reset:</p>
<ul>
<li value="1">The program execution restarts from the beginning of code. </li>
<li value="2">All variables are set to their initial value (zero by default).</li>
</ul>
<p class="PlainText">Make sure to keep this in mind while working on your BASIC Stamp projects. Some programs have variable values that you do not want to lose when you disconnect or reconnect your board to the PC. This is common with datalogging activities.</p>
<h2>Datalogging Activities</h2>
<p class="PlainText">Some Stamps in Class activities use BASIC Stamp programs that log sensor data. Typically, the programmed board is disconnected from the PC, and taken someplace to record data with sensors. Afterward, the board is reconnected to the PC so the sensor data can be displayed on the Debug Terminal or saved to the PC&#160;for later use. </p>
<p class="PlainText">If a program only records sensor data in RAM as variable values, a USB-based board will lose that data when reconnecting to the PC because the BASIC Stamp will reset. So, USB-based boards must stay connected to the computer with programs that hold data RAM as variable values. </p>
<p class="PlainText">For USB-based boards and datalogging programs with applications where the board is disconnected and reconnected to the PC, the program should:</p>
<ul>
<li value="1">Save values to EEPROM</li>
<li value="2">Use a one-second delay at the beginning of the program.</li>
</ul>
<h2>Save Values to EEPROM&#160;using <span class="keyword_in_text">READ</span>, <span class="keyword_in_text">WRITE</span>,&#160;and <span class="keyword_in_text">DATA</span> <![CDATA[ ]]></h2>
<p class="PlainText">A simple solution for retaining values between resets is to save them in portions of the EEPROM program memory that are not used to store the actual program. Since the program is stored starting at the highest memory address, the low memory addresses are usually available for storing these values.</p>
<p class="PlainText">Use the <span class="keyword_in_text">WRITE</span> command to store values to addresses in BASIC Stamp EEPROM memory. Then, use <span class="keyword_in_text">READ</span> commands to retrieve those values from EEPROM, even after connecting it to the PC. You can build <span class="keyword_in_text">READ</span> commands into your main program, or even run a separate program to retrieve those values. </p>
<p class="PlainText"> Pre-initialized values can also be stored in EEPROM with the <span class="keyword_in_text">DATA</span> directive. </p>
<p class="PlainText" MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE">See the PBASIC Language Reference's <a href="../LanguageTopics/Commands/READ.htm" target="" title="" alt="" class="MCXref_0">READ</a>, <a href="../LanguageTopics/Commands/WRITE.htm" target="" title="" alt="" class="MCXref_0">WRITE</a>, and <a href="../LanguageTopics/Commands/DATA.htm" target="" title="" alt="" class="MCXref_0">DATA</a> commands for more information.</p>
<h2>Prevent Unexpected Bugs by Starting Your Programs with a One-Second Delay</h2>
<p class="PlainText">If your application requires reconnecting your USB board to the PC while the BASIC Stamp program is running, always add a one-second delay to the beginning of your program. Examples of one-second delays for BS2 modules include: <span class="code_in_text">PAUSE 1000</span> and <span class="code_in_text">FREQOUT Pin, 1000, <i>Frequency</i></span>. </p>
<p class="PlainText"> Adding a one-second delay at the start of your program could prevent these two unwanted behaviors:</p>
<ol>
<li value="1">If the BASIC Stamp transmits serial messages immediately after these resets, the operating system could mistake it for a serial mouse or other plug-and play-device.</li>
<li value="2"> If your program advances a value stored in EEPROM with each reset, the value will increase by one or more (ten is not uncommon) each time you connect your USB BASIC Stamp board to a PC.</li>
</ol>
<p class="PlainText">Again, the one-second delay at the very beginning of the program prevents these issues. Other ways to prevent them include leaving the power off until one second after you have connected your USB board, or pressing and holding the reset button for that time.</p>
<h2>Programs that Use the Reset Button</h2>
<p class="PlainText">Some programs use your board's Reset button to advance a value stored in EEPROM with each reset, or use the reset to trigger a "record" or "playback" mode.</p>
<p class="PlainText">For reset button applications with USB boards, it's best to design the application assuming the reset will happen when you disconnect and reconnect the board to the PC. Then, make sure to press and hold the reset button each time you disconnect or reconnect your board. This will ensure that a single, expected reset occurs, and not multiple resets as can happen with reconnection.</p>
<p class="PlainText">This example program uses a <span class="keyword_in_text">DATA</span> directive to pre-initialize the value stored by EEPROM address 0 to 255 when the program is loaded. The <span class="keyword_in_text">READ</span> command fetches this value from EEPROM and adds 1 to it. For a byte variable, 255 + 1 = 0 since 255 is the largest it can store, so it rolls over to zero. Taking the remainder of this <span class="code_in_text">eeVal/2</span> results in either 0 or 1. The <span class="keyword_in_text">WRITE</span> command stores this modified value back to EEPROM address 0. Then, the <span class="keyword_in_text">ON…GOTO…</span> command uses <span class="code_in_text">eeVal</span>, which stores 0 or 1. With each reset of the BASIC Stamp, the value advances from 0 to 1, to 0 again, and so on…</p><pre class="SICcode">
' {$STAMP BS2} ' Select BS2 as target module
' {$PBASIC 2.5} ' Select PBASIC 2.5 as language
eeVal VAR Byte ' EEPROM value variable
DATA 255 ' Pre-initialize EEPROM address 0 to 255
PAUSE 1000 ' Always wait 1 s before advancing EEPROM
READ 0, eeVal ' Fetch value from EEPROM address 0
eeval = eeVal + 1 ' Add 1 to eeVal
eeval = eeval // 2 ' Take remainder of eeVal / 2
WRITE 0, eeVal ' Write new result back to EEPROM
ON eeVal GOTO Playback, Record ' Use eeVal result to select routine
Playback: ' Playback label
DEBUG "Playing back..." ' Debug message indicating playback started
' Report logged data code here ' Your playback code goes here
END ' End, don't record after playback
Record: ' Record label
DEBUG "Recording..." ' Message indicates recording started
' Datalogging code here ' Your datalogging code goes here
END </pre>
<h2>Check for the PC Connection with <span class="keyword_in_text">SERIN</span></h2>
<p class="PlainText">Another useful strategy is to write a program routine that checks to see if the board is connected to the PC. Then the program can make decisions based on this information. For example, "if not connected, then log data” and “if connected, then display data.”</p>
<p class="PlainText">The code example below demonstrates one way to do this. It displays a message to press any key, then a <span class="keyword_in_text">SERIN</span> command that waits for a message from P16 (the programming port) for 2000 ms. If a character is typed into the Debug Terminals Transmit windowpane during that time, the program continues through the <span class="code_in_text">Playback</span> routine. If not, it jumps to the <span class="code_in_text">Record</span> routine.</p><pre class="SICcode">
' {$STAMP BS2} ' Select BS2 as target module
' {$PBASIC 2.5} ' Select PBASIC 2.5 as language
char VAR Byte ' Variable for getting character
PAUSE 1000 ' Always wait 1 s before serial transmit
DEBUG "Press any key...", CR ' User prompt
' Wait 2 s for character from Debug Terminals Transmit windowpane. Jump to
' Record label if no character received during that time. Continue to Playback
' label if character received.
SERIN 16, 84, 2000, Record, [char]
Playback: ' Playback label
DEBUG "Playing back..." ' Debug message indicating playback started
' Report logged data code here ' Your playback code goes here
END ' End, dont record after playback
Record: ' Record label
DEBUG "Recording..." ' Message indicates recording started
' Datalogging code here ' Your datalogging code goes here
END </pre>
<p class="PlainText" MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE">See the PBASIC Language Reference's <![CDATA[ ]]><a href="../LanguageTopics/Commands/SERIN.htm" target="" title="" alt="" class="MCXref_0">SERIN</a> command for more information.</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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Glossary" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../" MadCap:HelpSystemFileName="Default.xml">
<head>
<link href="SkinSupport/MadCap.css" rel="stylesheet" type="text/css" />
<title>Glossary</title>
<link href="Resources/Stylesheets/BSE_Help.css" rel="stylesheet" type="text/css" />
<script src="SkinSupport/MadCapAll.js" type="text/javascript">
</script>
</head>
<body style="background-color: #fafafa;">
<div id="GlossaryBody">
<div class="GlossaryPageEntry">
<div class="GlossaryPageTerm">
<a href="javascript:void(0);" class="GlossaryPageTerm" id="MCDropDownHotSpot_557459045_0" onclick="FMCDropDown( this ); FMCScrollToVisible( window, this.parentNode.parentNode ); return false;">My Term</a>
<a name="557459045_anchor1">
</a>
</div>
<div class="GlossaryPageDefinition" id="MCDropDownBody_557459045_0" style="display: none;">My definition</div>
</div>
</div>
<p>&#160;</p>
<script type="text/javascript" src="SkinSupport/MadCapBodyEnd.js">
</script>
</body>
</html>

View File

@ -0,0 +1,28 @@
CMCXmlParser._FilePathToXmlStringMap.Add(
'Glossary',
'<?xml version=\"1.0\" encoding=\"utf-8\"?>' +
'<html xmlns:MadCap=\"http://www.madcapsoftware.com/Schemas/MadCap.xsd\" MadCap:disableMasterStylesheet=\"true\" MadCap:tocPath=\"\" MadCap:InPreviewMode=\"false\" MadCap:PreloadImages=\"false\" MadCap:RuntimeFileType=\"Glossary\" MadCap:TargetType=\"WebHelp\" lang=\"en-us\" xml:lang=\"en-us\" MadCap:PathToHelpSystem=\"../\" MadCap:HelpSystemFileName=\"Default.xml\">' +
' <head>' +
' <link href=\"SkinSupport/MadCap.css\" rel=\"stylesheet\" type=\"text/css\" />' +
' <title>Glossary</title>' +
' <link href=\"Resources/Stylesheets/BSE_Help.css\" rel=\"stylesheet\" type=\"text/css\" />' +
' <script src=\"SkinSupport/MadCapAll.js\" type=\"text/javascript\">' +
' </script>' +
' </head>' +
' <body style=\"background-color: #fafafa;\">' +
' <div id=\"GlossaryBody\">' +
' <div class=\"GlossaryPageEntry\">' +
' <div class=\"GlossaryPageTerm\">' +
' <a href=\"javascript:void(0);\" class=\"GlossaryPageTerm\" id=\"MCDropDownHotSpot_557459045_0\" onclick=\"FMCDropDown( this ); FMCScrollToVisible( window, this.parentNode.parentNode ); return false;\">My Term</a>' +
' <a name=\"557459045_anchor1\">' +
' </a>' +
' </div>' +
' <div class=\"GlossaryPageDefinition\" id=\"MCDropDownBody_557459045_0\" style=\"display: none;\">My definition</div>' +
' </div>' +
' </div>' +
' <p>&#160;</p>' +
' <script type=\"text/javascript\" src=\"SkinSupport/MadCapBodyEnd.js\">' +
' </script>' +
' </body>' +
'</html>'
);

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Glossary" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../" MadCap:HelpSystemFileName="Default.xml">
<head>
<link href="SkinSupport/MadCap.css" rel="stylesheet" type="text/css" />
<title>Glossary</title>
<link href="Resources/Stylesheets/BSE_Help.css" rel="stylesheet" type="text/css" />
<script src="SkinSupport/MadCapAll.js" type="text/javascript">
</script>
</head>
<body style="background-color: #fafafa;">
<div id="GlossaryBody">
<div class="GlossaryPageEntry">
<div class="GlossaryPageTerm">
<a href="javascript:void(0);" class="GlossaryPageTerm" id="MCDropDownHotSpot_557459045_0" onclick="FMCDropDown( this ); FMCScrollToVisible( window, this.parentNode.parentNode ); return false;">My Term</a>
<a name="557459045_anchor1">
</a>
</div>
<div class="GlossaryPageDefinition" id="MCDropDownBody_557459045_0" style="display: none;">My definition</div>
</div>
</div>
<p>&#160;</p>
<script type="text/javascript" src="SkinSupport/MadCapBodyEnd.js">
</script>
</body>
</html>

View File

@ -0,0 +1,464 @@
<?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>Products</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>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><span class="MCBreadcrumbs">Products</span>
</div>
<h1>BASIC Stamp Comparison Chart</h1>
<p class="PlainText">BASIC Stamp microcontroller modules are like tiny single-board computers.&#160; Many projects that require an embedded system with some level of intelligence can use a BASIC Stamp module as the controller. Each BASIC Stamp module contains a PBASIC Interpreter chip, internal memory (RAM and EEPROM), a 5-volt regulator, a number of general-purpose I/O pins (TTL-level, 0-5 volts), and a set of built-in commands for math and I/O pin operations.&#160; </p>
<p class="PlainText">See the <a href="PinDesc.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">Pin Descriptions</a> <![CDATA[ ]]>and <a href="ConnSchematics.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">Connection Schematics</a> pages for more information.</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr align="center" bgcolor="CFCFCF">
<td width="12%">&#160;</td>
<td>
<img src="../Resources/Images/ClearBS1.png" />
</td>
<td>
<img src="../Resources/Images/ClearBS2.png" />
</td>
<td>
<img src="../Resources/Images/ClearBS2sx.png" />
</td>
<td>
<img src="../Resources/Images/ClearBS2e.png" />
</td>
<td>
<img src="../Resources/Images/ClearBS2p24.png" />
</td>
<td>
<img src="../Resources/Images/ClearBS2p40.png" />
</td>
<td>
<img src="../Resources/Images/ClearBS2pe.png" />
</td>
<td>
<img src="../Resources/Images/ClearBS2px.png" />
</td>
</tr>
<tr align="center">
<td width="10%" bgcolor="CFCFCF">Name</td>
<td>BS1
</td>
<td>BS2
</td>
<td>BS2e
</td>
<td>BS2sx
</td>
<td>BS2p24
</td>
<td>BS2p40
</td>
<td>BS2pe
</td>
<td>BS2px
</td>
</tr>
<tr align="center">
<td width="10%" bgcolor="CFCFCF">Features</td>
<td>Affordable yet capable, the original BASIC Stamp is perfect for smaller projects or tight spaces.</td>
<td>Ideal for beginners yet quite powerful, with a vast resource base and sample code. Core of the Stamps in Class program.</td>
<td>Perfect for those who have experience with the BASIC Stamp 2 and would like more variable and program space.</td>
<td>Supports the BS2 command set with more variable and program space, and 2.5 times the execution speed.</td>
<td>Special commands support I/O polling, character LCDs, and i2C and 1-Wire protocols. </td>
<td>All of the features of the BS2p, plus an additional bank of 16 I/O&#160;pins.</td>
<td>BS2p command set paired with lower power consumption and more memory for battery-powered data logging applications.</td>
<td>The fastest BASIC Stamp microcontroller supports the BS2p command set as well as special I/O configuration features.</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">Environment**
</td>
<td>
<p>-40 to +85 ºC</p>
<p> (-40 to +185 F)
</p>
</td>
<td>
<p>-40 to +85 ºC</p>
<p>(-40 to +185 F)
</p>
</td>
<td>
<p>-40 to +85 ºC</p>
<p>(-40 to +185 F)
</p>
</td>
<td>
<p>-40 to +85 ºC</p>
<p>(-40 to +185 F)
</p>
</td>
<td>
<p>-40 to +85 ºC</p>
<p>(-40 to +185 F)
</p>
</td>
<td>
<p>0 to +70 ºC</p>
<p>(32 to +158 ºF)
</p>
</td>
<td>
<p>0 to +70 ºC</p>
<p>(32 to +158 ºF)
</p>
</td>
<td>
<p>0 to +70 ºC</p>
<p>(32 to +158 ºF)
</p>
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">PBASIC Interpreter chip
</td>
<td>Microchip PIC'56
</td>
<td>Microchip PIC'57
</td>
<td>Ubicom SX28
</td>
<td>Ubicom SX28
</td>
<td>Ubicom SX48
</td>
<td>Ubicom SX48
</td>
<td>Ubicom SX48
</td>
<td>Ubicom SX48
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">Processor Speed
</td>
<td>4 MHz
</td>
<td>20 MHz
</td>
<td>20 MHz
</td>
<td>50 MHz
</td>
<td>20 MHz Turbo
</td>
<td>20 MHz Turbo
</td>
<td>8 MHz Turbo
</td>
<td>32 MHz Turbo
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">Program Execution Speed
</td>
<td>~2,000 instructions/sec.
</td>
<td>~4,000
instructions/sec.
</td>
<td>~4,000 instructions/sec.
</td>
<td>~10,000 instructions/sec.
</td>
<td>~12,000 instructions/sec.
</td>
<td>~12,000 instructions/sec.
</td>
<td>~6000 instructions/sec.
</td>
<td>~19,000 instructions/sec.
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">RAM Size
</td>
<td>16 Bytes (2 I/O, 14 Variable)
</td>
<td>32 Bytes
(6 I/O, 26 Variable)
</td>
<td>32 Bytes (6 I/O, 26 Variable)
</td>
<td>32 Bytes
(6 I/O, 26 Variable)
</td>
<td>38 Bytes
(12 I/O, 26 Variable)
</td>
<td>38 Bytes
(12 I/O, 26 Variable)
</td>
<td>38 Bytes
(12 I/O, 26 Variable)
</td>
<td>38 Bytes
(12 I/O, 26 Variable)
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">Scratchpad RAM
</td>
<td>N/A
</td>
<td>N/A
</td>
<td>64 Bytes
</td>
<td>64 Bytes
</td>
<td>128 Bytes
</td>
<td>128 Bytes
</td>
<td>128 Bytes
</td>
<td>128 Bytes
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">EEPROM (Program) Size
</td>
<td>256 Bytes,
~80 instructions
</td>
<td>2K Bytes,
~500 instructions
</td>
<td>8 x 2K Bytes,
~4,000 inst
</td>
<td>8 x 2K Bytes,
~4,000 instructions
</td>
<td>8 x 2K Bytes,
~4,000 instructions
</td>
<td>8 x 2K Bytes,
~4,000 instructions
</td>
<td>16 x 2K Bytes
(16 K for source)
</td>
<td>8 x 2K Bytes,
~4,000 instructions
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">Number of I/O Pins
</td>
<td>8
</td>
<td>16 + 2 Dedicated Serial
</td>
<td>16 + 2 Dedicated Serial
</td>
<td>16 + 2 Dedicated Serial
</td>
<td>16 + 2 Dedicated Serial
</td>
<td>32 + 2 Dedicated Serial
</td>
<td>16 + 2 Dedicated Serial
</td>
<td>16 + 2 Dedicated Serial
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">Regulated Voltage Requirements
</td>
<td>5 - 15 VDC </td>
<td>5 - 15 VDC </td>
<td>5 - 12 VDC </td>
<td>5 - 12 VDC </td>
<td>5 - 12 VDC </td>
<td>5 - 12 VDC </td>
<td>5 - 12 VDC </td>
<td>5 - 12 VDC </td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">Current Draw@ 5 volts
</td>
<td>1 mA Run,
25 µA Sleep
</td>
<td>3 mA Run,
50 µA Sleep
</td>
<td>25 mA Run,
200 µA Sleep
</td>
<td>60 mA Run,&#160;
500 µA Sleep
</td>
<td>40 mA Run,
350 µA Sleep
</td>
<td>40 mA Run,
350 µA Sleep
</td>
<td>15 mA Run,
150 µA Sleep
</td>
<td>55 mA Run,
450 µA Sleep
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">Source/Sink Current per I/O
</td>
<td>20 mA / 25 mA
</td>
<td>20 mA / 25 mA
</td>
<td>30 mA / 30 mA
</td>
<td>30 mA / 30 mA
</td>
<td>30 mA /
30 mA
</td>
<td>30 mA / 30 mA
</td>
<td>30 mA / 30 mA
</td>
<td>30 mA / 30 mA
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">Source/Sink
Current per unit
</td>
<td>40 mA / 50 mA
</td>
<td>40 mA / 50 mA
per 8 I/O pins
</td>
<td>60 mA / 60 mA
per 8 I/O pins
</td>
<td>60 mA / 60 mA
per 8 I/O pins
</td>
<td>60 mA / 60 mA
per 8 I/O pins
</td>
<td>60 mA /60 mA
per 8 I/O pins
</td>
<td>60 mA / 60 mA
per 8 I/O pins
</td>
<td>60 mA / 60 mA
per 8 I/O pins
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">PBASIC Commands*
</td>
<td>32
</td>
<td>42
</td>
<td>45
</td>
<td>45
</td>
<td>61
</td>
<td>61
</td>
<td>61
</td>
<td>63
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">PC Interface
</td>
<td>Serial
(w/BS1 Serial Adapter)
</td>
<td>Serial
(9600 baud)
</td>
<td>Serial (9600 baud)
</td>
<td>Serial (9600 baud)
</td>
<td>Serial (9600 baud)
</td>
<td>Serial
(9600 baud)
</td>
<td>Serial (9600 baud)
</td>
<td>Serial (19200 baud)
</td>
</tr>
<tr align="center">
<td bgcolor="CFCFCF" width="11%">Windows Text Editor Version
</td>
<td>Stampw.exe (v2.1 and up)
</td>
<td>Stampw.exe (v1.04 and up)
</td>
<td>Stampw.exe
(v1.096 and up)
</td>
<td>Stampw.exe
(v1.091 and up)
</td>
<td>Stampw.exe
(v1.1 and up)
</td>
<td>Stampw.exe
(v1.1 and up)
</td>
<td>Stampw.exe
(v1.33 and up)
</td>
<td>Stampw.exe
(v2.2 and up)
</td>
</tr>
</table>
<p class="PlainText">*PBASIC command count totals include PBASIC 2.5 on all BS2 models.</p>
<p class="PlainText">**Environment ratings may change with future hardware revisions; please <a href="../HomeTopics/Resources.htm#Contact_Parallax" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">Contact Parallax</a> for more information.</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>

View File

@ -0,0 +1,74 @@
<?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="BASIC Stamp Hardware" 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>Connection Schematics</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>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="BS_Chart.htm">BASIC Stamp Hardware</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Connection Schematics</span>
</div>
<h1>Connection Schematics</h1>
<p class="PlainText">We recommend using a Parallax development board and cable for programming BASIC Stamp modules. When these items are not available, you may create your own board by duplicating the following diagrams with your own circuits and cables.</p>
<p class="PlainText">Be very careful to follow these diagrams closely; it is quite common for programming problems with the BASIC Stamp to be a result of a poorly made custom cable or programming connections on your applications board. For example, with the programming connections for all the BS2 models, it is possible to reverse a couple of wires and still get positive results using some of the "connection" tests and yet you still will not be able to communicate with the BASIC Stamp. It is vital that you check your connections with a meter and verify the pin numbering to avoid problems like this.</p>
<h2>Programming and Run-time Communication Connections for all BS2 models</h2>
<p class="PlainText">Though it is not shown, power must be connected to the BASIC Stamp to program it. Note that the programming connections for the 40-pin BS2p40 are the same as for the 24-pin BS2 models.</p>
<p class="PlainText">
<img src="../Resources/Images/BS24connSchem.png" />
</p>
<p>&#160;</p>
<h2>BS1 Programming Connections with BS1 Serial Adapter</h2>
<p class="PlainText">Though it is not shown, power must be connected to the BS1 to program it.</p>
<p>
<img src="../Resources/Images/BS1connSchem.png" />
</p>
<p>&#160;</p>
<h3>BASIC Stamp 1 Serial Adapter</h3>
<p class="PlainText">Starting with Version 2.1, the BASIC Stamp Editor/Compiler supports programming
BASIC Stamp 1 modules through a standard serial connection using the adapter shown above and below. The adapter translates the voltage
and mechanical differences of the BS1 to be compatible with the serial port. For convenience, Parallax
manufactures the BASIC Stamp 1 Serial Adapter (#27111) that plugs into the end of a serial cable and connects
to the programming header of the BS1.</p>
<p>
<img src="../Resources/Images/BS1adapter.png" />
</p>
<p>&#160;</p>
<p class="PlainText">For those that would like to make their own adapter, the schematic is shown
below.</p>
<p>
<img src="../Resources/Images/BS1adapterSch.png" border="0" />
</p>
<p class="PlainText">&#160;</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>

View File

@ -0,0 +1,492 @@
<?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="BASIC Stamp Hardware" 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>Pin Descriptions</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>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="BS_Chart.htm">BASIC Stamp Hardware</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Pin Descriptions</span>
</div>
<h1>Pin Descriptions</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;">&#160;</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p class="PlainText">&#160;</p>
<h2>BASIC Stamp 1</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<col />
<col />
<col />
<col />
<tr bgcolor="CFCFCF">
<td rowspan="8" style="background-color: #ffffff;">
<img src="../Resources/Images/BS1pinout.png" />
</td>
<td width="15%">Pin
</td>
<td width="15%">Name
</td>
<td width="70%">Description
</td>
</tr>
<tr>
<td>
<p>1</p>
</td>
<td>
<p>VIN</p>
</td>
<td>
<p>Unregulated power in: accepts 5.5 - 15 VDC (6-40 VDC on BS1&#8209;IC rev. b), which is then internally regulated to 5 volts. May be left unconnected if 5 volts is applied to the VDD (+5V) pin.</p>
</td>
</tr>
<tr>
<td>
<p>2</p>
</td>
<td>
<p>VSS</p>
</td>
<td>
<p>System ground: connects to BS1 Serial Adapter ground for programming.</p>
</td>
</tr>
<tr>
<td>
<p>3</p>
</td>
<td>
<p>PCO</p>
</td>
<td>
<p>PC Out: 4800 baud serial output (TTL level) to PC.</p>
</td>
</tr>
<tr>
<td>
<p>4</p>
</td>
<td>
<p>PCI</p>
</td>
<td>
<p>PC In:&#160; 4800 baud serial input (TTL level) from PC.</p>
</td>
</tr>
<tr>
<td>
<p>5</p>
</td>
<td>
<p>VDD</p>
</td>
<td>
<p>5-volt DC input/output: (Also called +5V) if an unregulated voltage is applied to the VIN pin, then this pin will output 5 volts.&#160; If no voltage is applied to the VIN pin, then a regulated voltage between 4.5V and 5.5V should be applied to this pin.</p>
</td>
</tr>
<tr>
<td>
<p>6</p>
</td>
<td>
<p>RES</p>
</td>
<td>
<p>Reset input/output: goes low when power supply is less than approximately 4.2 volts, causing the BASIC Stamp to reset.&#160; Can be driven low to force a reset.&#160; This pin is internally pulled high and may be left disconnected if not needed.&#160; Do not drive high.</p>
</td>
</tr>
<tr>
<td>
<p>7-14</p>
</td>
<td>
<p>P0-P7</p>
</td>
<td>
<p>General-purpose I/O pins: each can sink 25 mA and source 20 mA. However, the total of all pins should not exceed 50 mA (sink) and 40 mA (source).</p>
</td>
</tr>
</table>
<h2>BASIC Stamp 2</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<col />
<col />
<col />
<col />
<tr bgcolor="CFCFCF">
<td rowspan="10" style="background-color: #ffffff;">
<img src="../Resources/Images/BS24_dimensions.png" />
</td>
<td width="15%">Pin
</td>
<td width="15%">Name
</td>
<td width="70%">Description
</td>
</tr>
<tr>
<td>1
</td>
<td>SOUT
</td>
<td>Serial Out: connects to PC serial port RX pin (DB9 pin 2 / DB25 pin 3) for programming.
</td>
</tr>
<tr>
<td>2
</td>
<td>SIN
</td>
<td>Serial In: connects to PC serial port TX pin (DB9 pin 3 / DB25 pin 2) for programming.
</td>
</tr>
<tr>
<td>3
</td>
<td>ATN
</td>
<td>Attention: connects to PC serial port DTR pin (DB9 pin 4 / DB25 pin 20) for programming.
</td>
</tr>
<tr>
<td>4
</td>
<td>VSS
</td>
<td>System ground: (same as pin 23) connects to PC serial port GND pin (DB9 pin 5 / DB25 pin 7) for programming.
</td>
</tr>
<tr>
<td>5-20
</td>
<td>P0-P15
</td>
<td>General-purpose I/O pins: each can sink 25 mA and source 20 mA. However, the total of all pins should not exceed 50 mA (sink) and 40 mA (source) if using the internal 5-volt regulator.&#160; The total per 8-pin groups (P0 P7 or P8 15) should not exceed 50 mA (sink) and 40 mA (source) if using an external 5-volt regulator.
</td>
</tr>
<tr>
<td>21
</td>
<td>VDD
</td>
<td>5-volt DC input/output: if an unregulated voltage is applied to the VIN pin, then this pin will output 5 volts.&#160; If no voltage is applied to the VIN pin, then a regulated voltage between 4.5V and 5.5V should be applied to this pin.
</td>
</tr>
<tr>
<td>22
</td>
<td>RES
</td>
<td>Reset input/output: goes low when power supply is less than approximately 4.2 volts, causing the BASIC Stamp to reset.&#160; Can be driven low to force a reset.&#160; This pin is internally pulled high and may be left disconnected if not needed.&#160; Do not drive high.
</td>
</tr>
<tr>
<td>23
</td>
<td>VSS
</td>
<td>System ground: (same as pin 4) connects to power supplys ground (GND) terminal.
</td>
</tr>
<tr>
<td>24
</td>
<td>VIN
</td>
<td>Unregulated power in: accepts 5.5 - 15 VDC (6-40 VDC on BS2-IC Rev. e, f, and g), which is then internally regulated to 5 volts. Must be left unconnected if 5 volts is applied to the VDD (+5V) pin.
</td>
</tr>
</table>
<h2>BASIC Stamp 2e, 2sx, 2p, 2pe, 2px</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<col />
<col />
<col />
<col />
<tr bgcolor="CFCFCF">
<td rowspan="10" style="background-color: #ffffff;">
<img src="../Resources/Images/BS24_dimensions.png" />
</td>
<td width="15%">Pin
</td>
<td width="15%">Name
</td>
<td width="70%">Description
</td>
</tr>
<tr>
<td>
<p>1</p>
</td>
<td>
<p>SOUT</p>
</td>
<td>
<p>Serial Out: connects to PC serial port RX pin (DB9 pin 2 / DB25 pin 3) for programming.</p>
</td>
</tr>
<tr>
<td>
<p>2</p>
</td>
<td>
<p>SIN</p>
</td>
<td>
<p>Serial In: connects to PC serial port TX pin (DB9 pin 3 / DB25 pin 2) for programming.</p>
</td>
</tr>
<tr>
<td>
<p>3</p>
</td>
<td>
<p>ATN</p>
</td>
<td>
<p>Attention: connects to PC serial port DTR pin (DB9 pin 4 / DB25 pin 20) for programming.</p>
</td>
</tr>
<tr>
<td>
<p>4</p>
</td>
<td>
<p>VSS</p>
</td>
<td>
<p>System ground: (same as pin 23), connects to PC serial port GND pin (DB9 pin 5 / DB25 pin 7) for programming.</p>
</td>
</tr>
<tr>
<td>
<p>5-20</p>
</td>
<td>
<p>P0-P15</p>
</td>
<td>
<p>General-purpose I/O pins: each can source and sink 30 mA. However, the total of all pins should not exceed 75 mA (source or sink) if using the internal 5-volt regulator.&#160; The total per 8-pin groups P0 P7 or P8 15 should not exceed 60 mA (source or sink) if using an external 5-volt regulator.</p>
</td>
</tr>
<tr>
<td>
<p>21</p>
</td>
<td>
<p>VDD</p>
</td>
<td>
<p>5-volt DC input/output: if an unregulated voltage is applied to the VIN pin, then this pin will output 5 volts.&#160; If no voltage is applied to the VIN pin, then a regulated voltage between 4.5V and 5.5V should be applied to this pin.</p>
</td>
</tr>
<tr>
<td>
<p>22 </p>
</td>
<td>
<p>RES</p>
</td>
<td>
<p>Reset input/output: goes low when power supply is less than approximately 4.2 volts, causing the BASIC Stamp to reset.&#160; Can be driven low to force a reset.&#160; This pin is internally pulled high and may be left disconnected if not needed.&#160; Do not drive high.</p>
</td>
</tr>
<tr>
<td>
<p>23 </p>
</td>
<td>
<p>VSS</p>
</td>
<td>
<p>System ground: (same as pin 4) connects to power supplys ground (GND) terminal.</p>
</td>
</tr>
<tr>
<td>
<p>24 </p>
</td>
<td>
<p>VIN</p>
</td>
<td>
<p>Unregulated power in: accepts 5.5 - 12 VDC (7.5 recommended), which is then internally regulated to 5 volts. Must be left unconnected if 5 volts is applied to the VDD (+5V) pin.</p>
</td>
</tr>
</table>
<h2>BASIC Stamp 2p40</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<col />
<col />
<col />
<col />
<tr bgcolor="CFCFCF">
<td rowspan="11" style="background-color: #ffffff;">
<img src="../Resources/Images/BS40_dimensions.png" />
</td>
<td width="15%">Pin
</td>
<td width="15%">Name
</td>
<td width="70%">Description
</td>
</tr>
<tr>
<td>
<p>1</p>
</td>
<td>
<p>SOUT</p>
</td>
<td>
<p>Serial Out: connects to PC serial port RX pin (DB9 pin 2 / DB25 pin 3) for programming.</p>
</td>
</tr>
<tr>
<td>
<p>2</p>
</td>
<td>
<p>SIN</p>
</td>
<td>
<p>Serial In: connects to PC serial port TX pin (DB9 pin 3 / DB25 pin 2) for programming.</p>
</td>
</tr>
<tr>
<td>
<p>3</p>
</td>
<td>
<p>ATN</p>
</td>
<td>
<p>Attention: connects to PC serial port DTR pin (DB9 pin 4 / DB25 pin 20) for programming.</p>
</td>
</tr>
<tr>
<td>
<p>4</p>
</td>
<td>
<p>VSS</p>
</td>
<td>
<p>System ground: (same as pin 39) connects to PC serial port GND pin (DB9 pin 5 / DB25 pin 7) for programming.</p>
</td>
</tr>
<tr>
<td>
<p>5-20</p>
</td>
<td>
<p>P0-P15</p>
</td>
<td>
<p>General-purpose I/O pins: each can source and sink 30 mA. However, the total of all pins (including X0-X15) should not exceed 75 mA (source or sink) if using the internal 5-volt regulator.&#160; The total per 8-pin groups (P0 P7, P8 15, X0 X7 or X8 X15)&#160; should not exceed 100 mA (source or sink) if using an external 5-volt regulator.</p>
</td>
</tr>
<tr>
<td>
<p>21-36</p>
</td>
<td>
<p>X0-X15</p>
</td>
<td>
<p>Auxiliary Bank of General-purpose I/O pins: each can source and sink 30 mA. However, the total of all pins (including P0 P15) should not exceed 75 mA (source or sink) if using the internal 5-volt regulator.&#160; The total per 8-pin groups (P0 P7, P8 15, X0 X7 or X8 X15) should not exceed 60 mA (source or sink) if using an external 5-volt regulator.</p>
</td>
</tr>
<tr>
<td>
<p>37</p>
</td>
<td>
<p>VDD</p>
</td>
<td>
<p>5-volt DC input/output: if an unregulated voltage is applied to the VIN pin, then this pin will output 5 volts.&#160; If no voltage is applied to the VIN pin, then a regulated voltage between 4.5V and 5.5V should be applied to this pin.</p>
</td>
</tr>
<tr>
<td>
<p>38</p>
</td>
<td>
<p>RES</p>
</td>
<td>
<p>Reset input/output: goes low when power supply is less than approximately 4.2 volts, causing the BASIC Stamp to reset.&#160; Can be driven low to force a reset.&#160; This pin is internally pulled high and may be left disconnected if not needed.&#160; Do not drive high.</p>
</td>
</tr>
<tr>
<td>
<p>39</p>
</td>
<td>
<p>VSS</p>
</td>
<td>
<p>System ground: (same as pin 4) connects to power supplys ground (GND) terminal.</p>
</td>
</tr>
<tr>
<td>
<p>40</p>
</td>
<td>
<p>VIN</p>
</td>
<td>
<p>Unregulated power in: accepts 5.5 - 12 VDC (7.5 recommended), which is then internally regulated to 5 volts. Must be left unconnected if 5 volts is applied to the VDD (+5V) pin.</p>
</td>
</tr>
</table>
<p>&#160;</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>

View File

@ -0,0 +1,62 @@
<?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="Welcome" 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>Fine Print</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>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="HomePage.htm">Welcome</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Fine Print</span>
</div>
<h1>Fine Print</h1>
<h2><a name="Copyrigh"></a>Copyright</h2>
<p class="PlainText">This <span class="ContactInfoProjectName">BASIC Stamp Help</span> is copyright © <span class="SystemShortDate">8/8/2012</span> by <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
<p class="PlainText">No site license or end user license is required to use this software. By downloading or otherwise obtaining a copy of this software, you agree that it is to be used exclusively with Parallax BASIC Stamp products. Any other uses are not permitted and may represent a violation of Parallax copyrights, legally punishable according to Federal copyright or intellectual property laws. Any duplication of this documentation for commercial uses is expressly prohibited <span class="ContactInfoCompanyName">Parallax Inc.</span> Duplication for educational use is permitted subject to the following Conditions of Duplication: <span class="ContactInfoCompanyName">Parallax Inc.</span> grants the user a conditional right to download, duplicate, and distribute the Help content without Parallax's permission, under the following conditions: the material, or any portion thereof, may not be duplicated for commercial use; it may be duplicated only for educational purposes when used solely in conjunction with Parallax BASIC Stamp products, and the user may recover from the student only the cost of duplication.</p>
<p class="PlainText">Contact <a href="mailto:editor@parallax.com?subject=BASIC Stamp Editor Help Copyright">editor@parallax.com</a>.</p>
<h2>Trademark Information</h2>
<p class="PlainText">BASIC Stamp, Board of Education, and Boe-Bot are federally registered trademarks of <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
<p class="PlainText">PBASIC, Parallax and the Parallax logo are trademarks of <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
<p class="PlainText">Windows is a registered trademark of Microsoft Corporation.</p>
<p class="PlainText">I<sup>2</sup>C is a registered trademark of Philips Corporation.</p>
<p class="PlainText">1-Wire is a registered trademark of Maxim/Dallas Semiconductor. </p>
<p class="PlainText">Other brand and product names are trademarks or registered trademarks of
their respective holders.</p>
<h2>Disclaimer of Liability</h2>
<p class="PlainText"><span class="ContactInfoCompanyName">Parallax Inc.</span> is not responsible for special, incidental, or consequential
damages resulting from any breach of warranty, or under any legal theory,
including lost profits, downtime, goodwill, damage to or replacement of equipment
or property, and any costs of recovering, reprogramming, or reproducing any data
stored in or used with Parallax products. <span class="ContactInfoCompanyName">Parallax Inc.</span> is also not responsible for any personal damage, including that to life and health, resulting from use of any Parallax products. You take full responsibility for your BASIC Stamp application, no matter how life-threatening it may be.</p>
<div class="Col2">
<div class="MasterFoot">
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="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>

View File

@ -0,0 +1,56 @@
<?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="5" MadCap:lastHeight="47" MadCap:lastWidth="590" MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE,BSEconditions.BSHweb-PBASIC-EXCLUDE,BSEconditions.BSHweb-SIC-EXCLUDE,BSEconditions.BSHweb-Connect-EXCLUDE" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" class="HomePage" MadCap:PathToHelpSystem="../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
<head><title>Welcome</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>
<div class="background">
<p style="text-align: center;">&#160;</p>
<p style="text-align: center;"><a href="http://www.parallax.com/" target="_blank" title="Open Parallax website in new window" alt="Open Parallax website in new window"><img src="../Resources/Images/ParallaxLogo-Chrome.png" /></a>
</p>
<p style="text-align: center;">
<img src="../Resources/Images/Clear_8_modules.png" style="padding-left: 0px;padding-top: 30px;padding-bottom: 30px;border-left-style: none;border-right-style: none;border-top-style: none;border-bottom-style: none;" />
</p>
<h1 style="text-align: center;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span></h1>
<p style="text-align: center;">&#160;&#160;<a href="FinePrint.htm#Copyrigh">Copyright</a> © <span class="ContactInfoCompanyName">Parallax Inc.</span> <![CDATA[ ]]><span class="SystemShortDate">8/8/2012</span></p>
<p class="cheddarline">&#160;</p>
<div class="Col2">
<p><a href="WhatsNew.htm" target="" title="" alt="" class="MCXref_0">What's New</a>
</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
</div>
<div class="Col2">
<p style="text-align: right;"><a href="../StartTopics/Start.htm" target="" title="" alt="" class="MCXref_0">Getting Started with Stamps in Class</a>
</p>
<p style="text-align: right;"> <![CDATA[ ]]></p>
<p style="text-align: right;">&#160;</p>
<p style="text-align: right;">&#160;</p>
<p style="text-align: right;">&#160;</p>
</div>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
</div>
<script type="text/javascript" src="../SkinSupport/MadCapBodyEnd.js">
</script>
</body>
</html>

View File

@ -0,0 +1,84 @@
<?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="Welcome" 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>Resources</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>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="HomePage.htm">Welcome</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Resources</span>
</div>
<h1>Resources</h1>
<h3 MadCap:conditions="BSEconditions.BSHweb-Connect-EXCLUDE,BSEconditions.BSHweb-PBASIC-EXCLUDE,BSEconditions.BSHweb-SIC-EXCLUDE,BSEconditions.BSEWebHelp (Primary)-INCLUDE">PDF files included with the BASIC Stamp Editor</h3>
<ul MadCap:conditions="BSEconditions.BSHweb-Connect-EXCLUDE,BSEconditions.BSHweb-PBASIC-EXCLUDE,BSEconditions.BSHweb-SIC-EXCLUDE,BSEconditions.BSEWebHelp (Primary)-INCLUDE">
<li value="1"><a href="../../../BASIC Stamp Manual v2.2.pdf" target="_blank" title="Open PDF in new window" alt="Open PDF in new window">BASIC Stamp Manual</a>
</li>
<li value="2"><a href="../../../What's A Microcontroller v3.0.pdf" target="_blank" title="Open PDF in new window" alt="Open PDF in new window">What's a Microcontroller? Tutorial</a>
</li>
</ul>
<h3>Additional Online Downloads &amp; Resources</h3>
<ul>
<li value="1">BASIC Stamp information: <a href="http://www.parallax.com/basicstamp" target="_blank" title="Open website in new window" alt="Open website in new window">www.parallax.com/basicstamp</a> <![CDATA[ ]]></li>
<li value="2">Latest Version of this software: <a href="http://www.parallax.com/basicstampsoftware" target="_blank" title="Open website in new window" alt="Open website in new window">www.parallax.com/basicstampsoftware</a></li>
<li value="3">Parallax Education and DIY tutorials: <a href="http://learn.parallax.com/" target="_blank">learn.parallax.com</a></li>
<li value="4">Parallax Forums: <a href="http://forums.parallax.com/forums/" title="Open website in new window" alt="Open website in new window" target="_blank">forums.parallax.com</a></li>
</ul>
<h2><a name="Contact_Parallax"></a>Contact Parallax</h2>
<h3>By telephone: <![CDATA[ ]]></h3>
<ul>
<li value="1">Technical Support: <span class="ContactInfoPhoneSupport">888-997-8267</span></li>
<li value="2">Sales: <span class="ContactInfoPhoneSales">888-512-1024</span></li>
<li value="3">Outside Continental US: <span class="ContactInfoPhoneMain">916-624-8333</span></li>
<li value="4">Fax: <span class="ContactInfoPhoneFax">916-624-8003</span></li>
</ul>
<h3>By email:</h3>
<ul>
<li value="1"><a href="mailto:support@parallax.com" title="Send email to Support" alt="Send email to Support">support@parallax.com</a>
</li>
<li value="2"><a href="mailto:sales@parallax.com" title="Send email to Sales" alt="Send email to Sales">sales@parallax.com</a>
</li>
<li value="3"><a href="mailto:editor@parallax.com?subject=BASIC Stamp Editor Help" title="Send email to Editor" alt="Send email to Editor">editor@parallax.com</a>
</li>
</ul>
<h3>Mailing Address:</h3>
<p class="PlainTextIndent"><span class="ContactInfoCompanyName">Parallax Inc.</span>
<br /><span class="ContactInfoAddrStreet">599 Menlo Drive</span>
<br /><span class="ContactInfoAddrCityStateZip">Rocklin, CA 95765</span>
<br /><span class="ContactInfoAddrCountry">USA</span>
</p>
<p>&#160;</p>
<p>For Copyright, Trademark, and Disclaimer of Liability, please read the <a href="FinePrint.htm" target="" title="" alt="" class="MCXref_0">Fine Print</a>.</p>
<p>&#160;</p>
<div class="Col2">
<div class="MasterFoot">
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="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>

View File

@ -0,0 +1,135 @@
<?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="Welcome" 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>What's New</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>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="HomePage.htm">Welcome</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">What's New</span>
</div>
<h1>What's New</h1>
<p class="PlainText">Each release of <span class="ContactInfoProjectName">BASIC Stamp Help</span> and the <span class="ContactInfoSoftwareName">BASIC Stamp Editor</span> software can include new or enhanced items that may not be readily apparent. This topic is a summary of these notable changes.</p>
<p class="PlainText">Note that these changes are also reflected in the online version of the Help files. The Online Help is divided into three sections:</p>
<ul>
<li style="font-style: normal;" value="1"><a href="http://www.parallax.com/portals/0/help/BASICStamp/Start/" target="_blank" title="Open online Help in new window" alt="Open online Help in new window">BASIC Stamp - Getting Started Help</a>
</li>
<li style="font-style: normal;" value="2"><a href="http://www.parallax.com/portals/0/help/BASICStamp/Connect/" target="_blank" title="Open online Help in new window" alt="Open online Help in new window">BASIC Stamp - Connection Help</a>
</li>
<li style="font-style: normal;" value="3"><a href="http://www.parallax.com/portals/0/help/BASICStamp/PBASIC/" target="_blank" title="Open online Help in new window" alt="Open online Help in new window">BASIC Stamp - PBASIC Language Help</a>
</li>
</ul>
<p style="font-style: normal;">&#160;</p>
<h2><span class="ContactInfoProjectName">BASIC Stamp Help</span>
</h2>
<h3><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]><span style="font-size: 8pt;">(Released with <span class="ContactInfoSoftwareName">BASIC Stamp Editor</span> Software <span class="ContactInfoIDEversionShort">v2.5.3</span>)</span> <![CDATA[  ]]></h3>
<ul>
<li style="font-style: normal;" value="1">A <a href="../LanguageTopics/Commands/SLEEP.htm#Sleep" target="" title="" alt="" class="MCXref_0">Sleep Units vs Sleep Resolution</a> section with a table and equations was added to the <span class="keyword_in_text">SLEEP</span> command explanation.</li>
<li style="font-style: normal;" value="2">Updated explanations of watchdog timer and power conserving commands for <a href="../LanguageTopics/Commands/END.htm" target="" title="" alt="" class="MCXref_0">END</a>, <a href="../LanguageTopics/Commands/NAP.htm">NAP</a>, <a href="../LanguageTopics/Commands/POLLWAIT.htm">POLLWAIT</a>, and <a href="../LanguageTopics/Commands/SLEEP.htm">SLEEP</a>&#160;commands.</li>
<li style="font-style: normal;" value="3">Added USB 3.0 Caution to all the board connection topics in <a href="../StartTopics/Start.htm" target="" title="" alt="" class="MCXref_0">Getting Started with Stamps in Class</a>, and to <a href="../FAQTopics/TFAQ.htm" target="" title="" alt="" class="MCXref_0">Connection Troubleshooting</a>.</li>
<li style="font-style: normal;" value="4">Various small misspellings were corrected.</li>
</ul>
<h3>Version 2.5.3 <span style="font-size: 8pt;">(Released on web only)</span> <![CDATA[  ]]></h3>
<ul>
<li style="font-style: normal;" value="1">The hardware portion of the <a href="../StartTopics/Start.htm" target="" title="" alt="" class="MCXref_0">Getting Started with Stamps in Class</a> section was expanded to support the <a href="../StartTopics/HWB-usb.htm" target="" title="" alt="" class="MCXref_0">HomeWork Board - USB&#160;</a>. </li>
<li style="font-style: normal;" value="2">A note about USB Boards and Resets was added at the bottom of the <a href="../StartTopics/HWB-usb.htm" target="" title="" alt="" class="MCXref_0">HomeWork Board - USB&#160;</a> and <a href="../StartTopics/BOE-usb.htm" target="" title="" alt="" class="MCXref_0">Board of Education - USB</a> topics. It links to the next item.</li>
<li style="font-style: normal;" value="3">An extensive article <a href="../FAQTopics/UsbBoardResets.htm" target="" title="" alt="" class="MCXref_0">USB Resets BASIC Stamp</a> was added, with explanations and programming tips.</li>
</ul>
<h3>Version 2.5.2 <span style="font-size: 8pt;">(Released with <span class="ContactInfoSoftwareName">BASIC Stamp Editor</span> Software v2.5.2)</span> <![CDATA[  ]]></h3>
<ul>
<li style="font-style: normal;" value="1">No updates to help other than this page to reflect new version of software.</li>
</ul>
<h3>Version 2.5.1 <span style="font-size: 8pt;">(Released with <span class="ContactInfoSoftwareName">BASIC Stamp Editor</span> Software v2.5.1)</span>&#160;</h3>
<ul>
<li value="1">Updated <a href="../FAQTopics/TFAQ.htm" target="" title="" alt="" class="MCXref_0">Connection Troubleshooting</a> system to direct user to <a href="../FAQTopics/LatencyTimer.htm" target="" title="" alt="" class="MCXref_0">Latency Timer Settings</a> if experiencing intermittent programming connection.</li>
<li style="font-style: normal;" value="2">Corrected some tiny text errors.</li>
</ul>
<h3>Version 2.5 <![CDATA[ ]]><span style="font-size: 8pt;">(Released with BASIC Stamp Editor Software v2.5)</span></h3>
<p class="PlainText">This is a much-improved help system that coincides with the release of <i>What's A Microcontroller? v3.0</i>.</p>
<ul>
<li style="font-style: normal;" value="1">Now includes a <a href="../StartTopics/Start.htm" target="" title="" alt="" class="MCXref_0">Getting Started with Stamps in Class</a> section to assist new users following Stamps in Class tutorials such as <i>What's a Microcontroller?</i> and <i>Robotics with the Boe-Bot</i>.</li>
<li style="font-style: normal;" value="2">Features step-by-step <a href="../FAQTopics/TFAQ.htm" target="" title="" alt="" class="MCXref_0">Connection Troubleshooting</a> details to help resolve BASIC&#160;Stamp setup issues.</li>
<li style="font-style: normal;" value="3"><a href="../HardwareTopics/BS_Chart.htm">BASIC&#160;Stamp Hardware</a> details now include feature comparisons and notes about hardware functions.</li>
<li style="font-style: normal;" value="4">Tips are now included for those who want to <a href="../LanguageTopics/Reference/Adapt.htm" target="" title="" alt="" class="MCXref_0">Adapt BS2 Code to Other Models</a>.</li>
<li style="font-style: normal;" value="5">Improvements were made to discussions of <a href="../LanguageTopics/Reference/Operators.htm" target="" title="" alt="" class="MCXref_0">PBASIC Operators</a>, <a href="../LanguageTopics/Reference/MemoryOrg.htm" target="" title="" alt="" class="MCXref_0">Memory Organization </a>, <a href="../LanguageTopics/Reference/Variables.htm" target="" title="" alt="" class="MCXref_0">Variables</a>, and <a href="../LanguageTopics/Reference/Directives.htm" target="" title="" alt="" class="MCXref_0">Compiler Directives</a>.</li>
<li style="font-style: normal;" value="6">Contains many enhancements to aid navigation, save favorite topics for later, search for information, and find additional BASIC&#160;Stamp resources.</li>
<li style="font-style: normal;" value="7">Published in Web Help format (.htm).</li>
</ul>
<h3>Versions 1.0 - 1.4</h3>
<p class="PlainText">The first releases of <span class="ContactInfoProjectName">BASIC Stamp Help</span> in compiled HTML help format (.chm).</p>
<p>&#160;</p>
<p>&#160;</p>
<h2><span class="ContactInfoSoftwareName">BASIC Stamp Editor</span> Software</h2>
<h3>Version 2.5.3</h3>
<h4>General</h4>
<ul>
<li value="1">Updated installer to include BASIC Stamp Help v2.5.4 and updated a few related source code examples.</li>
<li value="2">Updated BASIC Stamp Editor to include the adjusted source code examples in module libraries.</li>
</ul>
<h3>Version 2.5.2</h3>
<h4>Bug Fix</h4>
<ul>
<li value="1">Fixed bug that was preventing the Generate Object Code feature from properly extracting the Stamp Loader.</li>
</ul>
<p>&#160;</p>
<h3>Version 2.5.1</h3>
<h4>Bug Fix</h4>
<ul>
<li value="1">Fixed bug causing Edit Tips button to fail on the Tip of the Day window.</li>
<li value="2">Fixed bug causing copy/paste operations to fail from BASIC&#160;Stamp Help.</li>
</ul>
<h4>General</h4>
<ul>
<li value="1">Updated error 305 - "Hardware communication failure! Check serial cable and power supply" to use the term "programming cable" instead of "serial cable" since it applies to both serial cables and USB cables.</li>
<li value="2">Fixed misspelled word "occurrence" in error and status messages.</li>
<li value="3">Updated Run menu to include function key shortcuts instead of Ctrl+ shortcuts. NOTE: Ctrl+ shortcuts still remain in effect.</li>
<li value="4">Added serial search rule to automatically exclude the PropScope from serial port search operations.</li>
</ul>
<h4>Misc</h4>
<ul>
<li value="1">Updated the included Parallax USB&#160;Driver Installer to <span>v2.08.02</span>.</li>
</ul>
<p>&#160;</p>
<h3>Version 2.5</h3>
<h4>General</h4>
<ul>
<li value="1">Enhanced Help menu to include links to new BASIC Stamp Help, <i>BASIC Stamp Manual v2.2</i>, and <i>What's A Microcontroller? v3.0</i> text.</li>
<li value="2">Updated a number of example BASIC Stamp programs.</li>
</ul>
<h4>Misc</h4>
<ul>
<li value="1">Replaced USB Drivers with Parallax USB&#160;Driver Installer v2.04.16 (R2).</li>
</ul>
<div class="Col2">
<div class="MasterFoot">
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="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>

View File

@ -0,0 +1,121 @@
<?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>AUXIO</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">AUXIO</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" /> (BS2p40)</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/AuMainIotermEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">AUXIO / MAINIO / IOTERM Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">AUXIO</span></p>
<h2>Function</h2>
<p class="PlainText">Switch from control of main I/O pins</p>
<h2>Quick Facts</h2>
<table cellpadding="4" cellspacing="0" border="1" style="caption-side: top;width: 100%;">
<col />
<col />
<tr bgcolor="#CFCFCF">
<td width="15%" align="center">&#160;</td>
<td width="85%" align="center">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">I/O Pin IDs</td>
<td>0 - 15 (just like main I/O, but after AUXIO command, all references affect
physical pins 21 - 36).</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td>
<p>Command is accepted by the 24-pin BS2p, BS2pe, and BS2px, but only the 40-pin BS2p40 gives access to the auxiliary I/O pins.</p>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td>
<p colspan="2" align="center"><a href="MAINIO.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">MAINIO</a>, <a href="IOTERM.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">IOTERM</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The BS2p, BS2pe, and BS2px is available as a 24-pin module that is pin-compatible
with the BS2, BS2e, and BS2sx. Also available is a 40-pin module called the BS2p40
with an additional 16 I/O pins (for a total of 32). The BS2p40's extra, or
<i>auxiliary</i>, I/O pins can be accessed in the same manner as the main I/O pins
(by using the IDs 0 to 15) but only after issuing an <span class="keyword_in_text">AUXIO</span> or <span class="keyword_in_text">IOTERM 1</span> command. The <span class="keyword_in_text">AUXIO</span> command causes the BASIC
Stamp to affect the auxiliary I/O pins instead of the main I/O pins in all further
code until the <span class="keyword_in_text">MAINIO</span> or <span class="keyword_in_text">IOTERM 0</span> command is reached, or the BASIC Stamp
is reset or power-cycled. <span class="keyword_in_text"> AUXIO</span> is also used when setting the DIRS register
for auxiliary IO pins on the BS2p40.</p>
<p class="PlainText">The following example illustrates this:</p><pre class="BScode" xml:space="preserve">
Main:
HIGH 0
AUXIO
LOW 0
</pre>
<p class="PlainText">The first line of the above example will set I/O pin 0 of the main I/O pins
(physical pin 5) high. Afterward, the <span class="keyword_in_text">AUXIO</span> command tells the BASIC
Stamp that all commands following it should affect the auxiliary I/O pins.
The following <span class="keyword_in_text">LOW</span> command will set I/O pin 0 of the auxiliary I/O pins
(physical pin 21) low.&#160;</p>
<p class="PlainText">Note that the main I/O and auxiliary I/O pins are independent of each other;
the states of the main I/O pins remain unchanged while the program affects the
auxiliary I/O pins, and vice versa.</p>
<h3> Reducing Power Consumption </h3>
<p class="PlainText">When the BASIC Stamp is reset all RAM variables, including DIRS and OUTS are
cleared to zero. This goes for main and auxiliary pins. On the BS2p24,
BS2pe, and BS2px the auxiliary pins from the interpreter chip are not connected to
physical IO pins on the BASIC Stamp. While not connected to anything, these
pins do have pull-ups activated, effectively connecting them to Vdd. After
reset, reading the auxiliary pins from a BS2p24, BS2pe, or BS2px will return all 1s.
For lowest possible current consumption where required, you may set the BS2p24,
BS2pe, and BS2px auxiliary pins as output low.</p><pre class="BScode" xml:space="preserve">
Setup:
AUXIO ' select AUXIO pins
OUTS = $0000 ' force outputs low
DIRS = $FFFF ' make (unconnected) pins outputs
MAINIO ' back to MAINIO group
</pre>
<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>

View File

@ -0,0 +1,107 @@
<?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>BRANCH</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">BRANCH</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/BranchEx.htm" target="" title="" alt="" class="MCXref_0">BRANCH Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax <img align="absmiddle" src="../../graphics/mini_1.gif" />:
<span class="keyword_in_text">BRANCH</span> <![CDATA[ ]]><i>Offset<u style="font-style: normal; text-decoration: none;">, (</u>Address1</i>,<i> Address2</i>, ..<i>.AddressN</i>)</p>
<p class="PlainText">Syntax <img align="absmiddle" src="../../graphics/mini_2.gif" />: <span class="keyword_in_text">BRANCH</span> <![CDATA[ ]]><i>Offset,</i> [<i>Address1</i>,<i> Address2</i>, ...<i>AddressN</i>]</p>
<h2>Function</h2>
<p class="PlainText">Go to the <i>Address</i> specified by <i>Offset</i> (if in range).</p>
<ul>
<li value="1"><b><i>Offset</i></b> is a variable/constant/expression* (0 - 255) that
specifies the index of the address, in the list, to branch to (0 - N).</li>
<li value="2"><b><i>Addresses</i></b> are labels that specify where to go. <span class="keyword_in_text">BRANCH </span>will ignore any list entries beyond offset 255.</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>
<td align="center" width="150" bgcolor="#CFCFCF">&#160;</td>
<td align="center" width="40%" bgcolor="#CFCFCF">BS1</td>
<td align="center" width="40%" bgcolor="#CFCFCF">BS2 Family</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Limit of <i>Address</i> entries</td>
<td align="center">Limited only by memory</td>
<td align="center">256</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center">None</td>
<td align="center">
<p align="center"><a href="ON_GOTO.htm" target="" title="" alt="" class="MCXref_0">ON...GOTO</a>
</p>
</td>
</tr>
</table>
<p>&#160;</p>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">BRANCH </span>instruction is useful when you want to write something like this:</p><pre class="BScode" xml:space="preserve">Test_Value:
IF value = 0 THEN Case_0 ' if value is 0, jump to Case_0
IF value = 1 THEN Case_1 ' if value is 1, jump to Case_1
IF value = 2 THEN Case_2 ' if value is 2, jump to Case_2
</pre>
<p class="PlainText">You can use <span class="keyword_in_text">BRANCH</span> to organize this into a single statement:</p>
<p class="PlainText">
<img src="../../graphics/bs1_inline.gif" />
</p><pre class="BScode" xml:space="preserve">&#160;&#160;BRANCH value, (Case_0, Case_1, Case_2)</pre>
<p class="PlainText">
<img src="../../graphics/bs2all_inline.gif" />
</p><pre class="BScode" xml:space="preserve">&#160;&#160;BRANCH value, (Case_0, Case_1, Case_2)</pre>
<p class="PlainText">This works exactly the same as the previous <a href="IF_THEN.htm" target="" title="" alt="" class="MCXref_0">IF…THEN</a> example. If the value isnt in range (in this case if value is greater than 2), <span class="keyword_in_text">BRANCH </span>does nothing and the program continues with the next instruction after <span class="keyword_in_text">BRANCH</span>.</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>

View File

@ -0,0 +1,126 @@
<?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>BUTTON</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">BUTTON</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/ButtonEx.htm" target="" title="" alt="" class="MCXref_0">BUTTON Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">BUTTON</span> <![CDATA[ ]]><i>Pin</i>,<i> DownState</i>,<i> Delay</i>,<i> Rate</i>,<i> Workspace</i>,<i> TargetState</i>,<i> Address</i></p>
<h2>Function</h2>
<p class="PlainText">Monitor and process a pushbutton input, perform auto-repeat, and branch to address
if button is in target state. Button circuits may be active-low or active-high.
</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>DownState</i></b> is a variable/constant/expression* (0 or 1) that
specifies which logical state occurs when the button is pressed.</li>
<li value="3"><b><i>Delay</i></b> is a variable/constant/expression* (0 - 255) that specifies
how long the button must be pressed before auto-repeat starts. The delay is
measured in cycles of the <span class="keyword_in_text">BUTTON</span> routine. <i>Delay</i> has two special
settings: 0 and 255. If <i>Delay</i> is 0, <span class="keyword_in_text">BUTTON</span> performs no debounce
or auto-repeat. If <i>Delay</i> is 255, Button performs debounce, but no
auto-repeat. </li>
<li value="4"><b><i>Rate</i></b> is a variable/constant/expression* (0 - 255) that specifies
the number of cycles between auto-repeats. The rate is expressed in cycles
of the <span class="keyword_in_text">BUTTON</span> routine. </li>
<li value="5"><b><i>Workspace</i></b> is a byte variable used by <span class="keyword_in_text">BUTTON</span> for workspace.
It must be cleared to 0 before being used by <span class="keyword_in_text">BUTTON</span> for the first time
and should not be adjusted outside of the <span class="keyword_in_text">BUTTON</span> instruction. NOTE:
All RAM is cleared to 0 by default upon power-up or reset of the BASIC
Stamp. </li>
<li value="6"><b><i>TargetState</i></b> is a variable/constant/expression* (0 or 1) that
specifies which state the button should be in for a branch to occur (0=not
pressed, 1=pressed).</li>
<li value="7"><b><i>Address</i></b> is a label that specifies where to branch if the button
is in the target state.</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>Explanation<br /></h2>
<p class="PlainText">When you press a button or flip a switch, the contacts make or break a connection.
A brief (1 to 20-ms) burst of noise occurs as the contacts scrape and bounce against
each other. By scanning an input within a loop to ensure that the contact remains
in a specified state for a minimum duration, spurious multiple inputs caused by
contact noise can be eliminated. The <span class="keyword_in_text">BUTTON </span>instruction helps prevent this
noise from being interpreted as more than one switch action; this is the function
of the <i>Delay</i> parameter. (For a demonstration of switch bounce, see the demo
program for the <a href="COUNT.htm" target="" title="" alt="" class="MCXref_0">COUNT</a> instruction.) <i>Delay</i>, combined
with the <i>Rate</i> parameter, allows the programmer to control the rate at which
multiple inputs are accepted by the BASIC Stamp.</p>
<p class="PlainText"><span class="keyword_in_text">BUTTON</span> also lets PBASIC react to a button press the way your computer
keyboard does to a key press. When you press a key, a character immediately appears
on the screen. If you hold the key down, there's a delay, then a rapid-fire stream
of characters appears on the screen. <span class="keyword_in_text">BUTTON</span>'s auto-repeat function can be
set up to work much the same way. </p>
<p class="PlainText"><span class="keyword_in_text">BUTTON</span> is designed for use inside a program loop. Each time through the
loop, <span class="keyword_in_text">BUTTON</span> checks the state of the specified pin. When it first matches
<i>DownState</i>, <span class="keyword_in_text">BUTTON</span> begins the <i>Delay</i> countdown for auto-repeat.
Then, in accordance with <i>TargetState</i>, it either branches to address
(TargetState = 1) or doesn't (TargetState = 0).</p>
<p class="PlainText">If the switch stays in <i>DownState</i>, <span class="keyword_in_text">BUTTON</span> counts the number of
program loops that execute. When this count equals <i>Delay</i>, <span class="keyword_in_text">BUTTON</span>once again triggers the action specified by <i>TargetState</i> and <i>Address</i>. Hereafter,
if the switch remains in <i>DownState</i>, <span class="keyword_in_text">BUTTON</span> waits <i>Rate</i> number
of cycles between actions. The <i>Workspace</i> variable is used by <span class="keyword_in_text">BUTTON</span>
to keep track of how many cycles have occurred since the pin switched to
<i>TargetState</i> or since the last auto-repeat.</p>
<p class="PlainText"><span class="keyword_in_text">BUTTON</span> does not stop program execution. In order for its delay and auto
repeat functions to work properly, <span class="keyword_in_text">BUTTON</span> must be executed from within a
program loop.</p>
<center>
<img src="../../graphics/button_sch.gif" border="0" />
</center>
<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>

View File

@ -0,0 +1,117 @@
<?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>COMPARE</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">COMPARE</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/CompareEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">COMPARE Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">COMPARE</span> <![CDATA[ ]]><i>Mode,</i> <![CDATA[ ]]><i>Result</i></p>
<h2>Function</h2>
<p>Enable or disable comparator, compare voltages on P1 and P2 and retrieve
comparison result to store in <i>Result</i>.
</p>
<ul>
<li value="1"><b><i>Mode</i></b> is a variable/constant/expression (0 2) that enables
or disables the comparator (input pins P1 and P2) and determines if the
optional comparator output pin (pin P0) is enabled or not. See the table
below for an explanation of the <i>Mode</i> values.</li>
<li value="2"><b><i>Result</i></b> is a variable (usually a bit) in which the
comparison result is stored.</li>
</ul>
<h2>Quick Facts<br /></h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="80" align="center">&#160;</td>
<td width="80%%" align="center">BS2px</td>
</tr>
<tr>
<td align="center" rowspan="3" bgcolor="#CFCFCF"><i>Mode</i> Values</td>
<td>0: Disables comparator.</td>
</tr>
<tr>
<td>1: Enables comparator with P0 as <i>Result</i> output.</td>
</tr>
<tr>
<td>2: Enables comparator without P0 as <i>Result</i> output.</td>
</tr>
<tr>
<td align="center" rowspan="2" bgcolor="#CFCFCF"><i>Result</i> Values</td>
<td>0: Voltage P1 &gt; P2; P0 optionally outputs 0.</td>
</tr>
<tr>
<td>1: Voltage P1 &lt; P2; P0 optionally outputs 1.</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">COMPARE</span> command enables or disables the built-in comparator
hardware on the BS2px's I/O pins P0, P1, and P2. I/O pins P1 and P2 are
the comparator inputs and P0 is optionally the comparator result output
pin.</p>
<p class="PlainText">By default, the comparator feature is disabled. Using the <span class="keyword_in_text">COMPARE</span> command with a <i>Mode</i> argument of 1 or 2 enables the comparator feature
(using input pins P1 and P2) and returns the result of the comparison in
<i>Result</i>. If <i>Mode</i> is 1, the result of the comparison is also
output on I/O pin P0. The following is an example of the <span class="keyword_in_text">COMPARE </span>command:</p><pre class="BScode" xml:space="preserve">
result VAR Bit
Main:
COMPARE 1, result
</pre>
<p class="PlainText">This example enables the comparator (setting P0 to output the result,
with P1 and P2 as the comparator inputs) and writes the result of the
comparison into <i>result</i>. Both <i>Result </i>and the output pin P0
will be 0 if the input voltage on P1 was greater than that of P2.
<i>result</i> and the output pin P0 will be 1 if the input voltage on P1
was less than that of P2.</p>
<p class="PlainText">Note that the comparator hardware operates independently of the
execution speed of the BS2px and will continue to run and update P0 if
Mode = 1, even during sleep mode (execution of <span class="keyword_in_text">END</span>, <span class="keyword_in_text">NAP</span>,
<span class="keyword_in_text">POLLWAIT</span> 8, or <span class="keyword_in_text">SLEEP</span> commands). To avoid spurious current
draw during sleep mode, disable the comparator first.</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>

View File

@ -0,0 +1,208 @@
<?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>CONFIGPIN</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">CONFIGPIN</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/ConfigpinEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">CONFIGPIN Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">CONFIGPIN</span> <![CDATA[ ]]><i>Mode</i>, <i>PinMask</i></p>
<h2>Function</h2>
<p class="PlainText">Configure special properties of I/O pins.
</p>
<ul>
<li value="1"><b><i>Mode</i></b>&#160; is a variable/constant/expression (0 3), or one
of four predefined symbols, that specifies the I/O pin property to configure:
Schmitt Trigger, Logic Threshold, Pull-up Resistor or Output Direction. See
table below for an explanation of <i>Mode</i> values.</li>
<li value="2"><b><i>PinMask</i></b>&#160; is a variable/constant/expression (1 65535)
that indicates how <i>Mode</i> is applied to I/O pins. Each bit of
<i>PinMask</i> corresponds to an individual I/O pin. A high bit (1) enables
the <i>Mode</i> and a low bit (0) disables the <i>Mode</i> on the
corresponding I/O pin.</li>
</ul>
<h2>Quick Facts<br /></h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="80" align="center">&#160;</td>
<td width="80%%" align="center">BS2px</td>
</tr>
<tr>
<td align="center" rowspan="4" bgcolor="#CFCFCF"><i>Mode</i> Values</td>
<td>0 (or SCHMITT): Schmitt Trigger</td>
</tr>
<tr>
<td>1 (or THRESHOLD): Logic Threshold</td>
</tr>
<tr>
<td>2 (or PULLUP): Pull-up Resistor</td>
</tr>
<tr>
<td>3 (or DIRECTION): Output Direction</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="INPUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">INPUT</a>, <a href="OUTPUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">OUTPUT</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">CONFIGPIN</span> command enables or disables special I/O pin properties
on all 16 I/O pins at once. There are four properties, or modes, available:
Schmitt Trigger, Logic Threshold, Pull-up Resistor, and Output Direction.
Each I/O pin on the BS2px contains special hardware dedicated to each of
these properties.</p>
<p class="PlainText">By default, all BASIC Stamp I/O pins are set to inputs. Enabling the
Output Direction mode sets an I/O pins direction to output. Disabling
the Output Direction mode sets an I/O pins direction to input. This has
the same effect as using the <span class="keyword_in_text">OUTPUT</span> or <span class="keyword_in_text">INPUT</span> commands, or the
DIRx = # assignment statement to configure I/O pin directions. The
following is an example of the <span class="keyword_in_text">CONFIGPIN</span> command using the Output
Direction mode:</p><pre class="BScode" xml:space="preserve">
CONFIGPIN DIRECTION, %0000000100010011
</pre>
<p class="PlainText">Every high bit (1) in the <i>PinMask</i> argument enables the output direction
for the corresponding I/O pin while every low bit (0) disables the output
direction. In the above example, I/O pins 8, 4, 1, and 0 are set to the
output direction and all other I/O pins are set to the input direction. This
is similar to the following statement:</p><pre class="BScode" xml:space="preserve">
DIRS = %0000000100010011
</pre>
<p class="PlainText">Pull-up resistors are commonly used in circuitry where a component, such
as a button, provides an open/drain signal; the signal is either floating
(open) or is driven to ground (drain). Since the BASIC Stamp input pins
must always be connected to either 5 volts or ground (0 volts) in order to
read a reliable logic state with them, a pull-up resistor is required on
circuitry, such as the button circuit mentioned above, so that the signal is
never left floating (electrically disconnected).</p>
<p class="PlainText">The following example enables internal pull-up resistors on I/O pins 15,
12, 6, and 3, and disables internal pull-up resistors on all other I/O pins:</p><pre class="BScode" xml:space="preserve">
CONFIGPIN PULLUP, %1001000001001000
</pre>
<p class="PlainText">Note that the internal pull-up resistors are intentionally weak, about 20
kΩ. Additionally, the internal pull-up resistors can be activated for all
pins, regardless of pin direction, but really matter only when the
associated pin is set to input mode.</p>
<p class="PlainText">An input pins logic threshold determines the voltage levels that are
interpreted as logic high (1) and logic low (0). Most microcontrollers, and
other integrated circuits use one of two types of logic threshold: TTL Level
or CMOS Level. The BASIC Stamp I/O pins are, by default, configured for TTL
level logic thresholds. The figure below is an illustration of the difference
between TTL and CMOS logic levels.</p>
<table border="0">
<tr>
<td>
<img src="../../graphics/level_ttl.gif" border="0">
</img>
</td>
<td>&#160; &#160; &#160; &#160; &#160;</td>
<td>
<img src="../../graphics/level_cmos.gif" border="0">
</img>
</td>
</tr>
<tr align="center">
<td><b>TTL Logic Level</b>
</td>
<td>&#160; &#160;</td>
<td><b>CMOS Logic Level</b>
</td>
</tr>
</table>
<p class="PlainText">&#160;</p>
<p class="PlainText">The logic threshold for TTL is 1.4 volts; a voltage below 1.4 is considered
to be a logic 0 while a voltage above 1.4 is considered to be a logic 1. The
logic threshold for CMOS is 50% of Vdd; a voltage below ½ Vdd is
considered a logic 0 while a voltage above ½ Vdd is considered a logic 1.</p>
<p class="PlainText">For the <span class="keyword_in_text">CONFIGPIN</span> command's THRESHOLD mode, a high bit (1) in the
<i>PinMask</i> argument sets the corresponding I/O pin to CMOS threshold
level, and a low bit sets it to a TTL threshold level. The following example
sets CMOS threshold level on I/O pins 3, 2, 1, and 0, and TTL threshold
level on all other I/O pins.</p><pre class="BScode" xml:space="preserve">
CONFIGPIN THRESHOLD, %0000000000001111
</pre>
<p class="PlainText">The threshold level can be set for all pins, regardless of pin direction, but
really matters only when the associated pin is set to input mode.</p>
<p class="PlainText">Normally, if a signal on an input pin is somewhat noisy (the voltage level
randomly rises and falls beyond the logic threshold boundary) then
reading that pins input value will result in spurious highs and lows (1s
and 0s). Schmitt Triggers are circuits that make inputs more steady and
reliable by adding a region of hysteresis around the logic threshold that
the signal must completely traverse before the logic level is interpreted as
being changed. By default BASIC Stamp I/O pins are set to normal input
mode, but the BS2px can be configured for Schmitt Trigger mode as well.
The figure below illustrates Schmitt Trigger characteristics.</p>
<table border="0">
<tr>
<td>
<img src="../../graphics/level_schmitt.gif" border="0">
</img>
</td>
</tr>
</table>
<p class="PlainText">In Schmitt Trigger mode, the threshold for a logic 0 is approximately 15%
of Vdd and the threshold for a logic 1 is approximately 85% of Vdd. The
input pin defaults to an unknown state until the initial voltage crosses a
logic 0 or logic 1 boundary. Thereafter, the voltage must cross above 85%
of Vdd to be interpreted as a logic 1 and must cross below 15% of Vdd to
be interpreted as a logic 0. If the voltage transitions somewhere between
the two thresholds, the interpreted logic state remains the same as the
previous state.</p>
<p class="PlainText">For the <span class="keyword_in_text">CONFIGPIN</span> commands SCHMITT mode, a high bit (1) in the
<i>PinMask</i> argument enables the Schmitt Trigger on the corresponding I/O
pin and a low bit (0) disables the Schmitt Trigger. The following example
sets Schmitt Triggers on I/O pins 7, 6, 5, and 4, and sets all other I/O pins
to normal mode.</p><pre class="BScode" xml:space="preserve">
CONFIGPIN SCHMITT, %0000000011110000
</pre>
<p class="PlainText">Schmitt Trigger mode can be activated for all pins, regardless of pin
direction, but really matters only when the associated pin is set to input
mode.</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>

View File

@ -0,0 +1,141 @@
<?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>COUNT</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">COUNT</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/CountEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">COUNT Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p>Syntax: <span class="keyword_in_text">COUNT</span> <![CDATA[ ]]><i>Pin</i>,<i> Duration</i>,<i> Variable</i></p>
<h2>Function</h2>
<p class="PlainText">Count the number of cycles (0-1-0 or 1-0-1) on the specified pin during the <i>Duration</i> time frame and store that number 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>Duration</i></b> is a variable/constant/expression (1 65535) specifying
the time during which to count. The unit of time for <i>Duration</i> is described
below.</li>
<li value="3"><b><i>Variable</i></b> is a variable (usually a Word) in which the count will
be stored.</li>
</ul>
<h2>Quick Facts<br /></h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="20%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2 / BS2e</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2sx</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2p</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2pe</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Units in <i>Duration</i></td>
<td align="center">1 ms</td>
<td align="center">400 µs</td>
<td align="center">287 µs</td>
<td align="center">720 µs</td>
<td align="center">287 µs</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF"><i>Duration</i> range</td>
<td align="center">1 ms to 65.535 s</td>
<td align="center">400 µs to 26.214 s</td>
<td align="center">287 µs to 18.809 s</td>
<td align="center">720 µs to 47.180 s</td>
<td align="center">287 µs to 18.809 s</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Minimum pulse width</td>
<td align="center">4.16 µs</td>
<td align="center">1.66 µs</td>
<td align="center">1.20 µs</td>
<td align="center">3.00 µs</td>
<td align="center">1.20 µs</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Maximum frequency<br></br>(square wave)</td>
<td align="center">120,000 Hz</td>
<td align="center">300,000 Hz</td>
<td align="center">416,700 Hz</td>
<td align="center">166,667 Hz</td>
<td align="center">416,700 Hz</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="5">
<p colspan="5" align="center"><a href="PULSIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">PULSIN</a>
</p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">COUNT</span> instruction makes the <i>Pin</i> an input, then for the specified
<i>duration</i>, counts cycles on that pin and stores the total in a variable. A
cycle is a change in state from 1 to 0 to 1, or from 0 to 1 to 0.</p>
<p class="PlainText">According to table above, <span class="keyword_in_text">COUNT</span> on the BS2 can respond to transitions
(pulse widths) as small as 4.16 microseconds (µs). A cycle consists of two transitions
(e.g., 0 to 1, then 1 to 0), so <span class="keyword_in_text">COUNT</span> (on the BS2) can respond to square
waves with periods as short as 8.32 µs; up to 120 kilohertz (kHz) in frequency.
For non-square waves (those whose high time and low time are unequal), the shorter
of the high and low times must be at least 4.16 µs in width (on the BS2). Refer
to the table for data on other BASIC Stamp modules.</p>
<p class="PlainText">If you use <span class="keyword_in_text">COUNT</span> on slowly changing analog waveforms like sine waves,
you may find that the value returned is higher than expected. This is because the
waveform may pass through the BASIC Stamps 1.4-volt logic threshold slowly enough
that noise causes false counts. You can fix this by passing the signal through
a Schmitt Trigger, like one of the inverters of a 74HCT14. Or, you may use the
BS2pxs built-in Schmitt-Trigger pin property; see
<a href="CONFIGPIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">CONFIGPIN</a> for details. </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>

View File

@ -0,0 +1,269 @@
<?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>DATA</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">DATA</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/DataEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DATA Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: {<i>Symbol</i>} <span class="keyword_in_text">DATA</span>
{@<i>Address</i>,} {Word} <i>DataItem </i>{,<i> DataItem ...</i>}</p>
<h2>Function</h2>
<p class="PlainText">Write user data to the EEPROM location(s) during program download.
</p>
<ul>
<li value="1"><b><i>Symbol</i></b> is an optional, unique symbol name that will be
automatically defined as a constant equal to the location number of the first
data item.</li>
<li value="2"><b><i>Address</i></b> is an optional starting location for subsequent
<i>DataItems</i></li>
<li value="3"><b><i>DataItem</i></b> is a constant/expression (0 - 65535) indicating a value
or how to store a value.</li>
</ul>
<h2>Quick Facts</h2>
<table cellpadding="4" cellspacing="0" border="1" style="caption-side: top;width: 100%;">
<col />
<col />
<tr bgcolor="#CFCFCF">
<td width="15%" align="center">&#160;</td>
<td width="85%" align="center">All BS2 Models</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td>Writes values to EEPROM during download in blocks of 16 bytes. Writes byte- or word-sized values. Can be used to decrease program size.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center"><a href="READ.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">READ</a>, <a href="WRITE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">WRITE</a></td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">When you download a program into the BASIC Stamp, it is stored in the EEPROM starting
at the highest address (2047) and working towards the lowest address. Most programs
don't use the entire EEPROM, so the lower portion is available for other uses.
The <span class="keyword_in_text">DATA</span> directive allows you to define a set of data to store in the available
EEPROM locations. It is called a "directive" rather than a "command" because it
performs an activity at compile-time rather than at run-time (i.e.: the <span class="keyword_in_text">DATA</span>directive is not downloaded to the BASIC Stamp, but the data it contains is downloaded).</p>
<p class="PlainText">The simplest form of the <span class="keyword_in_text">DATA</span> directive is something like the following:</p><pre class="BScode" xml:space="preserve">
DATA 100, 200, 52, 45
</pre>
<p class="PlainText">This example, when downloaded, will cause the values 100, 200, 52 and 45 to be
written to EEPROM locations 0, 1, 2 and 3, respectively. You can then use the
<span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> commands in your code to access these locations and
the data you've stored there.</p>
<p class="PlainText"><span class="keyword_in_text">DATA</span> uses a counter, called a pointer, to keep track of available EEPROM
addresses. The value of the pointer is initially 0. When a program is downloaded,
the <span class="keyword_in_text">DATA</span> directive stores the first byte value at the current pointer address,
then increments (adds 1 to) the pointer. If the program contains more than one
<span class="keyword_in_text">DATA</span> directive, subsequent <span class="keyword_in_text">DATA</span>s start with the pointer value left
by the previous <span class="keyword_in_text">DATA</span>. For example, if the program contains:</p><pre class="BScode" xml:space="preserve">
DATA 72, 69, 76, 76, 79
DATA 104, 101, 108, 108, 111
</pre>
<p class="PlainText">The first <span class="keyword_in_text">DATA</span> directive will start at location 0 and increment the pointer
for each data value it stores (1, 2, 3, 4, and 5). The second <span class="keyword_in_text">DATA</span> directive
will start with the pointer value of 5 and work upward from there. As a result,
the first 10 bytes of EEPROM will look like the following:</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="20%" align="center" bgcolor="#CFCFCF" rowspan="2">&#160;</td>
<td align="center" bgcolor="#CFCFCF" colspan="10">EEPROM Location (address)</td>
</tr>
<tr>
<td width="8%" align="center" bgcolor="#CFCFCF">0</td>
<td width="8%" align="center" bgcolor="#CFCFCF">1</td>
<td width="8%" align="center" bgcolor="#CFCFCF">2</td>
<td width="8%" align="center" bgcolor="#CFCFCF">3</td>
<td width="8%" align="center" bgcolor="#CFCFCF">4</td>
<td width="8%" align="center" bgcolor="#CFCFCF">5</td>
<td width="8%" align="center" bgcolor="#CFCFCF">6</td>
<td width="8%" align="center" bgcolor="#CFCFCF">7</td>
<td width="8%" align="center" bgcolor="#CFCFCF">8</td>
<td width="8%" align="center" bgcolor="#CFCFCF">9</td>
</tr>
<tr>
<td width="20%" align="center" bgcolor="#CFCFCF">Contents</td>
<td width="8%" align="center">72</td>
<td width="8%" align="center">69</td>
<td width="8%" align="center">76</td>
<td width="8%" align="center">76</td>
<td width="8%" align="center">79</td>
<td width="8%" align="center">104</td>
<td width="8%" align="center">101</td>
<td width="8%" align="center">108</td>
<td width="8%" align="center">108</td>
<td width="8%" align="center">111</td>
</tr>
</table>
<p>&#160;</p>
<p class="PlainText">What if you don't want to store values starting at location 0? Fortunately,
the <span class="keyword_in_text">DATA</span> directive has an option to specify the next location to use. You
can specify the next location number (to set the pointer to) by inserting a
<i>DataItem</i> in the form @x ;where x is the location number. The following code
writes the same data in the table above to locations 100 through 109:</p><pre class="BScode" xml:space="preserve">
DATA @100, 72, 69, 76, 76, 79, 104, 101, 108, 108, 111
</pre>
<p class="PlainText">In this example, the first <i>DataItem </i>is @100. This tells the <span class="keyword_in_text">DATA</span> directive
to store the following <i>DataItem</i>(s) starting at location 100. All the
<i>DataItems</i> to the right of the @100 are stored in their respective locations
(100, 101, 102... 109).</p>
<p>In addition, the <span class="keyword_in_text">DATA</span> directive allows you to specify new starting locations
at any time within the <i>DataItem</i> list. If, for example, you wanted to store
56 at location 100 and 47 at location 150 (while leaving every other location intact),
you could type the following:</p><pre class="BScode" xml:space="preserve">
DATA @100, 56, @150, 47
</pre>
<p class="PlainText">If you have multiple <span class="keyword_in_text">DATA</span> directives in your program, it may be difficult
to remember exactly what locations contain the desired data. For this reason, the
<span class="keyword_in_text">DATA</span> directive can optionally be prefixed with a unique symbol name. This
symbol becomes a constant that is set equal to the location number of the first
byte of data within the directive. For example,</p><pre class="BScode" xml:space="preserve">
MyNumbers DATA @100, 72, 73
</pre>
<p class="PlainText">This would store the values 72 and 73 starting with location 100 and will create
a constant, called MyNumbers, which is set equal to 100. Your program can then
use the MyNumbers constant as a reference to the start of the data within a <span class="keyword_in_text">READ</span>or <span class="keyword_in_text">WRITE</span> command. Each <span class="keyword_in_text">DATA</span> directive can have a unique symbol preceding
it, allowing you to reference the data defined at different locations.</p>
<p class="PlainText">There may be a time when you wish to reserve a section of EEPROM for use by your
BASIC code, but not necessarily store data there to begin with. To do this, simply
specify a <i>DataItem</i> within parentheses, as in:</p><pre class="BScode" xml:space="preserve">
DATA @100, (20)
</pre>
<p class="PlainText">The above <span class="keyword_in_text">DATA</span> directive will reserve 20 bytes of EEPROM, starting with
location 100. It doesn't store any values there, rather it simply leaves the data
as it is and increments <span class="keyword_in_text">DATA</span>'s location pointer by 20. A good reason to
do this is when you have a program already downloaded into the BASIC Stamp that
has created or manipulated some data in EEPROM. To protect that section of EEPROM
from being overwritten by your next program (perhaps a new version of the same
program) you can reserve the space as shown above. The EEPROM's contents from
locations 100 to 119 will remain intact. NOTE: This only "reserves" the space for
the program you are currently downloading; the BASIC Stamp does not know to
"reserve" the space for future programs. In other words, make sure use this
feature of the <span class="keyword_in_text">DATA</span> directive in every program you download if you don't
want to risk overwriting valuable EEPROM data.</p>
<p class="PlainText">It is important to realize that EEPROM is not overwritten during programming
unless it is needed for program storage, or is filled by a <span class="keyword_in_text">DATA</span> directive
specifying data to be written. During downloading, EEPROM is always written in
16-byte sections if, and only if, any location within that section needs writing. </p>
<p class="PlainText"><span class="keyword_in_text">DATA</span> can also store the same number in a block of consecutive locations.
This is similar to reserving a block of EEPROM, above, but with a value added before
the first parenthesis. For example,</p><pre class="BScode" xml:space="preserve">
DATA @100, 0 (20)
</pre>
<p class="PlainText">This statement writes the value 0 in all the EEPROM locations from 100 to 119.</p>
<p>A common use for <span class="keyword_in_text">DATA</span> is to store strings; sequences of bytes representing
text. PBASIC converts quoted text like "A" into the corresponding ASCII character
code (65 in this case). To make data entry easier, you can place quotes around a
whole chunk of text used in a <span class="keyword_in_text">DATA</span> directive, and PBASIC will understand
it to mean a series of bytes (see the last line of code below). The following
three <span class="keyword_in_text">DATA</span> directives are equivalent: </p><pre class="BScode" xml:space="preserve">
DATA 72, 69, 76, 76, 79
DATA "H", "E", "L", "L", "O"
DATA "HELLO"
</pre>
<p class="PlainText">All three lines of code, above, will result in the numbers 72, 69, 76, 76, and
79 being stored into EEPROM upon downloading. These numbers are simply the ASCII
character codes for "H", "E", "L", "L", and "O", respectively. See the
Example program link at the top for a demonstration of storing and
reading multiple text strings.</p>
<p class="PlainText">The EEPROM is organized as a sequential set of byte-sized memory locations.
By default, the <span class="keyword_in_text">DATA</span> directive stores bytes into EEPROM. If you try to
store a word-size value (ex: <span class="keyword_in_text">DATA</span> 1125) only the lower byte of the value
will be stored. This does not mean that you can't store word-sized values, however.
A word consists of two bytes, called a low-byte and a high-byte. If you wanted
to store the value 1125 using the <span class="keyword_in_text">DATA</span> directive, simply insert the prefix
"Word" before the number, as in:</p><pre class="BScode" xml:space="preserve">
DATA Word 1125
</pre>
<p class="PlainText">The directive above will automatically break the word-size value into two bytes
and store them into two sequential EEPROM locations (the low-byte first, followed
by the high-byte, or "<i>Little Endian</i>"). In this case, the low-byte is 101
and the high byte is 4 and they will be stored in locations 0 and 1, respectively.
If you have multiple word-size values, you must prefix each value with "Word",
as in:</p><pre class="BScode" xml:space="preserve">
DATA Word 1125, Word 2000
</pre>
<p class="PlainText">To retrieve a word-size value, you'll need to use the Word modifier with
<span class="keyword_in_text">READ</span> (only available in PBASIC 2.5 syntax). For example,</p><pre class="BScode" xml:space="preserve">
' {$PBASIC 2.5}
result VAR Word
Storage:
DATA Word 1125
Main:
READ 0, Word result
DEBUG DEC result
END
</pre>
<p class="PlainText">This code would write the low-byte and high-byte of the number 1125 into locations
0 and 1 during download. When the program runs, the <span class="keyword_in_text">READ</span> function (with
the Word modifier) will retrieve the value out of EEPROM and then display the value
on the screen. See the <a href="READ.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">READ</a> and <a href="WRITE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">WRITE</a> commands for more information.</p>
<p class="PlainText">Finally, a <i>DataItem</i> may be defined using a simple expression with the binary
operators as shown below:</p><pre class="BScode" xml:space="preserve">
MinLvl CON 10
myLvl VAR Byte
Level1 DATA MinLvl + 10
Level2 DATA MinLvl * 5 + 21
Main:
READ Level2, myLvl ' read EE location Level2
DEBUG DEC myLvl ' show value of myLvl (71)
END
</pre>
<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>

View File

@ -0,0 +1,620 @@
<?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>DEBUG</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">DEBUG</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/DebugEx.htm" target="" title="" alt="" class="MCXref_0">DEBUG Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">DEBUG</span> <![CDATA[ ]]><i>OutputData </i>{, <i>OutputData</i>}</p>
<h2>Function</h2>
<p class="PlainText">Display information on the PC screen within the BASIC Stamp editor program. This
command can be used to display text or numbers in various formats on the PC screen
in order to follow program flow (called debugging) or as part of the functionality
of the BASIC Stamp application.
</p>
<ul>
<li value="1"><b><i>OutputData</i></b> is a variable/constant/expression* (0 - 65535) that
specifies the information to output. Valid data can be ASCII characters (text
strings and control characters), decimal numbers (0 - 65535), hexadecimal numbers
($0000 - $FFFF) or binary numbers (up to %1111111111111111). Data can be
modified with special formatters as explained below.</li>
</ul>
<p>*<img align="absmiddle" src="../../graphics/bs1note.gif" style="vertical-align: super;" /> Note: Expressions are not allowed as arguments on the BS1. The only
constant allowed for the BS1 <span class="keyword_in_text">DEBUG</span> command is a text string.</p>
<h2>Quick Facts<br /></h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="16%" align="center">&#160;</td>
<td width="28%" align="center">BS1</td>
<td width="28%" align="center">BS2, BS2e, BS2sx, BS2p, and BS2pe</td>
<td width="28%" align="center">BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Serial Protocol</td>
<td align="center">Asychronous 4800 baud, N, 8, 1<br></br>Inverted polarity,
Raw Data<br></br>Custom packetized format</td>
<td align="center">Asychronous 9600 baud, N, 8, 1<br></br>Inverted polarity,
Raw Data</td>
<td align="center">Asychronous 19.2 kBaud, N, 8, 1<br></br>Inverted polarity,
Raw Data</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="3">
<p colspan="3" align="center"><a href="DEBUGIN.htm" target="" title="" alt="" class="MCXref_0">DEBUGIN</a>, <a href="SEROUT.htm" target="" title="" alt="" class="MCXref_0">SEROUT</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">DEBUG</span> provides a convenient way for your BASIC Stamp to send messages to
the PC screen while running. The name "debug" suggests its most popular use;
debugging programs by showing you the value of a variable or expression, or by
indicating what portion of a program is currently executing. <span class="keyword_in_text">DEBUG</span> is also
a great way to rehearse programming techniques. Throughout this manual, we use
<span class="keyword_in_text">DEBUG</span> to give you immediate feedback on the effects of instructions. The
following example demonstrates using the <span class="keyword_in_text">DEBUG</span> command to send the text
string message "Hello World!". </p><pre class="BScode" xml:space="preserve">
DEBUG "Hello, World!" ' test Message
</pre>
<p class="PlainText">After you download this one-line program, the BASIC Stamp Editor will open a
Debug terminal on your PC screen and wait for a response from the BASIC Stamp.
A moment later, the phrase "Hello World!" will appear. Note that if you close the
Debug terminal, your program keeps executing, but you can't see the <span class="keyword_in_text">DEBUG</span>
data anymore.</p>
<p class="PlainText">Multiple pieces of data can be sent with one <span class="keyword_in_text">DEBUG</span> command by separating
the data with commas (,). The following example produces exactly the same results
as the example above.</p><pre class="BScode" xml:space="preserve">
DEBUG "Hello, ", "World!" ' test Message
</pre>
<p class="PlainText"><span class="keyword_in_text">DEBUG</span> can also print and format numbers (values) from both constants
and variables. Please note that formatting the <span class="keyword_in_text">DEBUG</span> output with the BS1
differs significantly from formatting the <span class="keyword_in_text">DEBUG</span> output with the BS2 family.
Please read the appropriate sections that follow carefully.</p>
<p class="Tip" MadCap:autonum="Tip: &#160;"><span class="autonumber"><span class="TipSpan">Tip: &#160;</span></span><b>Don't let your BASIC Stamp be mistaken for a mouse! </b>
<br />
<br />Connecting USB-based boards to your PC may cause the BASIC Stamp to reset. If your BASIC Stamp program immediately starts sending serial data to the computer via a <span class="keyword_in_text">DEBUG</span> or <span class="keyword_in_text">SEROUT</span> command, your computer's operating system may mistake it for a mouse or other serial plug-and-play device. To avoid this, place a 1-second pause at the beginning of the program. </p>
<h2>
<img align="absmiddle" src="../../graphics/bs1_inline.gif" border="0" />&#160; BASIC Stamp 1 Formatting</h2>
<p class="PlainText">On the BS1, the <span class="keyword_in_text">DEBUG</span> command, by default, displays numbers in the format
"symbol = value" (followed by a carriage return), using the decimal number system.
For example: </p><pre class="BScode" xml:space="preserve">
SYMBOL x = B2
Init:
x = 75
Main:
DEBUG x
END
</pre>
<p class="PlainText">...displays "x = 75" on the screen. To display the value, in decimal, without
the "x =" text, use the decimal formatter (#) before the variable name. For
example, the following code displays "75" on the screen:</p><pre class="BScode" xml:space="preserve">
SYMBOL x = B2
Init:
x = 75
Main:
DEBUG #x
END
</pre>
<p class="PlainText">To display numbers in hexadecimal or binary form, use the $ or % formatter,
respectively. The code below displays the same number in its hexadecimal and binary
forms.</p><pre class="BScode" xml:space="preserve">
SYMBOL x = B2
Init:
x = 75
Main:
DEBUG $x, %x
END
</pre>
<p class="PlainText">After running the above code, "X = $4B" and "X = %01001011" should appear on the
screen. To display hexadecimal ($) or binary (%) values without the "symbol = "
preface, use the # modifier as shown below:</p><pre class="BScode" xml:space="preserve">
SYMBOL x = B2
x = 75
DEBUG #x, "as HEX is ", #$x ' displays "75 as HEX is $4B"
</pre>
<p class="PlainText">To display a number as its ASCII character equivalent, use the ASCII formatter
(@). Typing <span class="keyword_in_text">DEBUG</span> @x (in place of the <span class="keyword_in_text">DEBUG</span> statement in the code
above) would display "x = 'K'" on the screen.</p>
<p class="PlainText">Two pre-defined symbols, CR and CLS, can be used to send a carriage-return or
clear-screen command to the Debug Terminal. The CR symbol will cause the Debug
Terminal to start a new line and the CLS symbol will cause the Debug Terminal to
clear itself and place the cursor at the top-left corner of the screen. The
following code demonstrates this.</p><pre class="BScode" xml:space="preserve">
DEBUG "You can not see this.", CLS, "Here is line 1", CR, "Here is line 2"
</pre>
<p class="PlainText">When the above is run, the final result is "Here is line 1" on the first line
of the screen and "Here is line 2" on the second line. You may or may not have
seen "You can not see this." appear first. This is because it was immediately
followed by a clear-screen symbol, CLS, which caused the display to clear the
screen before displaying the rest of the information.</p>
<p class="Tip" MadCap:autonum="Tip: &#160;"><span class="autonumber"><span class="TipSpan">Tip: &#160;</span></span><b>The rest of this discussion does not apply to the BASIC Stamp
1.</b>
</p>
<h2>
<img align="absmiddle" src="../../graphics/bsall_inline.gif" border="0" />&#160; BASIC Stamp 2 Series Formatting</h2>
<p class="PlainText">On the all BASIC Stamp models except the BS1, the <span class="keyword_in_text">DEBUG</span> command, by default,
displays everything as ASCII characters. What if you want to display a number?
You might think the following example would do this:</p><pre class="BScode" xml:space="preserve">
x VAR Byte
Init:
x = 65
Main:
DEBUG x ' show value of x
END
</pre>
<p class="PlainText">Since we set x equal to 65 (in line 2), you might expect the <span class="keyword_in_text">DEBUG</span> line
to display "65" on the screen. Instead of "65", however, you'll see the letter
"A" if you run this example. The problem is that we never told the BASIC Stamp
how to output x, and it defaults to ASCII (the ASCII character at position 65 is
"A"). Instead, we need to tell it to display the "decimal form" of the number in
X. We can do this by using the decimal formatter (DEC) before the variable. The
example below will display "65" on the screen.</p><pre class="BScode" xml:space="preserve">
x VAR Byte
Init:
x = 65
Main:
DEBUG DEC x ' show decimal value of x
END
</pre>
<p class="PlainText">In addition to decimal (DEC), <span class="keyword_in_text">DEBUG</span> can display numbers in hexadecimal
(HEX) and binary (BIN). See the table below for a complete list of formatters.</p>
<p>Expressions are allowed within the <span class="keyword_in_text">DEBUG</span> command arguments as well. In
the above code, <span class="keyword_in_text">DEBUG</span> DEC x+25 would yield "90" and <span class="keyword_in_text">DEBUG</span> DEC
x*10/2-3 would yield "322".</p>
<p>&#160;</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="150">Formatter</td>
<td width="80%">Description</td>
</tr>
<tr valign="top">
<td>?</td>
<td>Displays "symbol = x' + carriage return; where x is a number. Default
format is decimal, but may be combined with conversion formatters (ex:
BIN ? x to display "x = binary_number").</td>
</tr>
<tr valign="top">
<td>ASC ?</td>
<td>Displays "symbol = 'x'" + carriage return; where x is an ASCII character.</td>
</tr>
<tr valign="top">
<td>DEC{1..5}</td>
<td>Decimal, optionally fixed to 1 - 5 digits</td>
</tr>
<tr valign="top">
<td>SDEC{1..5}</td>
<td>Signed decimal, optionally fixed to 1 - 5 digits</td>
</tr>
<tr valign="top">
<td>HEX{1..4}</td>
<td>Hexadecimal, optionally fixed to 1 - 4 digits</td>
</tr>
<tr valign="top">
<td>SHEX{1..4}</td>
<td>Signed hexadecimal, optionally fixed to 1 - 4 digits </td>
</tr>
<tr valign="top">
<td>IHEX{1..4}</td>
<td>Indicated hexadecimal, optionally fixed to 1 - 4 digits</td>
</tr>
<tr valign="top">
<td>ISHEX{1..4}</td>
<td>Signed, indicated hexadecimal, optionally fixed to 1 - 4 digits ($ prefix)</td>
</tr>
<tr valign="top">
<td>BIN{1..16}</td>
<td>Binary, optionally fixed to 1 - 16 digits</td>
</tr>
<tr valign="top">
<td>SBIN{1..16}</td>
<td>Signed binary, optionally fixed to 1 - 16 digits</td>
</tr>
<tr valign="top">
<td>IBIN{1..16}</td>
<td>Indicated binary, optionally fixed to 1 - 16 digits</td>
</tr>
<tr valign="top">
<td>ISBIN{1..16}</td>
<td>Signed, indicated binary, optionally fixed to 1 - 16 digits</td>
</tr>
<tr valign="top">
<td>STR ByteArray</td>
<td>ASCII string from bytearray until byte = 0.</td>
</tr>
<tr valign="top">
<td>STR ByteArray {\L}</td>
<td>ASCII string consisting of n bytes from bytearray.</td>
</tr>
<tr valign="top">
<td>REP Byte\L</td>
<td>Display ASCII character n times.</td>
</tr>
</table>
<p class="PlainText">As seen above, special versions of the DEC, HEX and BIN formatters allow for
the display of indicated, signed and fixed-width numbers. The term "indicated"
simply means that a special symbol is displayed, before the number, indicating
what number system it belongs to. For example:</p><pre class="BScode" xml:space="preserve">
x VAR Byte
Init:
x = 65
Main:
DEBUG HEX x ' show hexadecimal value of x
END
</pre>
<p class="PlainText">...displays "41" (65, in decimal, is 41, in hexadecimal). You might see a problem
here... unless you knew the number was supposed to be hexadecimal, you might think
it was 41, in decimal... a totally different number. To help avoid this, use the
IHEX formatter (the "I" stands for indicated). Changing the <span class="keyword_in_text">DEBUG</span> line to
read: <span class="keyword_in_text">DEBUG</span> IHEX x would print "$41" on the screen. A similar formatter
for binary also exists, IBIN, which prints a "%" before the number.</p>
<p class="PlainText">Signed numbers are preceded with a space ( ) or a minus sign (-) to indicate a
positive or negative number, respectively. Normally, any number displayed by the
BASIC Stamp is shown in its unsigned (positive) form without any indicator. The
signed formatters allow
you to display the number as a signed (rather than unsigned) value.</p>
<p class="Tip" MadCap:autonum="Tip: &#160;"><span class="autonumber"><span class="TipSpan">Tip: &#160;</span></span><b>Only
Word-sized variables can be used for signed number display. </b>
</p>
<p class="PlainText">The code below
demonstrates the difference in all three numbering schemes.</p><pre class="BScode" xml:space="preserve">
x VAR Word
Init:
x = -65
Main:
DEBUG "Signed: ", SDEC x, " ", ISHEX x, " ", ISBIN x, CR
DEBUG "Unsigned: ", DEC x, " ", IHEX x, " ", IBIN x
END
</pre>
<p class="PlainText">This code will generate the display shown below:</p><pre>Signed: -65 -$41 -%1000001<br />Unsigned: 65471 $FFBF %1111111110111111
</pre>
<p class="PlainText">The signed form of the number -65 is shown in decimal, hexadecimal and then in
binary on the top line. The unsigned form, in all three number systems, is shown
on the bottom line. If the unsigned form looks strange to you, it's because negative
numbers are stored in twos-compliment format within the BASIC Stamp. </p>
<p class="PlainText">Suppose that your program contained several <span class="keyword_in_text">DEBUG</span> instructions showing
the contents of different variables. You would want some way to tell them apart.
One possible way is to do the following:</p><pre class="BScode" xml:space="preserve">
x VAR Byte
y VAR Byte
Init:
x = 100
y = 250
Main:
DEBUG "X = ", DEC x, CR ' show decimal value of x
DEBUG "Y = ", DEC y, CR ' show decimal value of y
END
</pre>
<p class="PlainText">...but typing the name of the variables in quotes (for the display) can get a
little tedious. A special formatter, the question mark (?), can save you a lot
of time. The code below does exactly the same thing (with less typing):</p><pre class="BScode" xml:space="preserve">
x VAR Byte
y VAR Byte
Init:
x = 100
y = 250
Main:
DEBUG DEC ? x ' show decimal value of x
DEBUG DEC ? y ' show decimal value of y
END
</pre>
<p class="PlainText">The display would look something like this:</p><pre>x = 100<br />y = 250
</pre>
<p class="PlainText">The ? formatter always displays data in the form "symbol = value" (followed by
a carriage return). In addition, it defaults to displaying in decimal, so we really
only needed to type: <span class="keyword_in_text">DEBUG</span> ? x for the above code. You can, of course,
use any of the three number systems. For example: <span class="keyword_in_text">DEBUG</span> HEX ? x or
<span class="keyword_in_text">DEBUG</span> BIN ? y. </p>
<p class="PlainText">It's important to note that the "symbol" it displays is taken directly from what
appears to the right of the ?. If you were to use an expression, for example:
<span class="keyword_in_text">DEBUG</span> ? x*10/2+3 in the above code, the display would show: "x*10/2+3
= 503". </p>
<p class="PlainText">A special formatter, ASC, is also available for use only with the ? formatter
to display ASCII characters, as in: <span class="keyword_in_text">DEBUG</span> ASC ? x.</p>
<p class="PlainText">What if you need to display a table of data; multiple rows and columns? The
Signed/Unsigned code (above) approaches this but, if you notice, the columns don't
line up. The number formatters (DEC, HEX and BIN) have some useful variations to
make the display fixed-width. Up to 5 digits can be displayed for decimal numbers.
To fix the value to a specific number of decimal digits, you can use DEC1, DEC2,
DEC3, DEC4 or DEC5. For example:</p><pre class="BScode" xml:space="preserve">
x VAR Byte
Init:
x = 165
Main:
DEBUG DEC5 x ' show decimal value of x
END ' in 5 digits
</pre>
<p class="PlainText">...displays "00165". Notice that leading zeros? The display is "fixed" to 5 digits,
no more and no less. Any unused digits will be filled with zeros.</p>
<p class="PlainText">Using DEC4 in the same code would display "0165". DEC3 would display "165".
What would happen if we used DEC2? Regardless of the number, the BASIC Stamp will
ensure that it is always the exact number of digits you specified. In this case,
it would truncate the "1" and only display "65". </p>
<p class="PlainText">Using the fixed-width version of the formatters in the Signed/Unsigned code
above, may result in the following code:</p><pre class="BScode" xml:space="preserve">
x VAR Word
Init:
x = -65
Main:
DEBUG "Signed: ", SDEC5 x, " ", ISHEX4 x, " ", ISBIN16 x, CR
DEBUG "Unsigned: ", DEC5 x, " ", IHEX4 x, " ", IBIN16 x
END
</pre>
<p>...and displays:</p><pre>Signed: -00065 -$0041 -%0000000001000001<br />Unsigned: 65471 $FFBF %1111111110111111
</pre>
<p class="PlainText">Note that the columns don't line up exactly (due to the extra "sign" characters
in the first row), but it certainly looks better than the alternative.</p>
<h3><a name="Displayi"></a>Displaying Strings (Byte Arrays)</h3>
<p class="PlainText">If you have a string of characters to display (a byte array), you can use the
STR formatter to do so. The STR formatter has two forms (as shown in the table above)
for variable-width and fixed-width data. The example below is the variable-width
form.</p><pre class="BScode" xml:space="preserve">
alpha VAR Byte(5)
Init:
alpha(0) = "A"
alpha(1) = "B"
alpha(2) = "C"
alpha(3) = "D"
alpha(4) = 0
Main:
DEBUG STR alpha, CR ' display "ABCD"
END
</pre>
<p class="PlainText">This code displays "ABCD" on the screen. In this form, the STR formatter displays
each character contained in the byte array until it finds a character that is equal
to 0 (value 0, not "0"). This is convenient for use with the <a href="SERIN.htm" target="" title="" alt="" class="MCXref_0">SERIN</a> command's STR
formatter, which appends 0's to the end of variable-width character string inputs.
NOTE: If your byte array doesn't end with 0, the BASIC Stamp will read and output
all RAM register contents until it finds a 0 or until it cycles through all RAM
locations.</p>
<p class="PlainText">To specify a fixed-width format for the STR formatter, use the form STR alpha\n;
where alpha is the byte array and n is the number of characters to print. Changing
the <span class="keyword_in_text">DEBUG</span> line in the example above to: <span class="code_in_text">DEBUG STR alpha\2</span> would display
"AB" on the screen.</p>
<p class="PlainText">If you need to display the same ASCII character multiple times, the REP (repeat)
formatter can help. REP takes the form: REP x\n ;where x is the character and
n is the number of times to repeat it. For example:</p><pre class="BScode" xml:space="preserve">
DEBUG REP "-"\10
</pre>
<p class="PlainText">...would display 10 hyphens on the screen, "<tt>----------</tt>". </p>
<p class="PlainText">Since individual <span class="keyword_in_text">DEBUG</span> instructions can grow to be fairly complicated,
and since a program can contain many <span class="keyword_in_text">DEBUG</span>s, you'll probably want to control
the character positioning of the Debug Terminal screen. <span class="keyword_in_text">DEBUG</span> supports a
number of different control characters, some with pre-defined symbols. The Debug
Terminal in the Windows<sup>®</sup> version of the editor supports all the
control characters shown below, while the DOS version only supports a few of them.</p>
<p class="PlainText">Some of the control characters have pre-defined symbols associated with them.
In your <span class="keyword_in_text">DEBUG</span> commands, you can use those symbols, for example: <span class="keyword_in_text">DEBUG</span>"Hello", CR displays "Hello" followed by a carriage return. You can always use
the ASCII value for any of the control characters, however. For example: <span class="keyword_in_text">DEBUG</span>"Hello", 13 is exactly the same as the code above.</p>
<p class="PlainText">The Move To control character is perhaps the most unique of the set. If the
Debug Terminal receives this character, it expects to see an x and y position value
to follow (in the next two characters received). The following line moves the
cursor to column number 4 in row number 5 and displays "Hello":</p><pre class="BScode" xml:space="preserve">
DEBUG CRSRXY, 4, 5, "Hello"
</pre>
<p class="PlainText">The upper-left cursor position is 0, 0 (that is column 0, line 0). The right-most
cursor positions depend on the size of the Debug Terminal window (which is user
adjustable). If a character position that is out of range is received, the Debug
Terminal wraps back around to the opposite side of the screen.</p>
<p class="PlainText">The Clear EOL (end of line) control character clears the characters that appear
to the right of, and on, the cursor's current position. The cursor is not moved
by this action.</p>
<p class="PlainText">The Clear Down control character clears the characters that appear below, and
on, the cursor's current line. The cursor is not moved by this action.</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="150">Name</td>
<td width="75">Symbol</td>
<td width="75">ASCII<br></br>Value</td>
<td width="1000">Description</td>
</tr>
<tr valign="top">
<td width="150">Clear Screen</td>
<td width="75" align="center">CLS <sup>1</sup></td>
<td width="75" align="center">0</td>
<td width="1000">Clear the screen and place cursor at home position.</td>
</tr>
<tr valign="top">
<td width="150">Home</td>
<td width="75" align="center">HOME</td>
<td width="75" align="center">1</td>
<td width="1000">Place cursor at home in upper-left corner of the screen.</td>
</tr>
<tr valign="top">
<td width="150">Move To (x, y)</td>
<td width="75" align="center">CRSRXY <sup>2</sup></td>
<td width="75" align="center">2</td>
<td width="1000">Move cursor to specified location (column, line). Must be
followed by two values (x and then y)</td>
</tr>
<tr valign="top">
<td width="150">Cursor Left</td>
<td width="75" align="center">CRSRLF <sup>2</sup></td>
<td width="75" align="center">3</td>
<td width="1000">Move cursor one character to left.</td>
</tr>
<tr valign="top">
<td width="150">Cursor Right</td>
<td width="75" align="center">CRSRRT <sup>2</sup></td>
<td width="75" align="center">4</td>
<td width="1000">Move cursor one character to right.</td>
</tr>
<tr valign="top">
<td width="150">Cursor Up</td>
<td width="75" align="center">CRSRUP <sup>2</sup></td>
<td width="75" align="center">5</td>
<td width="1000">Move cursor one character up.</td>
</tr>
<tr valign="top">
<td width="150">Cursor Down</td>
<td width="75" align="center">CRSRDN <sup>2</sup></td>
<td width="75" align="center">6</td>
<td width="1000">Move cursor one character down.</td>
</tr>
<tr valign="top">
<td width="150">Bell</td>
<td width="75" align="center">BELL</td>
<td width="75" align="center">7</td>
<td width="1000">Beep the PC speaker.</td>
</tr>
<tr valign="top">
<td width="150">Backspace</td>
<td width="75" align="center">BKSP</td>
<td width="75" align="center">8</td>
<td width="1000">Back up cursor to left one space.</td>
</tr>
<tr valign="top">
<td width="150">Tab</td>
<td width="75" align="center">TAB</td>
<td width="75" align="center">9</td>
<td width="1000">Tab to the next column.</td>
</tr>
<tr valign="top">
<td width="150">Line Feed</td>
<td width="75" align="center">LF</td>
<td width="75" align="center">10</td>
<td width="1000">Move cursor down one line.</td>
</tr>
<tr valign="top">
<td width="150">Clear to End of Line</td>
<td width="75" align="center">CLREOL <sup>2</sup></td>
<td width="75" align="center">11</td>
<td width="1000">Clear line contents to the right of cursor.</td>
</tr>
<tr valign="top">
<td width="150">Clear Down</td>
<td width="75" align="center">CLRDN <sup>2</sup></td>
<td width="75" align="center">12</td>
<td width="1000">Clear screen contents below cursor.</td>
</tr>
<tr valign="top">
<td width="150">Carriage Return</td>
<td width="75" align="center">CR <sup>1</sup></td>
<td width="75" align="center">13</td>
<td width="1000">Move cursor to the first column of the next line (shift any
data on the right down to that line as well)</td>
</tr>
<tr valign="top">
<td width="150">Move To Column X</td>
<td width="75" align="center">CRSRX <sup>2</sup></td>
<td width="75" align="center">14</td>
<td width="1000">Move cursor to specified column. Must be followed by byte
value (x) for the column (0 is the left-most column)</td>
</tr>
<tr valign="top">
<td width="150">Move To Line Y</td>
<td width="75" align="center">CRSRY <sup>2</sup></td>
<td width="75" align="center">15</td>
<td width="1000">Move cursor to specified line. Must be followed by byte
value (y) for the line (0 is the top-most line)</td>
</tr>
</table>
<p><sup>1</sup> Supported by BS1 <span class="keyword_in_text">DEBUG </span>command (others not supported).<br /><sup>2</sup> This control character only works with the Windows<sup>®</sup>
version of the editor software.</p>
<p class="PlainText">&#160;</p>
<p class="PlainText">In the BS2 family, <span class="keyword_in_text">DEBUG</span> is actually a special case of the <span class="keyword_in_text">SEROUT</span>instruction. It is set for inverted (RS-232-compatible) serial output through the
programming connector (the SOUT pin) at 9600 baud (BS2, BS2e, BS2sx, BS2p, and
BS2pe) or 19.2 kBaud (BS2px), no parity, 8 data bits, and 1 stop bit.
For example,</p><pre class="BScode" xml:space="preserve">
DEBUG "Hello"
</pre>
<p class="PlainText">...is exactly like:</p><pre class="BScode" xml:space="preserve">
SEROUT 16, $4054, ["Hello"]
</pre>
<p class="PlainText">in terms of function (on a BS2). The <span class="keyword_in_text">DEBUG</span> line actually takes less
program space, and is obviously easier to type.</p>
<p class="PlainText">You may view <span class="keyword_in_text">DEBUG</span>'s output using a terminal program set to the above
parameters, but you may have to modify either your carrier board or the serial
cable to temporarily disconnect pin 3 of the BASIC Stamp (pin 4 of the DB-9
connector). See the <a href="SEROUT.htm" target="" title="" alt="" class="MCXref_0">SEROUT</a> command for more detail. </p>
<p class="PlainText">Another method to decrease program space is to reduce the number of <span class="keyword_in_text">DEBUG</span>
instructions by spreading <span class="keyword_in_text">DEBUG</span> data across multiple lines. To do this,
each line that wraps around must end with a comma as in the example below:
</p><pre class="BScode" xml:space="preserve">
DEBUG "This is line 1", CR,
"This is line 2"
</pre>
<p class="PlainText">The example above works identically to, but uses less program space than, this version:</p><pre class="BScode" xml:space="preserve">
DEBUG "This is line 1", CR
DEBUG "This is line 2"
</pre>
<p class="Tip" MadCap:autonum="Tip: &#160;"><span class="autonumber"><span class="TipSpan">Tip: &#160;</span></span>Note that spreading a <span class="keyword_in_text">DEBUG</span> statement across multiple lines requires the
declaration of PBASIC 2.5 syntax.</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>

View File

@ -0,0 +1,305 @@
<?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>DEBUGIN</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">DEBUGIN</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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" /><span class="code_in_text"> {PBASIC&#160;2.5}</span>
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/DebugDebuginEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DEBUG / DEBUGIN Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">DEBUGIN</span> <![CDATA[ ]]><i>InputData</i></p>
<h2>Function</h2>
<p class="PlainText">Retrieve information from the user via the Debug Terminal window within the BASIC Stamp editor program.
</p>
<ul>
<li value="1"><b><i>InputData</i></b> is list of variables and formatters that tells
<span class="keyword_in_text">DEBUGIN</span> what to do with incoming data. <span class="keyword_in_text">DEBUGIN</span> can store data in
a variable or array, interpret numeric text (decimal, binary, or hex) and store
the corresponding value in a variable, wait for a fixed or variable sequence of
bytes, or ignore a specified number of bytes. These actions can be combined
in any order in the <i>InputData</i> list.</li>
</ul>
<h2>Quick Facts<br /></h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="20%" align="center">&#160;</td>
<td width="40%" align="center">BS2, BS2e, BS2sx, BS2p, and BS2pe</td>
<td width="40%" align="center">BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Serial Protocol</td>
<td align="center">Asychronous 9600 baud, N, 8, 1<br></br>Inverted polarity,
Raw Data</td>
<td align="center">Asychronous 19.2 kBaud, N, 8, 1<br></br>Inverted polarity,
Raw Data</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="2">
<p colspan="2" align="center"><a href="DEBUG.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DEBUG</a>, <a href="SERIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SERIN</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">DEBUGIN</span> provides a convenient way for your BASIC Stamp accept input from
the use via the Debug Terminal. <span class="keyword_in_text">DEBUGIN</span> can wait for, filter and
convert incoming data in powerful ways, using the same techniques and modifiers
as <a href="SERIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SERIN</a>.
</p>
<p class="PlainText">This simple example waits for a number from the user, then prints a message
the specified number of times: </p><pre class="BScode" xml:space="preserve">
lines VAR Nib
idx VAR Nib
Main:
DEBUG CLS, "How many lines to print (1 - 5)? --&gt; "
DEBUGIN DEC1 lines
IF ((lines &gt;= 1) AND (lines &lt;= 5)) THEN
DEBUG CR, CR
FOR idx = 1 TO lines ' print message specified times
DEBUG DEC1 idx, ". "
DEBUG "BASIC Stamp!", CR
NEXT
END ' end of program
ELSE
DEBUG CR, "Invalid entry!" ' warning message
PAUSE 2000 ' wait 2 seconds
GOTO Main ' get another entry
ENDIF
</pre>
<p class="PlainText">After you download this program, the BASIC Stamp Editor will open a Debug
Terminal on your PC screen and wait for an entry from the user. Since the DEC1
modifier is used with <span class="keyword_in_text">DEBUGIN</span>, the program will ignore all keys except
"0" - "9". If the value entered is between 1 and 5, the message will be printed,
otherwise the program will display an "Invalid entry" message, then loop back
and wait for another entry.</p>
<p class="PlainText"><span class="keyword_in_text">DEBUGIN</span> is actually a special case of the <span class="keyword_in_text">SERIN</span> instruction. It
is set for inverted (RS-232-compatible) serial output through the programming
connector (the SIN pin) at 9600 baud (BS2, BS2e, BS2sx, BS2p, and BS2pe) or
19.2 kBaud (BS2px), no parity, 8 data bits, and 1 stop bit.
For example,</p><pre class="BScode" xml:space="preserve">
DEBUGIN DEC1 lines
</pre>
<p class="PlainText">...is exactly like:</p><pre class="BScode" xml:space="preserve">
SERIN 16, $4054, [DEC1 lines]
</pre>
<p class="PlainText">...in terms of function (on a BS2). The <span class="keyword_in_text">DEBUGIN</span> line actually takes less
program space, and is obviously easier to type.</p>
<p class="PlainText">The tables below list all the available conversion formatters and special
formatters available to the <span class="keyword_in_text">DEBUGIN</span> command. See the
<a href="SERIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SERIN</a> command for additional information and examples
of their use.</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="15%">Conversion Formatter</td>
<td width="45%">Type of Number</td>
<td width="30%">Numeric Characters Accepted</td>
<td width="10%">Notes</td>
</tr>
<tr align="center">
<td>DEC{1..5}</td>
<td>Decimal, optionally limited to 1 - 5 digits</td>
<td>0 through 9</td>
<td>1</td>
</tr>
<tr align="center">
<td>SDEC{1..5}</td>
<td>Signed decimal, optionally limited to 1 - 5 digits</td>
<td>-, 0 through 9</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>HEX{1..4}</td>
<td>Hexadecimal, optionally limited to 1 - 4 digits</td>
<td>0 through 9, A through F</td>
<td>1,3</td>
</tr>
<tr align="center">
<td>SHEX{1..4}</td>
<td>Signed hexadecimal, optionally limited to 1 - 4 digits </td>
<td>-, 0 through 9, A through F</td>
<td>1,2,3</td>
</tr>
<tr align="center">
<td>IHEX{1..4}</td>
<td>Indicated hexadecimal, optionally limited to 1 - 4 digits</td>
<td>$, 0 through 9, A through F</td>
<td>1,3,4</td>
</tr>
<tr align="center">
<td>ISHEX{1..4}</td>
<td>Signed, indicated hexadecimal, optionally limited to 1 - 4 digits</td>
<td>-, $, 0 through 9, A through F</td>
<td>1,2,3,4</td>
</tr>
<tr align="center">
<td>BIN{1..16}</td>
<td>Binary, optionally limited to 1 - 16 digits</td>
<td>0, 1</td>
<td>1</td>
</tr>
<tr align="center">
<td>SBIN{1..16}</td>
<td>Signed binary, optionally limited to 1 - 16 digits</td>
<td>-, 0, 1</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>IBIN{1..16}</td>
<td>Indicated binary, optionally limited to 1 - 16 digits</td>
<td>%, 0, 1</td>
<td>1,4</td>
</tr>
<tr align="center">
<td>ISBIN{1..16}</td>
<td>Signed, indicated binary, optionally limited to 1 - 16 digits</td>
<td>-, %, 0, 1</td>
<td>1,2,4</td>
</tr>
<tr align="center">
<td>NUM</td>
<td>Generic numeric input; hex or binary number must be indicated</td>
<td>$, %, 0 through 9, A through F</td>
<td>1,3,4</td>
</tr>
<tr align="center">
<td>SNUM</td>
<td>Similar to NUM with value treated as signed with range -32768 to +32767</td>
<td>-, $, %, 0 through 9, A through F</td>
<td>1,2,3,4</td>
</tr>
</table>
<ol>
<li value="1">All numeric conversions will continue to accept new data until receiving
either the specified number of digits (ex: three digits for DEC3) or a
non-numeric character.</li>
<li value="2">To be recognized as part of a number, the minus sign (-) must immediately
precede a numeric character. The minus sign character occurring in non-numeric
text is ignored and any character (including a space) between a minus and a
number causes the minus to be ignored.</li>
<li value="3">The hexadecimal formatters are not case-sensitive; "a" through "f" means
the same as "A" through "F".</li>
<li value="4">Indicated hexadecimal and binary formatters ignore all characters, even
valid numerics, until they receive the appropriate prefix ($ for hexadecimal,
% for binary). The indicated formatters can differentiate between text and
hexadecimal (ex: ABC would be interpreted by HEX as a number but IHEX would
ignore it unless expressed as $ABC). Likewise, the binary version can
distinguish the decimal number 10 from the binary number %10. A prefix
occurring in non-numeric text is ignored, and any character (including a
space) between a prefix and a number causes the prefix to be ignored. Indicated,
signed formatters require that the minus sign come before the prefix, as
in -$1B45.</li>
</ol>
<p>&#160;</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="150">Special Formatter</td>
<td>Action</td>
</tr>
<tr>
<td align="center">STR ByteArray \L {\E}</td>
<td>Input a character string of length L into an array. If specified, an end
character E causes the string input to end before reaching length L.
Remaining bytes are filled with 0s (zeros).</td>
</tr>
<tr>
<td align="center">WAITSTR ByteArray {\L}</td>
<td>Wait for a sequence of bytes matching a string stored in an array variable,
optionally limited to L characters. If the optional L argument is left off,
the end of the array-string must be marked by a byte containing a zero (0).</td>
</tr>
<tr>
<td align="center">SKIP Length</td>
<td>Ignore Length bytes of characters.</td>
</tr>
</table>
<p>&#160;</p>
<p>
<img src="../../graphics/bs2ppepx_inline.gif" border="0" />
<br />
</p>
<p>
<br />
</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="150">Special Formatter</td>
<td>Action</td>
</tr>
<tr>
<td align="center">SPSTR L</td>
<td>Buffer length L bytes (up to 126) of serial characters to Scratchpad RAM,
starting at location 0. Use <a href="GET.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GET</a> to retrieve the
characters.</td>
</tr>
</table><pre class="BScode" xml:space="preserve">
idx VAR Nib
char VAR Byte
Setup:
DEBUG CLS, "Enter (4-character) passcode: "
Main:
DEBUGIN SPSTR 4
DEBUG CLS, "Checking: "
FOR idx = 0 TO 3
GET idx, char
DEBUG char
NEXT
END
</pre>
<p class="PlainText">The example above will redirect four characters from the Debug Terminal
input to Scratchpad locations 0 - 3.</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>

View File

@ -0,0 +1,148 @@
<?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>DO…LOOP</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">DO…LOOP</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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" /><span class="code_in_text"> {PBASIC&#160;2.5}</span>
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/DoLoopEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DO...LOOP Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax:</p>
<p class="PlainText"><span class="keyword_in_text">DO </span>{ <span class="keyword_in_text">WHILE</span> | <span class="keyword_in_text">UNTIL</span> <![CDATA[ ]]><i>condition(s)</i> }<br />&#160; &#160; &#160;<i>Statement(s)</i><br />&#160; &#160;<span class="keyword_in_text">LOOP</span> { <span class="keyword_in_text">WHILE</span> | <span class="keyword_in_text">UNTIL</span> <![CDATA[ ]]><i>condition(s)</i> }
</p>
<h2>Function</h2>
<p class="PlainText">Create a repeating loop that executes the program lines between <span class="keyword_in_text">DO</span> and
<span class="keyword_in_text">LOOP</span>, optionally testing before or after the loop statements
</p>
<ul>
<li value="1"><b><i>Condition</i></b> is an optional variable/constant/expression (0 -
65535) which determines whether the loop will run or terminate.</li>
<li value="2"><b><i>Statement</i></b> is any valid PBASIC statement.</li>
</ul>
<h2>Quick Facts<br /></h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="26%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="64%" align="center" bgcolor="#CFCFCF">BS2 Family</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Maximum nested loops</td>
<td align="center">16</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">WHILE <i>Condition</i> evaluation</td>
<td align="center">Run loop if <i>Condition</i> evaluates as True (1)</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">UNTIL <i>Condition</i> evaluation</td>
<td align="center">Terminate loop if <i>Condition</i> evaluates as True (1)</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="EXIT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">EXIT</a>, <a href="FOR_NEXT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">FOR…NEXT</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">DO...LOOP</span> loops let your program execute a series of instructions
indefinitely, or until a specified condition terminates the loop. The simplest
form is shown here: </p><pre class="BScode" xml:space="preserve">
Error_Message:
DO
DEBUG "Error...", CR
PAUSE 2000
LOOP
</pre>
<p class="PlainText">In this example the error message will be printed on the
<a href="DEBUG.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DEBUG</a> screen every two seconds until the BASIC Stamp is
reset. Simple <span class="keyword_in_text">DO...LOOP</span> loops can be terminated with
<a href="EXIT.htm" class="MCXref_0" xrefformat="{paratext}">EXIT</a>. For example:</p><pre class="BScode" xml:space="preserve">
Error_Message:
DO
DEBUG "Error...", CR
PAUSE 1000
IF (AckPin = 0) THEN EXIT ' wait for user button press
LOOP
GOTO Initialize ' re-initialize system
</pre>
<p class="PlainText">In this case the loop will continue until the pin named AckPin is pulled low,
then the loop will terminate and continue at the line <span class="code_in_text">GOTO Initialize</span>.</p>
<p class="PlainText">More often than not, you will want to test some condition to determine whether
the loop code should run or continue to run. A loop that tests the condition before
running loop code is constructed like this:</p><pre class="BScode" xml:space="preserve">
reps VAR Nib
Print_Stars:
DO WHILE (reps &lt; 3) ' test before loop statements
DEBUG "*"
reps = reps + 1
LOOP
</pre>
<p class="PlainText">In this program the loop code <span class="code_in_text">DEBUG "*"</span> will not run unless the <span class="keyword_in_text">WHILE</span>
condition evaluates as True. Another way to write the loop is like this:</p><pre class="BScode" xml:space="preserve">
reps VAR Nib
Print_Stars:
DO
DEBUG "*"
reps = reps + 1
LOOP UNTIL (reps &gt;= 3) ' test after loop statements
</pre>
<p class="PlainText">The difference is that with this loop, the loop statements will always run at
least once before the condition is tested and will continue to as long as the
<span class="keyword_in_text">UNTIL</span> condition evaluates as False.</p>
<p class="PlainText">Note that <span class="keyword_in_text">WHILE</span> (loop runs while True) and <span class="keyword_in_text">UNTIL</span> (loop runs until
True) tests can be interchanged, but are generally used as illustrated above.
</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>

View File

@ -0,0 +1,201 @@
<?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>DTMFOUT</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">DTMFOUT</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/DtmfoutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DTMFOUT Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">DTMFOUT</span> <![CDATA[ ]]><i>Pin</i>, {<i>OnTime</i>,<i> OffTime</i>,} [<i>Tone
</i>{,<i> Tone...</i>}]</p>
<h2>Function</h2>
<p class="PlainText">Generate dual-tone, multi-frequency tones (DTMF, i.e., telephone "touch" tones).
</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 output mode during generation of
tones and set to input mode afterwards.</li>
<li value="2"><b><i>OnTime</i></b> is an optional variable/constant/expression (0 - 65535)
specifying a duration of the tone. The unit of time and the default time for
<i>OnTime</i> is described below. </li>
<li value="3"><b><i>OffTime</i></b> is an optional variable/constant/expression (0 - 65535)
specifying the length of silent pause after a tone (or between tones, if
multiple tones are specified). The unit of time and the default time for
<i>OffTime</i> is described below.</li>
<li value="4"><b><i>Tone</i></b> is a variable/constant/expression (0 - 15) specifying the
DTMF tone to generate. Tones 0 through 11 correspond to the standard layout
of the telephone keypad, while 12 through 15 are the fourth-column tones used
by phone test equipment and in ham-radio applications. </li>
</ul>
<h2>Quick Facts<br /></h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="20%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2 / BS2e</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2sx</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2p</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2pe</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Default <i>OnTime</i></td>
<td align="center">200 ms</td>
<td align="center">80 ms</td>
<td align="center">55 ms</td>
<td align="center">196 ms</td>
<td align="center">34 ms</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Default <i>OffTime</i></td>
<td align="center">50 ms</td>
<td align="center">50 ms</td>
<td align="center">50 ms</td>
<td align="center">50 ms</td>
<td align="center">50 ms</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Units in <i>OnTime</i></td>
<td align="center">1 ms</td>
<td align="center">0.4 ms</td>
<td align="center">0.265 ms</td>
<td align="center">1 ms</td>
<td align="center">0.166 ms</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Units in <i>OffTime</i></td>
<td align="center">1 ms</td>
<td align="center">1 ms</td>
<td align="center">1 ms</td>
<td align="center">1 ms</td>
<td align="center">1 ms</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="5">
<p colspan="5" align="center"><a href="SOUND.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SOUND</a>,&#160; <a href="FREQOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">FREQOUT</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">DTMF tones are used to dial the phone or remotely control certain radio equipment.
The BASIC Stamp can generate these tones digitally using the <span class="keyword_in_text">DTMFOUT</span>
instruction. </p>
<p class="PlainText">This figure shows how to connect an audio amplifier or speaker to hear these
tones:</p>
<center>
<img src="../../graphics/freqout_sch.gif" border="0">
</img>
</center>
<p class="PlainText">...and this figure shows how to connect the BASIC Stamp to the phone line:</p>
<center>
<img src="../../graphics/daa_sch.gif" border="0">
</img>
</center>
<p class="PlainText">The following <span class="keyword_in_text">DTMFOUT</span> instruction will generate DTMF tones on I/O pin 0:
</p><pre class="BScode" xml:space="preserve">
' Call Parallax
DTMFOUT 0, [1, 9, 1, 6, 6, 2, 4, 8, 3, 3, 3]
</pre>
<p class="PlainText">If the BASIC Stamp is connected to the phone line properly, the above command
would be equivalent to dialing 1-916-624-8333 from a phone keypad. If you wanted
to slow the pace of the dialing to accommodate a noisy phone line or radio link,
you could use the optional <i>OnTime</i> and <i>OffTime</i> values:
</p><pre class="BScode" xml:space="preserve">
' Call Parallax; dial slowly.
DTMFOUT 0, 500, 100, [1, 9, 1, 6, 6, 2, 4, 8, 3, 3, 3]
</pre>
<p>In this example, on a BS2 the<i>OnTime</i> is set to 500 ms (1/2 second) and <i>OffTime</i> to 100 ms (1/10th second).</p>
<p>&#160;</p>
<center>
<table cellpadding="4" cellspacing="0" border="1">
<tr>
<td align="center" width="75" bgcolor="#CFCFCF">Tone Value</td>
<td align="center" width="250" bgcolor="#CFCFCF">Corresponding Telephone Key</td>
</tr>
<tr>
<td align="center">0 - 9</td>
<td align="center">Digits 0 through 9</td>
</tr>
<tr>
<td align="center">10</td>
<td align="center">Star (*)</td>
</tr>
<tr>
<td align="center">11</td>
<td align="center">Pound (#)</td>
</tr>
<tr>
<td align="center">12 - 15</td>
<td align="center">Fourth column tones A through D</td>
</tr>
</table>
</center>
<p class="PlainText">&#160;</p>
<p class="PlainText">The BASIC Stamp microcontroller is a purely digital device. DTMF tones are analog
waveforms, consisting of a mixture of two sine waves at different audio frequencies.
So how does a digital device generate analog output? The BASIC Stamp creates and
mixes the sine waves mathematically, then uses the resulting stream of numbers to
control the duty cycle of a very fast pulse-width modulation (PWM) routine. So
what's actually coming out of the I/O pin is a rapid stream of pulses. The purpose
of the filtering arrangements shown in the figures above is to smooth out the
high-frequency PWM, leaving only the lower frequency audio behind. </p>
<p class="PlainText">Keep this in mind if you want to interface a BASIC Stamp module's DTMF output to radios
and other equipment that could be adversely affected by the presence of
high-frequency
noise on the input. Make sure to filter the DTMF output thoroughly. The circuits
above are only a starting point; you may want to use an active low-pass filter
with a roll-off point around 2 kHz.</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>

View File

@ -0,0 +1,205 @@
<?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>EEPROM</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">EEPROM</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" /><span class="code_in_text"> {PBASIC&#160;1.0}</span>
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/EepromEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">EEPROM Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">EEPROM</span> {<i>Location</i>,} (<i> DataItem
</i>{,<i> DataItem</i>,...})</p>
<h2>Function</h2>
<p class="PlainText">Write data to the EEPROM during program download.</p>
<ul>
<li value="1"><b><i>Location</i></b> is an optional variable/constant (0 - 255) that
specifies the starting location in the EEPROM at which data should be stored.
If no location is given, data is written starting at the next available
location.</li>
<li value="2"><b><i>DataItem</i></b> is a constant (0 - 255) to be stored in EEPROM.</li>
</ul>
<h2>Quick Facts</h2>
<table cellpadding="4" cellspacing="0" border="1" style="caption-side: top;width: 100%;">
<col />
<col />
<tr bgcolor="#CFCFCF">
<td width="15%" align="center">&#160;</td>
<td width="85%" align="center">BS1</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td>Writes values to EEPROM during download. Can be used to decrease program size.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td>
<p colspan="2" align="center"><a href="READ.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">READ</a>, <a href="WRITE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">WRITE</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">When you download a program into the BASIC Stamp 1, it is stored in the EEPROM
starting at the highest address (255) and working towards the lowest address. Most
programs don't use the entire EEPROM, so the lower portion is available for other
uses. The <span class="keyword_in_text">EEPROM</span> directive allows you to define a set of data to store in
the available EEPROM locations. It is called a "directive" rather than a "command"
because it performs an activity at compile-time rather than at run-time (i.e., the
<span class="keyword_in_text">EEPROM</span> directive is not downloaded to the BASIC Stamp 1, but the data it
contains is downloaded).</p>
<p>The simplest form of the <span class="keyword_in_text">EEPROM</span> directive is something like the following:</p><pre class="BScode" xml:space="preserve">
EEPROM (100, 200, 52, 45)
</pre>
<p class="PlainText">This example, when downloaded, will cause the values 100, 200, 52 and 45 to be
written to EEPROM locations 0, 1, 2 and 3, respectively. You can then use the
<span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> commands in your code to access these locations and
the data you've stored there</p>
<p class="PlainText">The <span class="keyword_in_text">EEPROM</span> directive uses a counter, called a pointer, to keep track of
available EEPROM addresses. The value of the pointer is initially 0. When a program
is downloaded, the <span class="keyword_in_text">EEPROM</span> directive stores the first byte value at the current
pointer address, then increments (adds 1 to) the pointer. If the program contains
more than one <span class="keyword_in_text">EEPROM</span> directive, subsequent <span class="keyword_in_text">EEPROM</span> directives start
with the pointer value left by the previous <span class="keyword_in_text">EEPROM</span> directive. For example,
if the program contains:</p><pre class="BScode" xml:space="preserve">
EEPROM (72, 69, 76, 76, 79)
EEPROM (104, 101, 108, 108, 111)
</pre>
<p class="PlainText">The first <span class="keyword_in_text">EEPROM</span> directive will start at location 0 and increment the
pointer for each data value it stores (1, 2, 3, 4 and 5). The second <span class="keyword_in_text">EEPROM</span>directive will start with the pointer value of 5 and work upward from there. As
a result, the first 10 bytes of EEPROM will look like the following:</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="20%" align="center" bgcolor="#CFCFCF" rowspan="2">&#160;</td>
<td align="center" bgcolor="#CFCFCF" colspan="10">EEPROM Location (address)</td>
</tr>
<tr>
<td width="8%" align="center" bgcolor="#CFCFCF">0</td>
<td width="8%" align="center" bgcolor="#CFCFCF">1</td>
<td width="8%" align="center" bgcolor="#CFCFCF">2</td>
<td width="8%" align="center" bgcolor="#CFCFCF">3</td>
<td width="8%" align="center" bgcolor="#CFCFCF">4</td>
<td width="8%" align="center" bgcolor="#CFCFCF">5</td>
<td width="8%" align="center" bgcolor="#CFCFCF">6</td>
<td width="8%" align="center" bgcolor="#CFCFCF">7</td>
<td width="8%" align="center" bgcolor="#CFCFCF">8</td>
<td width="8%" align="center" bgcolor="#CFCFCF">9</td>
</tr>
<tr>
<td width="20%" align="center" bgcolor="#CFCFCF">Contents</td>
<td width="8%" align="center">72</td>
<td width="8%" align="center">69</td>
<td width="8%" align="center">76</td>
<td width="8%" align="center">76</td>
<td width="8%" align="center">79</td>
<td width="8%" align="center">104</td>
<td width="8%" align="center">101</td>
<td width="8%" align="center">108</td>
<td width="8%" align="center">108</td>
<td width="8%" align="center">111</td>
</tr>
</table>
<p class="PlainText">What if you don't want to store values starting at location 0? Fortunately,
the <span class="keyword_in_text">EEPROM</span> directive has an option to specify the next location to use.
You can specify the next location number (to set the pointer to) by using the
optional <i>Location</i> argument before the list of <i>DataItems</i>. The following
code writes the same data in the table above to locations 50 through 59:</p><pre class="BScode" xml:space="preserve">
EEPROM 50, (72, 69, 76, 76, 79, 104, 101, 108, 108, 111)
</pre>
<p class="PlainText">In this example, the <i>Location</i> argument is given and tells the <span class="keyword_in_text">EEPROM</span>directive to store the following <i>DataItem</i>(s) starting at location 50. The
<i>DataItems</i> in the list are stored in their respective locations (50, 51,
52... 59).</p>
<p class="PlainText">It is important to realize that the entire BASIC Stamp 1 EEPROM is overwritten
during programming. Any EEPROM location not containing a PBASIC program or
<i>DataItems</i> from an <span class="keyword_in_text">EEPROM</span> directive is written with a 0. </p>
<p class="PlainText">A common use for EEPROM is to store strings; sequences of bytes representing
text. PBASIC converts quoted text like "A" into the corresponding ASCII character
code (65 in this case). To make data entry easier, you can place quotes around a
whole chunk of text used in a <span class="keyword_in_text">EEPROM</span> directive, and PBASIC will understand
it to mean a series of bytes (see the last line of code below). The following three
<span class="keyword_in_text">EEPROM</span> directives are equivalent: </p><pre class="BScode" xml:space="preserve">
EEPROM (72, 69, 76, 76, 79)
EEPROM ("H", "E", "L", "L", "O")
EEPROM ("HELLO")
</pre>
<p class="PlainText">All three lines of code, above, will result in the numbers 72, 69, 76, 76, and
79 being stored into EEPROM upon downloading. These numbers are simply the ASCII
character codes for "H", "E", "L", "L", and "O", respectively. See the
Example program above for a demonstration of storing and
reading multiple text strings.</p>
<p class="PlainText">The EEPROM is organized as a sequential set of byte-sized memory locations.
The <span class="keyword_in_text">EEPROM</span> directive only stores bytes into EEPROM. If you try to store
a word-size value, for example: <span class="keyword_in_text">EEPROM</span> (1125), only the lower byte of the
value will be stored (in this case, 101). This does not mean that you can't store
word-sized values, however. A word consists of two bytes, called a low-byte and
a high-byte. If you wanted to store the value 1125 using the <span class="keyword_in_text">EEPROM</span> directive
you'll have to calculate the low-byte and the high-byte and insert them in the
list in the proper order, as in:</p><pre class="BScode" xml:space="preserve">
EEPROM (101, 4)
</pre>
<p class="PlainText">The directive above will store the two bytes into two sequential EEPROM
locations (the low-byte first, followed by the high-byte). We calculated this in
the following manner: 1) high-byte is INT(value / 256) and 2) low-byte is value -
(high-byte * 256).</p>
<p class="PlainText">To retrieve a word-size value, you'll need to use two <span class="keyword_in_text">READ</span> commands and
a word-size variable. For example,</p><pre class="BScode" xml:space="preserve">
SYMBOL result = W1 ' word-sized variable
SYMBOL resLo = B2 ' B2 is low-byte of W1
SYMBOL resHi = B3 ' B3 is high-byte of W1
EEPROM (101, 4)
Main:
READ 0, resLo
READ 1, resHi
DEBUG #result
END
</pre>
<p class="PlainText">This code would write the low-byte and high-byte of the number 1125 into
locations 0 and 1 during download. When the program runs, the two <span class="keyword_in_text">READ</span>commands will read the low-byte and high-byte out of EEPROM (reconstructing it in
a word-size variable) and then display the value on the screen. See the <a href="READ.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">READ</a>
and <a href="WRITE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">WRITE</a> commands for more
information.</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>

View File

@ -0,0 +1,127 @@
<?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>END</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">END</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;">&#160;</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">END</span></p>
<h2>Function</h2>
<p class="PlainText">End the program, placing the BASIC Stamp into low-power mode indefinitely. This
is equivalent to having a program that does not loop continuously; once the BASIC
Stamp reaches the end of the PBASIC program, it enters low-power mode indefinitely.
The <span class="keyword_in_text">END</span> command is optional, but recommended.</p>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr align="center" bgcolor="#CFCFCF">
<td width="23%">&#160;</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">Approximate current draw @ 5 VDC 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">Approximate current draw @ 5 VDC during END *</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="1">
<p colspan="1" align="center"><a href="NAP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">NAP</a>, <a href="SLEEP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SLEEP</a></p>
</td>
<td align="center" colspan="3">
<p colspan="3" align="center"><a href="NAP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">NAP</a>, <a href="SLEEP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SLEEP</a>, <a href="STOP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">STOP</a></p>
</td>
<td align="center" colspan="3">
<p colspan="3" align="center"><a href="NAP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">NAP</a>, <a href="SLEEP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SLEEP</a>, <a href="STOP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">STOP</a>, <a href="POLLWAIT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLWAIT</a></p>
</td>
</tr>
</table>
<p>*Note: This is an approximate value, not including loads on the I/O pins</p>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">END</span> puts the BASIC Stamp into its inactive, low-power mode. In this
mode the Stamp's current draw (excluding loads driven by the I/O pins) is
reduced to the amount shown above. <span class="keyword_in_text">END</span> keeps the BASIC Stamp
inactive until the reset line is activated, the power is cycled off and back on
or the PC downloads another program.</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>
<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>

View File

@ -0,0 +1,105 @@
<?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>EXIT</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">EXIT</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/ExitEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">EXIT Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">EXIT</span></p>
<h2>Function</h2>
<p class="PlainText">Causes the immediate termination of a loop construct
(<a href="FOR_NEXT.htm" class="MCXref_0" xrefformat="{paratext}">FOR…NEXT</a>, <a href="DO_LOOP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DO…LOOP</a>).
</p>
<h2>Quick Facts</h2>
<table cellpadding="4" cellspacing="0" border="1" style="caption-side: top;width: 100%;">
<col />
<col />
<tr bgcolor="#CFCFCF">
<td width="15%" align="center">&#160;</td>
<td width="85%" align="center">All BS2 Models</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Maximum EXITs per loop</td>
<td align="center">16</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center"><a href="FOR_NEXT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">FOR…NEXT</a>, <a href="DO_LOOP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DO…LOOP</a></td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">EXIT</span> command allows a program to terminate a loop structure before
the loop limit test is executed. While not required, <span class="keyword_in_text">EXIT</span> is usually
used as part of an <span class="keyword_in_text">IF...THEN</span> construct to test a secondary condition for
terminating a loop, or for testing a termination condition of an unconditional
<span class="keyword_in_text">DO...LOOP</span> structure.</p><pre class="BScode" xml:space="preserve">
col VAR Byte
row VAR Byte
Main:
FOR col = 0 TO 3
FOR row = 0 TO 15
IF (row &gt; 9) THEN EXIT
DEBUG CRSRXY, (col * 8), row, DEC row, CR
NEXT
NEXT
END
</pre>
<p class="PlainText">In this program, the <span class="code_in_text">FOR row = 0 TO 15</span> loop will not run past nine because
the <span class="code_in_text">IF (row &gt; 9) THEN EXIT</span> contained within will force the loop to terminate
when row is greater than nine. Note that the <span class="keyword_in_text">EXIT</span> command only terminates
the loop that contains it. In this program, the outer loop (col) will continue to
run until complete.</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>

View File

@ -0,0 +1,391 @@
<?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>FOR…NEXT</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">FOR…NEXT</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/ForNextEx.htm" target="" title="" alt="" class="MCXref_0">FOR...NEXT Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax <img align="absmiddle" src="../../graphics/mini_1.gif" /> :
<span class="keyword_in_text">FOR</span> <![CDATA[ ]]><i>Counter = StartValue</i> <![CDATA[ ]]><span class="keyword_in_text">TO</span> <![CDATA[ ]]><i>EndValue </i>{<span class="keyword_in_text">STEP </span>{-}<i> StepValue</i>} ... <span class="keyword_in_text">NEXT</span><i><![CDATA[ ]]></i>{<i>Counter</i>}</p>
<p class="PlainText">Syntax <img align="absmiddle" src="../../graphics/mini_2.gif" /> : <span class="keyword_in_text">FOR</span> <![CDATA[ ]]><i>Counter = StartValue</i> <![CDATA[ ]]><span class="keyword_in_text">TO</span> <![CDATA[ ]]><i>EndValue </i>{<span class="keyword_in_text">STEP</span><i> StepValue</i>}<i><![CDATA[ ]]></i>... <span class="keyword_in_text">NEXT</span></p>
<h2>Function</h2>
<p class="PlainText">Create a repeating loop that executes the program lines between <span class="keyword_in_text">FOR</span> and
<span class="keyword_in_text">NEXT</span>, incrementing or decrementing <i>Counter</i> according to <i>StepValue</i> until the value of the <i>Counter</i> variable passes the <i>EndValue</i>.
</p>
<ul>
<li value="1"><b><i>Counter</i></b> is a variable (usually a byte or a word) used as a
counter.</li>
<li value="2"><b><i>StartValue</i></b> is a variable/constant/expression* (0 - 65535) that
specifies the initial value of the variable (<i>Counter</i>).</li>
<li value="3"><b><i>EndValue</i></b> is a variable/constant/expression* (0 - 65535) that
specifies the end value of the variable (<i>Counter</i>). When the value
of Counter is outside of the range <i>StartValue</i> to <i>EndValue</i>, the
<span class="keyword_in_text">FOR...NEXT</span> loop stops executing and the program goes on to the instruction
after <span class="keyword_in_text">NEXT</span>.</li>
<li value="4"><b><i>StepValue</i></b> is an optional variable/constant/expression* (0 -
65535) by which the <i>Counter</i> increases or decreases with each iteration
through the <span class="keyword_in_text">FOR...NEXT</span> loop. On the BS1, use a minus sign (-)†
in front of the <i>StepValue</i> to indicate a negative step. On all other
BASIC Stamp models, if <i>StartValue</i> is larger than <i>EndValue</i>, PBASIC
understands <i>StepValue</i> to be negative, even though no minus sign is used.</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>
<p class="PlainText"><img src="../../graphics/bs1note.gif" style="vertical-align: super;" /> Note: Use a minus sign to indicate negative <i>StepValues</i> on the BS1.</p>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="26%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="37%" align="center" bgcolor="#CFCFCF">BS1</td>
<td width="37%" align="center" bgcolor="#CFCFCF">BS2 Family</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Max. nested commands</td>
<td align="center">8</td>
<td align="center">16</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">To decrement counter variable</td>
<td align="center">Set <i>StartValue</i> &gt; <i>EndValue</i><br></br>and enter
negative <i>StepValue</i> *</td>
<td align="center">Set <i>StartValue</i> &gt; <i>EndValue</i></td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF"><i>Counter</i> comparison</td>
<td align="center">Exit loop if <i>Counter</i> exceeds <i>EndValue</i></td>
<td align="center">Exit loop if <i>Counter</i> outside of range set by
<i>StartValue</i> to <i>EndValue</i></td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center">None</p>
</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="DO_LOOP.htm" target="" title="" alt="" class="MCXref_0">DO…LOOP</a>, <a href="EXIT.htm" target="" title="" alt="" class="MCXref_0">EXIT</a></p>
</td>
</tr>
</table>
<p>*Note: Direction (ie: increment/decrement) cannot be changed at runtime.</p>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">FOR...NEXT</span> loops let your program execute a series of instructions for a
specified number of repetitions (called iterations). By default, each time through
the loop, the counter variable is incremented by 1. It will continue to loop until
the result of the counter is outside of the range set by <i>StartValue</i> and
<i>EndValue</i>. Also, <span class="keyword_in_text">FOR...NEXT</span> loops always execute at least once. The
simplest form is shown here: </p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL reps = B2 ' FOR...NEXT loop counter
Main:
FOR reps = 1 TO 3 ' repeat with Reps = 1, 2, 3
DEBUG "*" ' print * on the screen
NEXT
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
reps VAR Nib ' FOR...NEXT loop counter
Main:
FOR reps = 1 TO 3 ' repeat with Reps = 1, 2, 3
DEBUG "*" ' print * on the screen
NEXT
END
</pre>
<p class="PlainText">In the above code, the <span class="keyword_in_text">FOR</span> command sets Reps = 1. Then the <span class="keyword_in_text">DEBUG</span>
line (within the <span class="keyword_in_text">FOR...NEXT</span> loop) is executed; printing an asterisk (*) on
the screen. When the BASIC Stamp sees the <span class="keyword_in_text">NEXT</span> command, it goes back to
the previous <span class="keyword_in_text">FOR</span> command, adds 1 to Reps and compares the result to the
range set by <i>StartValue</i> and <i>EndValue</i>. If reps is still within range,
it executes the code in the loop again. Each time the <span class="keyword_in_text">FOR...NEXT</span> loop
executes, the value of reps is updated (incremented by 1) and the code within the
loop (the <span class="keyword_in_text">DEBUG</span> line) is executed; printing another asterisk on the screen.
This code will run through the loop three times; setting reps to 1, 2 and 3, and
printing three asterisks on the screen. After the third loop, again the BASIC
Stamp goes back up to the <span class="keyword_in_text">FOR</span> command, adds 1 to reps and compares the result
(4 in this case) to the range. Since the range is 1 to 3 and the value is 4 (outside
the range) the <span class="keyword_in_text">FOR...NEXT</span> loop is done and the BASIC Stamp will jump down
to the first line of code following the <span class="keyword_in_text">NEXT</span> command.</p>
<p class="PlainText">You can view the changing values of reps by including the reps variable in a
<span class="keyword_in_text">DEBUG</span> command within the loop: </p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL reps = B2 ' FOR...NEXT loop counter
Main:
FOR reps = 1 TO 3 ' repeat with Reps = 1, 2, 3
DEBUG #reps, CR ' print number on the screen
NEXT
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
reps VAR Nib ' FOR...NEXT loop counter
Main:
FOR reps = 1 TO 3 ' repeat with Reps = 1, 2, 3
DEBUG DEC reps, CR ' print number on the screen
NEXT
END
</pre>
<p class="PlainText">Running this example should display "1" , "2", and "3" on the screen.</p>
<p class="PlainText"><span class="keyword_in_text">FOR...NEXT</span> can also be made to decrement (rather than increment) the
counter variable. The BS1 does this when you specify a negative <i>StepValue</i>(as well as a <i>StartValue</i> that is greater than the <i>EndValue</i>). All
other BASIC Stamp models do this automatically when the <i>StartValue</i> is greater
than the <i>EndValue</i>. Examples of both are shown below:</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL reps = B2 ' FOR...NEXT loop counter
Main:
FOR reps = 3 TO 1 STEP -1 ' repeat with Reps = 3, 2, 1
DEBUG #reps, CR ' print number on the screen
NEXT
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
reps VAR Nib ' FOR...NEXT loop counter
Main:
FOR reps = 3 TO 1 ' repeat with Reps = 3, 2, 1
DEBUG DEC reps, CR ' print number on the screen
NEXT
END
</pre>
<p class="PlainText">Note that the code for the BS2 series did not use the optional <span class="keyword_in_text">STEP</span> argument.
This is because we wanted to decrement by positive 1 anyway (the default unit)
and the BASIC Stamp realizes it needs to decrement because the <i>StartValue</i>is greater than the <i>EndValue</i>. A negative <i>StepValue</i> on the BS2 series
would be treated as its positive, two's complement counterpart. For example, -1
in two's complement is 65535. So the following code executes only once: </p><pre class="BScode" xml:space="preserve">
reps VAR Nib ' FOR...NEXT loop counter
Main:
FOR reps = 3 TO 1 STEP -1 ' decrement 3 by 65535
DEBUG DEC reps, CR ' print number on the screen
NEXT
END
</pre>
<p class="PlainText">The above code would run through the loop once with <i>reps</i> set to 3. The second
time around, it would decrement <i>reps</i> by 65535 (-1 is 65535 in two's complement)
effectively making the number -65532 (4 in two's complement) which is outside the
range of the loop.</p>
<p>All the arguments in the <span class="keyword_in_text">FOR...NEXT</span> command can be constants, variables
or expressions (on the BS2 series). This leads to some interesting uses. For
example, if you make the <i>StartValue</i> and <i>EndValue</i> a variable, and
change their values within the loop, you'll change the behavior of the loop itself.
Try the following:</p><pre class="BScode" xml:space="preserve">
reps VAR Byte ' counter for the FOR/NEXT loop
startVal VAR Byte
endVal VAR Byte
Setup:
startVal = 1 ' initialize startVal to 1
endVal = 3 ' initialize endVal to 3
Main:
FOR reps = startVal TO endVal ' repeat for 1 to 3
DEBUG DEC reps, CR
IF (reps = 3) THEN ' if reps = 3 then swap startVal and endVal
startVal = 3 ' otherwise continue loop
endVal = 1
ENDIF
NEXT
</pre>
<p class="PlainText">Here the loop starts with a range of 1 to 3. First, the <span class="keyword_in_text">DEBUG</span> line
prints the value of <i>reps</i>. Then the <span class="keyword_in_text">IF...THEN</span> line makes a decision; if
<i>reps</i> is equal to 3, then swap the order of <i>startVal</i> and <i>endVal</i>,
otherwise continue the loop execution. The next time through the loop (after
<i>startVal</i> and <i>endVal</i> have been swapped), <i>reps</i> will be decremented
instead of incremented because <i>startVal</i> is greater than <i>endVal</i>.
The result is a display on the screen of the numbers 1, 2, 3, 2, 1.</p>
<p class="PlainText">The following example uses the value of <i>reps</i> as the <i>StepValue</i>. This
creates a display of power's of 2 (1, 2, 4, 8, 16, 32, 64, etc):</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL reps = B2 ' FOR...NEXT loop counter
Main:
FOR reps = 1 TO 256 STEP reps ' each loop add current value of Reps
DEBUG reps ' show reps in Debug window.
NEXT
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
reps VAR Byte ' FOR...NEXT loop counter
Main:
FOR reps = 1 TO 256 STEP reps ' each loop add current value of Reps
DEBUG ? DEC reps ' show reps in debug window.
NEXT
END
</pre>
<p class="PlainText">There is a potential bug that you should be careful to avoid. The BASIC Stamp
uses unsigned 16-bit integer math for any math operation it performs, regardless
of the size of values or variables. The maximum value the BASIC Stamp can internally
calculate is 65535 (the largest 16-bit number). If you add 1 to 65535, you get 0
as the 16-bit register rolls over (like a car's odometer does when you exceed
the maximum mileage it can display). Similarly, if you subtract 1 from 0, you'll
get 65535 as the 16-bit register rolls under (a rollover in the opposite direction).</p>
<p class="PlainText">If you write a <span class="keyword_in_text">FOR...NEXT</span> loop who's <i>StepValue</i> would cause the
counter variable to go past 65535, this rollover may cause the loop to execute
more times than you expect. Try the following example: </p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL reps = W1 ' FOR...NEXT loop counter
Main:
FOR reps = 0 TO 65535 STEP 3000 ' each loop add 3000
DEBUG reps ' show reps in debug window
NEXT
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL reps = W1 ' FOR...NEXT loop counter
Main:
FOR reps = 0 TO 65535 STEP 3000 ' each loop add 3000
DEBUG reps ' show reps in debug window
NEXT
END
</pre>
<p class="PlainText">The value of <i>reps</i> increases by 3000 each trip through the loop. As it approaches
the <i>EndValue</i>, an interesting thing happens; <i>reps</i> is: 57000, 60000, 63000,
464, 3464... It passes the <i>EndValue</i>, rolls over and keeps going. That's
because the result of the calculation 63000 + 3000 exceeds the maximum capacity
of a 16-bit number and then rolls over to 464. When the result of 464 is tested
against the range ("Is <i>reps</i> &gt; 0 and is <i>reps</i> &lt; 65500?") it passes the test and the
loop continues. </p>
<p class="PlainText">A similar symptom can be seen in a program whose <i>EndValue</i> is mistakenly
set higher than what the counter variable can hold. The example below uses a
byte-sized variable, but the <i>EndValue</i> is set to a number greater than what
will fit in a byte:</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL reps = W1 ' FOR...NEXT loop counter
Main:
FOR reps = 0 TO 300 ' each loop add 1
DEBUG reps ' show reps in debug window
NEXT
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
reps VAR Byte ' FOR...NEXT loop counter
Main:
FOR reps = 0 TO 300 ' each loop add 1
DEBUG DEC ? reps ' show reps in debug window
NEXT
END
</pre>
<p class="PlainText">Here, <i>reps</i> is a byte variable; which can only hold the number range 0 to 255.
The <i>EndValue</i> is set to 300, however; greater than 255. This code will loop
endlessly because when reps is 255 and the <span class="keyword_in_text">FOR...NEXT</span> loop adds 1, reps
becomes 0 (bytes will rollover after 255 just like words will rollover after 65535).
The result, 0, is compared against the range (0 - 255) and it is found to be within
the range, so the <span class="keyword_in_text">FOR...NEXT</span> loop continues.</p>
<p class="PlainText">It's important to realize that on the BS2 series, the test is against the entire
range, not just the <i>EndValue</i>. The code below is a slight modification of
the previous example (the <i>StartValue</i> is 10 instead of 0) and will not loop
endlessly.</p>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
reps VAR Byte ' FOR...NEXT loop counter
Main:
FOR reps = 10 TO 300 ' each loop add 1
DEBUG DEC ? reps ' show reps in debug window
NEXT
END
</pre>
<p class="PlainText"><i>Reps</i> still rolls over to 0, as before, however, this time it is outside the
range of 10 to 255. The loop stops, leaving <i>reps</i> at 0. Note that this code is
still in error since <i>reps</i> will never reach 300 until it is declared as a Word.</p>
<p class="PlainText">NOTE: On the BS1, the loop will continue until <i>Counter</i> has gone past
<i>EndValue</i>. The rollover error will still occur if the BS1 cannot determine
if <i>Counter</i> went past <i>EndValue</i>.</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>

View File

@ -0,0 +1,138 @@
<?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>FREQOUT</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">FREQOUT</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/FreqoutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">FREQOUT Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">FREQOUT</span> <![CDATA[ ]]><i>Pin</i>,<i> Duration</i>,<i> Freq1 </i>{,<i> Freq2</i>}</p>
<h2>Function</h2>
<p class="PlainText">Generate one or two sine-wave tones for a specified duration.
</p>
<ul>
<li value="1"><b><i>Pin</i></b> a variable/constant/expression (0 - 15) that specifies the
I/O pin to use. This pin will be set to output mode.</li>
<li value="2"><b><i>Duration</i></b> a variable/constant/expression (0 - 65535) specifying
the amount of time to generate the tone(s). The unit of time for Duration is
described in the table below.</li>
<li value="3"><b><i>Freq1</i></b> is a variable/constant/expression (0 - 32767) specifying
frequency of the first tone. The unit of <i>Freq1</i> is described in the table
below.</li>
<li value="4"><b><i>Freq2</i></b> is an optional argument exactly like <i>Freq1</i>. When specified,
two frequencies will be mixed together on the specified I/O pin.</li>
</ul>
<p class="PlainText">Note: See <a href="SOUND.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SOUND</a> for the BS1.</p>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="20%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2 and BS2e</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2sx</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2p</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2pe</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Units in <i>Duration</i></td>
<td align="center">1 ms</td>
<td align="center">0.4 ms</td>
<td align="center">0.265 ms</td>
<td align="center">1 ms</td>
<td align="center">0.166 ms</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Units in <i>Freq1</i> and <i>Freq2</i></td>
<td align="center">1 Hz</td>
<td align="center">2.5 Hz</td>
<td align="center">3.77 Hz</td>
<td align="center">1.51 Hz</td>
<td align="center">6.03 Hz</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Range of frequency</td>
<td align="center">0 to 32767 Hz</td>
<td align="center">0 to 81.917 kHz</td>
<td align="center">0 to 123.531 kHz</td>
<td align="center">0 to 49.478 kHz</td>
<td align="center">0 to 197.585 kHz</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="5">
<p colspan="5" align="center"><a href="DTMFOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DTMFOUT</a>, <a href="PWM.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">PWM</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">FREQOUT</span> generates one or two sine waves using a pulse-width modulation
algorithm. The circuits in the figure below work by filtering out the
high-frequency PWM used to generate the sine waves. <span class="keyword_in_text">FREQOUT</span> works over a
very wide range of frequencies so at the upper end of its range, those PWM
filters will also filter out most of the desired frequency. You may find it
necessary to reduce values of the parallel capacitors shown in the circuit, or
to devise a custom active filter for your application. </p>
<center>
<img src="../../graphics/freqout_sch.gif" width="387" height="385" border="0">
</img>
</center>
<p class="PlainText">&#160;</p>
<p class="PlainText">Here's a simple <span class="keyword_in_text">FREQOUT</span> command: </p><pre class="BScode" xml:space="preserve">
FREQOUT 2, 1000, 2500
</pre>
<p class="PlainText">On the BS2, this command generates a 2500 Hz tone for 1 second (1000 ms) on
I/O pin 2. See the table above for timing data on other BASIC Stamp models.</p>
<p class="PlainText">To play two tones on the same I/O pin at once:</p><pre class="BScode" xml:space="preserve"> FREQOUT 2, 1000, 2500, 3000</pre>
<p class="PlainText">This will generate a 2500 Hz and 3000 Hz tone (on the BS2) for 1 second. The frequencies will mix together for a chord- or bell-like sound. To generate a silent pause, specify frequency value(s) of 0. </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>

View File

@ -0,0 +1,181 @@
<?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>GET</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">GET</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/GetPutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GET / PUT Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">GET</span> <![CDATA[ ]]><i>Location</i>,<i><![CDATA[ ]]></i>{Word}<i> Variable
</i>{,<i><![CDATA[ ]]></i>{Word}<i> Variable ...</i>}</p>
<h2>Function</h2>
<p class="PlainText">Read value(s) from Scratchpad RAM, starting at <i>Location</i> and store in
<i>Variable(s)*</i>.
</p>
<ul>
<li value="1"><b><i>Location</i></b> is a variable/constant/expression (0 63 for Bs2e
and BS2sx, and 0 135 for BS2p, BS2pe, and BS2px) that specifies the Scratchpad
RAM location to read from.</li>
<li value="2"><b><i>Variable</i></b> is a variable (usually a byte; unless using the optional <i>Word</i> modifier) to store the
value into. </li>
</ul>
<p>*Note: The optional arguments require PBASIC 2.5.</p>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="24%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="38%" align="center" bgcolor="#CFCFCF">BS2e and BS2sx</td>
<td width="38%" align="center" bgcolor="#CFCFCF">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Scratchpad RAM size and organization</td>
<td align="center">64 bytes (0 63). Organized as bytes only.</td>
<td align="center">136 bytes (0 135). Organized as bytes only.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">General purpose locations</td>
<td align="center">0 - 62</td>
<td align="center">0 126</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special use location</td>
<td align="center">Current program slot number in read-only location 63.</td>
<td align="center">Current program slot number in lowest nibble of read-only location 127. Current read/write slot number in highest nibble of location 127. </td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Additional locations</td>
<td align="center">None</td>
<td align="center">Locations 128 - 135 (read-only) hold state of polled input pins.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center"><a href="PUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">PUT</a>
</td>
<td align="center"><a href="PUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">PUT</a>, <a href="STORE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">STORE</a></td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">PBASIC 2.5 Syntax Options</td>
<td align="center" colspan="2">
<p colspan="2" align="center">Multiple sequential variables may be read from the Scratchpad RAM. </p>
<p colspan="2" align="center">The optional Word modifier may be specified to retrieve 16-bit values.</p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">By default, the <span class="keyword_in_text">GET</span> command reads a byte-sized value from the specified
Scratchpad RAM location and stores it into variable. All values in all locations
can be retrieved from within any of the eight program slots.</p>
<p class="PlainText">Scratchpad RAM is useful for passing data to programs in other program
slots and for additional workspace. It is different than regular RAM in
that symbol names cannot be assigned directly to locations and each
location is always configured as a byte only. The following code will read
the value at location 25, store it in a variable called <i>temp</i> and display
it:</p>
<p class="PlainText">The following example illustrates this:</p><pre class="BScode" xml:space="preserve">
temp VAR Byte
Main:
GET 25, temp
DEBUG DEC temp
END
</pre>
<p class="PlainText">When using the $PBASIC 2.5 directive, multiple sequential variables may be read
from the Scratchpad RAM, starting at <i>Location</i>, and the Word modifier may
be specified for 16-bit values.</p>
<p>
<img src="../../graphics/bsesxppepx_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
' {$PBASIC 2.5}
value VAR Word
value2 VAR Word
addr VAR Word ' EEPROM address
test VAR Byte ' test byte read back
Main:
value = $11
value2 = $2003
PUT 0, value, Word value2 ' write value to SP location 0
' and value2 to SP locations 1 &amp; 2
value = $FF ' modify variables
value2 = $FFFF
GET 0, value, Word value2 ' retrieve from Scratchpad
DEBUG HEX2 ? value ' display
DEBUG HEX4 ? value2
END
</pre>
<p class="PlainText">The low nibble of location 63 (BS2e and BS2sx) and location 127 (BS2p,
BS2pe, and BS2px) is a special, read-only location that always contains the
number of the currently running program slot. On the BS2p, BS2pe, and BS2px,
the high nibble of location 127 also contains the current program slot that
will be used for the <span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> commands. See the
demo program for an example of use.</p>
<p>
<img src="../../graphics/bsppepx_inline.gif" border="0">
</img>
</p>
<p class="PlainText">On the BS2p and BS2pe, the state of polled input pins can be retrieved from
upper Scratchpad locations:</p>
<ul>
<li value="1">128 : MAINIO pins 0 - 7</li>
<li value="2">129 : MAINIO pins 8 - 15</li>
<li value="3">130 : AUXIO pins 0 - 7</li>
<li value="4">131 : AUXIO pins 8 - 15</li>
</ul>
<p class="PlainText">This information can be used to determine which input pin (or pins) has
triggered a polled event.</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>

View File

@ -0,0 +1,156 @@
<?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>GOSUB</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">GOSUB</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/GosubEx.htm" target="" title="" alt="" class="MCXref_0">GOSUB Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">GOSUB</span> <![CDATA[ ]]><i>Address</i></p>
<h2>Function</h2>
<p class="PlainText">Store the address of the next instruction after <span class="keyword_in_text">GOSUB</span>, then go to the point
in the program specified by <i>Address</i>; with the intention of returning to the
stored address.
</p>
<ul>
<li value="1"><b><i>Address</i></b> is a label that specifies where to go.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="24%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="38%" align="center" bgcolor="#CFCFCF">BS1*</td>
<td width="38%" align="center" bgcolor="#CFCFCF">BS2 Family</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Maximum GOSUBs per program</td>
<td align="center">16</td>
<td align="center">255</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Maximum nested GOSUBs</td>
<td align="center">4</td>
<td align="center">4</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center"><a href="GOTO.htm" target="" title="" alt="" class="MCXref_0">GOTO</a>
</td>
<td align="center"><a href="ON_GOSUB.htm" target="" title="" alt="" class="MCXref_0">ON...GOSUB</a>, <a href="GOTO.htm" target="" title="" alt="" class="MCXref_0">GOTO</a></td>
</tr>
</table>
<p>&#160;</p>
<P>*<img src="../../graphics/bs1note.gif" style="vertical-align: super;" /> Note: Using <span class="keyword_in_text">GOSUB</span> on the BS1 requires variables B12 and B13 (W6) making them unavailable for general program use.</P>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">GOSUB</span> is a close relative of <span class="keyword_in_text">GOTO</span>, in fact, its name means, "GO
to a SUBroutine". When a PBASIC program reaches a <span class="keyword_in_text">GOSUB</span>, the program
executes the code beginning at the specified address label. Unlike <span class="keyword_in_text">GOTO</span>,
<span class="keyword_in_text">GOSUB</span> also stores the address of the instruction immediately following
itself. When the program encounters a <span class="keyword_in_text">RETURN</span> command, it interprets it
to mean, "go to the instruction that follows the most recent <span class="keyword_in_text">GOSUB</span>." In
other words, a <span class="keyword_in_text">GOSUB</span> makes the BASIC Stamp do a similar operation as
you do when you see a table or figure reference in this manual; 1) you
remember where you are, 2) you go to the table or figure and read the
information there, and 3) when you've reached the end of it, you "return"
to the place you were reading originally.</p>
<h3>GOSUB Can Save EEPROM (Program) Space</h3>
<p class="PlainText"><span class="keyword_in_text">GOSUB</span> is mainly used to execute the same piece of code from multiple
locations. If you have, for example, a block of three lines of code that need
to be run from 10 different locations in your entire program you could
simple copy and paste those three lines to each of those 10 locations. This
would amount to a total of 30 lines of repetitive code (and extra space
wasted in the program memory). A better solution is to place those three
lines in a separate routine, complete with it's own label and followed by a
<span class="keyword_in_text">RETURN</span> command, then just use a <span class="keyword_in_text">GOSUB</span> command at each of the 10
locations to access it. This technique can save a lot of program space.</p>
<p class="PlainText">Try the example below:
</p><pre class="BScode" xml:space="preserve">
Main:
GOSUB Hello
DEBUG "How are you?", CR
END
Hello:
DEBUG "Hello my friend.", CR
RETURN
</pre>
<p class="PlainText">The above code will start out by executing a <span class="keyword_in_text">GOSUB </span>to the section of code beginning with the label Hello. It will print "Hello my friend." on the screen then <span class="keyword_in_text">RETURN </span>to the line after the <span class="keyword_in_text">GOSUB</span>...which prints "How are you?" and <span class="keyword_in_text">END</span>s.</p>
<h3>Watch Out For Subroutines That Your Program Can "Fall Into"</h3>
<p class="PlainText">There's another interesting lesson here; what would happen if we removed
the <span class="keyword_in_text">END</span> command from this example? Since the BASIC Stamp reads the
code from left to right / top to bottom (like the English language) once it
had returned to and run the "How are you?" line, it would naturally "fall
into" the Hello routine again. Additionally, at the end of the Hello routine,
it would see the <span class="keyword_in_text">RETURN</span> again (although it didn't <span class="keyword_in_text">GOSUB</span> to that
routine this time) and because there wasn't a previous place to return to, the
BASIC Stamp will start the entire program over again. This would cause
an endless loop. The important thing to remember here is to always make
sure your program doesn't allow itself to "fall into" a subroutine.</p>
<p>*<img src="../../graphics/bs1note.gif" style="vertical-align: super;"></img> Note: On the BS1, a <span class="keyword_in_text">RETURN</span> without a <span class="keyword_in_text">GOSUB</span> will return
the program to the last <span class="keyword_in_text">GOSUB</span> (or will end the program if no <span class="keyword_in_text">GOSUB</span>was executed).</p>
<h3>GOSUB Limitations</h3>
<p class="PlainText">Only a limited number of <span class="keyword_in_text">GOSUB</span>s are allowed per program (as shown in above),
and they may be nested only four levels deep. In other words, the subroutine that's
the destination of a <span class="keyword_in_text">GOSUB</span> can contain a <span class="keyword_in_text">GOSUB</span> to another subroutine,
and so on, to a maximum depth (total number of <span class="keyword_in_text">GOSUB</span>s before the first
<span class="keyword_in_text">RETURN</span>) of four. Any deeper, and the program will "forget" its way back to
the starting point (the instruction following the very first <span class="keyword_in_text">GOSUB</span>).</p>
<p class="PlainText">When <span class="keyword_in_text">GOSUB</span>s are nested, each <span class="keyword_in_text">RETURN</span> takes the program back to the
instruction after the most-recent <span class="keyword_in_text">GOSUB</span>. As is mentioned above, if the
BASIC Stamp encounters a <span class="keyword_in_text">RETURN</span> without a previous <span class="keyword_in_text">GOSUB</span>, the
entire program starts over from the beginning. Take care to avoid these
phenomena.</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>

View File

@ -0,0 +1,105 @@
<?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>GOTO</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">GOTO</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/GotoEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GOTO Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">GOTO</span> <![CDATA[ ]]><i>Address</i></p>
<h2>Function</h2>
<p class="PlainText">Jump the point in the program specified by <i>Address</i>.
</p>
<ul>
<li value="1"><b><i>Address</i></b> is a label that specifies where to go.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="20%" align="CENTER" bgcolor="#CFCFCF">&#160;</td>
<td align="center" bgcolor="#CFCFCF">BS1</td>
<td align="center" bgcolor="#CFCFCF">All BS2 Models</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center">
<p align="CENTER"><a href="BRANCH.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">BRANCH</a>, <a href="GOSUB.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GOSUB</a></p>
</td>
<td align="center">
<p align="CENTER"><a href="ON_GOTO.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">ON...GOTO</a>, <a href="BRANCH.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">BRANCH</a>, <a href="GOSUB.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GOSUB</a></p>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Max. GOTOs<br />per program</td>
<td align="center" colspan="2">Unlimited, but good programming practices suggest minimizing the use of <span class="keyword_in_text">GOTO</span>.</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">GOTO</span> command makes the BASIC Stamp execute the code that starts at the
specified <i>Address</i> location. The BASIC Stamp reads PBASIC code from
left-to-right, top-to-bottom, just like in the English language. The <span class="keyword_in_text">GOTO</span>command forces the BASIC Stamp to jump to another section of code.</p>
<p class="PlainText">A common use for <span class="keyword_in_text">GOTO</span> is to create endless loops; programs that repeat
a group of instructions over and over. For example:
</p><pre class="BScode" xml:space="preserve">
Hello:
DEBUG "Hi", CR
PAUSE 500
GOTO Hello
</pre>
<p class="PlainText">The above code will print "Hi" on the screen, over and over again. The
<span class="code_in_text">GOTO Hello</span> line simply tells it to go back to the code that begins with
the label Hello.</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>

View File

@ -0,0 +1,109 @@
<?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>HIGH</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">HIGH</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/HighLowEx.htm" target="" title="" alt="" class="MCXref_0">HIGH / LOW Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">HIGH</span> <![CDATA[ ]]><i>Pin</i></p>
<h2>Function</h2>
<p class="PlainText">Make the specified pin an output and high.
</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression (0 - 15) that specifies
which I/O pin to set high. This pin will be placed into output mode.</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 cellpadding="4" cellspacing="0" border="1" style="caption-side: top;width: 100%;">
<col />
<col />
<tr bgcolor="#CFCFCF">
<td width="15%" align="center">&#160;</td>
<td width="85%" align="center">BS1 and all BS2 models</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td>
<p align="center"><a href="LOW.htm" target="" title="" alt="" class="MCXref_0">LOW</a>, <a href="TOGGLE.htm" target="" title="" alt="" class="MCXref_0">TOGGLE</a></p>
</td>
</tr>
</table>
<p>&#160;</p>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">HIGH</span> command sets the specified pin to 1 (a +5 volt level) and then
sets its mode to output. For example:
</p><pre class="BScode" xml:space="preserve">
&#160;HIGH 6
</pre>
<p class="PlainText">...does exactly the same thing as:</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0" />
</p><pre class="BScode" xml:space="preserve">
&#160;PIN6 = 1
&#160;DIR6 = 1
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
&#160;OUT6 = 1
&#160;DIR6 = 1
</pre>
<p class="PlainText">Using the <span class="keyword_in_text">HIGH</span> command is faster in this case.</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>

View File

@ -0,0 +1,366 @@
<?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>I2CIN</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">I2CIN</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/I2cInOutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">I2CIN / I2COUT Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">I2CIN</span> <![CDATA[ ]]><i>Pin</i>,<i> SlaveID</i>,<i><![CDATA[ ]]></i>{<i>Address </i>{\<i>LowAddress</i>},} [<i>InputData</i>]</p>
<h2>Function</h2>
<p class="PlainText">Receive data from a device using the I<sup>2</sup>C<sup>®</sup> protocol.
</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression (0 or 8) that specifies
which I/O pins to use. I<sup>2</sup>C devices require two I/O pins to communicate.
The <i>Pin</i> argument serves a double purpose; specifying the first pin (for
connection to the devices's SDA pin) and, indirectly, the other required pin (for
connection to the devices's SCL pin). See explanation below. Both I/O pins will
be toggled between output and input mode during the <span class="keyword_in_text">I2CIN</span> command and both
will be set to input mode by the end of the <span class="keyword_in_text">I2CIN</span> command.</li>
<li value="2"><b><i>SlaveID</i></b> is a variable/constant/expression (0 - 255) indicating
the unique ID of the I<sup>2</sup>C device.</li>
<li value="3"><b><i>Address</i></b> is a variable/constant/expression (0 - 255) indicating
the desired address within the I<sup>2</sup>C device to receive data from. The
<i>Address</i> argument may be used with the optional <i>LowAddress</i> argument
to indicate a word-sized address value. Note that some devices like the
PCF8574 do not require an internal address, so this parameter is optional (BS2p
firmware 1.3 or later is required to omit the <i>Address</i> parameter).</li>
<li value="4"><b><i>LowAddress</i></b> is a variable/constant/expression (0 - 255)
indicating the low-byte of the word-sized address within the I<sup>2</sup>C
device to receive data from. This argument must be used along with the
<i>Address</i> argument.</li>
<li value="5"><b><i>InputData</i></b> is a list of variables and modifiers that tells
<span class="keyword_in_text">I2CIN</span> what to do with incoming data. <span class="keyword_in_text">I2CIN</span> can store data in a
variable or array, interpret numeric text (decimal, binary, or hex) and store
the corresponding value in a variable, wait for a fixed or variable sequence
of bytes, or ignore a specified number of bytes. These actions can be combined
in any order in the <i>InputData</i> list.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td align="center">&#160;</td>
<td align="center" colspan="2">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td width="250" align="center" bgcolor="#CFCFCF">Value of <i>Pin</i></td>
<td width="40%" align="center">0</td>
<td width="40%" align="center">8</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">I/O Pin Arrangement</td>
<td>0: Serial Data (SDA) pin<br></br>1: Serial Clock (SCL) pin</td>
<td>8: Serial Data (SDA) pin<br></br>9: Serial Clock (SCL) pin</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Transmission Rate</td>
<td colspan="2">Approximately 81 kBits/sec (BS2p), 45 kBits/sec (BS2pe),
83 kBits/sec (BS2px) -- not including overhead.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td colspan="2">Both the SDA and SCL pins must have 4.7 kΩ
pull-up resisters.<br /> The I2CIN command does not allow for multiple masters.<br /> The BASIC Stamp cannot operate as an I<sup>2</sup>C slave device.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="2">
<p colspan="2" align="center"><a href="I2COUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">I2COUT</a>
</p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The I<sup>2</sup>C protocol is a form of synchronous serial communication
developed by Philips Semiconductor. It only requires two I/O pins and both
pins can be shared between multiple I<sup>2</sup>C devices. The <span class="keyword_in_text">I2CIN</span>command allows the BASIC Stamp to receive data from an I<sup>2</sup>C device.</p>
<p class="PlainText">The following is an example of the <span class="keyword_in_text">I2CIN</span> command:</p><pre class="BScode" xml:space="preserve">
result VAR Byte
Main:
I2CIN 0, $A1, 0, [result]
STOP
</pre>
<p class="PlainText">This code will transmit a "read" command to an I<sup>2</sup>C device (connected
to I/O pins 0 and 1) and then will receive one byte and store it in the variable
<i>result</i>. Though it may seem strange, the <span class="keyword_in_text">I2CIN</span> command first transmits
some data and then receives data. It must first transmit information (ID, read/write
and address) in order to tell the I<sup>2</sup>C device what information it would
like to receive. The exact information transmitted ($A1, 0) depends on the
I<sup>2</sup>C device that is being used.</p>
<p class="PlainText">The example above will read a byte of data from location 0 of a 24LC16B EEPROM
from Microchip. The figure below shows the proper wiring for this example to work.
The <i>SlaveID</i> argument ($A1) is both the ID of the chip and the command to
read from the chip; the 1 means read. The <i>Address</i> argument (0) is the EEPROM
location to read from. Note that the <span class="keyword_in_text">I2CIN</span> command will make up to eight
attempts to connect to the addressed device. If the device does not properly
respond, the <span class="keyword_in_text">I2CIN</span> command will timeout and the <i>InputData</i> will
remain unchanged.</p>
<p class="PlainText"><b>Note</b>: The 4.7 kΩ resisters are required for the <span class="keyword_in_text">I2CIN</span>command to function properly.</p>
<center>
<img src="../../graphics/24lc16_sch.gif" width="262" height="234" border="0">
</img>
</center>
<p class="PlainText">The <span class="keyword_in_text">I2CIN</span> command's <i>InputData</i> argument is similar to the
<span class="keyword_in_text">SERIN</span> command's <i>InputData</i> argument. This means data can be received
as ASCII character values, decimal, hexadecimal and binary translations and string
data as in the examples below. (Assume the 24LC16B EEPROM is used and it has the
string, "Value: 3A:101" stored, starting at location 0).</p><pre class="BScode" xml:space="preserve">
value VAR Byte(13)
Main:
I2CIN 0, $A1, 0, [value] ' receive ASCII code for "V"
I2CIN 0, $A1, 0, [DEC value] ' receive number 3
I2CIN 0, $A1, 0, [HEX value] ' receive number $3A
I2CIN 0, $A1, 0, [BIN value] ' receive number %101
I2CIN 0, $A1, 0, [STR value\13] ' receive string "Value: 3A:101"
STOP
</pre>
<p class="PlainText">The tables below list all the available conversion formatters and special
formatters available to the <span class="keyword_in_text">I2CIN</span> command. See the <a href="SERIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SERIN</a>&#160;command for additional information and examples
of their use.</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="15%">Conversion Formatter</td>
<td width="45%">Type of Number</td>
<td width="30%">Numeric Characters Accepted</td>
<td width="10%">Notes</td>
</tr>
<tr align="center">
<td>DEC{1..5}</td>
<td>Decimal, optionally limited to 1 - 5 digits</td>
<td>0 through 9</td>
<td>1</td>
</tr>
<tr align="center">
<td>SDEC{1..5}</td>
<td>Signed decimal, optionally limited to 1 - 5 digits</td>
<td>-, 0 through 9</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>HEX{1..4}</td>
<td>Hexadecimal, optionally limited to 1 - 4 digits</td>
<td>0 through 9, A through F</td>
<td>1,3</td>
</tr>
<tr align="center">
<td>SHEX{1..4}</td>
<td>Signed hexadecimal, optionally limited to 1 - 4 digits </td>
<td>-, 0 through 9, A through F</td>
<td>1,2,3</td>
</tr>
<tr align="center">
<td>IHEX{1..4}</td>
<td>Indicated hexadecimal, optionally limited to 1 - 4 digits</td>
<td>$, 0 through 9, A through F</td>
<td>1,3,4</td>
</tr>
<tr align="center">
<td>ISHEX{1..4}</td>
<td>Signed, indicated hexadecimal, optionally limited to 1 - 4 digits</td>
<td>-, $, 0 through 9, A through F</td>
<td>1,2,3,4</td>
</tr>
<tr align="center">
<td>BIN{1..16}</td>
<td>Binary, optionally limited to 1 - 16 digits</td>
<td>0, 1</td>
<td>1</td>
</tr>
<tr align="center">
<td>SBIN{1..16}</td>
<td>Signed binary, optionally limited to 1 - 16 digits</td>
<td>-, 0, 1</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>IBIN{1..16}</td>
<td>Indicated binary, optionally limited to 1 - 16 digits</td>
<td>%, 0, 1</td>
<td>1,4</td>
</tr>
<tr align="center">
<td>ISBIN{1..16}</td>
<td>Signed, indicated binary, optionally limited to 1 - 16 digits</td>
<td>-, %, 0, 1</td>
<td>1,2,4</td>
</tr>
<tr align="center">
<td>NUM</td>
<td>Generic numeric input; hex or binary number must be indicated</td>
<td>$, %, 0 through 9, A through F</td>
<td>1,3,4</td>
</tr>
<tr align="center">
<td>SNUM</td>
<td>Similar to NUM with value treated as signed with range -32768 to +32767</td>
<td>-, $, %, 0 through 9, A through F</td>
<td>1,2,3,4</td>
</tr>
</table>
<ol>
<li value="1">All numeric conversions will continue to accept new data until receiving
either the specified number of digits (ex: three digits for DEC3) or a non-numeric
character.</li>
<li value="2">To be recognized as part of a number, the minus sign (-) must immediately
precede a numeric character. The minus sign character occurring in non-numeric
text is ignored and any character (including a space) between a minus and a number
causes the minus to be ignored.</li>
<li value="3">The hexadecimal formatters are not case-sensitive; "a" through "f" means
the same as "A" through "F".</li>
<li value="4">Indicated hexadecimal and binary formatters ignore all characters, even valid
numerics, until they receive the appropriate prefix ($ for hexadecimal, % for
binary). The indicated formatters can differentiate between text and hexadecimal
(ex: ABC would be interpreted by HEX as a number but IHEX would ignore it unless
expressed as $ABC). Likewise, the binary version can distinguish the decimal
number 10 from the binary number %10. A prefix occurring in non-numeric text
is ignored, and any character (including a space) between a prefix and a number
causes the prefix to be ignored. Indicated, signed formatters require that the
minus sign come before the prefix, as in -$1B45.</li>
</ol>
<p>&#160;</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="20%">Special Formatter</td>
<td width="80%">Action</td>
</tr>
<tr>
<td align="center">STR ByteArray \L {\E}</td>
<td>Input a character string of length L into an array. If specified, an end
character E causes the string input to end before reaching length L. Remaining
bytes are filled with 0s (zeros).</td>
</tr>
<tr>
<td align="center">WAITSTR ByteArray {\L}</td>
<td>Wait for a sequence of bytes matching a string stored in an array variable,
optionally limited to L characters. If the optional L argument is left off,
the end of the array-string must be marked by a byte containing a zero (0).</td>
</tr>
<tr>
<td align="center">SKIP Length</td>
<td>Ignore Length bytes of characters.</td>
</tr>
<tr>
<td align="center">SPSTR Length</td>
<td>Buffer Length bytes (up to 126) of serial characters to Scratchpad RAM,
starting at location 0. Use <a href="GET.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GET</a> to retrieve the characters.</td>
</tr>
</table>
<p>&#160;</p>
<p class="PlainText">The I<sup>2</sup>C protocol has a well-defined standard for the information
passed at the start of each transmission. First of all, any information sent must
be transmitted in units of one byte (8-bits). The first byte, we call the
<i>SlaveID</i>, is an 8-bit pattern whose upper 7-bits contain the unique ID of
the device you wish to communicate with. The lowest bit indicates whether this
is a write operation (0) or a read operation (1). Here is the <i>SlaveID</i> <![CDATA[ ]]>format:</p>
<center>
<table cellpadding="4" cellspacing="0" border="1">
<tr align="center" bgcolor="#CFCFCF">
<td width="35">7</td>
<td width="35">6</td>
<td width="35">5</td>
<td width="35">4</td>
<td width="35">3</td>
<td width="35">2</td>
<td width="35">1</td>
<td width="35">0</td>
</tr>
<tr align="center">
<td>A<sub>6</sub></td>
<td>A<sub>5</sub></td>
<td>A<sub>4</sub></td>
<td>A<sub>3</sub></td>
<td>A<sub>2</sub></td>
<td>A<sub>1</sub></td>
<td>A<sub>0</sub></td>
<td>R/W</td>
</tr>
</table>
</center>
<p>&#160;</p>
<p class="PlainText">The second byte, immediately following the <i>SlaveID</i>, is the <i>Address</i>.
It indicates the 8-bit address (within the device) containing the data you would
like to receive.</p>
<p class="PlainText">Some devices require more than eights bits of address. For this case, the optional
<i>LowAddress</i> argument can be used for the low-byte of the required address.
When using the <i>LowAddress</i> argument, the <i>Address</i> argument is effectively
the high-byte of the address value. For example, if the entire address value is
2050, use 8 for the Address argument and 2 for the <i>LowAddress</i> argument
(8 * 256 + 2 = 2050).</p>
<p class="PlainText">Following the last address byte is the first byte of data. This data byte may
be transmitted or received by the BASIC Stamp. In the case of the <span class="keyword_in_text">I2CIN</span>command, this data byte is transmitted by the device and received by the BASIC
Stamp. Additionally, multiple data bytes can follow the address, depending on the
I<sup>2</sup>C device. Note that every device has different limitations regarding
how may contiguous bytes they can receive or transmit in one session. Be aware of
these device limitations and program accordingly.</p>
<p class="PlainText">Every I<sup>2</sup>C transmission session begins with a Start Condition and
ends with a Stop Condition. Additionally, immediately after every byte is
transmitted, an extra clock cycle is used to send or receive an acknowledgment
signal (ACK). All of these operations are automatically taken care of by the
<span class="keyword_in_text">I2CIN</span> command so that you need not be concerned with them. The general
I<sup>2</sup>C transmission format is shown below.</p>
<center>
<img src="../../graphics/i2c_packet.gif" width="531" height="245" border="0">
</img>
</center>
<p class="PlainText">Since the <span class="keyword_in_text">I2CIN</span> command is intended for input only, it actually overrides
the "R/W" bit (bit 0) in the <i>SlaveID</i> argument. This is done so that it can
use the I<sup>2</sup>C protocol's "Combined Format" for receiving data. Put simply,
this means a command such as:
</p><pre class="BScode" xml:space="preserve"> I2CIN 0, $A1, 10, [result]</pre>
<p class="PlainText">...actually transmits $A0, then 10, then $A1 and then it reads the data back from the device. The $A0 means "write", the 10 is the address to write to and, finally, the $A1 indicates a change of direction; to "read" the location, instead. Even though the <span class="keyword_in_text">I2CIN</span> command really doesn't care what the value of the <i>SlaveID</i>'s LSB is, it is suggested that you still set it appropriately for clarity.
</p>
<p class="PlainText">Also note that the <span class="keyword_in_text">I2CIN</span> command does not support multiple I<sup>2</sup>C
masters and the BASIC Stamp cannot operate as an I<sup>2</sup>C slave device.</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>

View File

@ -0,0 +1,327 @@
<?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>I2COUT</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">I2COUT</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/I2cInOutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">I2CIN / I2COUT Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">I2COUT</span> <![CDATA[ ]]><i>Pin</i>,<i> SlaveID</i>,<i><![CDATA[ ]]></i>{<i>Address </i>{\<i>LowAddress</i>},} [<i>OutputData</i>]</p>
<h2>Function</h2>
<p class="PlainText">Send data to a device using the I<sup>2</sup>C<sup>®</sup> protocol.
</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression (0 or 8) that specifies
which I/O pins to use. I<sup>2</sup>C devices require two I/O pins to communicate.
The <i>Pin</i> argument serves a double purpose; specifying the first pin (for
connection to the device's SDA pin) and, indirectly, the other required pin (for
connection to the device's SCL pin). See explanation below. Both I/O pins will be
toggled between output and input mode during the <span class="keyword_in_text">I2COUT</span> command and both
will be set to input mode by the end of the <span class="keyword_in_text">I2COUT</span> command.</li>
<li value="2"><b><i>SlaveID</i></b> is a variable/constant/expression (0 - 255) indicating
the unique ID of the I<sup>2</sup>C device.</li>
<li value="3"><b><i>Address</i></b> is a variable/constant/expression (0 - 255) indicating
the desired address within the I<sup>2</sup>C device to send data to. The
<i>Address</i> argument may be used with the optional <i>LowAddress</i> argument
to indicate a word-sized address value. Note that some devices like the
PCF8574 do not require an internal address, so this parameter is optional (BS2p
firmware 1.3 or later is required to omit the <i>Address</i> parameter).</li>
<li value="4"><b><i>LowAddress</i></b> is a variable/constant/expression (0 - 255) indicating
the low-byte of the word-sized address within the I<sup>2</sup>C device to send
data to. This argument must be used along with the <i>Address</i> argument.</li>
<li value="5"><b><i>OutputData</i></b> is a list of variables, constants, expressions and
formatters that tells <span class="keyword_in_text">I2COUT</span> how to format outgoing data. <span class="keyword_in_text">I2COUT</span>can transmit individual or repeating bytes, convert values into decimal,
hexadecimal or binary text representations, or transmit strings of bytes from
variable arrays. These actions can be combined in any order in the
<i>OutputData</i> list.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td align="center">&#160;</td>
<td align="center" colspan="2">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td width="250" align="center" bgcolor="#CFCFCF">Value of <i>Pin</i></td>
<td width="40%" align="center">0</td>
<td width="40%" align="center">8</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">I/O Pin Arrangement</td>
<td>0: Serial Data (SDA) pin<br></br>1: Serial Clock (SCL) pin</td>
<td>8: Serial Data (SDA) pin<br></br>9: Serial Clock (SCL) pin</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Transmission Rate</td>
<td colspan="2">Approximately 81 kBits/sec (BS2p), 45 kBits/sec (BS2pe),
83 kBits/sec (BS2px) -- not including overhead.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td colspan="2">Both the SDA and SCL pins must have 4.7 kΩ pull-up
resistors.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="2">
<p colspan="2" align="center"><a href="I2CIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">I2CIN</a>
</p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The I<sup>2</sup>C protocol is a form of synchronous serial communication developed
by Philips Semiconductor. It only requires two I/O pins and both pins can be
shared between multiple I<sup>2</sup>C devices. The <span class="keyword_in_text">I2COUT</span> command allows
the BASIC Stamp to send data to an I<sup>2</sup>C device.</p>
<p class="PlainText">The following is an example of the <span class="keyword_in_text">I2COUT</span> command:</p><pre class="BScode" xml:space="preserve"> I2COUT 0, $A0, 5, [100]</pre>
<p class="PlainText">This code will transmit a "write" command to an I<sup>2</sup>C device (connected
to I/O pins 0 and 1), followed by an address of 5 and finally will transmit the
number 100.</p>
<p class="PlainText">The example above will write a byte of data to location 5 of a 24LC16B EEPROM from
Microchip. The figure below shows the proper wiring for this example to work. The
<i>SlaveID</i> argument ($A0) is both the ID of the chip and the command to write to
the chip; the 0 means write. The <i>Address</i> argument (5) is the EEPROM location
to write to.</p>
<p class="PlainText"><b>Note</b>: The 4.7 kΩ resisters are required for the <span class="keyword_in_text">I2COUT</span>
command to function properly.</p>
<center>
<img src="../../graphics/24lc16_sch.gif" border="0">
</img>
</center>
<p class="PlainText">The <span class="keyword_in_text">I2COUT</span> command's <i>OutputData</i> argument is similar to the
<span class="keyword_in_text">DEBUG</span> and <span class="keyword_in_text">SEROUT</span> command's <i>OutputData</i> argument. This means
data can be sent as literal text, ASCII character values, repetitive values,
decimal, hexadecimal and binary translations and string data as in the examples
below. (Assume the 24LC16B EEPROM is being used).</p><pre class="BScode" xml:space="preserve">
value VAR Byte
Setup:
value = 65
Main:
I2COUT 0, $A0, 0, [value] ' send ASCII character "A"
I2COUT 0, $A0, 0, [REP value\5] ' send "A" five times, i.e., "AAAAA"
I2COUT 0, $A0, 0, [DEC value] ' send "6" and "5"
I2COUT 0, $A0, 0, [HEX value] ' send "4" and "1"
I2COUT 0, $A0, 0, [BIN value] ' send "1000001"
END
</pre>
<p class="PlainText">The tables below list all the available conversion formatters and special
formatters available to the <span class="keyword_in_text">I2COUT</span> command. See the <a href="DEBUG.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DEBUG</a> and <a href="SEROUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SEROUT</a> commands for
additional information and examples of their use.</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="20%">Conversion Formatter</td>
<td width="70%">Type of Number</td>
<td width="10%">Notes</td>
</tr>
<tr align="center">
<td>DEC{1..5}</td>
<td align="left">Decimal, optionally fixed to 1 - 5 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>SDEC{1..5}</td>
<td align="left">Signed decimal, optionally fixed to 1 - 5 digits</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>HEX{1..4}</td>
<td align="left">Hexadecimal, optionally fixed to 1 - 4 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>SHEX{1..4}</td>
<td align="left">Signed hexadecimal, optionally fixed to 1 - 4 digits </td>
<td>1,2</td>
</tr>
<tr align="center">
<td>IHEX{1..4}</td>
<td align="left">Indicated hexadecimal, optionally fixed to 1 - 4 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>ISHEX{1..4}</td>
<td align="left">Signed, indicated hexadecimal, optionally fixed to 1 - 4
digits ($ prefix)</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>BIN{1..16}</td>
<td align="left">Binary, optionally fixed to 1 - 16 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>SBIN{1..16}</td>
<td align="left">Signed binary, optionally fixed to 1 - 16 digits</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>IBIN{1..16}</td>
<td align="left">Indicated binary, optionally fixed to 1 - 16 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>ISBIN{1..16}</td>
<td align="left">Signed, indicated binary, optionally fixed to 1 - 16 digits</td>
<td>1,2</td>
</tr>
</table>
<ol>
<li value="1">Fixed-digit formatters like DEC4 will pad the number with leading 0s if
necessary; ex: DEC4 65 sends 0065. If a number is larger than the specified
number of digits, the leading digits will be dropped; ex: DEC4 56422 sends
6422.</li>
<li value="2">Signed modifiers work under two's complement rules.</li>
</ol>
<p>&#160;</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="20%">Special Formatter</td>
<td width="80%">Action</td>
</tr>
<tr>
<td align="center">?</td>
<td>Displays "symbol = x' + carriage return; where x is a number. Default
format is decimal, but may be combined with conversion formatters (ex: BIN
? x to display "x = binary_number").</td>
</tr>
<tr>
<td align="center">ASC ?</td>
<td>Displays "symbol = 'x'" + carriage return; where x is an ASCII character.</td>
</tr>
<tr>
<td align="center">STR ByteArray {\L}</td>
<td>Send character string from an array. The optional \L argument can be used
to limit the output to L characters, otherwise, characters will be sent up to
the first byte equal to 0 or the end of RAM space is reached.</td>
</tr>
<tr>
<td align="center">REP Byte\L</td>
<td>Send a string consisting of Byte repeated L times (ex: REP "X"\10
sends "XXXXXXXXXX").</td>
</tr>
</table>
<p>&#160;</p>
<p class="PlainText">The I<sup>2</sup>C protocol has a well-defined standard for the information
passed at the start of each transmission. First of all, any information sent must
be transmitted in units of one byte (8-bits). The first byte, we call the
<i>SlaveID</i>, is an 8-bit pattern whose upper 7-bits contain the unique ID of
the device you wish to communicate with. The lowest bit indicates whether this
is a write operation (0) or a read operation (1). Here is the <i>SlaveID</i> <![CDATA[ ]]>format:</p>
<center>
<table cellpadding="4" cellspacing="0" border="1">
<tr align="center" bgcolor="#CFCFCF">
<td width="35">7</td>
<td width="35">6</td>
<td width="35">5</td>
<td width="35">4</td>
<td width="35">3</td>
<td width="35">2</td>
<td width="35">1</td>
<td width="35">0</td>
</tr>
<tr align="center">
<td>A<sub>6</sub></td>
<td>A<sub>5</sub></td>
<td>A<sub>4</sub></td>
<td>A<sub>3</sub></td>
<td>A<sub>2</sub></td>
<td>A<sub>1</sub></td>
<td>A<sub>0</sub></td>
<td>R/W</td>
</tr>
</table>
</center>
<p>&#160;</p>
<p class="PlainText">The second byte, immediately following the <i>SlaveID</i>, is the <i>Address</i>.
It indicates the 8-bit address (within the device) where the <i>OutputData</i> is
to be written (the first location if more than one byte is written). Note that
the <i>Address</i> argument is optional and may be left unspecified for devices
that don't require an address parameter.</p>
<p class="PlainText">Some devices require more than eights bits of address. For this case, the optional
<i>LowAddress</i> argument can be used for the low-byte of the required address.
When using the <i>LowAddress</i> argument, the <i>Address</i> argument is
effectively the high-byte of the address value. For example, if the entire
address value is 2050, use 8 for the <i>Address</i> argument and 2 for the
<i>LowAddress</i> argument (8 * 256 + 2 = 2050).</p>
<p class="PlainText">Following the last address byte is the first byte of data. This data byte may
be transmitted or received by the BASIC Stamp. In the case of the <span class="keyword_in_text">I2COUT</span>
command, this data byte is transmitted by the BASIC Stamp and received by the
device. Additionally, multiple data bytes can follow the address, depending on
the I<sup>2</sup>C device. Note that every device has different limitations
regarding how may contiguous bytes they can receive or transmit in one session.
Be aware of these device limitations and program accordingly.</p>
<p class="PlainText">Every I<sup>2</sup>C transmission session begins with a Start Condition and
ends with a Stop Condition. Additionally, immediately after every byte is
transmitted, an extra clock cycle is used to send or receive an acknowledgment
signal (ACK). All of these operations are automatically taken care of by the
<span class="keyword_in_text">I2CIN</span> command so that you need not be concerned with them. The general
I<sup>2</sup>C transmission format is shown below.</p>
<center>
<img src="../../graphics/i2c_packet.gif" border="0">
</img>
</center>
<p>&#160;</p>
<p class="PlainText">Since the <span class="keyword_in_text">I2COUT</span> command is intended for output only, it actually
overrides the "R/W" bit (bit 0) in the <i>SlaveID</i> argument. This is done to
avoid device conflicts should the value be mistyped. Put simply, this means
commands such as:
</p><pre class="BScode" xml:space="preserve"> I2COUT 0, $A0, 10, [0] </pre>
<p class="PlainText">...and:</p><pre class="BScode" xml:space="preserve"> I2COUT 0, $A1, 10, [0]</pre>
<p class="PlainText">...both transmit the same thing ($A0, then 10, then the data). Even though the
<span class="keyword_in_text">I2COUT</span> command really doesn't care what the value of the <i>SlaveID</i>'s
LSB is, it is suggested that you still set it appropriately for clarity.</p>
<p class="PlainText">Also note that the <span class="keyword_in_text">I2COUT</span> command does not support multiple I<sup>2</sup>C
masters and the BASIC Stamp cannot operate as an I<sup>2</sup>C slave device.</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>

View File

@ -0,0 +1,453 @@
<?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>IF…THEN</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">IF…THEN</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" /><span class="code_in_text"> {PBASIC&#160;1.0} {PBASIC&#160;2.0}</span>
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/IfThenEx.htm" target="" title="" alt="" class="MCXref_0">IF...THEN Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax:
<b>IF</b> <![CDATA[ ]]><i>Condition</i> <![CDATA[ ]]><b>THEN</b> <![CDATA[ ]]><i>Address</i></p>
<h2>Function</h2>
<p class="PlainText">Evaluate <i>Condition</i> and, if it is true, go to the point in the program marked
by <i>Address</i>.
</p>
<ul>
<li value="1"><b><i>Condition</i></b> is a statement, such as "x = 7" that can be evaluated
as True or False. The <i>Condition</i> can be a very simple or very complex
relationship, as described below.</li>
<li value="2"><b><i>Address</i></b> is a label that specifies where to go in the event that
<i>Condition</i> is true.</li>
</ul>
<p class="PlainText">Note: See <a href="IF_THEN_ELSE.htm" target="" title="" alt="" class="MCXref_0">IF…THEN…ELSE</a> for all BS2 models and PBASIC 2.5.</p>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="20%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="30%" align="center" bgcolor="#CFCFCF">BS1</td>
<td width="30%" align="center" bgcolor="#CFCFCF">BS2 Family</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Comparison operators</td>
<td align="center">=, &lt;&gt;, &gt;, &lt;, &gt;=, &lt;=</td>
<td align="center">=, &lt;&gt;, &gt;, &lt;, &gt;=, &lt;=</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Conditional Logic Operators</td>
<td align="center">AND, OR</td>
<td align="center">NOT, AND, OR, XOR</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Format of <i>Condition</i></td>
<td align="center"><i>Variable Comparison Value</i>;<br /> where <i>Value</i> is a variable or constant</td>
<td align="center"><i>Value1 Comparison Value2</i>;<br /> where <i>Value1</i> and <i>Value2</i> can be any of variable, constant or expression</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Parentheses</td>
<td align="center">Not Allowed</td>
<td align="center">Allowed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center">None</p>
</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="IF_THEN_ELSE.htm" target="" title="" alt="" class="MCXref_0">IF…THEN…ELSE</a>, <a href="SELECT_CASE.htm" target="" title="" alt="" class="MCXref_0">SELECT...CASE</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">IF...THEN</span> is PBASIC's primary decision maker. It tests a condition and, if
that condition is true, goes to a point in the program specified by an address label.
The condition that <span class="keyword_in_text">IF...THEN</span> tests is written as a mixture of comparison
and logic operators. The available comparison operators are: </p>
<center>
<table cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="130" align="center" bgcolor="#CFCFCF">Comparison Operator Symbol</td>
<td width="170" align="center" bgcolor="#CFCFCF">Definition</td>
</tr>
<tr>
<td align="center">=</td>
<td align="center">Equal</td>
</tr>
<tr>
<td align="center">&lt;&gt;</td>
<td align="center">Not Equal</td>
</tr>
<tr>
<td align="center">&gt;</td>
<td align="center">Greater Than</td>
</tr>
<tr>
<td align="center">&lt;</td>
<td align="center">Less Than</td>
</tr>
<tr>
<td align="center">&gt;=</td>
<td align="center">Greater Than or Equal To</td>
</tr>
<tr>
<td align="center">&lt;=</td>
<td align="center">Less Than or Equal To</td>
</tr>
</table>
</center>
<p>&#160;</p>
<p class="PlainText">Comparisons are always written in the form: <i>Value1 Comparison Value2</i>. The
values to be compared can be any combination of variables (any size), constants,
or expressions. </p>
<p class="PlainText">
<img src="../../graphics/bs1note.gif" style="vertical-align: super;" /> Note: On the BS1, expressions are not allowed as arguments, and
<i>Value1</i> (to the left of comparison) must be a variable.</p>
<p class="PlainText">The following example is an <span class="keyword_in_text">IF...THEN</span> command with a simple condition:</p><pre class="BScode" xml:space="preserve">
IF 10 &lt; 200 THEN Main
</pre>
<p class="PlainText">This code will compare the number 10 to the number 200. If 10 is less than 200,
the condition is true. In this case, 10 is less than 200 (and always will be),
so the program will jump (or <span class="keyword_in_text">GOTO</span>) the label called Main. Of course, this
is a silly example (10 is always less than 200 so this line will always cause a
jump to Main). Most of the time, you'll use at least one variable in your condition:</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL value = W1
Main:
PULSIN 0, 1, value
DEBUG #value, CR
IF value &lt; 4000 THEN Main
DEBUG "Value was greater than 4000!"
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
value VAR Word
Main:
PULSIN 0, 1, value
DEBUG DEC value, CR
IF (value &lt; 4000) THEN Main
DEBUG "Value was greater than 4000!"
END
</pre>
<p class="PlainText">Here, the BASIC Stamp will look for and measure a pulse on I/O pin 0, then compare
the result, value, against 4000. If value is less than (&lt;) 4000, it will jump
back to Main. Each time through the loop, it displays the measured value and once
it is greater than or equal to 4000, it displays, "Value was greater than 4000!"</p>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p>
<p class="PlainText">On the BS2, BS2e, BS2sx, BS2p, and BS2pe, the values can be expressions as well.
This leads to very flexible and sophisticated comparisons. The <span class="keyword_in_text">IF...THEN</span>
statement below is functionally the same as the one in the program above:</p><pre class="BScode" xml:space="preserve">
IF (value &lt; (45 * 100 - (25 * 20))) THEN Main
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p>
<p class="PlainText">Here the BASIC Stamp evaluates the expression: 45 * 100 = 4500, 25 * 20 = 500,
and 4500 - 500 = 4000. Then the BASIC Stamp performs the comparison: is value &lt;
4000? Another example that is functionally the same:</p><pre class="BScode" xml:space="preserve">
IF ((value / 100) &lt; 40) THEN Main
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p>
<p class="PlainText">It's important to realize that all comparisons are performed using unsigned,
16-bit math. This can lead to strange results if you mix signed and unsigned numbers
in <span class="keyword_in_text">IF...THEN</span> conditions. Watch what happens here when we include a signed
number (-99):</p><pre class="BScode" xml:space="preserve">
IF (-99 &lt; 100) THEN Is_Less
DEBUG "Greater than or equal to 100"
END
Is_Less:
DEBUG "Less than 100"
END
</pre>
<p class="PlainText">Although -99 is obviously less than 100, the program will say it is greater.
The problem is that -99 is internally represented as the two's complement value
65437, which (using unsigned math) is greater than 100. This phenomena will occur
whether or not the negative value is a constant, variable or expression. </p>
<p class="PlainText"><span class="keyword_in_text">IF...THEN</span> supports the conditional logic operators NOT, AND, OR, and XOR.
See the table below for a list of the operators and their effects. NOTE: The NOT
and XOR operators are not available on the BS1.</p>
<p class="PlainText">The NOT operator inverts the outcome of a condition, changing False to True,
and True to False. The following <span class="keyword_in_text">IF...THEN</span>s are equivalent: </p><pre class="BScode" xml:space="preserve">
IF (x &lt;&gt; 100) THEN Not_Equal ' Jump to Not_Equal if x is not 100
IF NOT (x = 100) THEN Not_Equal ' Jump to Not_Equal if x is not 100
</pre>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL value1 = B2
SYMBOL value2 = B3
Setup:
value1 = 5
value2 = 9
Main:
IF value1 = 5 AND value2 = 10 THEN Is_True ' change AND to OR and see
DEBUG "Statement was false." ' what happens
END
Is_True:
DEBUG "Statement was true."
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
value1 VAR Byte
value2 VAR Byte
Setup:
value1 = 5
value2 = 9
Main:
' Change AND to OR and see what happens
IF (value1 = 5) AND (value2 = 10) THEN Is_True
DEBUG "Statement was false."
END
Is_True:
DEBUG "Statement was true."
END
</pre>
<p class="PlainText">The condition "(value1 = 5) AND (value2 = 10)" is not true. Although value1 is
5, value2 is not 10. The AND operator works just as it does in English; both
conditions must be true for the statement to be true. The OR operator also works
in a familiar way; if one or the other or both conditions are true, then the
statement is true. The XOR operator (short for exclusive-OR) may not be familiar,
but it does have an English counterpart: If one condition or the other (but not
both) is true, then the statement is true. </p>
<p class="PlainText">The table below summarizes the effects of the conditional logic operators. As
with math, you can alter the order in which comparisons and logical operations
are performed by using parentheses. Operations are normally evaluated left-to-right.
Putting parentheses around an operation forces PBASIC 2.0 to evaluate it before
operations not in parentheses. </p>
<p class="PlainText">
<img src="../../graphics/bs1note.gif" style="vertical-align: super;" /> Note: On the BS1, parentheses are not allowed within
arguments.</p>
<center>
<table cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="100" align="center" bgcolor="#CFCFCF">Condition A</td>
<td width="100" align="center" bgcolor="#CFCFCF">NOT A</td>
</tr>
<tr>
<td align="center">False</td>
<td align="center">True</td>
</tr>
<tr>
<td align="center">True</td>
<td align="center">False</td>
</tr>
</table>
<br>
</br>
<table cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="100" align="center" bgcolor="#CFCFCF">Condition A</td>
<td width="100" align="center" bgcolor="#CFCFCF">Condition B</td>
<td width="100" align="center" bgcolor="#CFCFCF">A AND B</td>
</tr>
<tr>
<td align="center">False</td>
<td align="center">False</td>
<td align="center">False</td>
</tr>
<tr>
<td align="center">False</td>
<td align="center">True</td>
<td align="center">False</td>
</tr>
<tr>
<td align="center">True</td>
<td align="center">False</td>
<td align="center">False</td>
</tr>
<tr>
<td align="center">True</td>
<td align="center">True</td>
<td align="center">True</td>
</tr>
</table>
<br>
</br>
<table cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="100" align="center" bgcolor="#CFCFCF">Condition A</td>
<td width="100" align="center" bgcolor="#CFCFCF">Condition B</td>
<td width="100" align="center" bgcolor="#CFCFCF">A OR B</td>
</tr>
<tr>
<td align="center">False</td>
<td align="center">False</td>
<td align="center">False</td>
</tr>
<tr>
<td align="center">False</td>
<td align="center">True</td>
<td align="center">True</td>
</tr>
<tr>
<td align="center">True</td>
<td align="center">False</td>
<td align="center">True</td>
</tr>
<tr>
<td align="center">True</td>
<td align="center">True</td>
<td align="center">True</td>
</tr>
</table>
<br>
</br>
<table cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="100" align="center" bgcolor="#CFCFCF">Condition A</td>
<td width="100" align="center" bgcolor="#CFCFCF">Condition B</td>
<td width="100" align="center" bgcolor="#CFCFCF">A XOR B</td>
</tr>
<tr>
<td align="center">False</td>
<td align="center">False</td>
<td align="center">False</td>
</tr>
<tr>
<td align="center">False</td>
<td align="center">True</td>
<td align="center">True</td>
</tr>
<tr>
<td align="center">True</td>
<td align="center">False</td>
<td align="center">True</td>
</tr>
<tr>
<td align="center">True</td>
<td align="center">True</td>
<td align="center">False</td>
</tr>
</table>
</center>
<p>&#160;</p>
<p class="PlainText">Unlike the <span class="keyword_in_text">IF...THEN</span> commands in other BASIC language variants, PBASIC 1.0/2.0's
<span class="keyword_in_text">IF...THEN</span> can only go to a label as the result of a decision. It cannot
conditionally perform some instruction, as in "IF x &lt; 20 THEN y = y + 1" (This
is possible using the $PBASIC 2.5 directive). To achieve this in PBASIC 1.0 and 2.0,
you have to invert the logic using NOT and skip over the conditional instruction
unless the condition is met: </p><pre class="BScode" xml:space="preserve">
IF NOT (x &lt; 20) THEN No_Inc ' Don't increment y unless x &lt; 20.
y = y + 1 ' Increment y if x &lt; 20.
No_Inc: ' Program continues.
</pre>
<p class="PlainText">You can also code a conditional <span class="keyword_in_text">GOSUB</span>, as in "<span class="code_in_text">IF (x = 100) THEN GOSUB Centennial</span>."
In PBASIC 2.0:</p><pre class="BScode" xml:space="preserve">
IF NOT (x = 100) THEN No_Cent
GOSUB Centennial ' IF x = 100 THEN GOSUB Centennial.
No_Cent: ' Program continues.
</pre>
<p class="PlainText">Internally, the BASIC Stamp defines "False" as 0 and "True" as any value other
than 0. Consider the following instructions: </p><pre class="BScode" xml:space="preserve">
flag VAR Bit
Setup:
flag = 1
Test:
IF flag THEN Is_True
Is_False:
DEBUG "False", CR
END
Is_True:
DEBUG "True"
END
</pre>
<p class="PlainText">Since flag is 1, <span class="keyword_in_text">IF...THEN</span> would evaluate it as true and print the message
"True" on the screen. Suppose you changed the <span class="keyword_in_text">IF...THEN</span> command to read
"<span class="code_in_text">IF NOT (flag) THEN IsTrue</span>." That would also evaluate as True. Whoa! Isn't NOT 1
the same thing as 0? No, at least not in the 16-bit world of the BASIC Stamp.</p>
<p class="PlainText">Internally, the BASIC Stamp sees a bit variable containing 1 as the 16-bit number
%0000000000000001. So it sees the NOT of that as %1111111111111110. Since any
non-zero number is regarded as True, NOT 1 is True. Strange but true. </p>
<p class="PlainText">The easiest way to avoid the kinds of problems this might cause is to always
use a conditional operator with <span class="keyword_in_text">IF...THEN</span>. Change the example above to read
<span class="code_in_text">IF (flag = 1) THEN Is_True</span>. The result of the comparison will follow <span class="keyword_in_text">IF...THEN</span>rules. Also, the logical operators will work as they should; <span class="code_in_text">IF NOT (flag = 1)
THEN Is_True</span> will correctly evaluate to False when flag contains 1.</p>
<p class="PlainText">This also means that you should only use the "named" conditional logic operators
NOT, AND, OR, and XOR with <span class="keyword_in_text">IF...THEN</span>. The conditional logic operators format
their results correctly for <span class="keyword_in_text">IF...THEN</span> instructions. The other logical
operators, represented by symbols ~ &amp; | and ^ do not; they are binary logic operators.</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>

View File

@ -0,0 +1,181 @@
<?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>IF…THEN…ELSE</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">IF…THEN…ELSE</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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" /><span class="code_in_text"> {PBASIC&#160;2.5}</span>
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/IfThenElseEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">IF...THEN...ELSE Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <br /><br />&#160; &#160;<b>IF</b> <![CDATA[ ]]><i>Condition</i> <![CDATA[ ]]><span class="keyword_in_text">THEN</span><br />&#160; &#160; &#160;<i>Statement(s)</i><br />&#160;{ <span class="keyword_in_text">ELSEIF</span> <![CDATA[ ]]><i>Condition(s)</i> <![CDATA[ ]]><span class="keyword_in_text">THEN</span><br />&#160; &#160; &#160;<i>Statement(s)</i> }<br />&#160;{ <span class="keyword_in_text">ELSE</span><br />&#160; &#160; &#160;<i>Statement(s)</i> }<br />&#160; &#160;<span class="keyword_in_text">ENDIF</span><br /><br />&#160; &#160;<b>IF</b> <![CDATA[ ]]><i>Condition</i> <![CDATA[ ]]><span class="keyword_in_text">THEN</span> <![CDATA[ ]]><i>Statement(s)</i>{ <span class="keyword_in_text">ELSEIF</span> <![CDATA[ ]]><i>Statement(s)</i> } { <span class="keyword_in_text">ELSE</span> <![CDATA[ ]]><i>Statement(s)</i> }</p>
<h2>Function</h2>
<p class="PlainText">Evaluate <i>Condition</i> and, if it is true, execute the statement(s) following
<span class="keyword_in_text">THEN</span>, otherwise jump to and evaluate the <span class="keyword_in_text">ELSEIF</span> condition. If no
<span class="keyword_in_text">ELSEIF</span> statement/block is provided, jump to and execute the statements that
follow <span class="keyword_in_text">ELSE</span>. If no <span class="keyword_in_text">ELSE</span> block is provided, the program will continue
at the line that follows <span class="keyword_in_text">ENDIF</span> (or the next line when single-line syntax
is used).
</p>
<ul>
<li value="1"><b><i>Condition</i></b> is a statement, such as "x = 7" that can be evaluated
as True or False. The <i>Condition</i> can be a very simple or very complex
relationship, as described below.</li>
<li value="2"><b><i>Statement</i></b> is any valid PBASIC statement. Multiple statements
may be placed on the same line (though not recommended) by separating each
statement with a colon ( : ).</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="20%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="80%" align="center" bgcolor="#CFCFCF">BS2 Family</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Comparison operators</td>
<td align="center">=, &lt;&gt;, &gt;, &lt;, &gt;=, &lt;=</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Conditional Logic Operators</td>
<td align="center">NOT, AND, OR, XOR</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Format of condition</td>
<td align="center"><i>Value1 Comparison Value2</i>;<br />where <i>Value1</i> and <i>Value2</i> can
be any of variable, constant or expression</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Parentheses</td>
<td align="center">Allowed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Nesting</td>
<td align="center">Up to 16 levels</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="IF_THEN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">IF…THEN</a>, <a href="SELECT_CASE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SELECT...CASE</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">IF...THEN...ELSE</span> is a primary PBASIC decision maker that allows one block of
code or [optionally] another to run based on the value (True or False) of a condition.
The condition that <span class="keyword_in_text">IF...THEN...ELSE</span> tests is written as a mixture of
comparison and logic operators. The available comparison operators are:</p>
<center>
<table cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="130" align="center" bgcolor="#CFCFCF">Comparison Operator Symbol</td>
<td width="170" align="center" bgcolor="#CFCFCF">Definition</td>
</tr>
<tr>
<td align="center">=</td>
<td align="center">Equal</td>
</tr>
<tr>
<td align="center">&lt;&gt;</td>
<td align="center">Not Equal</td>
</tr>
<tr>
<td align="center">&gt;</td>
<td align="center">Greater Than</td>
</tr>
<tr>
<td align="center">&lt;</td>
<td align="center">Less Than</td>
</tr>
<tr>
<td align="center">&gt;=</td>
<td align="center">Greater Than or Equal To</td>
</tr>
<tr>
<td align="center">&lt;=</td>
<td align="center">Less Than or Equal To</td>
</tr>
</table>
</center>
<p>&#160;</p>
<p class="PlainText">Comparisons are always written in the form: <i>Value1 Comparison Value2</i>. The values
to be compared can be any combination of variables (any size), constants, or
expressions.</p><pre class="BScode" xml:space="preserve">
value VAR Word
Main:
DO
PULSIN 0, 1, value ' measure pulse input
DEBUG DEC value, CR
IF (value &gt; 4000) THEN ' evaluate duration
DEBUG "Value was greater than 4000"
ELSEIF (value = 4000) THEN
DEBUG "Value was equal to 4000"
ELSE
DEBUG "Value was less than 4000"
ENDIF
DEBUG CR, CR
PAUSE 1000
LOOP
</pre>
<p class="PlainText">Here, the BASIC Stamp will look for and measure a pulse on I/O pin 0, then
compare the result, value, against 4000. Based on this comparison, a message
regarding the pulse width value will be printed.</p>
<p class="PlainText">In the following example, single-line syntax is used. Note that <span class="keyword_in_text">ENDIF</span>
is not required when using single-line formatting of <span class="keyword_in_text">IF...THEN...ELSE</span>:
</p><pre class="BScode" xml:space="preserve">
DEBUG "Your grade is: "
IF (score &gt;= 90) THEN DEBUG "A", CR : ELSE DEBUG "B (or less)", CR
</pre>
<p class="PlainText">See <a href="IF_THEN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">IF…THEN</a> for additional details on the use of
comparison and conditional operators. </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>

View File

@ -0,0 +1,123 @@
<?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>INPUT</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">INPUT</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/InputOutputEx.htm" target="" title="" alt="" class="MCXref_0">INPUT / OUTPUT Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">INPUT </span> <![CDATA[ ]]><i>Pin</i></p>
<h2>Function</h2>
<p class="PlainText">Make the specified pin an input.
</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression* (0 - 15) that specifies
which I/O pin to set to input mode.</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>
<td align="center" width="150" bgcolor="#CFCFCF">&#160;</td>
<td align="center" width="40%" bgcolor="#CFCFCF">BS1</td>
<td align="center" width="40%" bgcolor="#CFCFCF">All BS2 Models</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Input Pin Variables</td>
<td align="center">PINS: PIN0 through PIN7</td>
<td align="center">INS; IN0 through IN15</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="2">
<p colspan="2" align="center"><a href="OUTPUT.htm" target="" title="" alt="" class="MCXref_0">OUTPUT</a>, <a href="REVERSE.htm" target="" title="" alt="" class="MCXref_0">REVERSE</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">There are several ways to make a pin an input. When the BASIC Stamp is reset, all
of the pins are inputs. Commands that rely on input pins, like <span class="keyword_in_text">PULSIN</span> and
<span class="keyword_in_text">SERIN</span>, automatically change the specified pin to input. Writing 0s to
particular bits of the variable DIRS makes the corresponding pins inputs. And
then theres the <span class="keyword_in_text">INPUT</span> command.</p>
<p class="PlainText">When a pin is an input, your program can check its state by reading from
the corresponding INS variable (PINS on the BS1). For example:</p>
<p>
<img src="../../graphics/bs1_inline.gif" width="9" height="16" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
Setup:
INPUT 4
Hold:
IF PIN4 = 0 THEN Hold ' Stay here until P4 is 1
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
Setup:
INPUT 4
Hold:
IF (IN4 = 0) THEN Hold ' Stay here until P4 is 1
</pre>
<p class="PlainText">What happens if your program writes to the OUTS bit (PINS bit on the
BS1) of a pin that is set up as an input? The value is stored in OUTS (PINS
on the BS1), but has no effect on the outside world. If the pin is changed to
output, the last value written to the corresponding OUTS bit (or PINS bit
on the BS1) will appear on the pin. The Example program shows how this works.</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>

View File

@ -0,0 +1,115 @@
<?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>IOTERM</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">IOTERM</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" /> (BS2p40)</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/AuMainIotermEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">AUXIO / MAINIO / IOTERM Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">IOTERM</span> <![CDATA[ ]]><i>Port</i></p>
<h2>Function</h2>
<p class="PlainText">Switch program control to main I/O pins or auxiliary I/O pins (on the BS2p40 only)
depending on the value of <i>Port</i>.
</p>
<ul>
<li value="1"><b><i>Port</i></b> is a variable/constant/expression (0 - 1) that specifies
which I/O port to use.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="15%" align="center">&#160;</td>
<td width="85%" align="center">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Values for <i>Port</i></td>
<td>0 = switch to main I/O group, 1 = switch to auxiliary I/O group.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">I/O Pin IDs</td>
<td>0 - 15 (after IOTERM command, all references affect physical pins
5 - 20 or 21 - 36 depending on state of <i>Port).</i></td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td>
<p>Command is accepted by the 24-pin BS2p, BS2pe, and BS2px, but only the 40-pin BS2p40 gives access to the auxiliary I/O pins.</p>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="AUXIO.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">AUXIO</a>, <a href="MAINIO.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">MAINIO</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The BS2p, BS2pe, and BS2px is available as a 24-pin module that is pin-compatible
with the BS2, BS2e, and BS2sx. Also availabe is a 40-pin module called the BS2p40
with an additional 16 I/O pins (for a total of 32). The BS2p40's I/O pins are
organized into two groups, called main and auxiliary. The I/O pins in each group
can be accessed in the same manner (by referencing I/O pins 0 - 15) but access is
only possible within one group at a time. The <span class="keyword_in_text">IOTERM</span> command causes the
BASIC Stamp to affect either the main or auxiliary I/O pins in all further code
until the <span class="keyword_in_text">MAINIO</span>, <span class="keyword_in_text">AUXIO</span> or another <span class="keyword_in_text">IOTERM</span> command is reached,
or the BASIC Stamp is reset or power-cycled. The value of <i>Port</i> determines
which group of I/O pins will be referenced. Using 0 for <i>Port</i> will switch
to the main I/O group and using 1 for Port will switch to the auxiliary group.</p>
<p class="PlainText">The following example illustrates this:</p><pre class="BScode" xml:space="preserve">
HIGH 0
IOTERM 1
LOW 0
</pre>
<p class="PlainText">The first line of the above example will set I/O pin 0 of the main I/O pins
(physical pin 5) high. Afterward, the <span class="keyword_in_text">IOTERM</span> command tells the BASIC
Stamp that all commands following it should affect the auxiliary I/O pins
(Port = 1). The following <span class="keyword_in_text">LOW</span> command will set I/O pin 0 of the
auxiliary I/O pins (physical pin 21) low.</p>
<p class="PlainText">Note that the main I/O and auxiliary I/O pins are independent of each
other; the states of the main I/O pins remain unchanged while the
program affects the auxiliary I/O pins, and vice versa.</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>

View File

@ -0,0 +1,570 @@
<?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>LCDCMD</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">LCDCMD</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/LcdcmdEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">LCDCMD</span> <![CDATA[ ]]><i>Pin</i>,<i> Command</i></p>
<h2>Function</h2>
<p class="PlainText">Send a command to an LCD display.
</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression (0 - 1 or 8 - 9) that
specifies which I/O pins to use. The LCD requires, at most, seven I/O pins
to operate. The <i>Pin</i> argument serves a double purpose; specifying the
first pin and, indirectly the group of other required pins. See explanation
below. All I/O pins will be set to output mode.</li>
<li value="2"><b><i>Command</i></b> is a variable/constant/expression (0 - 255) indicating
the LCD command to send.</li>
</ul>
<h2>Quick Facts</h2>
<table cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="275" align="center">&#160;</td>
<td width="1200" align="center">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Values for <i>Pin</i></td>
<td align="center">0, 1, 8, or 9</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">I/O pin arrangement when <i>Pin</i>
is 0 or 1</td>
<td>0 or 1 (depending on <i>Pin</i>) : LCD Enable (E) pin<br></br> 2 : LCD Read/Write (R/W) pin<br></br> 3 : LCD Register Select (RS) pin<br></br> 4 - 7 : LCD Data Bus (DB4 - DB7, respectively) pins</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">I/O pin arrangement when <i>Pin</i> is
8 or 9</td>
<td>8 or 9 (depending on <i>Pin</i>) : LCD Enable (E) pin<br></br> 10 : LCD Read/Write (R/W) pin<br></br> 11 : LCD Register Select (RS) pin<br></br> 12 - 15 : LCD Data Bus (DB4 - DB7, respectively) pins</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td align="center" colspan="1">LCDCMD is designed to use the LCD's 4-bit mode only.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="LCDIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDIN</a>, <a href="LCDOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDOUT</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The three LCD commands (<span class="keyword_in_text">LCDCMD</span>, <span class="keyword_in_text">LCDIN</span> and <span class="keyword_in_text">LCDOUT</span>) allow the
BS2p, BS2pe, or BS2px to interface directly to standard LCD displays that feature
a Hitachi 44780 controller (part #HD44780A). This includes many 1 x 16, 2 x 16,
and 4 x 20 character LCD displays. </p>
<p class="PlainText">The Hitachi 44780 LCD controller supports a number of special instructions for
initializing the display, moving the cursor, changing the default layout, etc.
The <span class="keyword_in_text">LCDCMD</span> command is used to send one of these instructions to the LCD.
It is most commonly used to initialize the display upon a power-up or reset
condition. Note that <span class="keyword_in_text">LCDCMD</span>, <span class="keyword_in_text">LCDIN</span> and <span class="keyword_in_text">LCDOUT</span> use a 4-bit
interface to the LCD which requires a specific initialization sequence before
<span class="keyword_in_text">LCDIN</span> and <span class="keyword_in_text">LCDOUT</span> can be used. Specifics on the initialization
sequence will follow.</p>
<p class="PlainText">The following is an example of the <span class="keyword_in_text">LCDCMD</span> command:</p><pre class="BScode" xml:space="preserve">
LCDCMD 1, 24
</pre>
<p class="PlainText">The preceding code will send the Scroll Left command (represented by the number
24) to the LCD whose enable pin is connected to I/O pin 1. This will cause the LCD
display to scroll, or shift, the entire display one character to the left.</p>
<p class="PlainText">You may have noticed that the <i>Pin</i> argument in the example above was 1.
The <span class="keyword_in_text">LCDCMD</span> command actually uses more than just this I/O pin, however.
The <span class="keyword_in_text">LCDCMD</span> command requires seven I/O pins. This is because the standard
LCD displays have a parallel interface, rather than a serial one. The <i>Pin</i>
argument can be the numbers 0, 1, 8, or 9 and will result in the use of the I/O
pins shown above. The figure below shows the required wiring for the above command
to work.</p>
<center>
<img src="../../graphics/lcd_sch.gif" border="0">
</img>
</center>
<p class="PlainText">Note that we could have used 0 for the Pin argument and moved the LCD's Enable
pin (pin 6) to I/O pin 0. Similarly, using 9 for the Pin argument would have
required us to wire the LCD's pins to I/O pins 9 through 15, rather than I/O pins
1 through 7.</p>
<p class="PlainText">When the LCD is first powered-up, it will be in an unknown state and must be
properly configured before sending commands like the one shown above. This process
is known as initializing the LCD and is the first thing your program should do
upon starting up. The following code is a good example of LCD initialization.
(<i>Refer to Hitachi documentation for details</i>).</p><pre class="BScode" xml:space="preserve">
Init_LCD:
PAUSE 1000 ' allow LCD to power-up
LCDCMD 1, 48 ' Send wake-up sequence (3x)
PAUSE 5
LCDCMD 1, 48
PAUSE 1
LCDCMD 1, 48
PAUSE 1
LCDCMD 1, 32 ' Set data bus to 4-bit mode
LCDCMD 1, 40 ' Set 2-line mode with 5x8 font
LCDCMD 1, 8 ' Turn display off
LCDCMD 1, 12 ' Turn display on without cursor
LCDCMD 1, 6 ' Auto-increment cursor
LCDCMD 1, 1 ' Clear the display
</pre>
<p class="PlainText">This initialization code is the most commonly used sequence for a 2 x 16 and
4 x 20 LCD display (the 2-line mode instruction sets the 4 x 20 to 4-line mode).
The <span class="code_in_text">PAUSE 1000</span> command is optional, but only if your program takes more
than approximately 700 ms before it executes the Init_LCD code above. Without
it, upon powering your circuit, the BASIC Stamp may talk to the LCD too early,
the LCD will then miss some of the commands and the display will operate strangely,
or not at all.</p>
<p class="PlainText">Do not change the "wake-up" and "4-bit mode" sequence commands. However, the
commands below the line that says, "Set data bus to 4-bit mode" may be modified
to set other desired modes.</p>
<p class="PlainText">The table below shows the most commonly used LCD commands. Here's an example:</p><pre class="BScode" xml:space="preserve">
LCDCMD 1, 128 + 64
</pre>
<p class="PlainText">The preceding command will move the cursor to the first character position
on the second line (on a 2 x 16 display). 128 is the Move To Display Address
command and 64 is the location number. See the "Character Positioning" section
below, for more information.</p>
<h2>Common LCD Commands</h2>
<table cellpadding="4" cellspacing="0" border="1" width="100%">
<tr valign="top" bgcolor="#CFCFCF">
<td width="200" align="center">&#160;</td>
<td width="125" align="center">Command<br></br>(Decimal)</td>
<td align="center">Description</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Do Nothing</td>
<td align="center">0</td>
<td>Don't perform any special function.</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Clear Display</td>
<td align="center">1</td>
<td>Move cursor and display to home position.</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Home Display</td>
<td align="center">2</td>
<td>Move cursor and display to home position.</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Inc Cursor</td>
<td align="center">6</td>
<td>Set cursor direction to right, without a display shift.</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Display Off</td>
<td align="center">8</td>
<td>Turn off display (display data is retained).</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Display On</td>
<td align="center">12</td>
<td>Turn on display without cursor (display is restored).</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Blinking Cursor</td>
<td align="center">13</td>
<td>Turn on display with blinking cursor.</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Underline Cursor</td>
<td align="center">14</td>
<td>Turn on display with underline cursor.</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Cursor Left</td>
<td align="center">16</td>
<td>Move cursor left one character.</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Cursor Right</td>
<td align="center">20</td>
<td>Move cursor right one character.</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Scroll Left</td>
<td align="center">24</td>
<td>Scroll display left one character.</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Scroll Right</td>
<td align="center">28</td>
<td>Scroll display right one character.</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Move To CGRAM Address</td>
<td align="center">64 + address</td>
<td>Move pointer to Character Generator RAM location</td>
</tr>
<tr>
<td bgcolor="#CFCFCF">Move To DDRAM Address</td>
<td align="center">128 + address</td>
<td>Move cursor to Display Data RAM location</td>
</tr>
</table>
<p>&#160;</p>
<p class="PlainText">While most users will only need the commands shown above, the table below
details all of the instructions supported by the LCD (for advanced users). Many
instructions are multipurpose, depending on the state of special bits. Clever
manipulation of the instruction bits will allow for powerful control of the LCD.</p>
<table cellpadding="4" cellspacing="0" border="1" width="100%">
<tr valign="top" align="center" bgcolor="#CFCFCF">
<td width="200" rowspan="2">&#160;</td>
<td width="200" colspan="8" align="center">Command Code (bits)</td>
<td rowspan="2">Description</td>
</tr>
<tr valign="top" bgcolor="#CFCFCF">
<td width="25" align="center">7</td>
<td width="25" align="center">6</td>
<td width="25" align="center">5</td>
<td width="25" align="center">4</td>
<td width="25" align="center">3</td>
<td width="25" align="center">2</td>
<td width="25" align="center">1</td>
<td width="25" align="center">0</td>
</tr>
<tr align="center" valign="top">
<td align="left" bgcolor="#CFCFCF">Clear Display</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td align="left">Clear entire display and move cursor home (address 0)</td>
</tr>
<tr align="center" valign="top">
<td align="left" bgcolor="#CFCFCF">Home Display</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td align="left">Move cursor home and return display to home position.</td>
</tr>
<tr align="center" valign="top">
<td align="left" bgcolor="#CFCFCF">Entry Mode</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>M</td>
<td>S</td>
<td align="left">Sets cursor direction (M: 0=left, 1=right) and display scrolling
(S: 0=no scroll, 1=scroll)</td>
</tr>
<tr align="center" valign="top">
<td align="left" bgcolor="#CFCFCF">Display/Cursor</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>D</td>
<td>U</td>
<td>B</td>
<td align="left">Sets display on/off (D), underline cursor (U) and blinking
block cursor (B). (0=off, 1=on)</td>
</tr>
<tr align="center" valign="top">
<td align="left" bgcolor="#CFCFCF">Scroll Display / Shift Cursor</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>C</td>
<td>M</td>
<td>0</td>
<td>0</td>
<td align="left">Shifts display or cursor (C: 0=cursor, 1=display) left or
right (M: 0=left, 1=right).</td>
</tr>
<tr align="center" valign="top">
<td align="left" bgcolor="#CFCFCF">Function Set</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>B</td>
<td>L</td>
<td>F</td>
<td>0</td>
<td>0</td>
<td align="left">Sets bus size (B: 0=4-bits, 1=8-bits), number of lines
(L: 0=1?line, 1=2-lines) and font size (F: 0=5x8, 1=5x10)</td>
</tr>
<tr align="center" valign="top">
<td align="left" bgcolor="#CFCFCF">Move To CGRAM Address</td>
<td>O</td>
<td>1</td>
<td>A</td>
<td>A</td>
<td>A</td>
<td>A</td>
<td>A</td>
<td>A</td>
<td align="left">Move pointer to Character Generator RAM location specified
by address (A)</td>
</tr>
<tr align="center" valign="top">
<td align="left" bgcolor="#CFCFCF">Move To DDRAM Address</td>
<td>1</td>
<td>A</td>
<td>A</td>
<td>A</td>
<td>A</td>
<td>A</td>
<td>A</td>
<td>A</td>
<td align="left">Move cursor to Display Data RAM location specified by
address (A)</td>
</tr>
</table>
<p>&#160;</p>
<p class="PlainText">The last command shown above (Move To DDRAM Address) is used to move the cursor
to a specific position on the LCD. The LCD's DDRAM (Display Data RAM) is a fixed
size with unique position number for each character cell. The viewable portion
of the DDRAM depends on the LCD's logical view position (which can be altered with
the Scroll Display command). The default view position is called the Home position;
it means that the display's upper left character corresponds to DDRAM location 0.
The diagrams below indicates the position numbers for characters on the LCD screen.</p>
<p class="PlainText">Note that the diagram shows the most common DDRAM mapping, though some LCD's
may have organized the DDRAM differently. A little experimentation with your LCD
may reveal this.</p>
<h3>2 x 16 Display</h3>
<table border="0">
<tr nowrap="" align="center" bgcolor="#CFCFCF">
<td bgcolor="white">&#160;</td>
<td nowrap="" colspan="16">On-screen Positions*</td>
<td colspan="3">Off-screen</td>
</tr>
<tr nowrap="" align="center" bgcolor="#99CC66">
<td nowrap="" width="50" bgcolor="#CFCFCF">Line 1</td>
<td width="25">0</td>
<td width="25">1</td>
<td width="25">2</td>
<td width="25">3</td>
<td width="25">4</td>
<td width="25">5</td>
<td width="25">6</td>
<td width="25">7</td>
<td width="25">8</td>
<td width="25">9</td>
<td width="25">10</td>
<td width="25">11</td>
<td width="25">12</td>
<td width="25">13</td>
<td width="25">14</td>
<td width="25">15</td>
<td width="25" bgcolor="#CFCFCF">16</td>
<td width="25" bgcolor="#CFCFCF">...</td>
<td width="25" bgcolor="#CFCFCF">39</td>
</tr>
<tr nowrap="" align="center" bgcolor="#99CC66">
<td nowrap="" width="50" bgcolor="#CFCFCF">Line 2</td>
<td width="25">64</td>
<td width="25">65</td>
<td width="25">66</td>
<td width="25">67</td>
<td width="25">68</td>
<td width="25">69</td>
<td width="25">79</td>
<td width="25">71</td>
<td width="25">72</td>
<td width="25">73</td>
<td width="25">74</td>
<td width="25">75</td>
<td width="25">76</td>
<td width="25">77</td>
<td width="25">78</td>
<td width="25">79</td>
<td width="25" bgcolor="#CFCFCF">80</td>
<td width="25" bgcolor="#CFCFCF">...</td>
<td width="25" bgcolor="#CFCFCF">103</td>
</tr>
</table>
<p class="PlainText">* Assuming the display is in the home position</p>
<h3>4 x 20 Display</h3>
<table border="0">
<tr nowrap="" align="center" bgcolor="#99CC66">
<td nowrap="" width="50" bgcolor="#CFCFCF">Line 1</td>
<td width="25">0</td>
<td width="25">1</td>
<td width="25">2</td>
<td width="25">3</td>
<td width="25">4</td>
<td width="25">5</td>
<td width="25">6</td>
<td width="25">7</td>
<td width="25">8</td>
<td width="25">9</td>
<td width="25">10</td>
<td width="25">11</td>
<td width="25">12</td>
<td width="25">13</td>
<td width="25">14</td>
<td width="25">15</td>
<td width="25">16</td>
<td width="25">17</td>
<td width="25">18</td>
<td width="25">19</td>
</tr>
<tr nowrap="" align="center" bgcolor="#99CC66">
<td nowrap="" width="50" bgcolor="#CFCFCF">Line 2</td>
<td width="25">64</td>
<td width="25">65</td>
<td width="25">66</td>
<td width="25">67</td>
<td width="25">68</td>
<td width="25">69</td>
<td width="25">79</td>
<td width="25">71</td>
<td width="25">72</td>
<td width="25">73</td>
<td width="25">74</td>
<td width="25">75</td>
<td width="25">76</td>
<td width="25">77</td>
<td width="25">78</td>
<td width="25">79</td>
<td width="25">80</td>
<td width="25">81</td>
<td width="25">82</td>
<td width="25">83</td>
</tr>
<tr nowrap="" align="center" bgcolor="#99CC66">
<td nowrap="" width="50" bgcolor="#CFCFCF">Line 3</td>
<td width="25">20</td>
<td width="25">21</td>
<td width="25">22</td>
<td width="25">23</td>
<td width="25">24</td>
<td width="25">25</td>
<td width="25">26</td>
<td width="25">27</td>
<td width="25">28</td>
<td width="25">29</td>
<td width="25">30</td>
<td width="25">31</td>
<td width="25">32</td>
<td width="25">33</td>
<td width="25">34</td>
<td width="25">35</td>
<td width="25">36</td>
<td width="25">37</td>
<td width="25">38</td>
<td width="25">39</td>
</tr>
<tr nowrap="" align="center" bgcolor="#99CC66">
<td nowrap="" width="50" bgcolor="#CFCFCF">Line 4</td>
<td width="25">84</td>
<td width="25">85</td>
<td width="25">86</td>
<td width="25">87</td>
<td width="25">88</td>
<td width="25">89</td>
<td width="25">90</td>
<td width="25">91</td>
<td width="25">92</td>
<td width="25">93</td>
<td width="25">94</td>
<td width="25">95</td>
<td width="25">96</td>
<td width="25">97</td>
<td width="25">98</td>
<td width="25">99</td>
<td width="25">100</td>
<td width="25">101</td>
<td width="25">102</td>
<td width="25">103</td>
</tr>
</table>
<p>&#160;</p>
<p class="PlainText">On a standard 2 x 16 character display, the following command would move the
cursor to the third column of the second line:</p><pre class="BScode" xml:space="preserve">
LCDCMD 1, 128 + 66
</pre>
<p class="PlainText">The number 128 tells the LCD we wish to move the cursor and 66 is the location
number of the desired position. Similarly, sending just 128 (128 + 0) would move
the cursor to the first character of the first line (the upper left character if
the display is at the home position).</p>
<p class="PlainText">You may have noticed that the 2 x 16 display has many locations that are not
visible; they are to the right of the edge of the screen. These locations (16 -
39 and 80 to 103) become important for scrolling operations. For example, it is
possible to move the cursor to location 16, print some text there and then issue
a number of Scroll Left instructions (<span class="keyword_in_text">LCDCMD</span> 1, 24) to slowly scroll the
text onto the display from right to left. If you did so, the DDRAM positions that
were on the left of the screen would now be past the left edge of the screen. For
example:</p><pre class="BScode" xml:space="preserve">
LCDCMD 1, 24
LCDCMD 1, 24
</pre>
<p class="PlainText">...would cause the screen to scroll to the left by two characters. At this point,
the upper-left character in the display would actually be DDRAM location 2 and the
lower-left character would be DDRAM location 66. Locations 0, 1, 64 and 65 would
be off the left edge of the LCD and would no longer be visible. Some interesting
effects can be achieved by taking advantage of this feature.</p>
<p class="PlainText">The 4 x 20 LCD has a strange DDRAM map. The upper-right character is location
19 and the next location, 20, appears as the first character of the third line.
This strange mapping is due to constraints in the LCD controller and the
manufacturers design, and unfortunately makes the scrolling features virtually
useless on the 4 x 20 displays.</p>
<p class="PlainText">Even though the LCD requires many pins to talk to it, only the Enable pin needs
to remain dedicated to the LCD and all the other pins can be multiplexed (shared)
with certain other devices (if wired carefully). In addition, the I/O pin connected
to the LCD's R/W pin is only necessary if the <span class="keyword_in_text">LCDIN</span> command will be used
in the application. If the <span class="keyword_in_text">LCDIN</span> command will not be used, LCD pin 5 (R/W
pin) can be connected to ground and I/O pin 2 (shown above) may be left disconnected.
I/O pin 2 will still be set to output mode for each <span class="keyword_in_text">LCDCMD</span> and <span class="keyword_in_text">LCDOUT</span>command executed, however.</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>

View File

@ -0,0 +1,293 @@
<?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>LCDIN</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">LCDIN</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/LcdinEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDIN Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">LCDIN</span> <![CDATA[ ]]><i>Pin</i>,<i> Command</i>, [<i>InputData</i>]</p>
<h2>Function</h2>
<p class="PlainText">Receive data from an LCD display.
</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression (0 - 1 or 8 - 9) that
specifies which I/O pins to use. The LCD requires, at most, seven I/O pins to
operate. The <i>Pin</i> argument serves a double purpose; specifying the first
pin and, indirectly, the group of other required pins. See explanation below.
All I/O pins will be set to output mode initially and the upper I/O pins (4 -
7 or 12 - 15) will be set to input mode by the end of the <span class="keyword_in_text">LCDIN</span> command.</li>
<li value="2"><b><i>Command</i></b> is a variable/constant/expression (0 - 255) indicating
the LCD command to send.</li>
<li value="3"><b><i>InputData</i></b> is a list of variables and formatters that tells
<span class="keyword_in_text">LCDIN</span> what to do with incoming data. <span class="keyword_in_text">LCDIN</span> can store data in a
variable or array, interpret numeric text (decimal, binary, or hex) and store
the corresponding value in a variable, wait for a fixed or variable sequence
of bytes, or ignore a specified number of bytes. These actions can be combined
in any order in the <i>InputData</i> list.</li>
</ul>
<h2>Quick Facts</h2>
<table cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="275" align="center">&#160;</td>
<td width="1200" align="center">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Values for <i>Pin</i></td>
<td align="center">0, 1, 8, or 9</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">I/O pin arrangement when<br></br><i>Pin</i> is
0 or 1</td>
<td>0 or 1 (depending on <i>Pin</i>) : LCD Enable (E) pin<br></br> 2 : LCD Read/Write (R/W) pin<br></br> 3 : LCD Register Select (RS) pin<br></br> 4 - 7 : LCD Data Bus (DB4 - DB7, respectively) pins</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">I/O pin arrangement when<br></br><i>Pin</i> is
8 or 9</td>
<td>8 or 9 (depending on <i>Pin</i>) : LCD Enable (E) pin<br></br> 10 : LCD Read/Write (R/W) pin<br></br> 11 : LCD Register Select (RS) pin<br></br> 12 - 15 : LCD Data Bus (DB4 - DB7, respectively) pins</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td align="center" colspan="1"><span class="keyword_in_text">LCDIN </span>is designed to use the LCD's 4-bit mode only.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a>, <a href="LCDOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDOUT</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The three LCD commands (<span class="keyword_in_text">LCDCMD</span>, <span class="keyword_in_text">LCDIN</span> and <span class="keyword_in_text">LCDOUT</span>) allow the
BS2p, BS2pe, or BS2pe to interface directly to standard LCD displays that feature
a Hitachi 44780 controller (part #HD44780A). This includes many 1 x 16, 2 x 16,
and 4 x 20 character LCD displays. Note that <span class="keyword_in_text">LCDCMD</span>, <span class="keyword_in_text">LCDIN</span> and
<span class="keyword_in_text">LCDOUT</span> use a 4-bit interface to the LCD which requires a specific
initialization sequence before <span class="keyword_in_text">LCDIN</span> and <span class="keyword_in_text">LCDOUT</span> can be used
(see <a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a> for initialization details).</p>
<p class="PlainText">The <span class="keyword_in_text">LCDIN</span> command is used to send one instruction and then receive at
least one data byte from the LCD's Character Generator RAM (CGRAM) or Display Data
RAM (DDRAM). The following is an example of the <span class="keyword_in_text">LCDIN</span> command:</p><pre class="BScode" xml:space="preserve">
char VAR Byte
Main:
LCDIN 1, 128, [char]
STOP
</pre>
<p class="PlainText">The preceding example will read the character value at location 0 of the DDRAM.
See the "Character Positioning" section, below, for more information.</p>
<p class="PlainText">The <span class="keyword_in_text">LCDIN</span> command actually uses more than just the I/O pin specified by
the <i>Pin</i> argument. The <span class="keyword_in_text">LCDIN</span> command requires seven I/O pins. This
is because the standard LCD displays have a parallel interface, rather than a
serial one. The <i>Pin</i> argument can be the numbers 0, 1, 8, or 9 and will
result in the use of the I/O pins shown above. Please refer to the
<a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a> command description for information on properly
wiring the LCD display.</p>
<p class="PlainText">When the LCD is first powered-up, it will be in an unknown state and must be
properly configured before sending commands like the one shown above. This process
is known as initializing the LCD and is the first thing your program should do
upon starting up. Please refer to the <a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a> command
description for information on properly initializing the LCD display. </p>
<p class="PlainText">The <span class="keyword_in_text">LCDIN</span> command's <i>InputData</i> argument is similar to the <span class="keyword_in_text">SERIN</span> command's <i>InputData</i> argument. This means data can be received as ASCII
character values, decimal, hexadecimal and binary translations and string data as
in the examples below (assume the LCD display has "Value: 3A:101" starting at the
first character of the first line on the screen).</p><pre class="BScode" xml:space="preserve">
value VAR Byte(13)
Main:
LCDIN 1, 128, [value] ' receive ASCII code for "V"
LCDIN 1, 128, [DEC value] ' receive the number 3
LCDIN 1, 128, [HEX value] ' receive the number $3A
LCDIN 1, 128, [BIN value] ' receive the number %101
LCDIN 1, 128, [STR value\13] ' receive the string "Value: 3A:101"
</pre>
<p class="PlainText">The tables below list all the available conversion formatters and special
formatters available to the <span class="keyword_in_text">LCDIN</span> command. See the
<a href="SERIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SERIN</a> command for additional information and examples
of their use.</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="15%">Conversion Formatter</td>
<td width="45%">Type of Number</td>
<td width="30%">Numeric Characters Accepted</td>
<td width="10%">Notes</td>
</tr>
<tr align="center">
<td>DEC{1..5}</td>
<td>Decimal, optionally limited to 1 - 5 digits</td>
<td>0 through 9</td>
<td>1</td>
</tr>
<tr align="center">
<td>SDEC{1..5}</td>
<td>Signed decimal, optionally limited to 1 - 5 digits</td>
<td>-, 0 through 9</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>HEX{1..4}</td>
<td>Hexadecimal, optionally limited to 1 - 4 digits</td>
<td>0 through 9, A through F</td>
<td>1,3</td>
</tr>
<tr align="center">
<td>SHEX{1..4}</td>
<td>Signed hexadecimal, optionally limited to 1 - 4 digits </td>
<td>-, 0 through 9, A through F</td>
<td>1,2,3</td>
</tr>
<tr align="center">
<td>IHEX{1..4}</td>
<td>Indicated hexadecimal, optionally limited to 1 - 4 digits</td>
<td>$, 0 through 9, A through F</td>
<td>1,3,4</td>
</tr>
<tr align="center">
<td>ISHEX{1..4}</td>
<td>Signed, indicated hexadecimal, optionally limited to 1 - 4 digits</td>
<td>-, $, 0 through 9, A through F</td>
<td>1,2,3,4</td>
</tr>
<tr align="center">
<td>BIN{1..16}</td>
<td>Binary, optionally limited to 1 - 16 digits</td>
<td>0, 1</td>
<td>1</td>
</tr>
<tr align="center">
<td>SBIN{1..16}</td>
<td>Signed binary, optionally limited to 1 - 16 digits</td>
<td>-, 0, 1</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>IBIN{1..16}</td>
<td>Indicated binary, optionally limited to 1 - 16 digits</td>
<td>%, 0, 1</td>
<td>1,4</td>
</tr>
<tr align="center">
<td>ISBIN{1..16}</td>
<td>Signed, indicated binary, optionally limited to 1 - 16 digits</td>
<td>-, %, 0, 1</td>
<td>1,2,4</td>
</tr>
<tr align="center">
<td>NUM</td>
<td>Generic numeric input; hex or binary number must be indicated</td>
<td>$, %, 0 through 9, A through F</td>
<td>1,3,4</td>
</tr>
<tr align="center">
<td>SNUM</td>
<td>Similar to NUM with value treated as signed with range -32768 to +32767</td>
<td>-, $, %, 0 through 9, A through F</td>
<td>1,2,3,4</td>
</tr>
</table>
<ol>
<li value="1">All numeric conversions will continue to accept new data until receiving
either the specified number of digits (ex: three digits for DEC3) or a
non-numeric character.</li>
<li value="2">To be recognized as part of a number, the minus sign (-) must immediately
precede a numeric character. The minus sign character occurring in non-numeric
text is ignored and any character (including a space) between a minus and a
number causes the minus to be ignored.</li>
<li value="3">The hexadecimal formatters are not case-sensitive; "a" through "f" means
the same as "A" through "F".</li>
<li value="4">Indicated hexadecimal and binary formatters ignore all characters, even
valid numerics, until they receive the appropriate prefix ($ for hexadecimal,
% for binary). The indicated formatters can differentiate between text and
hexadecimal (ex: ABC would be interpreted by HEX as a number but IHEX would
ignore it unless expressed as $ABC). Likewise, the binary version can
distinguish the decimal number 10 from the binary number %10. A prefix
occurring in non-numeric text is ignored, and any character (including a
space) between a prefix and a number causes the prefix to be ignored. Indicated,
signed formatters require that the minus sign come before the prefix, as
in -$1B45.</li>
</ol>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="20%">Special Formatter</td>
<td width="80%">Action</td>
</tr>
<tr>
<td align="center">STR ByteArray \L {\E}</td>
<td>Input a character string of length L into an array. If specified, an end
character E causes the string input to end before reaching length L.
Remaining bytes are filled with 0s (zeros).</td>
</tr>
<tr>
<td align="center">WAITSTR ByteArray {\L}</td>
<td>Wait for a sequence of bytes matching a string stored in an array
variable, optionally limited to L characters. If the optional L argument is
left off, the end of the array-string must be marked by a byte containing a
zero (0).</td>
</tr>
<tr>
<td align="center">SKIP Length</td>
<td>Ignore Length bytes of characters.</td>
</tr>
<tr>
<td align="center">SPSTR Length</td>
<td>Buffer Length bytes (up to 126) of serial characters to Scratchpad RAM,
starting at location 0. Use <a href="GET.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GET</a> to retrieve the
characters.</td>
</tr>
</table>
<p>&#160;</p>
<p class="PlainText">Some possible uses of the <span class="keyword_in_text">LCDIN</span> command are 1) in combination with the
<span class="keyword_in_text">LCDOUT</span> command to store and read data from the unused DDRAM or CGRAM
locations (as extra variable space), 2) to verify that the data from a previous
<span class="keyword_in_text">LCDOUT</span> command was received and processed properly by the LCD, and 3) to
read character data from CGRAM for the purposes of modifying it and storing it
as a custom character.</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>

View File

@ -0,0 +1,309 @@
<?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>LCDOUT</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">LCDOUT</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/LcdoutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDOUT Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">LCDOUT</span> <![CDATA[ ]]><i>Pin</i>,<i> Command</i>, [<i>OutputData</i>]</p>
<h2>Function</h2>
<p class="PlainText">Send data to an LCD display.
</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression (0 - 1 or 8 - 9) that
specifies which I/O pins to use. The LCD requires, at most, seven I/O pins
to operate. The <i>Pin</i> argument serves a double purpose; specifying the
first pin and, indirectly, the group of other required pins. See explanation
below. All I/O pins will be set to output mode initially and the upper I/O
pins (4 - 7 or 12 - 15) will be set to output mode by the end of the <span class="keyword_in_text">LCDOUT</span> command.</li>
<li value="2"><b><i>Command</i></b> is a variable/constant/expression (0 - 255) indicating
an LCD command to send.</li>
<li value="3"><b><i>OutputData</i></b> is a list of variables, constants, expressions and
formatters that tells <span class="keyword_in_text">LCDOUT</span> how to format outgoing data. <span class="keyword_in_text">LCDOUT</span>
can transmit individual or repeating bytes, convert values into decimal, hex
or binary text representations, or transmit strings of bytes from variable
arrays. These actions can be combined in any order in the <i>OutputData</i>list.</li>
</ul>
<h2>Quick Facts</h2>
<table cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="275" align="center">&#160;</td>
<td width="1200" align="center">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Values for <i>Pin</i></td>
<td align="center">0, 1, 8, or 9</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">I/O pin arrangement when<br></br><i>Pin</i> is
0 or 1</td>
<td>0 or 1 (depending on <i>Pin</i>) : LCD Enable (E) pin<br></br> 2 : LCD Read/Write (R/W) pin<br></br> 3 : LCD Register Select (RS) pin<br></br> 4 - 7 : LCD Data Bus (DB4 - DB7, respectively) pins</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">I/O pin arrangement when<br></br><i>Pin</i> is
8 or 9</td>
<td>8 or 9 (depending on <i>Pin</i>) : LCD Enable (E) pin<br></br> 10 : LCD Read/Write (R/W) pin<br></br> 11 : LCD Register Select (RS) pin<br></br> 12 - 15 : LCD Data Bus (DB4 - DB7, respectively) pins</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a>, <a href="LCDIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDIN</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The three LCD commands (<span class="keyword_in_text">LCDCMD</span>, <span class="keyword_in_text">LCDIN</span> and <span class="keyword_in_text">LCDOUT</span>) allow the
BS2p, BS2pe, or BS2pe to interface directly to standard LCD displays that feature
a Hitachi 44780 controller (part #HD44780A). This includes many 1 x 16, 2 x 16,
and 4 x 20 character LCD displays. Note that <span class="keyword_in_text">LCDCMD</span>, <span class="keyword_in_text">LCDIN</span> and
<span class="keyword_in_text">LCDOUT</span> use a 4-bit interface to the LCD which requires a specific
initialization sequence before <span class="keyword_in_text">LCDIN</span> and <span class="keyword_in_text">LCDOUT</span> can be used
(see <a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a> for initialization details).</p>
<p class="PlainText">The <span class="keyword_in_text">LCDOUT</span> command is used to send one instruction followed by at least
one data byte to the LCD. The data that is output is written to the LCD's
Character Generator RAM (CGRAM) or Display Data RAM (DDRAM). The following is an
example of the <span class="keyword_in_text">LCDOUT</span> command:</p><pre class="BScode" xml:space="preserve">
LCDOUT 1, 1, ["Hello World!"]
</pre>
<p class="PlainText">The preceding example will clear the LCD screen and then send "Hello World!" to
the screen. The first argument (1) is the starting I/O pin number and the second
argument (also 1) is the LCD's instruction for Clear Screen.</p>
<p class="PlainText">The <span class="keyword_in_text">LCDOUT</span> command actually uses more than just the I/O pin specified
by the <i>Pin</i> argument. The LCDOUT command requires seven I/O pins. This is
because the standard LCD displays have a parallel interface, rather than a serial
one. The <i>Pin</i> argument can be the numbers 0, 1, 8, or 9 and will result in
the use of the I/O pins shown above. Please refer to the
<a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a> command description for information on properly
wiring the LCD display.</p>
<p class="PlainText">When the LCD is first powered-up, it will be in an unknown state and must be
properly configured before sending commands like the one shown above. This process
is known as initializing the LCD and is the first thing your program should do
upon starting up. Please refer to the <a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a> command
description for information on properly initializing the LCD display.</p>
<p class="PlainText">The <span class="keyword_in_text">LCDOUT</span> command's <i>OutputData</i> argument is exactly like that
of the <span class="keyword_in_text">DEBUG</span> and <span class="keyword_in_text">SEROUT</span> command's <i>OutputData</i> argument.
This means data can be sent as literal text, ASCII character values, repetitive
values, decimal, hexadecimal and binary translations and string data as in the
examples below.</p><pre class="BScode" xml:space="preserve">
value VAR Byte
Setup:
value = 65
Main:
LCDOUT 1, 0, [value] ' send ASCII character "A"
LCDOUT 1, 0, [REP value\5] ' send "AAAAA"
LCDOUT 1, 0, [DEC value] ' send "6" and "5"
LCDOUT 1, 0, [HEX value] ' send "4" and "1"
LCDOUT 1, 0, [BIN value] ' send "1000001"
STOP
</pre>
<p class="PlainText">The tables below list all the available conversion formatters and special
formatters available to the <span class="keyword_in_text">LCDOUT</span> command. See the
<a href="DEBUG.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DEBUG</a> and <a href="SEROUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SEROUT</a> commands for
additional information and examples of their use.</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="20%">Conversion Formatter</td>
<td width="70%">Type of Number</td>
<td width="10%">Notes</td>
</tr>
<tr align="center">
<td>DEC{1..5}</td>
<td align="left">Decimal, optionally fixed to 1 - 5 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>SDEC{1..5}</td>
<td align="left">Signed decimal, optionally fixed to 1 - 5 digits</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>HEX{1..4}</td>
<td align="left">Hexadecimal, optionally fixed to 1 - 4 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>SHEX{1..4}</td>
<td align="left">Signed hexadecimal, optionally fixed to 1 - 4 digits </td>
<td>1,2</td>
</tr>
<tr align="center">
<td>IHEX{1..4}</td>
<td align="left">Indicated hexadecimal, optionally fixed to 1 - 4 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>ISHEX{1..4}</td>
<td align="left">Signed, indicated hexadecimal, optionally fixed to 1 - 4
digits ($ prefix)</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>BIN{1..16}</td>
<td align="left">Binary, optionally fixed to 1 - 16 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>SBIN{1..16}</td>
<td align="left">Signed binary, optionally fixed to 1 - 16 digits</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>IBIN{1..16}</td>
<td align="left">Indicated binary, optionally fixed to 1 - 16 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>ISBIN{1..16}</td>
<td align="left">Signed, indicated binary, optionally fixed to 1 - 16 digits</td>
<td>1,2</td>
</tr>
</table>
<ol>
<li value="1">Fixed-digit formatters like DEC4 will pad the number with leading 0s if
necessary; ex: DEC4 65 sends 0065. If a number is larger than the specified
number of digits, the leading digits will be dropped; ex: DEC4 56422 sends
6422.</li>
<li value="2">Signed modifiers work under two's complement rules.</li>
</ol>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="20%">Special Formatter</td>
<td width="80%">Action</td>
</tr>
<tr>
<td align="center">?</td>
<td>Displays "symbol = x' + carriage return; where x is a number. Default
format is decimal, but may be combined with conversion formatters (ex: BIN
? x to display "x = binary_number").</td>
</tr>
<tr>
<td align="center">ASC ?</td>
<td>Displays "symbol = 'x'" + carriage return; where x is an ASCII character.</td>
</tr>
<tr>
<td align="center">STR ByteArray {\L}</td>
<td>Send character string from an array. The optional \L argument can be used
to limit the output to L characters, otherwise, characters will be sent up
to the first byte equal to 0 or the end of RAM space is reached.</td>
</tr>
<tr>
<td align="center">REP Byte\L</td>
<td>Send a string consisting of Byte repeated L times (ex: REP "X"\10 sends
"XXXXXXXXXX").</td>
</tr>
</table>
<h3>Using the <i>Command</i> Argument</h3>
<p class="PlainText">The <i>Command</i> argument is useful for proceeding a set of data with a
special LCD instruction. For example, the code below will move the cursor to
location 64 (the first character on the second line) and print "Hi":</p><pre class="BScode" xml:space="preserve">
LCDOUT 1, 128 + 64, ["Hi"]
</pre>
<p class="PlainText">The next example, below, will turn on the blinking block cursor and print
"Yo!":</p><pre class="BScode" xml:space="preserve">
LCDOUT 1, 13, ["Yo!"]
</pre>
<p class="PlainText">Occasionally, you will want to send data without preceding it with a command.
To do this, simply use 0 for the <i>Command</i> argument, as in:</p><pre class="BScode" xml:space="preserve">
LCDOUT 1, 0, ["Hello there!"]
</pre>
<p class="PlainText">Another use for the <span class="keyword_in_text">LCDOUT</span> command is to access and create custom
characters. The Hitachi 44780 controller has a built-in character set that is
similar to the ASCII character set (at least for the first 128 characters).
Most of these characters are stored in ROM and are not changeable, however, the
first eight characters (ASCII 0 though 7) are programmable.</p>
<p class="PlainText">Each of the programmable characters is five pixels wide and eight pixels tall.
It takes eight bytes to describe each character; one byte per row (the left-most
three bits are ignored). For example, the character at ASCII location 0 is defined
by the bit patterns stored in bytes 0 through 7 of Character Generator RAM (CGRAM).
The character at ASCII location 1 is defined by the bit patterns stored in bytes
8 through 15 of CGRAM, and so on.</p>
<p class="PlainText">To create a custom character, use some graph paper to plot out the bit pattern
(on and off pixels) in a 5 x 8 pattern, as shown in below. Then calculate the
corresponding binary value of the bit pattern for each of the eight rows of
character data.</p>
<center>
<table border="0">
<tr>
<td align="center"><b>Character Cell Structure and Data</b>
</td>
</tr>
<tr>
<td>
<img src="../../graphics/lcd_char.gif" border="0">
</img>
</td>
</tr>
</table>
</center>
<p class="PlainText">After the data is calculated for each character (8 byte values per character),
use the <span class="keyword_in_text">LCDOUT</span> command with the "Move To CGRAM Address" instruction to
insert the data into the character's CGRAM locations. For example, the code
below will store the character shown in above into character 0's CGRAM data
locations. Then it will place the cursor back on the display (DDRAM) and print
the character on the screen.</p><pre class="BScode" xml:space="preserve">
LCDOUT 1, 64+0, [00, 10, 10, 00, 17, 14, 06, 00]
LCDOUT 1, 128+0, ["Custom Char: ", 0]
</pre>
<p class="PlainText">The number 64 in the <i>Command</i> argument is the LCD's "Move to CGRAM Address"
instruction and the 0 that is added to it is the location of the first row of data
for the character 0. The <span class="keyword_in_text">LCDOUT</span> command will write the first <i>OutputData</i>
value (00) to this location, the second <i>OutputData</i> value (10) to location 1,
etc. If we wanted this custom character to affect character 1, instead of 0, we'd
have to adjust value of the "Move To..." command, i.e., 64+8. To affect character 2,
we'd use 64+16.</p>
<p class="PlainText">To try the example above, don't forget to execute the LCD initialization code
(shown in the <a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a> description) first and never forget
to move the cursor back to the screen (as with the last command, above) when you're
done writing the character data to CGRAM.</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>

View File

@ -0,0 +1,86 @@
<?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>LET</title>
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
</script>
</head>
<body>
<h1 class="code">LET</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
</p>
</div>
<p style="text-align: right;">&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: {<span class="keyword_in_text">LET</span>}<i>Variable </i>=<i> Value</i></p>
<h2>Function</h2>
<p class="PlainText">Sets <i>Variable</i> equal to the value of <i>Value</i>.
</p>
<ul>
<li value="1"><b><i>Variable</i></b> is a variable/constant/expression (0-65535).</li>
<li value="2"><b><i>Value</i></b> is a variable which will be set equal to <i>Value</i>. </li>
</ul>
<h2>Explanation<br /></h2>
<p class="PlainText"><span class="keyword_in_text">LET</span> is an optional instruction for the BASIC Stamp 1 that can be used with variable assignment statements, such as A = 5 and B = A + 2, etc. This instruction is not required and only exits on the BASIC Stamp 1. <span class="keyword_in_text">LET</span> was a commonly used command in early forms of BASIC, and was originally included in the BS1 command set to accommodate programmers from that generation. Parallax recommends that all new BASIC Stamp 1 programs use assignment statements without the <span class="keyword_in_text">LET</span> command.</p>
<p class="PlainText">The example below demonstrates the use of <span class="keyword_in_text">LET</span> in assignment statements. Note that the Lunchtime and Dinnertime routines do essentially the same type of thing, but the Dinnertime approach is recommended.</p><pre class="BScode" xml:space="preserve">' {$STAMP BS1}
' {$PBASIC 1.0}
' {$STAMP BS1}
SYMBOL salad = B1
SYMBOL bread = B2
SYMBOL soup = B3
SYMBOL lunch = B4
SYMBOL dinner = B5
Lunchtime:
LET salad = 3
LET bread = 1
LET soup = 4
lunch = salad + bread + soup
DEBUG "Lunch = $", #lunch, "plus local tax.", CR
Dinnertime:
salad = 4
bread = 2
soup = 5
dinner = salad + bread + soup
DEBUG "Dinner = $",#dinner, "plus local tax.", CR
</pre>
<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>

View File

@ -0,0 +1,401 @@
<?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>LOOKDOWN</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">LOOKDOWN</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/LookdownEx.htm" target="" title="" alt="" class="MCXref_0">LOOKDOWN Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax <img align="absmiddle" src="../../graphics/mini_1.gif" /> :
<span class="keyword_in_text">LOOKDOWN</span><i>Target</i>, (<i>Value0, Value1</i>, ...<i>ValueN </i>),<i> Variable</i><br />Syntax <img align="absmiddle" src="../../graphics/mini_2.gif" /> :
<span class="keyword_in_text">LOOKDOWN</span> <![CDATA[ ]]><i>Target</i>, {<i>ComparisonOp</i>} [<i>Value0</i>,<i> Value1</i>,
...<i>ValueN</i>],<i> Variable</i></p>
<h2>Function</h2>
<p class="PlainText">Compare <i>Target</i> value to a list of values and store the index number of
the first value that matches into <i>Variable</i>. If no value in the list matches,
<i>Variable</i> is left unaffected. On the BS2, BS2e, BS2sx and BS2p, the optional
<i>ComparisonOp</i> is used as criteria for the match; the default criteria is
"equal to."
</p>
<ul>
<li value="1"><b><i>Target</i></b> is a variable/constant/expression* (0 - 65535) to be
compared to the values in the list. </li>
<li value="2"><b><i>ComparisonOp</i></b> is an optional comparison operator (as described
below) to be used as the criteria when comparing values. When no
<i>ComparisonOp</i> is specified, equal to (=) is assumed. This argument is
not available on the BS1.</li>
<li value="3"><b><i>Values</i></b> are variables/constants/expressions* (0 - 65535) to
be compared to <i>Target</i>.</li>
<li value="4"><b><i>Variable</i></b> is a variable (usually a byte) that will be set to
the index (0 - 255) of the matching value in the <i>Values</i> list. If no
matching value is found, <i>Variable</i> is left unaffected. </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>
<td width="20%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="80%" align="center" bgcolor="#CFCFCF">All BASIC Stamp Modules</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Limit of value entries</td>
<td align="center">256</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Starting index number</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">If value list contains no match...</td>
<td align="center"><i>Variable</i> is left unaffected</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Command</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="LOOKUP.htm" target="" title="" alt="" class="MCXref_0">LOOKUP</a>
</p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">LOOKDOWN</span> works like the index in a book. In an index, you search for a
topic and get the page number. <span class="keyword_in_text">LOOKDOWN</span> searches for a target value in
a list, and stores the index number of the first match in a variable. For
example: </p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL value = B2
SYMBOL result = B3
Setup:
value = 17
result = 15
Main:
LOOKDOWN value, (26, 177, 13, 1, 0, 17, 99), result
DEBUG "Value matches item ", #result, "in list"
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
value VAR Byte
result VAR Byte
Setup:
value = 17
result = 15
Main:
LOOKDOWN value, [26, 177, 13, 1, 0, 17, 99], result
DEBUG "Value matches item ", DEC result, " in list"
END
</pre>
<p class="PlainText"><span class="keyword_in_text">DEBUG</span> prints, "Value matches item 5 in list" because the value (17)
matches item 5 of [26, 177, 13, 1, 0, 17, 99]. Note that index numbers count up
from 0, not 1; that is, in this list, 26 is item 0.</p>
<p class="PlainText">What happens if the value doesn't match any of the items in the list? Try
changing "<span class="code_in_text">value = 17</span>" to "<span class="code_in_text">value = 2.</span>" Since 2 is not on the list, <span class="keyword_in_text">LOOKDOWN</span>
leaves <span class="code_in_text">result </span>unaffected. Since <span class="code_in_text">result </span>contained 15 before <span class="keyword_in_text">LOOKDOWN</span>
executed, <span class="keyword_in_text">DEBUG</span> prints "Value matches item 15 in list." By strategically
setting the initial value of <span class="code_in_text">result</span>, as we have here, your program can be written
to detect when an item was not found in the list. </p>
<p class="PlainText">Don't forget that text phrases are just lists of byte values, so they too are
eligible for <span class="keyword_in_text">LOOKDOWN</span> searches, as in this example:</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL value = B2
SYMBOL result = B3
Setup:
value = "f"
result = 255
Main:
LOOKDOWN value, ("The quick brown fox"), result
DEBUG "Value matches item ", #result, "in list"
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
value VAR Byte
result VAR Byte
Setup:
value = "f"
result = 255
Main:
LOOKDOWN value, ["The quick brown fox"], result
DEBUG "Value matches item ", DEC result, " in list"
END
</pre>
<p><span class="keyword_in_text">DEBUG</span> prints, "Value matches item 16 in list" because the character at
index item 16 is "f" in the phrase, "The quick brown fox".</p>
<p class="PlainText">The examples above show <span class="keyword_in_text">LOOKDOWN</span> working with lists of constants, but
it also works with variables and expressions also. Note, however, that expressions
are not allowed as argument on the BS1.</p>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p>
<p class="PlainText">On the BS2, BS2e, BS2sx, BS2p and BS2pe, the <span class="keyword_in_text">LOOKDOWN</span> command can also
use another criteria (other than "equal to") for its list. All of the examples
above use <span class="keyword_in_text">LOOKDOWN</span>'s default comparison operator, =, that searches for an
exact match. The entire list of <i>ComaprisonOps</i> is shown below. The
"greater than" comparison operator (&gt;) is used in the following example: </p><pre class="BScode" xml:space="preserve">
value VAR Byte
result VAR Byte
Setup:
value = 17
result = 15
Main:
LOOKDOWN value, &gt;[26, 177, 13, 1, 0, 17, 99], result
DEBUG "Value greater than item ", DEC result, " in list"
END
</pre>
<p class="PlainText"><span class="keyword_in_text">DEBUG</span> prints, "Value greater than item 2 in list" because the first
item the value 17 is greater than is 13 (which is item 2 in the list). Value is
also greater than items 3 and 4, but these are ignored, because <span class="keyword_in_text">LOOKDOWN</span>
only cares about the first item that matches the criteria. This can require a
certain amount of planning in devising the order of the list. To see a complete program, see the
<a href="../ExampleTopics/LookdownEx.htm" target="" title="" alt="" class="MCXref_0">LOOKDOWN Examples</a>.</p>
<p class="PlainText"><span class="keyword_in_text">LOOKDOWN</span> comparison operators use unsigned 16-bit math. They will not
work correctly with signed numbers, which are represented internally as two's
complement (large 16-bit integers). For example, the two's complement
representation of -99 is 65437. So although -99 is certainly less than 0, it
would appear to be larger than zero to the <span class="keyword_in_text">LOOKDOWN</span> comparison operators.
The bottom line is: Don't used signed numbers with <span class="keyword_in_text">LOOKDOWN</span> comparisons.</p>
<center>
<table width="80%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="25%" align="center" bgcolor="#CFCFCF">ComparisonOp Symbol</td>
<td width="55%" align="center" bgcolor="#CFCFCF">Description</td>
</tr>
<tr>
<td align="center">=</td>
<td align="center">Find the first value Target is equal to</td>
</tr>
<tr>
<td align="center">&lt;&gt;</td>
<td align="center">Find the first value Target is not equal to</td>
</tr>
<tr>
<td align="center">&gt;</td>
<td align="center">Find the first value Target is greater than</td>
</tr>
<tr>
<td align="center">&lt;</td>
<td align="center">Find the first value Target is less than</td>
</tr>
<tr>
<td align="center">&gt;=</td>
<td align="center">Find the first value Target is greater than or equal to</td>
</tr>
<tr>
<td align="center">&lt;=</td>
<td align="center">Find the first value Target is less than or equal to</td>
</tr>
</table>
</center>
<p>&#160;</p>
<p class="PlainText">A common application for <span class="keyword_in_text">LOOKDOWN</span> is to use it in conjunction with the
<span class="keyword_in_text">BRANCH</span> command to create selective jumps based on a simple variable input: </p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL cmd = B2
Setup:
cmd = "M"
Main:
LOOKDOWN cmd, ("SLMH"), cmd
BRANCH cmd, (_Stop, _Low, _Medium, _High)
DEBUG "Command not in list"
END
_Stop:
DEBUG "Stop"
END
_Low:
DEBUG "Low"
END
_Medium:
DEBUG "Medium"
END
_High:
DEBUG "High"
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
cmd VAR Byte
Setup:
cmd = "M"
Main:
LOOKDOWN cmd, ["SLMH"], cmd
BRANCH cmd, [_Stop, _Low, _Medium, _High]
DEBUG "Command not in list"
END
_Stop:
DEBUG "Stop"
END
_Low:
DEBUG "Low"
END
_Medium:
DEBUG "Medium"
END
_High:
DEBUG "High"
END
</pre>
<p class="PlainText">In this example, <span class="code_in_text">cmd </span>contains "M" (ASCII 77). <span class="keyword_in_text">LOOKDOWN</span> finds that this
is item 2 of a list of one-character commands and stores 2 into <span class="code_in_text">cmd</span>. <span class="keyword_in_text">BRANCH</span>then goes to item 2 of its list, which is the program label "<span class="code_in_text">_Medium</span>" at which
point <span class="keyword_in_text">DEBUG</span> prints "Medium" on the PC screen. This is a powerful method
for interpreting user input, and a lot neater than the alternative <span class="keyword_in_text">IF...THEN</span>instructions. </p>
<p class="PlainText">Another great use of <span class="keyword_in_text">LOOKDOWN</span> is in combination with <span class="keyword_in_text">LOOKUP</span> to
"map" non-contiguous sets of numbers together. For example, you may have an
application where certain numbers are received by the BASIC Stamp and, in response,
the BASIC Stamp needs to send a specific set of numbers. This may be easy to code
if the numbers are contiguous, or follow some known algebraic equation... but what
if they don't? The table below shows some sample, non-contiguous inputs and the
corresponding outputs the BASIC Stamp needs to respond with:</p>
<center>
<table width="60%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="10%" align="center" bgcolor="#CFCFCF">Index</td>
<td width="25%" align="center" bgcolor="#CFCFCF">Each of these values
received (inputs):</td>
<td width="25%" align="center" bgcolor="#CFCFCF">Needs to result in each of
these values sent (outputs):</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">5</td>
<td align="center">16</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">14</td>
<td align="center">17</td>
</tr>
<tr>
<td align="center">2</td>
<td align="center">1</td>
<td align="center">18</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">43</td>
<td align="center">24</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">26</td>
<td align="center">10</td>
</tr>
<tr>
<td align="center">5</td>
<td align="center">22</td>
<td align="center">12</td>
</tr>
<tr>
<td align="center">6</td>
<td align="center">30</td>
<td align="center">11</td>
</tr>
</table>
</center>
<p>&#160;</p>
<p class="PlainText">So, if we receive the number 5, we need to output 16. If we received 43, we
need to output 24, and so on. These numbers are not contiguous and they don't
appear to be derived from any simple algorithm. We can solve this problem with
two lines of code, as follows:</p><pre class="BScode" xml:space="preserve">
LOOKDOWN value, [5, 14, 1, 43, 26, 22, 30], value
LOOKUP value, [16, 17, 18, 24, 10, 12, 11], value
</pre>
<p class="PlainText">Assuming our received number is in value, the first line (<span class="keyword_in_text">LOOKDOWN</span>)
will find the value in the list and store the index of the location that matches
back into <span class="code_in_text">value</span>. (This step "maps" the non-contiguous numbers: 5, 14, 1, etc,
to a contiguous set of numbers: 0, 1, 2, etc). The second line (<span class="keyword_in_text">LOOKUP</span>)
takes our new value, finds the number at that location and stores it back into
<span class="code_in_text">value</span>. If the received value was 14, <span class="keyword_in_text">LOOKDOWN</span> stores 1 into value and
<span class="keyword_in_text">LOOKUP</span> looks at the value at location 1 and stores 17 in <span class="code_in_text">value</span>. The
number 43 gets mapped to 3, 3 gets mapped to 24, and so on. This is a quick and
easy fix for a potentially messy problem!</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>

View File

@ -0,0 +1,255 @@
<?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>LOOKUP</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">LOOKUP</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/LookupEx.htm" target="" title="" alt="" class="MCXref_0">LOOKUP Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax <img align="absmiddle" src="../../graphics/mini_1.gif" /> :
<span class="keyword_in_text">LOOKUP</span> <![CDATA[ ]]><i>Index</i>, (<i>Value0</i>,<i> Value1</i>, ...<i>ValueN</i>),<i>
Variable</i><br />Syntax <img align="absmiddle" src="../../graphics/mini_2.gif" /> :
<span class="keyword_in_text">LOOKUP</span> <![CDATA[ ]]><i>Index</i>, [<i>Value0</i>,<i> Value1</i>, ...<i>ValueN</i>],<i>
Variable</i></p>
<h2>Function</h2>
<p class="PlainText">Find the value at location <i>Index</i> and store it in <i>Variable</i>.
If <i>Index</i> exceeds the highest index value of the items in the list,
<i>Variable</i> is left unaffected.
</p>
<ul>
<li value="1"><b><i>Index</i></b> is a variable/constant/expression* (0 - 255) indicating
the list item to retrieve. </li>
<li value="2"><b><i>Values</i></b> are variables/constants/expressions* (0 - 65535).</li>
<li value="3"><b><i>Variables</i></b> is a variable that will be set to the value at the
<i>Index</i> location. If <i>Index</i> exceeds the highest location number, <i>Variable</i> is left unaffected.</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>
<td width="20%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="80%" align="center" bgcolor="#CFCFCF">All BASIC Stamp Modules</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Limit of value entries</td>
<td align="center">256</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Starting index number</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">If index exceeds the highest location...</td>
<td align="center"><i>Variable</i> is left unaffected</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Command</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="LOOKDOWN.htm" target="" title="" alt="" class="MCXref_0">LOOKDOWN</a>
</p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">LOOKUP</span> retrieves an item from a list based on the item's position, Index,
in the list. For example: </p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL idx = B2
SYMBOL result = B3
Setup:
idx = 3
result = 255
Main:
LOOKUP idx, (26, 177, 13, 1, 0, 17, 99), result
DEBUG "Item ", #idx, "is: ", #result
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
idx VAR Nib
result VAR Byte
Setup:
idx = 3
result = 255
Main:
LOOKUP idx, [26, 177, 13, 1, 0, 17, 99], result
DEBUG "Item ", DEC idx, " is: ", DEC result
END
</pre>
<p class="PlainText">In this example, <span class="keyword_in_text">DEBUG</span> prints "Item 3 is: 1." Note that the first
location number is 0. In the list above, item 0 is 26, item 1 is 177, etc.</p>
<p class="PlainText">If <i>Index</i> is beyond the end of the list, the result variable is unchanged.
In the example above, if index were greater than 6, the message would have reported
the result to be 255, because that's what result contained before <span class="keyword_in_text">LOOKUP</span>
executed. </p>
<p class="PlainText">Don't forget that text phrases are just lists of byte values, so they too are
eligible for <span class="keyword_in_text">LOOKUP</span> searches, as in this example:</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL idx = B2
SYMBOL result = B3
Setup:
idx = 16
result = "*"
Main:
LOOKUP idx, ("The quick brown fox"), result
DEBUG @result
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
iidx VAR Byte
result VAR Byte
Setup:
idx = 16
result = "*"
Main:
LOOKUP idx, ["The quick brown fox"], result
DEBUG ASC? result
END
</pre>
<p class="PlainText"><span class="keyword_in_text">DEBUG</span> prints, "Result = 'f'" because the character at index item 16 is
"f" in the phrase, "The quick brown fox".</p>
<p class="PlainText">The examples above show <span class="keyword_in_text">LOOKUP</span> working with lists of constants, but it
also works with variables and expressions also. Note, however, that expressions
are not allowed as argument on the BS1. </p>
<p class="PlainText">A great use of <span class="keyword_in_text">LOOKUP</span> is in combination with <span class="keyword_in_text">LOOKDOWN</span> to "map"
non-contiguous sets of numbers together. For example, you may have an application
where certain numbers are received by the BASIC Stamp and, in response, the BASIC
Stamp needs to send a specific set of numbers. This may be easy to code if the
numbers are contiguous, or follow some know algebraic equations… but what if they
don't? The table below shows some sample, non-contiguous inputs and the
corresponding outputs the BASIC Stamp needs to respond with:</p>
<center>
<table width="60%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="10%" align="center" bgcolor="#CFCFCF">Index</td>
<td width="25%" align="center" bgcolor="#CFCFCF">Each of these values
received (inputs):</td>
<td width="25%" align="center" bgcolor="#CFCFCF">Needs to result in each of
these values sent (outputs):</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">5</td>
<td align="center">16</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">14</td>
<td align="center">17</td>
</tr>
<tr>
<td align="center">2</td>
<td align="center">1</td>
<td align="center">18</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">43</td>
<td align="center">24</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">26</td>
<td align="center">10</td>
</tr>
<tr>
<td align="center">5</td>
<td align="center">22</td>
<td align="center">12</td>
</tr>
<tr>
<td align="center">6</td>
<td align="center">30</td>
<td align="center">11</td>
</tr>
</table>
</center>
<p>&#160;</p>
<p class="PlainText">So, if we receive the number 5, we need to output 16. If we received 43, we
need to output 24, and so on. These numbers are not contiguous and they don't
appear to be derived from any simple algorithm. We can solve this problem with
two lines of code, as follows:</p><pre class="BScode" xml:space="preserve">
LOOKDOWN value, [5, 14, 1, 43, 26, 22, 30], value
LOOKUP value, [16, 17, 18, 24, 10, 12, 11], value
</pre>
<p class="PlainText">Assuming our received number is in <span class="code_in_text">value</span>, the first line (<span class="keyword_in_text">LOOKDOWN</span>)
will find the value in the list and store the index of the location that matches
back into <span class="code_in_text">value</span>. (This step "maps" the non-contiguous numbers: 5, 14, 1, etc,
to a contiguous set of numbers: 0, 1, 2, etc). The second line (<span class="keyword_in_text">LOOKUP</span>)
takes our new value, finds the number at that location and stores it back into
<span class="code_in_text">value</span>. If the received value was 14, <span class="keyword_in_text">LOOKDOWN</span> stores 1 into <span class="code_in_text">value </span>and
<span class="keyword_in_text">LOOKUP</span> looks at the value at location 1 and stores 17 in <span class="code_in_text">value</span>. The
number 43 gets mapped to 3, 3 gets mapped to 24, and so on. This is a quick and
easy fix for a potentially messy problem!</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>

View File

@ -0,0 +1,108 @@
<?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>LOW</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">LOW</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/HighLowEx.htm" target="" title="" alt="" class="MCXref_0">HIGH / LOW Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">LOW</span> <![CDATA[ ]]><i>Pin</i></p>
<h2>Function</h2>
<p class="PlainText">Make the specified pin output low.
</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression (0 - 15) that specifies
which I/O pin to set low. This pin will be placed into output mode.</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 cellpadding="4" cellspacing="0" border="1" style="caption-side: top;width: 100%;">
<col />
<col />
<tr bgcolor="#CFCFCF">
<td width="15%" align="center">&#160;</td>
<td width="85%" align="center">BS1 and all BS2 models</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td>
<p align="center"><a href="HIGH.htm" target="" title="" alt="" class="MCXref_0">HIGH</a>, <a href="TOGGLE.htm" target="" title="" alt="" class="MCXref_0">TOGGLE</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">LOW</span> command sets the specified pin to 0 (a 0 volt level) and then
sets its mode to output. For example,
</p><pre class="BScode" xml:space="preserve">
&#160;LOW 6
</pre>
<p class="PlainText">...does exactly the same thing as:</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0" />
</p><pre class="BScode" xml:space="preserve">
&#160;PIN6 = 0
&#160;DIR6 = 1
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
&#160;OUT6 = 0
&#160;DIR6 = 1
</pre>
<p class="PlainText">Using the <span class="keyword_in_text">LOW</span> command is faster in this case.</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>

View File

@ -0,0 +1,90 @@
<?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>MAINIO</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">MAINIO</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" /> (BS2p40)</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/AuMainIotermEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">AUXIO / MAINIO / IOTERM Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">MAINIO</span></p>
<h2>Function</h2>
<p>Switch from control of auxiliary I/O pins to main I/O pins (on the BS2p40 only).</p>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="15%" align="center">&#160;</td>
<td width="85%" align="center">BS2p / BS2pe / BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">I/O Pin IDs</td>
<td>0 - 15 (just like auxiliary I/O, but after <span class="keyword_in_text">MAINIO</span> command, all
references affect physical pins 5 - 20).</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td>
<p>Command is accepted by the 24-pin BS2p, BS2pe, and BS2px, but only the 40-pin BS2p40 gives access to the auxiliary I/O pins.</p>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="AUXIO.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">AUXIO</a>, <a href="IOTERM.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">IOTERM</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The BS2p, BS2pe, and BS2px is available as a 24-pin module that is pin-compatible with the BS2, BS2e, and BS2sx. Also availabe is a 40-pin module called the BS2p40 with an additional 16 I/O pins (for a total of 32). The BS2p40's extra, or auxiliary, I/O pins can be accessed in the same manner as the main I/O pins (by using the IDs 0 to 15) but only after issuing an <span class="keyword_in_text">AUXIO</span> or <span class="keyword_in_text">IOTERM 1</span> command. The <span class="keyword_in_text">MAINIO</span> command causes the BASIC Stamp to affect the main I/O pins (the default) instead of the auxiliary I/O pins in all further code until the <span class="keyword_in_text">AUXIO</span> or <span class="keyword_in_text">IOTERM 1</span> command is reached, or the BASIC Stamp is reset or power-cycled.</p>
<p class="PlainText">The following example illustrates this:<br></br></p><pre class="BScode" xml:space="preserve">
AUXIO
HIGH 0
MAINIO
LOW 0
</pre>
<p class="PlainText">The first line of the above example will tell the BASIC Stamp to affect the auxiliary I/O pins in the commands following it. Line 2 sets I/O pin 0 of the auxiliary I/O pins (physical pin 21) high. Afterward, the <span class="keyword_in_text">MAINIO </span>command tells the BASIC Stamp that all commands following it should affect the main I/O pins. The last command, <span class="keyword_in_text">LOW</span>, will set I/O pin 0 of the main I/O pins (physical pin 5) low.</p>
<p class="PlainText">Note that the main I/O and auxiliary I/O pins are independent of each other; the states of the main I/O pins remain unchanged while the program affects the auxiliary I/O pins, and vice versa.</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>

View File

@ -0,0 +1,194 @@
<?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>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</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%">&#160;</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>&#160;</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 ©&#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>

View File

@ -0,0 +1,107 @@
<?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>ON...GOSUB</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">ON...GOSUB</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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" /><span class="code_in_text"> {PBASIC&#160;2.5}</span>
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/OnGosubEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">ON...GOSUB Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">ON</span> <![CDATA[ ]]><i>Offset</i> <![CDATA[ ]]><span class="keyword_in_text">GOSUB</span> <![CDATA[ ]]><i>Address1</i>, <i>Address2</i>, ...<i>AddressN</i></p>
<h2>Function</h2>
<p class="PlainText">Store the address of the next instruction after <span class="keyword_in_text">ON..GOSUB</span>, then go to the
<i>Address</i> specified by offset (if in range) with the intention of returning
to the stored address. If <i>Offset</i>-1 is greater than the number of elements in
the address table, the program continues at the line following <span class="keyword_in_text">ON..GOSUB</span>.</p>
<ul>
<li value="1"><b><i>Offset</i></b> is a variable/constant/expression (0 - 255) that
specifies the index of the address, in the list, to branch to (0 - N).</li>
<li value="2"><b><i>Addresses</i></b> are labels that specify where to go for a given <i>Offset</i>. <span class="keyword_in_text">ON...GOSUB</span>
will ignore any list entries beyond offset 255.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td align="center" width="25%" bgcolor="#CFCFCF">&#160;</td>
<td align="center" bgcolor="#CFCFCF">BS2 Family</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Limit of <i>Address</i> entries</td>
<td align="center">256</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Maximum nested <span class="keyword_in_text">GOSUB</span>s </td>
<td align="center">4</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Maximum <span class="keyword_in_text">GOSUB</span>s per Program</td>
<td align="center">255 (each <span class="keyword_in_text">ON...GOSUB</span> counts as as a <span class="keyword_in_text">GOSUB </span>regardless of number of address list entries)</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="BRANCH.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">BRANCH</a>, <a href="GOSUB.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GOSUB</a>, <a href="GOTO.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GOTO</a>, <a href="ON_GOTO.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">ON...GOTO</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">ON...GOSUB</span> instruction is useful when you want to write something like
this:</p><pre class="BScode" xml:space="preserve">
IF (value = 0) THEN GOSUB Case_0
IF (value = 1) THEN GOSUB Case_1
IF (value = 2) THEN GOSUB Case_2
</pre>
<p class="PlainText">You can use <span class="keyword_in_text">ON...GOSUB</span> to organize this into a single statement:</p><pre class="BScode" xml:space="preserve">
ON value GOSUB Case_0, Case_1, Case_2
</pre>
<p class="PlainText">This works exactly the same as the previous <a href="IF_THEN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">IF…THEN</a> example. If the value isn't in range (in this case if <span class="code_in_text">value</span> is greater than 2), <span class="keyword_in_text">ON...GOSUB</span> does nothing and the program continues with the next instruction after <span class="keyword_in_text">ON</span>.</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>

View File

@ -0,0 +1,98 @@
<?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>ON...GOTO</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">ON...GOTO</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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" /><span class="code_in_text"> {PBASIC&#160;2.5}</span>
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/OnGotoEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">ON...GOTO Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p>Syntax: <span class="keyword_in_text">ON</span> <![CDATA[ ]]><i>Offset</i> <![CDATA[ ]]><b>GOTO</b> <![CDATA[ ]]><i>Address1</i>,<i> Address2</i>,
...<i>AddressN</i></p>
<h2>Function</h2>
<p>Go to the address specified by offset (if in range).
</p>
<ul>
<li value="1"><b><i>Offset</i></b> is a variable/constant/expression (0 - 255) that specifies
the index of the address, in the list, to branch to (0 - N).</li>
<li value="2"><b><i>Addresses</i></b> are labels that specify where to go. <span class="keyword_in_text">ON...GOTO</span>will ignore any list entries beyond offset 255.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td align="center" width="25%" bgcolor="#CFCFCF">&#160;</td>
<td align="center" bgcolor="#CFCFCF">BS2 Family</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Limit of <i>Address</i> entries</td>
<td align="center">256</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="BRANCH.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">BRANCH</a>, <a href="GOSUB.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GOSUB</a>, <a href="ON_GOSUB.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">ON...GOSUB</a>, <a href="GOTO.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GOTO</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">ON...GOTO</span> instruction is useful when you want to write something like
this:</p><pre class="BScode" xml:space="preserve">
IF idx = 0 THEN Case_0 ' idx = 0: jump to label "Case_0"
IF idx = 1 THEN Case_1 ' idx = 1: jump to label "Case_1"
IF idx = 2 THEN Case_2 ' idx = 2: jump to label "Case_2"
</pre>
<p class="PlainText">You can use <span class="keyword_in_text">ON...GOTO</span> to organize this into a single statement:</p><pre class="BScode" xml:space="preserve">
ON idx GOTO Case_0, Case_1, Case_2
</pre>
<p class="PlainText">This works exactly the same as the previous <a href="IF_THEN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">IF…THEN</a> example. If the value isn't in range (in this case if <span class="code_in_text">value</span> is greater than 2), <span class="keyword_in_text">ON...GOSUB</span> does nothing and the program continues with the next instruction after <span class="keyword_in_text">ON</span>.</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>

View File

@ -0,0 +1,111 @@
<?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>OUTPUT</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">OUTPUT</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/InputOutputEx.htm" target="" title="" alt="" class="MCXref_0">INPUT / OUTPUT Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">OUTPUT</span> <![CDATA[ ]]><i>Pin</i></p>
<h2>Function</h2>
<p class="PlainText">Make the specified pin an output.
</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression* (0 - 15) that specifies
which I/O pin to set to output mode</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 cellpadding="4" cellspacing="0" border="1" style="caption-side: top;width: 100%;">
<col />
<col />
<tr bgcolor="#CFCFCF">
<td width="15%" align="center">&#160;</td>
<td width="85%" align="center">BS1 and all BS2 models</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td>
<p align="center"><a href="INPUT.htm" target="" title="" alt="" class="MCXref_0">INPUT</a>, <a href="REVERSE.htm" target="" title="" alt="" class="MCXref_0">REVERSE</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">There are several ways to make a pin an output. Commands that rely on
output pins, like <span class="keyword_in_text">PULSOUT</span> and <span class="keyword_in_text">SEROUT</span>, automatically change the
specified pin to output. Writing 1s to particular bits of the variable DIRS
makes the corresponding pins outputs. And then theres the <span class="keyword_in_text">OUTPUT</span>command.</p>
<p class="PlainText">When a pin is an output, your program can change its state by writing to
the corresponding bit in the OUTS variable (PINS on the BS1). For
example:
</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
OUTPUT 4
PIN4 = 1
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
OUTPUT 4
OUT4 = 1
</pre>
<p class="PlainText">When your program changes a pin from input to output, whatever state happens to be in the corresponding bit of OUTS (PINS on the BS1) sets the initial state of the pin. To simultaneously make a pin an output and set its state use the <span class="keyword_in_text">HIGH</span> and <span class="keyword_in_text">LOW</span> commands.</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>

View File

@ -0,0 +1,432 @@
<?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>OWIN</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">OWIN</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/OwinOwoutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">OWIN / OWOUT Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">OWIN</span> <![CDATA[ ]]><i>Pin</i>,<i> Mode</i>, [<i>InputData</i>]</p>
<h2>Function</h2>
<p>Receive data from a device using the Maxim/Dallas Semiconductor 1-Wire<sup>®</sup>protocol.</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression (0 - 15) that specifies
which I/O pin to use. 1-Wire devices require only one I/O pin
(called DQ) to communicate. This I/O pin will be toggled between output
and input mode during the <span class="keyword_in_text">OWIN</span> command and will be set to input mode
by the end of the <span class="keyword_in_text">OWIN</span> command.</li>
<li value="2"><b><i>Mode</i></b> is a variable/constant/expression (0 - 15) indicating
the mode of data transfer. The <i>Mode</i> argument controls placement of
reset pulses (and detection of presence pulses) as well as byte vs. bit input
and normal vs. high speed. See explanation below.</li>
<li value="3"><b><i>InputData</i></b> is a list of variables and modifiers that tells
<span class="keyword_in_text">OWIN</span> what to do with incoming data. <span class="keyword_in_text">OWIN</span> can store data in a
variable or array, interpret numeric text (decimal, binary, or hex) and store
the corresponding value in a variable, wait for a fixed or variable sequence
of bytes, or ignore a specified number of bytes. These actions can be combined
in any order in the <i>InputData</i> list.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="20%" align="center">&#160;</td>
<td width="80%" align="center">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Receive Rate</td>
<td>Approximately 20 kBits/sec (low speed, not including reset pulse)</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td>The DQ pin (specified by <i>Pin</i>) must have a 4.7 kΩ pull-up
resist0r.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="OWOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">OWOUT</a>
</p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The 1-Wire protocol is a form of asynchronous serial communication developed by
Maxim/Dallas Semiconductor. It only requires one I/O pin and that pin can
be shared between multiple 1-Wire devices. The <span class="keyword_in_text">OWIN</span> command
allows the BASIC Stamp to receive data from a 1-Wire device.</p>
<p>The following is an example of the <span class="keyword_in_text">OWIN</span> command:</p><pre class="BScode" xml:space="preserve">
result VAR Byte
Main:
OWIN 0, 1, [result]
STOP
</pre>
<p class="PlainText">This code will transmit a "reset" pulse to a 1-Wire device
(connected to I/O pin 0) and then will detect the device's "presence" pulse and
then receive one byte and store it in the variable result. </p>
<p class="PlainText">The <i>Mode</i> argument is used to control placement of reset pulses (and
detection of presence pulses) and to designate byte vs. bit input and normal vs.
high speed<sup></sup>. The tables below show the meaning of each of the
four bits of <i>Mode</i> and some of the 16 possible values and their effect. </p>
<h3><i>Mode</i> Format bits</h3>
<table width="35%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="50" align="center">Bit</td>
<td width="200" align="center">Function</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">0</td>
<td>Front-End Reset<br></br>• 0 = No reset <br></br>• 1 = Generate reset before data</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">1</td>
<td>Back-End Reset<br></br>• 0 = No reset <br></br>• 1 = Generate reset after data</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">2</td>
<td>Bit / Byte Transfer<br></br>• 0 = Byte <br></br>• 1 = Bit</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">3</td>
<td>Low / High Speed<sup></sup><br></br>• 0 = Low <br></br>• 1 = High</td>
</tr>
</table>
<p>&#160;</p>
<table width="35%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center">
<td width="50">Mode</td>
<td>Effect</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">0</td>
<td>No Reset, Byte mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">1</td>
<td>Reset before data, Byte mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">2</td>
<td>Reset after data, Byte mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">3</td>
<td>Reset before and after data, Byte mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">4</td>
<td>No Reset, Bit mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">5</td>
<td>Reset before data, Bit mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">6</td>
<td>Reset after data, Bit mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">7</td>
<td>Reset before and after data, Bit mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">8</td>
<td>No Reset, Byte mode, High speed<sup></sup></td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">9</td>
<td>Reset before data, Byte mode, High speed<sup></sup></td>
</tr>
</table>
<p><sup></sup> The BS2pe is not capable of High-Speed transfers.</p>
<p>&#160;</p>
<p class="PlainText">The proper value for <i>Mode</i> depends on the 1-Wire device
and the portion of the communication you're working on. Please consult the data
sheet for the device in question to determine the correct value for Mode. In many
cases, however, when using the <span class="keyword_in_text">OWIN</span> command, <i>Mode</i> should be set for
either No Reset (to receive data from a transaction already started by a <span class="keyword_in_text">OWOUT</span>command) or a Back-End Reset (to terminate the session after data is received).
This may vary due to device and application requirements, however.</p>
<p>When using the Bit (rather than Byte) mode of data transfer, all variables in
the <i>InputData</i> argument will only receive one bit. For example, the following
code could be used to receive two bits using this mode:</p><pre class="BScode" xml:space="preserve">
bitOne VAR Bit
bitTwo VAR Bit
Main:
OWIN 0, 6, [bitOne, bitTwo]
STOP
</pre>
<p class="PlainText">In the code above, we chose the value "6" for <i>Mode</i>. This sets Bit transfer
and Back-End Reset modes. Also, we could have chosen to make the bitOne and bitTwo
variables each a byte in size, but they still would only have received one bit each
in the <span class="keyword_in_text">OWIN</span> command (due to the <i>Mode</i> selected).</p>
<p class="PlainText">The <span class="keyword_in_text">OWIN</span> command's <i>InputData</i> argument is similar to the <b>SERIN</b>command's <i>InputData</i> argument. This means data can be received as ASCII
character values, decimal, hexadecimal and binary translations and string data as
in the examples below. (Assume a 1-Wire device is used and that
it transmits the string, "Value: 3A:101" every time it receives a Front-End Reset
pulse).</p><pre class="BScode" xml:space="preserve">
value VAR Byte(13)
Main:
OWIN 0, 1, [value] ' receive ASCII code for "V"
OWIN 0, 1, [DEC value] ' receive the number 3
OWIN 0, 1, [HEX value] ' receive the number $3A
OWIN 0, 1, [BIN value] ' receive the number %101
OWIN 0, 1, [STR value\13] ' receive the string "Value: 3A:101"
STOP
</pre>
<p class="PlainText">The tables below list all the available special formatters and conversion
formatters available to the <span class="keyword_in_text">OWIN</span> command. See the <a href="SERIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SERIN</a> command for additional information and examples of their use.</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="150">Special Formatter</td>
<td>Action</td>
</tr>
<tr>
<td align="center">STR ByteArray \L {\E}</td>
<td>Input a character string of length L into an array. If specified, an end
character E causes the string input to end before reaching length L.
Remaining bytes are filled with 0s (zeros).</td>
</tr>
<tr>
<td align="center">WAITSTR ByteArray {\L}</td>
<td>Wait for a sequence of bytes matching a string stored in an array variable,
optionally limited to L characters. If the optional L argument is left off,
the end of the array-string must be marked by a byte containing a zero (0).</td>
</tr>
<tr>
<td align="center">SKIP Length</td>
<td>Ignore Length bytes of characters.</td>
</tr>
<tr>
<td align="center">SPSTR Length</td>
<td>Buffer Length bytes (up to 126) of serial characters to Scratchpad RAM,
starting at location 0. Use <a href="GET.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GET</a> to retrieve the
characters.</td>
</tr>
</table>
<p>&#160;</p>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0" />
</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="15%">Conversion Formatter</td>
<td width="45%">Type of Number</td>
<td width="30%">Numeric Characters Accepted</td>
<td width="10%">Notes</td>
</tr>
<tr align="center">
<td>DEC{1..5}</td>
<td>Decimal, optionally limited to 1 - 5 digits</td>
<td>0 through 9</td>
<td>1</td>
</tr>
<tr align="center">
<td>SDEC{1..5}</td>
<td>Signed decimal, optionally limited to 1 - 5 digits</td>
<td>-, 0 through 9</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>HEX{1..4}</td>
<td>Hexadecimal, optionally limited to 1 - 4 digits</td>
<td>0 through 9, A through F</td>
<td>1,3</td>
</tr>
<tr align="center">
<td>SHEX{1..4}</td>
<td>Signed hexadecimal, optionally limited to 1 - 4 digits </td>
<td>-, 0 through 9, A through F</td>
<td>1,2,3</td>
</tr>
<tr align="center">
<td>IHEX{1..4}</td>
<td>Indicated hexadecimal, optionally limited to 1 - 4 digits</td>
<td>$, 0 through 9, A through F</td>
<td>1,3,4</td>
</tr>
<tr align="center">
<td>ISHEX{1..4}</td>
<td>Signed, indicated hexadecimal, optionally limited to 1 - 4 digits</td>
<td>-, $, 0 through 9, A through F</td>
<td>1,2,3,4</td>
</tr>
<tr align="center">
<td>BIN{1..16}</td>
<td>Binary, optionally limited to 1 - 16 digits</td>
<td>0, 1</td>
<td>1</td>
</tr>
<tr align="center">
<td>SBIN{1..16}</td>
<td>Signed binary, optionally limited to 1 - 16 digits</td>
<td>-, 0, 1</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>IBIN{1..16}</td>
<td>Indicated binary, optionally limited to 1 - 16 digits</td>
<td>%, 0, 1</td>
<td>1,4</td>
</tr>
<tr align="center">
<td>ISBIN{1..16}</td>
<td>Signed, indicated binary, optionally limited to 1 - 16 digits</td>
<td>-, %, 0, 1</td>
<td>1,2,4</td>
</tr>
<tr align="center">
<td>NUM</td>
<td>Generic numeric input; hex or binary number must be indicated</td>
<td>$, %, 0 through 9, A through F</td>
<td>1,3,4</td>
</tr>
<tr align="center">
<td>SNUM</td>
<td>Similar to NUM with value treated as signed with range -32768 to +32767</td>
<td>-, $, %, 0 through 9, A through F</td>
<td>1,2,3,4</td>
</tr>
</table>
<ol>
<li value="1">All numeric conversions will continue to accept new data until receiving
either the specified number of digits (ex: three digits for DEC3) or a
non-numeric character.</li>
<li value="2">To be recognized as part of a number, the minus sign (-) must immediately
precede a numeric character. The minus sign character occurring in non-numeric
text is ignored and any character (including a space) between a minus and a
number causes the minus to be ignored.</li>
<li value="3">The hexadecimal formatters are not case-sensitive; "a" through "f" means
the same as "A" through "F".</li>
<li value="4">Indicated hexadecimal and binary formatters ignore all characters, even
valid numerics, until they receive the appropriate prefix ($ for hexadecimal,
% for binary). The indicated formatters can differentiate between text and
hexadecimal (ex: ABC would be interpreted by HEX as a number but IHEX would
ignore it unless expressed as $ABC). Likewise, the binary version can
distinguish the decimal number 10 from the binary number %10. A prefix
occurring in non-numeric text is ignored, and any character (including a space)
between a prefix and a number causes the prefix to be ignored. Indicated, signed
formatters require that the minus sign come before the prefix, as in -$1B45.</li>
</ol>
<h3>The 1-Wire Protocol Format</h3>
<p class="PlainText">The 1-Wire protocol has a well-defined standard for transaction
sequences. Every transaction sequence consists of four parts: 1) Initialization, 2)
ROM Function Command, 3) Memory Function Command, and 4) Transaction/Data.
Additionally, the ROM Function Command and Memory Function Command are always 8
bits wide (1 byte in size) and is sent least-significant-bit (LSB) first.</p>
<p>The Initialization part consists of a reset pulse (generated by the master)
and will be followed by a presence pulse (generated by all slave devices). The
figure below details the reset pulse generated by the BASIC Stamp and a typical
presence pulse generated by a 1-Wire slave, in response.</p>
<center>
<img src="../../graphics/ow_pulses.gif" border="0">
</img>
</center>
<p>&#160;</p>
<p class="PlainText">This reset pulse is controlled by the lowest two bits of the <i>Mode</i> argument
in the <span class="keyword_in_text">OWIN</span> command. It can be made to appear before the ROM Function
Command (ex: Mode = 1), after the Transaction/Data portion (ex: Mode = 2), before
and after the entire transaction (ex: Mode = 3) or not at all (ex: Mode = 0).
See the section on <i>Mode</i>, above, for more information.</p>
<p class="PlainText">Following the Initialization part is the ROM Function Command. The ROM Function
Command is used to address the desired 1-Wire device. The table
below shows common ROM Function Commands. If only a single 1-Wire
device is connected, the Skip ROM command can be used to address it. If more than
one 1-Wire device is attached, the BASIC Stamp will ultimately have
to address them individually using the Match ROM command.</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="100">Command</td>
<td width="100">Value (HEX)</td>
<td>Action</td>
</tr>
<tr>
<td align="center">Read ROM</td>
<td align="center">$33</td>
<td>Reads the 64-bit ID of the 1-Wire device. This command
can only be used if there is a single 1-Wire device on the
line.</td>
</tr>
<tr>
<td align="center">Match ROM</td>
<td align="center">$55</td>
<td>This command, followed by a 64-bit ID, allows the BASIC Stamp to address
a specific 1-Wire device.</td>
</tr>
<tr>
<td align="center">Skip ROM</td>
<td align="center">$CC</td>
<td>Address a 1-Wire device without its 64-bit ID. This
command can only be used if there is a single 1-Wire device
on the line.</td>
</tr>
<tr>
<td align="center">Search ROM</td>
<td align="center">$F0</td>
<td>Reads the 64-bit IDs of all the 1-Wire devices on the
line. A process of elimination is used to distinguish each unique device.</td>
</tr>
</table>
<p>&#160;</p>
<p class="PlainText">The third part, the Memory Function Command, allows the BASIC Stamp to address
specific memory locations, or features, of the 1-Wire device.
Refer to the 1-Wire device's data sheet for a list of the available
Memory Function Commands.</p>
<p class="PlainText">Finally, the Transaction/Data section is used to read or write data to the
1-Wire device. The <span class="keyword_in_text">OWIN</span> command will read data at this
point in the transaction. A read is accomplished by generating a brief low-pulse
and sampling the line within 15 ms of the falling edge of the pulse. This is called
a "Read Slot." The figure below shows typical Read Slots performed by the BASIC
Stamp. See the <a href="OWOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">OWOUT</a> command for information on Write Slots.</p>
<center>
<img src="../../graphics/ow_readslots.gif" border="0" />
</center>
<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>

View File

@ -0,0 +1,401 @@
<?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>OWOUT</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">OWOUT</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/OwinOwoutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">OWIN / OWOUT Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">OWOUT</span> <![CDATA[ ]]><i>Pin</i>,<i> Mode</i>, [<i>OutputData</i>]</p>
<h2>Function</h2>
<p class="PlainText">Send data to a device using the Maxim/Dallas Semiconductor 1-Wire<sup>®</sup>protocol.</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression (0 - 15) that specifies
which I/O pin to use. 1-Wire devices require only one I/O
pin (called DQ) to communicate. This I/O pin will be toggled between output
and input mode during the <span class="keyword_in_text">OWOUT</span> command and will be set to input mode
by the end of the <span class="keyword_in_text">OWOUT</span> command.</li>
<li value="2"><b><i>Mode</i></b> is a variable/constant/expression (0 - 15) indicating
the mode of data transfer. The <i>Mode</i> argument controls placement of
reset pulses (and detection of presence pulses) as well as byte vs. bit input
and normal vs. high<sup></sup> speed. See explanation below.</li>
<li value="3"><b><i>OutputData</i></b> is a list of variables and modifiers that tells
<span class="keyword_in_text">OWOUT</span> how to format outgoing data. <span class="keyword_in_text">OWOUT</span> can transmit individual
or repeating bytes, convert values into decimal, hexadecimal or binary text
representations, or transmit strings of bytes from variable arrays. These
actions can be combined in any order in the <i>OutputData</i> list.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="20%" align="center">&#160;</td>
<td width="80%" align="center">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Transmission Rate</td>
<td>Approximately 20 kbits/sec (low speed, not including reset pulse)</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td>The DQ pin (specified by <i>Pin</i>) must have a 4.7 kΩ pull-up
resister.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="OWIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">OWIN</a>
</p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The 1-Wire protocol is a form of asynchronous serial communication developed by
Maxim/Dallas Semiconductor. It only requires one I/O pin and that pin can
be shared between multiple 1-Wire devices. The <span class="keyword_in_text">OWOUT</span>
command allows the BASIC Stamp to send data to a 1-Wire device.</p>
<p class="PlainText">The following is an example of the <span class="keyword_in_text">OWOUT</span> command:</p><pre class="BScode" xml:space="preserve">
OWOUT 0, 1, [$4E]
</pre>
<p class="PlainText">This code will transmit a "reset" pulse to a 1-Wire device
(connected to I/O pin 0) and then will detect the device's "presence" pulse and
then transmit one byte (the value $4E).</p>
<p class="PlainText">The <i>Mode</i> argument is used to control placement of reset pulses (and
detection of presence pulses) and to designate byte vs. bit input and normal vs.
high speed<sup></sup>. The tables below show the meaning of each of the
four bits of <i>Mode</i> and some of the 16 possible values and their effect. </p>
<table align="center" width="35%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="50" style="text-align: center;">Bit</td>
<td width="200" style="text-align: center;">Function</td>
</tr>
<tr>
<td bgcolor="#CFCFCF" style="text-align: center;">0</td>
<td style="text-align: left;">Front-End Reset<br></br>• 0 = No reset <br></br>• 1 = Generate reset
before data</td>
</tr>
<tr>
<td bgcolor="#CFCFCF" style="text-align: center;">1</td>
<td style="text-align: left;">Back-End Reset<br></br>• 0 = No reset <br></br>• 1 = Generate reset
after data</td>
</tr>
<tr>
<td bgcolor="#CFCFCF" style="text-align: center;">2</td>
<td style="text-align: left;">Bit / Byte Transfer<br></br>• 0 = Byte <br></br>• 1 = Bit</td>
</tr>
<tr>
<td bgcolor="#CFCFCF" style="text-align: center;">3</td>
<td style="text-align: left;">Low / High Speed<sup></sup><br></br>• 0 = Low <br></br>• 1 = High</td>
</tr>
</table>
<p>&#160;</p>
<table width="35%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center">
<td width="50">Mode</td>
<td>Effect</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">0</td>
<td>No Reset, Byte mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">1</td>
<td>Reset before data, Byte mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">2</td>
<td>Reset after data, Byte mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">3</td>
<td>Reset before and after data, Byte mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">4</td>
<td>No Reset, Bit mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">5</td>
<td>Reset before data, Bit mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">6</td>
<td>Reset after data, Bit mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">7</td>
<td>Reset before and after data, Bit mode, Low speed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">8</td>
<td>No Reset, Byte mode, High speed<sup></sup></td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">9</td>
<td>Reset before data, Byte mode, High speed<sup></sup></td>
</tr>
</table>
<p><sup></sup> The BS2pe is not capable of High Speed transfers.</p>
<p>&#160;</p>
<p class="PlainText">The proper value for <i>Mode</i> depends on the 1-Wire device
and the portion of the communication you're working on. Please consult the data
sheet for the device in question to determine the correct value for <i>Mode</i>.
In many cases, however, when using the <span class="keyword_in_text">OWOUT</span> command, <i>Mode</i> should
be set for a Front-End Reset (to initialize the transaction). This may vary due
to device and application requirements, however.</p>
<p class="PlainText">When using the Bit (rather than Byte) mode of data transfer, all variables in
the <i>OutputData</i> argument will only transmit one bit. For example, the
following code could be used to send two bits using this mode:</p><pre class="BScode" xml:space="preserve">
bitOne VAR Bit
bitTwo VAR Bit
Init:
bitOne = 0
bitTwo = 1
Main:
OWOUT 0, 5, [bitOne, bitTwo]
STOP
</pre>
<p class="PlainText">In the code above, we chose the value "5" for <i>Mode</i>. This sets Bit transfer
and Front-End Reset modes. Also, we could have chosen to make the bitOne and
bitTwo variables each a byte in size, but the BASIC Stamp would still only use the
their lowest bit (Bit0) as the value to transmit in the <span class="keyword_in_text">OWOUT</span> command (due
to the <i>Mode</i> we chose).</p>
<p class="PlainText">The <span class="keyword_in_text">OWOUT</span> command's <i>OutputData</i> argument is similar to the <b>DEBUG</b>
and <b>SEROUT</b> command's <i>OutputData</i> argument. This means data can be
sent as literal text, ASCII character values, repetitive values, decimal, hexadecimal
and binary translations and string data as in the examples below.</p><pre class="BScode" xml:space="preserve">
value VAR Byte
Init:
value = 65
Main:
OWOUT 0, 1, [value] ' send ASCII character "A"
OWOUT 0, 1, [REP value\5] ' send "A" 5x, ie: "AAAAA"
OWOUT 0, 1, [DEC value] ' send "6" and "5"
OWOUT 0, 1, [HEX value] ' send "4" and "1"
OWOUT 0, 1, [BIN value] ' send "1000001"
STOP
</pre>
<p class="PlainText">The tables below list all the available special formatters and conversion
formatters available to the <span class="keyword_in_text">OWOUT</span> command. See the <a href="DEBUG.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DEBUG</a>
&#160; and <a href="SEROUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SEROUT</a> commands
for additional information and examples of their use.</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="20%">Special Formatter</td>
<td width="80%">Action</td>
</tr>
<tr>
<td align="center">?</td>
<td>Displays "symbol = x' + carriage return; where x is a number. Default
format is decimal, but may be combined with conversion formatters (ex: BIN
? x to display "x = binary_number").</td>
</tr>
<tr>
<td align="center">ASC ?</td>
<td>Displays "symbol = 'x'" + carriage return; where x is an ASCII
character.</td>
</tr>
<tr>
<td align="center">STR ByteArray {\L}</td>
<td>Send character string from an array. The optional \L argument can be
used to limit the output to L characters, otherwise, characters will be
sent up to the first byte equal to 0 r the end of RAM space is reached.</td>
</tr>
<tr>
<td align="center">REP Byte\L</td>
<td>Send a string consisting of Byte repeated L times (ex: REP "X"\10 sends
"XXXXXXXXXX").</td>
</tr>
</table>
<p>&#160;</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="20%">Conversion Formatter</td>
<td width="70%">Type of Number</td>
<td width="10%">Notes</td>
</tr>
<tr align="center">
<td>DEC{1..5}</td>
<td align="left">Decimal, optionally fixed to 1 - 5 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>SDEC{1..5}</td>
<td align="left">Signed decimal, optionally fixed to 1 - 5 digits</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>HEX{1..4}</td>
<td align="left">Hexadecimal, optionally fixed to 1 - 4 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>SHEX{1..4}</td>
<td align="left">Signed hexadecimal, optionally fixed to 1 - 4 digits </td>
<td>1,2</td>
</tr>
<tr align="center">
<td>IHEX{1..4}</td>
<td align="left">Indicated hexadecimal, optionally fixed to 1 - 4 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>ISHEX{1..4}</td>
<td align="left">Signed, indicated hexadecimal, optionally fixed to 1 - 4
digits ($ prefix)</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>BIN{1..16}</td>
<td align="left">Binary, optionally fixed to 1 - 16 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>SBIN{1..16}</td>
<td align="left">Signed binary, optionally fixed to 1 - 16 digits</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>IBIN{1..16}</td>
<td align="left">Indicated binary, optionally fixed to 1 - 16 digits</td>
<td>1</td>
</tr>
<tr align="center">
<td>ISBIN{1..16}</td>
<td align="left">Signed, indicated binary, optionally fixed to 1 - 16 digits</td>
<td>1,2</td>
</tr>
</table>
<ol>
<li value="1">Fixed-digit formatters like DEC4 will pad the number with leading 0s if
necessary; ex: DEC4 65 sends 0065. If a number is larger than the specified
number of digits, the leading digits will be dropped; ex: DEC4 56422 sends
6422.</li>
<li value="2">Signed modifiers work under two's complement rules.</li>
</ol>
<h3>The 1-Wire Protocol Format</h3>
<p class="PlainText">The 1-Wire protocol has a well-defined standard for transaction
sequences. Every transaction sequence consists of four parts: 1) Initialization,
2) ROM Function Command, 3) Memory Function Command, and 4) Transaction/Data.
Additionally, the ROM Function Command and Memory Function Command are always 8
bits wide (1 byte in size) and is sent least-significant-bit (LSB) first.
</p>
<p class="PlainText">The Initialization part consists of a reset pulse (generated by the master)
and will be followed by a presence pulse (generated by all slave devices). The
figure below details the reset pulse generated by the BASIC Stamp and a typical
presence pulse generated by a 1-Wire slave, in response.</p>
<center>
<img src="../../graphics/ow_pulses.gif" width="389" height="223" border="0">
</img>
</center>
<p>&#160;</p>
<p class="PlainText">This reset pulse is controlled by the lowest two bits of the <i>Mode</i>
argument in the <span class="keyword_in_text">OWIN</span> command. It can be made to appear before the ROM
Function Command (ex: Mode = 1), after the Transaction/Data portion (ex: Mode
= 2), before and after the entire transaction (ex: Mode = 3) or not at all (ex:
Mode = 0). See the section on <i>Mode</i>, above, for more information.</p>
<p class="PlainText">Following the Initialization part is the ROM Function Command. The ROM Function
Command is used to address the desired 1-Wire device. The table
below shows common ROM Function Commands. If only a single 1-Wire
device is connected, the Match ROM command can be used to address it. If more than
one 1-Wire device is attached, the BASIC Stamp will ultimately
have to address them individually using the Match ROM command.</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="100">Command</td>
<td width="100">Value (HEX)</td>
<td>Action</td>
</tr>
<tr>
<td align="center">Read ROM</td>
<td align="center">$33</td>
<td>Reads the 64-bit ID of the 1-Wire device. This command
can only be used if there is a single 1-Wire device on the
line.</td>
</tr>
<tr>
<td align="center">Match ROM</td>
<td align="center">$55</td>
<td>This command, followed by a 64-bit ID, allows the BASIC Stamp to address
a specific 1-Wire device.</td>
</tr>
<tr>
<td align="center">Skip ROM</td>
<td align="center">$CC</td>
<td>Address a 1-Wire device without its 64-bit ID. This
command can only be used if there is a single 1-Wire device
on the line.</td>
</tr>
<tr>
<td align="center">Search ROM</td>
<td align="center">$F0</td>
<td>Reads the 64-bit IDs of all the 1-Wire devices on the
line. A process of elimination is used to distinguish each unique device.</td>
</tr>
</table>
<p>&#160;</p>
<p class="PlainText">The third part, the Memory Function Command, allows the BASIC Stamp to address
specific memory locations, or features, of the 1-Wire device.
Refer to the 1-Wire device's data sheet for a list of the available
Memory Function Commands.</p>
<p class="PlainText">Finally, the Transaction/Data section is used to read or write data to the
1-Wire device. The <span class="keyword_in_text">OWOUT</span> command will write data at this
point in the transaction. A write is accomplished by generating a low-pulse of
a varying width to indicate a 0 or a 1. This is called a "Write Slot" and must be
at least 60 us wide. The figure below shows typical Write Slots performed by the
BASIC Stamp. See the <a href="OWIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">OWIN</a> command for information on Read
Slots.</p>
<center>
<img src="../../graphics/ow_writeslots.gif" border="0" />
</center>
<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>

View File

@ -0,0 +1,87 @@
<?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>PAUSE</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">PAUSE</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" /><span class="code_in_text"> {PBASIC&#160;2.5}</span>
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/PauseEx.htm" target="" title="" alt="" class="MCXref_0">PAUSE Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">PAUSE</span> <![CDATA[ ]]><i>Duration</i></p>
<h2>Function</h2>
<p class="PlainText">Pause the program (do nothing) for the specified <i>Duration</i>.
</p>
<ul>
<li value="1"><b><i>Duration</i></b> is a variable/constant/expression* (0 - 65535) that
specifies the duration of the pause. The unit of time for <i>Duration</i> is
one millisecond. </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>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">PAUSE</span> delays the execution of the next program instruction for the specified
number of milliseconds. For example: </p><pre class="BScode" xml:space="preserve">
Flash:
&#160; LOW 0
&#160;PAUSE 100
&#160; HIGH 0
&#160;PAUSE 100
&#160;GOTO Flash
</pre>
<p class="PlainText">This code causes pin 0 to go low for 100 ms, then high for 100 ms. The delays
produced by <span class="keyword_in_text">PAUSE</span> are as accurate as the ceramic-resonator time base (on
the BASIC Stamp modules), ±1 percent. When you use <span class="keyword_in_text">PAUSE</span> in timing-critical
applications, keep in mind the relatively low speed of the PBASIC interpreter.
This is the time required for the BASIC Stamp to read and interpret an instruction
stored in the EEPROM. </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>

View File

@ -0,0 +1,245 @@
<?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>POLLIN</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">POLLIN</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/PollinOutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLIN / POLLOUT / POLLMODE Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">POLLIN</span> <![CDATA[ ]]><i>Pin, State</i></p>
<h2>Function</h2>
<p class="PlainText">Specify a polled-input pin and active state.
</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 I/O 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 to poll the I/O pin for a low (0) or a high (1) level.</li>
</ul>
<h2>Quick Facts</h2>
<table cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="150" align="center">&#160;</td>
<td width="1000" align="center">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Available actions in response to reaching
the desired <i>State</i></td>
<td align="left">
<ol>
<li value="1">Nothing,</li>
<li value="2">Set polled-output pins to a specified state,</li>
<li value="3">Run another program (in a specified program-slot),</li>
<li value="4">Wait (pause program execution) until desired State is reached,</li>
<li value="5">Any combination of 2, 3 and 4, above.</li>
</ol>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td align="left">
<ul>
<li value="1">The polled-input pins are monitored (polled) in-between each command
within the PBASIC code.</li>
<li value="2">On the BS2p40 polled-input pins can be defined on both main and
auxiliary I/O pins. These are all active regardless of which group
the program happens to be using at the time of a polling event.</li>
<li value="3">Polled input pins are stored in special Scratchpad RAM locations. Use
<a href="GET.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GET</a> to retrieve.<br /><ul type="square"><li value="1">Location 128 : MAINIO Pins 0 - 7</li><li value="2">Location 129 : MAINIO Pins 8 - 15</li><li value="3">Location 130 : AUXIO Pins 0 - 7</li><li value="4">Location 131 : AUXIO Pins 8 - 15</li></ul></li>
</ul>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="POLLMODE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLMODE</a>, <a href="POLLOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLOUT</a>, <a href="POLLRUN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLRUN</a>, <a href="POLLWAIT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLWAIT</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">POLLIN</span> command is one of a family of unique "polling" commands on the
BS2p, BS2pe, and BS2px modules. The other commands in this family include <span class="keyword_in_text">POLLMODE</span>,
<span class="keyword_in_text">POLLOUT</span>, <span class="keyword_in_text">POLLRUN</span> and <span class="keyword_in_text">POLLWAIT</span>. The <span class="keyword_in_text">POLLIN</span> command
is used to specify an input pin to monitor, or "poll", in-between instructions
during the rest of the PBASIC program. The BASIC Stamp will then perform some
activity (in between instructions) when the specified State is detected. The
activity performed depends on the <span class="keyword_in_text">POLLMODE</span>, <span class="keyword_in_text">POLLOUT</span> and <span class="keyword_in_text">POLLRUN</span>commands.</p>
<p class="PlainText">The "polling" commands allow the BASIC Stamp to respond to certain I/O pin
events at a faster rate than what is normally possible through manual PBASIC
programming. The term "poll" comes from the fact that the BASIC Stamp's interpreter
periodically checks the state of the designated polled-input pins. It "polls"
these pins after the end of each PBASIC instruction and before it reads the next
PBASIC instruction from the user program; giving the appearance that it is polling
"in the background". </p>
<p class="PlainText">This feature should not be confused with the concept of interrupts, as
<i><b>the BASIC Stamp does not support true interrupts.</b></i></p>
<p class="PlainText">The following is an example of the <span class="keyword_in_text">POLLIN</span> command:</p><pre class="BScode" xml:space="preserve">
POLLIN 0, 0
POLLMODE 2
</pre>
<p class="PlainText">The <span class="keyword_in_text">POLLIN</span> command in the above code will cause the BASIC Stamp to set
I/O pin 0 to an input mode and get ready to poll it for a low (0) state. The
BASIC Stamp will not actually start polling until it is set to the appropriate
mode, however. The second line, <span class="keyword_in_text">POLLMODE</span>, initiates the polling process
(see the <a href="POLLMODE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLMODE</a> description for more information).
From then on, as the BASIC Stamp executes the rest of the program, it will check
for a low level (logic 0) on I/O pin 0, in-between instructions. </p>
<p class="PlainText">In the code above, no obvious action will be noticed since we didn't tell the
BASIC Stamp what to do when it detects a change on the I/O pin. One possible
action the BASIC Stamp can be instructed to take is to change the state of an
output, called a polled-output. Take a look at the next example:</p><pre class="BScode" xml:space="preserve">
Setup:
POLLIN 0, 0
POLLOUT 1, 1
POLLMODE 2
Main
DEBUG "Looping...", CR
GOTO Main
</pre>
<p class="PlainText">In this example, in addition to an endless loop, we've added another polling
command called <span class="keyword_in_text">POLLOUT</span> (see the <a href="POLLOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLOUT</a> description
for more information). Our <span class="keyword_in_text">POLLOUT</span> command tells the BASIC Stamp to set
I/O pin 1 to an output mode and set it high (1) when it detects the desired poll
state. The poll state is the low (0) level on I/O pin 0 that <span class="keyword_in_text">POLLIN</span> told
it to look for. If the polled-input pin is high, it will set polled-output
pin 1 to low (0), instead.</p>
<p class="PlainText">Once the program reaches the endless loop, starting at Main, it will continuously
print "Looping..." on the PC screen. In between reading the <span class="keyword_in_text">DEBUG</span> command
and the <span class="keyword_in_text">GOTO</span> command (and vice versa) it will check polled-input pin 0 and
set polled-output pin 1 accordingly. In this case, when I/O pin 0 is set low,
the BASIC Stamp will set I/O pin 1 high. When I/O pin 0 is set high, the BASIC
Stamp will set I/O pin 1 low. It will continue to perform this operation,
in-between each command in the loop, endlessly.</p>
<p>It's important to note that, in this example, only the <span class="keyword_in_text">DEBUG</span> and <span class="keyword_in_text">GOTO</span>commands are being executed over and over again. The first three lines of code
are only run once, yet their effects are "remembered" by the BASIC Stamp throughout
the rest of the program.</p>
<p>If the polling commands were not used, the program would have to look like the
one below in order to achieve the same effect.</p><pre class="BScode" xml:space="preserve">
Setup:
INPUT 0
OUTPUT 1
Main:
OUT1 = ~IN0
DEBUG "Looping...", CR
OUT1 = ~IN0
GOTO Main
</pre>
<p class="PlainText">In this example, we create the inverse relationship of input pin 0 and output
pin 1 manually, in-between the <span class="keyword_in_text">DEBUG</span> and <span class="keyword_in_text">GOTO</span> lines. Though the
effects are the same as when using the polling commands, this program actually
takes a little longer to run and consumes 7 additional bytes of program (EEPROM)
space. Clearly, using the polling commands is more efficient.</p>
<p class="PlainText">You can have as many polled-input and polled-output pins as you have available.
If multiple polled-input pins are defined, any one of them can trigger changes on
the polled-output pins that are also defined. For example:</p><pre class="BScode" xml:space="preserve">
Setup:
POLLIN 0, 1
POLLIN 1, 1
POLLOUT 2, 1
POLLMODE 2
Main:
DEBUG "Looping...", CR
GOTO Main
</pre>
<p class="PlainText">This code sets I/O pins 0 and 1 to polled-input pins (looking for a high (1)
state) and sets I/O pin 2 to be a polled-output pin (with a high-active state).
If either I/O pin 0 or 1 goes high, the BASIC Stamp will set I/O pin 2 high.
This works similar to a logical OR operation. The truth table below shows all the
possible states of these two polled-input pins and the corresponding states the
BASIC Stamp will set the polled-output pin to.</p>
<center>
<table width="200" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td colspan="2" align="center">Polled-Inputs</td>
<td colspan="1" align="center">Polled-Output</td>
</tr>
<tr bgcolor="#CFCFCF">
<td width="50" align="center">0</td>
<td width="50" align="center">1</td>
<td width="100" align="center">2</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
</table>
</center>
<p>&#160;</p>
<p class="PlainText">Normally, any polled-output pins reflect the state changes continuously, as
described above. The <span class="keyword_in_text">POLLMODE</span> command supports another feature, however,
where the polled-output pins will latch the active state; they will change only
once (when the poll state is reached) and stay in the new state until the PBASIC
program tells it to change again. See the
<a href="POLLMODE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLMODE</a> description for more information.</p>
<p class="PlainText">Other possible actions in response to polled-input states are: 1) Running
another program (in a specified program slot), 2) Waiting (pausing program
execution with or without low-power mode) until the poll state is reached, or 3)
Any combination of the above-mentioned actions</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>

View File

@ -0,0 +1,270 @@
<?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>POLLMODE</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">POLLMODE</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/PollinOutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLIN / POLLOUT / POLLMODE Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">POLLMODE</span> <![CDATA[ ]]><i>Mode</i></p>
<h2>Function</h2>
<p class="PlainText">Specify a polled command mode.</p>
<ul>
<li value="1"><b><i>Mode</i></b> is a variable/constant/expression (0 - 15) that indicates
the mode in which to process the polled command configuration.</li>
</ul>
<h2>Quick Facts</h2>
<table cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="150" align="center">&#160;</td>
<td width="1000" align="center">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td align="left">
<ul>
<li value="1">Polled-output pins will either change states continuously, just once
or not at all, depending on the <span class="keyword_in_text">POLLMODE</span> command</li>
<li value="2">A poll mode of 2 or 4 is required for a <span class="keyword_in_text">POLLWAIT</span> command
to work</li>
<li value="3">If both polled-outputs and polled-run are active, the polled-output
event will occur before the polled-run event.</li>
</ul>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="POLLIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLIN</a>, <a href="POLLOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLOUT</a>, <a href="POLLRUN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLRUN</a>, <a href="POLLWAIT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLWAIT</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">POLLMODE</span> command is one of a family of unique "polling" commands on the
BS2p, BS2pe, and BS2px modules. The other commands in this family include <span class="keyword_in_text">POLLIN</span>,
<span class="keyword_in_text">POLLOUT</span>, <span class="keyword_in_text">POLLRUN</span> and <span class="keyword_in_text">POLLWAIT</span>. The <span class="keyword_in_text">POLLMODE</span> command
is used to specify the mode in which polling events and activities are processed.
This activity will occur in between instructions during the rest of the PBASIC
program.</p>
<p class="PlainText">The "polling" commands allow the BASIC Stamp to respond to certain I/O pin events
at a faster rate than what is normally possible through manual PBASIC programming.
The term "poll" comes from the fact that the BASIC Stamp's interpreter periodically
checks the state of the designated polled-input pins. It "polls" these pins after
the end of each PBASIC instruction and before it reads the next PBASIC instruction
from the user program; giving the appearance that it is polling "in the
background".</p>
<p class="PlainText">This feature should not be confused with the concept of interrupts, as <i><b>the
BASIC Stamp does not support true interrupts.</b></i></p>
<p class="PlainText">The <span class="keyword_in_text">POLLMODE</span> command sets one of 15 possible modes for the polling
commands. It is used mainly before and/or after any <span class="keyword_in_text">POLLIN</span>, <span class="keyword_in_text">POLLOUT</span>
and <span class="keyword_in_text">POLLRUN</span> commands to disable and enable the polling features as desired.
The table below shows the mode values and their effect.</p>
<table cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="150" align="center">Mode</td>
<td width="1000" align="center">Effect</td>
</tr>
<tr>
<td align="center">0</td>
<td align="left">Deactivate polling, clear polled-input and output configuration.</td>
</tr>
<tr>
<td align="center">1</td>
<td align="left">Deactivate polling, save polled-input and output configuration.</td>
</tr>
<tr>
<td align="center">2</td>
<td align="left">Activate polling with polled-output action (and polled-wait) only.</td>
</tr>
<tr>
<td align="center">3<sup>1</sup></td>
<td align="left">Activate polling with polled-run action only.</td>
</tr>
<tr>
<td align="center">4<sup>2</sup></td>
<td align="left">Activate polling with polled-output/polled-wait and polled-run actions.</td>
</tr>
<tr>
<td align="center">5<sup>3</sup></td>
<td align="left">Clear polled-input configuration.</td>
</tr>
<tr>
<td align="center">6<sup>3</sup></td>
<td align="left">Clear polled-output configuration.</td>
</tr>
<tr>
<td align="center">7<sup>3</sup></td>
<td align="left">Clear polled-input and output configuration.</td>
</tr>
<tr>
<td align="center">8 - 15</td>
<td align="left">Same at 0 - 7 except polled-output states are latched.</td>
</tr>
</table>
<p>&#160;</p>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="10"><sup>1</sup>
</td>
<td>After the polled-run action occurs, the mode switches to 1 (deactivated,
saved)</td>
</tr>
<tr>
<td width="10"><sup>2</sup>
</td>
<td>After the polled-run action occurs, the mode switches to 2 (activated,
outputs)</td>
</tr>
<tr>
<td width="10"><sup>3</sup>
</td>
<td>These modes do not override the previous mode. Also, the output state of
polled-outputs does not change as a result of these modes.</td>
</tr>
</table>
<p>&#160;</p>
<p class="PlainText">The polled-run modes, 3 and 4, are unique. As soon as the polled-run action
occurs, the mode switches to 1 (deactivated, saved) or 2 (activated, outputs),
respectively. This is so that the BASIC Stamp doesn't continuously go to the
start of the designated program slot while the polled-inputs are in the desired
poll state. Without this "one shot" feature, your program would appear to lock-up
as long as the polled-inputs are in the designated state.</p>
<p class="PlainText">The clear configuration modes, 5, 6 and 7, are also unique. These modes do not
override the previous mode. For example, if polled-inputs, polled-outputs and a
polled-run configuration was set and the mode was set to 4 (activated, outputs and
run) and later the program issued a <span class="keyword_in_text">POLLMODE</span> 6 command, the polled-output
configuration would be cleared but the mode would switch back to 4... still allowing
the run action. This also means if, later still, the program issues a <span class="keyword_in_text">POLLOUT</span>
command, this polled-output would take effect immediately (since the mode is still
4). Also note that these modes do not change the output state of previously defined
polled-output pins.</p>
<p class="PlainText">The <span class="keyword_in_text">POLLMODE</span> command determines what action, if any, will occur in
response to a polled-input event. This command works in conjunction with the
<span class="keyword_in_text">POLLIN</span>, <span class="keyword_in_text">POLLOUT</span> and <span class="keyword_in_text">POLLRUN</span> commands. The following is an
example of the <span class="keyword_in_text">POLLMODE</span> command:</p><pre class="BScode" xml:space="preserve">
Setup:
POLLIN 0, 0
POLLOUT 1, 1
POLLMODE 2
Main:
DEBUG "Looping...", CR
GOTO Main
</pre>
<p>In this example, the first two lines configure I/O pin 0 as a polled-input
(looking for a low state) and I/O pin 1 as a polled-output (going high if I/O pin
0 goes low, and vice versa). The third line, <span class="keyword_in_text">POLLMODE</span>, initiates the
polling process and configures polled-outputs to be active. From then on, as the
BASIC Stamp executes the rest of the program, it will check for a low level
(logic 0) on I/O pin 0 in between instructions and will set I/O pin 1 accordingly.</p>
<p class="PlainText">If, in the above example, the poll mode was set to 1 (which means deactivate
polling but save configuration) I/O pins 0 and 1 would still be defined the same
way, and I/O pin 1 would still be set to output mode, but no polling would take
place during the rest of the program.</p>
<p class="PlainText">Here's another example that demonstrates mode 1 (deactivate but save
configuration).</p><pre class="BScode" xml:space="preserve">
Setup:
POLLIN 0, 0
POLLOUT 1, 1
POLLMODE 2
DEBUG "Polling configured", CR
Main:
POLLMODE 1
DEBUG "No polling allowed here...", CR
PAUSE 1000
POLLMODE 2
Poll_Now:
DEBUG "Polling now...", CR
GOTO Poll_Now
</pre>
<p class="PlainText">In this case, polling is configured and activated before "Polling configured"
is printed on the screen. Once we reach the Main routine, however, polling is
disabled (via the <span class="keyword_in_text">POLLMODE</span> 1 command) and no polling occurs during the
printing of "No polling allowed here..." or during the 1 second pause afterward.
Finally, polling is activated again, and since the configuration was saved (because
of mode 1, before) the polling activity acts just like it did initially for the
remainder of the program. The ability to temporarily disable polling, without
changing the configuration, can be a powerful feature for certain "critical" parts
of a program.</p>
<p class="PlainText">The following example contains two programs. The first should be downloaded
into program slot 0 and the second into program slot 1. We'll assume they are
called POLL0.BSP and POLL1.BSP, respectively (as defined in the $STAMP directive
lines). </p><pre class="BScode" xml:space="preserve">
' ----- Program #1 (Slot 0) -----
' {$STAMP BS2p, POLL1.BSP}
Setup:
POLLIN 0, 0
POLLOUT 1, 1
POLLRUN 1
POLLMODE 4
Main:
DEBUG "Program 1", CR
GOTO Main
</pre><pre class="BScode" xml:space="preserve">
' ----- Program #2 (Slot 1) -----
' {$STAMP BS2p}
DEBUG "Switching...", CR
Again:
DEBUG "Program 2", CR
GOTO Again
</pre>
<p class="PlainText">In this example (containing two programs; one is slot 0 and the other in slot 1)
program 1 (slot 0) will configure polled-input pin 0 to detect a low state and
polled-output 1 to go high in response. Program 1 also configures a polled-run
activity (see the <span class="keyword_in_text">POLLRUN</span> description for more information) to run the
program in slot 1. The <span class="keyword_in_text">POLLMODE</span> setting activates the polled-output and
the polled-run. Then, program 1 continuously prints "Program 1" on the PC screen.</p>
<p class="PlainText">Once I/O pin 0 goes low, however, the BASIC Stamp will set I/O pin 1 high,
then execution will be switched to the program in slot 1 (program 2). Program 2
will first print "Switching..." on the PC screen and then will continuously print
"Program 2". From this point forward, I/O pin 1 will continue to be set low and
high in response to changes occurring on I/O pin 0, but the polled-run activity
is disabled and the BASIC Stamp endlessly runs the code in program 2's Again
routine.</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>

View File

@ -0,0 +1,264 @@
<?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>POLLOUT</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">POLLOUT</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/PollinOutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLIN / POLLOUT / POLLMODE Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">POLLOUT</span> <![CDATA[ ]]><i>Pin</i>,<i> State</i></p>
<h2>Function</h2>
<p class="PlainText">Specify a polled-output pin and active state.
</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 I/O pin will be set to output mode.</li>
<li value="2"><b><i>State</i></b> is a variable/constant/expression (0 - 1) that specifies
whether to set the I/O pin low (0) or high (1) when a polled-input pin changes
to its poll state.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="25%" align="center">&#160;</td>
<td width="75%" align="center">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td align="left">
<ul>
<li value="1">The <span class="keyword_in_text">POLLOUT</span> command will immediately change the I/O pin to an
output mode and set its level opposite to that of <i>State</i>,
regardless of the polled-input states or the polled mode.</li>
<li value="2">Polled-output pins will either change states continuously, just once
or not at all, depending on the <span class="keyword_in_text">POLLMODE</span> command.</li>
<li value="3">On the BS2p40 polled-output pins can be defined on both main and
and auxiliary I/O pins. These are all active regardless of which group
the program happens to be using at the time of a polling event.</li>
<li value="4">If both polled-outputs and polled-run are active, the polled-output event
will occur before the polled-run event.</li>
</ul>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="POLLIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLIN</a>, <a href="POLLMODE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLMODE</a>, <a href="POLLRUN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLRUN</a>, <a href="POLLWAIT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLWAIT</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">POLLOUT</span> command is one of a family of unique "polling" commands on the
BS2p, BS2pe, and BS2px modules. The other commands in this family include <span class="keyword_in_text">POLLIN</span>,
<span class="keyword_in_text">POLLMODE</span>, <span class="keyword_in_text">POLLRUN</span> and <span class="keyword_in_text">POLLWAIT</span>. The <span class="keyword_in_text">POLLOUT</span> command
is used to specify an output pin that changes states in response to changes on
any of the defined polled-input pins. This activity will occur in between
instructions during the rest of the PBASIC program.</p>
<p class="PlainText">The "polling" commands allow the BASIC Stamp to respond to certain I/O pin
events at a faster rate than what is normally possible through manual PBASIC
programming. The term "poll" comes from the fact that the BASIC Stamp's interpreter
periodically checks the state of the designated polled-input pins. It "polls"
these pins after the end of each PBASIC instruction and before it reads the next
PBASIC instruction from the user program; giving the appearance that it is polling
"in the background". </p>
<p class="PlainText">This feature should not be confused with the concept of interrupts, as
<i><b>the BASIC Stamp does not support true interrupts.</b></i></p>
<p>The <span class="keyword_in_text">POLLOUT</span> command achieves one of three possible actions in response
to a polled-input event. This command works in conjunction with the <span class="keyword_in_text">POLLIN</span>
and <span class="keyword_in_text">POLLMODE</span> commands. The following is an example of the <span class="keyword_in_text">POLLOUT</span>
command:</p><pre class="BScode" xml:space="preserve">
Setup:
POLLIN 0, 0
POLLOUT 1, 1
POLLMODE 2
Main:
DEBUG "Looping...", CR
GOTO Main
</pre>
<p class="PlainText">In this example, the <span class="keyword_in_text">POLLOUT</span> command tells the BASIC Stamp to set I/O
pin 1 to an output mode and set it high (1) when it detects the desired poll state.
The poll state is the low (0) level on I/O pin 0 that <span class="keyword_in_text">POLLIN</span> told it to
look for. If the polled-input pin is high, the BASIC Stamp will set
polled-output pin 1 to low (0), instead. The BASIC Stamp will not actually start
polling until it is set to the appropriate mode, however. The third line,
<span class="keyword_in_text">POLLMODE</span>, initiates the polling process (see the
<a href="POLLMODE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLMODE</a> description for more information). From then
on, as the BASIC Stamp executes the rest of the program, it will check for a low
level (logic 0) on I/O pin 0 in between instructions. </p>
<p class="PlainText">Once the program reaches the endless loop, at Main, it will continuously
print "Looping...." on the PC screen. In between reading the <span class="keyword_in_text">DEBUG</span> command
and the <span class="keyword_in_text">GOTO</span> command (and vice versa) it will check polled-input pin 0 and
set polled-output pin 1 accordingly. In this case, when I/O pin 0 is set low,
the BASIC Stamp will set I/O pin 1 high. When I/O pin 0 is set high, the BASIC
Stamp will set I/O pin 1 low. It will continue to perform this operation,
in between each command in the loop, endlessly.</p>
<p class="PlainText">It's important to note that in this example only the <span class="keyword_in_text">DEBUG</span> and
<span class="keyword_in_text">GOTO</span> commands are being executed over and over again. The first three
lines of code are only run once, yet their effects are "remembered" by the BASIC
Stamp throughout the rest of the program.</p>
<p class="PlainText">If the polling commands were not used, the program would have to look like
the one below in order to achieve the same effect.</p><pre class="BScode" xml:space="preserve">
Setup:
INPUT 0
OUTPUT 1
Main:
OUT1 = ~IN0
DEBUG "Looping...", CR
OUT1 = ~IN0
GOTO Main
</pre>
<p class="PlainText">In this example, we create the inverse relationship of input pin 0 and output
pin 1 manually, in-between the <span class="keyword_in_text">DEBUG</span> and <span class="keyword_in_text">GOTO</span> lines. Though the
effects are the same as when using the polling commands, this program actually
takes a little longer to run and consumes 7 additional bytes of program (EEPROM)
space. Clearly, using the polling commands is more efficient.</p>
<p class="PlainText">You can have as many polled-input and polled-output pins as you have available.
If multiple polled-input pins are defined, any one of them can trigger changes on
the polled-output pins that are also defined. For example:</p><pre class="BScode" xml:space="preserve">
Setup:
POLLIN 0, 1
POLLIN 1, 1
POLLOUT 2, 1
POLLMODE 2
Main:
DEBUG "Looping...", CR
GOTO Main
</pre>
<p class="PlainText">This code sets I/O pins 0 and 1 to polled-input pins (looking for a high (1)
state) and sets I/O pin 2 to be a polled-output pin (with a high-active state).
If either I/O pin 0 or 1 goes high, the BASIC Stamp will set I/O pin 2 high.
This works similar to a logical OR operation. The truth table below shows all the
possible states of these two polled-input pins and the corresponding states the
BASIC Stamp will set the polled-output pin to.</p>
<center>
<table width="200" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td colspan="2" align="center">Polled-Inputs</td>
<td colspan="1" align="center">Polled-Output</td>
</tr>
<tr bgcolor="#CFCFCF">
<td width="50" align="center">0</td>
<td width="50" align="center">1</td>
<td width="100" align="center">2</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
</table>
</center>
<p>&#160;</p>
<p class="PlainText">Normally, any polled-output pins reflect the state changes continuously, as
described above. The <span class="keyword_in_text">POLLMODE</span> command supports another feature, however,
where the polled-output pins will latch the active state; they will change only
once (when the poll state is reached) and stay in the new state until the PBASIC
program tells it to change again. See the <a href="POLLMODE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLMODE</a>
description for more information.</p>
<p class="PlainText">A clever use of the "latched" feature is to set a polled-output to be the same
as the polled-input. For example, suppose an application needed to respond in some
way if a polled-input pin goes high, but it doesn't need to respond immediately,
and the other tasks should not be interrupted. In essence, we need a way to know
if the pin has gone high since the last time we checked it. Look at this
example:</p><pre class="BScode" xml:space="preserve">
idx VAR Byte
Setup:
POLLOUT 0, 1 ' pin 0 is polled-output, high
POLLIN 0, 1 ' pin 0 back to polled-input, high
POLLMODE 10 ' Set mode to latch the polled-output
Work: ' kill time waiting for polled
FOR idx = 1 TO 20 ' event
DEBUG "Working....", CR
NEXT
IF (OUT0 = 0) THEN Work
Respond: ' Response message
DEBUG CR,
"You set my pin high!", CR
POLLMODE 10 ' Reset polled-output's latch function
GOTO Work
</pre>
<p class="PlainText">Here, we set I/O pin 0 to a polled-output, then immediately set it to a
polled-input. Then we set the polled-mode to latch the polled-outputs. Since
the <span class="keyword_in_text">POLLIN</span> command occurred after the <span class="keyword_in_text">POLLOUT</span>, I/O pin 0 will be
an input, but the polling feature will still affect the OUT0 bit (output latch
for I/O pin 0). Then, the program performs some work, and once in a while, checks
the state of OUT0. If OUT0 is 0, I/O pin 0 was never seen to go high. If,
however, OUT0 is 1, I/O pin 0 must have gone high while the program was doing
other work, and now it can respond in the proper manner. This even works if the
pin had gone high and then low again before we check it (as long as it was high
at some point in between the instructions in our Work routine.</p>
<p class="PlainText">It is important to note that during the time between the <span class="keyword_in_text">POLLOUT</span> and
<span class="keyword_in_text">POLLIN</span> commands, I/O pin 0 will be set to an output direction. This can
cause a temporary short with the circuitry connected to I/O pin 0, so it is
vital that a large enough series resister (perhaps 220 ohms or greater) be
inserted on that pin to protect the external device and the BASIC Stamp.</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>

View File

@ -0,0 +1,144 @@
<?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>POLLRUN</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">POLLRUN</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/PollrunEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLRUN Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">POLLRUN</span> <![CDATA[ ]]><i>ProgramSlot</i></p>
<h2>Function</h2>
<p class="PlainText">Specify a program to run upon a polled-input event.
</p>
<ul>
<li value="1"><b><i>ProgramSlot</i></b> is a variable/constant/expression (0 - 7) that
specifies the program slot to run when a polled-input event occurs.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="20%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="80%" align="center" bgcolor="#CFCFCF">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Default Slot</td>
<td align="left">The default polled-run slot is 0. If no <span class="keyword_in_text">POLLRUN</span>
command is given and a poll mode of 3 or 4 is set, the program in slot 0
will run in response to a polled-input event.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td align="left">
<ul>
<li value="1">If both polled-outputs and polled-run are active, the polled-output
event will occur before the polled-run event.
</li>
</ul>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="POLLIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLIN</a>, <a href="POLLMODE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLMODE</a>, <a href="POLLOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLOUT</a>, <a href="POLLWAIT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLWAIT</a>, <a href="RUN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">RUN</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">POLLRUN</span> command is one of a family of unique "polling" commands on the
BS2p, BS2pe, and BS2px modules. The other commands in this family include <span class="keyword_in_text">POLLIN</span>,
<span class="keyword_in_text">POLLMODE</span>, <span class="keyword_in_text">POLLOUT</span> and <span class="keyword_in_text">POLLWAIT</span>. The <span class="keyword_in_text">POLLRUN</span> command
is used to specify a program slot to run in response to a polled event. This
activity can occur in between any two instructions within the rest of the PBASIC
program.</p>
<p class="PlainText">The "polling" commands allow the BASIC Stamp to respond to certain I/O pin
events at a faster rate than what is normally possible through manual PBASIC
programming. The term "poll" comes from the fact that the BASIC Stamp's interpreter
periodically checks the state of the designated polled-input pins. It "polls"
these pins after the end of each PBASIC instruction and before it reads the next
PBASIC instruction from the user program; giving the appearance that it is polling
"in the background". This feature should not be confused with the concept of
interrupts, as the BASIC Stamp does not support true interrupts.</p>
<p class="PlainText">The following is a simple example of the <span class="keyword_in_text">POLLRUN</span> command:</p><pre class="BScode" xml:space="preserve">
Setup:
POLLIN 0, 0
POLLRUN 1
POLLMODE 3
Main:
DEBUG "Waiting in Program Slot 0...", CR
GOTO Main
</pre>
<p class="PlainText">The first line of the above code will set up I/O pin 0 as a polled-input pin
looking for a low (0) state. The second line, <span class="keyword_in_text">POLLRUN</span>, tells the BASIC
Stamp that when I/O pin 0 goes low, it should switch execution over to the
program residing in program slot 1. The third line, <span class="keyword_in_text">POLLMODE</span>, activates
the polled-run configuration.</p>
<p class="PlainText">Once the BASIC Stamp reaches the Main routine, it will continuously print
"Waiting in Program Slot 0..." on the PC screen. In between reading the
<span class="keyword_in_text">DEBUG</span> and <span class="keyword_in_text">GOTO</span> commands, however, the BASIC Stamp will poll I/O
pin 0 and check for a high or low state. If the state of pin 0 is high,
it will do nothing and continue as normal. If the state of pin 1 is low, it
will switch execution over to the program in slot 1 (the second program is not
shown in this example). The switch to another program slot works exactly like
with the <span class="keyword_in_text">RUN</span> command; the designated program is run and the BASIC Stamp
does not "return" to the previous program (similar to a <span class="keyword_in_text">GOTO</span> command).</p>
<p class="PlainText">Note that in order for the polled-run activity to occur, the poll mode must
be set to either 3 or 4 (the two modes that activate polled-run). Also note,
that the polled-run modes, 3 and 4, are unique. As soon as the polled-run action
occurs, the mode switches to 1 (deactivated, saved) or 2 (activated, outputs),
respectively. This is so that the BASIC Stamp doesn't continuously go to the
start of the designated program slot while the polled-inputs are in the desired
poll state. Without this "one shot" feature, your program would appear to lock-up
as long as the polled-inputs are in the designated state.</p>
<p class="PlainText">After the program switch takes place, the <i>ProgramSlot</i> value is maintained.
Any future change to poll mode 3 or 4, without another <span class="keyword_in_text">POLLRUN</span> command, will
result in the previously defined program slot being used.</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>

View File

@ -0,0 +1,218 @@
<?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>POLLWAIT</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">POLLWAIT</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/PollwaitEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLWAIT Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">POLLWAIT</span> <![CDATA[ ]]><i>Duration</i></p>
<h2>Function</h2>
<p>Pause program execution, in a low-power mode, in units of <i>Duration</i> until any
polled-input pin reaches the desired poll state.
</p>
<ul>
<li value="1"><b><i>Duration</i></b> is a variable/constant/expression (0 - 8) that
specifies the duration of the low-power state. The low-power duration is
2<sup style="font-style: italic;">Duration</sup> x 18 milliseconds. The table below indicates the low-power
duration for any given <i>Duration</i>. Using 8 as the <i>Duration</i> is a special
case; the BS2p, BS2pe, and BS2px will not go into low-power mode and will
respond quicker to polled inputs.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="2" cellspacing="0" border="1">
<tr>
<td width="25%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="25%" align="center" bgcolor="#CFCFCF">BS2p</td>
<td width="25%" align="center" bgcolor="#CFCFCF">BS2pe</td>
<td width="25%" align="center" bgcolor="#CFCFCF">BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Current draw during <span class="keyword_in_text">POLLWAIT</span></td>
<td align="center">350 µA</td>
<td align="center">36 µA</td>
<td align="center">450 µA</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Response time with <i>Duration</i><br />set
to 8</td>
<td align="center">Less than 160 µs</td>
<td align="center">Less than 250 µs</td>
<td align="center">Less than 100 µs</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td align="left" colspan="3">
<ul>
<li value="1">Poll mode must be 2 or 4 and at least one polled-input must be set
to activate <span class="keyword_in_text">POLLWAIT</span><br></br>(<span class="keyword_in_text">POLLWAIT</span> will be ignored
otherwise).</li>
<li value="2">If both polled-wait and polled-run are active, the polled-run event
will occur immediately after the polled-wait detects an event.</li>
</ul>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="3">
<p colspan="3" align="center"><a href="POLLIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLIN</a>, <a href="POLLMODE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLMODE</a>, <a href="POLLOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLOUT</a>, <a href="POLLRUN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLRUN</a>, <a href="END.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">END</a>, <a href="NAP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">NAP</a>, <a href="SLEEP.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SLEEP</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">POLLWAIT</span> command is one of a family of unique "polling" commands on
the BS2p and BS2pe modules. The other commands in this family include <span class="keyword_in_text">POLLIN</span>,
<span class="keyword_in_text">POLLMODE</span>, <span class="keyword_in_text">POLLOUT</span> and <span class="keyword_in_text">POLLRUN</span>. The <span class="keyword_in_text">POLLWAIT</span> command
is used to pause program execution and go into a low-power state until any
polled-input pin reaches the desired poll state.</p>
<p class="PlainText">The "polling" commands allow the BASIC Stamp to respond to certain I/O pin
events at a faster rate than what is normally possible through manual PBASIC
programming. The term "poll" comes from the fact that the BASIC Stamp's interpreter
periodically checks the state of the designated polled-input pins. It "polls"
these pins after the end of each PBASIC instruction and before it reads the next
PBASIC instruction from the user program; giving the appearance that it is polling
"in the background". This feature should not be confused with the concept of
interrupts, as the BASIC Stamp does not support true interrupts.</p>
<p class="PlainText">The <span class="keyword_in_text">POLLWAIT</span> command is unique among the polling commands in that it
actually causes execution to halt, until a polled-input pin event occurs.
The <i>Duration</i> argument is similar to that of the <span class="keyword_in_text">NAP</span> command; using
the values 0 to 7 specifies the duration of the low-power period. After the
low-power period is over, the BASIC Stamp polls the polled-input pins and determines
if any meet the desired poll state. If no polled-input is in the desired state
(as set by <span class="keyword_in_text">POLLIN</span> command) the BASIC Stamp goes back into low-power mode,
again, for the same duration as before. If any polled-input is in the desired
state, however, the BASIC Stamp will continue execution with the next line of
code.</p>
<p class="PlainText">A <i>Duration</i> of 8 makes the BASIC Stamp pause execution in normal running
mode (not low-power mode) until a polled-input event occurs. The response time
is indicated in the table below. Since the response time is so fast, this feature
can be used to synchronize a portion of PBASIC code to an incoming pulse</p>
<center>
<table cellpadding="4" cellspacing="0" border="1">
<tr>
<td align="center" width="45" bgcolor="#CFCFCF"><i>Duration</i>
</td>
<td align="center" width="165" bgcolor="#CFCFCF">Length of Low-Power Mode</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">18 ms</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">36 ms</td>
</tr>
<tr>
<td align="center">2</td>
<td align="center">72 ms</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">144 ms</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">288 ms</td>
</tr>
<tr>
<td align="center">5</td>
<td align="center">576 ms</td>
</tr>
<tr>
<td align="center">6</td>
<td align="center">1152 ms (1.152 seconds)</td>
</tr>
<tr>
<td align="center">7</td>
<td align="center">2304 ms (2.304 seconds)</td>
</tr>
<tr>
<td align="center">8</td>
<td align="center">No power-down</td>
</tr>
</table>
</center>
<p>&#160;</p>
<p class="PlainText">The following is a simple example of the <span class="keyword_in_text">POLLWAIT</span> command.</p><pre class="BScode" xml:space="preserve">
Setup:
POLLIN 0, 0
POLLMODE 2
Main:
POLLWAIT 0
TOGGLE 1
GOTO Main
</pre>
<p class="PlainText">In this example, the <span class="keyword_in_text">POLLIN</span> command sets I/O pin 0 to be a polled-input
pin looking for a low (0) state. The Main routine immediately runs a <span class="keyword_in_text">POLLWAIT</span>command and specifies a <i>Duration</i> of 0 (with results in a low-power state of
18 ms). This means that every 18 milliseconds, the BASIC Stamp wakes-up and checks
I/O pin 0 for a low. If I/O pin 0 is high, it goes back to sleep for another 18
milliseconds. If I/O pin 0 is low, it runs the next line of code, which toggles
the state of I/O pin 1. Then the loop starts all over again. </p>
<p class="PlainText">If low-power mode is not required, change the <span class="keyword_in_text">POLLWAIT</span> command in the
example above to "<span class="code_in_text">POLLWAIT 8</span>" instead. This will have the effect of keeping
the BASIC Stamp in normal running mode (i.e., no low-power glitches) and will also
cause the <span class="keyword_in_text">TOGGLE</span> command to execute in a much shorter amount of time after
a polled-input event occurs.</p>
<p class="PlainText">Note: Due to the
nature of low-power mode, I/O pin 1 may occasionally toggle between high and low even if I/O pin 0 stays low. This is an
artifact of power conserving commands, described below.</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>
<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>

View File

@ -0,0 +1,122 @@
<?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>POT</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">POT</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" /><span class="code_in_text"> {PBASIC&#160;1.0}</span>
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/PotEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POT Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">POT</span> <![CDATA[ ]]><i>Pin</i>,<i> Scale</i>,<i> Variable</i></p>
<h2>Function</h2>
<p class="PlainText">Read a 5 kΩ to 50 kΩ potentiometer, thermistor, photocell, or other
variable resistance.</p>
<ul>
<li value="1"><b><i>Pin</i></b> is a variable/constant (0 - 7) that specifies the I/O pin
to use. This pin will be set to output mode initially, then to input mode. </li>
<li value="2"><b><i>Scale</i></b> is a variable/constant (0 - 255) used to scale the
command's internal 16-bit result. See Explanation below for steps to finding
the scale value to use for your circuit.</li>
<li value="3"><b><i>Variable</i></b> is a variable (usually a byte) where the final result
of the reading will be stored. Internally, the <span class="keyword_in_text">POT</span> command calculates
a 16-bit value, which is scaled down to an 8-bit value. </li>
</ul>
<p>Note: See <a href="RCTIME.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">RCTIME</a> for all BS2 models.</p>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">POT</span> reads a variable resistance and returns a value (0 - 255) representing
the amount of time it took to discharge the capacitor through the resistance. Pin
must be connected to one side of the variable resistance, whose other side is
connected through a capacitor to ground, as shown below. </p>
<center>
<img src="../../graphics/pot_sch.gif" border="0">
</img>
</center>
<p>&#160;</p>
<p class="PlainText"><span class="keyword_in_text">POT</span> works by first setting the specified I/O pin to an output and setting
its state high. This step places +5 volts on one side of the capacitor and ground
(0 volts) on the other side, which charges the capacitor. <span class="keyword_in_text">POT</span> will hold the
pin high for 10 milliseconds to charge the capacitor. It is important to select
component values that will allow the capacitor to charge in this period. If, for
example, a 50 kΩ potentiometer is used with a 0.1 µF cap, the maximum
charge time would be:</p>
<p class="PlainText">Charge time: 5 x (50 x 10<sup>3</sup>) x (0.1 x 10<sup>-6</sup>)
= 25 x 10<sup>-3</sup></p>
<p class="PlainText">The full charge time (5 TC) is 25 x 10<sup>-3</sup> or 25 milliseconds.
Obviously, the capacitor would never fully charge when the potentiometer is
at its maximum position. In this case, changing the capacitor to 0.01 µF
reduces the charge time to 2.5 milliseconds; well within the range of the
<span class="keyword_in_text">POT</span> function.</p>
<p class="PlainText">After the capacitor is charged the I/O pin to an input mode and <span class="keyword_in_text">POT</span>starts its timer. Initially the I/O pin will see a high (1) that will eventually
drop to a low (0) when the capacitor discharges past the 1.4-volt threshold.
The timer stops once the low is seen. The value of the variable resistor affects
the time it takes to discharge the capacitor from 5 volts to approximately 1.4
volts.</p>
<p class="PlainText">The 16-bit reading is multiplied by (<i>Scale</i> ÷ 256), so a scale
value of 128 would reduce the range by approximately 50%, a scale of 64 would
reduce to 25%, and so on. The amount by which the internal value must be scaled
varies with the size of the resistor being used.</p>
<h3>Finding the best <i>Scale</i> value: </h3>
<ol type="1">
<li value="1">Build the circuit shown above and plug the BS1 into the PC. </li>
<li value="2">Select Run | POT Scaling.<br></br> A special calibration window appears, allowing you to find the best value.</li>
<li value="3">The window asks for the number of the I/O pin to which the variable resistor
is connected. Select the appropriate pin (0 - 7).</li>
<li value="4">The editor downloads a short program to the BS1 (this overwrites any program
already stored in the BS1).</li>
<li value="5">Two numbers will be displayed: scale and value. Adjust the resistor until
the smallest number is shown for scale (assuming you can adjust the resistor,
as with a potentiometer).</li>
<li value="6">Once you've found the smallest number for scale, you're done. This number
should be used for the <i>Scale</i> in the <span class="keyword_in_text">POT</span> command.</li>
<li value="7">Optionally, you can verify the scale number found above by selecting the
POT Value checkbox. This locks the scale and causes the BS1 to read the resistor
continuously. The window displays the value. If the scale is good, you should
be able to adjust the resistor, achieving a 0-255 reading for the value (or as
close as possible). To change the scale value and repeat this step, just
uncheck the box. Continue this process until you find the best scale.</li>
</ol>
<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>

View File

@ -0,0 +1,136 @@
<?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>

View File

@ -0,0 +1,145 @@
<?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>PULSOUT</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">PULSOUT</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/PulsoutEx.htm" target="" title="" alt="" class="MCXref_0">PULSOUT Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">PULSOUT</span> <![CDATA[ ]]><i>Pin</i>,<i> Duration</i></p>
<h2>Function</h2>
<p class="PlainText">Generate a pulse on <i>Pin</i> with a width of <i>Duration</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 output mode.</li>
<li value="2"><b><i>Duration</i></b> is a variable/constant/expression* (0 - 65535) that
specifies the duration of the pulse. The unit of time for <i>Duration</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.8 µ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>52.428 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="PULSIN.htm" target="" title="" alt="" class="MCXref_0">PULSIN</a>
</p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">PULSOUT</span> sets <i>Pin</i> to output mode, inverts the state of that pin;
waits for the specified <i>Duration</i>; then inverts the state of the pin again;
returning the bit to its original state. The unit of <i>Duration</i> is described
above. The following example will generate a 100 µs pulse on I/O pin 5: </p><pre class="BScode" xml:space="preserve">
PULSOUT 5, 50 ' generate a pulse on pin 5
</pre>
<p class="PlainText">The polarity of the pulse depends on the state of the pin before the command
executes. In the example above, if pin 5 was low, <span class="keyword_in_text">PULSOUT</span> would produce
a positive pulse. If the pin was high, <span class="keyword_in_text">PULSOUT</span> would produce a negative
pulse.</p>
<p class="PlainText">If the pin is an input, the output state bit, OUT5 (PIN5 on the BS1) won't
necessarily match the state of the pin. What happens then? For example: Pin 7 is
an input (DIR7 = 0) and pulled high by a resistor as shown below. Suppose that
pin 7 is low when we execute the instruction: </p><pre class="BScode" xml:space="preserve">
PULSOUT 7, 5 ' generate a pulse on pin 7
</pre>
<p class="PlainText">The figure below shows the sequence of events on that pin. Initially, pin 7
is high. Its output driver is turned off (because it is in input mode), so the
10 kΩ resistor sets the state on the pin. When <span class="keyword_in_text">PULSOUT</span> executes, it
turns on the output driver, allowing OUT7 (PIN7 on the BS1) to control the pin.</p>
<center>
<img src="../../graphics/pulsout_sch.gif" border="0">
</img>
</center>
<p>&#160;</p>
<p class="PlainText">Since OUT7 (PIN7 on the BS1) is 0, the pin goes low when made an output. After
a few microseconds of preparation, <span class="keyword_in_text">PULSOUT</span> inverts the state of the pin;
from low to high. It leaves the pin in that state for the specified time (10µs
if using a BS2) and then inverts it again, leaving the pin in its original
(output) state. </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>

View File

@ -0,0 +1,167 @@
<?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>PUT</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">PUT</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/GetPutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GET / PUT Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">PUT</span> <![CDATA[ ]]><i>Location</i>, {<i>WORD</i>}<i> Value</i>{,<i><![CDATA[ ]]></i>{<i>WORD</i>}<i> Value ...</i>}</p>
<h2>Function</h2>
<p class="PlainText">Write one or more values to the Scratchpad RAM, starting at <i>Location</i> and
building upward.
</p>
<ul>
<li value="1"><b><i>Location</i></b> is a variable/constant/expression (0 62 for BS2e
and BS2sx, and 0 126 for BS2p, BS2pe, and BS2px) that specifies the
Scratchpad RAM location to write to.</li>
<li value="2"><b><i>Value</i></b> is a variable/constant/expression to store
in RAM.*</li>
</ul>
<p class="PlainText">*Note: The optional arguments require PBASIC 2.5.</p>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="24%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="38%" align="center" bgcolor="#CFCFCF">BS2e and BS2sx</td>
<td width="38%" align="center" bgcolor="#CFCFCF">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Scratchpad RAM size and organization</td>
<td align="center">64 bytes (0 63). Organized as bytes only.</td>
<td align="center">136 bytes (0 135). Organized as bytes only.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">General purpose locations</td>
<td align="center">0 - 62</td>
<td align="center">0 126</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special use location</td>
<td align="center">Current program slot number in read-only location 63.</td>
<td align="center">Current program slot number in lowest nibble of read-only location 127. Current read/write slot number in highest nibble of location 127. </td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Additional locations</td>
<td align="center">None</td>
<td align="center">Locations 128 - 135 (read-only) hold state of polled input pins.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center"><a href="GET.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GET</a>
</td>
<td align="center"><a href="GET.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GET</a>, <a href="STORE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">STORE</a></td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">PBASIC 2.5 Syntax Options</td>
<td align="center" colspan="2">
<p colspan="2" align="center">Multiple sequential variables may be read from the Scratchpad RAM. </p>
<p colspan="2" align="center">The optional WORD modifier may be specified to retrieve 16-bit values.</p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The <span class="keyword_in_text">PUT</span> command writes a value into the specified Scratchpad RAM location(s).
All values in the general-purpose locations can be written to from within any of
the eight program slots.</p>
<p class="PlainText">Scratchpad RAM is useful for passing data to programs in other program slots
and for additional workspace. It is different than regular RAM in that symbol
names cannot be assigned directly to locations and each location is always
configured as a byte only. The following code will write the value 100 to location
25, read it back out with <span class="keyword_in_text">GET</span> and display it:</p>
<p class="PlainText">The following example illustrates this:<br></br></p><pre class="BScode" xml:space="preserve">
temp VAR Byte
Main:
PUT 25, 100
GET 25, temp
DEBUG DEC temp
END
</pre>
<p class="PlainText">When using $PBASIC 2.5 syntax, Word-sized variables can be written to the
Scratchpad RAM with a single <span class="keyword_in_text">PUT</span> statement, as well as multiple items to
consecutive locations. The Word modifier writes the low-byte first, then the
high-byte (<i>"Little Endian"</i>).</p>
<p>
<img src="../../graphics/bsesxppepx_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
' {$PBASIC 2.5}
value VAR Word
value2 VAR Word
addr VAR Word ' EEPROM address
test VAR Byte ' test byte read back
Main:
value = $11
value2 = $2003
PUT 0, value, Word value2 ' write value to SP location 0
' and value2 to SP locations 1 &amp; 2
value = $FF ' modify variables
value2 = $FFFF
GET 0, value, Word value2 ' retrieve from Scratchpad
DEBUG HEX2 ? value ' display
DEBUG HEX4 ? value2
END
</pre>
<p class="PlainText">Most Scratchpad RAM locations are available for general use. The highest
location (63 for BS2e/BS2sx and 127 for BS2p/BS2pe) is a special, read-only,
location that always contains the number of the currently running program slot.
On the BS2p/BS2pe, the upper nibble of location 127 also contains the current
program slot that will be used for the <span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> commands.
Any values written to this location will be ignored.</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>

View File

@ -0,0 +1,201 @@
<?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>PWM</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">PWM</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/PwmEx.htm" target="" title="" alt="" class="MCXref_0">PWM Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">PWM</span> <![CDATA[ ]]><i>Pin</i>,<i> Duty</i>,<i> Duration</i></p>
<h2>Function</h2>
<p class="PlainText">Convert a digital value to analog output via pulse-width modulation.
</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 output mode initially then set to
input mode when the command finishes.</li>
<li value="2"><b><i>Duty</i></b> is a variable/constant/expression* (0 - 255) that specifies
the analog output level as a number of 256<sup>ths</sup> of 5 V (0 to 4.98 V).</li>
<li value="3"><b><i>Duration</i></b> is a variable/constant/expression* (0 - 255) that
specifies the duration of the PWM output.</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 nowrap="" width="150">&#160;</td>
<td width="12%">BS1</td>
<td width="12%">BS2 and 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>Duration</i></td>
<td>5 ms</td>
<td>1 ms</td>
<td>0.4 ms</td>
<td>0.65 ms</td>
<td>1.62 ms</td>
<td>0.4 ms</td>
</tr>
<tr align="center">
<td bgcolor="#CFCFCF">Average voltage equation</td>
<td colspan="6">Average Voltage = (<i>Duty</i> ÷ 256) x 5 volts</td>
</tr>
<tr align="center">
<td bgcolor="#CFCFCF">Require charge time (<i>Duration</i> ) equation</td>
<td colspan="6">Charge time = 5 x R x C,
<i>Duration</i> = Charge time ÷ Units in Duration</td>
</tr>
<tr align="center">
<td bgcolor="#CFCFCF">Special Notes</td>
<td colspan="6"><i>Pin</i> is set to output initially, and set to input at end</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="6">
<p colspan="6" align="center"><a href="FREQOUT.htm" target="" title="" alt="" class="MCXref_0">FREQOUT</a>, <a href="DTMFOUT.htm" target="" title="" alt="" class="MCXref_0">DTMFOUT</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">Pulse-width modulation (<span class="keyword_in_text">PWM</span>) allows the BASIC Stamp (a purely digital device)
to generate an analog voltage. The basic idea is this: If you make a pin output
high, the voltage at that pin will be close to 5 V. Output low is close to 0 V.
What if you switched the pin rapidly between high and low so that it was high half
the time and low half the time? The average voltage over time would be halfway
between 0 and 5 V (2.5 V). <span class="keyword_in_text">PWM</span> emits a burst of 1s and 0s whose ratio is
proportional to the duty value you specify.</p>
<p class="PlainText">The proportion of 1s to 0s in <span class="keyword_in_text">PWM</span> is called the duty cycle. The duty
cycle controls the analog voltage in a very direct way; the higher the duty cycle
the higher the voltage. In the case of the BASIC Stamp, the duty cycle can range
from 0 to 255. <i>Duty</i> is literally the proportion of 1s to 0s output by the
<span class="keyword_in_text">PWM</span> command. To determine the proportional <span class="keyword_in_text">PWM</span> output voltage, use
this formula: (<i>Duty</i> ÷ 256) x 5 V. For example, if <i>Duty</i>
is 100, (100 ÷ 256) x 5 V = 1.953 V; <span class="keyword_in_text">PWM</span> outputs a train of pulses
whose average voltage is 1.953 V.</p>
<p class="PlainText">In order to convert <span class="keyword_in_text">PWM</span> into an analog voltage we have to filter out the
pulses and store the average voltage. The resistor/capacitor combination shown
below will do the job. The capacitor will hold the voltage set by <span class="keyword_in_text">PWM</span> even
after the instruction has finished. How long it will hold the voltage depends on
how much current is drawn from it by external circuitry, and the internal leakage
of the capacitor. In order to hold the voltage relatively steady, a program must
periodically repeat the <span class="keyword_in_text">PWM</span> instruction to give the capacitor a fresh
charge. </p>
<p class="PlainText">Just as it takes time to discharge a capacitor, it also takes time to charge
it in the first place. The <span class="keyword_in_text">PWM</span> command lets you specify the charging time
in terms of <span class="keyword_in_text">PWM</span> duration. The timing for the units in <i>Duration</i> is
shown in in the table above. So, on the BS2, to charge a capacitor for five
milliseconds, you would specify five units in <i>Duration</i>. </p>
<p class="PlainText">How do you determine how long to charge a capacitor? Use this rule-of-thumb
formula: Charge time = 5 x R x C. For instance, the circuit below uses a 10 kΩ
(10 x 10<sup>3</sup> ohm) resistor and a 1 µF (1 x 10<sup>-6</sup> F) capacitor:</p>
<p class="PlainText">Charge time = 5 x 10 x 10<sup>3</sup> x 1 x 10<sup>-6</sup> = 50 x 10<sup>-3</sup>
seconds, or 50 milliseconds.</p>
<center>
<img src="../../graphics/pwm_sch.gif" border="0">
</img>
</center>
<p>&#160;</p>
<p class="PlainText">Since, on the BS2, each unit in <i>Duration</i> is approximately a millisecond,
it would take at least 50 units to charge the capacitor. Assuming the circuit is
connected to P0, here's the complete <span class="keyword_in_text">PWM</span> instruction: </p>
<p>
<img src="../../graphics/bs2e_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
PWM 0, 100, 50 ' Put a 1.96V charge on cap (BS2, BS2e)
</pre>
<p class="PlainText">To charge the same circuit to the same level using a BS2sx, the <i>Duration</i>would require adjustment as follows:</p>
<p>
<img src="../../graphics/bs2sx_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
PWM 0, 100, 125 ' Put a 1.96V charge on cap (BS2sx)
</pre>
<p class="PlainText">After outputting the <span class="keyword_in_text">PWM</span> pulses, the BASIC Stamp leaves the pin in input
mode (0 in the corresponding bit of DIRS). In input mode, the pin's output driver
is effectively disconnected. If it were not, the steady output state of the pin
would change the voltage on the capacitor and undo the voltage setting established
by <span class="keyword_in_text">PWM</span>. Keep in mind that leakage currents of up to 1 µA can flow into
or out of this "disconnected" pin. Over time, these small currents will cause the
voltage on the capacitor to drift. The same applies for leakage current from an
op-amp's input, as well as the capacitor's own internal leakage. Executing
<span class="keyword_in_text">PWM</span> occasionally will reset the capacitor voltage to the intended value.</p>
<p class="PlainText"><span class="keyword_in_text">PWM</span> charges the capacitor; the load presented by your circuit discharges
it. How long the charge lasts (and therefore how often your program should repeat
the <span class="keyword_in_text">PWM</span> command to refresh the charge) depends on how much current the
circuit draws, and how stable the voltage must be. You may need to buffer <span class="keyword_in_text">PWM</span>output with a simple op-amp follower if your load or stability requirements are
more than the passive circuit can handle. </p>
<p class="PlainText">The term "PWM" applies only loosely to the action of the BASIC Stamp's <span class="keyword_in_text">PWM</span>
command. Most systems that output <span class="keyword_in_text">PWM</span> do so by splitting a fixed period
of time into an on time (1) and an off time (0). Suppose the interval is 1 ms
and the duty cycle is 100 ÷ 256. Conventional <span class="keyword_in_text">PWM</span> would turn the
output on for 0.39 ms and off for 0.61 ms, repeating this process each millisecond.
The main advantage of this kind of <span class="keyword_in_text">PWM</span> is its predictability; you know the
exact frequency of the pulses (in this case, 1 kHz), and their widths are
controlled by the duty cycle. </p>
<p class="PlainText">BASIC Stamp's <span class="keyword_in_text">PWM</span> <![CDATA[ ]]><u>does not work this way</u>. It outputs a rapid
sequence of on/off pulses, as short as 1.6 µs in duration, whose overall proportion
over the course of a full <span class="keyword_in_text">PWM</span> cycle of approximately a millisecond is equal
to the duty cycle. This has the advantage of very quickly zeroing in on the desired
output voltage, but it does not produce the neat, orderly pulses that you might
expect. All BS2 modules also uses this high-speed <span class="keyword_in_text">PWM</span>technique to generate pseudo-sine wave tones with the
<a href="DTMFOUT.htm" target="" title="" alt="" class="MCXref_0">DTMFOUT</a> and <a href="FREQOUT.htm" target="" title="" alt="" class="MCXref_0">FREQOUT</a>
instructions. </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>

View File

@ -0,0 +1,146 @@
<?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>RANDOM</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">RANDOM</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/RandomEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">RANDOM Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">RANDOM</span> <![CDATA[ ]]><i>Variable</i></p>
<h2>Function</h2>
<p class="PlainText">Generate a pseudo-random number.
</p>
<ul>
<li value="1"><b><i>Variable</i></b> is a variable (usually a word) whose bits will be
scrambled to produce a random number. <i>Variable</i> acts as <span class="keyword_in_text">RANDOM</span>'s
input and its result output. Each pass through <span class="keyword_in_text">RANDOM</span> stores the next
number, in the pseudo-random sequence, in <i>Variable</i>.</li>
</ul>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">RANDOM</span> generates pseudo-random numbers ranging from 0 to 65535. They're
called "pseudo-random" because they appear random, but are generated by a logic
operation that uses the initial value in <i>Variable</i> to "tap" into a sequence
of 65535 essentially random numbers. If the same initial value, called the "seed",
is always used, then the same sequence of numbers is generated. The following
example demonstrates this:</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL result = W1
Main:
result = 11000 ' set initial "seed" value
RANDOM result ' generate random number
DEBUG result ' show the result on screen
GOTO Main
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
result VAR Word
Main:
result = 11000 ' set initial "seed" value
RANDOM result ' generate random number
DEBUG DEC ? result ' show the result on screen
GOTO Main
</pre>
<p class="PlainText">In this example, the same number would appear on the screen over and over again.
This is because the same seed value was used each time; specifically, the first
line of the loop sets result to 11000. The <span class="keyword_in_text">RANDOM</span> command really needs
a different seed value each time. Moving the "Result =" line out of the loop will
solve this problem, as in:</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL result = W1
Setup:
result = 11000 ' set initial "seed" value
Main:
RANDOM result ' generate random number
DEBUG result ' show the result on screen
GOTO Main
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
result VAR Word
Setup:
result = 11000 ' set initial "seed" value
Main:
RANDOM result ' generate random number
DEBUG DEC ? result ' show the result on screen
GOTO Main
END
</pre>
<p class="PlainText">Here, result is only initialized once, before the loop. Each time through the
loop, the previous value of result, generated by <span class="keyword_in_text">RANDOM</span>, is used as the
next seed value. This generates a more desirable set of pseudo-random numbers.</p>
<p class="PlainText">In applications requiring more apparent randomness, it's necessary to "seed"
<span class="keyword_in_text">RANDOM</span> with a more random value every time. For instance, in the
example program, <span class="keyword_in_text">RANDOM</span> is executed continuously
(using the previous resulting number as the next seed value) while the program
waits for the user to press a button. Since the user can't control the timing of
button presses very accurately, the results approach true randomness. </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>

View File

@ -0,0 +1,182 @@
<?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>RCTIME</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">RCTIME</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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>&#160;</p>
<p style="text-align: right;"><a href="../ExampleTopics/RctimeEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">RCTIME Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">RCTIME</span> <![CDATA[ ]]><i>Pin</i>,<i> State</i>,<i> Variable</i></p>
<h2>Function</h2>
<p class="PlainText">Measure time while <i>Pin</i> remains in <i>State</i>; usually to measure the
charge/discharge time of resistor/capacitor (RC) circuit..
</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 placed into input mode.</li>
<li value="2"><b><i>State</i></b> is a variable/constant/expression (0 - 1) that specifies
the desired state to measure. Once <i>Pin</i> is not in <i>State</i>, the
command ends and stores the result in <i>Variable</i>.</li>
<li value="3"><b><i>Variable</i></b> is a variable (usually a word) in which the time
measurement will be stored. The unit of time for <i>Variable</i> is described
below.</li>
</ul>
<p>Note: See <a href="POT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POT</a> for the BS1.</p>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center">
<td nowrap="" width="150">&#160;</td>
<td width="23%">BS2, BS2e, and BS2pe</td>
<td width="23%">BS2sx</td>
<td width="23%">BS2p</td>
<td width="23%">BS2px</td>
</tr>
<tr align="center">
<td bgcolor="#CFCFCF">Units in <i>Variable</i></td>
<td>2 µs</td>
<td>0.8 µs</td>
<td>0.75 µs</td>
<td>0.75 µs</td>
</tr>
<tr align="center">
<td bgcolor="#CFCFCF"><i>Maximum pulse width</i>
</td>
<td>131.07 ms</td>
<td>52.428 ms</td>
<td>49.151 ms</td>
<td>49.151 ms</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">RCTIME</span> can be used to measure the charge or discharge time of a
resistor/capacitor circuit. This allows you to measure resistance or capacitance;
use R or C sensors such as thermistors or capacitive humidity sensors or respond
to user input through a potentiometer. In a broader sense, <span class="keyword_in_text">RCTIME</span> can also
serve as a fast, precise stopwatch for events of very short duration. </p>
<p class="PlainText">When <span class="keyword_in_text">RCTIME</span> executes, it starts a counter (who's unit of time is shown
above). It stops this counter as soon as the specified pin is no longer in
<i>State</i> (0 or 1). If pin is not in <i>State</i> when the instruction executes,
<span class="keyword_in_text">RCTIME</span> will return 1 in <i>Variable</i>, since the instruction requires one
timing cycle to discover this fact. If pin remains in <i>State</i> longer than
65535 timing cycles <span class="keyword_in_text">RCTIME</span> returns 0. </p>
<p class="PlainText">The figure below shows suitable RC circuits for use with <span class="keyword_in_text">RCTIME</span>. Circuits
A are preferred, because the BASIC Stamp's logic threshold is approximately 1.4
volts. This means that the voltage seen by the pin will start at 5V then fall
to 1.4V (a span of 3.6V) before <span class="keyword_in_text">RCTIME</span> stops. With Circuit B, the voltage
will start at 0V and rise to 1.4V (spanning only 1.4V) before <span class="keyword_in_text">RCTIME</span> stops.
For the same combination of R and C, Circuits A will yield a higher count, and
therefore more resolution than Circuit B. </p>
<center>
<img src="../../graphics/rctime_sch_new.gif" border="0">
</img>
</center>
<p>&#160;</p>
<p class="PlainText">Before <span class="keyword_in_text">RCTIME</span> executes, the capacitor must be put into the state
specified in the <span class="keyword_in_text">RCTIME</span> instruction. For example, with Circuit A, the
capacitor must be charged until the top plate at 5V.</p>
<p class="PlainText">Here's a typical sequence of instructions for Circuit A (assuming I/O pin
7 is used):</p><pre class="BScode" xml:space="preserve">
result VAR Word
Test:
HIGH 7 ' charge the cap
PAUSE 1 ' for 1 ms
RCTIME 7, 1, result ' measure RC discharge time
DEBUG DEC ? result ' display result
END
</pre>
<p class="PlainText">Using <span class="keyword_in_text">RCTIME</span> is very straightforward, except for one detail: For a given
R and C, what value will <span class="keyword_in_text">RCTIME</span> return? It's easy to figure, based on a
value called the RC time constant, or tau (τ) for short. Tau represents the time
required for a given RC combination to charge or discharge by 63 percent of the
total change in voltage that they will undergo. More importantly, the value t is
used in the generalized RC timing calculation. Tau's formula is just R multiplied
by C: </p>
<p class="PlainText">τ = R x C</p>
<p class="PlainText">The general RC timing formula uses τ to tell us the time required for an RC
circuit to change from one voltage to another: </p>
<p class="PlainText">time = -τ x ( ln(V<sub>final</sub> / V<sub>initial</sub>) )</p>
<p class="PlainText">In this formula ln is the natural logarithm; it's a key on most scientific
calculators. Let's do some math. Assume we're interested in a 10 kΩ
resistor and 0.1 µF capacitor. Calculate τ: </p>
<p class="PlainText">τ = (10 x 10<sup>3</sup>) x (0.1 x 10<sup>-6</sup>) = 1 x 10<sup>-3</sup></p>
<p class="PlainText">The RC time constant is 1 x 10<sup>-3</sup> or 1 millisecond. Now calculate
the time required for this RC circuit to go from 5V to 1.4V (as in Circuit A): </p>
<p class="PlainText">Time = -1 x 10<sup>-3</sup> x ( ln(1.4v ÷ 5.0v) ) =
1.273 x 10<sup>-3</sup></p>
<p class="PlainText">On the BS2, the unit of time is 2 µs, that time (1.273 x 10<sup>-3</sup>) works
out to about 635 units. With a 10 kΩ resistor and 0.1 µF capacitor,
<span class="keyword_in_text">RCTIME</span> would return a value of approximately 635. Since V<sub>initial</sub>and V<sub>final</sub> doesn't change, we can use a simplified rule of thumb to
estimate <span class="keyword_in_text">RCTIME</span> results for Circuit A: </p>
<p class="PlainText"><span class="keyword_in_text">RCTIME</span> units = 635 x R (in kΩ) x C (in µF)</p>
<p class="PlainText">Another handy rule of thumb can help you calculate how long to charge/discharge
the capacitor before <span class="keyword_in_text">RCTIME</span>. In the example above that's the purpose of the
<span class="keyword_in_text">HIGH</span> and <span class="keyword_in_text">PAUSE</span> commands. A given RC charges or discharges 98 percent
of the way in five time constants (5 x R x C). In Circuits A and B, the
charge/discharge current passes through the 220 Ω series resistor and the
capacitor. So if the capacitor were 0.1 µF, the minimum charge/discharge time
should be: </p>
<p class="PlainText">Charge time = 5 x 220 x (0.1 x 10<sup>-6</sup>) = 110 x 10<sup>-6</sup></p>
<p class="PlainText">So it takes only 110 µs for the capacitor to charge/discharge, meaning that the
one millisecond charge/discharge time of the example is plenty. </p>
<p class="PlainText">A final note about the circuits above: You may be wondering why the 220 Ω
resistor is necessary at all. Consider what would happen if resistor R was a
potentiometer, and were adjusted to 0 Ω. When the I/O pin went high to
discharge the capacitor, it would see a short direct to ground. The 220 Ω
series resistor would limit the short circuit current to 5V ÷ 220 Ω
= 23 mA and protect the BASIC Stamp from damage. (Actual current would be quite
a bit less due to internal resistance of the pin's output driver, but you get
the idea.)</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>

View File

@ -0,0 +1,227 @@
<?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>READ</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">READ</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/ReadEx.htm" target="" title="" alt="" class="MCXref_0">READ Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax <img align="absmiddle" src="../../graphics/mini_1.gif" />:
<span class="keyword_in_text">READ</span><i>Location</i>,<i> Variable</i><br />Syntax <img align="absmiddle" src="../../graphics/mini_2.gif" />:
<span class="keyword_in_text">READ</span><i>Location, </i>{WORD}<i> Variable </i>{, {WORD}<i> Variable</i>, ...}</p>
<h2>Function</h2>
<ul>
<li value="1"><b><i>Location</i></b> Location is a variable/constant/expression*
(0 - 255 on BS1, 0 - 2047 on all other BASIC Stamp models) that specifies the
EEPROM address to read from.</li>
<li value="2"><b><i>Variable</i></b> is a variable (usually a byte) where the value
is stored.*</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>
<p class="PlainText">*Note: The optional arguments require PBASIC 2.5.</p>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="19%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="27%" align="center" bgcolor="#CFCFCF">BS1</td>
<td width="27%" align="center" bgcolor="#CFCFCF">BS2, BS2e, and BS2sx</td>
<td width="27%" align="center" bgcolor="#CFCFCF">BS2p, BS2pe, and BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Range of EEPROM locations</td>
<td align="center">0 to 255</td>
<td align="center">0 to 2047</td>
<td align="center">0 to 2047<br></br>(see notes below)</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td align="center">n/a</td>
<td align="center"><span class="keyword_in_text">READ</span> only works with current program slot on
BS2e and BS2sx.</td>
<td align="center"><span class="keyword_in_text">READ</span> works with any program slot as set by the
<span class="keyword_in_text">STORE</span> command.</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1"><a href="WRITE.htm" target="" title="" alt="" class="MCXref_0">WRITE</a>, <a href="EEPROM.htm" target="" title="" alt="" class="MCXref_0">EEPROM</a></td>
<td align="center">
<p colspan="1" align="center"><a href="WRITE.htm" target="" title="" alt="" class="MCXref_0">WRITE</a>, <a href="DATA.htm" target="" title="" alt="" class="MCXref_0">DATA</a></p>
</td>
<td align="center">
<p colspan="1" align="center"><a href="WRITE.htm" target="" title="" alt="" class="MCXref_0">WRITE</a>, <a href="DATA.htm" target="" title="" alt="" class="MCXref_0">DATA</a>, <a href="STORE.htm" target="" title="" alt="" class="MCXref_0">STORE</a></p>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">PBASIC 2.5 Syntax Options</td>
<td align="center" colspan="1">
<p colspan="1" align="center">n/a</p>
</td>
<td align="center" colspan="2">
<p colspan="2" align="center">Multiple sequential variables may be read from the Scratchpad RAM, and the optional WORD modifier may be specified to retrieve 16-bit values.</p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText">The EEPROM is used for both program storage (which builds downward from address
255 on BS1, 2047 on all other BASIC Stamp models) and data storage (which builds upward
from address 0). The <span class="keyword_in_text">READ</span> instruction retrieves a value from any
EEPROM address and stores it in <i>Variable</i>. When the optional Word modifier
($PBASIC 2.5 required) is used, the low byte of <i>Variable</i> is read from
<i>Location</i>, the high byte of <i>Variable</i> from <i>Location + 1.</i></p>
<p class="PlainText">Any location within the EEPROM can be read (including your PBASIC program's
tokens) at run-time. This feature is mainly used to retrieve long-term data from
EEPROM; data stored in EEPROM is not lost when the power is removed.</p>
<p class="PlainText">The following <span class="keyword_in_text">READ</span> command retrieves the value at location 100 and
stores it into the variable called <i>Result</i>:</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL result = B2
Main:
READ 100, result
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
result VAR Byte
Main:
READ 100, result
END
</pre>
<p class="PlainText">The EEPROM is organized as a sequential set of byte-sized memory locations. The READ command retrieves byte-sized values from EEPROM. This does not mean that you can't read word-sized values, however. A word consists of two bytes, called a low-byte and a high-byte. If you wanted to read a word-sized value, you can use two READ commands and a word-size variable (along with some handy modifiers). For example:</p>
<p>
<img src="../../graphics/bs1_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
SYMBOL result = W1 ' word-sized variable
SYMBOL resLo = B2 ' low-byte of W1
SYMBOL resHi = B3 ' high-byte of W1
EEPROM (101, 4) ' Store word-sized value
Main:
READ 0, resLo
READ 1, resHi
DEBUG #result
END
</pre>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
result VAR Word
DATA Word 1125 ' Store word-sized value
Main:
READ 0, result.LowByte
READ 1, result.HighByte
DEBUG DEC ? result
END
</pre>
<p class="PlainText">This code uses the <b>EEPROM</b> or <span class="keyword_in_text">DATA</span> directive to write the low-byte
and high-byte of the number 1125 into locations 0 and 1 during download. When the
program runs, the two <span class="keyword_in_text">READ</span> commands will read the low-byte and high-byte
out of EEPROM (reconstructing it in a word-size variable) and then display the
value on the screen.</p>
<p class="PlainText">When using $PBASIC 2.5 syntax, word-sized variables can be retrieved with a single
<span class="keyword_in_text">READ</span> statement, as well as multiple items from consecutive locations.</p>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p><pre class="BScode" xml:space="preserve">
' {$PBASIC 2.5}
idNum VAR Word
score VAR Byte
ID_Rec DATA Word 1125, 75 ' Store multiple items
Main:
READ ID_Rec, Word idNum, score ' Read multiple variables
DEBUG DEC ? idNum ' Display them
DEBUG DEC ? score
END
</pre>
<p class="PlainText">Note that the <span class="keyword_in_text">EEPROM</span> and <span class="keyword_in_text">DATA</span> directives store data in the EEPROM
before the program runs, however, the <span class="keyword_in_text">WRITE</span> command can be used to store
data while the program is running. Additionally, the EEPROM locations can be read
an unlimited number of times, but EEPROM locations can be worn out by excessive
writes. See the <a href="WRITE.htm" target="" title="" alt="" class="MCXref_0">WRITE</a> command for more information.</p>
<p class="PlainText">When using the <span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> commands, take care to ensure that
your program doesn't overwrite itself. On the BS1, location 255 holds the address
of the last instruction in your program. Therefore, your program can use any space
below the address given in location 255. For example, if location 255 holds the
value 100, then your program can use locations 0-99 for data.</p>
<p>
<img src="../../graphics/bs2all_inline.gif" border="0">
</img>
</p>
<p class="PlainText">On other BASIC Stamp models, you'll need to view the Memory Map of the program before
you download it, to determine the last EEPROM location used.</p>
<p>
<img src="../../graphics/bs2ppepx_inline.gif" border="0">
</img>
</p>
<p class="PlainText">On the BS2p, BS2pe, and BS2px the <span class="keyword_in_text">READ</span> and <span class="keyword_in_text">WRITE</span> commands can
affect locations in any program slot as set by the <span class="keyword_in_text">STORE</span> command. See the
<a href="STORE.htm" target="" title="" alt="" class="MCXref_0">STORE</a> command for more information.</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>

View File

@ -0,0 +1,120 @@
<?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>RETURN</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">RETURN</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/ReturnEx.htm" target="" title="" alt="" class="MCXref_0">RETURN Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">RETURN</span></p>
<h2>Function</h2>
<p class="PlainText">Return from a subroutine, assuming there was a previous <span class="keyword_in_text">GOSUB</span> or
<span class="keyword_in_text">ON...GOSUB</span> executed.
</p>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="30%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="35%" align="center" bgcolor="#CFCFCF">BS1</td>
<td width="35%" align="center" bgcolor="#CFCFCF">All BS2 Models</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center">
<p align="center"><a href="GOSUB.htm" target="" title="" alt="" class="MCXref_0">GOSUB</a>
</p>
</td>
<td align="center">
<p align="center"><a href="GOSUB.htm" target="" title="" alt="" class="MCXref_0">GOSUB</a>, <a href="ON_GOSUB.htm" target="" title="" alt="" class="MCXref_0">ON...GOSUB</a></p>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Maximum number of <span class="keyword_in_text">RETURN</span>s per
program</td>
<td align="center" colspan="2">Unlimited. However, the number of <span class="keyword_in_text">GOSUB</span>s is limited.
See <a href="GOSUB.htm" target="" title="" alt="" class="MCXref_0">GOSUB</a> for more information.</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">RETURN</span> sends the program back to the address (instruction) immediately
following the most recent <span class="keyword_in_text">GOSUB</span>. If <span class="keyword_in_text">RETURN</span> is executed without a
prior <span class="keyword_in_text">GOSUB</span>, the BASIC Stamp will return to the first executable line of
the program; usually resulting in a logical bug in the code. See the <span class="keyword_in_text">GOSUB</span>command for more information.</p>
<p class="PlainText">
<img src="../../graphics/bs1note.gif" style="vertical-align: super;" /> Note: On the BS1, a <span class="keyword_in_text">RETURN</span> without a <span class="keyword_in_text">GOSUB</span> will
return the program to the last <span class="keyword_in_text">GOSUB</span> (or will end the program if
no <span class="keyword_in_text">GOSUB</span> was executed)</p>
<p class="PlainText">The example below will start out by <span class="keyword_in_text">GOSUB</span>-ing to the section of code beginning with the label Hello. It will print "Hello my friend." on the screen then <span class="keyword_in_text">RETURN</span> to the line after the <span class="keyword_in_text">GOSUB</span>, which prints "How are you?" and <span class="keyword_in_text">END</span>s.</p><pre class="BScode" xml:space="preserve">
Main:
GOSUB Hello
DEBUG "How are you?", CR
END
Hello:
DEBUG "Hello my friend.", CR
RETURN
</pre>
<h3>Watch Out For Subroutines That Your Program Can "Fall Into"</h3>
<p class="PlainText">There's another interesting lesson here; what would happen if we removed the
<span class="keyword_in_text">END</span> command from this example? Since the BASIC Stamp reads the code from
left to right, top to bottom (like the English language) once it had returned
to and run the "How are you?" line, it would naturally "fall into" the Hello
routine again. Additionally, at the end of the Hello routine, it would see the
<span class="keyword_in_text">RETURN</span> again (although it didn't <span class="keyword_in_text">GOSUB</span> to that routine this time)
and because there wasn't a previous place to return to, the BASIC Stamp will start
the entire program over again. This would cause an endless loop. The important
thing to remember here is to always make sure your program doesn't allow itself
to "fall into" a subroutine.</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>

View File

@ -0,0 +1,101 @@
<?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>REVERSE</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">REVERSE</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/ReverseEx.htm" target="" title="" alt="" class="MCXref_0">REVERSE Examples</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">REVERSE</span> <![CDATA[ ]]><i>Pin</i></p>
<h2>Function</h2>
<p class="PlainText">Reverse the data direction of the specified pin.
</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 placed into the mode opposite of its current
input/output mode.</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 cellpadding="4" cellspacing="0" border="1" style="caption-side: top;width: 100%;">
<col />
<col />
<tr bgcolor="#CFCFCF">
<td width="15%" align="center">&#160;</td>
<td width="85%" align="center">BS1 and all BS2 models</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td>
<p align="center"><a href="HIGH.htm" target="" title="" alt="" class="MCXref_0">HIGH</a>, <a href="TOGGLE.htm" target="" title="" alt="" class="MCXref_0">TOGGLE</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">Reverse</span> is convenient way to switch the I/O direction of a pin. If the pin
is an input, <span class="keyword_in_text">Reverse</span> makes it an output; if it's an output, <span class="keyword_in_text">Reverse</span>makes it an input.</p>
<p class="PlainText">Remember that "input" really has two meanings: (1) Setting a pin to input
makes it possible to check the state (1 or 0) of external circuitry connected
to that pin. The current state is in the corresponding bit of the INS register
(PINS on the BS1). (2) Setting a pin to input also disconnects the output
driver, the corresponding bit of OUTS (PINS on the BS1).</p>
<p class="PlainText">The example programs illustrate this second fact
with a two-tone LED blinker, using the circuit below:</p>
<p>&#160;</p>
<p style="text-align: center;">
<img src="../../graphics/reverse_sch.gif" />
</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>

View File

@ -0,0 +1,194 @@
<?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>RUN</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">RUN</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<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/RunEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">RUN Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">RUN</span> <![CDATA[ ]]><i>ProgramSlot</i></p>
<h2>Function</h2>
<p class="PlainText">Switches execution to another BASIC Stamp program (in a different program slot).
</p>
<ul>
<li value="1"><b><i>ProgramSlot</i></b> is a variable/constant/expression (0 7) that
specifies the program slot to run.</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="20%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2e</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2sx</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2p</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2pe</td>
<td width="16%" align="center" bgcolor="#CFCFCF">BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Number of program slots</td>
<td colspan="5" align="center">8 (numbered 0 to 7) <sup></sup></td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Time delay to switch between program slots</td>
<td align="center">770 µs</td>
<td align="center">300 µs</td>
<td align="center">250 µs</td>
<td align="center">736 µs</td>
<td align="center">195 µs</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="2">
<p colspan="2" align="center">n/a</p>
</td>
<td align="center" colspan="3">
<p colspan="3" align="center"><a href="POLLRUN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLRUN</a>
</p>
</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
<td colspan="5" align="center"><span class="keyword_in_text">RUN</span> is similar to a <span class="keyword_in_text">GOTO</span>...you can not "return" from a <span class="keyword_in_text">RUN</span></td>
</tr>
</table>
<p><sup></sup>The BS2pe has 16 slots, but only slots 0 - 7 are available for programs. Slots 8 - 15 may be used for data storage.</p>
<h2>Explanation</h2>
<p class="PlainText">The BS2e, BS2sx, BS2p, and BS2px have a total of 16 kilobytes of code space; the BS2pe
has 16 kilobytes of code space and an additional 16 kilobytes of data space. This
EEPROM space is organized into slots of 2 kilobytes (2048 bytes) each. Up to eight
different programs can be downloaded to the BASIC Stamp (one program per slot).
When the BASIC Stamp powers up, or is reset, the program in slot 0 is executed.</p>
<p class="PlainText">The <span class="keyword_in_text">RUN</span> command allows you to activate another program and causes
the BASIC Stamp to stay in the newly activated program until it receives
another <span class="keyword_in_text">RUN</span> command, or until a power-down or reset condition occurs.
The <span class="keyword_in_text">RUN</span> command is similar to a <span class="keyword_in_text">GOTO</span> command in that it allows you
to "goto" another program. Normally a master-type program will be used
in program slot 0 (since slot 0 runs first) and will control initial execution
of the other programs.</p>
<p class="PlainText">Look at the following example (there are two programs here, make sure to
download them into program slots 0 and 1, respectively). See the special use of the <a href="../Reference/Directives.htm">$STAMP</a>&#160;directive in <a href="../Reference/Directives.htm#Defining">Defining Multi-File Projects</a> for more information.
</p>
<p class="PlainText">Download the following two lines into program slot 0:</p><pre class="BScode" xml:space="preserve">
DEBUG "Hello "
&#160;RUN 1
</pre>
<p class="PlainText">Download the following three lines into program slot 1:</p><pre class="BScode" xml:space="preserve">
DEBUG "World!", CR
&#160;PAUSE 1000
&#160;RUN 0
</pre>
<p class="PlainText">The above two programs (assuming they have been downloaded into program slots 0 and 1, respectively) will display "Hello World!" on the screen. Program 0 is the first to run and it displays "Hello ", then issues a <span class="code_in_text">RUN 1</span> command. The BASIC Stamp then starts execution of program 1, from its first line of code, which causes "World!" to be displayed. Program 1 then pauses for one second and the runs program 0 again.</p>
<h3>What Happens To I/O Pins And RAM When Using RUN?</h3>
<p class="PlainText">The I/O pins retain their current state (directions and output latches) and
all Variable and Scratchpad RAM locations retain their current data
during a transition between programs with the RUN command. If sharing
data between programs within Variable RAM, make sure to keep similar
variable declarations (defined in the same order) in all programs so that
the variables align themselves on the proper word, byte, nibble and bit
boundaries across programs. The following programs illustrate what happens
with mismatched variable declarations:</p><pre class="BScode" xml:space="preserve">
' Download this program to Slot 0
cats VAR Byte
dogs VAR Byte
Setup:
cats = 3
dogs = 1
Main:
DEBUG "In Slot 0", CR
DEBUG ? cats
DEBUG ? dogs
RUN 1
</pre><pre class="BScode" xml:space="preserve">
' Download this program to Slot 1
cats VAR Byte
dogs VAR Byte
fleas VAR Word
Main:
DEBUG "In Slot 1", CR
DEBUG ? cats
DEBUG ? dogs
DEBUG ? fleas
END
</pre>
<p class="PlainText">When the Slot 1 program runs you may be surprised to see that cats and dogs
are now zero and fleas are up to 259! - even though we didn't explicitly define
them. What happened? The key to remember is that variable names are simply
pointers to RAM addresses, and the PBASIC compiler assigns variable names to RAM
in descending order by size. This means that in the Slot 1 program, fleas was
assigned to RAM locations 0 and 1 which are holding the values 3 and 1
respectively. Since words are stored low-byte first, the value 259 for fleas
makes sense (3 + (1 * 256)).</p>
<p class="PlainText">Any program number specified above 7 will wrap around and result in
running one of the 8 programs (RUN 8 will run program 0, RUN 9 will run
program 1, etc). The current program slot can be read from the last byte of the
Scratchpad RAM. Example:</p><pre class="BScode" xml:space="preserve">
#SELECT $STAMP
#CASE BS2
pgmSlot = 0 ' everything in slot 0
rwSlot = 0
#CASE BS2E, BS2SX
READ 63, pgmSlot ' read current slot
rwSlot = pgmSlot ' READ/WRITE slot is same
#CASE BS2P, BS2PE, BS2PX
READ 127, pgmSlot ' get slot control byte
rwSlot = rwSlot.HIGHNIB ' READ/WRITE in high nibble
pgmSlot = pgmSlot.LOWNIB ' pgm slot in low nibble
#ENDSELECT
</pre>
<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>

View File

@ -0,0 +1,168 @@
<?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>SELECT...CASE</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">SELECT...CASE</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p class="PlainText">
<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" /><span class="code_in_text"> {PBASIC&#160;2.5}</span>
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/SelectCaseEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SELECT...CASE Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <br></br><br></br>&#160; &#160;<span class="keyword_in_text">SELECT</span> <![CDATA[ ]]><i>Expression</i><br></br>&#160; &#160; &#160;<span class="keyword_in_text">CASE</span> <![CDATA[ ]]><i>Condition(s)</i><br></br>&#160; &#160; &#160; &#160;<i>Statement(s)</i><br></br>&#160; &#160;{ <span class="keyword_in_text">CASE</span> <![CDATA[ ]]><i>Condition(s)</i><br></br>&#160; &#160; &#160; &#160;<i>Statement(s)</i><br></br>&#160; &#160; &#160;<span class="keyword_in_text">CASE ELSE</span><br></br>&#160; &#160; &#160; &#160;<i>Statement(s)</i> }<br></br>&#160; &#160;<span class="keyword_in_text">ENDSELECT</span></p>
<h2>Function</h2>
<p class="PlainText">Evaluate <i>Expression</i> and then conditionally execute a block of code based
on comparison to <i>Condition(s)</i>. After executing a block of code the
program continues at the line that follows <span class="keyword_in_text">ENDSELECT</span>. If no conditions
are found True and a <span class="keyword_in_text">CASE ELSE</span> block is included, the <span class="keyword_in_text">CASE ELSE</span>
code statements will execute. </p>
<ul>
<li value="1"><b><i>Expression</i></b> is a variable, a constant or an expression.</li>
<li value="2"><b><i>Condition</i></b> is a statement, that can be evaluated as True or
False. The <i>Condition</i> can be a very simple or very complex
relationship, as described below. Multiple conditions within the same
<span class="keyword_in_text">CASE</span> can be separated by commas ( , ).</li>
<li value="3"><b><i>Statement(s)</i></b> is any valid PBASIC statement or statements.
Multiple statements may be placed on the same line (though not recommended)
by separating each statement with a colon ( : ).</li>
</ul>
<h2>Quick Facts</h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="20%" align="center" bgcolor="#CFCFCF">&#160;</td>
<td width="80%" align="center" bgcolor="#CFCFCF">BS2 Family</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Comparison operators</td>
<td align="center">= (assumed if no operator), &lt;&gt;, &gt;, &lt;, &gt;=,
&lt;=</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Conditional Logic Operators</td>
<td align="center">NOT, AND, OR, XOR</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF"><i>Condition</i> format</td>
<td align="center">condition_op <i>value</i> &#160; or &#160;
<i>value1</i> TO <i>value2</i></td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Parentheses</td>
<td align="center">Allowed</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Nesting</td>
<td align="center">Up to 16 levels</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="1">
<p colspan="1" align="center"><a href="IF_THEN_ELSE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">IF…THEN…ELSE</a>, <a href="ON_GOSUB.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">ON...GOSUB</a>, <a href="BRANCH.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">BRANCH</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">SELECT...CASE</span> is an advanced decision-making structure and is often used
to replace compound <span class="keyword_in_text">IF...THEN...ELSE</span> structures. The available comparison
operators are:</p>
<center>
<table cellpadding="4" cellspacing="0" border="1">
<tr>
<td width="130" align="center" bgcolor="#CFCFCF">Comparison Operator Symbol</td>
<td width="170" align="center" bgcolor="#CFCFCF">Definition</td>
</tr>
<tr>
<td align="center">=</td>
<td align="center">Equal (assumed)</td>
</tr>
<tr>
<td align="center">&lt;&gt;</td>
<td align="center">Not Equal</td>
</tr>
<tr>
<td align="center">&gt;</td>
<td align="center">Greater Than</td>
</tr>
<tr>
<td align="center">&lt;</td>
<td align="center">Less Than</td>
</tr>
<tr>
<td align="center">&gt;=</td>
<td align="center">Greater Than or Equal To</td>
</tr>
<tr>
<td align="center">&lt;=</td>
<td align="center">Less Than or Equal To</td>
</tr>
</table>
</center>
<p>&#160;</p>
<p class="PlainText">Example:</p><pre class="BScode" xml:space="preserve">
SELECT irCmd
CASE 0 TO 3
HIGH irCmd ' enable selected output
FREQOUT Spkr, 50, 880 ' beep
CASE AllOff, Mute
OutA = %0000 ' all outputs off
CASE ELSE ' invalid command
DEBUG "Bad Command", CR
ENDSELECT
</pre>
<p class="PlainText">Here, the BASIC Stamp will examine the value of variable irCmd. If irCmd is
between zero and three (inclusive), the associated output (P0 .. P3) will be
made high and and the speaker will beep. If irCmd is equal to either AllOff or
Mute (constants), then outputs P0 - P3 will be made low. On any other value of
irCmd, a message will be displayed that indicates an invalid command.</p>
<p class="PlainText">See <a href="IF_THEN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">IF…THEN</a> for additional details on the use of
comparison and conditional operators.</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>

Some files were not shown because too many files have changed in this diff Show More