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

138 lines
8.3 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
<head><title>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>